Make WordPress Core

Changeset 7517


Ignore:
Timestamp:
03/26/2008 03:59:40 AM (16 years ago)
Author:
ryan
Message:

Filter list of plugins actions. Props DD32. see #5660

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/plugins.php

    r7515 r7517  
    7171<?php
    7272
    73 if ( get_option('active_plugins') )
    74     $current_plugins = get_option('active_plugins');
    75 
    7673$plugins = get_plugins();
    7774
     
    115112    <tbody id="plugins">
    116113<?php
    117     $style = '';
     114    foreach($plugins as $plugin_file => $plugin_data) {
     115        $action_links = array();
     116       
     117        $style = '';
    118118
    119     foreach($plugins as $plugin_file => $plugin_data) {
    120         $style = ('class="alternate"' == $style|| 'class="alternate active"' == $style) ? '' : 'alternate';
    121 
    122         if (!empty($current_plugins) && in_array($plugin_file, $current_plugins)) {
    123             $toggle = "<a href='" . wp_nonce_url("plugins.php?action=deactivate&amp;plugin=$plugin_file", 'deactivate-plugin_' . $plugin_file) . "' title='".__('Deactivate this plugin')."' class='delete'>".__('Deactivate')."</a>";
    124             $plugin_data['Title'] = "<strong>{$plugin_data['Title']}</strong>";
    125             $style .= $style == 'alternate' ? ' active' : 'active';
     119        if( is_plugin_active($plugin_file) ) {
     120            $action_links[] = "<a href='" . wp_nonce_url("plugins.php?action=deactivate&amp;plugin=$plugin_file", 'deactivate-plugin_' . $plugin_file) . "' title='".__('Deactivate this plugin')."' class='delete'>".__('Deactivate')."</a>";
     121            $style = 'active';
    126122        } else {
    127             $toggle = "<a href='" . wp_nonce_url("plugins.php?action=activate&amp;plugin=$plugin_file", 'activate-plugin_' . $plugin_file) . "' title='".__('Activate this plugin')."' class='edit'>".__('Activate')."</a>";
     123            $action_links[] = "<a href='" . wp_nonce_url("plugins.php?action=activate&amp;plugin=$plugin_file", 'activate-plugin_' . $plugin_file) . "' title='".__('Activate this plugin')."' class='edit'>".__('Activate')."</a>";
    128124        }
     125        if ( current_user_can('edit_plugins') && is_writable(ABSPATH . PLUGINDIR . '/' . $plugin_file) )
     126            $action_links[] = "<a href='plugin-editor.php?file=$plugin_file' title='".__('Open this file in the Plugin Editor')."' class='edit'>".__('Edit')."</a>";
    129127
    130128        $plugins_allowedtags = array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array());
     
    135133        $plugin_data['Description'] = wp_kses($plugin_data['Description'], $plugins_allowedtags);
    136134        $plugin_data['Author']      = wp_kses($plugin_data['Author'], $plugins_allowedtags);
     135        $author = ( empty($plugin_data['Author']) ) ? '' :  ' <cite>' . sprintf( __('By %s'), $plugin_data['Author'] ) . '.</cite>';
    137136
    138137        if ( $style != '' )
    139             $style = 'class="' . $style . '"';
    140         if ( is_writable(ABSPATH . PLUGINDIR . '/' . $plugin_file) )
    141             $edit = " | <a href='plugin-editor.php?file=$plugin_file' title='".__('Open this file in the Plugin Editor')."' class='edit'>".__('Edit')."</a>";
    142         else
    143             $edit = '';
     138            $style = ' class="' . $style . '"';
    144139
    145         $author = ( empty($plugin_data['Author']) ) ? '' :  ' <cite>' . sprintf( __('By %s'), $plugin_data['Author'] ) . '.</cite>';
     140        $action_links = apply_filters('plugin_action_links', $action_links, $plugin_file, $plugin_info);
    146141
    147142        echo "
    148     <tr $style>
     143    <tr$style>
    149144        <td class='name'>{$plugin_data['Title']}</td>
    150145        <td class='vers'>{$plugin_data['Version']}</td>
    151146        <td class='desc'><p>{$plugin_data['Description']}$author</p></td>
    152147        <td class='togl action-links'>$toggle"; 
    153         if ( current_user_can('edit_plugins') ) echo $edit;
     148        if ( !empty($action_links) )
     149            echo implode(' | ', $action_links);
    154150        echo "</td>
    155151    </tr>";
Note: See TracChangeset for help on using the changeset viewer.