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/export.php

    r38725 r42343  
    1010require_once( dirname( __FILE__ ) . '/admin.php' );
    1111
    12 if ( !current_user_can('export') )
    13     wp_die(__('Sorry, you are not allowed to export the content of this site.'));
     12if ( ! current_user_can( 'export' ) ) {
     13    wp_die( __( 'Sorry, you are not allowed to export the content of this site.' ) );
     14}
    1415
    1516/** Load WordPress export API */
    1617require_once( ABSPATH . 'wp-admin/includes/export.php' );
    17 $title = __('Export');
     18$title = __( 'Export' );
    1819
    1920/**
     
    2627<script type="text/javascript">
    2728    jQuery(document).ready(function($){
    28         var form = $('#export-filters'),
    29             filters = form.find('.export-filters');
    30         filters.hide();
    31         form.find('input:radio').change(function() {
     29         var form = $('#export-filters'),
     30             filters = form.find('.export-filters');
     31         filters.hide();
     32         form.find('input:radio').change(function() {
    3233            filters.slideUp('fast');
    3334            switch ( $(this).val() ) {
     
    3637                case 'pages': $('#page-filters').slideDown(); break;
    3738            }
    38         });
     39         });
    3940    });
    4041</script>
     
    4344add_action( 'admin_head', 'export_add_js' );
    4445
    45 get_current_screen()->add_help_tab( array(
    46     'id'      => 'overview',
    47     'title'   => __('Overview'),
    48     'content' => '<p>' . __('You can export a file of your site&#8217;s content in order to import it into another installation or platform. The export file will be an XML file format called WXR. Posts, pages, comments, custom fields, categories, and tags can be included. You can choose for the WXR file to include only certain posts or pages by setting the dropdown filters to limit the export by category, author, date range by month, or publishing status.') . '</p>' .
    49         '<p>' . __('Once generated, your WXR file can be imported by another WordPress site or by another blogging platform able to access this format.') . '</p>',
    50 ) );
     46get_current_screen()->add_help_tab(
     47    array(
     48        'id'      => 'overview',
     49        'title'   => __( 'Overview' ),
     50        'content' => '<p>' . __( 'You can export a file of your site&#8217;s content in order to import it into another installation or platform. The export file will be an XML file format called WXR. Posts, pages, comments, custom fields, categories, and tags can be included. You can choose for the WXR file to include only certain posts or pages by setting the dropdown filters to limit the export by category, author, date range by month, or publishing status.' ) . '</p>' .
     51            '<p>' . __( 'Once generated, your WXR file can be imported by another WordPress site or by another blogging platform able to access this format.' ) . '</p>',
     52    )
     53);
    5154
    5255get_current_screen()->set_help_sidebar(
    53     '<p><strong>' . __('For more information:') . '</strong></p>' .
    54     '<p>' . __('<a href="https://codex.wordpress.org/Tools_Export_Screen">Documentation on Export</a>') . '</p>' .
    55     '<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>'
     56    '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
     57    '<p>' . __( '<a href="https://codex.wordpress.org/Tools_Export_Screen">Documentation on Export</a>' ) . '</p>' .
     58    '<p>' . __( '<a href="https://wordpress.org/support/">Support Forums</a>' ) . '</p>'
    5659);
    5760
     
    6568        $args['content'] = 'post';
    6669
    67         if ( $_GET['cat'] )
     70        if ( $_GET['cat'] ) {
    6871            $args['category'] = (int) $_GET['cat'];
    69 
    70         if ( $_GET['post_author'] )
     72        }
     73
     74        if ( $_GET['post_author'] ) {
    7175            $args['author'] = (int) $_GET['post_author'];
     76        }
    7277
    7378        if ( $_GET['post_start_date'] || $_GET['post_end_date'] ) {
    7479            $args['start_date'] = $_GET['post_start_date'];
    75             $args['end_date'] = $_GET['post_end_date'];
    76         }
    77 
    78         if ( $_GET['post_status'] )
     80            $args['end_date']   = $_GET['post_end_date'];
     81        }
     82
     83        if ( $_GET['post_status'] ) {
    7984            $args['status'] = $_GET['post_status'];
     85        }
    8086    } elseif ( 'pages' == $_GET['content'] ) {
    8187        $args['content'] = 'page';
    8288
    83         if ( $_GET['page_author'] )
     89        if ( $_GET['page_author'] ) {
    8490            $args['author'] = (int) $_GET['page_author'];
     91        }
    8592
    8693        if ( $_GET['page_start_date'] || $_GET['page_end_date'] ) {
    8794            $args['start_date'] = $_GET['page_start_date'];
    88             $args['end_date'] = $_GET['page_end_date'];
    89         }
    90 
    91         if ( $_GET['page_status'] )
     95            $args['end_date']   = $_GET['page_end_date'];
     96        }
     97
     98        if ( $_GET['page_status'] ) {
    9299            $args['status'] = $_GET['page_status'];
     100        }
    93101    } elseif ( 'attachment' == $_GET['content'] ) {
    94102        $args['content'] = 'attachment';
     
    96104        if ( $_GET['attachment_start_date'] || $_GET['attachment_end_date'] ) {
    97105            $args['start_date'] = $_GET['attachment_start_date'];
    98             $args['end_date'] = $_GET['attachment_end_date'];
    99         }
    100     }
    101     else {
     106            $args['end_date']   = $_GET['attachment_end_date'];
     107        }
     108    } else {
    102109        $args['content'] = $_GET['content'];
    103110    }
     
    131138    global $wpdb, $wp_locale;
    132139
    133     $months = $wpdb->get_results( $wpdb->prepare( "
     140    $months = $wpdb->get_results(
     141        $wpdb->prepare(
     142            "
    134143        SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
    135144        FROM $wpdb->posts
    136145        WHERE post_type = %s AND post_status != 'auto-draft'
    137146        ORDER BY post_date DESC
    138     ", $post_type ) );
     147    ", $post_type
     148        )
     149    );
    139150
    140151    $month_count = count( $months );
    141     if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) )
     152    if ( ! $month_count || ( 1 == $month_count && 0 == $months[0]->month ) ) {
    142153        return;
     154    }
    143155
    144156    foreach ( $months as $date ) {
    145         if ( 0 == $date->year )
     157        if ( 0 == $date->year ) {
    146158            continue;
     159        }
    147160
    148161        $month = zeroise( $date->month, 2 );
     
    155168<h1><?php echo esc_html( $title ); ?></h1>
    156169
    157 <p><?php _e('When you click the button below WordPress will create an XML file for you to save to your computer.'); ?></p>
    158 <p><?php _e('This format, which we call WordPress eXtended RSS or WXR, will contain your posts, pages, comments, custom fields, categories, and tags.'); ?></p>
    159 <p><?php _e('Once you&#8217;ve saved the download file, you can use the Import function in another WordPress installation to import the content from this site.'); ?></p>
     170<p><?php _e( 'When you click the button below WordPress will create an XML file for you to save to your computer.' ); ?></p>
     171<p><?php _e( 'This format, which we call WordPress eXtended RSS or WXR, will contain your posts, pages, comments, custom fields, categories, and tags.' ); ?></p>
     172<p><?php _e( 'Once you&#8217;ve saved the download file, you can use the Import function in another WordPress installation to import the content from this site.' ); ?></p>
    160173
    161174<h2><?php _e( 'Choose what to export' ); ?></h2>
     
    171184    <li>
    172185        <label><span class="label-responsive"><?php _e( 'Categories:' ); ?></span>
    173         <?php wp_dropdown_categories( array( 'show_option_all' => __('All') ) ); ?>
     186        <?php wp_dropdown_categories( array( 'show_option_all' => __( 'All' ) ) ); ?>
    174187        </label>
    175188    </li>
     
    178191        <?php
    179192        $authors = $wpdb->get_col( "SELECT DISTINCT post_author FROM {$wpdb->posts} WHERE post_type = 'post'" );
    180         wp_dropdown_users( array(
    181             'include' => $authors,
    182             'name' => 'post_author',
    183             'multi' => true,
    184             'show_option_all' => __( 'All' ),
    185             'show' => 'display_name_with_login',
    186         ) ); ?>
     193        wp_dropdown_users(
     194            array(
     195                'include'         => $authors,
     196                'name'            => 'post_author',
     197                'multi'           => true,
     198                'show_option_all' => __( 'All' ),
     199                'show'            => 'display_name_with_login',
     200            )
     201        );
     202        ?>
    187203        </label>
    188204    </li>
     
    206222        <select name="post_status" id="post-status">
    207223            <option value="0"><?php _e( 'All' ); ?></option>
    208             <?php $post_stati = get_post_stati( array( 'internal' => false ), 'objects' );
    209             foreach ( $post_stati as $status ) : ?>
     224            <?php
     225            $post_stati = get_post_stati( array( 'internal' => false ), 'objects' );
     226            foreach ( $post_stati as $status ) :
     227            ?>
    210228            <option value="<?php echo esc_attr( $status->name ); ?>"><?php echo esc_html( $status->label ); ?></option>
    211229            <?php endforeach; ?>
     
    220238        <?php
    221239        $authors = $wpdb->get_col( "SELECT DISTINCT post_author FROM {$wpdb->posts} WHERE post_type = 'page'" );
    222         wp_dropdown_users( array(
    223             'include' => $authors,
    224             'name' => 'page_author',
    225             'multi' => true,
    226             'show_option_all' => __( 'All' ),
    227             'show' => 'display_name_with_login',
    228         ) ); ?>
     240        wp_dropdown_users(
     241            array(
     242                'include'         => $authors,
     243                'name'            => 'page_author',
     244                'multi'           => true,
     245                'show_option_all' => __( 'All' ),
     246                'show'            => 'display_name_with_login',
     247            )
     248        );
     249        ?>
    229250        </label>
    230251    </li>
     
    255276</ul>
    256277
    257 <?php foreach ( get_post_types( array( '_builtin' => false, 'can_export' => true ), 'objects' ) as $post_type ) : ?>
     278<?php
     279foreach ( get_post_types(
     280    array(
     281        '_builtin'   => false,
     282        'can_export' => true,
     283    ), 'objects'
     284) as $post_type ) :
     285?>
    258286<p><label><input type="radio" name="content" value="<?php echo esc_attr( $post_type->name ); ?>" /> <?php echo esc_html( $post_type->label ); ?></label></p>
    259287<?php endforeach; ?>
     
    288316?>
    289317
    290 <?php submit_button( __('Download Export File') ); ?>
     318<?php submit_button( __( 'Download Export File' ) ); ?>
    291319</form>
    292320</div>
Note: See TracChangeset for help on using the changeset viewer.