WordPress.org

Make WordPress Core

Ticket #13418: 13418.patch

File 13418.patch, 2.0 KB (added by hakre, 11 years ago)

Code streamlined in beginning of media_upload_library_form()

  • wp-admin/includes/media.php

     
    18441844 *
    18451845 * @param unknown_type $errors
    18461846 */
    1847 function media_upload_library_form($errors) {
     1847function media_upload_library_form( $errors ) {
    18481848        global $wpdb, $wp_query, $wp_locale, $type, $tab, $post_mime_types;
    18491849
    18501850        media_upload_header();
    18511851
    1852         $post_id = intval($_REQUEST['post_id']);
     1852        $post_id = (int) $_REQUEST['post_id'];
    18531853
    1854         $form_action_url = admin_url("media-upload.php?type=$type&tab=library&post_id=$post_id");
    1855         $form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);
     1854        $form_action_url = admin_url( "media-upload.php?type=$type&tab=library&post_id=$post_id" );
     1855        $form_action_url = apply_filters( 'media_upload_form_url', $form_action_url, $type );
    18561856
    1857         $_GET['paged'] = isset( $_GET['paged'] ) ? intval($_GET['paged']) : 0;
    1858         if ( $_GET['paged'] < 1 )
    1859                 $_GET['paged'] = 1;
    1860         $start = ( $_GET['paged'] - 1 ) * 10;
    1861         if ( $start < 1 )
    1862                 $start = 0;
     1857        $_GET['paged'] = empty( $_GET['paged'] ) ? 0 : (int) $_GET['paged'];
     1858        $_GET['paged'] = max( 1, $_GET['paged'] );
     1859        $start         = ( $_GET['paged'] - 1 ) * 10;
     1860
    18631861        add_filter( 'post_limits', create_function( '$a', "return 'LIMIT $start, 10';" ) );
    18641862
    18651863        list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query();
     
    18691867<form id="filter" action="" method="get">
    18701868<input type="hidden" name="type" value="<?php echo esc_attr( $type ); ?>" />
    18711869<input type="hidden" name="tab" value="<?php echo esc_attr( $tab ); ?>" />
    1872 <input type="hidden" name="post_id" value="<?php echo (int) $post_id; ?>" />
     1870<input type="hidden" name="post_id" value="<?php echo $post_id; ?>" />
    18731871<input type="hidden" name="post_mime_type" value="<?php echo isset( $_GET['post_mime_type'] ) ? esc_attr( $_GET['post_mime_type'] ) : ''; ?>" />
    18741872
    18751873<p id="media-search" class="search-box">