Ticket #5660: 5660.2.diff

File 5660.2.diff, 3.8 KB (added by DD32, 5 years ago)

refresh the patch to allow a customised list of action links (refreshed again after [7515])

  • wp-admin/plugins.php

     
    7070<p><?php _e('Plugins extend and expand the functionality of WordPress. Once a plugin is installed, you may activate it or deactivate it here.'); ?></p> 
    7171<?php 
    7272 
    73 if ( get_option('active_plugins') ) 
    74         $current_plugins = get_option('active_plugins'); 
    75  
    7673$plugins = get_plugins(); 
    7774 
    7875if (empty($plugins)) { 
     
    114111        </thead> 
    115112        <tbody id="plugins"> 
    116113<?php 
    117         $style = ''; 
    118  
    119114        foreach($plugins as $plugin_file => $plugin_data) { 
    120                 $style = ('class="alternate"' == $style|| 'class="alternate active"' == $style) ? '' : 'alternate'; 
     115                $action_links = array(); 
     116                 
     117                $style = ''; 
    121118 
    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()); 
    131129 
     
    134132                $plugin_data['Version']     = wp_kses($plugin_data['Version'], $plugins_allowedtags); 
    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>"; 
    156152        do_action( 'after_plugin_row', $plugin_file );