Changeset 45934 for trunk/src/wp-admin/includes/media.php
- Timestamp:
- 09/04/2019 01:10:57 AM (6 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-admin/includes/media.php (modified) (114 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/media.php
r45932 r45934 81 81 if ( ! empty( $tabs ) ) { 82 82 echo "<ul id='sidemenu'>\n"; 83 83 84 if ( isset( $redir_tab ) && array_key_exists( $redir_tab, $tabs ) ) { 84 85 $current = $redir_tab; … … 109 110 echo "\t<li id='" . esc_attr( "tab-$callback" ) . "'>$link</li>\n"; 110 111 } 112 111 113 echo "</ul>\n"; 112 114 } … … 266 268 function media_send_to_editor( $html ) { 267 269 ?> 268 <script type="text/javascript">269 var win = window.dialogArguments || opener || parent || top;270 win.send_to_editor( <?php echo wp_json_encode( $html ); ?> );271 </script>270 <script type="text/javascript"> 271 var win = window.dialogArguments || opener || parent || top; 272 win.send_to_editor( <?php echo wp_json_encode( $html ); ?> ); 273 </script> 272 274 <?php 273 275 exit; … … 287 289 */ 288 290 function media_handle_upload( $file_id, $post_id, $post_data = array(), $overrides = array( 'test_form' => false ) ) { 289 290 291 $time = current_time( 'mysql' ); 291 292 $post = get_post( $post_id ); 293 292 294 if ( $post ) { 293 295 // The post date doesn't usually matter for pages, so don't backdate this upload. … … 307 309 $name = wp_basename( $name, ".$ext" ); 308 310 309 $url = $file['url']; 310 $type = $file['type']; 311 $file = $file['file']; 312 $title = sanitize_text_field( $name ); 313 $content = ''; 314 $excerpt = ''; 311 $url = $file['url']; 312 $type = $file['type']; 313 $file = $file['file']; 314 $title = sanitize_text_field( $name ); 315 $content = ''; 316 $excerpt = ''; 317 $image_ref = false; 315 318 316 319 if ( preg_match( '#^audio#', $type ) ) { … … 357 360 if ( ! empty( $meta['track_number'] ) ) { 358 361 $track_number = explode( '/', $meta['track_number'] ); 362 359 363 if ( isset( $track_number[1] ) ) { 360 364 /* translators: Audio file track information. 1: Audio track number, 2: Total audio tracks. */ … … 373 377 // Use image exif/iptc data for title and caption defaults if possible. 374 378 } elseif ( 0 === strpos( $type, 'image/' ) ) { 379 // Image file reference passed by the uploader. 380 if ( ! empty( $_POST['_wp_temp_image_ref'] ) ) { 381 $image_ref = preg_replace( '/[^a-zA-Z0-9_]/', '', $_POST['_wp_temp_image_ref'] ); 382 } 383 375 384 $image_meta = wp_read_image_metadata( $file ); 385 376 386 if ( $image_meta ) { 377 387 if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) ) { … … 402 412 403 413 // Save the data 404 $id = wp_insert_attachment( $attachment, $file, $post_id, true ); 405 if ( ! is_wp_error( $id ) ) { 406 wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) ); 407 } 408 409 return $id; 410 414 $attachment_id = wp_insert_attachment( $attachment, $file, $post_id, true ); 415 416 if ( ! is_wp_error( $attachment_id ) ) { 417 // If an image, keep the upload reference until all image sub-sizes are created. 418 if ( $image_ref ) { 419 set_transient( '_wp_temp_image_ref:' . $image_ref, $attachment_id, HOUR_IN_SECONDS ); 420 } 421 422 // The image sub-sizes are created during wp_generate_attachment_metadata(). 423 // This is generally slow and may cause timeouts or out of memory errors. 424 wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $file ) ); 425 426 // At this point the image is uploaded successfully even if there were specific errors or some sub-sizes were not created. 427 // The transient is not needed any more. 428 if ( $image_ref ) { 429 delete_transient( '_wp_temp_image_ref:' . $image_ref ); 430 } 431 } 432 433 return $attachment_id; 411 434 } 412 435 … … 427 450 $time = current_time( 'mysql' ); 428 451 $post = get_post( $post_id ); 452 429 453 if ( $post ) { 430 454 if ( substr( $post->post_date, 0, 4 ) > 0 ) { … … 434 458 435 459 $file = wp_handle_sideload( $file_array, $overrides, $time ); 460 436 461 if ( isset( $file['error'] ) ) { 437 462 return new WP_Error( 'upload_error', $file['error'] ); … … 446 471 // Use image exif/iptc data for title and caption defaults if possible. 447 472 $image_meta = wp_read_image_metadata( $file ); 473 448 474 if ( $image_meta ) { 449 475 if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) ) { 450 476 $title = $image_meta['title']; 451 477 } 478 452 479 if ( trim( $image_meta['caption'] ) ) { 453 480 $content = $image_meta['caption']; … … 475 502 476 503 // Save the attachment metadata 477 $id = wp_insert_attachment( $attachment, $file, $post_id, true ); 478 if ( ! is_wp_error( $id ) ) { 479 wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) ); 480 } 481 482 return $id; 504 $attachment_id = wp_insert_attachment( $attachment, $file, $post_id, true ); 505 506 if ( ! is_wp_error( $attachment_id ) ) { 507 wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $file ) ); 508 } 509 510 return $attachment_id; 483 511 } 484 512 … … 496 524 _wp_admin_html_begin(); 497 525 ?> 498 <title><?php bloginfo( 'name' ); ?> › <?php _e( 'Uploads' ); ?> — <?php _e( 'WordPress' ); ?></title>526 <title><?php bloginfo( 'name' ); ?> › <?php _e( 'Uploads' ); ?> — <?php _e( 'WordPress' ); ?></title> 499 527 <?php 500 528 501 529 wp_enqueue_style( 'colors' ); 502 530 // Check callback name for 'media' 503 if ( ( is_array( $content_func ) && ! empty( $content_func[1] ) && 0 === strpos( (string) $content_func[1], 'media' ) ) 504 || ( ! is_array( $content_func ) && 0 === strpos( $content_func, 'media' ) ) ) { 531 if ( 532 ( is_array( $content_func ) && ! empty( $content_func[1] ) && 0 === strpos( (string) $content_func[1], 'media' ) ) || 533 ( ! is_array( $content_func ) && 0 === strpos( $content_func, 'media' ) ) 534 ) { 505 535 wp_enqueue_style( 'deprecated-media' ); 506 536 } 507 537 wp_enqueue_style( 'ie' ); 538 508 539 ?> 509 <script type="text/javascript">510 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();}}};511 var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>', pagenow = 'media-upload-popup', adminpage = 'media-upload-popup',512 isRtl = <?php echo (int) is_rtl(); ?>;513 </script>540 <script type="text/javascript"> 541 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();}}}; 542 var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>', pagenow = 'media-upload-popup', adminpage = 'media-upload-popup', 543 isRtl = <?php echo (int) is_rtl(); ?>; 544 </script> 514 545 <?php 515 546 /** This action is documented in wp-admin/admin-header.php */ … … 563 594 564 595 $body_id_attr = ''; 596 565 597 if ( isset( $GLOBALS['body_id'] ) ) { 566 598 $body_id_attr = ' id="' . $GLOBALS['body_id'] . '"'; 567 599 } 600 568 601 ?> 569 </head>570 <body<?php echo $body_id_attr; ?> class="wp-core-ui no-js">571 <script type="text/javascript">572 document.body.className = document.body.className.replace('no-js', 'js');573 </script>602 </head> 603 <body<?php echo $body_id_attr; ?> class="wp-core-ui no-js"> 604 <script type="text/javascript"> 605 document.body.className = document.body.className.replace('no-js', 'js'); 606 </script> 574 607 <?php 608 575 609 $args = func_get_args(); 576 610 $args = array_slice( $args, 1 ); … … 579 613 /** This action is documented in wp-admin/admin-footer.php */ 580 614 do_action( 'admin_print_footer_scripts' ); 615 581 616 ?> 582 <script type="text/javascript">if(typeof wpOnload=='function')wpOnload();</script>583 </body>584 </html>617 <script type="text/javascript">if(typeof wpOnload=='function')wpOnload();</script> 618 </body> 619 </html> 585 620 <?php 586 621 } … … 602 637 603 638 $post = get_post(); 639 604 640 if ( ! $post && ! empty( $GLOBALS['post_ID'] ) ) { 605 641 $post = $GLOBALS['post_ID']; 606 642 } 607 643 608 wp_enqueue_media( 609 array( 610 'post' => $post, 611 ) 612 ); 644 wp_enqueue_media( array( 'post' => $post ) ); 613 645 614 646 $img = '<span class="wp-media-buttons-icon"></span> '; 615 647 616 648 $id_attribute = $instance === 1 ? ' id="insert-media-button"' : ''; 649 617 650 printf( 618 651 '<button type="button"%s class="button insert-media add_media" data-editor="%s">%s</button>', … … 621 654 $img . __( 'Add Media' ) 622 655 ); 656 623 657 /** 624 658 * Filters the legacy (pre-3.5.0) media buttons. … … 710 744 $post['post_content'] = $attachment['post_content']; 711 745 } 746 712 747 if ( isset( $attachment['post_title'] ) ) { 713 748 $post['post_title'] = $attachment['post_title']; 714 749 } 750 715 751 if ( isset( $attachment['post_excerpt'] ) ) { 716 752 $post['post_excerpt'] = $attachment['post_excerpt']; 717 753 } 754 718 755 if ( isset( $attachment['menu_order'] ) ) { 719 756 $post['menu_order'] = $attachment['menu_order']; … … 740 777 if ( isset( $attachment['image_alt'] ) ) { 741 778 $image_alt = wp_unslash( $attachment['image_alt'] ); 779 742 780 if ( $image_alt != get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ) ) { 743 781 $image_alt = wp_strip_all_tags( $image_alt, true ); … … 772 810 </script> 773 811 <?php 812 774 813 exit; 775 814 } … … 777 816 if ( isset( $send_id ) ) { 778 817 $attachment = wp_unslash( $_POST['attachments'][ $send_id ] ); 779 780 $html = isset( $attachment['post_title'] ) ? $attachment['post_title'] : ''; 818 $html = isset( $attachment['post_title'] ) ? $attachment['post_title'] : ''; 819 781 820 if ( ! empty( $attachment['url'] ) ) { 782 821 $rel = ''; 822 783 823 if ( strpos( $attachment['url'], 'attachment_id' ) || get_attachment_link( $send_id ) == $attachment['url'] ) { 784 824 $rel = " rel='attachment wp-att-" . esc_attr( $send_id ) . "'"; 785 825 } 826 786 827 $html = "<a href='{$attachment['url']}'$rel>$html</a>"; 787 828 } … … 799 840 */ 800 841 $html = apply_filters( 'media_send_to_editor', $html, $send_id, $attachment ); 842 801 843 return media_send_to_editor( $html ); 802 844 } … … 821 863 $id = media_handle_upload( 'async-upload', $_REQUEST['post_id'] ); 822 864 unset( $_FILES ); 865 823 866 if ( is_wp_error( $id ) ) { 824 867 $errors['upload_error'] = $id; … … 829 872 if ( ! empty( $_POST['insertonlybutton'] ) ) { 830 873 $src = $_POST['src']; 874 831 875 if ( ! empty( $src ) && ! strpos( $src, '://' ) ) { 832 876 $src = "http://$src"; … … 845 889 $type = 'file'; 846 890 $ext = preg_replace( '/^.+?\.([^.]+)$/', '$1', $src ); 891 847 892 if ( $ext ) { 848 893 $ext_type = wp_ext2type( $ext ); … … 868 913 $align = ''; 869 914 $alt = esc_attr( wp_unslash( $_POST['alt'] ) ); 915 870 916 if ( isset( $_POST['align'] ) ) { 871 917 $align = esc_attr( wp_unslash( $_POST['align'] ) ); 872 918 $class = " class='align$align'"; 873 919 } 920 874 921 if ( ! empty( $src ) ) { 875 922 $html = "<img src='" . esc_url( $src ) . "' alt='$alt'$class />"; … … 896 943 $errors['upload_notice'] = __( 'Saved.' ); 897 944 wp_enqueue_script( 'admin-gallery' ); 945 898 946 return wp_iframe( 'media_upload_gallery_form', $errors ); 899 947 … … 904 952 return $return; 905 953 } 954 906 955 if ( is_array( $return ) ) { 907 956 $errors = $return; … … 911 960 if ( isset( $_GET['tab'] ) && $_GET['tab'] == 'type_url' ) { 912 961 $type = 'image'; 962 913 963 if ( isset( $_GET['type'] ) && in_array( $_GET['type'], array( 'video', 'audio', 'file' ) ) ) { 914 964 $type = $_GET['type']; 915 965 } 966 916 967 return wp_iframe( 'media_upload_type_url_form', $type, $errors, $id ); 917 968 } … … 938 989 // Set variables for storage, fix file filename for query strings. 939 990 preg_match( '/[^\?]+\.(jpe?g|jpe|gif|png)\b/i', $file, $matches ); 991 940 992 if ( ! $matches ) { 941 993 return new WP_Error( 'image_sideload_failed', __( 'Invalid image URL' ) ); … … 976 1028 $alt = isset( $desc ) ? esc_attr( $desc ) : ''; 977 1029 $html = "<img src='$src' alt='$alt' />"; 1030 978 1031 return $html; 979 1032 } else { … … 998 1051 return $return; 999 1052 } 1053 1000 1054 if ( is_array( $return ) ) { 1001 1055 $errors = $return; … … 1016 1070 function media_upload_library() { 1017 1071 $errors = array(); 1072 1018 1073 if ( ! empty( $_POST ) ) { 1019 1074 $return = media_upload_form_handler(); … … 1051 1106 'right' => __( 'Right' ), 1052 1107 ); 1108 1053 1109 if ( ! array_key_exists( (string) $checked, $alignments ) ) { 1054 1110 $checked = 'none'; … … 1056 1112 1057 1113 $out = array(); 1114 1058 1115 foreach ( $alignments as $name => $label ) { 1059 1116 $name = esc_attr( $name ); … … 1062 1119 " /><label for='image-align-{$name}-{$post->ID}' class='align image-align-{$name}-label'>$label</label>"; 1063 1120 } 1121 1064 1122 return join( "\n", $out ); 1065 1123 } … … 1096 1154 $check = get_user_setting( 'imgsize', 'medium' ); 1097 1155 } 1156 1098 1157 $out = array(); 1099 1158 … … 1161 1220 1162 1221 $url = ''; 1222 1163 1223 if ( $url_type == 'file' ) { 1164 1224 $url = $file; … … 1268 1328 function image_media_send_to_editor( $html, $attachment_id, $attachment ) { 1269 1329 $post = get_post( $attachment_id ); 1330 1270 1331 if ( substr( $post->post_mime_type, 0, 5 ) == 'image' ) { 1271 1332 $url = $attachment['url']; … … 1294 1355 $post = get_post( $post ); 1295 1356 } 1357 1296 1358 if ( is_array( $post ) ) { 1297 1359 $post = new WP_Post( (object) $post ); … … 1339 1401 foreach ( get_attachment_taxonomies( $post ) as $taxonomy ) { 1340 1402 $t = (array) get_taxonomy( $taxonomy ); 1403 1341 1404 if ( ! $t['public'] || ! $t['show_ui'] ) { 1342 1405 continue; 1343 1406 } 1407 1344 1408 if ( empty( $t['label'] ) ) { 1345 1409 $t['label'] = $taxonomy; 1346 1410 } 1411 1347 1412 if ( empty( $t['args'] ) ) { 1348 1413 $t['args'] = array(); … … 1350 1415 1351 1416 $terms = get_object_term_cache( $post->ID, $taxonomy ); 1417 1352 1418 if ( false === $terms ) { 1353 1419 $terms = wp_get_object_terms( $post->ID, $taxonomy, $t['args'] ); … … 1359 1425 $values[] = $term->slug; 1360 1426 } 1427 1361 1428 $t['value'] = join( ', ', $values ); 1362 1429 … … 1371 1438 if ( substr( $post->post_mime_type, 0, 5 ) == 'image' ) { 1372 1439 $alt = get_post_meta( $post->ID, '_wp_attachment_image_alt', true ); 1440 1373 1441 if ( empty( $alt ) ) { 1374 1442 $alt = ''; … … 1425 1493 function get_media_items( $post_id, $errors ) { 1426 1494 $attachments = array(); 1495 1427 1496 if ( $post_id ) { 1428 1497 $post = get_post( $post_id ); 1498 1429 1499 if ( $post && $post->post_type == 'attachment' ) { 1430 1500 $attachments = array( $post->ID => $post ); … … 1452 1522 continue; 1453 1523 } 1524 1454 1525 $item = get_media_item( $id, array( 'errors' => isset( $errors[ $id ] ) ? $errors[ $id ] : null ) ); 1526 1455 1527 if ( $item ) { 1456 1528 $output .= "\n<div id='media-item-$id' class='media-item child-of-$attachment->post_parent preloaded'><div class='progress hidden'><div class='bar'></div></div><div id='media-upload-error-$id' class='hidden'></div><div class='filename hidden'></div>$item\n</div>"; … … 1480 1552 if ( $attachment_id ) { 1481 1553 $thumb_url = wp_get_attachment_image_src( $attachment_id, 'thumbnail', true ); 1554 1482 1555 if ( $thumb_url ) { 1483 1556 $thumb_url = $thumb_url[0]; … … 1526 1599 $class = empty( $parsed_args['errors'] ) ? 'startclosed' : 'startopen'; 1527 1600 $toggle_links = " 1528 <a class='toggle describe-toggle-on' href='#'>$toggle_on</a>1529 <a class='toggle describe-toggle-off' href='#'>$toggle_off</a>";1601 <a class='toggle describe-toggle-on' href='#'>$toggle_on</a> 1602 <a class='toggle describe-toggle-off' href='#'>$toggle_off</a>"; 1530 1603 } else { 1531 1604 $class = ''; … … 1554 1627 $media_dims = ''; 1555 1628 $meta = wp_get_attachment_metadata( $post->ID ); 1629 1556 1630 if ( isset( $meta['width'], $meta['height'] ) ) { 1557 1631 $media_dims .= "<span id='media-dims-$post->ID'>{$meta['width']} × {$meta['height']}</span> "; … … 1569 1643 1570 1644 $image_edit_button = ''; 1645 1571 1646 if ( wp_attachment_is_image( $post->ID ) && wp_image_editor_supports( array( 'mime_type' => $post->post_mime_type ) ) ) { 1572 1647 $nonce = wp_create_nonce( "image_editor-$post->ID" ); … … 1577 1652 1578 1653 $item = " 1579 $type_html1580 $toggle_links1581 $order1582 $display_title1583 <table class='slidetoggle describe $class'>1584 <thead class='media-item-info' id='media-head-$post->ID'>1585 <tr>1654 $type_html 1655 $toggle_links 1656 $order 1657 $display_title 1658 <table class='slidetoggle describe $class'> 1659 <thead class='media-item-info' id='media-head-$post->ID'> 1660 <tr> 1586 1661 <td class='A1B1' id='thumbnail-head-$post->ID'> 1587 1662 <p><a href='$attachment_url' target='_blank'><img class='thumbnail' src='$thumb_url' alt='' /></a></p> … … 1592 1667 <p><strong>" . __( 'File type:' ) . "</strong> $post->post_mime_type</p> 1593 1668 <p><strong>" . __( 'Upload date:' ) . '</strong> ' . mysql2date( __( 'F j, Y' ), $post->post_date ) . '</p>'; 1669 1594 1670 if ( ! empty( $media_dims ) ) { 1595 1671 $item .= '<p><strong>' . __( 'Dimensions:' ) . "</strong> $media_dims</p>\n"; 1596 1672 } 1597 1673 1598 $item .= "</td></tr>\n";1674 $item .= "</td></tr>\n"; 1599 1675 1600 1676 $item .= " … … 1641 1717 $thumbnail = ''; 1642 1718 $calling_post_id = 0; 1719 1643 1720 if ( isset( $_GET['post_id'] ) ) { 1644 1721 $calling_post_id = absint( $_GET['post_id'] ); … … 1646 1723 $calling_post_id = $post->post_parent; 1647 1724 } 1725 1648 1726 if ( 'image' == $type && $calling_post_id && current_theme_supports( 'post-thumbnails', get_post_type( $calling_post_id ) ) 1649 1727 && post_type_supports( get_post_type( $calling_post_id ), 'thumbnail' ) && get_post_thumbnail_id( $calling_post_id ) != $attachment_id ) { … … 1659 1737 $form_fields['buttons'] = array( 'tr' => "\t\t<tr class='submit'><td></td><td class='savesend'>" . $parsed_args['send'] . " $thumbnail $delete</td></tr>\n" ); 1660 1738 } 1739 1661 1740 $hidden_fields = array(); 1662 1741 … … 1685 1764 1686 1765 $item .= "\t\t<tr class='$class'>\n\t\t\t<th scope='row' class='label'><label for='$name'><span class='alignleft'>{$field['label']}{$required}</span><br class='clear' /></label></th>\n\t\t\t<td class='field'>"; 1766 1687 1767 if ( ! empty( $field[ $field['input'] ] ) ) { 1688 1768 $item .= $field[ $field['input'] ]; … … 1697 1777 $item .= "<input type='text' class='text' id='$name' name='$name' value='" . esc_attr( $field['value'] ) . "'{$required_attr} />"; 1698 1778 } 1779 1699 1780 if ( ! empty( $field['helps'] ) ) { 1700 1781 $item .= "<p class='help'>" . join( "</p>\n<p class='help'>", array_unique( (array) $field['helps'] ) ) . '</p>'; … … 1728 1809 $item .= "\t\t<tr class='final'><td colspan='2'>{$form_fields['_final']}</td></tr>\n"; 1729 1810 } 1811 1730 1812 $item .= "\t</tbody>\n"; 1731 1813 $item .= "\t</table>\n"; … … 1771 1853 foreach ( get_attachment_taxonomies( $post ) as $taxonomy ) { 1772 1854 $t = (array) get_taxonomy( $taxonomy ); 1855 1773 1856 if ( ! $t['public'] || ! $t['show_ui'] ) { 1774 1857 continue; 1775 1858 } 1859 1776 1860 if ( empty( $t['label'] ) ) { 1777 1861 $t['label'] = $taxonomy; 1778 1862 } 1863 1779 1864 if ( empty( $t['args'] ) ) { 1780 1865 $t['args'] = array(); … … 1782 1867 1783 1868 $terms = get_object_term_cache( $post->ID, $taxonomy ); 1869 1784 1870 if ( false === $terms ) { 1785 1871 $terms = wp_get_object_terms( $post->ID, $taxonomy, $t['args'] ); … … 1791 1877 $values[] = $term->slug; 1792 1878 } 1879 1793 1880 $t['value'] = join( ', ', $values ); 1794 1881 $t['taxonomy'] = true; … … 1832 1919 1833 1920 $item = ''; 1921 1834 1922 foreach ( $form_fields as $id => $field ) { 1835 1923 if ( $id[0] == '_' ) { … … 1877 1965 $item .= "<input type='text' class='text' id='$id_attr' name='$name' value='" . esc_attr( $field['value'] ) . "' $readonly{$required_attr} />"; 1878 1966 } 1967 1879 1968 if ( ! empty( $field['helps'] ) ) { 1880 1969 $item .= "<p class='help'>" . join( "</p>\n<p class='help'>", array_unique( (array) $field['helps'] ) ) . '</p>'; 1881 1970 } 1971 1882 1972 $item .= "</td>\n\t\t</tr>\n"; 1883 1973 … … 1940 2030 1941 2031 echo '<script type="text/javascript">post_id = ' . $post_id . ';</script>'; 2032 1942 2033 if ( empty( $_GET['chromeless'] ) ) { 1943 2034 echo '<div id="media-upload-header">'; … … 1980 2071 $max_upload_size = 0; 1981 2072 } 2073 1982 2074 ?> 1983 1984 <div id="media-upload-notice"> 2075 <div id="media-upload-notice"> 1985 2076 <?php 1986 2077 … … 1990 2081 1991 2082 ?> 1992 </div>1993 <div id="media-upload-error">2083 </div> 2084 <div id="media-upload-error"> 1994 2085 <?php 1995 2086 … … 1999 2090 2000 2091 ?> 2001 </div>2092 </div> 2002 2093 <?php 2094 2003 2095 if ( is_multisite() && ! is_upload_space_available() ) { 2004 2096 /** … … 2046 2138 'file_data_name' => 'async-upload', 2047 2139 'url' => $upload_action_url, 2048 'filters' => array( 2049 'max_file_size' => $max_upload_size . 'b', 2050 ), 2140 'filters' => array( 'max_file_size' => $max_upload_size . 'b' ), 2051 2141 'multipart_params' => $post_params, 2052 2142 ); … … 2054 2144 // Currently only iOS Safari supports multiple files uploading but iOS 7.x has a bug that prevents uploading of videos 2055 2145 // when enabled. See #29602. 2056 if ( wp_is_mobile() && strpos( $_SERVER['HTTP_USER_AGENT'], 'OS 7_' ) !== false && 2057 strpos( $_SERVER['HTTP_USER_AGENT'], 'like Mac OS X' ) !== false ) { 2058 2146 if ( 2147 wp_is_mobile() && 2148 strpos( $_SERVER['HTTP_USER_AGENT'], 'OS 7_' ) !== false && 2149 strpos( $_SERVER['HTTP_USER_AGENT'], 'like Mac OS X' ) !== false 2150 ) { 2059 2151 $plupload_init['multi_selection'] = false; 2060 2152 } … … 2070 2162 2071 2163 ?> 2072 2073 <script type="text/javascript"> 2164 <script type="text/javascript"> 2074 2165 <?php 2075 2166 // Verify size is an int. If not return default value. 2076 2167 $large_size_h = absint( get_option( 'large_size_h' ) ); 2168 2077 2169 if ( ! $large_size_h ) { 2078 2170 $large_size_h = 1024; 2079 2171 } 2172 2080 2173 $large_size_w = absint( get_option( 'large_size_w' ) ); 2174 2081 2175 if ( ! $large_size_w ) { 2082 2176 $large_size_w = 1024; 2083 2177 } 2178 2084 2179 ?> 2085 var resize_height = <?php echo $large_size_h; ?>, resize_width = <?php echo $large_size_w; ?>,2086 wpUploaderInit = <?php echo wp_json_encode( $plupload_init ); ?>;2087 </script>2088 2089 <div id="plupload-upload-ui" class="hide-if-no-js">2180 var resize_height = <?php echo $large_size_h; ?>, resize_width = <?php echo $large_size_w; ?>, 2181 wpUploaderInit = <?php echo wp_json_encode( $plupload_init ); ?>; 2182 </script> 2183 2184 <div id="plupload-upload-ui" class="hide-if-no-js"> 2090 2185 <?php 2091 2186 /** … … 2096 2191 */ 2097 2192 do_action( 'pre-plupload-upload-ui' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores 2193 2098 2194 ?> 2099 <div id="drag-drop-area"> 2100 <div class="drag-drop-inside"> 2101 <p class="drag-drop-info"><?php _e( 'Drop files to upload' ); ?></p> 2102 <p><?php _ex( 'or', 'Uploader: Drop files here - or - Select Files' ); ?></p> 2103 <p class="drag-drop-buttons"><input id="plupload-browse-button" type="button" value="<?php esc_attr_e( 'Select Files' ); ?>" class="button" /></p> 2195 <div id="drag-drop-area"> 2196 <div class="drag-drop-inside"> 2197 <p class="drag-drop-info"><?php _e( 'Drop files to upload' ); ?></p> 2198 <p><?php _ex( 'or', 'Uploader: Drop files here - or - Select Files' ); ?></p> 2199 <p class="drag-drop-buttons"><input id="plupload-browse-button" type="button" value="<?php esc_attr_e( 'Select Files' ); ?>" class="button" /></p> 2200 </div> 2104 2201 </div> 2105 </div>2106 2202 <?php 2107 2203 /** … … 2113 2209 do_action( 'post-plupload-upload-ui' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores 2114 2210 ?> 2115 </div>2116 2117 <div id="html-upload-ui" class="hide-if-js">2211 </div> 2212 2213 <div id="html-upload-ui" class="hide-if-js"> 2118 2214 <?php 2119 2215 /** … … 2123 2219 */ 2124 2220 do_action( 'pre-html-upload-ui' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores 2221 2125 2222 ?> 2126 2223 <p id="async-upload-wrap"> … … 2138 2235 */ 2139 2236 do_action( 'post-html-upload-ui' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores 2237 2140 2238 ?> 2141 </div>2239 </div> 2142 2240 2143 2241 <p class="max-upload-size"> … … 2190 2288 $form_class .= ' html-uploader'; 2191 2289 } 2290 2192 2291 ?> 2193 2194 <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"> 2195 <?php submit_button( '', 'hidden', 'save', false ); ?> 2196 <input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" /> 2197 <?php wp_nonce_field( 'media-form' ); ?> 2198 2199 <h3 class="media-title"><?php _e( 'Add media files from your computer' ); ?></h3> 2292 <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"> 2293 <?php submit_button( '', 'hidden', 'save', false ); ?> 2294 <input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" /> 2295 <?php wp_nonce_field( 'media-form' ); ?> 2296 2297 <h3 class="media-title"><?php _e( 'Add media files from your computer' ); ?></h3> 2200 2298 2201 2299 <?php media_upload_form( $errors ); ?> 2202 2300 2203 <script type="text/javascript">2204 jQuery(function($){2205 var preloaded = $(".media-item.preloaded");2206 if ( preloaded.length > 0 ) {2207 preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');});2208 }2209 updateMediaForm();2210 });2211 </script>2212 <div id="media-items">2301 <script type="text/javascript"> 2302 jQuery(function($){ 2303 var preloaded = $(".media-item.preloaded"); 2304 if ( preloaded.length > 0 ) { 2305 preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');}); 2306 } 2307 updateMediaForm(); 2308 }); 2309 </script> 2310 <div id="media-items"> 2213 2311 <?php 2214 2312 … … 2222 2320 } 2223 2321 } 2322 2224 2323 ?> 2225 </div>2226 2227 <p class="savebutton ml-submit">2228 <?php submit_button( __( 'Save all changes' ), '', 'save', false ); ?>2229 </p>2230 </form>2324 </div> 2325 2326 <p class="savebutton ml-submit"> 2327 <?php submit_button( __( 'Save all changes' ), '', 'save', false ); ?> 2328 </p> 2329 </form> 2231 2330 <?php 2232 2331 } … … 2258 2357 $form_class .= ' html-uploader'; 2259 2358 } 2359 2260 2360 ?> 2261 2262 <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"> 2263 <input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" /> 2264 <?php wp_nonce_field( 'media-form' ); ?> 2265 2266 <h3 class="media-title"><?php _e( 'Insert media from another website' ); ?></h3> 2267 2268 <script type="text/javascript"> 2269 var addExtImage = { 2361 <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"> 2362 <input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" /> 2363 <?php wp_nonce_field( 'media-form' ); ?> 2364 2365 <h3 class="media-title"><?php _e( 'Insert media from another website' ); ?></h3> 2366 2367 <script type="text/javascript"> 2368 var addExtImage = { 2270 2369 2271 2370 width : '', … … 2282 2381 alt = f.alt.value.replace(/'/g, ''').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>'); 2283 2382 2284 <?php 2285 /** This filter is documented in wp-admin/includes/media.php */ 2286 if ( ! apply_filters( 'disable_captions', '' ) ) { 2383 <?php 2384 /** This filter is documented in wp-admin/includes/media.php */ 2385 if ( ! apply_filters( 'disable_captions', '' ) ) { 2386 ?> 2387 if ( f.caption.value ) { 2388 caption = f.caption.value.replace(/\r\n|\r/g, '\n'); 2389 caption = caption.replace(/<[a-zA-Z0-9]+( [^<>]+)?>/g, function(a){ 2390 return a.replace(/[\r\n\t]+/, ' '); 2391 }); 2392 2393 caption = caption.replace(/\s*\n\s*/g, '<br />'); 2394 } 2395 <?php 2396 } 2397 2287 2398 ?> 2288 if ( f.caption.value ) {2289 caption = f.caption.value.replace(/\r\n|\r/g, '\n');2290 caption = caption.replace(/<[a-zA-Z0-9]+( [^<>]+)?>/g, function(a){2291 return a.replace(/[\r\n\t]+/, ' ');2292 });2293 2294 caption = caption.replace(/\s*\n\s*/g, '<br />');2295 }2296 <?php } ?>2297 2298 2399 cls = caption ? '' : ' class="'+t.align+'"'; 2299 2400 … … 2349 2450 t.preloadImg.src = src; 2350 2451 } 2351 }; 2352 2353 jQuery(document).ready( function($) { 2354 $('.media-types input').click( function() { 2355 $('table.describe').toggleClass('not-image', $('#not-image').prop('checked') ); 2452 }; 2453 2454 jQuery(document).ready( function($) { 2455 $('.media-types input').click( function() { 2456 $('table.describe').toggleClass('not-image', $('#not-image').prop('checked') ); 2457 }); 2356 2458 }); 2357 }); 2358 </script> 2359 2360 <div id="media-items"> 2361 <div class="media-item media-blank"> 2459 </script> 2460 2461 <div id="media-items"> 2462 <div class="media-item media-blank"> 2362 2463 <?php 2363 2464 /** … … 2369 2470 */ 2370 2471 echo apply_filters( 'type_url_form_media', wp_media_insert_url_form( $type ) ); 2472 2371 2473 ?> 2372 </div>2373 </div>2374 </form>2474 </div> 2475 </div> 2476 </form> 2375 2477 <?php 2376 2478 } … … 2402 2504 $form_class .= ' html-uploader'; 2403 2505 } 2506 2404 2507 ?> 2405 2406 <script type="text/javascript"> 2407 jQuery(function($){ 2408 var preloaded = $(".media-item.preloaded"); 2409 if ( preloaded.length > 0 ) { 2410 preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');}); 2411 updateMediaForm(); 2412 } 2413 }); 2414 </script> 2415 <div id="sort-buttons" class="hide-if-no-js"> 2416 <span> 2417 <?php _e( 'All Tabs:' ); ?> 2418 <a href="#" id="showall"><?php _e( 'Show' ); ?></a> 2419 <a href="#" id="hideall" style="display:none;"><?php _e( 'Hide' ); ?></a> 2420 </span> 2421 <?php _e( 'Sort Order:' ); ?> 2422 <a href="#" id="asc"><?php _e( 'Ascending' ); ?></a> | 2423 <a href="#" id="desc"><?php _e( 'Descending' ); ?></a> | 2424 <a href="#" id="clear"><?php _ex( 'Clear', 'verb' ); ?></a> 2425 </div> 2426 <form enctype="multipart/form-data" method="post" action="<?php echo esc_url( $form_action_url ); ?>" class="<?php echo $form_class; ?>" id="gallery-form"> 2427 <?php wp_nonce_field( 'media-form' ); ?> 2428 <?php //media_upload_form( $errors ); ?> 2429 <table class="widefat"> 2430 <thead><tr> 2431 <th><?php _e( 'Media' ); ?></th> 2432 <th class="order-head"><?php _e( 'Order' ); ?></th> 2433 <th class="actions-head"><?php _e( 'Actions' ); ?></th> 2434 </tr></thead> 2435 </table> 2436 <div id="media-items"> 2437 <?php add_filter( 'attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2 ); ?> 2438 <?php echo get_media_items( $post_id, $errors ); ?> 2439 </div> 2440 2441 <p class="ml-submit"> 2442 <?php 2443 submit_button( 2444 __( 'Save all changes' ), 2445 'savebutton', 2446 'save', 2447 false, 2448 array( 2449 'id' => 'save-all', 2450 'style' => 'display: none;', 2451 ) 2452 ); 2453 ?> 2454 <input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" /> 2455 <input type="hidden" name="type" value="<?php echo esc_attr( $GLOBALS['type'] ); ?>" /> 2456 <input type="hidden" name="tab" value="<?php echo esc_attr( $GLOBALS['tab'] ); ?>" /> 2457 </p> 2458 2459 <div id="gallery-settings" style="display:none;"> 2460 <div class="title"><?php _e( 'Gallery Settings' ); ?></div> 2461 <table id="basic" class="describe"><tbody> 2462 <tr> 2463 <th scope="row" class="label"> 2464 <label> 2465 <span class="alignleft"><?php _e( 'Link thumbnails to:' ); ?></span> 2466 </label> 2467 </th> 2468 <td class="field"> 2469 <input type="radio" name="linkto" id="linkto-file" value="file" /> 2470 <label for="linkto-file" class="radio"><?php _e( 'Image File' ); ?></label> 2471 2472 <input type="radio" checked="checked" name="linkto" id="linkto-post" value="post" /> 2473 <label for="linkto-post" class="radio"><?php _e( 'Attachment Page' ); ?></label> 2474 </td> 2475 </tr> 2476 2477 <tr> 2478 <th scope="row" class="label"> 2479 <label> 2480 <span class="alignleft"><?php _e( 'Order images by:' ); ?></span> 2481 </label> 2482 </th> 2483 <td class="field"> 2484 <select id="orderby" name="orderby"> 2485 <option value="menu_order" selected="selected"><?php _e( 'Menu order' ); ?></option> 2486 <option value="title"><?php _e( 'Title' ); ?></option> 2487 <option value="post_date"><?php _e( 'Date/Time' ); ?></option> 2488 <option value="rand"><?php _e( 'Random' ); ?></option> 2489 </select> 2490 </td> 2491 </tr> 2492 2493 <tr> 2494 <th scope="row" class="label"> 2495 <label> 2496 <span class="alignleft"><?php _e( 'Order:' ); ?></span> 2497 </label> 2498 </th> 2499 <td class="field"> 2500 <input type="radio" checked="checked" name="order" id="order-asc" value="asc" /> 2501 <label for="order-asc" class="radio"><?php _e( 'Ascending' ); ?></label> 2502 2503 <input type="radio" name="order" id="order-desc" value="desc" /> 2504 <label for="order-desc" class="radio"><?php _e( 'Descending' ); ?></label> 2505 </td> 2506 </tr> 2507 2508 <tr> 2509 <th scope="row" class="label"> 2510 <label> 2511 <span class="alignleft"><?php _e( 'Gallery columns:' ); ?></span> 2512 </label> 2513 </th> 2514 <td class="field"> 2515 <select id="columns" name="columns"> 2516 <option value="1">1</option> 2517 <option value="2">2</option> 2518 <option value="3" selected="selected">3</option> 2519 <option value="4">4</option> 2520 <option value="5">5</option> 2521 <option value="6">6</option> 2522 <option value="7">7</option> 2523 <option value="8">8</option> 2524 <option value="9">9</option> 2525 </select> 2526 </td> 2527 </tr> 2528 </tbody></table> 2529 2530 <p class="ml-submit"> 2531 <input type="button" class="button" style="display:none;" onMouseDown="wpgallery.update();" name="insert-gallery" id="insert-gallery" value="<?php esc_attr_e( 'Insert gallery' ); ?>" /> 2532 <input type="button" class="button" style="display:none;" onMouseDown="wpgallery.update();" name="update-gallery" id="update-gallery" value="<?php esc_attr_e( 'Update gallery settings' ); ?>" /> 2533 </p> 2534 </div> 2535 </form> 2508 <script type="text/javascript"> 2509 jQuery(function($){ 2510 var preloaded = $(".media-item.preloaded"); 2511 if ( preloaded.length > 0 ) { 2512 preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');}); 2513 updateMediaForm(); 2514 } 2515 }); 2516 </script> 2517 <div id="sort-buttons" class="hide-if-no-js"> 2518 <span> 2519 <?php _e( 'All Tabs:' ); ?> 2520 <a href="#" id="showall"><?php _e( 'Show' ); ?></a> 2521 <a href="#" id="hideall" style="display:none;"><?php _e( 'Hide' ); ?></a> 2522 </span> 2523 <?php _e( 'Sort Order:' ); ?> 2524 <a href="#" id="asc"><?php _e( 'Ascending' ); ?></a> | 2525 <a href="#" id="desc"><?php _e( 'Descending' ); ?></a> | 2526 <a href="#" id="clear"><?php _ex( 'Clear', 'verb' ); ?></a> 2527 </div> 2528 <form enctype="multipart/form-data" method="post" action="<?php echo esc_url( $form_action_url ); ?>" class="<?php echo $form_class; ?>" id="gallery-form"> 2529 <?php wp_nonce_field( 'media-form' ); ?> 2530 <?php //media_upload_form( $errors ); ?> 2531 <table class="widefat"> 2532 <thead><tr> 2533 <th><?php _e( 'Media' ); ?></th> 2534 <th class="order-head"><?php _e( 'Order' ); ?></th> 2535 <th class="actions-head"><?php _e( 'Actions' ); ?></th> 2536 </tr></thead> 2537 </table> 2538 <div id="media-items"> 2539 <?php add_filter( 'attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2 ); ?> 2540 <?php echo get_media_items( $post_id, $errors ); ?> 2541 </div> 2542 2543 <p class="ml-submit"> 2544 <?php 2545 submit_button( 2546 __( 'Save all changes' ), 2547 'savebutton', 2548 'save', 2549 false, 2550 array( 2551 'id' => 'save-all', 2552 'style' => 'display: none;', 2553 ) 2554 ); 2555 ?> 2556 <input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" /> 2557 <input type="hidden" name="type" value="<?php echo esc_attr( $GLOBALS['type'] ); ?>" /> 2558 <input type="hidden" name="tab" value="<?php echo esc_attr( $GLOBALS['tab'] ); ?>" /> 2559 </p> 2560 2561 <div id="gallery-settings" style="display:none;"> 2562 <div class="title"><?php _e( 'Gallery Settings' ); ?></div> 2563 <table id="basic" class="describe"><tbody> 2564 <tr> 2565 <th scope="row" class="label"> 2566 <label> 2567 <span class="alignleft"><?php _e( 'Link thumbnails to:' ); ?></span> 2568 </label> 2569 </th> 2570 <td class="field"> 2571 <input type="radio" name="linkto" id="linkto-file" value="file" /> 2572 <label for="linkto-file" class="radio"><?php _e( 'Image File' ); ?></label> 2573 2574 <input type="radio" checked="checked" name="linkto" id="linkto-post" value="post" /> 2575 <label for="linkto-post" class="radio"><?php _e( 'Attachment Page' ); ?></label> 2576 </td> 2577 </tr> 2578 2579 <tr> 2580 <th scope="row" class="label"> 2581 <label> 2582 <span class="alignleft"><?php _e( 'Order images by:' ); ?></span> 2583 </label> 2584 </th> 2585 <td class="field"> 2586 <select id="orderby" name="orderby"> 2587 <option value="menu_order" selected="selected"><?php _e( 'Menu order' ); ?></option> 2588 <option value="title"><?php _e( 'Title' ); ?></option> 2589 <option value="post_date"><?php _e( 'Date/Time' ); ?></option> 2590 <option value="rand"><?php _e( 'Random' ); ?></option> 2591 </select> 2592 </td> 2593 </tr> 2594 2595 <tr> 2596 <th scope="row" class="label"> 2597 <label> 2598 <span class="alignleft"><?php _e( 'Order:' ); ?></span> 2599 </label> 2600 </th> 2601 <td class="field"> 2602 <input type="radio" checked="checked" name="order" id="order-asc" value="asc" /> 2603 <label for="order-asc" class="radio"><?php _e( 'Ascending' ); ?></label> 2604 2605 <input type="radio" name="order" id="order-desc" value="desc" /> 2606 <label for="order-desc" class="radio"><?php _e( 'Descending' ); ?></label> 2607 </td> 2608 </tr> 2609 2610 <tr> 2611 <th scope="row" class="label"> 2612 <label> 2613 <span class="alignleft"><?php _e( 'Gallery columns:' ); ?></span> 2614 </label> 2615 </th> 2616 <td class="field"> 2617 <select id="columns" name="columns"> 2618 <option value="1">1</option> 2619 <option value="2">2</option> 2620 <option value="3" selected="selected">3</option> 2621 <option value="4">4</option> 2622 <option value="5">5</option> 2623 <option value="6">6</option> 2624 <option value="7">7</option> 2625 <option value="8">8</option> 2626 <option value="9">9</option> 2627 </select> 2628 </td> 2629 </tr> 2630 </tbody></table> 2631 2632 <p class="ml-submit"> 2633 <input type="button" class="button" style="display:none;" onMouseDown="wpgallery.update();" name="insert-gallery" id="insert-gallery" value="<?php esc_attr_e( 'Insert gallery' ); ?>" /> 2634 <input type="button" class="button" style="display:none;" onMouseDown="wpgallery.update();" name="update-gallery" id="update-gallery" value="<?php esc_attr_e( 'Update gallery settings' ); ?>" /> 2635 </p> 2636 </div> 2637 </form> 2536 2638 <?php 2537 2639 } … … 2581 2683 2582 2684 ?> 2583 2584 <form id="filter" method="get"> 2585 <input type="hidden" name="type" value="<?php echo esc_attr( $type ); ?>" /> 2586 <input type="hidden" name="tab" value="<?php echo esc_attr( $tab ); ?>" /> 2587 <input type="hidden" name="post_id" value="<?php echo (int) $post_id; ?>" /> 2588 <input type="hidden" name="post_mime_type" value="<?php echo isset( $_GET['post_mime_type'] ) ? esc_attr( $_GET['post_mime_type'] ) : ''; ?>" /> 2589 <input type="hidden" name="context" value="<?php echo isset( $_GET['context'] ) ? esc_attr( $_GET['context'] ) : ''; ?>" /> 2590 2591 <p id="media-search" class="search-box"> 2592 <label class="screen-reader-text" for="media-search-input"><?php _e( 'Search Media' ); ?>:</label> 2593 <input type="search" id="media-search-input" name="s" value="<?php the_search_query(); ?>" /> 2594 <?php submit_button( __( 'Search Media' ), '', '', false ); ?> 2595 </p> 2596 2597 <ul class="subsubsub"> 2598 <?php 2599 $type_links = array(); 2600 $_num_posts = (array) wp_count_attachments(); 2601 $matches = wp_match_mime_types( array_keys( $post_mime_types ), array_keys( $_num_posts ) ); 2602 foreach ( $matches as $_type => $reals ) { 2603 foreach ( $reals as $real ) { 2604 if ( isset( $num_posts[ $_type ] ) ) { 2605 $num_posts[ $_type ] += $_num_posts[ $real ]; 2606 } else { 2607 $num_posts[ $_type ] = $_num_posts[ $real ]; 2608 } 2609 } 2610 } 2611 // If available type specified by media button clicked, filter by that type 2612 if ( empty( $_GET['post_mime_type'] ) && ! empty( $num_posts[ $type ] ) ) { 2613 $_GET['post_mime_type'] = $type; 2614 list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query(); 2615 } 2616 if ( empty( $_GET['post_mime_type'] ) || $_GET['post_mime_type'] == 'all' ) { 2617 $class = ' class="current"'; 2618 } else { 2619 $class = ''; 2620 } 2621 $type_links[] = '<li><a href="' . esc_url( 2622 add_query_arg( 2623 array( 2624 'post_mime_type' => 'all', 2625 'paged' => false, 2626 'm' => false, 2627 ) 2628 ) 2629 ) . '"' . $class . '>' . __( 'All Types' ) . '</a>'; 2630 foreach ( $post_mime_types as $mime_type => $label ) { 2631 $class = ''; 2632 2633 if ( ! wp_match_mime_types( $mime_type, $avail_post_mime_types ) ) { 2634 continue; 2635 } 2636 2637 if ( isset( $_GET['post_mime_type'] ) && wp_match_mime_types( $mime_type, $_GET['post_mime_type'] ) ) { 2685 <form id="filter" method="get"> 2686 <input type="hidden" name="type" value="<?php echo esc_attr( $type ); ?>" /> 2687 <input type="hidden" name="tab" value="<?php echo esc_attr( $tab ); ?>" /> 2688 <input type="hidden" name="post_id" value="<?php echo (int) $post_id; ?>" /> 2689 <input type="hidden" name="post_mime_type" value="<?php echo isset( $_GET['post_mime_type'] ) ? esc_attr( $_GET['post_mime_type'] ) : ''; ?>" /> 2690 <input type="hidden" name="context" value="<?php echo isset( $_GET['context'] ) ? esc_attr( $_GET['context'] ) : ''; ?>" /> 2691 2692 <p id="media-search" class="search-box"> 2693 <label class="screen-reader-text" for="media-search-input"><?php _e( 'Search Media' ); ?>:</label> 2694 <input type="search" id="media-search-input" name="s" value="<?php the_search_query(); ?>" /> 2695 <?php submit_button( __( 'Search Media' ), '', '', false ); ?> 2696 </p> 2697 2698 <ul class="subsubsub"> 2699 <?php 2700 $type_links = array(); 2701 $_num_posts = (array) wp_count_attachments(); 2702 $matches = wp_match_mime_types( array_keys( $post_mime_types ), array_keys( $_num_posts ) ); 2703 foreach ( $matches as $_type => $reals ) { 2704 foreach ( $reals as $real ) { 2705 if ( isset( $num_posts[ $_type ] ) ) { 2706 $num_posts[ $_type ] += $_num_posts[ $real ]; 2707 } else { 2708 $num_posts[ $_type ] = $_num_posts[ $real ]; 2709 } 2710 } 2711 } 2712 // If available type specified by media button clicked, filter by that type 2713 if ( empty( $_GET['post_mime_type'] ) && ! empty( $num_posts[ $type ] ) ) { 2714 $_GET['post_mime_type'] = $type; 2715 list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query(); 2716 } 2717 if ( empty( $_GET['post_mime_type'] ) || $_GET['post_mime_type'] == 'all' ) { 2638 2718 $class = ' class="current"'; 2639 } 2640 2719 } else { 2720 $class = ''; 2721 } 2641 2722 $type_links[] = '<li><a href="' . esc_url( 2642 2723 add_query_arg( 2643 2724 array( 2644 'post_mime_type' => $mime_type,2725 'post_mime_type' => 'all', 2645 2726 'paged' => false, 2727 'm' => false, 2646 2728 ) 2647 2729 ) 2648 ) . '"' . $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>'; 2649 } 2650 /** 2651 * Filters the media upload mime type list items. 2652 * 2653 * Returned values should begin with an `<li>` tag. 2654 * 2655 * @since 3.1.0 2656 * 2657 * @param string[] $type_links An array of list items containing mime type link HTML. 2658 */ 2659 echo implode( ' | </li>', apply_filters( 'media_upload_mime_type_links', $type_links ) ) . '</li>'; 2660 unset( $type_links ); 2661 ?> 2662 </ul> 2663 2664 <div class="tablenav"> 2665 2666 <?php 2667 $page_links = paginate_links( 2668 array( 2669 'base' => add_query_arg( 'paged', '%#%' ), 2670 'format' => '', 2671 'prev_text' => __( '«' ), 2672 'next_text' => __( '»' ), 2673 'total' => ceil( $wp_query->found_posts / 10 ), 2674 'current' => $q['paged'], 2675 ) 2676 ); 2677 2678 if ( $page_links ) { 2679 echo "<div class='tablenav-pages'>$page_links</div>"; 2680 } 2681 ?> 2682 2683 <div class="alignleft actions"> 2684 <?php 2685 2686 $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"; 2687 2688 $arc_result = $wpdb->get_results( $arc_query ); 2689 2690 $month_count = count( $arc_result ); 2691 $selected_month = isset( $_GET['m'] ) ? $_GET['m'] : 0; 2692 2693 if ( $month_count && ! ( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) { 2730 ) . '"' . $class . '>' . __( 'All Types' ) . '</a>'; 2731 foreach ( $post_mime_types as $mime_type => $label ) { 2732 $class = ''; 2733 2734 if ( ! wp_match_mime_types( $mime_type, $avail_post_mime_types ) ) { 2735 continue; 2736 } 2737 2738 if ( isset( $_GET['post_mime_type'] ) && wp_match_mime_types( $mime_type, $_GET['post_mime_type'] ) ) { 2739 $class = ' class="current"'; 2740 } 2741 2742 $type_links[] = '<li><a href="' . esc_url( 2743 add_query_arg( 2744 array( 2745 'post_mime_type' => $mime_type, 2746 'paged' => false, 2747 ) 2748 ) 2749 ) . '"' . $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>'; 2750 } 2751 /** 2752 * Filters the media upload mime type list items. 2753 * 2754 * Returned values should begin with an `<li>` tag. 2755 * 2756 * @since 3.1.0 2757 * 2758 * @param string[] $type_links An array of list items containing mime type link HTML. 2759 */ 2760 echo implode( ' | </li>', apply_filters( 'media_upload_mime_type_links', $type_links ) ) . '</li>'; 2761 unset( $type_links ); 2694 2762 ?> 2695 <select name='m'> 2696 <option<?php selected( $selected_month, 0 ); ?> value='0'><?php _e( 'All dates' ); ?></option> 2763 </ul> 2764 2765 <div class="tablenav"> 2766 2697 2767 <?php 2698 foreach ( $arc_result as $arc_row ) { 2699 if ( $arc_row->yyear == 0 ) { 2700 continue; 2701 } 2702 $arc_row->mmonth = zeroise( $arc_row->mmonth, 2 ); 2703 2704 if ( $arc_row->yyear . $arc_row->mmonth == $selected_month ) { 2705 $default = ' selected="selected"'; 2706 } else { 2707 $default = ''; 2708 } 2709 2710 echo "<option$default value='" . esc_attr( $arc_row->yyear . $arc_row->mmonth ) . "'>"; 2711 echo esc_html( $wp_locale->get_month( $arc_row->mmonth ) . " $arc_row->yyear" ); 2712 echo "</option>\n"; 2768 $page_links = paginate_links( 2769 array( 2770 'base' => add_query_arg( 'paged', '%#%' ), 2771 'format' => '', 2772 'prev_text' => __( '«' ), 2773 'next_text' => __( '»' ), 2774 'total' => ceil( $wp_query->found_posts / 10 ), 2775 'current' => $q['paged'], 2776 ) 2777 ); 2778 2779 if ( $page_links ) { 2780 echo "<div class='tablenav-pages'>$page_links</div>"; 2713 2781 } 2714 2782 ?> 2715 </select> 2716 <?php } ?> 2717 2718 <?php submit_button( __( 'Filter »' ), '', 'post-query-submit', false ); ?> 2719 2720 </div> 2721 2722 <br class="clear" /> 2723 </div> 2724 </form> 2725 2726 <form enctype="multipart/form-data" method="post" action="<?php echo esc_url( $form_action_url ); ?>" class="<?php echo $form_class; ?>" id="library-form"> 2727 2783 2784 <div class="alignleft actions"> 2785 <?php 2786 2787 $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"; 2788 2789 $arc_result = $wpdb->get_results( $arc_query ); 2790 2791 $month_count = count( $arc_result ); 2792 $selected_month = isset( $_GET['m'] ) ? $_GET['m'] : 0; 2793 2794 if ( $month_count && ! ( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) { 2795 ?> 2796 <select name='m'> 2797 <option<?php selected( $selected_month, 0 ); ?> value='0'><?php _e( 'All dates' ); ?></option> 2798 <?php 2799 2800 foreach ( $arc_result as $arc_row ) { 2801 if ( $arc_row->yyear == 0 ) { 2802 continue; 2803 } 2804 2805 $arc_row->mmonth = zeroise( $arc_row->mmonth, 2 ); 2806 2807 if ( $arc_row->yyear . $arc_row->mmonth == $selected_month ) { 2808 $default = ' selected="selected"'; 2809 } else { 2810 $default = ''; 2811 } 2812 2813 echo "<option$default value='" . esc_attr( $arc_row->yyear . $arc_row->mmonth ) . "'>"; 2814 echo esc_html( $wp_locale->get_month( $arc_row->mmonth ) . " $arc_row->yyear" ); 2815 echo "</option>\n"; 2816 } 2817 2818 ?> 2819 </select> 2820 <?php } ?> 2821 2822 <?php submit_button( __( 'Filter »' ), '', 'post-query-submit', false ); ?> 2823 2824 </div> 2825 2826 <br class="clear" /> 2827 </div> 2828 </form> 2829 2830 <form enctype="multipart/form-data" method="post" action="<?php echo esc_url( $form_action_url ); ?>" class="<?php echo $form_class; ?>" id="library-form"> 2728 2831 <?php wp_nonce_field( 'media-form' ); ?> 2729 2832 <?php //media_upload_form( $errors ); ?> 2730 2833 2731 <script type="text/javascript"> 2732 <!-- 2733 jQuery(function($){ 2734 var preloaded = $(".media-item.preloaded"); 2735 if ( preloaded.length > 0 ) { 2736 preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');}); 2737 updateMediaForm(); 2738 } 2739 }); 2740 --> 2741 </script> 2742 2743 <div id="media-items"> 2744 <?php add_filter( 'attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2 ); ?> 2745 <?php echo get_media_items( null, $errors ); ?> 2746 </div> 2747 <p class="ml-submit"> 2748 <?php submit_button( __( 'Save all changes' ), 'savebutton', 'save', false ); ?> 2749 <input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" /> 2750 </p> 2751 </form> 2834 <script type="text/javascript"> 2835 jQuery(function($){ 2836 var preloaded = $(".media-item.preloaded"); 2837 if ( preloaded.length > 0 ) { 2838 preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');}); 2839 updateMediaForm(); 2840 } 2841 }); 2842 </script> 2843 2844 <div id="media-items"> 2845 <?php add_filter( 'attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2 ); ?> 2846 <?php echo get_media_items( null, $errors ); ?> 2847 </div> 2848 <p class="ml-submit"> 2849 <?php submit_button( __( 'Save all changes' ), 'savebutton', 'save', false ); ?> 2850 <input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" /> 2851 </p> 2852 </form> 2752 2853 <?php 2753 2854 } … … 2770 2871 </th> 2771 2872 <td class="field"><textarea id="caption" name="caption"></textarea></td> 2772 </tr> 2773 '; 2873 </tr>'; 2774 2874 } else { 2775 2875 $caption = ''; … … 2777 2877 2778 2878 $default_align = get_option( 'image_default_align' ); 2879 2779 2880 if ( empty( $default_align ) ) { 2780 2881 $default_align = 'none'; … … 2857 2958 </td> 2858 2959 </tr> 2859 </tbody></table> 2860 '; 2861 2960 </tbody></table>'; 2862 2961 } 2863 2962 … … 2927 3026 $end = '</a>'; 2928 3027 } 3028 2929 3029 ?> 2930 <p class="hide-if-no-js"><label>2931 <input name="image_resize" type="checkbox" id="image_resize" value="true"<?php echo $checked; ?> />3030 <p class="hide-if-no-js"><label> 3031 <input name="image_resize" type="checkbox" id="image_resize" value="true"<?php echo $checked; ?> /> 2932 3032 <?php 2933 3033 /* translators: 1: Link start tag, 2: Link end tag, 3: Width, 4: Height. */ 2934 3034 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' ) ); 3035 2935 3036 ?> 2936 </label></p>3037 </label></p> 2937 3038 <?php 2938 3039 } … … 2960 3061 function edit_form_image_editor( $post ) { 2961 3062 $open = isset( $_GET['image-editor'] ); 3063 2962 3064 if ( $open ) { 2963 3065 require_once ABSPATH . 'wp-admin/includes/image-edit.php'; … … 2966 3068 $thumb_url = false; 2967 3069 $attachment_id = intval( $post->ID ); 3070 2968 3071 if ( $attachment_id ) { 2969 3072 $thumb_url = wp_get_attachment_image_src( $attachment_id, array( 900, 450 ), true ); … … 2976 3079 <div class="wp_attachment_holder wp-clearfix"> 2977 3080 <?php 3081 2978 3082 if ( wp_attachment_is_image( $post->ID ) ) : 2979 3083 $image_edit_button = ''; … … 2985 3089 $open_style = ''; 2986 3090 $not_open_style = ''; 3091 2987 3092 if ( $open ) { 2988 3093 $open_style = ' style="display:none"'; … … 2990 3095 $not_open_style = ' style="display:none"'; 2991 3096 } 3097 2992 3098 ?> 2993 2994 3099 <div class="imgedit-response" id="imgedit-response-<?php echo $attachment_id; ?>"></div> 2995 3100 … … 2999 3104 </div> 3000 3105 <div<?php echo $not_open_style; ?> class="image-editor" id="image-editor-<?php echo $attachment_id; ?>"> 3001 <?php 3002 if ( $open ) { 3003 wp_image_editor( $attachment_id );} 3004 ?> 3106 <?php 3107 3108 if ( $open ) { 3109 wp_image_editor( $attachment_id ); 3110 } 3111 3112 ?> 3005 3113 </div> 3006 3114 <?php … … 3018 3126 $w = ! empty( $meta['width'] ) ? min( $meta['width'], 640 ) : 0; 3019 3127 $h = ! empty( $meta['height'] ) ? $meta['height'] : 0; 3128 3020 3129 if ( $h && $w < $meta['width'] ) { 3021 3130 $h = round( ( $meta['height'] * $w ) / $meta['width'] ); … … 3023 3132 3024 3133 $attr = array( 'src' => $att_url ); 3134 3025 3135 if ( ! empty( $w ) && ! empty( $h ) ) { 3026 3136 $attr['width'] = $w; … … 3029 3139 3030 3140 $thumb_id = get_post_thumbnail_id( $attachment_id ); 3141 3031 3142 if ( ! empty( $thumb_id ) ) { 3032 3143 $attr['poster'] = wp_get_attachment_url( $thumb_id ); … … 3036 3147 3037 3148 elseif ( isset( $thumb_url[0] ) ) : 3038 3039 3149 ?> 3040 3150 <div class="wp_attachment_image wp-clearfix" id="media-head-<?php echo $attachment_id; ?>"> … … 3057 3167 3058 3168 endif; 3169 3059 3170 ?> 3060 3171 </div> … … 3066 3177 </p> 3067 3178 <p class="attachment-alt-text-description" id="alt-text-description"> 3068 <?php 3069 printf( 3070 /* translators: 1: Link to tutorial, 2: Additional link attributes, 3: Accessibility text. */ 3071 __( '<a href="%1$s" %2$s>Describe the purpose of the image%3$s</a>. Leave empty if the image is purely decorative.' ), 3072 esc_url( 'https://www.w3.org/WAI/tutorials/images/decision-tree' ), 3073 'target="_blank" rel="noopener noreferrer"', 3074 sprintf( 3075 '<span class="screen-reader-text"> %s</span>', 3076 /* translators: Accessibility text. */ 3077 __( '(opens in a new tab)' ) 3078 ) 3079 ); 3080 ?> 3179 <?php 3180 3181 printf( 3182 /* translators: 1: Link to tutorial, 2: Additional link attributes, 3: Accessibility text. */ 3183 __( '<a href="%1$s" %2$s>Describe the purpose of the image%3$s</a>. Leave empty if the image is purely decorative.' ), 3184 esc_url( 'https://www.w3.org/WAI/tutorials/images/decision-tree' ), 3185 'target="_blank" rel="noopener noreferrer"', 3186 sprintf( 3187 '<span class="screen-reader-text"> %s</span>', 3188 /* translators: Accessibility text. */ 3189 __( '(opens in a new tab)' ) 3190 ) 3191 ); 3192 3193 ?> 3081 3194 </p> 3082 3195 <?php endif; ?> … … 3088 3201 3089 3202 <?php 3090 $quicktags_settings = array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close' ); 3091 $editor_args = array( 3092 'textarea_name' => 'content', 3093 'textarea_rows' => 5, 3094 'media_buttons' => false, 3095 'tinymce' => false, 3096 'quicktags' => $quicktags_settings, 3097 ); 3203 3204 $quicktags_settings = array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close' ); 3205 $editor_args = array( 3206 'textarea_name' => 'content', 3207 'textarea_rows' => 5, 3208 'media_buttons' => false, 3209 'tinymce' => false, 3210 'quicktags' => $quicktags_settings, 3211 ); 3212 3098 3213 ?> 3099 3214 3100 3215 <label for="attachment_content"><strong><?php _e( 'Description' ); ?></strong> 3101 <?php 3102 if ( preg_match( '#^(audio|video)/#', $post->post_mime_type ) ) { 3103 echo ': ' . __( 'Displayed on attachment pages.' ); 3104 } 3105 ?> 3216 <?php 3217 3218 if ( preg_match( '#^(audio|video)/#', $post->post_mime_type ) ) { 3219 echo ': ' . __( 'Displayed on attachment pages.' ); 3220 } 3221 3222 ?> 3106 3223 </label> 3107 3224 <?php wp_editor( $post->post_content, 'attachment_content', $editor_args ); ?> … … 3109 3226 </div> 3110 3227 <?php 3228 3111 3229 $extras = get_compat_media_markup( $post->ID ); 3112 3230 echo $extras['item']; … … 3120 3238 */ 3121 3239 function attachment_submitbox_metadata() { 3122 $post = get_post(); 3123 3124 $file = get_attached_file( $post->ID ); 3240 $post = get_post(); 3241 $attachment_id = $post->ID; 3242 3243 $file = get_attached_file( $attachment_id ); 3125 3244 $filename = esc_html( wp_basename( $file ) ); 3126 3245 3127 3246 $media_dims = ''; 3128 $meta = wp_get_attachment_metadata( $post->ID ); 3247 $meta = wp_get_attachment_metadata( $attachment_id ); 3248 3129 3249 if ( isset( $meta['width'], $meta['height'] ) ) { 3130 $media_dims .= "<span id='media-dims-$ post->ID'>{$meta['width']} × {$meta['height']}</span> ";3250 $media_dims .= "<span id='media-dims-$attachment_id'>{$meta['width']} × {$meta['height']}</span> "; 3131 3251 } 3132 3252 /** This filter is documented in wp-admin/includes/media.php */ 3133 3253 $media_dims = apply_filters( 'media_meta', $media_dims, $post ); 3134 3254 3135 $att_url = wp_get_attachment_url( $post->ID ); 3255 $att_url = wp_get_attachment_url( $attachment_id ); 3256 3136 3257 ?> 3137 3258 <div class="misc-pub-section misc-pub-attachment"> … … 3143 3264 </div> 3144 3265 <div class="misc-pub-section misc-pub-filetype"> 3145 <?php _e( 'File type:' ); ?> <strong> 3146 <?php 3147 if ( preg_match( '/^.*?\.(\w+)$/', get_attached_file( $post->ID ), $matches ) ) { 3148 echo esc_html( strtoupper( $matches[1] ) ); 3149 list( $mime_type ) = explode( '/', $post->post_mime_type ); 3150 if ( $mime_type !== 'image' && ! empty( $meta['mime_type'] ) ) { 3151 if ( $meta['mime_type'] !== "$mime_type/" . strtolower( $matches[1] ) ) { 3152 echo ' (' . $meta['mime_type'] . ')'; 3153 } 3154 } 3155 } else { 3156 echo strtoupper( str_replace( 'image/', '', $post->post_mime_type ) ); 3157 } 3158 ?> 3266 <?php _e( 'File type:' ); ?> 3267 <strong> 3268 <?php 3269 3270 if ( preg_match( '/^.*?\.(\w+)$/', get_attached_file( $post->ID ), $matches ) ) { 3271 echo esc_html( strtoupper( $matches[1] ) ); 3272 list( $mime_type ) = explode( '/', $post->post_mime_type ); 3273 if ( $mime_type !== 'image' && ! empty( $meta['mime_type'] ) ) { 3274 if ( $meta['mime_type'] !== "$mime_type/" . strtolower( $matches[1] ) ) { 3275 echo ' (' . $meta['mime_type'] . ')'; 3276 } 3277 } 3278 } else { 3279 echo strtoupper( str_replace( 'image/', '', $post->post_mime_type ) ); 3280 } 3281 3282 ?> 3159 3283 </strong> 3160 3284 </div> 3161 3285 3162 3286 <?php 3163 $file_size = false; 3287 3288 $file_size = false; 3164 3289 3165 3290 if ( isset( $meta['filesize'] ) ) { … … 3169 3294 } 3170 3295 3171 if ( ! empty( $file_size ) ) :3296 if ( ! empty( $file_size ) ) { 3172 3297 ?> 3173 <div class="misc-pub-section misc-pub-filesize">3174 <?php _e( 'File size:' ); ?> <strong><?php echo size_format( $file_size ); ?></strong>3175 </div>3176 <?php3177 endif;3298 <div class="misc-pub-section misc-pub-filesize"> 3299 <?php _e( 'File size:' ); ?> <strong><?php echo size_format( $file_size ); ?></strong> 3300 </div> 3301 <?php 3302 } 3178 3303 3179 3304 if ( preg_match( '#^(audio|video)/#', $post->post_mime_type ) ) { … … 3201 3326 continue; 3202 3327 } 3328 3203 3329 ?> 3204 <div class="misc-pub-section misc-pub-mime-meta misc-pub-<?php echo sanitize_html_class( $key ); ?>"> 3205 <?php echo $label; ?> <strong> 3206 <?php 3207 switch ( $key ) { 3208 case 'bitrate': 3209 echo round( $meta['bitrate'] / 1000 ) . 'kb/s'; 3210 if ( ! empty( $meta['bitrate_mode'] ) ) { 3211 echo ' ' . strtoupper( esc_html( $meta['bitrate_mode'] ) ); 3212 } 3213 break; 3214 default: 3215 echo esc_html( $meta[ $key ] ); 3216 break; 3330 <div class="misc-pub-section misc-pub-mime-meta misc-pub-<?php echo sanitize_html_class( $key ); ?>"> 3331 <?php echo $label; ?> 3332 <strong> 3333 <?php 3334 3335 switch ( $key ) { 3336 case 'bitrate': 3337 echo round( $meta['bitrate'] / 1000 ) . 'kb/s'; 3338 if ( ! empty( $meta['bitrate_mode'] ) ) { 3339 echo ' ' . strtoupper( esc_html( $meta['bitrate_mode'] ) ); 3217 3340 } 3218 ?> 3219 </strong> 3220 </div> 3341 break; 3342 default: 3343 echo esc_html( $meta[ $key ] ); 3344 break; 3345 } 3346 3347 ?> 3348 </strong> 3349 </div> 3221 3350 <?php 3222 3351 } … … 3245 3374 continue; 3246 3375 } 3376 3247 3377 ?> 3248 <div class="misc-pub-section misc-pub-audio misc-pub-<?php echo sanitize_html_class( $key ); ?>"> 3249 <?php echo $label; ?> <strong><?php echo esc_html( $meta['audio'][ $key ] ); ?></strong> 3378 <div class="misc-pub-section misc-pub-audio misc-pub-<?php echo sanitize_html_class( $key ); ?>"> 3379 <?php echo $label; ?> <strong><?php echo esc_html( $meta['audio'][ $key ] ); ?></strong> 3380 </div> 3381 <?php 3382 } 3383 } 3384 3385 if ( $media_dims ) { 3386 ?> 3387 <div class="misc-pub-section misc-pub-dimensions"> 3388 <?php _e( 'Dimensions:' ); ?> <strong><?php echo $media_dims; ?></strong> 3250 3389 </div> 3251 <?php3252 }3253 }3254 3255 if ( $media_dims ) :3256 ?>3257 <div class="misc-pub-section misc-pub-dimensions">3258 <?php _e( 'Dimensions:' ); ?> <strong><?php echo $media_dims; ?></strong>3259 </div>3260 3390 <?php 3261 endif;3391 } 3262 3392 } 3263 3393 … … 3329 3459 require( ABSPATH . WPINC . '/ID3/getid3.php' ); 3330 3460 } 3461 3331 3462 $id3 = new getID3(); 3332 3463 $data = $id3->analyze( $file ); … … 3335 3466 $metadata['lossless'] = $data['video']['lossless']; 3336 3467 } 3468 3337 3469 if ( ! empty( $data['video']['bitrate'] ) ) { 3338 3470 $metadata['bitrate'] = (int) $data['video']['bitrate']; 3339 3471 } 3472 3340 3473 if ( ! empty( $data['video']['bitrate_mode'] ) ) { 3341 3474 $metadata['bitrate_mode'] = $data['video']['bitrate_mode']; 3342 3475 } 3476 3343 3477 if ( ! empty( $data['filesize'] ) ) { 3344 3478 $metadata['filesize'] = (int) $data['filesize']; 3345 3479 } 3480 3346 3481 if ( ! empty( $data['mime_type'] ) ) { 3347 3482 $metadata['mime_type'] = $data['mime_type']; 3348 3483 } 3484 3349 3485 if ( ! empty( $data['playtime_seconds'] ) ) { 3350 3486 $metadata['length'] = (int) round( $data['playtime_seconds'] ); 3351 3487 } 3488 3352 3489 if ( ! empty( $data['playtime_string'] ) ) { 3353 3490 $metadata['length_formatted'] = $data['playtime_string']; 3354 3491 } 3492 3355 3493 if ( ! empty( $data['video']['resolution_x'] ) ) { 3356 3494 $metadata['width'] = (int) $data['video']['resolution_x']; 3357 3495 } 3496 3358 3497 if ( ! empty( $data['video']['resolution_y'] ) ) { 3359 3498 $metadata['height'] = (int) $data['video']['resolution_y']; 3360 3499 } 3500 3361 3501 if ( ! empty( $data['fileformat'] ) ) { 3362 3502 $metadata['fileformat'] = $data['fileformat']; 3363 3503 } 3504 3364 3505 if ( ! empty( $data['video']['dataformat'] ) ) { 3365 3506 $metadata['dataformat'] = $data['video']['dataformat']; 3366 3507 } 3508 3367 3509 if ( ! empty( $data['video']['encoder'] ) ) { 3368 3510 $metadata['encoder'] = $data['video']['encoder']; 3369 3511 } 3512 3370 3513 if ( ! empty( $data['video']['codec'] ) ) { 3371 3514 $metadata['codec'] = $data['video']['codec']; … … 3417 3560 return false; 3418 3561 } 3562 3419 3563 $metadata = array(); 3420 3564 … … 3426 3570 require( ABSPATH . WPINC . '/ID3/getid3.php' ); 3427 3571 } 3572 3428 3573 $id3 = new getID3(); 3429 3574 $data = $id3->analyze( $file ); … … 3437 3582 $metadata['fileformat'] = $data['fileformat']; 3438 3583 } 3584 3439 3585 if ( ! empty( $data['filesize'] ) ) { 3440 3586 $metadata['filesize'] = (int) $data['filesize']; 3441 3587 } 3588 3442 3589 if ( ! empty( $data['mime_type'] ) ) { 3443 3590 $metadata['mime_type'] = $data['mime_type']; 3444 3591 } 3592 3445 3593 if ( ! empty( $data['playtime_seconds'] ) ) { 3446 3594 $metadata['length'] = (int) round( $data['playtime_seconds'] ); 3447 3595 } 3596 3448 3597 if ( ! empty( $data['playtime_string'] ) ) { 3449 3598 $metadata['length_formatted'] = $data['playtime_string']; … … 3532 3681 wp_die( __( 'Sorry, you are not allowed to edit this post.' ) ); 3533 3682 } 3683 3534 3684 $ids = array(); 3685 3535 3686 foreach ( (array) $_REQUEST['media'] as $att_id ) { 3536 3687 $att_id = (int) $att_id; … … 3545 3696 if ( ! empty( $ids ) ) { 3546 3697 $ids_string = implode( ',', $ids ); 3698 3547 3699 if ( 'attach' === $action ) { 3548 3700 $result = $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET post_parent = %d WHERE post_type = 'attachment' AND ID IN ( $ids_string )", $parent_id ) ); … … 3559 3711 $location = 'upload.php'; 3560 3712 $referer = wp_get_referer(); 3713 3561 3714 if ( $referer ) { 3562 3715 if ( false !== strpos( $referer, 'upload.php' ) ) { … … 3567 3720 $key = 'attach' === $action ? 'attached' : 'detach'; 3568 3721 $location = add_query_arg( array( $key => $result ), $location ); 3722 3569 3723 wp_redirect( $location ); 3570 3724 exit;
Note: See TracChangeset
for help on using the changeset viewer.