Changeset 43571 for trunk/src/wp-admin/includes/media.php
- Timestamp:
- 08/17/2018 01:50:26 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/media.php
r42984 r43571 264 264 */ 265 265 function media_send_to_editor( $html ) { 266 ?>266 ?> 267 267 <script type="text/javascript"> 268 268 var win = window.dialogArguments || opener || parent || top; 269 269 win.send_to_editor( <?php echo wp_json_encode( $html ); ?> ); 270 270 </script> 271 <?php271 <?php 272 272 exit; 273 273 } … … 369 369 } 370 370 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. 372 372 } elseif ( 0 === strpos( $type, 'image/' ) && $image_meta = wp_read_image_metadata( $file ) ) { 373 373 if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) ) { … … 389 389 'post_content' => $content, 390 390 'post_excerpt' => $excerpt, 391 ), $post_data 391 ), 392 $post_data 392 393 ); 393 394 … … 459 460 'post_title' => $title, 460 461 'post_content' => $content, 461 ), $post_data 462 ), 463 $post_data 462 464 ); 463 465 … … 485 487 function wp_iframe( $content_func /* ... */ ) { 486 488 _wp_admin_html_begin(); 487 ?>489 ?> 488 490 <title><?php bloginfo( 'name' ); ?> › <?php _e( 'Uploads' ); ?> — <?php _e( 'WordPress' ); ?></title> 489 <?php490 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' ) ) 494 496 || ( ! 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 ?> 499 501 <script type="text/javascript"> 500 502 addLoadEvent = 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();}}}; … … 502 504 isRtl = <?php echo (int) is_rtl(); ?>; 503 505 </script> 504 <?php506 <?php 505 507 /** This action is documented in wp-admin/admin-header.php */ 506 508 do_action( 'admin_enqueue_scripts', 'media-upload-popup' ); … … 537 539 do_action( 'admin_head' ); 538 540 539 if ( is_string( $content_func ) ) {540 /**541 * Fires in the admin header for each specific form tab in the legacy542 * (pre-3.5.0) media upload popup.543 *544 * The dynamic portion of the hook, `$content_func`, refers to the form545 * callback for the media upload type. Possible values include546 * 'media_upload_type_form', 'media_upload_type_url_form', and547 * 'media_upload_library_form'.548 *549 * @since 2.5.0550 */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 ?> 559 561 </head> 560 562 <body<?php echo $body_id_attr; ?> class="wp-core-ui no-js"> … … 562 564 document.body.className = document.body.className.replace('no-js', 'js'); 563 565 </script> 564 <?php566 <?php 565 567 $args = func_get_args(); 566 568 $args = array_slice( $args, 1 ); … … 569 571 /** This action is documented in wp-admin/admin-footer.php */ 570 572 do_action( 'admin_print_footer_scripts' ); 571 ?>573 ?> 572 574 <script type="text/javascript">if(typeof wpOnload=='function')wpOnload();</script> 573 575 </body> 574 576 </html> 575 <?php577 <?php 576 578 } 577 579 … … 755 757 756 758 if ( isset( $_POST['insert-gallery'] ) || isset( $_POST['update-gallery'] ) ) { 757 ?>759 ?> 758 760 <script type="text/javascript"> 759 761 var win = window.dialogArguments || opener || parent || top; … … 1070 1072 */ 1071 1073 $size_names = apply_filters( 1072 'image_size_names_choose', array( 1074 'image_size_names_choose', 1075 array( 1073 1076 'thumbnail' => __( 'Thumbnail' ), 1074 1077 'medium' => __( 'Medium' ), … … 1782 1785 1783 1786 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'] 1787 1796 ); 1788 1797 … … 1944 1953 $max_upload_size = 0; 1945 1954 } 1946 ?>1955 ?> 1947 1956 1948 1957 <div id="media-upload-notice"> 1949 <?php1950 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 ?> 1956 1965 </div> 1957 1966 <div id="media-upload-error"> 1958 <?php1959 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 ?> 1965 1974 </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 1968 1986 /** 1969 * Fires when an upload will exceed the defined upload space quota for a network site.1970 * 1971 * @since 3.5.01987 * Fires just before the legacy (pre-3.5.0) upload interface is loaded. 1988 * 1989 * @since 2.6.0 1972 1990 */ 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 && 2021 2030 strpos( $_SERVER['HTTP_USER_AGENT'], 'like Mac OS X' ) !== false ) { 2022 2031 2023 $plupload_init['multi_selection'] = false;2024 }2025 2026 /**2027 * Filters the default Plupload settings.2028 *2029 * @since 3.3.02030 *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 ?> 2036 2045 2037 2046 <script type="text/javascript"> 2038 <?php2039 // 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 ?> 2049 2058 var resize_height = <?php echo $large_size_h; ?>, resize_width = <?php echo $large_size_w; ?>, 2050 2059 wpUploaderInit = <?php echo wp_json_encode( $plupload_init ); ?>; … … 2052 2061 2053 2062 <div id="plupload-upload-ui" class="hide-if-no-js"> 2054 <?php2055 /**2056 * Fires before the upload interface loads.2057 *2058 * @since 2.6.0 As 'pre-flash-upload-ui'2059 * @since 3.3.02060 */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 ?> 2063 2072 <div id="drag-drop-area"> 2064 2073 <div class="drag-drop-inside"> … … 2068 2077 </div> 2069 2078 </div> 2070 <?php2071 /**2072 * Fires after the upload interface loads.2073 *2074 * @since 2.6.0 As 'post-flash-upload-ui'2075 * @since 3.3.02076 */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 ?> 2079 2088 </div> 2080 2089 … … 2095 2104 </p> 2096 2105 <div class="clear"></div> 2097 <?php2098 /**2099 * Fires after the upload button in the media upload interface.2100 *2101 * @since 2.6.02102 */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 ?> 2105 2114 </div> 2106 2115 2107 2116 <p class="max-upload-size"><?php printf( __( 'Maximum upload file size: %s.' ), esc_html( size_format( $max_upload_size ) ) ); ?></p> 2108 <?php2117 <?php 2109 2118 2110 2119 /** … … 2149 2158 $form_class .= ' html-uploader'; 2150 2159 } 2151 ?>2160 ?> 2152 2161 2153 2162 <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 ); ?> 2155 2164 <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' ); ?> 2157 2166 2158 2167 <h3 class="media-title"><?php _e( 'Add media files from your computer' ); ?></h3> 2159 2168 2160 <?php media_upload_form( $errors ); ?>2169 <?php media_upload_form( $errors ); ?> 2161 2170 2162 2171 <script type="text/javascript"> … … 2170 2179 </script> 2171 2180 <div id="media-items"> 2172 <?php2173 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 ?> 2184 2193 </div> 2185 2194 2186 2195 <p class="savebutton ml-submit"> 2187 <?php submit_button( __( 'Save all changes' ), '', 'save', false ); ?>2196 <?php submit_button( __( 'Save all changes' ), '', 'save', false ); ?> 2188 2197 </p> 2189 2198 </form> 2190 <?php2199 <?php 2191 2200 } 2192 2201 … … 2217 2226 $form_class .= ' html-uploader'; 2218 2227 } 2219 ?>2228 ?> 2220 2229 2221 2230 <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"> 2222 2231 <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' ); ?> 2224 2233 2225 2234 <h3 class="media-title"><?php _e( 'Insert media from another website' ); ?></h3> … … 2241 2250 alt = f.alt.value.replace(/'/g, ''').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>'); 2242 2251 2243 <?php2252 <?php 2244 2253 /** This filter is documented in wp-admin/includes/media.php */ 2245 if ( ! apply_filters( 'disable_captions', '' ) ) {2246 ?>2254 if ( ! apply_filters( 'disable_captions', '' ) ) { 2255 ?> 2247 2256 if ( f.caption.value ) { 2248 2257 caption = f.caption.value.replace(/\r\n|\r/g, '\n'); … … 2253 2262 caption = caption.replace(/\s*\n\s*/g, '<br />'); 2254 2263 } 2255 <?php } ?>2264 <?php } ?> 2256 2265 2257 2266 cls = caption ? '' : ' class="'+t.align+'"'; … … 2319 2328 <div id="media-items"> 2320 2329 <div class="media-item media-blank"> 2321 <?php2322 /**2323 * Filters the insert media from URL form HTML.2324 *2325 * @since 3.3.02326 *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 ?> 2331 2340 </div> 2332 2341 </div> 2333 2342 </form> 2334 <?php2343 <?php 2335 2344 } 2336 2345 … … 2361 2370 $form_class .= ' html-uploader'; 2362 2371 } 2363 ?>2372 ?> 2364 2373 2365 2374 <script type="text/javascript"> … … 2374 2383 <div id="sort-buttons" class="hide-if-no-js"> 2375 2384 <span> 2376 <?php _e( 'All Tabs:' ); ?>2385 <?php _e( 'All Tabs:' ); ?> 2377 2386 <a href="#" id="showall"><?php _e( 'Show' ); ?></a> 2378 2387 <a href="#" id="hideall" style="display:none;"><?php _e( 'Hide' ); ?></a> 2379 2388 </span> 2380 <?php _e( 'Sort Order:' ); ?>2389 <?php _e( 'Sort Order:' ); ?> 2381 2390 <a href="#" id="asc"><?php _e( 'Ascending' ); ?></a> | 2382 2391 <a href="#" id="desc"><?php _e( 'Descending' ); ?></a> | … … 2384 2393 </div> 2385 2394 <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 ); ?> 2388 2397 <table class="widefat"> 2389 2398 <thead><tr> … … 2394 2403 </table> 2395 2404 <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 ); ?> 2398 2407 </div> 2399 2408 2400 2409 <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 ?> 2409 2422 <input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" /> 2410 2423 <input type="hidden" name="type" value="<?php echo esc_attr( $GLOBALS['type'] ); ?>" /> … … 2489 2502 </div> 2490 2503 </form> 2491 <?php2504 <?php 2492 2505 } 2493 2506 … … 2535 2548 list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query( $q ); 2536 2549 2537 ?>2550 ?> 2538 2551 2539 2552 <form id="filter" method="get"> … … 2551 2564 2552 2565 <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' ) { 2593 2585 $class = ' class="current"'; 2594 } 2595 2586 } else { 2587 $class = ''; 2588 } 2596 2589 $type_links[] = '<li><a href="' . esc_url( 2597 2590 add_query_arg( 2598 2591 array( 2599 'post_mime_type' => $mime_type,2592 'post_mime_type' => 'all', 2600 2593 'paged' => false, 2594 'm' => false, 2601 2595 ) 2602 2596 ) 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 ?> 2617 2630 </ul> 2618 2631 2619 2632 <div class="tablenav"> 2620 2633 2621 <?php2622 $page_links = paginate_links(2623 array(2624 'base' => add_query_arg( 'paged', '%#%' ),2625 'format' => '',2626 'prev_text' => __( '«' ),2627 'next_text' => __( '»' ),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' => __( '«' ), 2640 'next_text' => __( '»' ), 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 ?> 2637 2650 2638 2651 <div class="alignleft actions"> 2639 <?php2640 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 ?> 2650 2663 <select name='m'> 2651 2664 <option<?php selected( $selected_month, 0 ); ?> value='0'><?php _e( 'All dates' ); ?></option> 2652 <?php2653 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 ?> 2670 2683 </select> 2671 <?php } ?>2672 2673 <?php submit_button( __( 'Filter »' ), '', 'post-query-submit', false ); ?>2684 <?php } ?> 2685 2686 <?php submit_button( __( 'Filter »' ), '', 'post-query-submit', false ); ?> 2674 2687 2675 2688 </div> … … 2681 2694 <form enctype="multipart/form-data" method="post" action="<?php echo esc_url( $form_action_url ); ?>" class="<?php echo $form_class; ?>" id="library-form"> 2682 2695 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 ); ?> 2685 2698 2686 2699 <script type="text/javascript"> … … 2697 2710 2698 2711 <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 ); ?> 2701 2714 </div> 2702 2715 <p class="ml-submit"> 2703 <?php submit_button( __( 'Save all changes' ), 'savebutton', 'save', false ); ?>2716 <?php submit_button( __( 'Save all changes' ), 'savebutton', 'save', false ); ?> 2704 2717 <input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" /> 2705 2718 </p> 2706 2719 </form> 2707 <?php2720 <?php 2708 2721 } 2709 2722 … … 2869 2882 $end = '</a>'; 2870 2883 } 2871 ?>2884 ?> 2872 2885 <p class="hide-if-no-js"><label> 2873 2886 <input name="image_resize" type="checkbox" id="image_resize" value="true"<?php echo $checked; ?> /> 2874 <?php2887 <?php 2875 2888 /* translators: 1: link start tag, 2: link end tag, 3: width, 4: height */ 2876 2889 printf( __( 'Scale images to match the large size selected in %1$simage options%2$s (%3$d × %4$d).' ), $a, $end, (int) get_option( 'large_size_w', '1024' ), (int) get_option( 'large_size_h', '1024' ) ); 2877 ?>2890 ?> 2878 2891 </label></p> 2879 <?php2892 <?php 2880 2893 } 2881 2894 … … 2926 2939 $not_open_style = ' style="display:none"'; 2927 2940 } 2928 ?>2941 ?> 2929 2942 2930 2943 <div class="imgedit-response" id="imgedit-response-<?php echo $attachment_id; ?>"></div> … … 2938 2951 if ( $open ) { 2939 2952 wp_image_editor( $attachment_id );} 2940 ?>2953 ?> 2941 2954 </div> 2942 <?php2955 <?php 2943 2956 elseif ( $attachment_id && wp_attachment_is( 'audio', $post ) ) : 2944 2957 … … 3025 3038 echo ': ' . __( 'Displayed on attachment pages.' ); 3026 3039 } 3027 ?>3040 ?> 3028 3041 </label> 3029 3042 <?php wp_editor( $post->post_content, 'attachment_content', $editor_args ); ?> … … 3056 3069 3057 3070 $att_url = wp_get_attachment_url( $post->ID ); 3058 ?>3071 ?> 3059 3072 <div class="misc-pub-section misc-pub-attachment"> 3060 3073 <label for="attachment_url"><?php _e( 'File URL:' ); ?></label> … … 3078 3091 echo strtoupper( str_replace( 'image/', '', $post->post_mime_type ) ); 3079 3092 } 3080 ?>3093 ?> 3081 3094 </strong> 3082 3095 </div> … … 3123 3136 continue; 3124 3137 } 3125 ?>3138 ?> 3126 3139 <div class="misc-pub-section misc-pub-mime-meta misc-pub-<?php echo sanitize_html_class( $key ); ?>"> 3127 3140 <?php echo $label; ?> <strong> … … 3138 3151 break; 3139 3152 } 3140 ?>3153 ?> 3141 3154 </strong> 3142 3155 </div> 3143 <?php3156 <?php 3144 3157 } 3145 3158 … … 3167 3180 continue; 3168 3181 } 3169 ?>3182 ?> 3170 3183 <div class="misc-pub-section misc-pub-audio misc-pub-<?php echo sanitize_html_class( $key ); ?>"> 3171 3184 <?php echo $label; ?> <strong><?php echo esc_html( $meta['audio'][ $key ] ); ?></strong> 3172 3185 </div> 3173 <?php3186 <?php 3174 3187 } 3175 3188 } 3176 3189 3177 3190 if ( $media_dims ) : 3178 ?>3191 ?> 3179 3192 <div class="misc-pub-section misc-pub-dimensions"> 3180 3193 <?php _e( 'Dimensions:' ); ?> <strong><?php echo $media_dims; ?></strong> 3181 3194 </div> 3182 <?php3195 <?php 3183 3196 endif; 3184 3197 }
Note: See TracChangeset
for help on using the changeset viewer.