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/media-new.php

    r38725 r42343  
    1313require_once( dirname( __FILE__ ) . '/admin.php' );
    1414
    15 if (!current_user_can('upload_files'))
    16     wp_die(__('Sorry, you are not allowed to upload files.'));
     15if ( ! current_user_can( 'upload_files' ) ) {
     16    wp_die( __( 'Sorry, you are not allowed to upload files.' ) );
     17}
    1718
    18 wp_enqueue_script('plupload-handlers');
     19wp_enqueue_script( 'plupload-handlers' );
    1920
    2021$post_id = 0;
    2122if ( isset( $_REQUEST['post_id'] ) ) {
    2223    $post_id = absint( $_REQUEST['post_id'] );
    23     if ( ! get_post( $post_id ) || ! current_user_can( 'edit_post', $post_id ) )
     24    if ( ! get_post( $post_id ) || ! current_user_can( 'edit_post', $post_id ) ) {
    2425        $post_id = 0;
     26    }
    2527}
    2628
    2729if ( $_POST ) {
    28     if ( isset($_POST['html-upload']) && !empty($_FILES) ) {
    29         check_admin_referer('media-form');
     30    if ( isset( $_POST['html-upload'] ) && ! empty( $_FILES ) ) {
     31        check_admin_referer( 'media-form' );
    3032        // Upload File button was clicked
    3133        $upload_id = media_handle_upload( 'async-upload', $post_id );
     
    3840}
    3941
    40 $title = __('Upload New Media');
     42$title       = __( 'Upload New Media' );
    4143$parent_file = 'upload.php';
    4244
    43 get_current_screen()->add_help_tab( array(
    44 'id'        => 'overview',
    45 'title'     => __('Overview'),
    46 'content'   =>
    47     '<p>' . __('You can upload media files here without creating a post first. This allows you to upload files to use with posts and pages later and/or to get a web link for a particular file that you can share. There are three options for uploading files:') . '</p>' .
    48     '<ul>' .
    49         '<li>' . __('<strong>Drag and drop</strong> your files into the area below. Multiple files are allowed.') . '</li>' .
    50         '<li>' . __('Clicking <strong>Select Files</strong> opens a navigation window showing you files in your operating system. Selecting <strong>Open</strong> after clicking on the file you want activates a progress bar on the uploader screen.') . '</li>' .
    51         '<li>' . __('Revert to the <strong>Browser Uploader</strong> by clicking the link below the drag and drop box.') . '</li>' .
    52     '</ul>'
    53 ) );
     45get_current_screen()->add_help_tab(
     46    array(
     47        'id'      => 'overview',
     48        'title'   => __( 'Overview' ),
     49        'content' =>
     50                 '<p>' . __( 'You can upload media files here without creating a post first. This allows you to upload files to use with posts and pages later and/or to get a web link for a particular file that you can share. There are three options for uploading files:' ) . '</p>' .
     51                 '<ul>' .
     52                     '<li>' . __( '<strong>Drag and drop</strong> your files into the area below. Multiple files are allowed.' ) . '</li>' .
     53                     '<li>' . __( 'Clicking <strong>Select Files</strong> opens a navigation window showing you files in your operating system. Selecting <strong>Open</strong> after clicking on the file you want activates a progress bar on the uploader screen.' ) . '</li>' .
     54                     '<li>' . __( 'Revert to the <strong>Browser Uploader</strong> by clicking the link below the drag and drop box.' ) . '</li>' .
     55                 '</ul>',
     56    )
     57);
    5458get_current_screen()->set_help_sidebar(
    55     '<p><strong>' . __('For more information:') . '</strong></p>' .
    56     '<p>' . __('<a href="https://codex.wordpress.org/Media_Add_New_Screen">Documentation on Uploading Media Files</a>') . '</p>' .
    57     '<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>'
     59    '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
     60    '<p>' . __( '<a href="https://codex.wordpress.org/Media_Add_New_Screen">Documentation on Uploading Media Files</a>' ) . '</p>' .
     61    '<p>' . __( '<a href="https://wordpress.org/support/">Support Forums</a>' ) . '</p>'
    5862);
    5963
     
    6266$form_class = 'media-upload-form type-form validate';
    6367
    64 if ( get_user_setting('uploader') || isset( $_GET['browser-uploader'] ) )
     68if ( get_user_setting( 'uploader' ) || isset( $_GET['browser-uploader'] ) ) {
    6569    $form_class .= ' html-uploader';
     70}
    6671?>
    6772<div class="wrap">
    6873    <h1><?php echo esc_html( $title ); ?></h1>
    6974
    70     <form enctype="multipart/form-data" method="post" action="<?php echo admin_url('media-new.php'); ?>" class="<?php echo esc_attr( $form_class ); ?>" id="file-form">
     75    <form enctype="multipart/form-data" method="post" action="<?php echo admin_url( 'media-new.php' ); ?>" class="<?php echo esc_attr( $form_class ); ?>" id="file-form">
    7176
    7277    <?php media_upload_form(); ?>
     
    7681    </script>
    7782    <input type="hidden" name="post_id" id="post_id" value="<?php echo $post_id; ?>" />
    78     <?php wp_nonce_field('media-form'); ?>
     83    <?php wp_nonce_field( 'media-form' ); ?>
    7984    <div id="media-items" class="hide-if-no-js"></div>
    8085    </form>
Note: See TracChangeset for help on using the changeset viewer.