This is how to add a ‘Settings’ link under your plugin on the plugins page. The ‘Settings’ link will appear right next to the Deactivate link. If you are within a PHP class, do example 1. If your plugin is not within a PHP class, follow example 2.
Example 1: If your plugin is within a PHP class
Step 1:
Add this to your plugin file, in the constructor:
add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), array( $this, 'plugin_settings_link' ) );
Step 2:
Add this method to the class:
function plugin_settings_link($links) { $url = get_admin_url() . 'options-general.php?page=yourplugin_options'; $settings_link = '<a href="'.$url.'">' . __( 'Settings', 'textdomain' ) . '</a>'; array_unshift( $links, $settings_link ); return $links; }
Step 2:
Make the following changes to the code above.
Line 2: change yourplugin_options
to your own plugin options page slug.
Line 3: change ‘textdomain’ to your own plugin’s text domain.
Example 2: If Not Within a PHP Class
If you’re plugin is NOT built with a PHP class, then use this instead:
function myplugin_settings_link( $links ) { $url = get_admin_url() . 'options-general.php?page=yourplugin_options'; $settings_link = '<a href="' . $url . '">' . __('Settings', 'textdomain') . '</a>'; array_unshift( $links, $settings_link ); return $links; } function myplugin_after_setup_theme() { add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'myplugin_settings_link'); } add_action ('after_setup_theme', 'myplugin_after_setup_theme');
Make the following changes to the code above.
Line 2: change yourplugin_options
to your own plugin options page slug.
Line 3: change ‘textdomain’ to your own plugin’s text domain.
Mahesh
April 26th, 2013 at 2:30 am
Thanks Isabel,
This helps me a lot..keep it up
Isabel
April 29th, 2013 at 5:11 pm
Thank you.