Provide a Shortcut to Your Settings Page with Plugin Action Links

Written by Jean Galea
Written by Jean Galea
When you use this code in your plugin, it will add a 'Settings' link to your plugin's listing under 'Plugins'. The link will take you to the plugin's options page. The benefit of the plugin action link is that users see it immediately after they activate the plugin, thus adding to the overall experience.

Partner Sponsors

BionicWP

Full disclosure: If you purchase through a link on our site, we may earn a commission. Learn more.

When you use this code in your plugin, it will add a ‘Settings’ link to your plugin’s listing under ‘Plugins’. The link will take you to the plugin’s options page.

The benefit of the plugin action link is that users see it immediately after they activate the plugin, thus adding to the overall experience.

[php]
add_filter(‘plugin_action_links’, ‘myplugin_plugin_action_links’, 10, 2);

function myplugin_plugin_action_links($links, $file) {
static $this_plugin;

if (!$this_plugin) {
$this_plugin = plugin_basename(__FILE__);
}

if ($file == $this_plugin) {
// The "page" query string value must be equal to the slug
// of the Settings admin page we defined earlier, which in
// this case equals "myplugin-settings".
$settings_link = ‘<a href="’ . get_bloginfo(‘wpurl’) . ‘/wp-admin/admin.php?page=myplugin-settings">Settings</a>’;
array_unshift($links, $settings_link);
}

return $links;
}
[/php]

If you enjoyed this post, make sure to subscribe to WPMayor’s RSS feed.

This article was filed in our archives.
Written by Jean Galea
Jean Galea is an investor, entrepreneur, and blogger. He is the founder of WP Mayor, the plugins WP RSS Aggregator and Spotlight, as well as the Mastermind.fm podcast. His personal blog can be found at jeangalea.com.

In this article

Discover More

Share Your Thoughts

Your email address will not be published. Required fields are marked *

New discoveries, every week.
Join thousands of designers, developers, and builders that come to WP Mayor to find the best guides, tools, and services for their next website. One email, once a week.
WP Mayor Newsletter

Claim Your Free Website Tip 👇

Leave your name, email and website URL below to receive one actionable improvement tip tailored for your website within the next 24 hours.

"They identified areas for improvement that we had not previously considered." - Elliot

By providing your information, you'll also be subscribing to our weekly newsletter packed with exclusive content and insights. You can unsubscribe at any time with just one click.

What's missing?