Changeset 26908
- Timestamp:
- 01/06/2014 05:47:51 AM (11 years ago)
- Location:
- trunk/src/wp-admin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/media.php
r25727 r26908 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.0) media popup. 26 * 27 * @since 2.5.0 28 * 29 * @param array $_default_tabs An array of media tabs. 30 */ 31 return apply_filters( 'media_upload_tabs', $_default_tabs ); 25 32 } 26 33 … … 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 elseif ( isset($_GET['tab']) && array_key_exists($_GET['tab'], $tabs) )80 } elseif ( isset($_GET['tab']) && array_key_exists($_GET['tab'], $tabs) ) { 74 81 $current = $_GET['tab']; 75 else 76 $current = apply_filters('media_upload_default_tab', $default); 82 } else { 83 /** This filter is documented in wp-admin/media-upload.php */ 84 $current = apply_filters( 'media_upload_default_tab', $default ); 85 } 77 86 78 87 foreach ( $tabs as $callback => $text ) { … … 114 123 $html = '<a href="' . esc_attr($url) . "\"$rel>$html</a>"; 115 124 125 /** 126 * Filter the image HTML markup to send to the editor. 127 * 128 * @since 2.5.0 129 * 130 * @param string $html The image HTML markup to send. 131 * @param int $id The attachment id. 132 * @param string $caption The image caption. 133 * @param string $title The image title. 134 * @param string $align The image alignment. 135 * @param string $url The image source URL. 136 * @param string $size The image size. 137 * @param string $alt The image alternative, or alt, text. 138 */ 116 139 $html = apply_filters( 'image_send_to_editor', $html, $id, $caption, $title, $align, $url, $size, $alt ); 117 140 … … 136 159 function image_add_caption( $html, $id, $caption, $title, $align, $url, $size, $alt = '' ) { 137 160 161 /** 162 * Filter whether to disable captions. 163 * 164 * Prevents image captions from being appended to image HTML when inserted into the editor. 165 * 166 * @since 2.6.0 167 * 168 * @param bool $bool Whether to disable appending captions. Returning true to the filter 169 * will disable captions. Default empty string. 170 */ 138 171 if ( empty($caption) || apply_filters( 'disable_captions', '' ) ) 139 172 return $html; … … 157 190 $shcode = '[caption id="' . $id . '" align="align' . $align . '" width="' . $width . '"]' . $html . ' ' . $caption . '[/caption]'; 158 191 192 /** 193 * Filter the image HTML markup including the caption shortcode. 194 * 195 * @since 2.6.0 196 * 197 * @param string $shcode The image HTML markup with caption shortcode. 198 * @param string $html The image HTML markup. 199 */ 159 200 return apply_filters( 'image_add_caption_shortcode', $shcode, $html ); 160 201 } … … 398 439 </script> 399 440 <?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'); 407 408 if ( is_string($content_func) ) 441 /** This action is documented in wp-admin/admin-header.php */ 442 do_action( 'admin_enqueue_scripts', 'media-upload-popup' ); 443 444 /** 445 * Print admin styles enqueued for the legacy (pre-3.5.0) media upload popup. 446 * 447 * @since 2.9.0 448 */ 449 do_action( 'admin_print_styles-media-upload-popup' ); 450 451 /** This action is documented in wp-admin/admin-header.php */ 452 do_action( 'admin_print_styles' ); 453 454 /** 455 * Print admin scripts enqueued for the legacy (pre-3.5.0) media upload popup. 456 * 457 * @since 2.9.0 458 */ 459 do_action( 'admin_print_scripts-media-upload-popup' ); 460 461 /** This action is documented in wp-admin/admin-header.php */ 462 do_action( 'admin_print_scripts' ); 463 464 /** 465 * Print scripts enqueued for the admin header for the legacy (pre-3.5.0) 466 * media upload popup. 467 * 468 * @since 2.9.0 469 */ 470 do_action( 'admin_head-media-upload-popup' ); 471 472 /** This action is documented in wp-admin/admin-header.php */ 473 do_action( 'admin_head' ); 474 475 if ( is_string( $content_func ) ) { 476 /** 477 * Fires in the admin header for each specific form tab in the legacy 478 * (pre-3.5.0) media upload popup. 479 * 480 * The dynamic portion of the hook, $content_func, refers to the form 481 * callback for the media upload type. Possible values include 482 * 'media_upload_type_form', 'media_upload_type_url_form', and 483 * 'media_upload_library_form'. 484 * 485 * @since 2.5.0 486 */ 409 487 do_action( "admin_head_{$content_func}" ); 488 } 410 489 ?> 411 490 </head> … … 419 498 call_user_func_array($content_func, $args); 420 499 421 do_action('admin_print_footer_scripts'); 500 /** This action is documented in wp-admin/admin-footer.php */ 501 do_action( 'admin_print_footer_scripts' ); 422 502 ?> 423 503 <script type="text/javascript">if(typeof wpOnload=='function')wpOnload();</script> … … 447 527 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 528 449 // Don't use this filter. Want to add a button? Use the media_buttons action. 450 $legacy_filter = apply_filters('media_buttons_context', ''); // deprecated 529 /** 530 * Filter the legacy (pre-3.5.0) media buttons. 531 * 532 * @since 2.5.0 533 * @deprecated 3.5.0 Use 'media_buttons' action instead. 534 * 535 * @param string $string Media buttons context. Default empty. 536 */ 537 $legacy_filter = apply_filters( 'media_buttons_context', '' ); 451 538 452 539 if ( $legacy_filter ) { … … 473 560 $upload_iframe_src = add_query_arg('tab', $tab, $upload_iframe_src); 474 561 475 $upload_iframe_src = apply_filters($type . '_upload_iframe_src', $upload_iframe_src); 562 /** 563 * Filter the upload iframe source URL for a specific media type. 564 * 565 * The dynamic portion of the hook name, $type, refers to the type 566 * of media uploaded. 567 * 568 * @since 3.0.0 569 * 570 * @param string $upload_iframe_src The upload iframe source URL by type. 571 */ 572 $upload_iframe_src = apply_filters( $type . '_upload_iframe_src', $upload_iframe_src ); 476 573 477 574 return add_query_arg('TB_iframe', true, $upload_iframe_src); … … 515 612 } 516 613 517 $post = apply_filters('attachment_fields_to_save', $post, $attachment); 614 /** 615 * Filter the attachment fields to be saved. 616 * 617 * @since 2.5.0 618 * 619 * @see wp_get_attachment_metadata() 620 * 621 * @param WP_Post $post The WP_Post object. 622 * @param array $attachment An array of attachment metadata. 623 */ 624 $post = apply_filters( 'attachment_fields_to_save', $post, $attachment ); 518 625 519 626 if ( isset($attachment['image_alt']) ) { … … 562 669 } 563 670 564 $html = apply_filters('media_send_to_editor', $html, $send_id, $attachment); 671 /** 672 * Filter the HTML markup for a media item sent to the editor. 673 * 674 * @since 2.5.0 675 * 676 * @see wp_get_attachment_metadata() 677 * 678 * @param string $html HTML markup for a media item sent to the editor. 679 * @param int $send_id The first key from the $_POST['send'] data. 680 * @param array $attachment Array of attachment metadata. 681 */ 682 $html = apply_filters( 'media_send_to_editor', $html, $send_id, $attachment ); 565 683 return media_send_to_editor($html); 566 684 } … … 609 727 $type = $ext_type; 610 728 729 /** 730 * Filter the URL sent to the editor for a specific media type. 731 * 732 * The dynamic portion of the hook name, $type, refers to the type 733 * of media being sent. 734 * 735 * @since 3.3.0 736 * 737 * @param string $html HTML markup sent to the editor. 738 * @param string $src Media source URL. 739 * @param string $title Media title. 740 */ 611 741 $html = apply_filters( $type . '_send_to_editor_url', $html, esc_url_raw( $src ), $title ); 612 742 } else { … … 620 750 $html = "<img src='" . esc_url($src) . "' alt='$alt'$class />"; 621 751 752 /** 753 * Filter the image URL sent to the editor. 754 * 755 * @since 2.8.0 756 * 757 * @param string $html HTML markup sent to the editor for an image. 758 * @param string $src Image source URL. 759 * @param string $alt Image alternate, or alt, text. 760 * @param string $align The image alignment. Default 'alignnone'. Possible values include 761 * 'alignleft', 'aligncenter', 'alignright', 'alignnone'. 762 */ 622 763 $html = apply_filters( 'image_send_to_editor_url', $html, esc_url_raw( $src ), $alt, $align ); 623 764 } … … 779 920 function image_size_input_fields( $post, $check = '' ) { 780 921 781 // 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')) ); 922 /** 923 * Filter the names and labels of the default image sizes. 924 * 925 * @since 3.3.0 926 * 927 * @param array $size_names Array of image sizes and their names. Default values 928 * include 'Thumbnail', 'Medium', 'Large', 'Full Size'. 929 */ 930 $size_names = apply_filters( 'image_size_names_choose', array( 931 'thumbnail' => __( 'Thumbnail' ), 932 'medium' => __( 'Medium' ), 933 'large' => __( 'Large' ), 934 'full' => __( 'Full Size' ) 935 ) ); 783 936 784 937 if ( empty($check) ) … … 1062 1215 } 1063 1216 1064 $form_fields = apply_filters('attachment_fields_to_edit', $form_fields, $post); 1217 /** 1218 * Filter the attachment fields to edit. 1219 * 1220 * @since 2.5.0 1221 * 1222 * @param array $form_fields An array of attachment form fields. 1223 * @param WP_Post $post The WP_Post attachment object. 1224 */ 1225 $form_fields = apply_filters( 'attachment_fields_to_edit', $form_fields, $post ); 1065 1226 1066 1227 return $form_fields; … … 1127 1288 $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 1289 $args = wp_parse_args( $args, $default_args ); 1290 1291 /** 1292 * Filter the arguments used to retrieve an image for the edit image form. 1293 * 1294 * @since 3.1.0 1295 * 1296 * @see get_media_item 1297 * 1298 * @param array $args An array of arguments. 1299 */ 1129 1300 $args = apply_filters( 'get_media_item_args', $args ); 1130 1301 extract( $args, EXTR_SKIP ); … … 1181 1352 if ( isset( $meta['width'], $meta['height'] ) ) 1182 1353 $media_dims .= "<span id='media-dims-$post->ID'>{$meta['width']} × {$meta['height']}</span> "; 1354 1355 /** 1356 * Filter the media metadata. 1357 * 1358 * @since 2.5.0 1359 * 1360 * @param string $media_dims The HTML markup containing the media dimensions. 1361 * @param WP_Post $post The WP_Post attachment object. 1362 */ 1183 1363 $media_dims = apply_filters( 'media_meta', $media_dims, $post ); 1184 1364 … … 1344 1524 1345 1525 $args = wp_parse_args( $args, $default_args ); 1526 1527 /** This filter is documented in wp-admin/includes/media.php */ 1346 1528 $args = apply_filters( 'get_media_item_args', $args ); 1347 1529 … … 1377 1559 $form_fields = array_merge_recursive($form_fields, (array) $args['errors'] ); 1378 1560 1561 /** This filter is documented in wp-admin/includes/media.php */ 1379 1562 $form_fields = apply_filters( 'attachment_fields_to_edit', $form_fields, $post ); 1380 1563 … … 1383 1566 $form_fields['url'], $form_fields['menu_order'], $form_fields['image_url'] ); 1384 1567 1568 /** This filter is documented in wp-admin/includes/media.php */ 1385 1569 $media_meta = apply_filters( 'media_meta', '', $post ); 1386 1570 … … 1542 1726 <?php 1543 1727 if ( is_multisite() && !is_upload_space_available() ) { 1728 /** 1729 * Fires when an upload will exceed the defined upload space quota for a network site. 1730 * 1731 * @since 3.5.0 1732 */ 1544 1733 do_action( 'upload_ui_over_quota' ); 1545 1734 return; 1546 1735 } 1547 1736 1548 do_action('pre-upload-ui'); 1737 /** 1738 * Fires just before the legacy (pre-3.5.0) upload interface is loaded. 1739 * 1740 * @since 2.6.0 1741 */ 1742 do_action( 'pre-upload-ui' ); 1549 1743 1550 1744 $post_params = array( … … 1556 1750 ); 1557 1751 1558 $post_params = apply_filters( 'upload_post_params', $post_params ); // hook change! old name: 'swfupload_post_params' 1752 /** 1753 * Filter the media upload post parameters. 1754 * 1755 * @since 3.1.0 As 'swfupload_post_params' 1756 * @since 3.3.0 1757 * 1758 * @param array $post_params An array of media upload parameters used by Plupload. 1759 */ 1760 $post_params = apply_filters( 'upload_post_params', $post_params ); 1559 1761 1560 1762 $plupload_init = array( … … 1580 1782 $plupload_init['multi_selection'] = false; 1581 1783 1784 /** 1785 * Filter the default Plupload settings. 1786 * 1787 * @since 3.3.0 1788 * 1789 * @param array $plupload_init An array of default settings used by Plupload. 1790 */ 1582 1791 $plupload_init = apply_filters( 'plupload_init', $plupload_init ); 1583 1792 … … 1599 1808 1600 1809 <div id="plupload-upload-ui" class="hide-if-no-js"> 1601 <?php do_action('pre-plupload-upload-ui'); // hook change, old name: 'pre-flash-upload-ui' ?> 1810 <?php 1811 /** 1812 * Fires before the upload interface loads. 1813 * 1814 * @since 2.6.0 As 'pre-flash-upload-ui' 1815 * @since 3.3.0 1816 */ 1817 do_action( 'pre-plupload-upload-ui' ); ?> 1602 1818 <div id="drag-drop-area"> 1603 1819 <div class="drag-drop-inside"> … … 1607 1823 </div> 1608 1824 </div> 1609 <?php do_action('post-plupload-upload-ui'); // hook change, old name: 'post-flash-upload-ui' ?> 1825 <?php 1826 /** 1827 * Fires after the upload interface loads. 1828 * 1829 * @since 2.6.0 As 'post-flash-upload-ui' 1830 * @since 3.3.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"> 1613 <?php do_action('pre-html-upload-ui'); ?> 1836 <?php 1837 /** 1838 * Fires before the upload button in the media upload interface. 1839 * 1840 * @since 2.6.0 1841 */ 1842 do_action( 'pre-html-upload-ui' ); 1843 ?> 1614 1844 <p id="async-upload-wrap"> 1615 1845 <label class="screen-reader-text" for="async-upload"><?php _e('Upload'); ?></label> … … 1619 1849 </p> 1620 1850 <div class="clear"></div> 1621 <?php do_action('post-html-upload-ui'); ?> 1851 <?php 1852 /** 1853 * Fires after the upload button in the media upload interface. 1854 * 1855 * @since 2.6.0 1856 */ 1857 do_action( 'post-html-upload-ui' ); 1858 ?> 1622 1859 </div> 1623 1860 … … 1628 1865 <?php } 1629 1866 1630 do_action('post-upload-ui'); 1867 /** 1868 * Fires on the post upload UI screen. 1869 * 1870 * Legacy (pre-3.5.0) media workflow hook. 1871 * 1872 * @since 2.6.0 1873 */ 1874 do_action( 'post-upload-ui' ); 1631 1875 } 1632 1876 … … 1647 1891 1648 1892 $form_action_url = admin_url("media-upload.php?type=$type&tab=type&post_id=$post_id"); 1649 $form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type); 1893 1894 /** 1895 * Filter the media upload form action URL. 1896 * 1897 * @since 2.6.0 1898 * 1899 * @param string $form_action_url The media upload form action URL. 1900 * @param string $type The type of media. Default 'file'. 1901 */ 1902 $form_action_url = apply_filters( 'media_upload_form_url', $form_action_url, $type ); 1650 1903 $form_class = 'media-upload-form type-form validate'; 1651 1904 … … 1712 1965 1713 1966 $form_action_url = admin_url("media-upload.php?type=$type&tab=type&post_id=$post_id"); 1714 $form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type); 1967 /** This filter is documented in wp-admin/includes/media.php */ 1968 $form_action_url = apply_filters( 'media_upload_form_url', $form_action_url, $type ); 1715 1969 $form_class = 'media-upload-form type-form validate'; 1716 1970 … … 1742 1996 alt = f.alt.value.replace(/'/g, ''').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>'); 1743 1997 1744 <?php if ( ! apply_filters( 'disable_captions', '' ) ) { ?> 1998 <?php 1999 /** This filter is documented in wp-admin/includes/media.php */ 2000 if ( ! apply_filters( 'disable_captions', '' ) ) { 2001 ?> 1745 2002 if ( f.caption.value ) { 1746 2003 caption = f.caption.value.replace(/\r\n|\r/g, '\n'); … … 1819 2076 <div id="media-items"> 1820 2077 <div class="media-item media-blank"> 1821 <?php echo apply_filters( 'type_url_form_media', wp_media_insert_url_form( $type ) ); ?> 2078 <?php 2079 /** 2080 * Filter the insert media from URL form HTML. 2081 * 2082 * @since 3.3.0 2083 * 2084 * @param string $form_html The insert from URL form HTML. 2085 */ 2086 echo apply_filters( 'type_url_form_media', wp_media_insert_url_form( $type ) ); 2087 ?> 1822 2088 </div> 1823 2089 </div> … … 1841 2107 $post_id = intval($_REQUEST['post_id']); 1842 2108 $form_action_url = admin_url("media-upload.php?type=$type&tab=gallery&post_id=$post_id"); 1843 $form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type); 2109 /** This filter is documented in wp-admin/includes/media.php */ 2110 $form_action_url = apply_filters( 'media_upload_form_url', $form_action_url, $type ); 1844 2111 $form_class = 'media-upload-form validate'; 1845 2112 … … 1987 2254 1988 2255 $form_action_url = admin_url("media-upload.php?type=$type&tab=library&post_id=$post_id"); 1989 $form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type); 2256 /** This filter is documented in wp-admin/includes/media.php */ 2257 $form_action_url = apply_filters( 'media_upload_form_url', $form_action_url, $type ); 1990 2258 $form_class = 'media-upload-form validate'; 1991 2259 … … 2050 2318 $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 2319 } 2320 /** 2321 * Filter the media upload mime type list items. 2322 * 2323 * Returned values should begin with an <li> tag. 2324 * 2325 * @since 3.1.0 2326 * 2327 * @param array $type_links An array of list items containing mime type link HTML. 2328 */ 2052 2329 echo implode(' | </li>', apply_filters( 'media_upload_mime_type_links', $type_links ) ) . '</li>'; 2053 2330 unset($type_links); … … 2149 2426 */ 2150 2427 function wp_media_insert_url_form( $default_view = 'image' ) { 2151 if ( !apply_filters( 'disable_captions', '' ) ) { 2428 /** This filter is documented in wp-admin/includes/media.php */ 2429 if ( ! apply_filters( 'disable_captions', '' ) ) { 2152 2430 $caption = ' 2153 2431 <tr class="image-only"> … … 2431 2709 if ( isset( $meta['width'], $meta['height'] ) ) 2432 2710 $media_dims .= "<span id='media-dims-$post->ID'>{$meta['width']} × {$meta['height']}</span> "; 2711 /** This filter is documented in wp-admin/includes/media.php */ 2433 2712 $media_dims = apply_filters( 'media_meta', $media_dims, $post ); 2434 2713 … … 2470 2749 2471 2750 /** 2472 * Audio and video metadata fields to be shown in the publish meta box.2751 * Filter the audio and video metadata fields to be shown in the publish meta box. 2473 2752 * 2474 2753 * The key for each item in the array should correspond to an attachment 2475 2754 * metadata key, and the value should be the desired label. 2476 2755 * 2477 * @since 2756 * @since 3.7.0 2478 2757 * 2479 2758 * @param array $fields { 2480 2759 * An array of the attachment metadata keys and labels. 2481 2760 * 2482 * @type string 'mime_type'Label to be shown before the field mime_type.2483 * @type string 'year'Label to be shown before the field year.2484 * @type string 'genre'Label to be shown before the field genre.2485 * @type string 'length_formatted'Label to be shown before the field length_formatted.2761 * @type string $mime_type Label to be shown before the field mime_type. 2762 * @type string $year Label to be shown before the field year. 2763 * @type string $genre Label to be shown before the field genre. 2764 * @type string $length_formatted Label to be shown before the field length_formatted. 2486 2765 * } 2487 2766 */ … … 2516 2795 2517 2796 /** 2518 * Audio attachment metadata fields to be shown in the publish meta box.2797 * Filter the audio attachment metadata fields to be shown in the publish meta box. 2519 2798 * 2520 2799 * The key for each item in the array should correspond to an attachment 2521 2800 * metadata key, and the value should be the desired label. 2522 2801 * 2523 * @since 2802 * @since 3.7.0 2524 2803 * 2525 2804 * @param array $fields { 2526 2805 * An array of the attachment metadata keys and labels. 2527 2806 * 2528 * @type string 'dataformat'Label to be shown before the field dataformat.2529 * @type string 'codec'Label to be shown before the field codec.2807 * @type string $dataformat Label to be shown before the field dataformat. 2808 * @type string $codec Label to be shown before the field codec. 2530 2809 * } 2531 2810 */ -
trunk/src/wp-admin/media-upload.php
r25616 r26908 45 45 46 46 // tab: gallery, library, or type-specific 47 if ( isset($_GET['tab']) ) 47 if ( isset($_GET['tab']) ) { 48 48 $tab = strval($_GET['tab']); 49 else 50 $tab = apply_filters('media_upload_default_tab', 'type'); 49 } else { 50 /** 51 * Filter the default tab in the legacy (pre-3.5.0) media popup. 52 * 53 * @since 2.5.0 54 * 55 * @param string $type The default media popup tab. 56 */ 57 $tab = apply_filters( 'media_upload_default_tab', 'type' ); 58 } 51 59 52 60 $body_id = 'media-upload';
Note: See TracChangeset
for help on using the changeset viewer.