[wp-hackers] Need help with: coding new Plugin options

DD32 wordpress at dd32.id.au
Fri Nov 7 08:41:58 GMT 2008


On Fri, 07 Nov 2008 19:13:45 +1100, Daiv Mowbray <daiv at daivmowbray.com>  
wrote:

> and:
> /**
> * Add link to options page from plugin list.
> */
>
> 			function filter_plugin_actions($links, $file) {
>    				 static $this_plugin;
>     					if( ! $this_plugin ) $this_plugin = plugin_basename(__FILE__);
>
>    				if( $file == $this_plugin ){
>    					$settings_link = '<a href="options-general.php?
> page=myplugin">'.__('Settings').'</a>';
>     					array_unshift( $links, $settings_link ); // before other links
>   				}
>     				return $links;
> 			}

theres a better option for this under 2.7, instead of firing on every  
action-links filter, You can use the  plugin_action_links_{$plugin} filter:

add_action('plugin_action_links_' . plugin_basename(__FILE__),  
'filter_plugin_actions');
function filter_plugin_actions($links) {
     $settings_link = '<a  
href="options-general.php?page=myplugin">'.__('Settings').'</a>';
     array_unshift( $links, $settings_link ); // before other links
     return $links;
}


More information about the wp-hackers mailing list