admin管理员组

文章数量:1391987

I want to add a dashboard widget that will provide a support form for the clients of my custom theme. Inside the widget I want also to add some links to support files that I'm thinking to embed inside the widget itself. If I create some .php files or .html I can link them inside the dashboard widget as a link and if the user clicks on one of them will get the information he need?

I want to add a dashboard widget that will provide a support form for the clients of my custom theme. Inside the widget I want also to add some links to support files that I'm thinking to embed inside the widget itself. If I create some .php files or .html I can link them inside the dashboard widget as a link and if the user clicks on one of them will get the information he need?

Share Improve this question asked Mar 9, 2020 at 17:33 sialfasialfa 32910 silver badges29 bronze badges 3
  • Hello! I'm not sure what your specific question is, are you asking if this can be done? How to add a dashboard widget? Build a client support form? Narrow your question down so it can be answered, with a clearly stated specific question. Remember, problems are made to be broken down, and you can more questions on the site for each piece – Tom J Nowell Commented Mar 9, 2020 at 18:47
  • Hi @TomJNowell ! I need to understand if I can create a docs folder inside the theme /plugin directory where I will add the dashboard widget and then use that folder to store some html or php files to display in modal or Iframe if the users needs support for the custom themes I build for them. I'm not sure about this, because wordpress has it's own way to work so I don't think that this can be done? – sialfa Commented Mar 9, 2020 at 19:11
  • I would advise against it, I don't believe it's necessary, and it's not something I've seen documentation plugins do – Tom J Nowell Commented Mar 9, 2020 at 19:16
Add a comment  | 

1 Answer 1

Reset to default 0

Yes, you can link directly from the dashboard to files within a plugin or theme directory. There are PHP and WP functions you can use to make sure you're targeting the correct directory:

Themes:

Let's say you have example/wp-content/themes/wpse-theme/example.html, and "wpse-theme" is either the only theme, or the parent theme. You can link to this using:

<a href="<?php echo get_template_directory_uri() . '/example.html'; ?>">Example 1</a>

Or, let's say you have that same example/wp-content/themes/wpse-theme/example.html but "wpse-theme" is a child theme. You would use this instead:

<a href="<?php echo get_stylesheet_directory_uri() . '/example.html'; ?>">Example 1</a>

(The only difference is whether you're calling the "template" directory (parent theme) or "stylesheet" directory (child theme).)

Plugins:

Let's say you have example/wp-content/plugins/wpse-plugin/example.html. You can link to this using:

<a href="<?php echo __DIR__; ?>/example.html">Example 1</a>

However, this would mean that you're saving static information on individual client websites. Typically, it's more common for themes and plugins link to a single support site instead, so that clients are always seeing the latest information and they're not holding copies of potentially outdated information. There are also a variety of help plugins available, so you might want to look into those if you'd like to use something that already exists.

本文标签: phpCreate dashboard widget for custom theme support