Make WordPress Core


Ignore:
Timestamp:
08/17/2018 01:50:26 AM (8 years ago)
Author:
pento
Message:

Coding Standards: Upgrade WPCS to 1.0.0

WPCS 1.0.0 includes a bunch of new auto-fixers, which drops the number of coding standards issues across WordPress significantly. Prior to running the auto-fixers, there were 15,312 issues detected. With this commit, we now drop to 4,769 issues.

This change includes three notable additions:

  • Multiline function calls must now put each parameter on a new line.
  • Auto-formatting files is now part of the grunt precommit script.
  • Auto-fixable coding standards issues will now cause Travis failures.

Fixes #44600.

File:
1 edited

Legend:

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

    r42984 r43571  
    264264 */
    265265function media_send_to_editor( $html ) {
    266 ?>
     266        ?>
    267267<script type="text/javascript">
    268268var win = window.dialogArguments || opener || parent || top;
    269269win.send_to_editor( <?php echo wp_json_encode( $html ); ?> );
    270270</script>
    271 <?php
     271        <?php
    272272        exit;
    273273}
     
    369369                }
    370370
    371         // Use image exif/iptc data for title and caption defaults if possible.
     371                // Use image exif/iptc data for title and caption defaults if possible.
    372372        } elseif ( 0 === strpos( $type, 'image/' ) && $image_meta = wp_read_image_metadata( $file ) ) {
    373373                if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) ) {
     
    389389                        'post_content'   => $content,
    390390                        'post_excerpt'   => $excerpt,
    391                 ), $post_data
     391                ),
     392                $post_data
    392393        );
    393394
     
    459460                        'post_title'     => $title,
    460461                        'post_content'   => $content,
    461                 ), $post_data
     462                ),
     463                $post_data
    462464        );
    463465
     
    485487function wp_iframe( $content_func /* ... */ ) {
    486488        _wp_admin_html_begin();
    487 ?>
     489        ?>
    488490<title><?php bloginfo( 'name' ); ?> &rsaquo; <?php _e( 'Uploads' ); ?> &#8212; <?php _e( 'WordPress' ); ?></title>
    489 <?php
    490 
    491 wp_enqueue_style( 'colors' );
    492 // Check callback name for 'media'
    493 if ( ( is_array( $content_func ) && ! empty( $content_func[1] ) && 0 === strpos( (string) $content_func[1], 'media' ) )
     491        <?php
     492
     493        wp_enqueue_style( 'colors' );
     494        // Check callback name for 'media'
     495        if ( ( is_array( $content_func ) && ! empty( $content_func[1] ) && 0 === strpos( (string) $content_func[1], 'media' ) )
    494496        || ( ! is_array( $content_func ) && 0 === strpos( $content_func, 'media' ) ) ) {
    495         wp_enqueue_style( 'deprecated-media' );
    496 }
    497 wp_enqueue_style( 'ie' );
    498 ?>
     497                wp_enqueue_style( 'deprecated-media' );
     498        }
     499        wp_enqueue_style( 'ie' );
     500        ?>
    499501<script type="text/javascript">
    500502addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
     
    502504isRtl = <?php echo (int) is_rtl(); ?>;
    503505</script>
    504 <?php
     506        <?php
    505507        /** This action is documented in wp-admin/admin-header.php */
    506508        do_action( 'admin_enqueue_scripts', 'media-upload-popup' );
     
    537539        do_action( 'admin_head' );
    538540
    539 if ( is_string( $content_func ) ) {
    540         /**
    541         * Fires in the admin header for each specific form tab in the legacy
    542         * (pre-3.5.0) media upload popup.
    543         *
    544         * The dynamic portion of the hook, `$content_func`, refers to the form
    545         * callback for the media upload type. Possible values include
    546         * 'media_upload_type_form', 'media_upload_type_url_form', and
    547         * 'media_upload_library_form'.
    548         *
    549         * @since 2.5.0
    550         */
    551         do_action( "admin_head_{$content_func}" );
    552 }
    553 
    554 $body_id_attr = '';
    555 if ( isset( $GLOBALS['body_id'] ) ) {
    556         $body_id_attr = ' id="' . $GLOBALS['body_id'] . '"';
    557 }
    558 ?>
     541        if ( is_string( $content_func ) ) {
     542                /**
     543                * Fires in the admin header for each specific form tab in the legacy
     544                * (pre-3.5.0) media upload popup.
     545                *
     546                * The dynamic portion of the hook, `$content_func`, refers to the form
     547                * callback for the media upload type. Possible values include
     548                * 'media_upload_type_form', 'media_upload_type_url_form', and
     549                * 'media_upload_library_form'.
     550                *
     551                * @since 2.5.0
     552                */
     553                do_action( "admin_head_{$content_func}" );
     554        }
     555
     556        $body_id_attr = '';
     557        if ( isset( $GLOBALS['body_id'] ) ) {
     558                $body_id_attr = ' id="' . $GLOBALS['body_id'] . '"';
     559        }
     560        ?>
    559561</head>
    560562<body<?php echo $body_id_attr; ?> class="wp-core-ui no-js">
     
    562564document.body.className = document.body.className.replace('no-js', 'js');
    563565</script>
    564 <?php
     566        <?php
    565567        $args = func_get_args();
    566568        $args = array_slice( $args, 1 );
     
    569571        /** This action is documented in wp-admin/admin-footer.php */
    570572        do_action( 'admin_print_footer_scripts' );
    571 ?>
     573        ?>
    572574<script type="text/javascript">if(typeof wpOnload=='function')wpOnload();</script>
    573575</body>
    574576</html>
    575 <?php
     577        <?php
    576578}
    577579
     
    755757
    756758        if ( isset( $_POST['insert-gallery'] ) || isset( $_POST['update-gallery'] ) ) {
    757         ?>
     759                ?>
    758760                <script type="text/javascript">
    759761                var win = window.dialogArguments || opener || parent || top;
     
    10701072         */
    10711073        $size_names = apply_filters(
    1072                 'image_size_names_choose', array(
     1074                'image_size_names_choose',
     1075                array(
    10731076                        'thumbnail' => __( 'Thumbnail' ),
    10741077                        'medium'    => __( 'Medium' ),
     
    17821785
    17831786        unset(
    1784                 $form_fields['image-size'], $form_fields['align'], $form_fields['image_alt'],
    1785                 $form_fields['post_title'], $form_fields['post_excerpt'], $form_fields['post_content'],
    1786                 $form_fields['url'], $form_fields['menu_order'], $form_fields['image_url']
     1787                $form_fields['image-size'],
     1788                $form_fields['align'],
     1789                $form_fields['image_alt'],
     1790                $form_fields['post_title'],
     1791                $form_fields['post_excerpt'],
     1792                $form_fields['post_content'],
     1793                $form_fields['url'],
     1794                $form_fields['menu_order'],
     1795                $form_fields['image_url']
    17871796        );
    17881797
     
    19441953                $max_upload_size = 0;
    19451954        }
    1946 ?>
     1955        ?>
    19471956
    19481957<div id="media-upload-notice">
    1949 <?php
    1950 
    1951 if ( isset( $errors['upload_notice'] ) ) {
    1952         echo $errors['upload_notice'];
    1953 }
    1954 
    1955 ?>
     1958        <?php
     1959
     1960        if ( isset( $errors['upload_notice'] ) ) {
     1961                echo $errors['upload_notice'];
     1962        }
     1963
     1964        ?>
    19561965</div>
    19571966<div id="media-upload-error">
    1958 <?php
    1959 
    1960 if ( isset( $errors['upload_error'] ) && is_wp_error( $errors['upload_error'] ) ) {
    1961         echo $errors['upload_error']->get_error_message();
    1962 }
    1963 
    1964 ?>
     1967        <?php
     1968
     1969        if ( isset( $errors['upload_error'] ) && is_wp_error( $errors['upload_error'] ) ) {
     1970                echo $errors['upload_error']->get_error_message();
     1971        }
     1972
     1973        ?>
    19651974</div>
    1966 <?php
    1967 if ( is_multisite() && ! is_upload_space_available() ) {
     1975        <?php
     1976        if ( is_multisite() && ! is_upload_space_available() ) {
     1977                /**
     1978                 * Fires when an upload will exceed the defined upload space quota for a network site.
     1979                 *
     1980                 * @since 3.5.0
     1981                 */
     1982                do_action( 'upload_ui_over_quota' );
     1983                return;
     1984        }
     1985
    19681986        /**
    1969          * Fires when an upload will exceed the defined upload space quota for a network site.
    1970          *
    1971          * @since 3.5.0
     1987         * Fires just before the legacy (pre-3.5.0) upload interface is loaded.
     1988         *
     1989         * @since 2.6.0
    19721990         */
    1973         do_action( 'upload_ui_over_quota' );
    1974         return;
    1975 }
    1976 
    1977 /**
    1978  * Fires just before the legacy (pre-3.5.0) upload interface is loaded.
    1979  *
    1980  * @since 2.6.0
    1981  */
    1982 do_action( 'pre-upload-ui' );
    1983 
    1984 $post_params = array(
    1985         'post_id'  => $post_id,
    1986         '_wpnonce' => wp_create_nonce( 'media-form' ),
    1987         'type'     => $_type,
    1988         'tab'      => $_tab,
    1989         'short'    => '1',
    1990 );
    1991 
    1992 /**
    1993  * Filters the media upload post parameters.
    1994  *
    1995  * @since 3.1.0 As 'swfupload_post_params'
    1996  * @since 3.3.0
    1997  *
    1998  * @param array $post_params An array of media upload parameters used by Plupload.
    1999  */
    2000 $post_params = apply_filters( 'upload_post_params', $post_params );
    2001 
    2002 /*
    2003  * Since 4.9 the `runtimes` setting is hardcoded in our version of Plupload to `html5,html4`,
    2004  * and the `flash_swf_url` and `silverlight_xap_url` are not used.
    2005  */
    2006 $plupload_init = array(
    2007         'browse_button'    => 'plupload-browse-button',
    2008         'container'        => 'plupload-upload-ui',
    2009         'drop_element'     => 'drag-drop-area',
    2010         'file_data_name'   => 'async-upload',
    2011         'url'              => $upload_action_url,
    2012         'filters'          => array(
    2013                 'max_file_size' => $max_upload_size . 'b',
    2014         ),
    2015         'multipart_params' => $post_params,
    2016 );
    2017 
    2018 // Currently only iOS Safari supports multiple files uploading but iOS 7.x has a bug that prevents uploading of videos
    2019 // when enabled. See #29602.
    2020 if ( wp_is_mobile() && strpos( $_SERVER['HTTP_USER_AGENT'], 'OS 7_' ) !== false &&
     1991        do_action( 'pre-upload-ui' );
     1992
     1993        $post_params = array(
     1994                'post_id'  => $post_id,
     1995                '_wpnonce' => wp_create_nonce( 'media-form' ),
     1996                'type'     => $_type,
     1997                'tab'      => $_tab,
     1998                'short'    => '1',
     1999        );
     2000
     2001        /**
     2002         * Filters the media upload post parameters.
     2003         *
     2004         * @since 3.1.0 As 'swfupload_post_params'
     2005         * @since 3.3.0
     2006         *
     2007         * @param array $post_params An array of media upload parameters used by Plupload.
     2008         */
     2009        $post_params = apply_filters( 'upload_post_params', $post_params );
     2010
     2011        /*
     2012        * Since 4.9 the `runtimes` setting is hardcoded in our version of Plupload to `html5,html4`,
     2013        * and the `flash_swf_url` and `silverlight_xap_url` are not used.
     2014        */
     2015        $plupload_init = array(
     2016                'browse_button'    => 'plupload-browse-button',
     2017                'container'        => 'plupload-upload-ui',
     2018                'drop_element'     => 'drag-drop-area',
     2019                'file_data_name'   => 'async-upload',
     2020                'url'              => $upload_action_url,
     2021                'filters'          => array(
     2022                        'max_file_size' => $max_upload_size . 'b',
     2023                ),
     2024                'multipart_params' => $post_params,
     2025        );
     2026
     2027        // Currently only iOS Safari supports multiple files uploading but iOS 7.x has a bug that prevents uploading of videos
     2028        // when enabled. See #29602.
     2029        if ( wp_is_mobile() && strpos( $_SERVER['HTTP_USER_AGENT'], 'OS 7_' ) !== false &&
    20212030        strpos( $_SERVER['HTTP_USER_AGENT'], 'like Mac OS X' ) !== false ) {
    20222031
    2023         $plupload_init['multi_selection'] = false;
    2024 }
    2025 
    2026 /**
    2027  * Filters the default Plupload settings.
    2028  *
    2029  * @since 3.3.0
    2030  *
    2031  * @param array $plupload_init An array of default settings used by Plupload.
    2032  */
    2033 $plupload_init = apply_filters( 'plupload_init', $plupload_init );
    2034 
    2035 ?>
     2032                $plupload_init['multi_selection'] = false;
     2033        }
     2034
     2035        /**
     2036        * Filters the default Plupload settings.
     2037        *
     2038        * @since 3.3.0
     2039        *
     2040        * @param array $plupload_init An array of default settings used by Plupload.
     2041        */
     2042        $plupload_init = apply_filters( 'plupload_init', $plupload_init );
     2043
     2044        ?>
    20362045
    20372046<script type="text/javascript">
    2038 <?php
    2039 // Verify size is an int. If not return default value.
    2040 $large_size_h = absint( get_option( 'large_size_h' ) );
    2041 if ( ! $large_size_h ) {
    2042         $large_size_h = 1024;
    2043 }
    2044 $large_size_w = absint( get_option( 'large_size_w' ) );
    2045 if ( ! $large_size_w ) {
    2046         $large_size_w = 1024;
    2047 }
    2048 ?>
     2047        <?php
     2048        // Verify size is an int. If not return default value.
     2049        $large_size_h = absint( get_option( 'large_size_h' ) );
     2050        if ( ! $large_size_h ) {
     2051                $large_size_h = 1024;
     2052        }
     2053        $large_size_w = absint( get_option( 'large_size_w' ) );
     2054        if ( ! $large_size_w ) {
     2055                $large_size_w = 1024;
     2056        }
     2057        ?>
    20492058var resize_height = <?php echo $large_size_h; ?>, resize_width = <?php echo $large_size_w; ?>,
    20502059wpUploaderInit = <?php echo wp_json_encode( $plupload_init ); ?>;
     
    20522061
    20532062<div id="plupload-upload-ui" class="hide-if-no-js">
    2054 <?php
    2055 /**
    2056  * Fires before the upload interface loads.
    2057  *
    2058  * @since 2.6.0 As 'pre-flash-upload-ui'
    2059  * @since 3.3.0
    2060  */
    2061 do_action( 'pre-plupload-upload-ui' );
    2062 ?>
     2063        <?php
     2064        /**
     2065        * Fires before the upload interface loads.
     2066        *
     2067        * @since 2.6.0 As 'pre-flash-upload-ui'
     2068        * @since 3.3.0
     2069        */
     2070        do_action( 'pre-plupload-upload-ui' );
     2071        ?>
    20632072<div id="drag-drop-area">
    20642073        <div class="drag-drop-inside">
     
    20682077        </div>
    20692078</div>
    2070 <?php
    2071 /**
    2072  * Fires after the upload interface loads.
    2073  *
    2074  * @since 2.6.0 As 'post-flash-upload-ui'
    2075  * @since 3.3.0
    2076  */
    2077 do_action( 'post-plupload-upload-ui' );
    2078 ?>
     2079        <?php
     2080        /**
     2081        * Fires after the upload interface loads.
     2082        *
     2083        * @since 2.6.0 As 'post-flash-upload-ui'
     2084        * @since 3.3.0
     2085        */
     2086        do_action( 'post-plupload-upload-ui' );
     2087        ?>
    20792088</div>
    20802089
     
    20952104        </p>
    20962105        <div class="clear"></div>
    2097 <?php
    2098 /**
    2099  * Fires after the upload button in the media upload interface.
    2100  *
    2101  * @since 2.6.0
    2102  */
    2103 do_action( 'post-html-upload-ui' );
    2104 ?>
     2106        <?php
     2107        /**
     2108        * Fires after the upload button in the media upload interface.
     2109        *
     2110        * @since 2.6.0
     2111        */
     2112        do_action( 'post-html-upload-ui' );
     2113        ?>
    21052114</div>
    21062115
    21072116<p class="max-upload-size"><?php printf( __( 'Maximum upload file size: %s.' ), esc_html( size_format( $max_upload_size ) ) ); ?></p>
    2108 <?php
     2117        <?php
    21092118
    21102119        /**
     
    21492158                $form_class .= ' html-uploader';
    21502159        }
    2151 ?>
     2160        ?>
    21522161
    21532162<form enctype="multipart/form-data" method="post" action="<?php echo esc_url( $form_action_url ); ?>" class="<?php echo $form_class; ?>" id="<?php echo $type; ?>-form">
    2154 <?php submit_button( '', 'hidden', 'save', false ); ?>
     2163        <?php submit_button( '', 'hidden', 'save', false ); ?>
    21552164<input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
    2156 <?php wp_nonce_field( 'media-form' ); ?>
     2165        <?php wp_nonce_field( 'media-form' ); ?>
    21572166
    21582167<h3 class="media-title"><?php _e( 'Add media files from your computer' ); ?></h3>
    21592168
    2160 <?php media_upload_form( $errors ); ?>
     2169        <?php media_upload_form( $errors ); ?>
    21612170
    21622171<script type="text/javascript">
     
    21702179</script>
    21712180<div id="media-items">
    2172 <?php
    2173 
    2174 if ( $id ) {
    2175         if ( ! is_wp_error( $id ) ) {
    2176                 add_filter( 'attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2 );
    2177                 echo get_media_items( $id, $errors );
    2178         } else {
    2179                 echo '<div id="media-upload-error">' . esc_html( $id->get_error_message() ) . '</div></div>';
    2180                 exit;
    2181         }
    2182 }
    2183 ?>
     2181        <?php
     2182
     2183        if ( $id ) {
     2184                if ( ! is_wp_error( $id ) ) {
     2185                        add_filter( 'attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2 );
     2186                        echo get_media_items( $id, $errors );
     2187                } else {
     2188                        echo '<div id="media-upload-error">' . esc_html( $id->get_error_message() ) . '</div></div>';
     2189                        exit;
     2190                }
     2191        }
     2192        ?>
    21842193</div>
    21852194
    21862195<p class="savebutton ml-submit">
    2187 <?php submit_button( __( 'Save all changes' ), '', 'save', false ); ?>
     2196        <?php submit_button( __( 'Save all changes' ), '', 'save', false ); ?>
    21882197</p>
    21892198</form>
    2190 <?php
     2199        <?php
    21912200}
    21922201
     
    22172226                $form_class .= ' html-uploader';
    22182227        }
    2219 ?>
     2228        ?>
    22202229
    22212230<form enctype="multipart/form-data" method="post" action="<?php echo esc_url( $form_action_url ); ?>" class="<?php echo $form_class; ?>" id="<?php echo $type; ?>-form">
    22222231<input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
    2223 <?php wp_nonce_field( 'media-form' ); ?>
     2232        <?php wp_nonce_field( 'media-form' ); ?>
    22242233
    22252234<h3 class="media-title"><?php _e( 'Insert media from another website' ); ?></h3>
     
    22412250                        alt = f.alt.value.replace(/'/g, '&#039;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
    22422251
    2243 <?php
     2252        <?php
    22442253        /** This filter is documented in wp-admin/includes/media.php */
    2245 if ( ! apply_filters( 'disable_captions', '' ) ) {
    2246         ?>
     2254        if ( ! apply_filters( 'disable_captions', '' ) ) {
     2255                ?>
    22472256        if ( f.caption.value ) {
    22482257                caption = f.caption.value.replace(/\r\n|\r/g, '\n');
     
    22532262                caption = caption.replace(/\s*\n\s*/g, '<br />');
    22542263        }
    2255 <?php } ?>
     2264        <?php } ?>
    22562265
    22572266                cls = caption ? '' : ' class="'+t.align+'"';
     
    23192328<div id="media-items">
    23202329<div class="media-item media-blank">
    2321 <?php
    2322 /**
    2323  * Filters the insert media from URL form HTML.
    2324  *
    2325  * @since 3.3.0
    2326  *
    2327  * @param string $form_html The insert from URL form HTML.
    2328  */
    2329 echo apply_filters( 'type_url_form_media', wp_media_insert_url_form( $type ) );
    2330 ?>
     2330        <?php
     2331        /**
     2332        * Filters the insert media from URL form HTML.
     2333        *
     2334        * @since 3.3.0
     2335        *
     2336        * @param string $form_html The insert from URL form HTML.
     2337        */
     2338        echo apply_filters( 'type_url_form_media', wp_media_insert_url_form( $type ) );
     2339        ?>
    23312340</div>
    23322341</div>
    23332342</form>
    2334 <?php
     2343        <?php
    23352344}
    23362345
     
    23612370                $form_class .= ' html-uploader';
    23622371        }
    2363 ?>
     2372        ?>
    23642373
    23652374<script type="text/javascript">
     
    23742383<div id="sort-buttons" class="hide-if-no-js">
    23752384<span>
    2376 <?php _e( 'All Tabs:' ); ?>
     2385        <?php _e( 'All Tabs:' ); ?>
    23772386<a href="#" id="showall"><?php _e( 'Show' ); ?></a>
    23782387<a href="#" id="hideall" style="display:none;"><?php _e( 'Hide' ); ?></a>
    23792388</span>
    2380 <?php _e( 'Sort Order:' ); ?>
     2389        <?php _e( 'Sort Order:' ); ?>
    23812390<a href="#" id="asc"><?php _e( 'Ascending' ); ?></a> |
    23822391<a href="#" id="desc"><?php _e( 'Descending' ); ?></a> |
     
    23842393</div>
    23852394<form enctype="multipart/form-data" method="post" action="<?php echo esc_url( $form_action_url ); ?>" class="<?php echo $form_class; ?>" id="gallery-form">
    2386 <?php wp_nonce_field( 'media-form' ); ?>
    2387 <?php //media_upload_form( $errors ); ?>
     2395        <?php wp_nonce_field( 'media-form' ); ?>
     2396        <?php //media_upload_form( $errors ); ?>
    23882397<table class="widefat">
    23892398<thead><tr>
     
    23942403</table>
    23952404<div id="media-items">
    2396 <?php add_filter( 'attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2 ); ?>
    2397 <?php echo get_media_items( $post_id, $errors ); ?>
     2405        <?php add_filter( 'attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2 ); ?>
     2406        <?php echo get_media_items( $post_id, $errors ); ?>
    23982407</div>
    23992408
    24002409<p class="ml-submit">
    2401 <?php
    2402 submit_button(
    2403         __( 'Save all changes' ), 'savebutton', 'save', false, array(
    2404                 'id'    => 'save-all',
    2405                 'style' => 'display: none;',
    2406         )
    2407 );
    2408 ?>
     2410        <?php
     2411        submit_button(
     2412                __( 'Save all changes' ),
     2413                'savebutton',
     2414                'save',
     2415                false,
     2416                array(
     2417                        'id'    => 'save-all',
     2418                        'style' => 'display: none;',
     2419                )
     2420        );
     2421        ?>
    24092422<input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
    24102423<input type="hidden" name="type" value="<?php echo esc_attr( $GLOBALS['type'] ); ?>" />
     
    24892502</div>
    24902503</form>
    2491 <?php
     2504        <?php
    24922505}
    24932506
     
    25352548        list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query( $q );
    25362549
    2537 ?>
     2550        ?>
    25382551
    25392552<form id="filter" method="get">
     
    25512564
    25522565<ul class="subsubsub">
    2553 <?php
    2554 $type_links = array();
    2555 $_num_posts = (array) wp_count_attachments();
    2556 $matches    = wp_match_mime_types( array_keys( $post_mime_types ), array_keys( $_num_posts ) );
    2557 foreach ( $matches as $_type => $reals ) {
    2558         foreach ( $reals as $real ) {
    2559                 if ( isset( $num_posts[ $_type ] ) ) {
    2560                         $num_posts[ $_type ] += $_num_posts[ $real ];
    2561                 } else {
    2562                         $num_posts[ $_type ] = $_num_posts[ $real ];
    2563                 }
    2564         }
    2565 }
    2566 // If available type specified by media button clicked, filter by that type
    2567 if ( empty( $_GET['post_mime_type'] ) && ! empty( $num_posts[ $type ] ) ) {
    2568         $_GET['post_mime_type']                        = $type;
    2569         list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query();
    2570 }
    2571 if ( empty( $_GET['post_mime_type'] ) || $_GET['post_mime_type'] == 'all' ) {
    2572         $class = ' class="current"';
    2573 } else {
    2574         $class = '';
    2575 }
    2576 $type_links[] = '<li><a href="' . esc_url(
    2577         add_query_arg(
    2578                 array(
    2579                         'post_mime_type' => 'all',
    2580                         'paged'          => false,
    2581                         'm'              => false,
    2582                 )
    2583         )
    2584 ) . '"' . $class . '>' . __( 'All Types' ) . '</a>';
    2585 foreach ( $post_mime_types as $mime_type => $label ) {
    2586         $class = '';
    2587 
    2588         if ( ! wp_match_mime_types( $mime_type, $avail_post_mime_types ) ) {
    2589                 continue;
    2590         }
    2591 
    2592         if ( isset( $_GET['post_mime_type'] ) && wp_match_mime_types( $mime_type, $_GET['post_mime_type'] ) ) {
     2566        <?php
     2567        $type_links = array();
     2568        $_num_posts = (array) wp_count_attachments();
     2569        $matches    = wp_match_mime_types( array_keys( $post_mime_types ), array_keys( $_num_posts ) );
     2570        foreach ( $matches as $_type => $reals ) {
     2571                foreach ( $reals as $real ) {
     2572                        if ( isset( $num_posts[ $_type ] ) ) {
     2573                                $num_posts[ $_type ] += $_num_posts[ $real ];
     2574                        } else {
     2575                                $num_posts[ $_type ] = $_num_posts[ $real ];
     2576                        }
     2577                }
     2578        }
     2579        // If available type specified by media button clicked, filter by that type
     2580        if ( empty( $_GET['post_mime_type'] ) && ! empty( $num_posts[ $type ] ) ) {
     2581                $_GET['post_mime_type']                        = $type;
     2582                list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query();
     2583        }
     2584        if ( empty( $_GET['post_mime_type'] ) || $_GET['post_mime_type'] == 'all' ) {
    25932585                $class = ' class="current"';
    2594         }
    2595 
     2586        } else {
     2587                $class = '';
     2588        }
    25962589        $type_links[] = '<li><a href="' . esc_url(
    25972590                add_query_arg(
    25982591                        array(
    2599                                 'post_mime_type' => $mime_type,
     2592                                'post_mime_type' => 'all',
    26002593                                'paged'          => false,
     2594                                'm'              => false,
    26012595                        )
    26022596                )
    2603         ) . '"' . $class . '>' . sprintf( translate_nooped_plural( $label[2], $num_posts[ $mime_type ] ), '<span id="' . $mime_type . '-counter">' . number_format_i18n( $num_posts[ $mime_type ] ) . '</span>' ) . '</a>';
    2604 }
    2605 /**
    2606  * Filters the media upload mime type list items.
    2607  *
    2608  * Returned values should begin with an `<li>` tag.
    2609  *
    2610  * @since 3.1.0
    2611  *
    2612  * @param string[] $type_links An array of list items containing mime type link HTML.
    2613  */
    2614 echo implode( ' | </li>', apply_filters( 'media_upload_mime_type_links', $type_links ) ) . '</li>';
    2615 unset( $type_links );
    2616 ?>
     2597        ) . '"' . $class . '>' . __( 'All Types' ) . '</a>';
     2598        foreach ( $post_mime_types as $mime_type => $label ) {
     2599                $class = '';
     2600
     2601                if ( ! wp_match_mime_types( $mime_type, $avail_post_mime_types ) ) {
     2602                        continue;
     2603                }
     2604
     2605                if ( isset( $_GET['post_mime_type'] ) && wp_match_mime_types( $mime_type, $_GET['post_mime_type'] ) ) {
     2606                        $class = ' class="current"';
     2607                }
     2608
     2609                $type_links[] = '<li><a href="' . esc_url(
     2610                        add_query_arg(
     2611                                array(
     2612                                        'post_mime_type' => $mime_type,
     2613                                        'paged'          => false,
     2614                                )
     2615                        )
     2616                ) . '"' . $class . '>' . sprintf( translate_nooped_plural( $label[2], $num_posts[ $mime_type ] ), '<span id="' . $mime_type . '-counter">' . number_format_i18n( $num_posts[ $mime_type ] ) . '</span>' ) . '</a>';
     2617        }
     2618        /**
     2619         * Filters the media upload mime type list items.
     2620         *
     2621         * Returned values should begin with an `<li>` tag.
     2622         *
     2623         * @since 3.1.0
     2624         *
     2625         * @param string[] $type_links An array of list items containing mime type link HTML.
     2626         */
     2627        echo implode( ' | </li>', apply_filters( 'media_upload_mime_type_links', $type_links ) ) . '</li>';
     2628        unset( $type_links );
     2629        ?>
    26172630</ul>
    26182631
    26192632<div class="tablenav">
    26202633
    2621 <?php
    2622 $page_links = paginate_links(
    2623         array(
    2624                 'base'      => add_query_arg( 'paged', '%#%' ),
    2625                 'format'    => '',
    2626                 'prev_text' => __( '&laquo;' ),
    2627                 'next_text' => __( '&raquo;' ),
    2628                 'total'     => ceil( $wp_query->found_posts / 10 ),
    2629                 'current'   => $q['paged'],
    2630         )
    2631 );
    2632 
    2633 if ( $page_links ) {
    2634         echo "<div class='tablenav-pages'>$page_links</div>";
    2635 }
    2636 ?>
     2634        <?php
     2635        $page_links = paginate_links(
     2636                array(
     2637                        'base'      => add_query_arg( 'paged', '%#%' ),
     2638                        'format'    => '',
     2639                        'prev_text' => __( '&laquo;' ),
     2640                        'next_text' => __( '&raquo;' ),
     2641                        'total'     => ceil( $wp_query->found_posts / 10 ),
     2642                        'current'   => $q['paged'],
     2643                )
     2644        );
     2645
     2646        if ( $page_links ) {
     2647                echo "<div class='tablenav-pages'>$page_links</div>";
     2648        }
     2649        ?>
    26372650
    26382651<div class="alignleft actions">
    2639 <?php
    2640 
    2641 $arc_query = "SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = 'attachment' ORDER BY post_date DESC";
    2642 
    2643 $arc_result = $wpdb->get_results( $arc_query );
    2644 
    2645 $month_count    = count( $arc_result );
    2646 $selected_month = isset( $_GET['m'] ) ? $_GET['m'] : 0;
    2647 
    2648 if ( $month_count && ! ( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) {
    2649 ?>
     2652        <?php
     2653
     2654        $arc_query = "SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = 'attachment' ORDER BY post_date DESC";
     2655
     2656        $arc_result = $wpdb->get_results( $arc_query );
     2657
     2658        $month_count    = count( $arc_result );
     2659        $selected_month = isset( $_GET['m'] ) ? $_GET['m'] : 0;
     2660
     2661        if ( $month_count && ! ( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) {
     2662                ?>
    26502663<select name='m'>
    26512664<option<?php selected( $selected_month, 0 ); ?> value='0'><?php _e( 'All dates' ); ?></option>
    2652 <?php
    2653 foreach ( $arc_result as $arc_row ) {
    2654         if ( $arc_row->yyear == 0 ) {
    2655                 continue;
    2656         }
    2657         $arc_row->mmonth = zeroise( $arc_row->mmonth, 2 );
    2658 
    2659         if ( $arc_row->yyear . $arc_row->mmonth == $selected_month ) {
    2660                 $default = ' selected="selected"';
    2661         } else {
    2662                 $default = '';
    2663         }
    2664 
    2665         echo "<option$default value='" . esc_attr( $arc_row->yyear . $arc_row->mmonth ) . "'>";
    2666         echo esc_html( $wp_locale->get_month( $arc_row->mmonth ) . " $arc_row->yyear" );
    2667         echo "</option>\n";
    2668 }
    2669 ?>
     2665                <?php
     2666                foreach ( $arc_result as $arc_row ) {
     2667                        if ( $arc_row->yyear == 0 ) {
     2668                                continue;
     2669                        }
     2670                        $arc_row->mmonth = zeroise( $arc_row->mmonth, 2 );
     2671
     2672                        if ( $arc_row->yyear . $arc_row->mmonth == $selected_month ) {
     2673                                $default = ' selected="selected"';
     2674                        } else {
     2675                                $default = '';
     2676                        }
     2677
     2678                        echo "<option$default value='" . esc_attr( $arc_row->yyear . $arc_row->mmonth ) . "'>";
     2679                        echo esc_html( $wp_locale->get_month( $arc_row->mmonth ) . " $arc_row->yyear" );
     2680                        echo "</option>\n";
     2681                }
     2682                ?>
    26702683</select>
    2671 <?php } ?>
    2672 
    2673 <?php submit_button( __( 'Filter &#187;' ), '', 'post-query-submit', false ); ?>
     2684        <?php } ?>
     2685
     2686        <?php submit_button( __( 'Filter &#187;' ), '', 'post-query-submit', false ); ?>
    26742687
    26752688</div>
     
    26812694<form enctype="multipart/form-data" method="post" action="<?php echo esc_url( $form_action_url ); ?>" class="<?php echo $form_class; ?>" id="library-form">
    26822695
    2683 <?php wp_nonce_field( 'media-form' ); ?>
    2684 <?php //media_upload_form( $errors ); ?>
     2696        <?php wp_nonce_field( 'media-form' ); ?>
     2697        <?php //media_upload_form( $errors ); ?>
    26852698
    26862699<script type="text/javascript">
     
    26972710
    26982711<div id="media-items">
    2699 <?php add_filter( 'attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2 ); ?>
    2700 <?php echo get_media_items( null, $errors ); ?>
     2712        <?php add_filter( 'attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2 ); ?>
     2713        <?php echo get_media_items( null, $errors ); ?>
    27012714</div>
    27022715<p class="ml-submit">
    2703 <?php submit_button( __( 'Save all changes' ), 'savebutton', 'save', false ); ?>
     2716        <?php submit_button( __( 'Save all changes' ), 'savebutton', 'save', false ); ?>
    27042717<input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
    27052718</p>
    27062719</form>
    2707 <?php
     2720        <?php
    27082721}
    27092722
     
    28692882                $end = '</a>';
    28702883        }
    2871 ?>
     2884        ?>
    28722885<p class="hide-if-no-js"><label>
    28732886<input name="image_resize" type="checkbox" id="image_resize" value="true"<?php echo $checked; ?> />
    2874 <?php
     2887        <?php
    28752888        /* translators: 1: link start tag, 2: link end tag, 3: width, 4: height */
    28762889        printf( __( 'Scale images to match the large size selected in %1$simage options%2$s (%3$d &times; %4$d).' ), $a, $end, (int) get_option( 'large_size_w', '1024' ), (int) get_option( 'large_size_h', '1024' ) );
    2877 ?>
     2890        ?>
    28782891</label></p>
    2879 <?php
     2892        <?php
    28802893}
    28812894
     
    29262939                        $not_open_style = ' style="display:none"';
    29272940                }
    2928         ?>
     2941                ?>
    29292942
    29302943                <div class="imgedit-response" id="imgedit-response-<?php echo $attachment_id; ?>"></div>
     
    29382951                        if ( $open ) {
    29392952                                wp_image_editor( $attachment_id );}
    2940 ?>
     2953                        ?>
    29412954                </div>
    2942         <?php
     2955                <?php
    29432956        elseif ( $attachment_id && wp_attachment_is( 'audio', $post ) ) :
    29442957
     
    30253038                                                                                                                        echo ': ' . __( 'Displayed on attachment pages.' );
    30263039                                                                                                                }
    3027         ?>
     3040                                                                                                                ?>
    30283041        </label>
    30293042        <?php wp_editor( $post->post_content, 'attachment_content', $editor_args ); ?>
     
    30563069
    30573070        $att_url = wp_get_attachment_url( $post->ID );
    3058 ?>
     3071        ?>
    30593072        <div class="misc-pub-section misc-pub-attachment">
    30603073                <label for="attachment_url"><?php _e( 'File URL:' ); ?></label>
     
    30783091                                                echo strtoupper( str_replace( 'image/', '', $post->post_mime_type ) );
    30793092                                        }
    3080                 ?>
     3093                                        ?>
    30813094                </strong>
    30823095        </div>
     
    31233136                                continue;
    31243137                        }
    3125         ?>
     3138                        ?>
    31263139                <div class="misc-pub-section misc-pub-mime-meta misc-pub-<?php echo sanitize_html_class( $key ); ?>">
    31273140                        <?php echo $label; ?> <strong>
     
    31383151                                                                break;
    31393152                                                }
    3140                         ?>
     3153                                                ?>
    31413154                        </strong>
    31423155                </div>
    3143         <?php
     3156                        <?php
    31443157                }
    31453158
     
    31673180                                continue;
    31683181                        }
    3169         ?>
     3182                        ?>
    31703183                <div class="misc-pub-section misc-pub-audio misc-pub-<?php echo sanitize_html_class( $key ); ?>">
    31713184                        <?php echo $label; ?> <strong><?php echo esc_html( $meta['audio'][ $key ] ); ?></strong>
    31723185                </div>
    3173         <?php
     3186                        <?php
    31743187                }
    31753188        }
    31763189
    31773190        if ( $media_dims ) :
    3178         ?>
     3191                ?>
    31793192        <div class="misc-pub-section misc-pub-dimensions">
    31803193                <?php _e( 'Dimensions:' ); ?> <strong><?php echo $media_dims; ?></strong>
    31813194        </div>
    3182 <?php
     3195                <?php
    31833196        endif;
    31843197}
Note: See TracChangeset for help on using the changeset viewer.