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.