Make WordPress Core

Ticket #25375: 25375.2.diff

File 25375.2.diff, 18.0 KB (added by DrewAPicture, 12 years ago)

Missed a few hooks in the first pass.

  • src/wp-admin/includes/media.php

     
    2121                'library' => __('Media Library')
    2222        );
    2323
    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 );
    2532}
    2633
    2734/**
     
    7380                elseif ( isset($_GET['tab']) && array_key_exists($_GET['tab'], $tabs) )
    7481                        $current = $_GET['tab'];
    7582                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 );
    7789
    7890                foreach ( $tabs as $callback => $text ) {
    7991                        $class = '';
     
    113125        if ( $url )
    114126                $html = '<a href="' . esc_attr($url) . "\"$rel>$html</a>";
    115127
     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         */
    116142        $html = apply_filters( 'image_send_to_editor', $html, $id, $caption, $title, $align, $url, $size, $alt );
    117143
    118144        return $html;
     
    135161 */
    136162function image_add_caption( $html, $id, $caption, $title, $align, $url, $size, $alt = '' ) {
    137163
     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         */
    138174        if ( empty($caption) || apply_filters( 'disable_captions', '' ) )
    139175                return $html;
    140176
     
    156192
    157193        $shcode = '[caption id="' . $id . '" align="align' . $align     . '" width="' . $width . '"]' . $html . ' ' . $caption . '[/caption]';
    158194
     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         */
    159203        return apply_filters( 'image_add_caption_shortcode', $shcode, $html );
    160204}
    161205add_filter( 'image_send_to_editor', 'image_add_caption', 20, 8 );
     
    397441//]]>
    398442</script>
    399443<?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         * Enqueue scripts for the admin.
     446         *
     447         * @since Unknown
     448         * @since 3.5.0
     449         *
     450         * @param Unknown
     451         */
     452        do_action( 'admin_enqueue_scripts', 'media-upload-popup' );
    407453
     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
    408497if ( 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         */
     508do_action( "admin_head_{$content_func}" );
    410509?>
    411510</head>
    412511<body<?php if ( isset($GLOBALS['body_id']) ) echo ' id="' . $GLOBALS['body_id'] . '"'; ?> class="wp-core-ui no-js">
     
    418517        $args = array_slice($args, 1);
    419518        call_user_func_array($content_func, $args);
    420519
     520        /**
     521         * Prints scripts enqueued for the admin footer.
     522         *
     523         * @since Unknown
     524         */
    421525        do_action('admin_print_footer_scripts');
    422526?>
    423527<script type="text/javascript">if(typeof wpOnload=='function')wpOnload();</script>
     
    446550
    447551        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>';
    448552
    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         */
    450563        $legacy_filter = apply_filters('media_buttons_context', ''); // deprecated
    451564
    452565        if ( $legacy_filter ) {
     
    472585        if ( ! empty( $tab ) )
    473586                $upload_iframe_src = add_query_arg('tab', $tab, $upload_iframe_src);
    474587
     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         */
    475597        $upload_iframe_src = apply_filters($type . '_upload_iframe_src', $upload_iframe_src);
    476598
    477599        return add_query_arg('TB_iframe', true, $upload_iframe_src);
     
    514636                                $post['post_parent'] = $attachment['post_parent'];
    515637                }
    516638
     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                 */
    517647                $post = apply_filters('attachment_fields_to_save', $post, $attachment);
    518648
    519649                if ( isset($attachment['image_alt']) ) {
     
    561691                        $html = "<a href='{$attachment['url']}'$rel>$html</a>";
    562692                }
    563693
     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                 */
    564703                $html = apply_filters('media_send_to_editor', $html, $send_id, $attachment);
    565704                return media_send_to_editor($html);
    566705        }
     
    608747                                && ( 'audio' == $ext_type || 'video' == $ext_type ) )
    609748                                        $type = $ext_type;
    610749
     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                         */
    611761                        $html = apply_filters( $type . '_send_to_editor_url', $html, esc_url_raw( $src ), $title );
    612762                } else {
    613763                        $align = '';
     
    779929function image_size_input_fields( $post, $check = '' ) {
    780930
    781931                // 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                );
    783938
     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
    784948                if ( empty($check) )
    785949                        $check = get_user_setting('imgsize', 'medium');
    786950
     
    10611225                unset( $form_fields['image_alt'] );
    10621226        }
    10631227
     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         */
    10641236        $form_fields = apply_filters('attachment_fields_to_edit', $form_fields, $post);
    10651237
    10661238        return $form_fields;
     
    11261298
    11271299        $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 );
    11281300        $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         */
    11291309        $args = apply_filters( 'get_media_item_args', $args );
    11301310        extract( $args, EXTR_SKIP );
    11311311
     
    11801360        $meta = wp_get_attachment_metadata( $post->ID );
    11811361        if ( isset( $meta['width'], $meta['height'] ) )
    11821362                $media_dims .= "<span id='media-dims-$post->ID'>{$meta['width']}&nbsp;&times;&nbsp;{$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         */
    11831372        $media_dims = apply_filters( 'media_meta', $media_dims, $post );
    11841373
    11851374        $image_edit_button = '';
     
    13431532        $user_can_edit = current_user_can( 'edit_post', $attachment_id );
    13441533
    13451534        $args = wp_parse_args( $args, $default_args );
     1535
     1536        //duplicate_hook
    13461537        $args = apply_filters( 'get_media_item_args', $args );
    13471538
    13481539        $form_fields = array();
     
    13761567        // The recursive merge is easily traversed with array casting: foreach( (array) $things as $thing )
    13771568        $form_fields = array_merge_recursive($form_fields, (array) $args['errors'] );
    13781569
     1570        //duplicate_hook
    13791571        $form_fields = apply_filters( 'attachment_fields_to_edit', $form_fields, $post );
    13801572
    13811573        unset( $form_fields['image-size'], $form_fields['align'], $form_fields['image_alt'],
    13821574                $form_fields['post_title'], $form_fields['post_excerpt'], $form_fields['post_content'],
    13831575                $form_fields['url'], $form_fields['menu_order'], $form_fields['image_url'] );
    13841576
     1577        //duplicate_hook
    13851578        $media_meta = apply_filters( 'media_meta', '', $post );
    13861579
    13871580        $defaults = array(
     
    15451738        return;
    15461739}
    15471740
    1548 do_action('pre-upload-ui');
     1741/**
     1742 * Fires just before the legacy (pre-3.5) upload interface is loaded.
     1743 *
     1744 * @since Unknown
     1745 */
     1746do_action( 'pre-upload-ui' );
    15491747
    15501748$post_params = array(
    15511749                "post_id" => $post_id,
     
    15551753                "short" => "1",
    15561754);
    15571755
    1558 $post_params = apply_filters( 'upload_post_params', $post_params ); // hook change! old name: 'swfupload_post_params'
     1756/**
     1757 * Filter the media upload post parameters.
     1758 *
     1759 * Previously 'swfupload_post_params'.
     1760 *
     1761 * @since Unknown
     1762 * @since 3.5.0
     1763 *
     1764 * @param array $post_params An array of media upload parameters used by Plupload.
     1765 */
     1766$post_params = apply_filters( 'upload_post_params', $post_params );
    15591767
    15601768$plupload_init = array(
    15611769        'runtimes' => 'html5,silverlight,flash,html4',
     
    15791787if ( wp_is_mobile() )
    15801788        $plupload_init['multi_selection'] = false;
    15811789
     1790/**
     1791 * Filter the default Plupload settings.
     1792 *
     1793 * @since Unknown
     1794 *
     1795 * @param array $plupload_init An array of default settings used by Plupload.
     1796 */
    15821797$plupload_init = apply_filters( 'plupload_init', $plupload_init );
    15831798
    15841799?>
     
    15981813</script>
    15991814
    16001815<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' ?>
     1816<?php
     1817/**
     1818 * Fires before the upload interface loads.
     1819 *
     1820 * Previously named 'pre-flash-upload-ui'.
     1821 *
     1822 * @since Unknown
     1823 * @since 3.5.0
     1824 */
     1825do_action('pre-plupload-upload-ui'); // hook change, old name: 'pre-flash-upload-ui' ?>
    16021826<div id="drag-drop-area">
    16031827        <div class="drag-drop-inside">
    16041828        <p class="drag-drop-info"><?php _e('Drop files here'); ?></p>
     
    16061830        <p class="drag-drop-buttons"><input id="plupload-browse-button" type="button" value="<?php esc_attr_e('Select Files'); ?>" class="button" /></p>
    16071831        </div>
    16081832</div>
    1609 <?php do_action('post-plupload-upload-ui'); // hook change, old name: 'post-flash-upload-ui' ?>
     1833<?php
     1834/**
     1835 * Fires after the upload interface loads.
     1836 *
     1837 * Previously named 'post-flash-upload-ui'.
     1838 *
     1839 * @since Unknown
     1840 * @since 3.5.0
     1841 */
     1842do_action( 'post-plupload-upload-ui' ); ?>
    16101843</div>
    16111844
    16121845<div id="html-upload-ui" class="hide-if-js">
    1613 <?php do_action('pre-html-upload-ui'); ?>
     1846        <?php
     1847        /**
     1848         * Fires before the upload button in the media upload interface.
     1849         *
     1850         * @since Unknown
     1851         */
     1852        do_action( 'pre-html-upload-ui' );
     1853        ?>
    16141854        <p id="async-upload-wrap">
    16151855                <label class="screen-reader-text" for="async-upload"><?php _e('Upload'); ?></label>
    16161856                <input type="file" name="async-upload" id="async-upload" />
     
    16181858                <a href="#" onclick="try{top.tb_remove();}catch(e){}; return false;"><?php _e('Cancel'); ?></a>
    16191859        </p>
    16201860        <div class="clear"></div>
    1621 <?php do_action('post-html-upload-ui'); ?>
     1861<?php
     1862/**
     1863 * Fires after the upload button in the media upload interface.
     1864 *
     1865 * @since Unknown
     1866 */
     1867do_action( 'post-html-upload-ui' );
     1868?>
    16221869</div>
    16231870
    16241871<span class="max-upload-size"><?php printf( __( 'Maximum upload file size: %d%s.' ), esc_html($upload_size_unit), esc_html($sizes[$u]) ); ?></span>
     
    16271874        <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>
    16281875<?php }
    16291876
    1630         do_action('post-upload-ui');
     1877        /**
     1878         * Fires on the post upload UI screen.
     1879         *
     1880         * Legacy (pre-3.5) media workflow hook.
     1881         *
     1882         * @since Unknown
     1883         * @since 3.5.0
     1884         */
     1885        do_action( 'post-upload-ui' );
    16311886}
    16321887
    16331888/**
     
    16461901        $post_id = isset( $_REQUEST['post_id'] )? intval( $_REQUEST['post_id'] ) : 0;
    16471902
    16481903        $form_action_url = admin_url("media-upload.php?type=$type&tab=type&post_id=$post_id");
     1904
     1905        /**
     1906         * Filter the media upload form action URL.
     1907         *
     1908         * @since Unknown
     1909         *
     1910         * @param string $form_action_url The media upload form action URL.
     1911         * @param string $type            The type of media. Default 'file'.
     1912         */
    16491913        $form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);
    16501914        $form_class = 'media-upload-form type-form validate';
    16511915
     
    17111975        $post_id = isset( $_REQUEST['post_id'] ) ? intval( $_REQUEST['post_id'] ) : 0;
    17121976
    17131977        $form_action_url = admin_url("media-upload.php?type=$type&tab=type&post_id=$post_id");
     1978        //duplicate_hook
    17141979        $form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);
    17151980        $form_class = 'media-upload-form type-form validate';
    17161981
     
    17412006                if ( f.alt.value )
    17422007                        alt = f.alt.value.replace(/'/g, '&#039;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
    17432008
    1744 <?php if ( ! apply_filters( 'disable_captions', '' ) ) { ?>
     2009<?php
     2010        //duplicate_hook
     2011        if ( ! apply_filters( 'disable_captions', '' ) ) {
     2012                ?>
    17452013                if ( f.caption.value ) {
    17462014                        caption = f.caption.value.replace(/\r\n|\r/g, '\n');
    17472015                        caption = caption.replace(/<[a-zA-Z0-9]+( [^<>]+)?>/g, function(a){
     
    18182086
    18192087<div id="media-items">
    18202088<div class="media-item media-blank">
    1821 <?php echo apply_filters( 'type_url_form_media', wp_media_insert_url_form( $type ) ); ?>
     2089<?php
     2090$form_html = wp_media_insert_url_form( $type );
     2091/**
     2092 * Filter the insert from URL form HTML.
     2093 *
     2094 * @since Unknown
     2095 *
     2096 * @param string $form_html The insert from URL form HTML.
     2097 */
     2098echo apply_filters( 'type_url_form_media', $form_html );
     2099?>
    18222100</div>
    18232101</div>
    18242102</form>
     
    18402118
    18412119        $post_id = intval($_REQUEST['post_id']);
    18422120        $form_action_url = admin_url("media-upload.php?type=$type&tab=gallery&post_id=$post_id");
     2121        //duplicate_hook
    18432122        $form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);
    18442123        $form_class = 'media-upload-form validate';
    18452124
     
    19862265        $post_id = isset( $_REQUEST['post_id'] ) ? intval( $_REQUEST['post_id'] ) : 0;
    19872266
    19882267        $form_action_url = admin_url("media-upload.php?type=$type&tab=library&post_id=$post_id");
     2268        //duplicate_hook
    19892269        $form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);
    19902270        $form_class = 'media-upload-form validate';
    19912271
     
    20492329
    20502330        $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>';
    20512331}
     2332/**
     2333 * Filter the media upload mime type list items.
     2334 *
     2335 * @since Unknown
     2336 *
     2337 * @param array $type_links An array of list items containing mime type link HTML.
     2338 */
    20522339echo implode(' | </li>', apply_filters( 'media_upload_mime_type_links', $type_links ) ) . '</li>';
    20532340unset($type_links);
    20542341?>
     
    21482435 * @return string the form html
    21492436 */
    21502437function wp_media_insert_url_form( $default_view = 'image' ) {
     2438        //duplicate_hook
    21512439        if ( !apply_filters( 'disable_captions', '' ) ) {
    21522440                $caption = '
    21532441                <tr class="image-only">
     
    24302718        $meta = wp_get_attachment_metadata( $post->ID );
    24312719        if ( isset( $meta['width'], $meta['height'] ) )
    24322720                $media_dims .= "<span id='media-dims-$post->ID'>{$meta['width']}&nbsp;&times;&nbsp;{$meta['height']}</span> ";
     2721        //duplicate_hook
    24332722        $media_dims = apply_filters( 'media_meta', $media_dims, $post );
    24342723
    24352724        $att_url = wp_get_attachment_url( $post->ID );