Make WordPress Core


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

    r41605 r42343  
    5454function register_importer( $id, $name, $description, $callback ) {
    5555    global $wp_importers;
    56     if ( is_wp_error( $callback ) )
     56    if ( is_wp_error( $callback ) ) {
    5757        return $callback;
    58     $wp_importers[$id] = array ( $name, $description, $callback );
     58    }
     59    $wp_importers[ $id ] = array( $name, $description, $callback );
    5960}
    6061
     
    8283    if ( ! isset( $_FILES['import'] ) ) {
    8384        return array(
    84             'error' => __( 'File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.' )
     85            'error' => __( 'File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.' ),
    8586        );
    8687    }
    8788
    88     $overrides = array( 'test_form' => false, 'test_type' => false );
     89    $overrides                 = array(
     90        'test_form' => false,
     91        'test_type' => false,
     92    );
    8993    $_FILES['import']['name'] .= '.txt';
    90     $upload = wp_handle_upload( $_FILES['import'], $overrides );
     94    $upload                    = wp_handle_upload( $_FILES['import'], $overrides );
    9195
    9296    if ( isset( $upload['error'] ) ) {
     
    96100    // Construct the object array
    97101    $object = array(
    98         'post_title' => basename( $upload['file'] ),
    99         'post_content' => $upload['url'],
     102        'post_title'     => basename( $upload['file'] ),
     103        'post_content'   => $upload['url'],
    100104        'post_mime_type' => $upload['type'],
    101         'guid' => $upload['url'],
    102         'context' => 'import',
    103         'post_status' => 'private'
     105        'guid'           => $upload['url'],
     106        'context'        => 'import',
     107        'post_status'    => 'private',
    104108    );
    105109
     
    113117    wp_schedule_single_event( time() + DAY_IN_SECONDS, 'importer_scheduled_cleanup', array( $id ) );
    114118
    115     return array( 'file' => $upload['file'], 'id' => $id );
     119    return array(
     120        'file' => $upload['file'],
     121        'id'   => $id,
     122    );
    116123}
    117124
     
    126133    include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version
    127134
    128     $locale = get_user_locale();
    129     $cache_key = 'popular_importers_' . md5( $locale . $wp_version );
     135    $locale            = get_user_locale();
     136    $cache_key         = 'popular_importers_' . md5( $locale . $wp_version );
    130137    $popular_importers = get_site_transient( $cache_key );
    131138
    132139    if ( ! $popular_importers ) {
    133         $url = add_query_arg( array(
    134             'locale'  => $locale,
    135             'version' => $wp_version,
    136         ), 'http://api.wordpress.org/core/importers/1.1/' );
     140        $url     = add_query_arg(
     141            array(
     142                'locale'  => $locale,
     143                'version' => $wp_version,
     144            ), 'http://api.wordpress.org/core/importers/1.1/'
     145        );
    137146        $options = array( 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ) );
    138147
     
    141150        }
    142151
    143         $response = wp_remote_get( $url, $options );
     152        $response          = wp_remote_get( $url, $options );
    144153        $popular_importers = json_decode( wp_remote_retrieve_body( $response ), true );
    145154
     
    153162    if ( is_array( $popular_importers ) ) {
    154163        // If the data was received as translated, return it as-is.
    155         if ( $popular_importers['translated'] )
     164        if ( $popular_importers['translated'] ) {
    156165            return $popular_importers['importers'];
     166        }
    157167
    158168        foreach ( $popular_importers['importers'] as &$importer ) {
    159169            $importer['description'] = translate( $importer['description'] );
    160             if ( $importer['name'] != 'WordPress' )
     170            if ( $importer['name'] != 'WordPress' ) {
    161171                $importer['name'] = translate( $importer['name'] );
     172            }
    162173        }
    163174        return $popular_importers['importers'];
     
    166177    return array(
    167178        // slug => name, description, plugin slug, and register_importer() slug
    168         'blogger' => array(
    169             'name' => __( 'Blogger' ),
     179        'blogger'     => array(
     180            'name'        => __( 'Blogger' ),
    170181            'description' => __( 'Import posts, comments, and users from a Blogger blog.' ),
    171182            'plugin-slug' => 'blogger-importer',
    172183            'importer-id' => 'blogger',
    173184        ),
    174         'wpcat2tag' => array(
    175             'name' => __( 'Categories and Tags Converter' ),
     185        'wpcat2tag'   => array(
     186            'name'        => __( 'Categories and Tags Converter' ),
    176187            'description' => __( 'Convert existing categories to tags or tags to categories, selectively.' ),
    177188            'plugin-slug' => 'wpcat2tag-importer',
     
    179190        ),
    180191        'livejournal' => array(
    181             'name' => __( 'LiveJournal' ),
     192            'name'        => __( 'LiveJournal' ),
    182193            'description' => __( 'Import posts from LiveJournal using their API.' ),
    183194            'plugin-slug' => 'livejournal-importer',
     
    185196        ),
    186197        'movabletype' => array(
    187             'name' => __( 'Movable Type and TypePad' ),
     198            'name'        => __( 'Movable Type and TypePad' ),
    188199            'description' => __( 'Import posts and comments from a Movable Type or TypePad blog.' ),
    189200            'plugin-slug' => 'movabletype-importer',
    190201            'importer-id' => 'mt',
    191202        ),
    192         'opml' => array(
    193             'name' => __( 'Blogroll' ),
     203        'opml'        => array(
     204            'name'        => __( 'Blogroll' ),
    194205            'description' => __( 'Import links in OPML format.' ),
    195206            'plugin-slug' => 'opml-importer',
    196207            'importer-id' => 'opml',
    197208        ),
    198         'rss' => array(
    199             'name' => __( 'RSS' ),
     209        'rss'         => array(
     210            'name'        => __( 'RSS' ),
    200211            'description' => __( 'Import posts from an RSS feed.' ),
    201212            'plugin-slug' => 'rss-importer',
    202213            'importer-id' => 'rss',
    203214        ),
    204         'tumblr' => array(
    205             'name' => __( 'Tumblr' ),
     215        'tumblr'      => array(
     216            'name'        => __( 'Tumblr' ),
    206217            'description' => __( 'Import posts & media from Tumblr using their API.' ),
    207218            'plugin-slug' => 'tumblr-importer',
    208219            'importer-id' => 'tumblr',
    209220        ),
    210         'wordpress' => array(
    211             'name' => 'WordPress',
     221        'wordpress'   => array(
     222            'name'        => 'WordPress',
    212223            'description' => __( 'Import posts, pages, comments, custom fields, categories, and tags from a WordPress export file.' ),
    213224            'plugin-slug' => 'wordpress-importer',
Note: See TracChangeset for help on using the changeset viewer.