Ticket #25375: 25375.diff
| File 25375.diff, 16.4 KB (added by , 12 years ago) |
|---|
-
src/wp-admin/includes/media.php
21 21 'library' => __('Media Library') 22 22 ); 23 23 24 return apply_filters('media_upload_tabs', $_default_tabs); 24 /** 25 * Filter the available tabs in the legacy (pre-3.5) media popup. 26 * 27 * @since Unknown 28 * 29 * @param array $_default_tabs An array of media tabs in the form of key/value pairs. 30 */ 31 return apply_filters( 'media_upload_tabs', $_default_tabs ); 25 32 } 26 33 27 34 /** … … 68 75 69 76 if ( !empty($tabs) ) { 70 77 echo "<ul id='sidemenu'>\n"; 71 if ( isset($redir_tab) && array_key_exists($redir_tab, $tabs) ) 78 if ( isset($redir_tab) && array_key_exists($redir_tab, $tabs) ) {} 72 79 $current = $redir_tab; 73 80 elseif ( isset($_GET['tab']) && array_key_exists($_GET['tab'], $tabs) ) 74 81 $current = $_GET['tab']; 75 82 else 76 $current = apply_filters('media_upload_default_tab', $default); 83 /** 84 * Filter the default tab in the legacy (pre-3.5) media popup. 85 * 86 * @since Unknown 87 */ 88 $current = apply_filters( 'media_upload_default_tab', $default ); 77 89 78 90 foreach ( $tabs as $callback => $text ) { 79 91 $class = ''; … … 113 125 if ( $url ) 114 126 $html = '<a href="' . esc_attr($url) . "\"$rel>$html</a>"; 115 127 128 /** 129 * Filter the image HTML markup to send to the editor. 130 * 131 * @since Unknown 132 * 133 * @param string $html The image HTML markup to send. 134 * @param int $id The attachment id. 135 * @param string $caption The image caption. 136 * @param string $title The image title. 137 * @param string $align The image alignment. 138 * @param string $url The image source URL. 139 * @param string $size The image size. 140 * @param string $alt The image alternative, or alt, text. 141 */ 116 142 $html = apply_filters( 'image_send_to_editor', $html, $id, $caption, $title, $align, $url, $size, $alt ); 117 143 118 144 return $html; … … 135 161 */ 136 162 function image_add_caption( $html, $id, $caption, $title, $align, $url, $size, $alt = '' ) { 137 163 164 /** 165 * Filter whether to disable captions. 166 * 167 * Prevents image captions from being appended to image HTML when inserted into the editor. 168 * 169 * @since Unknown 170 * 171 * @param bool Whether to disable appending captions. Returning true to the filter will 172 * disable captions. Default empty string. 173 */ 138 174 if ( empty($caption) || apply_filters( 'disable_captions', '' ) ) 139 175 return $html; 140 176 … … 156 192 157 193 $shcode = '[caption id="' . $id . '" align="align' . $align . '" width="' . $width . '"]' . $html . ' ' . $caption . '[/caption]'; 158 194 195 /** 196 * Filter the image HTML markup including the caption shortcode. 197 * 198 * @since Unknown 199 * 200 * @param string $shcode The image HTML markup with caption shortcode. 201 * @param string $html The image HTML markup. 202 */ 159 203 return apply_filters( 'image_add_caption_shortcode', $shcode, $html ); 160 204 } 161 205 add_filter( 'image_send_to_editor', 'image_add_caption', 20, 8 ); … … 397 441 //]]> 398 442 </script> 399 443 <?php 400 do_action('admin_enqueue_scripts', 'media-upload-popup'); 401 do_action('admin_print_styles-media-upload-popup'); 402 do_action('admin_print_styles'); 403 do_action('admin_print_scripts-media-upload-popup'); 404 do_action('admin_print_scripts'); 405 do_action('admin_head-media-upload-popup'); 406 do_action('admin_head'); 444 /** 445 * Prints scripts enqueued for the admin for the legacy media upload popup. 446 * 447 * @since Unknown 448 * @since 3.5.0 449 * 450 * @param Unknown 451 */ 452 do_action( 'admin_enqueue_scripts', 'media-upload-popup' ); 407 453 454 /** 455 * Prints styles enqueued for the legacy media uplaod popup. 456 * 457 * @since Unknown 458 * @since 3.5.0 459 */ 460 do_action( 'admin_print_styles-media-upload-popup' ); 461 462 /** 463 * Prints styles enqueued for the admin. 464 * 465 * @since Unknown 466 */ 467 do_action( 'admin_print_styles' ); 468 469 /** 470 * Prints scripts enqueued for the legacy media upload popup. 471 * 472 * @since Unknown 473 * @since 3.5.0 474 */ 475 do_action( 'admin_print_scripts-media-upload-popup' ); 476 477 /** 478 * Prints scripts enqueued for the admin. 479 */ 480 do_action( 'admin_print_scripts' ); 481 482 /** 483 * Prints scripts enqueued for the admin header for the legacy media upload popup. 484 * 485 * @since Unknown 486 * @since 3.5.0 487 */ 488 do_action( 'admin_head-media-upload-popup' ); 489 490 /** 491 * Fires in the admin header. 492 * 493 * @since Unknown 494 */ 495 do_action( 'admin_head' ); 496 408 497 if ( is_string($content_func) ) 409 do_action( "admin_head_{$content_func}" ); 498 /** 499 * Fires in the admin header for specific media upload type forms. 500 * 501 * Part of the legacy (pre-3.5) media upload popup. 502 * 503 * The dynamic portion of the hook, $content_func, refers 504 * to the media upload type form callback. 505 * 506 * @since Unknown 507 */ 508 do_action( "admin_head_{$content_func}" ); 410 509 ?> 411 510 </head> 412 511 <body<?php if ( isset($GLOBALS['body_id']) ) echo ' id="' . $GLOBALS['body_id'] . '"'; ?> class="wp-core-ui no-js"> … … 418 517 $args = array_slice($args, 1); 419 518 call_user_func_array($content_func, $args); 420 519 520 /** 521 * Prints scripts enqueued for the admin footer. 522 * 523 * @since Unknown 524 */ 421 525 do_action('admin_print_footer_scripts'); 422 526 ?> 423 527 <script type="text/javascript">if(typeof wpOnload=='function')wpOnload();</script> … … 446 550 447 551 echo '<a href="#" id="insert-media-button" class="button insert-media add_media" data-editor="' . esc_attr( $editor_id ) . '" title="' . esc_attr__( 'Add Media' ) . '">' . $img . __( 'Add Media' ) . '</a>'; 448 552 449 // Don't use this filter. Want to add a button? Use the media_buttons action. 553 /** 554 * Filter legacy media buttons (deprecated). 555 * 556 * Don't use this filter. Want to add a button? Use the 'media_buttons' action. 557 * 558 * @since Unknown 559 * @deprecated Unknown 560 * 561 * @param string Media buttons context. 562 */ 450 563 $legacy_filter = apply_filters('media_buttons_context', ''); // deprecated 451 564 452 565 if ( $legacy_filter ) { … … 472 585 if ( ! empty( $tab ) ) 473 586 $upload_iframe_src = add_query_arg('tab', $tab, $upload_iframe_src); 474 587 588 /** 589 * Filter the upload iframe source URL by media type. 590 * 591 * The dynamic portion of the hook name, $type, refers to the type of media uploaded. 592 * 593 * @since Unknown 594 * 595 * @param string $upload_iframe_src The upload irame source URL by type. 596 */ 475 597 $upload_iframe_src = apply_filters($type . '_upload_iframe_src', $upload_iframe_src); 476 598 477 599 return add_query_arg('TB_iframe', true, $upload_iframe_src); … … 514 636 $post['post_parent'] = $attachment['post_parent']; 515 637 } 516 638 639 /** 640 * Filter attachment fields to be saved. 641 * 642 * @since Unknown 643 * 644 * @param WP_Post $post The WP_Post object. 645 * @param array $attachment An array of attachment metadata. 646 */ 517 647 $post = apply_filters('attachment_fields_to_save', $post, $attachment); 518 648 519 649 if ( isset($attachment['image_alt']) ) { … … 561 691 $html = "<a href='{$attachment['url']}'$rel>$html</a>"; 562 692 } 563 693 694 /** 695 * Filter the media HTML markup sent to the editor. 696 * 697 * @since Unknown 698 * 699 * @param string $html The media's HTML markup sent to the editor. 700 * @param int $send_id The first key from the $_POST['send'] data. 701 * @param array $attachment The attachment metadata. 702 */ 564 703 $html = apply_filters('media_send_to_editor', $html, $send_id, $attachment); 565 704 return media_send_to_editor($html); 566 705 } … … 608 747 && ( 'audio' == $ext_type || 'video' == $ext_type ) ) 609 748 $type = $ext_type; 610 749 750 /** 751 * Filter the media URL sent to the editor by type. 752 * 753 * The dynamic portion of the hook name, $type, refers to the type of media being sent. 754 * 755 * @since Unknown 756 * 757 * @param string $html The HTML markup sent to the editor. 758 * @param string $src The media source URL. 759 * @param string $title The media title. 760 */ 611 761 $html = apply_filters( $type . '_send_to_editor_url', $html, esc_url_raw( $src ), $title ); 612 762 } else { 613 763 $align = ''; … … 779 929 function image_size_input_fields( $post, $check = '' ) { 780 930 781 931 // get a list of the actual pixel dimensions of each possible intermediate version of this image 782 $size_names = apply_filters( 'image_size_names_choose', array('thumbnail' => __('Thumbnail'), 'medium' => __('Medium'), 'large' => __('Large'), 'full' => __('Full Size')) ); 932 $size_names = array( 933 'thumbnail' => __( 'Thumbnail' ), 934 'medium' => __( 'Medium' ), 935 'large' => __( 'Large' ), 936 'full' => __( 'Full Size' ) 937 ); 783 938 939 /** 940 * Filter the names of the default image sizes. 941 * 942 * @since Unknown 943 * 944 * @param array $size_names An array of image sizes and their names. 945 */ 946 $size_names = apply_filters( 'image_size_names_choose', $size_names ); 947 784 948 if ( empty($check) ) 785 949 $check = get_user_setting('imgsize', 'medium'); 786 950 … … 1061 1225 unset( $form_fields['image_alt'] ); 1062 1226 } 1063 1227 1228 /** 1229 * Filter the attachment fields to edit. 1230 * 1231 * @since Unknown 1232 * 1233 * @param array $form_fields An array of attachment form fields. 1234 * @param WP_Post $post The WP_Post attachment object. 1235 */ 1064 1236 $form_fields = apply_filters('attachment_fields_to_edit', $form_fields, $post); 1065 1237 1066 1238 return $form_fields; … … 1126 1298 1127 1299 $default_args = array( 'errors' => null, 'send' => $current_post_id ? post_type_supports( get_post_type( $current_post_id ), 'editor' ) : true, 'delete' => true, 'toggle' => true, 'show_title' => true ); 1128 1300 $args = wp_parse_args( $args, $default_args ); 1301 1302 /** 1303 * Filter the arguments used to get an image for the edit image form. 1304 * 1305 * @since Unknown 1306 * 1307 * @param array $args An array of arguments. @see get_media_item() 1308 */ 1129 1309 $args = apply_filters( 'get_media_item_args', $args ); 1130 1310 extract( $args, EXTR_SKIP ); 1131 1311 … … 1180 1360 $meta = wp_get_attachment_metadata( $post->ID ); 1181 1361 if ( isset( $meta['width'], $meta['height'] ) ) 1182 1362 $media_dims .= "<span id='media-dims-$post->ID'>{$meta['width']} × {$meta['height']}</span> "; 1363 1364 /** 1365 * Filter the media metadata. 1366 * 1367 * @since Unknown 1368 * 1369 * @param string $media_dims The HTML markup containing the media dimensions. 1370 * @param WP_Post $post The WP_Post attachment object. 1371 */ 1183 1372 $media_dims = apply_filters( 'media_meta', $media_dims, $post ); 1184 1373 1185 1374 $image_edit_button = ''; … … 1343 1532 $user_can_edit = current_user_can( 'edit_post', $attachment_id ); 1344 1533 1345 1534 $args = wp_parse_args( $args, $default_args ); 1535 1536 //duplicate_hook 1346 1537 $args = apply_filters( 'get_media_item_args', $args ); 1347 1538 1348 1539 $form_fields = array(); … … 1382 1573 $form_fields['post_title'], $form_fields['post_excerpt'], $form_fields['post_content'], 1383 1574 $form_fields['url'], $form_fields['menu_order'], $form_fields['image_url'] ); 1384 1575 1576 //duplicate_hook 1385 1577 $media_meta = apply_filters( 'media_meta', '', $post ); 1386 1578 1387 1579 $defaults = array( … … 1545 1737 return; 1546 1738 } 1547 1739 1548 do_action('pre-upload-ui'); 1740 /** 1741 * Fires just before the legacy (pre-3.5) upload interface is loaded. 1742 * 1743 * @since Unknown 1744 */ 1745 do_action( 'pre-upload-ui' ); 1549 1746 1550 1747 $post_params = array( 1551 1748 "post_id" => $post_id, … … 1555 1752 "short" => "1", 1556 1753 ); 1557 1754 1558 $post_params = apply_filters( 'upload_post_params', $post_params ); // hook change! old name: 'swfupload_post_params' 1755 /** 1756 * Filter the media upload post parameters. 1757 * 1758 * Previously 'swfupload_post_params'. 1759 * 1760 * @since Unknown 1761 * @since 3.5.0 1762 * 1763 * @param array $post_params An array of media upload parameters used by Plupload. 1764 */ 1765 $post_params = apply_filters( 'upload_post_params', $post_params ); 1559 1766 1560 1767 $plupload_init = array( 1561 1768 'runtimes' => 'html5,silverlight,flash,html4', … … 1579 1786 if ( wp_is_mobile() ) 1580 1787 $plupload_init['multi_selection'] = false; 1581 1788 1789 /** 1790 * Filter the default Plupload settings. 1791 * 1792 * @since Unknown 1793 * 1794 * @param array $plupload_init An array of default settings used by Plupload. 1795 */ 1582 1796 $plupload_init = apply_filters( 'plupload_init', $plupload_init ); 1583 1797 1584 1798 ?> … … 1606 1820 <p class="drag-drop-buttons"><input id="plupload-browse-button" type="button" value="<?php esc_attr_e('Select Files'); ?>" class="button" /></p> 1607 1821 </div> 1608 1822 </div> 1609 <?php do_action('post-plupload-upload-ui'); // hook change, old name: 'post-flash-upload-ui' ?> 1823 <?php 1824 /** 1825 * Fires below the upload interface. 1826 * 1827 * Previously named 'post-flash-upload-ui'. 1828 * 1829 * @since Unknown 1830 * @since 3.5.0 1831 */ 1832 do_action( 'post-plupload-upload-ui' ); ?> 1610 1833 </div> 1611 1834 1612 1835 <div id="html-upload-ui" class="hide-if-js"> … … 1627 1850 <span class="big-file-warning"><?php _e('Your browser has some limitations uploading large files with the multi-file uploader. Please use the browser uploader for files over 100MB.'); ?></span> 1628 1851 <?php } 1629 1852 1630 do_action('post-upload-ui'); 1853 /** 1854 * Fires on the post upload UI screen. 1855 * 1856 * Legacy (pre-3.5) media workflow hook. 1857 * 1858 * @since Unknown 1859 * @since 3.5.0 1860 */ 1861 do_action( 'post-upload-ui' ); 1631 1862 } 1632 1863 1633 1864 /** … … 1646 1877 $post_id = isset( $_REQUEST['post_id'] )? intval( $_REQUEST['post_id'] ) : 0; 1647 1878 1648 1879 $form_action_url = admin_url("media-upload.php?type=$type&tab=type&post_id=$post_id"); 1880 1881 /** 1882 * Filter the media upload form action URL. 1883 * 1884 * @since Unknown 1885 * 1886 * @param string $form_action_url The media upload form action URL. 1887 * @param string $type The type of media. Default 'file'. 1888 */ 1649 1889 $form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type); 1650 1890 $form_class = 'media-upload-form type-form validate'; 1651 1891 … … 1711 1951 $post_id = isset( $_REQUEST['post_id'] ) ? intval( $_REQUEST['post_id'] ) : 0; 1712 1952 1713 1953 $form_action_url = admin_url("media-upload.php?type=$type&tab=type&post_id=$post_id"); 1954 //duplicate_hook 1714 1955 $form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type); 1715 1956 $form_class = 'media-upload-form type-form validate'; 1716 1957 … … 1741 1982 if ( f.alt.value ) 1742 1983 alt = f.alt.value.replace(/'/g, ''').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>'); 1743 1984 1744 <?php if ( ! apply_filters( 'disable_captions', '' ) ) { ?> 1985 <?php 1986 //duplicate_hook 1987 if ( ! apply_filters( 'disable_captions', '' ) ) { 1988 ?> 1745 1989 if ( f.caption.value ) { 1746 1990 caption = f.caption.value.replace(/\r\n|\r/g, '\n'); 1747 1991 caption = caption.replace(/<[a-zA-Z0-9]+( [^<>]+)?>/g, function(a){ … … 1818 2062 1819 2063 <div id="media-items"> 1820 2064 <div class="media-item media-blank"> 1821 <?php echo apply_filters( 'type_url_form_media', wp_media_insert_url_form( $type ) ); ?> 2065 <?php 2066 $form_html = wp_media_insert_url_form( $type ); 2067 /** 2068 * Filter the insert from URL form HTML. 2069 * 2070 * @since Unknown 2071 * 2072 * @param string $form_html The insert from URL form HTML. 2073 */ 2074 echo apply_filters( 'type_url_form_media', $form_html ); 2075 ?> 1822 2076 </div> 1823 2077 </div> 1824 2078 </form> … … 1840 2094 1841 2095 $post_id = intval($_REQUEST['post_id']); 1842 2096 $form_action_url = admin_url("media-upload.php?type=$type&tab=gallery&post_id=$post_id"); 2097 //duplicate_hook 1843 2098 $form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type); 1844 2099 $form_class = 'media-upload-form validate'; 1845 2100 … … 1986 2241 $post_id = isset( $_REQUEST['post_id'] ) ? intval( $_REQUEST['post_id'] ) : 0; 1987 2242 1988 2243 $form_action_url = admin_url("media-upload.php?type=$type&tab=library&post_id=$post_id"); 2244 //duplicate_hook 1989 2245 $form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type); 1990 2246 $form_class = 'media-upload-form validate'; 1991 2247 … … 2049 2305 2050 2306 $type_links[] = "<li><a href='" . esc_url(add_query_arg(array('post_mime_type'=>$mime_type, 'paged'=>false))) . "'$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>'; 2051 2307 } 2308 /** 2309 * Filter the media upload mime type list items. 2310 * 2311 * @since Unknown 2312 * 2313 * @param array $type_links An array of list items containing mime type link HTML. 2314 */ 2052 2315 echo implode(' | </li>', apply_filters( 'media_upload_mime_type_links', $type_links ) ) . '</li>'; 2053 2316 unset($type_links); 2054 2317 ?> … … 2148 2411 * @return string the form html 2149 2412 */ 2150 2413 function wp_media_insert_url_form( $default_view = 'image' ) { 2414 //duplicate_hook 2151 2415 if ( !apply_filters( 'disable_captions', '' ) ) { 2152 2416 $caption = ' 2153 2417 <tr class="image-only"> … … 2430 2694 $meta = wp_get_attachment_metadata( $post->ID ); 2431 2695 if ( isset( $meta['width'], $meta['height'] ) ) 2432 2696 $media_dims .= "<span id='media-dims-$post->ID'>{$meta['width']} × {$meta['height']}</span> "; 2697 //duplicate_hook 2433 2698 $media_dims = apply_filters( 'media_meta', $media_dims, $post ); 2434 2699 2435 2700 $att_url = wp_get_attachment_url( $post->ID );