Direct link to “Settings” v2.7

<a href="Frank Bültge describes in his posting “WordPress Plugins bereichern” how you can improve your plugin’s ease of operation by adding a link to the option pages next to the Deactive and Edit links. In version 2.6 the corresponding code looked like this:

function addConfigureLink($links, $file) {
  static $this_plugin;
  if (!$this_plugin) {
    $this_plugin = plugin_basename(__FILE__);
  }
  if ($file == $this_plugin) {
    $settings_link = '' . 
      __('Settings') . '';
    $links = array_merge( array($settings_link), $links);
  }
  return $links;
}

add_filter("plugin_action_links", "addConfigureLink", 10, 2);

However using this approach the function addConfigureLink is called for every single plugin… and it does not look too well arranged.

Obviously the WP developers thought the same and improved the filter:

function addConfigureLink( $links ) { 
  $settings_link = 'Settings'; 
  array_unshift( $links, $settings_link ); 
  return $links; 
}

$plugin = plugin_basename(__FILE__); 
add_filter("plugin_action_links_$plugin", 'addConfigureLink' );

This way the function addConfigureLink no longer needs to check for every installed plugin and the code looks much cleaner.

After all you have to decide if you want to use such a “fresh” filter and ruin the compatibility to previous versions of WordPress or if you want to wait until the new version is widely spread. You can read my opinion at identi.ca (shameless self promotion!).

2 thoughts on “Direct link to “Settings” v2.7”

Leave a Reply

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

To respond on your own website, enter the URL of your response which should contain a link to this post's permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post's URL again. (Find out more about Webmentions.)