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?
1 Answer
Reset to default 0Yes, 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.
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