Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (6 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/import.php

    r38725 r42343  
    77 */
    88
    9 define('WP_LOAD_IMPORTERS', true);
     9define( 'WP_LOAD_IMPORTERS', true );
    1010
    1111/** Load WordPress Bootstrap */
     
    1616}
    1717
    18 $title = __('Import');
    19 
    20 get_current_screen()->add_help_tab( array(
    21     'id'      => 'overview',
    22     'title'   => __('Overview'),
    23     'content' => '<p>' . __('This screen lists links to plugins to import data from blogging/content management platforms. Choose the platform you want to import from, and click Install Now when you are prompted in the popup window. If your platform is not listed, click the link to search the plugin directory for other importer plugins to see if there is one for your platform.') . '</p>' .
    24         '<p>' . __('In previous versions of WordPress, all importers were built-in. They have been turned into plugins since most people only use them once or infrequently.') . '</p>',
    25 ) );
     18$title = __( 'Import' );
     19
     20get_current_screen()->add_help_tab(
     21    array(
     22        'id'      => 'overview',
     23        'title'   => __( 'Overview' ),
     24        'content' => '<p>' . __( 'This screen lists links to plugins to import data from blogging/content management platforms. Choose the platform you want to import from, and click Install Now when you are prompted in the popup window. If your platform is not listed, click the link to search the plugin directory for other importer plugins to see if there is one for your platform.' ) . '</p>' .
     25            '<p>' . __( 'In previous versions of WordPress, all importers were built-in. They have been turned into plugins since most people only use them once or infrequently.' ) . '</p>',
     26    )
     27);
    2628
    2729get_current_screen()->set_help_sidebar(
    28     '<p><strong>' . __('For more information:') . '</strong></p>' .
    29     '<p>' . __('<a href="https://codex.wordpress.org/Tools_Import_Screen">Documentation on Import</a>') . '</p>' .
    30     '<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>'
     30    '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
     31    '<p>' . __( '<a href="https://codex.wordpress.org/Tools_Import_Screen">Documentation on Import</a>' ) . '</p>' .
     32    '<p>' . __( '<a href="https://wordpress.org/support/">Support Forums</a>' ) . '</p>'
    3133);
    3234
     
    3537    $popular_importers = wp_get_popular_importers();
    3638} else {
    37     $popular_importers = array();
     39    $popular_importers = array();
    3840}
    3941
     
    6062<?php if ( ! empty( $_GET['invalid'] ) ) : ?>
    6163    <div class="error">
    62         <p><strong><?php _e( 'ERROR:' ); ?></strong> <?php
    63             /* translators: %s: importer slug */
    64             printf( __( 'The %s importer is invalid or is not installed.' ), '<strong>' . esc_html( $_GET['invalid'] ) . '</strong>' );
    65         ?></p>
     64        <p><strong><?php _e( 'ERROR:' ); ?></strong>
     65                                <?php
     66                                /* translators: %s: importer slug */
     67                                printf( __( 'The %s importer is invalid or is not installed.' ), '<strong>' . esc_html( $_GET['invalid'] ) . '</strong>' );
     68        ?>
     69        </p>
    6670    </div>
    6771<?php endif; ?>
    68 <p><?php _e('If you have posts or comments in another system, WordPress can import those into this site. To get started, choose a system to import from below:'); ?></p>
     72<p><?php _e( 'If you have posts or comments in another system, WordPress can import those into this site. To get started, choose a system to import from below:' ); ?></p>
    6973
    7074<?php
     
    7478// If a popular importer is not registered, create a dummy registration that links to the plugin installer.
    7579foreach ( $popular_importers as $pop_importer => $pop_data ) {
    76     if ( isset( $importers[ $pop_importer ] ) )
     80    if ( isset( $importers[ $pop_importer ] ) ) {
    7781        continue;
    78     if ( isset( $importers[ $pop_data['importer-id'] ] ) )
     82    }
     83    if ( isset( $importers[ $pop_data['importer-id'] ] ) ) {
    7984        continue;
     85    }
    8086
    8187    // Fill the array of registered (already installed) importers with data of the popular importers from the WordPress.org API.
    82     $importers[ $pop_data['importer-id'] ] = array( $pop_data['name'], $pop_data['description'], 'install' => $pop_data['plugin-slug'] );
     88    $importers[ $pop_data['importer-id'] ] = array(
     89        $pop_data['name'],
     90        $pop_data['description'],
     91        'install' => $pop_data['plugin-slug'],
     92    );
    8393}
    8494
    8595if ( empty( $importers ) ) {
    86     echo '<p>' . __('No importers are available.') . '</p>'; // TODO: make more helpful
     96    echo '<p>' . __( 'No importers are available.' ) . '</p>'; // TODO: make more helpful
    8797} else {
    8898    uasort( $importers, '_usort_by_first_member' );
     
    92102    <?php
    93103    foreach ( $importers as $importer_id => $data ) {
    94         $plugin_slug = $action = '';
     104        $plugin_slug         = $action = '';
    95105        $is_plugin_installed = false;
    96106
     
    102112                $plugins = get_plugins( '/' . $plugin_slug );
    103113                if ( ! empty( $plugins ) ) {
    104                     $keys = array_keys( $plugins );
     114                    $keys        = array_keys( $plugins );
    105115                    $plugin_file = $plugin_slug . '/' . $keys[0];
    106                     $url = wp_nonce_url( add_query_arg( array(
    107                         'action' => 'activate',
    108                         'plugin' => $plugin_file,
    109                         'from'   => 'import',
    110                     ), admin_url( 'plugins.php' ) ), 'activate-plugin_' . $plugin_file );
    111                     $action = sprintf(
     116                    $url         = wp_nonce_url(
     117                        add_query_arg(
     118                            array(
     119                                'action' => 'activate',
     120                                'plugin' => $plugin_file,
     121                                'from'   => 'import',
     122                            ), admin_url( 'plugins.php' )
     123                        ), 'activate-plugin_' . $plugin_file
     124                    );
     125                    $action      = sprintf(
    112126                        '<a href="%s" aria-label="%s">%s</a>',
    113127                        esc_url( $url ),
     
    123137            if ( empty( $action ) ) {
    124138                if ( is_main_site() ) {
    125                     $url = wp_nonce_url( add_query_arg( array(
    126                         'action' => 'install-plugin',
    127                         'plugin' => $plugin_slug,
    128                         'from'   => 'import',
    129                     ), self_admin_url( 'update.php' ) ), 'install-plugin_' . $plugin_slug );
     139                    $url    = wp_nonce_url(
     140                        add_query_arg(
     141                            array(
     142                                'action' => 'install-plugin',
     143                                'plugin' => $plugin_slug,
     144                                'from'   => 'import',
     145                            ), self_admin_url( 'update.php' )
     146                        ), 'install-plugin_' . $plugin_slug
     147                    );
    130148                    $action = sprintf(
    131149                        '<a href="%1$s" class="install-now" data-slug="%2$s" data-name="%3$s" aria-label="%4$s">%5$s</a>',
     
    146164            }
    147165        } else {
    148             $url = add_query_arg( array(
    149                 'import' => $importer_id,
    150             ), self_admin_url( 'admin.php' ) );
     166            $url    = add_query_arg(
     167                array(
     168                    'import' => $importer_id,
     169                ), self_admin_url( 'admin.php' )
     170            );
    151171            $action = sprintf(
    152172                '<a href="%1$s" aria-label="%2$s">%3$s</a>',
     
    161181
    162182        if ( ! $is_plugin_installed && is_main_site() ) {
    163             $url = add_query_arg( array(
    164                 'tab'       => 'plugin-information',
    165                 'plugin'    => $plugin_slug,
    166                 'from'      => 'import',
    167                 'TB_iframe' => 'true',
    168                 'width'     => 600,
    169                 'height'    => 550,
    170             ), network_admin_url( 'plugin-install.php' ) );
     183            $url     = add_query_arg(
     184                array(
     185                    'tab'       => 'plugin-information',
     186                    'plugin'    => $plugin_slug,
     187                    'from'      => 'import',
     188                    'TB_iframe' => 'true',
     189                    'width'     => 600,
     190                    'height'    => 550,
     191                ), network_admin_url( 'plugin-install.php' )
     192            );
    171193            $action .= sprintf(
    172194                ' | <a href="%1$s" class="thickbox open-plugin-details-modal" aria-label="%2$s">%3$s</a>',
     
    194216}
    195217
    196 if ( current_user_can('install_plugins') )
    197     echo '<p>' . sprintf( __('If the importer you need is not listed, <a href="%s">search the plugin directory</a> to see if an importer is available.'), esc_url( network_admin_url( 'plugin-install.php?tab=search&type=tag&s=importer' ) ) ) . '</p>';
     218if ( current_user_can( 'install_plugins' ) ) {
     219    echo '<p>' . sprintf( __( 'If the importer you need is not listed, <a href="%s">search the plugin directory</a> to see if an importer is available.' ), esc_url( network_admin_url( 'plugin-install.php?tab=search&type=tag&s=importer' ) ) ) . '</p>';
     220}
    198221?>
    199222
Note: See TracChangeset for help on using the changeset viewer.