[wp-hackers] "Action" links for plugins (was Plugin Settings Menu Location)

Per Søderlind per at soderlind.no
Wed May 21 19:32:23 GMT 2008


On 20. mai 2008 22:41 Stephen Rider wrote
> 
> Per user DD32 on Trac, you can add things to the "Action" column of a
> plugin on the Plugins page.
> 
> This would be an excellent way to add links to one-time setup config
> pages for plugins.  Adds _nothing_ to the menus, and thus we can avoid
> clutter.
> 
> <http://trac.wordpress.org/attachment/ticket/5660>
> Screenshot:
> <http://trac.wordpress.org/attachment/ticket/5660/example.png>
> 
> What we really *should* do before this becomes any kind of common
> practice is to __standardize__ it, so that it is done the same on
> different plugins.  Let's try to avoid having various plugins using
> "Setup", "Settings", "Config", "Configuration", "Configure" etc. ad
> nauseum
> 
> My suggestion for standard "Action" links for plugins:
> 
> Configure -- for one-time setup -- linked page DOES NOT appear
> elsewhere in Admin
> 
> Settings -- links to Settings pages that DO appear elsewhere in
> Admin.  Use this to avoid people not being able to find where you
> tucked it....
> 
> Uninstall -- Removes preferences, extra tables, etc from database.
> Completely remove plugin.
> 
> And of course, not going anywhere, is the standard:
> Activate/Deactivate

I'm writing plugin (wp-deleteplugin) that uses jQuery to add the Delete
action link to the Plugins page:

function ps_deleteplugin_jquery() {
  $link =
"plugins.php?action=delete&amp;page=wp-deleteplugin/wp-deleteplugin.php&amp;
plugin=";
  ?>
  <script type='text/javascript'>
  /**
  * @desc Add Delete Plugin link
  * @author Per Soderlind - www.soderlind.no";
  */
  jQuery(document).ready(function() {
    jQuery('#plugins
td.togl').filter(':contains(Activate)').each(function(i,el) {
      var strHref = jQuery( this ).find('a')[0].toString();
      var returnVal = new Array();
      var qString = null;
      var strQueryString = strHref.split("?");
      qString = strQueryString[1].split("&");
      for (var i=0;i<qString.length; i++){
        if (escape(unescape(qString[i].split("=")[0])) == "plugin") {
          returnVal.push(qString[i].split("=")[1]);
        }
      }

      if (returnVal.length==0) plugin = null;
      else if (returnVal.length==1) plugin = returnVal[0];
      else plugin = returnVal;

      jQuery( this ).append(" | <a href=\"<?php echo $link;?>" + plugin +"\"
title=\"Delete this plugin\" class=\"edit\">Delete</a>");
    });
  });
  </script>
  <?php
}

if (strpos($_SERVER['REQUEST_URI'], 'plugins.php') !== false) {
  add_action('admin_head', array(&$this, 'ps_deleteplugin_jquery'));
}

../PerS - www.soderlind.no



More information about the wp-hackers mailing list