Make WordPress Core


Ignore:
File:
1 edited

Legend:

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

    r16373 r17322  
    99/** WordPress Administration Bootstrap */
    1010require_once('./admin.php');
     11
    1112if ( is_multisite() ) {
    1213    $menu_perms = get_site_option( 'menu_items', array() );
    1314
    14     if ( empty($menu_perms['plugins']) && ! is_super_admin() )
     15    if ( empty( $menu_perms['plugins'] ) && ! is_super_admin() )
    1516        wp_die( __( 'Cheatin’ uh?' ) );
    16     else if ( $menu_perms['plugins'] != 1 && is_super_admin() )
    17         add_action( 'admin_notices', '_admin_notice_multisite_activate_plugins_page' );
    1817}
    1918
    20 if ( ! current_user_can( 'activate_plugins' ) )
     19if ( !current_user_can('activate_plugins') )
    2120    wp_die( __( 'You do not have sufficient permissions to manage plugins for this site.' ) );
    2221
    23 if ( isset($_POST['clear-recent-list']) )
    24     $action = 'clear-recent-list';
    25 elseif ( !empty($_REQUEST['action']) )
    26     $action = $_REQUEST['action'];
    27 elseif ( !empty($_REQUEST['action2']) )
    28     $action = $_REQUEST['action2'];
    29 else
    30     $action = false;
     22$wp_list_table = _get_list_table('WP_Plugins_List_Table');
     23$pagenum = $wp_list_table->get_pagenum();
     24
     25$action = $wp_list_table->current_action();
    3126
    3227$plugin = isset($_REQUEST['plugin']) ? $_REQUEST['plugin'] : '';
    33 
    34 $default_status = get_user_option('plugins_last_view');
    35 if ( empty($default_status) )
    36     $default_status = 'all';
    37 $status = isset($_REQUEST['plugin_status']) ? $_REQUEST['plugin_status'] : $default_status;
    38 if ( !in_array($status, array('all', 'active', 'inactive', 'recent', 'upgrade', 'network', 'mustuse', 'dropins', 'search')) )
    39     $status = 'all';
    40 if ( $status != $default_status && 'search' != $status )
    41     update_user_meta($current_user->ID, 'plugins_last_view', $status);
    42 
    43 $page = isset($_REQUEST['paged']) ? $_REQUEST['paged'] : 1;
    44 
    45 //Clean up request URI from temporary args for screen options/paging uri's to work as expected.
     28$s = isset($_REQUEST['s']) ? $_REQUEST['s'] : '';
     29
     30// Clean up request URI from temporary args for screen options/paging uri's to work as expected.
    4631$_SERVER['REQUEST_URI'] = remove_query_arg(array('error', 'deleted', 'activate', 'activate-multi', 'deactivate', 'deactivate-multi', '_error_nonce'), $_SERVER['REQUEST_URI']);
    4732
    48 if ( !empty($action) ) {
     33if ( $action ) {
    4934    $network_wide = false;
    5035    if ( ( isset( $_GET['networkwide'] ) || 'network-activate-selected' == $action ) && is_multisite() && current_user_can( 'manage_network_plugins' ) )
     
    5843            check_admin_referer('activate-plugin_' . $plugin);
    5944
    60             $result = activate_plugin($plugin, 'plugins.php?error=true&plugin=' . $plugin, $network_wide);
     45            $result = activate_plugin($plugin, self_admin_url('plugins.php?error=true&plugin=' . $plugin), $network_wide);
    6146            if ( is_wp_error( $result ) ) {
    6247                if ( 'unexpected_output' == $result->get_error_code() ) {
    63                     $redirect = 'plugins.php?error=true&charsout=' . strlen($result->get_error_data()) . '&plugin=' . $plugin;
     48                    $redirect = self_admin_url('plugins.php?error=true&charsout=' . strlen($result->get_error_data()) . '&plugin=' . $plugin . "&plugin_status=$status&paged=$page&s=$s");
    6449                    wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), $redirect));
    6550                    exit;
     
    7560            }
    7661            if ( isset($_GET['from']) && 'import' == $_GET['from'] ) {
    77                 wp_redirect("import.php?import=" . str_replace('-importer', '', dirname($plugin)) ); // overrides the ?error=true one above and redirects to the Imports page, striping the -importer suffix
     62                wp_redirect( self_admin_url("import.php?import=" . str_replace('-importer', '', dirname($plugin))) ); // overrides the ?error=true one above and redirects to the Imports page, striping the -importer suffix
    7863            } else {
    79                 wp_redirect("plugins.php?activate=true&plugin_status=$status&paged=$page"); // overrides the ?error=true one above
     64                wp_redirect( self_admin_url("plugins.php?activate=true&plugin_status=$status&paged=$page&s=$s") ); // overrides the ?error=true one above
    8065            }
    8166            exit;
     
    8671                wp_die(__('You do not have sufficient permissions to activate plugins for this site.'));
    8772
    88             check_admin_referer('bulk-manage-plugins');
     73            check_admin_referer('bulk-plugins');
    8974
    9075            $plugins = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
    91             $plugins = array_filter($plugins, create_function('$plugin', 'return !is_plugin_active($plugin);') ); // Only activate plugins which are not already active.
     76
     77            // Only activate plugins which are not already active.
     78            $check = $network_wide ? 'is_plugin_active_for_network' : 'is_plugin_active';
     79            foreach ( $plugins as $i => $plugin )
     80                if ( $check( $plugin ) )
     81                    unset( $plugins[ $i ] );
     82
    9283            if ( empty($plugins) ) {
    93                 wp_redirect("plugins.php?plugin_status=$status&paged=$page");
     84                wp_redirect( self_admin_url("plugins.php?plugin_status=$status&paged=$page&s=$s") );
    9485                exit;
    9586            }
    9687
    97             activate_plugins($plugins, 'plugins.php?error=true', $network_wide);
     88            activate_plugins($plugins, self_admin_url('plugins.php?error=true'), $network_wide);
    9889
    9990            $recent = (array)get_option('recently_activated');
     
    10495            update_option('recently_activated', $recent);
    10596
    106             wp_redirect("plugins.php?activate-multi=true&plugin_status=$status&paged=$page");
     97            wp_redirect( self_admin_url("plugins.php?activate-multi=true&plugin_status=$status&paged=$page&s=$s") );
    10798            exit;
    10899            break;
    109100        case 'update-selected' :
    110101
    111             check_admin_referer( 'bulk-manage-plugins' );
     102            check_admin_referer( 'bulk-plugins' );
    112103
    113104            if ( isset( $_GET['plugins'] ) )
     
    118109                $plugins = array();
    119110
    120             $title = __( 'Upgrade Plugins' );
     111            $title = __( 'Update Plugins' );
    121112            $parent_file = 'plugins.php';
    122113
    123             require_once( './admin-header.php' );
     114            require_once(ABSPATH . 'wp-admin/admin-header.php');
    124115
    125116            echo '<div class="wrap">';
     
    128119
    129120
    130             $url = 'update.php?action=update-selected&amp;plugins=' . urlencode( join(',', $plugins) );
     121            $url = self_admin_url('update.php?action=update-selected&amp;plugins=' . urlencode( join(',', $plugins) ));
    131122            $url = wp_nonce_url($url, 'bulk-update-plugins');
    132123
    133124            echo "<iframe src='$url' style='width: 100%; height:100%; min-height:850px;'></iframe>";
    134125            echo '</div>';
    135             require_once( './admin-footer.php' );
     126            require_once(ABSPATH . 'wp-admin/admin-footer.php');
    136127            exit;
    137128            break;
     
    169160            deactivate_plugins($plugin);
    170161            update_option('recently_activated', array($plugin => time()) + (array)get_option('recently_activated'));
    171             if (headers_sent())
    172                 echo "<meta http-equiv='refresh' content='" . esc_attr( "0;url=plugins.php?deactivate=true&plugin_status=$status&paged=$page" ) . "' />";
     162            if ( headers_sent() )
     163                echo "<meta http-equiv='refresh' content='" . esc_attr( "0;url=plugins.php?deactivate=true&plugin_status=$status&paged=$page&s=$s" ) . "' />";
    173164            else
    174                 wp_redirect("plugins.php?deactivate=true&plugin_status=$status&paged=$page");
     165                wp_redirect( self_admin_url("plugins.php?deactivate=true&plugin_status=$status&paged=$page&s=$s") );
    175166            exit;
    176167            break;
     
    179170                wp_die(__('You do not have sufficient permissions to deactivate plugins for this site.'));
    180171
    181             check_admin_referer('bulk-manage-plugins');
     172            check_admin_referer('bulk-plugins');
    182173
    183174            $plugins = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
    184175            $plugins = array_filter($plugins, 'is_plugin_active'); //Do not deactivate plugins which are already deactivated.
    185176            if ( empty($plugins) ) {
    186                 wp_redirect("plugins.php?plugin_status=$status&paged=$page");
     177                wp_redirect( self_admin_url("plugins.php?plugin_status=$status&paged=$page&s=$s") );
    187178                exit;
    188179            }
     
    195186
    196187            update_option('recently_activated', $deactivated + (array)get_option('recently_activated'));
    197             wp_redirect("plugins.php?deactivate-multi=true&plugin_status=$status&paged=$page");
     188            wp_redirect( self_admin_url("plugins.php?deactivate-multi=true&plugin_status=$status&paged=$page&s=$s") );
    198189            exit;
    199190            break;
     
    202193                wp_die(__('You do not have sufficient permissions to delete plugins for this site.'));
    203194
    204             check_admin_referer('bulk-manage-plugins');
     195            check_admin_referer('bulk-plugins');
    205196
    206197            //$_POST = from the plugin form; $_GET = from the FTP details screen.
    207198            $plugins = isset( $_REQUEST['checked'] ) ? (array) $_REQUEST['checked'] : array();
    208             $plugins = array_filter($plugins, create_function('$plugin', 'return !is_plugin_active($plugin);') ); //Do not allow to delete Activated plugins.
    209             if ( empty($plugins) ) {
    210                 wp_redirect("plugins.php?plugin_status=$status&paged=$page");
     199            if ( empty( $plugins ) ) {
     200                wp_redirect( self_admin_url("plugins.php?plugin_status=$status&paged=$page&s=$s") );
     201                exit;
     202            }
     203
     204            $plugins = array_filter($plugins, 'is_plugin_inactive'); // Do not allow to delete Activated plugins.
     205            if ( empty( $plugins ) ) {
     206                wp_redirect( self_admin_url( "plugins.php?error=true&main=true&plugin_status=$status&paged=$page&s=$s" ) );
    211207                exit;
    212208            }
     
    218214            if ( ! isset($_REQUEST['verify-delete']) ) {
    219215                wp_enqueue_script('jquery');
    220                 require_once('./admin-header.php');
     216                require_once(ABSPATH . 'wp-admin/admin-header.php');
    221217                ?>
    222218            <div class="wrap">
    223219                <?php
    224220                    $files_to_delete = $plugin_info = array();
     221                    $have_non_network_plugins = false;
    225222                    foreach ( (array) $plugins as $plugin ) {
    226223                        if ( '.' == dirname($plugin) ) {
     
    229226                                $plugin_info[ $plugin ] = $data;
    230227                                $plugin_info[ $plugin ]['is_uninstallable'] = is_uninstallable_plugin( $plugin );
     228                                if ( ! $plugin_info[ $plugin ]['Network'] )
     229                                    $have_non_network_plugins = true;
    231230                            }
    232231                        } else {
     
    239238                            if ( $folder_plugins = get_plugins( '/' . dirname($plugin)) ) {
    240239                                foreach( $folder_plugins as $plugin_file => $data ) {
    241                                     $plugin_info[ $plugin_file ] = $data;
     240                                    $plugin_info[ $plugin_file ] = _get_plugin_data_markup_translate( $plugin_file, $data );
    242241                                    $plugin_info[ $plugin_file ]['is_uninstallable'] = is_uninstallable_plugin( $plugin );
     242                                    if ( ! $plugin_info[ $plugin_file ]['Network'] )
     243                                        $have_non_network_plugins = true;
    243244                                }
    244245                            }
     
    249250                    echo '<h2>' . _n( 'Delete Plugin', 'Delete Plugins', $plugins_to_delete ) . '</h2>';
    250251                ?>
     252                <?php if ( $have_non_network_plugins && is_network_admin() ) : ?>
     253                <div class="error"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php echo _n( 'This plugin may be active on other sites in the network.', 'These plugins may be active on other sites in the network.', $plugins_to_delete ); ?></p></div>
     254                <?php endif; ?>
    251255                <p><?php echo _n( 'You are about to remove the following plugin:', 'You are about to remove the following plugins:', $plugins_to_delete ); ?></p>
    252256                    <ul class="ul-disc">
     
    256260                            if ( $plugin['is_uninstallable'] ) {
    257261                                /* translators: 1: plugin name, 2: plugin author */
    258                                 echo '<li>', sprintf( __( '<strong>%1$s</strong> by <em>%2$s</em> (will also <strong>delete its data</strong>)' ), esc_html($plugin['Name']), esc_html($plugin['Author']) ), '</li>';
     262                                echo '<li>', sprintf( __( '<strong>%1$s</strong> by <em>%2$s</em> (will also <strong>delete its data</strong>)' ), esc_html($plugin['Name']), esc_html($plugin['AuthorName']) ), '</li>';
    259263                                $data_to_delete = true;
    260264                            } else {
    261265                                /* translators: 1: plugin name, 2: plugin author */
    262                                 echo '<li>', sprintf( __('<strong>%1$s</strong> by <em>%2$s</em>' ), esc_html($plugin['Name']), esc_html($plugin['Author']) ), '</li>';
     266                                echo '<li>', sprintf( __('<strong>%1$s</strong> by <em>%2$s</em>' ), esc_html($plugin['Name']), esc_html($plugin['AuthorName']) ), '</li>';
    263267                            }
    264268                        }
     
    275279                    <input type="hidden" name="action" value="delete-selected" />
    276280                    <?php
    277                         foreach ( (array)$plugins as $plugin )
     281                        foreach ( (array) $plugins as $plugin )
    278282                            echo '<input type="hidden" name="checked[]" value="' . esc_attr($plugin) . '" />';
    279283                    ?>
    280                     <?php wp_nonce_field('bulk-manage-plugins') ?>
    281                     <input type="submit" name="submit" value="<?php $data_to_delete ? esc_attr_e('Yes, Delete these files and data') : esc_attr_e('Yes, Delete these files') ?>" class="button" />
     284                    <?php wp_nonce_field('bulk-plugins') ?>
     285                    <?php submit_button( $data_to_delete ? __( 'Yes, Delete these files and data' ) : __( 'Yes, Delete these files' ), 'button', 'submit', false ); ?>
    282286                </form>
    283287                <form method="post" action="<?php echo esc_url(wp_get_referer()); ?>" style="display:inline;">
    284                     <input type="submit" name="submit" value="<?php esc_attr_e('No, Return me to the plugin list') ?>" class="button" />
     288                    <?php submit_button( __( 'No, Return me to the plugin list' ), 'button', 'submit', false ); ?>
    285289                </form>
    286290
     
    296300            </div>
    297301                <?php
    298                 require_once('./admin-footer.php');
     302                require_once(ABSPATH . 'wp-admin/admin-footer.php');
    299303                exit;
    300304            } //Endif verify-delete
    301305            $delete_result = delete_plugins($plugins);
    302306
    303             set_transient('plugins_delete_result_'.$user_ID, $delete_result); //Store the result in a cache rather than a URL param due to object type & length
    304             wp_redirect("plugins.php?deleted=true&plugin_status=$status&paged=$page");
     307            set_transient('plugins_delete_result_' . $user_ID, $delete_result); //Store the result in a cache rather than a URL param due to object type & length
     308            wp_redirect( self_admin_url("plugins.php?deleted=true&plugin_status=$status&paged=$page&s=$s") );
    305309            exit;
    306310            break;
     
    311315}
    312316
     317$wp_list_table->prepare_items();
     318
     319$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
     320if ( $pagenum > $total_pages && $total_pages > 0 ) {
     321    wp_redirect( add_query_arg( 'paged', $total_pages ) );
     322    exit;
     323}
     324
    313325wp_enqueue_script('plugin-install');
    314326add_thickbox();
     327
     328add_screen_option( 'per_page', array('label' => _x( 'Plugins', 'plugins per page (screen options)' )) );
    315329
    316330add_contextual_help($current_screen,
     
    325339
    326340$title = __('Plugins');
    327 
    328 require_once('./admin-header.php');
     341$parent_file = 'plugins.php';
     342
     343require_once(ABSPATH . 'wp-admin/admin-header.php');
    329344
    330345$invalid = validate_active_plugins();
     
    336351<?php if ( isset($_GET['error']) ) :
    337352
    338     if ( isset($_GET['charsout']) )
     353    if ( isset( $_GET['main'] ) )
     354        $errmsg = __( 'You cannot delete a plugin while it is active on the main site.' );
     355    elseif ( isset($_GET['charsout']) )
    339356        $errmsg = sprintf(__('The plugin generated %d characters of <strong>unexpected output</strong> during activation.  If you notice &#8220;headers already sent&#8221; messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.'), $_GET['charsout']);
    340357    else
     
    343360    <div id="message" class="updated"><p><?php echo $errmsg; ?></p>
    344361    <?php
    345         if ( !isset($_GET['charsout']) && wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $plugin) ) { ?>
    346     <iframe style="border:0" width="100%" height="70px" src="<?php echo admin_url('plugins.php?action=error_scrape&amp;plugin=' . esc_attr($plugin) . '&amp;_wpnonce=' . esc_attr($_GET['_error_nonce'])); ?>"></iframe>
     362        if ( !isset( $_GET['main'] ) && !isset($_GET['charsout']) && wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $plugin) ) { ?>
     363    <iframe style="border:0" width="100%" height="70px" src="<?php echo 'plugins.php?action=error_scrape&amp;plugin=' . esc_attr($plugin) . '&amp;_wpnonce=' . esc_attr($_GET['_error_nonce']); ?>"></iframe>
    347364    <?php
    348365        }
     
    372389<div class="wrap">
    373390<?php screen_icon(); ?>
    374 <h2><?php echo esc_html( $title ); if ( current_user_can('install_plugins') ) { ?> <a href="plugin-install.php" class="button add-new-h2"><?php echo esc_html_x('Add New', 'plugin'); ?></a><?php } ?></h2>
    375 
    376 <?php
    377 
    378 $all_plugins = apply_filters( 'all_plugins', get_plugins() );
    379 $search_plugins = array();
    380 $active_plugins = array();
    381 $inactive_plugins = array();
    382 $recent_plugins = array();
    383 $recently_activated = get_option('recently_activated', array());
    384 $upgrade_plugins = array();
    385 $network_plugins = array();
    386 $mustuse_plugins = $dropins_plugins = array();
    387 if ( ! is_multisite() || current_user_can('manage_network_plugins') ) {
    388     if ( apply_filters( 'show_advanced_plugins', true, 'mustuse' ) )
    389         $mustuse_plugins = get_mu_plugins();
    390     if ( apply_filters( 'show_advanced_plugins', true, 'dropins' ) )
    391         $dropins_plugins = get_dropins();
    392 }
    393 
    394 set_transient( 'plugin_slugs', array_keys($all_plugins), 86400 );
    395 
    396 // Clean out any plugins which were deactivated over a week ago.
    397 foreach ( $recently_activated as $key => $time )
    398     if ( $time + (7*24*60*60) < time() ) //1 week
    399         unset($recently_activated[ $key ]);
    400 if ( $recently_activated != get_option('recently_activated') ) //If array changed, update it.
    401     update_option('recently_activated', $recently_activated);
    402 $current = get_site_transient( 'update_plugins' );
    403 
    404 foreach ( array( 'all_plugins', 'mustuse_plugins', 'dropins_plugins' ) as $plugin_array_name) {
    405     foreach ( (array) $$plugin_array_name as $plugin_file => $plugin_data ) {
    406         // Translate, Apply Markup, Sanitize HTML
    407         $plugin_data = _get_plugin_data_markup_translate($plugin_file, $plugin_data, false, true);
    408         ${$plugin_array_name}[ $plugin_file ] = $plugin_data;
    409     }
    410 }
    411 unset( $plugin_array_name );
    412 
    413 foreach ( (array) $all_plugins as $plugin_file => $plugin_data) {
    414     // Filter into individual sections
    415     if ( is_multisite() && is_network_only_plugin( $plugin_file ) && !current_user_can( 'manage_network_plugins' ) ) {
    416         unset( $all_plugins[ $plugin_file ] );
    417         continue;
    418     } elseif ( is_plugin_active_for_network($plugin_file) ) {
    419         $network_plugins[ $plugin_file ] = $plugin_data;
    420     } elseif ( is_plugin_active($plugin_file) ) {
    421         $active_plugins[ $plugin_file ] = $plugin_data;
    422     } else {
    423         if ( isset( $recently_activated[ $plugin_file ] ) ) // Was the plugin recently activated?
    424             $recent_plugins[ $plugin_file ] = $plugin_data;
    425         $inactive_plugins[ $plugin_file ] = $plugin_data;
    426     }
    427 
    428     if ( isset( $current->response[ $plugin_file ] ) )
    429         $upgrade_plugins[ $plugin_file ] = $plugin_data;
    430 }
    431 
    432 if ( !current_user_can('update_plugins') )
    433     $upgrade_plugins = array();
    434 
    435 $total_all_plugins = count($all_plugins);
    436 $total_inactive_plugins = count($inactive_plugins);
    437 $total_active_plugins = count($active_plugins);
    438 $total_recent_plugins = count($recent_plugins);
    439 $total_upgrade_plugins = count($upgrade_plugins);
    440 $total_network_plugins = count($network_plugins);
    441 $total_mustuse_plugins = count($mustuse_plugins);
    442 $total_dropins_plugins = count($dropins_plugins);
    443 
    444 // Searching.
    445 if ( !empty($_GET['s']) ) {
    446     function _search_plugins_filter_callback($plugin) {
    447         static $term;
    448         if ( is_null($term) )
    449             $term = stripslashes($_GET['s']);
    450         if (    stripos($plugin['Name'], $term) !== false ||
    451                 stripos($plugin['Description'], $term) !== false ||
    452                 stripos($plugin['Author'], $term) !== false ||
    453                 stripos($plugin['PluginURI'], $term) !== false ||
    454                 stripos($plugin['AuthorURI'], $term) !== false ||
    455                 stripos($plugin['Version'], $term) !== false )
    456             return true;
    457         else
    458             return false;
    459     }
    460     $status = 'search';
    461     $search_plugins = array_filter($all_plugins, '_search_plugins_filter_callback');
    462     $total_search_plugins = count($search_plugins);
    463 }
    464 
    465 $plugin_array_name = "${status}_plugins";
    466 if ( empty($$plugin_array_name) && !in_array($status, array('all', 'search')) ) {
    467     $status = 'all';
    468     $plugin_array_name = "${status}_plugins";
    469 }
    470 
    471 $plugins = &$$plugin_array_name;
    472 
    473 // Paging.
    474 $total_this_page = "total_{$status}_plugins";
    475 $total_this_page = $$total_this_page;
    476 $plugins_per_page = (int) get_user_option( 'plugins_per_page' );
    477 if ( empty( $plugins_per_page ) || $plugins_per_page < 1 )
    478     $plugins_per_page = 999;
    479 $plugins_per_page = apply_filters( 'plugins_per_page', $plugins_per_page );
    480 
    481 $start = ($page - 1) * $plugins_per_page;
    482 
    483 $page_links = paginate_links( array(
    484     'base' => add_query_arg( 'paged', '%#%' ),
    485     'format' => '',
    486     'prev_text' => __('&laquo;'),
    487     'next_text' => __('&raquo;'),
    488     'total' => ceil($total_this_page / $plugins_per_page),
    489     'current' => $page
    490 ));
    491 $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s&#8211;%s of %s' ) . '</span>%s',
    492     number_format_i18n( $start + 1 ),
    493     number_format_i18n( min( $page * $plugins_per_page, $total_this_page ) ),
    494     '<span class="total-type-count">' . number_format_i18n( $total_this_page ) . '</span>',
    495     $page_links
    496 );
    497 
    498 /**
    499  * @ignore
    500  *
    501  * @param array $plugins
    502  * @param string $context
    503  */
    504 function print_plugins_table($plugins, $context = '') {
    505     global $page;
    506     $checkbox = ! in_array( $context, array( 'mustuse', 'dropins' ) ) ? '<input type="checkbox" />' : '';
    507 ?>
    508 <table class="widefat" cellspacing="0" id="<?php echo $context ?>-plugins-table">
    509     <thead>
    510     <tr>
    511         <th scope="col" class="manage-column check-column"><?php echo $checkbox; ?></th>
    512         <th scope="col" class="manage-column"><?php _e('Plugin'); ?></th>
    513         <th scope="col" class="manage-column"><?php _e('Description'); ?></th>
    514     </tr>
    515     </thead>
    516 
    517     <tfoot>
    518     <tr>
    519         <th scope="col" class="manage-column check-column"><?php echo $checkbox; ?></th>
    520         <th scope="col" class="manage-column"><?php _e('Plugin'); ?></th>
    521         <th scope="col" class="manage-column"><?php _e('Description'); ?></th>
    522     </tr>
    523     </tfoot>
    524 
    525     <tbody class="plugins">
    526 <?php
    527 
    528     if ( empty($plugins) ) {
    529         echo '<tr>
    530             <td colspan="3">' . __('No plugins to show') . '</td>
    531         </tr>';
    532     }
    533     foreach ( (array)$plugins as $plugin_file => $plugin_data) {
    534         // preorder
    535         $actions = array(
    536             'network_deactivate' => '', 'deactivate' => '',
    537             'network_only' => '', 'activate' => '',
    538             'network_activate' => '',
    539             'edit' => '',
    540             'delete' => '',
    541         );
    542 
    543         if ( 'mustuse' == $context ) {
    544             $is_active = true;
    545         } elseif ( 'dropins' == $context ) {
    546             $dropins = _get_dropins();
    547             $plugin_name = $plugin_file;
    548             if ( $plugin_file != $plugin_data['Name'] )
    549                 $plugin_name .= '<br/>' . $plugin_data['Name'];
    550             if ( true === ( $dropins[ $plugin_file ][1] ) ) { // Doesn't require a constant
    551                 $is_active = true;
    552                 $description = '<p><strong>' . $dropins[ $plugin_file ][0] . '</strong></p>';
    553             } elseif ( constant( $dropins[ $plugin_file ][1] ) ) { // Constant is true
    554                 $is_active = true;
    555                 $description = '<p><strong>' . $dropins[ $plugin_file ][0] . '</strong></p>';
    556             } else {
    557                 $is_active = false;
    558                 $description = '<p><strong>' . $dropins[ $plugin_file ][0] . ' <span class="attention">' . __('Inactive:') . '</span></strong> ' . sprintf( __( 'Requires <code>%s</code> in <code>wp-config.php</code>.' ), "define('" . $dropins[ $plugin_file ][1] . "', true);" ) . '</p>';
    559             }
    560             if ( $plugin_data['Description'] )
    561                 $description .= '<p>' . $plugin_data['Description'] . '</p>';
    562         } else {
    563             $is_active_for_network = is_plugin_active_for_network($plugin_file);
    564             $is_active = $is_active_for_network || is_plugin_active( $plugin_file );
    565             if ( $is_active_for_network && !is_super_admin() )
    566                 continue;
    567 
    568             if ( $is_active ) {
    569                 if ( $is_active_for_network ) {
    570                     if ( is_super_admin() )
    571                         $actions['network_deactivate'] = '<a href="' . wp_nonce_url('plugins.php?action=deactivate&amp;networkwide=1&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page, 'deactivate-plugin_' . $plugin_file) . '" title="' . __('Deactivate this plugin') . '">' . __('Network Deactivate') . '</a>';
    572                 } else {
    573                     $actions['deactivate'] = '<a href="' . wp_nonce_url('plugins.php?action=deactivate&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page, 'deactivate-plugin_' . $plugin_file) . '" title="' . __('Deactivate this plugin') . '">' . __('Deactivate') . '</a>';
    574                 }
    575             } else {
    576                 if ( is_multisite() && is_network_only_plugin( $plugin_file ) )
    577                     $actions['network_only'] = '<span title="' . __('This plugin can only be activated for all sites in a network') . '">' . __('Network Only') . '</span>';
    578                 else
    579                     $actions['activate'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page, 'activate-plugin_' . $plugin_file) . '" title="' . __('Activate this plugin') . '" class="edit">' . __('Activate') . '</a>';
    580 
    581                 if ( is_multisite() && current_user_can( 'manage_network_plugins' ) )
    582                     $actions['network_activate'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;networkwide=1&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page, 'activate-plugin_' . $plugin_file) . '" title="' . __('Activate this plugin for all sites in this network') . '" class="edit">' . __('Network Activate') . '</a>';
    583 
    584                 if ( current_user_can('delete_plugins') )
    585                     $actions['delete'] = '<a href="' . wp_nonce_url('plugins.php?action=delete-selected&amp;checked[]=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page, 'bulk-manage-plugins') . '" title="' . __('Delete this plugin') . '" class="delete">' . __('Delete') . '</a>';
    586             } // end if $is_active
    587 
    588             if ( current_user_can('edit_plugins') && is_writable(WP_PLUGIN_DIR . '/' . $plugin_file) )
    589                 $actions['edit'] = '<a href="plugin-editor.php?file=' . $plugin_file . '" title="' . __('Open this file in the Plugin Editor') . '" class="edit">' . __('Edit') . '</a>';
    590         } // end if $context
    591 
    592         $actions = apply_filters( 'plugin_action_links', array_filter( $actions ), $plugin_file, $plugin_data, $context );
    593         $actions = apply_filters( "plugin_action_links_$plugin_file", $actions, $plugin_file, $plugin_data, $context );
    594 
    595         $class = $is_active ? 'active' : 'inactive';
    596         $checkbox = in_array( $context, array( 'mustuse', 'dropins' ) ) ? '' : "<input type='checkbox' name='checked[]' value='" . esc_attr($plugin_file) . "' />";
    597         if ( 'dropins' != $context ) {
    598             $description = '<p>' . $plugin_data['Description'] . '</p>';
    599             $plugin_name = $plugin_data['Name'];
    600         }
    601         echo "
    602     <tr class='$class'>
    603         <th scope='row' class='check-column'>$checkbox</th>
    604         <td class='plugin-title'><strong>$plugin_name</strong></td>
    605         <td class='desc'>$description</td>
    606     </tr>
    607     <tr class='$class second'>
    608         <td></td>
    609         <td class='plugin-title'>";
    610         echo '<div class="row-actions-visible">';
    611         foreach ( $actions as $action => $link ) {
    612             $sep = end($actions) == $link ? '' : ' | ';
    613             echo "<span class='$action'>$link$sep</span>";
    614         }
    615         echo "</div></td>
    616         <td class='desc'>";
    617         $plugin_meta = array();
    618         if ( !empty($plugin_data['Version']) )
    619             $plugin_meta[] = sprintf(__('Version %s'), $plugin_data['Version']);
    620         if ( !empty($plugin_data['Author']) ) {
    621             $author = $plugin_data['Author'];
    622             if ( !empty($plugin_data['AuthorURI']) )
    623                 $author = '<a href="' . $plugin_data['AuthorURI'] . '" title="' . __( 'Visit author homepage' ) . '">' . $plugin_data['Author'] . '</a>';
    624             $plugin_meta[] = sprintf( __('By %s'), $author );
    625         }
    626         if ( ! empty($plugin_data['PluginURI']) )
    627             $plugin_meta[] = '<a href="' . $plugin_data['PluginURI'] . '" title="' . __( 'Visit plugin site' ) . '">' . __('Visit plugin site') . '</a>';
    628 
    629         $plugin_meta = apply_filters('plugin_row_meta', $plugin_meta, $plugin_file, $plugin_data, $context);
    630         echo implode(' | ', $plugin_meta);
    631         echo "</td>
    632     </tr>\n";
    633 
    634         do_action( 'after_plugin_row', $plugin_file, $plugin_data, $context );
    635         do_action( "after_plugin_row_$plugin_file", $plugin_file, $plugin_data, $context );
    636     }
    637 ?>
    638     </tbody>
    639 </table>
    640 <?php
    641 } //End print_plugins_table()
    642 
    643 /**
    644  * @ignore
    645  *
    646  * @param string $context
    647  */
    648 function print_plugin_actions($context, $field_name = 'action' ) {
    649     if ( in_array( $context, array( 'mustuse', 'dropins' ) ) )
    650         return;
    651 ?>
    652     <div class="alignleft actions">
    653         <select name="<?php echo $field_name; ?>">
    654             <option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
    655     <?php if ( 'active' != $context ) : ?>
    656             <option value="activate-selected"><?php _e('Activate'); ?></option>
    657     <?php endif; ?>
    658     <?php if ( is_multisite() && 'network' != $context ) : ?>
    659             <option value="network-activate-selected"><?php _e('Network Activate'); ?></option>
    660     <?php endif; ?>
    661     <?php if ( 'inactive' != $context && 'recent' != $context ) : ?>
    662             <option value="deactivate-selected"><?php _e('Deactivate'); ?></option>
    663     <?php endif; ?>
    664     <?php if ( current_user_can( 'update_plugins' ) ) : ?>
    665             <option value="update-selected"><?php _e( 'Upgrade' ); ?></option>
    666     <?php endif; ?>
    667     <?php if ( current_user_can('delete_plugins') && ( 'active' != $context ) ) : ?>
    668             <option value="delete-selected"><?php _e('Delete'); ?></option>
    669     <?php endif; ?>
    670         </select>
    671         <input type="submit" name="doaction_active" value="<?php esc_attr_e('Apply'); ?>" class="button-secondary action" />
    672     <?php if ( 'recent' == $context ) : ?>
    673         <input type="submit" name="clear-recent-list" value="<?php esc_attr_e('Clear List') ?>" class="button-secondary" />
    674     <?php endif; ?>
    675     </div>
    676 <?php
    677 }
    678 ?>
    679 
    680 <form method="get" action="">
    681 <p class="search-box">
    682     <label class="screen-reader-text" for="plugin-search-input"><?php _e( 'Search Plugins' ); ?>:</label>
    683     <input type="text" id="plugin-search-input" name="s" value="<?php _admin_search_query(); ?>" />
    684     <input type="submit" value="<?php esc_attr_e( 'Search Installed Plugins' ); ?>" class="button" />
    685 </p>
    686 </form>
    687 
    688 <?php do_action( 'pre_current_active_plugins', $all_plugins ) ?>
    689 
    690 <form method="post" action="<?php echo admin_url('plugins.php') ?>">
    691 <?php wp_nonce_field('bulk-manage-plugins') ?>
     391<h2><?php echo esc_html( $title );
     392if ( ( ! is_multisite() || is_network_admin() ) && current_user_can('install_plugins') ) { ?>
     393<a href="<?php echo self_admin_url( 'plugin-install.php' ); ?>" class="button add-new-h2"><?php echo esc_html_x('Add New', 'plugin'); ?></a>
     394<?php }
     395if ( $s )
     396    printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html( $s ) ); ?>
     397</h2>
     398
     399<?php do_action( 'pre_current_active_plugins', $plugins['all'] ) ?>
     400
     401<?php $wp_list_table->views(); ?>
     402
     403<form method="post" action="">
     404
     405<?php $wp_list_table->search_box( __( 'Search Plugins' ), 'plugin' ); ?>
     406
    692407<input type="hidden" name="plugin_status" value="<?php echo esc_attr($status) ?>" />
    693408<input type="hidden" name="paged" value="<?php echo esc_attr($page) ?>" />
    694409
    695 <ul class="subsubsub">
    696 <?php
    697 $status_links = array();
    698 $class = ( 'all' == $status ) ? ' class="current"' : '';
    699 $status_links[] = "<li><a href='plugins.php?plugin_status=all' $class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_all_plugins, 'plugins' ), number_format_i18n( $total_all_plugins ) ) . '</a>';
    700 if ( ! empty($active_plugins) ) {
    701     $class = ( 'active' == $status ) ? ' class="current"' : '';
    702     $status_links[] = "<li><a href='plugins.php?plugin_status=active' $class>" . sprintf( _n( 'Active <span class="count">(%s)</span>', 'Active <span class="count">(%s)</span>', $total_active_plugins ), number_format_i18n( $total_active_plugins ) ) . '</a>';
    703 }
    704 if ( ! empty($recent_plugins) ) {
    705     $class = ( 'recent' == $status ) ? ' class="current"' : '';
    706     $status_links[] = "<li><a href='plugins.php?plugin_status=recent' $class>" . sprintf( _n( 'Recently Active <span class="count">(%s)</span>', 'Recently Active <span class="count">(%s)</span>', $total_recent_plugins ), number_format_i18n( $total_recent_plugins ) ) . '</a>';
    707 }
    708 if ( ! empty($inactive_plugins) ) {
    709     $class = ( 'inactive' == $status ) ? ' class="current"' : '';
    710     $status_links[] = "<li><a href='plugins.php?plugin_status=inactive' $class>" . sprintf( _n( 'Inactive <span class="count">(%s)</span>', 'Inactive <span class="count">(%s)</span>', $total_inactive_plugins ), number_format_i18n( $total_inactive_plugins ) ) . '</a>';
    711 }
    712 if ( ! empty($network_plugins) ) {
    713     $class = ( 'network' == $status ) ? ' class="current"' : '';
    714     $status_links[] = "<li><a href='plugins.php?plugin_status=network' $class>" . sprintf( _n( 'Network <span class="count">(%s)</span>', 'Network <span class="count">(%s)</span>', $total_network_plugins ), number_format_i18n( $total_network_plugins ) ) . '</a>';
    715 }
    716 if ( ! empty($mustuse_plugins) ) {
    717     $class = ( 'mustuse' == $status ) ? ' class="current"' : '';
    718     $status_links[] = "<li><a href='plugins.php?plugin_status=mustuse' $class>" . sprintf( _n( 'Must-Use <span class="count">(%s)</span>', 'Must-Use <span class="count">(%s)</span>', $total_mustuse_plugins ), number_format_i18n( $total_mustuse_plugins ) ) . '</a>';
    719 }
    720 if ( ! empty($dropins_plugins) ) {
    721     $class = ( 'dropins' == $status ) ? ' class="current"' : '';
    722     $status_links[] = "<li><a href='plugins.php?plugin_status=dropins' $class>" . sprintf( _n( 'Drop-ins <span class="count">(%s)</span>', 'Drop-ins <span class="count">(%s)</span>', $total_dropins_plugins ), number_format_i18n( $total_dropins_plugins ) ) . '</a>';
    723 }
    724 if ( ! empty($upgrade_plugins) ) {
    725     $class = ( 'upgrade' == $status ) ? ' class="current"' : '';
    726     $status_links[] = "<li><a href='plugins.php?plugin_status=upgrade' $class>" . sprintf( _n( 'Upgrade Available <span class="count">(%s)</span>', 'Upgrade Available <span class="count">(%s)</span>', $total_upgrade_plugins ), number_format_i18n( $total_upgrade_plugins ) ) . '</a>';
    727 }
    728 if ( ! empty($search_plugins) ) {
    729     $class = ( 'search' == $status ) ? ' class="current"' : '';
    730     $term = isset($_REQUEST['s']) ? urlencode(stripslashes($_REQUEST['s'])) : '';
    731     $status_links[] = "<li><a href='plugins.php?s=$term' $class>" . sprintf( _n( 'Search Results <span class="count">(%s)</span>', 'Search Results <span class="count">(%s)</span>', $total_search_plugins ), number_format_i18n( $total_search_plugins ) ) . '</a>';
    732 }
    733 echo implode( " |</li>\n", $status_links ) . '</li>';
    734 unset( $status_links );
    735 ?>
    736 </ul>
    737 
    738410<?php
    739411if ( 'mustuse' == $status )
    740     echo '<div class="clear"></div><p>' . __( 'Files in the <code>/wp-content/mu-plugins</code> directory are executed automatically.' ) . '</p>';
     412    echo '<br class="clear" /><p>' . __( 'Files in the <code>/wp-content/mu-plugins</code> directory are executed automatically.' ) . '</p>';
    741413elseif ( 'dropins' == $status )
    742     echo '<div class="clear"></div><p>' . __( 'Drop-ins are advanced plugins in the <code>/wp-content</code> directory that replace WordPress functionality when present.' ) . '</p>';
    743 
    744 if ( !empty( $plugins ) && ( ! in_array( $status, array( 'mustuse', 'dropins' ) ) || $page_links ) ) :
     414    echo '<br class="clear" /><p>' . __( 'Drop-ins are advanced plugins in the <code>/wp-content</code> directory that replace WordPress functionality when present.' ) . '</p>';
    745415?>
    746 <div class="tablenav">
     416
     417<?php $wp_list_table->display(); ?>
     418</form>
     419
     420</div>
     421
    747422<?php
    748 if ( $page_links )
    749     echo '<div class="tablenav-pages">', $page_links_text, '</div>';
    750 
    751 print_plugin_actions($status);
    752 ?>
    753 </div>
    754 <div class="clear"></div>
    755 <?php
    756 endif;
    757 
    758 if ( $total_this_page > $plugins_per_page )
    759     $plugins = array_slice($plugins, $start, $plugins_per_page);
    760 
    761 print_plugins_table($plugins, $status);
    762 
    763 if ( !empty( $plugins ) && ! in_array( $status, array( 'mustuse', 'dropins' ) ) || $page_links ) {
    764 ?>
    765 <div class="tablenav">
    766 <?php
    767 if ( $page_links )
    768     echo "<div class='tablenav-pages'>$page_links_text</div>";
    769 
    770 print_plugin_actions($status, "action2");
    771 ?>
    772 </div>
    773 <?php } ?>
    774 </form>
    775 
    776 <?php if ( empty($all_plugins) ) : ?>
    777 <br class="clear" />
    778 <p><?php _e('You do not appear to have any plugins available at this time.') ?></p>
    779 <?php endif; ?>
    780 
    781 </div>
    782 
    783 <?php
    784 include('./admin-footer.php');
    785 ?>
     423include(ABSPATH . 'wp-admin/admin-footer.php');
Note: See TracChangeset for help on using the changeset viewer.