0

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?

  • 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 Mar 9 '20 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 Mar 9 '20 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 Mar 9 '20 at 19:16
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.com/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.com/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.com/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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.