Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (8 years ago)
Author:
pento
Message:

Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.

File:
1 edited

Legend:

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

    r42201 r42343  
    1010require_once( dirname( __FILE__ ) . '/admin.php' );
    1111
    12 if ( ! current_user_can('activate_plugins') )
     12if ( ! current_user_can( 'activate_plugins' ) ) {
    1313    wp_die( __( 'Sorry, you are not allowed to manage plugins for this site.' ) );
    14 
    15 $wp_list_table = _get_list_table('WP_Plugins_List_Table');
    16 $pagenum = $wp_list_table->get_pagenum();
     14}
     15
     16$wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
     17$pagenum       = $wp_list_table->get_pagenum();
    1718
    1819$action = $wp_list_table->current_action();
    1920
    20 $plugin = isset($_REQUEST['plugin']) ? wp_unslash( $_REQUEST['plugin'] ) : '';
    21 $s = isset($_REQUEST['s']) ? urlencode( wp_unslash( $_REQUEST['s'] ) ) : '';
     21$plugin = isset( $_REQUEST['plugin'] ) ? wp_unslash( $_REQUEST['plugin'] ) : '';
     22$s      = isset( $_REQUEST['s'] ) ? urlencode( wp_unslash( $_REQUEST['s'] ) ) : '';
    2223
    2324// Clean up request URI from temporary args for screen options/paging uri's to work as expected.
    24 $_SERVER['REQUEST_URI'] = remove_query_arg(array('error', 'deleted', 'activate', 'activate-multi', 'deactivate', 'deactivate-multi', '_error_nonce'), $_SERVER['REQUEST_URI']);
     25$_SERVER['REQUEST_URI'] = remove_query_arg( array( 'error', 'deleted', 'activate', 'activate-multi', 'deactivate', 'deactivate-multi', '_error_nonce' ), $_SERVER['REQUEST_URI'] );
    2526
    2627wp_enqueue_script( 'updates' );
     
    3536
    3637            if ( is_multisite() && ! is_network_admin() && is_network_only_plugin( $plugin ) ) {
    37                 wp_redirect( self_admin_url("plugins.php?plugin_status=$status&paged=$page&s=$s") );
    38                 exit;
    39             }
    40 
    41             check_admin_referer('activate-plugin_' . $plugin);
    42 
    43             $result = activate_plugin($plugin, self_admin_url('plugins.php?error=true&plugin=' . urlencode( $plugin ) ), is_network_admin() );
     38                wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) );
     39                exit;
     40            }
     41
     42            check_admin_referer( 'activate-plugin_' . $plugin );
     43
     44            $result = activate_plugin( $plugin, self_admin_url( 'plugins.php?error=true&plugin=' . urlencode( $plugin ) ), is_network_admin() );
    4445            if ( is_wp_error( $result ) ) {
    4546                if ( 'unexpected_output' == $result->get_error_code() ) {
    46                     $redirect = self_admin_url('plugins.php?error=true&charsout=' . strlen($result->get_error_data()) . '&plugin=' . urlencode( $plugin ) . "&plugin_status=$status&paged=$page&s=$s");
    47                     wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), $redirect));
     47                    $redirect = self_admin_url( 'plugins.php?error=true&charsout=' . strlen( $result->get_error_data() ) . '&plugin=' . urlencode( $plugin ) . "&plugin_status=$status&paged=$page&s=$s" );
     48                    wp_redirect( add_query_arg( '_error_nonce', wp_create_nonce( 'plugin-activation-error_' . $plugin ), $redirect ) );
    4849                    exit;
    4950                } else {
    50                     wp_die($result);
     51                    wp_die( $result );
    5152                }
    5253            }
     
    6263            }
    6364
    64             if ( isset($_GET['from']) && 'import' == $_GET['from'] ) {
    65                 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, stripping the -importer suffix
    66             } else if ( isset($_GET['from']) && 'press-this' == $_GET['from'] ) {
    67                 wp_redirect( self_admin_url( "press-this.php") );
    68             } else {
    69                 wp_redirect( self_admin_url("plugins.php?activate=true&plugin_status=$status&paged=$page&s=$s") ); // overrides the ?error=true one above
     65            if ( isset( $_GET['from'] ) && 'import' == $_GET['from'] ) {
     66                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, stripping the -importer suffix
     67            } elseif ( isset( $_GET['from'] ) && 'press-this' == $_GET['from'] ) {
     68                wp_redirect( self_admin_url( 'press-this.php' ) );
     69            } else {
     70                wp_redirect( self_admin_url( "plugins.php?activate=true&plugin_status=$status&paged=$page&s=$s" ) ); // overrides the ?error=true one above
    7071            }
    7172            exit;
    7273
    7374        case 'activate-selected':
    74             if ( ! current_user_can('activate_plugins') )
    75                 wp_die(__('Sorry, you are not allowed to activate plugins for this site.'));
    76 
    77             check_admin_referer('bulk-plugins');
     75            if ( ! current_user_can( 'activate_plugins' ) ) {
     76                wp_die( __( 'Sorry, you are not allowed to activate plugins for this site.' ) );
     77            }
     78
     79            check_admin_referer( 'bulk-plugins' );
    7880
    7981            $plugins = isset( $_POST['checked'] ) ? (array) wp_unslash( $_POST['checked'] ) : array();
     
    99101            }
    100102
    101             if ( empty($plugins) ) {
    102                 wp_redirect( self_admin_url("plugins.php?plugin_status=$status&paged=$page&s=$s") );
    103                 exit;
    104             }
    105 
    106             activate_plugins($plugins, self_admin_url('plugins.php?error=true'), is_network_admin() );
     103            if ( empty( $plugins ) ) {
     104                wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) );
     105                exit;
     106            }
     107
     108            activate_plugins( $plugins, self_admin_url( 'plugins.php?error=true' ), is_network_admin() );
    107109
    108110            if ( ! is_network_admin() ) {
    109                 $recent = (array) get_option('recently_activated' );
    110             } else {
    111                 $recent = (array) get_site_option('recently_activated' );
     111                $recent = (array) get_option( 'recently_activated' );
     112            } else {
     113                $recent = (array) get_site_option( 'recently_activated' );
    112114            }
    113115
     
    122124            }
    123125
    124             wp_redirect( self_admin_url("plugins.php?activate-multi=true&plugin_status=$status&paged=$page&s=$s") );
    125             exit;
    126 
    127         case 'update-selected' :
    128 
     126            wp_redirect( self_admin_url( "plugins.php?activate-multi=true&plugin_status=$status&paged=$page&s=$s" ) );
     127            exit;
     128
     129        case 'update-selected':
    129130            check_admin_referer( 'bulk-plugins' );
    130131
    131             if ( isset( $_GET['plugins'] ) )
     132            if ( isset( $_GET['plugins'] ) ) {
    132133                $plugins = explode( ',', wp_unslash( $_GET['plugins'] ) );
    133             elseif ( isset( $_POST['checked'] ) )
     134            } elseif ( isset( $_POST['checked'] ) ) {
    134135                $plugins = (array) wp_unslash( $_POST['checked'] );
    135             else
     136            } else {
    136137                $plugins = array();
    137 
    138             $title = __( 'Update Plugins' );
     138            }
     139
     140            $title       = __( 'Update Plugins' );
    139141            $parent_file = 'plugins.php';
    140142
    141143            wp_enqueue_script( 'updates' );
    142             require_once(ABSPATH . 'wp-admin/admin-header.php');
     144            require_once( ABSPATH . 'wp-admin/admin-header.php' );
    143145
    144146            echo '<div class="wrap">';
    145147            echo '<h1>' . esc_html( $title ) . '</h1>';
    146148
    147             $url = self_admin_url('update.php?action=update-selected&amp;plugins=' . urlencode( join(',', $plugins) ));
    148             $url = wp_nonce_url($url, 'bulk-update-plugins');
     149            $url = self_admin_url( 'update.php?action=update-selected&amp;plugins=' . urlencode( join( ',', $plugins ) ) );
     150            $url = wp_nonce_url( $url, 'bulk-update-plugins' );
    149151
    150152            echo "<iframe src='$url' style='width: 100%; height:100%; min-height:850px;'></iframe>";
    151153            echo '</div>';
    152             require_once(ABSPATH . 'wp-admin/admin-footer.php');
     154            require_once( ABSPATH . 'wp-admin/admin-footer.php' );
    153155            exit;
    154156
     
    158160            }
    159161
    160             check_admin_referer('plugin-activation-error_' . $plugin);
    161 
    162             $valid = validate_plugin($plugin);
    163             if ( is_wp_error($valid) )
    164                 wp_die($valid);
     162            check_admin_referer( 'plugin-activation-error_' . $plugin );
     163
     164            $valid = validate_plugin( $plugin );
     165            if ( is_wp_error( $valid ) ) {
     166                wp_die( $valid );
     167            }
    165168
    166169            if ( ! WP_DEBUG ) {
     
    168171            }
    169172
    170             @ini_set('display_errors', true); //Ensure that Fatal errors are displayed.
     173            @ini_set( 'display_errors', true ); //Ensure that Fatal errors are displayed.
    171174            // Go back to "sandbox" scope so we get the same errors as before
    172175            plugin_sandbox_scrape( $plugin );
     
    180183            }
    181184
    182             check_admin_referer('deactivate-plugin_' . $plugin);
     185            check_admin_referer( 'deactivate-plugin_' . $plugin );
    183186
    184187            if ( ! is_network_admin() && is_plugin_active_for_network( $plugin ) ) {
    185                 wp_redirect( self_admin_url("plugins.php?plugin_status=$status&paged=$page&s=$s") );
     188                wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) );
    186189                exit;
    187190            }
     
    195198            }
    196199
    197             if ( headers_sent() )
     200            if ( headers_sent() ) {
    198201                echo "<meta http-equiv='refresh' content='" . esc_attr( "0;url=plugins.php?deactivate=true&plugin_status=$status&paged=$page&s=$s" ) . "' />";
    199             else
    200                 wp_redirect( self_admin_url("plugins.php?deactivate=true&plugin_status=$status&paged=$page&s=$s") );
     202            } else {
     203                wp_redirect( self_admin_url( "plugins.php?deactivate=true&plugin_status=$status&paged=$page&s=$s" ) );
     204            }
    201205            exit;
    202206
    203207        case 'deactivate-selected':
    204208            if ( ! current_user_can( 'deactivate_plugins' ) ) {
    205                 wp_die(__('Sorry, you are not allowed to deactivate plugins for this site.'));
    206             }
    207 
    208             check_admin_referer('bulk-plugins');
     209                wp_die( __( 'Sorry, you are not allowed to deactivate plugins for this site.' ) );
     210            }
     211
     212            check_admin_referer( 'bulk-plugins' );
    209213
    210214            $plugins = isset( $_POST['checked'] ) ? (array) wp_unslash( $_POST['checked'] ) : array();
     
    222226                    }
    223227                }
    224 
    225             }
    226             if ( empty($plugins) ) {
    227                 wp_redirect( self_admin_url("plugins.php?plugin_status=$status&paged=$page&s=$s") );
     228            }
     229            if ( empty( $plugins ) ) {
     230                wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) );
    228231                exit;
    229232            }
     
    242245            }
    243246
    244             wp_redirect( self_admin_url("plugins.php?deactivate-multi=true&plugin_status=$status&paged=$page&s=$s") );
     247            wp_redirect( self_admin_url( "plugins.php?deactivate-multi=true&plugin_status=$status&paged=$page&s=$s" ) );
    245248            exit;
    246249
    247250        case 'delete-selected':
    248             if ( ! current_user_can('delete_plugins') ) {
    249                 wp_die(__('Sorry, you are not allowed to delete plugins for this site.'));
    250             }
    251 
    252             check_admin_referer('bulk-plugins');
     251            if ( ! current_user_can( 'delete_plugins' ) ) {
     252                wp_die( __( 'Sorry, you are not allowed to delete plugins for this site.' ) );
     253            }
     254
     255            check_admin_referer( 'bulk-plugins' );
    253256
    254257            //$_POST = from the plugin form; $_GET = from the FTP details screen.
    255258            $plugins = isset( $_REQUEST['checked'] ) ? (array) wp_unslash( $_REQUEST['checked'] ) : array();
    256259            if ( empty( $plugins ) ) {
    257                 wp_redirect( self_admin_url("plugins.php?plugin_status=$status&paged=$page&s=$s") );
    258                 exit;
    259             }
    260 
    261             $plugins = array_filter($plugins, 'is_plugin_inactive'); // Do not allow to delete Activated plugins.
     260                wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) );
     261                exit;
     262            }
     263
     264            $plugins = array_filter( $plugins, 'is_plugin_inactive' ); // Do not allow to delete Activated plugins.
    262265            if ( empty( $plugins ) ) {
    263266                wp_redirect( self_admin_url( "plugins.php?error=true&main=true&plugin_status=$status&paged=$page&s=$s" ) );
     
    269272            $invalid_plugin_files = array_filter( $plugins, 'validate_file' );
    270273            if ( $invalid_plugin_files ) {
    271                 wp_redirect( self_admin_url("plugins.php?plugin_status=$status&paged=$page&s=$s") );
    272                 exit;
    273             }
    274 
    275             include(ABSPATH . 'wp-admin/update.php');
     274                wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) );
     275                exit;
     276            }
     277
     278            include( ABSPATH . 'wp-admin/update.php' );
    276279
    277280            $parent_file = 'plugins.php';
    278281
    279             if ( ! isset($_REQUEST['verify-delete']) ) {
    280                 wp_enqueue_script('jquery');
    281                 require_once(ABSPATH . 'wp-admin/admin-header.php');
     282            if ( ! isset( $_REQUEST['verify-delete'] ) ) {
     283                wp_enqueue_script( 'jquery' );
     284                require_once( ABSPATH . 'wp-admin/admin-header.php' );
    282285                ?>
    283286            <div class="wrap">
    284287                <?php
    285                     $plugin_info = array();
     288                    $plugin_info              = array();
    286289                    $have_non_network_plugins = false;
    287                     foreach ( (array) $plugins as $plugin ) {
    288                         $plugin_slug = dirname( $plugin );
    289 
    290                         if ( '.' == $plugin_slug ) {
    291                             if ( $data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ) ) {
    292                                 $plugin_info[ $plugin ] = $data;
    293                                 $plugin_info[ $plugin ]['is_uninstallable'] = is_uninstallable_plugin( $plugin );
    294                                 if ( ! $plugin_info[ $plugin ]['Network'] ) {
     290                foreach ( (array) $plugins as $plugin ) {
     291                    $plugin_slug = dirname( $plugin );
     292
     293                    if ( '.' == $plugin_slug ) {
     294                        if ( $data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ) ) {
     295                            $plugin_info[ $plugin ]                     = $data;
     296                            $plugin_info[ $plugin ]['is_uninstallable'] = is_uninstallable_plugin( $plugin );
     297                            if ( ! $plugin_info[ $plugin ]['Network'] ) {
     298                                $have_non_network_plugins = true;
     299                            }
     300                        }
     301                    } else {
     302                        // Get plugins list from that folder.
     303                        if ( $folder_plugins = get_plugins( '/' . $plugin_slug ) ) {
     304                            foreach ( $folder_plugins as $plugin_file => $data ) {
     305                                $plugin_info[ $plugin_file ]                     = _get_plugin_data_markup_translate( $plugin_file, $data );
     306                                $plugin_info[ $plugin_file ]['is_uninstallable'] = is_uninstallable_plugin( $plugin );
     307                                if ( ! $plugin_info[ $plugin_file ]['Network'] ) {
    295308                                    $have_non_network_plugins = true;
    296                                 }
    297                             }
    298                         } else {
    299                             // Get plugins list from that folder.
    300                             if ( $folder_plugins = get_plugins( '/' . $plugin_slug ) ) {
    301                                 foreach ( $folder_plugins as $plugin_file => $data ) {
    302                                     $plugin_info[ $plugin_file ] = _get_plugin_data_markup_translate( $plugin_file, $data );
    303                                     $plugin_info[ $plugin_file ]['is_uninstallable'] = is_uninstallable_plugin( $plugin );
    304                                     if ( ! $plugin_info[ $plugin_file ]['Network'] ) {
    305                                         $have_non_network_plugins = true;
    306                                     }
    307309                                }
    308310                            }
    309311                        }
    310312                    }
     313                }
    311314                    $plugins_to_delete = count( $plugin_info );
    312315                ?>
     
    317320                    <?php endif; ?>
    318321                    <p><?php _e( 'You are about to remove the following plugin:' ); ?></p>
    319                 <?php else: ?>
     322                <?php else : ?>
    320323                    <h1><?php _e( 'Delete Plugins' ); ?></h1>
    321324                    <?php if ( $have_non_network_plugins && is_network_admin() ) : ?>
     
    334337                            } else {
    335338                                /* translators: 1: plugin name, 2: plugin author */
    336                                 echo '<li>', sprintf( _x('%1$s by %2$s', 'plugin' ), '<strong>' . $plugin['Name'] . '</strong>', '<em>' . $plugin['AuthorName'] ) . '</em>', '</li>';
     339                                echo '<li>', sprintf( _x( '%1$s by %2$s', 'plugin' ), '<strong>' . $plugin['Name'] . '</strong>', '<em>' . $plugin['AuthorName'] ) . '</em>', '</li>';
    337340                            }
    338341                        }
    339342                        ?>
    340343                    </ul>
    341                 <p><?php
    342                 if ( $data_to_delete )
    343                     _e('Are you sure you wish to delete these files and data?');
    344                 else
    345                     _e('Are you sure you wish to delete these files?');
    346                 ?></p>
    347                 <form method="post" action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>" style="display:inline;">
     344                <p>
     345                <?php
     346                if ( $data_to_delete ) {
     347                    _e( 'Are you sure you wish to delete these files and data?' );
     348                } else {
     349                    _e( 'Are you sure you wish to delete these files?' );
     350                }
     351                ?>
     352                </p>
     353                <form method="post" action="<?php echo esc_url( $_SERVER['REQUEST_URI'] ); ?>" style="display:inline;">
    348354                    <input type="hidden" name="verify-delete" value="1" />
    349355                    <input type="hidden" name="action" value="delete-selected" />
    350356                    <?php
    351                         foreach ( (array) $plugins as $plugin ) {
    352                             echo '<input type="hidden" name="checked[]" value="' . esc_attr( $plugin ) . '" />';
    353                         }
     357                    foreach ( (array) $plugins as $plugin ) {
     358                        echo '<input type="hidden" name="checked[]" value="' . esc_attr( $plugin ) . '" />';
     359                    }
    354360                    ?>
    355                     <?php wp_nonce_field('bulk-plugins') ?>
     361                    <?php wp_nonce_field( 'bulk-plugins' ); ?>
    356362                    <?php submit_button( $data_to_delete ? __( 'Yes, delete these files and data' ) : __( 'Yes, delete these files' ), '', 'submit', false ); ?>
    357363                </form>
     
    364370            </div>
    365371                <?php
    366                 require_once(ABSPATH . 'wp-admin/admin-footer.php');
     372                require_once( ABSPATH . 'wp-admin/admin-footer.php' );
    367373                exit;
    368374            } else {
     
    372378            $delete_result = delete_plugins( $plugins );
    373379
    374             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
    375             wp_redirect( self_admin_url("plugins.php?deleted=$plugins_to_delete&plugin_status=$status&paged=$page&s=$s") );
     380            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
     381            wp_redirect( self_admin_url( "plugins.php?deleted=$plugins_to_delete&plugin_status=$status&paged=$page&s=$s" ) );
    376382            exit;
    377383
     
    386392        default:
    387393            if ( isset( $_POST['checked'] ) ) {
    388                 check_admin_referer('bulk-plugins');
    389                 $plugins = isset( $_POST['checked'] ) ? (array) wp_unslash( $_POST['checked'] ) : array();
     394                check_admin_referer( 'bulk-plugins' );
     395                $plugins  = isset( $_POST['checked'] ) ? (array) wp_unslash( $_POST['checked'] ) : array();
    390396                $sendback = wp_get_referer();
    391397
     
    397403            break;
    398404    }
    399 
    400405}
    401406
    402407$wp_list_table->prepare_items();
    403408
    404 wp_enqueue_script('plugin-install');
     409wp_enqueue_script( 'plugin-install' );
    405410add_thickbox();
    406411
    407412add_screen_option( 'per_page', array( 'default' => 999 ) );
    408413
    409 get_current_screen()->add_help_tab( array(
    410 'id'        => 'overview',
    411 'title'     => __('Overview'),
    412 'content'   =>
    413     '<p>' . __('Plugins extend and expand the functionality of WordPress. Once a plugin is installed, you may activate it or deactivate it here.') . '</p>' .
    414     '<p>' . __( 'The search for installed plugins will search for terms in their name, description, or author.' ) . ' <span id="live-search-desc" class="hide-if-no-js">' . __( 'The search results will be updated as you type.' ) . '</span></p>' .
    415     '<p>' . sprintf(
    416         /* translators: %s: WordPress Plugin Directory URL */
    417         __( 'If you would like to see more plugins to choose from, click on the &#8220;Add New&#8221; button and you will be able to browse or search for additional plugins from the <a href="%s">WordPress Plugin Directory</a>. Plugins in the WordPress Plugin Directory are designed and developed by third parties, and are compatible with the license WordPress uses. Oh, and they&#8217;re free!' ),
    418         __( 'https://wordpress.org/plugins/' )
    419     ) . '</p>'
    420 ) );
    421 get_current_screen()->add_help_tab( array(
    422 'id'        => 'compatibility-problems',
    423 'title'     => __('Troubleshooting'),
    424 'content'   =>
    425     '<p>' . __('Most of the time, plugins play nicely with the core of WordPress and with other plugins. Sometimes, though, a plugin&#8217;s code will get in the way of another plugin, causing compatibility issues. If your site starts doing strange things, this may be the problem. Try deactivating all your plugins and re-activating them in various combinations until you isolate which one(s) caused the issue.') . '</p>' .
    426     '<p>' . sprintf(
    427         /* translators: WP_PLUGIN_DIR constant value */
    428         __( 'If something goes wrong with a plugin and you can&#8217;t use WordPress, delete or rename that file in the %s directory and it will be automatically deactivated.' ),
    429         '<code>' . WP_PLUGIN_DIR . '</code>'
    430     ) . '</p>'
    431 ) );
     414get_current_screen()->add_help_tab(
     415    array(
     416        'id'      => 'overview',
     417        'title'   => __( 'Overview' ),
     418        'content' =>
     419                 '<p>' . __( 'Plugins extend and expand the functionality of WordPress. Once a plugin is installed, you may activate it or deactivate it here.' ) . '</p>' .
     420                 '<p>' . __( 'The search for installed plugins will search for terms in their name, description, or author.' ) . ' <span id="live-search-desc" class="hide-if-no-js">' . __( 'The search results will be updated as you type.' ) . '</span></p>' .
     421                '<p>' . sprintf(
     422                    /* translators: %s: WordPress Plugin Directory URL */
     423                     __( 'If you would like to see more plugins to choose from, click on the &#8220;Add New&#8221; button and you will be able to browse or search for additional plugins from the <a href="%s">WordPress Plugin Directory</a>. Plugins in the WordPress Plugin Directory are designed and developed by third parties, and are compatible with the license WordPress uses. Oh, and they&#8217;re free!' ),
     424                    __( 'https://wordpress.org/plugins/' )
     425                ) . '</p>',
     426    )
     427);
     428get_current_screen()->add_help_tab(
     429    array(
     430        'id'      => 'compatibility-problems',
     431        'title'   => __( 'Troubleshooting' ),
     432        'content' =>
     433                 '<p>' . __( 'Most of the time, plugins play nicely with the core of WordPress and with other plugins. Sometimes, though, a plugin&#8217;s code will get in the way of another plugin, causing compatibility issues. If your site starts doing strange things, this may be the problem. Try deactivating all your plugins and re-activating them in various combinations until you isolate which one(s) caused the issue.' ) . '</p>' .
     434                '<p>' . sprintf(
     435                    /* translators: WP_PLUGIN_DIR constant value */
     436                     __( 'If something goes wrong with a plugin and you can&#8217;t use WordPress, delete or rename that file in the %s directory and it will be automatically deactivated.' ),
     437                    '<code>' . WP_PLUGIN_DIR . '</code>'
     438                ) . '</p>',
     439    )
     440);
    432441
    433442get_current_screen()->set_help_sidebar(
    434     '<p><strong>' . __('For more information:') . '</strong></p>' .
    435     '<p>' . __('<a href="https://codex.wordpress.org/Managing_Plugins#Plugin_Management">Documentation on Managing Plugins</a>') . '</p>' .
    436     '<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>'
     443    '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
     444    '<p>' . __( '<a href="https://codex.wordpress.org/Managing_Plugins#Plugin_Management">Documentation on Managing Plugins</a>' ) . '</p>' .
     445    '<p>' . __( '<a href="https://wordpress.org/support/">Support Forums</a>' ) . '</p>'
    437446);
    438447
    439 get_current_screen()->set_screen_reader_content( array(
    440     'heading_views'      => __( 'Filter plugins list' ),
    441     'heading_pagination' => __( 'Plugins list navigation' ),
    442     'heading_list'       => __( 'Plugins list' ),
    443 ) );
    444 
    445 $title = __('Plugins');
     448get_current_screen()->set_screen_reader_content(
     449    array(
     450        'heading_views'      => __( 'Filter plugins list' ),
     451        'heading_pagination' => __( 'Plugins list navigation' ),
     452        'heading_list'       => __( 'Plugins list' ),
     453    )
     454);
     455
     456$title       = __( 'Plugins' );
    446457$parent_file = 'plugins.php';
    447458
    448 require_once(ABSPATH . 'wp-admin/admin-header.php');
     459require_once( ABSPATH . 'wp-admin/admin-header.php' );
    449460
    450461$invalid = validate_active_plugins();
     
    456467            __( 'The plugin %1$s has been <strong>deactivated</strong> due to an error: %2$s' ),
    457468            '<code>' . esc_html( $plugin_file ) . '</code>',
    458             $error->get_error_message() );
     469            $error->get_error_message()
     470        );
    459471        echo '</p></div>';
    460472    }
     
    462474?>
    463475
    464 <?php if ( isset($_GET['error']) ) :
    465 
    466     if ( isset( $_GET['main'] ) )
     476<?php
     477if ( isset( $_GET['error'] ) ) :
     478
     479    if ( isset( $_GET['main'] ) ) {
    467480        $errmsg = __( 'You cannot delete a plugin while it is active on the main site.' );
    468     elseif ( isset($_GET['charsout']) )
    469         $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']);
    470     else
    471         $errmsg = __('Plugin could not be activated because it triggered a <strong>fatal error</strong>.');
     481    } elseif ( isset( $_GET['charsout'] ) ) {
     482        $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'] );
     483    } else {
     484        $errmsg = __( 'Plugin could not be activated because it triggered a <strong>fatal error</strong>.' );
     485    }
    472486    ?>
    473487    <div id="message" class="error"><p><?php echo $errmsg; ?></p>
    474488    <?php
    475         if ( ! isset( $_GET['main'] ) && ! isset( $_GET['charsout'] ) && wp_verify_nonce( $_GET['_error_nonce'], 'plugin-activation-error_' . $plugin ) ) {
    476             $iframe_url = add_query_arg( array(
     489    if ( ! isset( $_GET['main'] ) && ! isset( $_GET['charsout'] ) && wp_verify_nonce( $_GET['_error_nonce'], 'plugin-activation-error_' . $plugin ) ) {
     490        $iframe_url = add_query_arg(
     491            array(
    477492                'action'   => 'error_scrape',
    478493                'plugin'   => urlencode( $plugin ),
    479494                '_wpnonce' => urlencode( $_GET['_error_nonce'] ),
    480             ), admin_url( 'plugins.php' ) );
    481         ?>
    482         <iframe style="border:0" width="100%" height="70px" src="<?php echo esc_url( $iframe_url ); ?>"></iframe>
     495            ), admin_url( 'plugins.php' )
     496        );
     497    ?>
     498    <iframe style="border:0" width="100%" height="70px" src="<?php echo esc_url( $iframe_url ); ?>"></iframe>
    483499    <?php
    484         }
     500    }
    485501    ?>
    486502    </div>
    487 <?php elseif ( isset($_GET['deleted']) ) :
     503<?php
     504elseif ( isset( $_GET['deleted'] ) ) :
    488505        $delete_result = get_transient( 'plugins_delete_result_' . $user_ID );
    489506        // Delete it once we're done.
    490507        delete_transient( 'plugins_delete_result_' . $user_ID );
    491508
    492         if ( is_wp_error($delete_result) ) : ?>
    493         <div id="message" class="error notice is-dismissible"><p><?php printf( __('Plugin could not be deleted due to an error: %s'), $delete_result->get_error_message() ); ?></p></div>
     509    if ( is_wp_error( $delete_result ) ) :
     510        ?>
     511        <div id="message" class="error notice is-dismissible"><p><?php printf( __( 'Plugin could not be deleted due to an error: %s' ), $delete_result->get_error_message() ); ?></p></div>
    494512        <?php else : ?>
    495513        <div id="message" class="updated notice is-dismissible">
     
    505523        </div>
    506524        <?php endif; ?>
    507 <?php elseif ( isset($_GET['activate']) ) : ?>
    508     <div id="message" class="updated notice is-dismissible"><p><?php _e('Plugin <strong>activated</strong>.') ?></p></div>
    509 <?php elseif (isset($_GET['activate-multi'])) : ?>
    510     <div id="message" class="updated notice is-dismissible"><p><?php _e('Selected plugins <strong>activated</strong>.'); ?></p></div>
    511 <?php elseif ( isset($_GET['deactivate']) ) : ?>
    512     <div id="message" class="updated notice is-dismissible"><p><?php _e('Plugin <strong>deactivated</strong>.') ?></p></div>
    513 <?php elseif (isset($_GET['deactivate-multi'])) : ?>
    514     <div id="message" class="updated notice is-dismissible"><p><?php _e('Selected plugins <strong>deactivated</strong>.'); ?></p></div>
     525<?php elseif ( isset( $_GET['activate'] ) ) : ?>
     526    <div id="message" class="updated notice is-dismissible"><p><?php _e( 'Plugin <strong>activated</strong>.' ); ?></p></div>
     527<?php elseif ( isset( $_GET['activate-multi'] ) ) : ?>
     528    <div id="message" class="updated notice is-dismissible"><p><?php _e( 'Selected plugins <strong>activated</strong>.' ); ?></p></div>
     529<?php elseif ( isset( $_GET['deactivate'] ) ) : ?>
     530    <div id="message" class="updated notice is-dismissible"><p><?php _e( 'Plugin <strong>deactivated</strong>.' ); ?></p></div>
     531<?php elseif ( isset( $_GET['deactivate-multi'] ) ) : ?>
     532    <div id="message" class="updated notice is-dismissible"><p><?php _e( 'Selected plugins <strong>deactivated</strong>.' ); ?></p></div>
    515533<?php elseif ( 'update-selected' == $action ) : ?>
    516     <div id="message" class="updated notice is-dismissible"><p><?php _e('All selected plugins are up to date.'); ?></p></div>
     534    <div id="message" class="updated notice is-dismissible"><p><?php _e( 'All selected plugins are up to date.' ); ?></p></div>
    517535<?php endif; ?>
    518536
    519537<div class="wrap">
    520 <h1 class="wp-heading-inline"><?php
     538<h1 class="wp-heading-inline">
     539<?php
    521540echo esc_html( $title );
    522 ?></h1>
    523 
    524 <?php
    525 if ( ( ! is_multisite() || is_network_admin() ) && current_user_can('install_plugins') ) { ?>
     541?>
     542</h1>
     543
     544<?php
     545if ( ( ! is_multisite() || is_network_admin() ) && current_user_can( 'install_plugins' ) ) {
     546?>
    526547    <a href="<?php echo self_admin_url( 'plugin-install.php' ); ?>" class="page-title-action"><?php echo esc_html_x( 'Add New', 'plugin' ); ?></a>
    527548<?php
     
    560581<form method="post" id="bulk-action-form">
    561582
    562 <input type="hidden" name="plugin_status" value="<?php echo esc_attr($status) ?>" />
    563 <input type="hidden" name="paged" value="<?php echo esc_attr($page) ?>" />
     583<input type="hidden" name="plugin_status" value="<?php echo esc_attr( $status ); ?>" />
     584<input type="hidden" name="paged" value="<?php echo esc_attr( $page ); ?>" />
    564585
    565586<?php $wp_list_table->display(); ?>
     
    574595wp_print_update_row_templates();
    575596
    576 include(ABSPATH . 'wp-admin/admin-footer.php');
     597include( ABSPATH . 'wp-admin/admin-footer.php' );
Note: See TracChangeset for help on using the changeset viewer.