WordPress.org

Make WordPress Core


Ignore:
Timestamp:
11/21/2012 03:10:17 PM (5 years ago)
Author:
nacin
Message:

media-new.php: Remove unused scripts, strings, error handling, save handling, and save button. fixes #22083.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/media-new.php

    r22755 r22764  
    1717
    1818wp_enqueue_script('plupload-handlers');
    19 wp_enqueue_script('image-edit');
    20 wp_enqueue_script('set-post-thumbnail' );
    21 wp_enqueue_style('imgareaselect');
    22 wp_enqueue_script( 'media-gallery' );
    23 
    24 $errors = array();
    2519
    2620unset( $_REQUEST['post_id'] );
    2721
    2822if ( $_POST ) {
     23    $location = 'upload.php';
    2924    if ( isset($_POST['html-upload']) && !empty($_FILES) ) {
    3025        check_admin_referer('media-form');
    3126        // Upload File button was clicked
    3227        $id = media_handle_upload('async-upload', $_REQUEST['post_id']);
    33         unset($_FILES);
    34         if ( is_wp_error($id) ) {
    35             $errors['upload_error'] = $id;
    36             $id = false;
    37         }
     28        if ( is_wp_error( $id ) )
     29            $location .= '?message=3';
    3830    }
    39 
    40     $errors = array_merge($errors, (array) media_upload_form_handler());
    41 
    42     $location = 'upload.php';
    43     if ( $errors )
    44         $location .= '?message=3';
    45 
    46     wp_redirect( admin_url($location) );
     31    wp_redirect( admin_url( $location ) );
    4732    exit;
    4833}
    4934
    50     $title = __('Upload New Media');
    51     $parent_file = 'upload.php';
    52     get_current_screen()->add_help_tab( array(
    53     'id'        => 'overview',
    54     'title'     => __('Overview'),
    55     'content'   =>
    56         '<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>' .
    57         '<ul>' .
    58             '<li>' . __('<strong>Drag and drop</strong> your files into the area below. Multiple files are allowed.') . '</li>' .
    59             '<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>' .
    60             '<li>' . __('Revert to the <strong>Browser Uploader</strong> by clicking the link below the drag and drop box.') . '</li>' .
    61         '</ul>' .
    62         '<p>' . __('Basic image editing is available after upload is complete. Make sure you click Save before leaving this screen.') . '</p>'
    63     ) );
    64     get_current_screen()->set_help_sidebar(
    65         '<p><strong>' . __('For more information:') . '</strong></p>' .
    66         '<p>' . __('<a href="http://codex.wordpress.org/Media_Add_New_Screen" target="_blank">Documentation on Uploading Media Files</a>') . '</p>' .
    67         '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
    68     );
     35$title = __('Upload New Media');
     36$parent_file = 'upload.php';
    6937
    70     require_once('./admin-header.php');
     38get_current_screen()->add_help_tab( array(
     39'id'        => 'overview',
     40'title'     => __('Overview'),
     41'content'   =>
     42    '<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>' .
     43    '<ul>' .
     44        '<li>' . __('<strong>Drag and drop</strong> your files into the area below. Multiple files are allowed.') . '</li>' .
     45        '<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>' .
     46        '<li>' . __('Revert to the <strong>Browser Uploader</strong> by clicking the link below the drag and drop box.') . '</li>' .
     47    '</ul>'
     48) );
     49get_current_screen()->set_help_sidebar(
     50    '<p><strong>' . __('For more information:') . '</strong></p>' .
     51    '<p>' . __('<a href="http://codex.wordpress.org/Media_Add_New_Screen" target="_blank">Documentation on Uploading Media Files</a>') . '</p>' .
     52    '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
     53);
    7154
    72     $form_class = 'media-upload-form wp-upload-form type-form validate';
     55require_once( ABSPATH . 'wp-admin/admin-header.php' );
    7356
    74     if ( get_user_setting('uploader') )
    75         $form_class .= ' html-uploader';
    76     ?>
    77     <div class="wrap">
     57$form_class = 'media-upload-form wp-upload-form type-form validate';
     58
     59if ( get_user_setting('uploader') || isset( $_GET['browser-uploader'] ) )
     60    $form_class .= ' html-uploader';
     61?>
     62<div class="wrap">
    7863    <?php screen_icon(); ?>
    7964    <h2><?php echo esc_html( $title ); ?></h2>
     
    8469
    8570    <script type="text/javascript">
    86     jQuery(function($){
    87         var preloaded = $(".media-item.preloaded");
    88         if ( preloaded.length > 0 ) {
    89             preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');});
    90         }
    91         updateMediaForm();
    92         post_id = 0;
    93         shortform = 3;
    94     });
     71    var post_id = 0, shortform = 3;
    9572    </script>
    9673    <input type="hidden" name="post_id" id="post_id" value="0" />
    9774    <?php wp_nonce_field('media-form'); ?>
    9875    <div id="media-items" class="hide-if-no-js"></div>
    99     <?php submit_button( __( 'Save all changes' ), 'button savebutton hidden', 'save' ); ?>
    10076    </form>
    101     </div>
     77</div>
    10278
    10379<?php
    104     include('./admin-footer.php');
     80include( ABSPATH . 'wp-admin/admin-footer.php' );
Note: See TracChangeset for help on using the changeset viewer.