When you’re building a plugin you of course want the best experience for the users. One part of this is the ability to easily install and use the plugin. The first time the plugin is installed, it would be great to be able to quickly navigate to the settings page if you have one, right after you’ve activated the plugin.
Having a link right next to (its actually below) your plugin would help users tremendously. You’ve probably already seen this on other plugin you’re using, and here’s how you can use it on your own plugins.
PS. These kind of links are called ‘Plugin action links’ in case you were wondering.
The plugin action links will only show up when the plugin is activated, so you won’t have to worry about hiding the settings link when the plugin isn’t active.
In the code snippet there are a couple things you’d need to change for your needs.
1) Function name
Change the function name to something else that no one else is using. Adding a prefix related to your plugin is best. If you use PHP namespaces you of course don’t have anything to worry about 🙂
Don’t forget to update the function name in the action hook which is at the bottom.
2) The link itself
Change the link and the text of the link to your needs. ‘Settings’ is the most common text thats used when linking to a settings page, and is highly recommended to use the same here.
If you want to add more then one link you can do so by adding extra array elements. Do try to keep the amount of links as low as possible here as it only clogs the user interface more.
The last thing that needs changing is the textdomain for the displayed text.
The code snippet above positions the ‘Settings’ link before the standard ‘Deactivate’ link, which is the most used format. If you’d like to change the order / add a links after the default plugin action links you can do so by merging the links in reverse like so:
One thought on “Adding links to your plugin on the plugins page”
Thanks Jeroen ,
that was so helpful 🙂
I had to change the admin url to link to my settings page:
esc_url( admin_url( ‘/options-general.php?page=ESB%20Help’ ) ) etc…
But wow, that was easy 😀