Make WordPress Core

Ticket #25375: 25375.diff

File 25375.diff, 16.4 KB (added by DrewAPicture, 12 years ago)

First pass, missing @since values

  • 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/**
     
    6875
    6976        if ( !empty($tabs) ) {
    7077                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) ) {}
    7279                        $current = $redir_tab;
    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         * 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' );
    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();
     
    13821573                $form_fields['post_title'], $form_fields['post_excerpt'], $form_fields['post_content'],
    13831574                $form_fields['url'], $form_fields['menu_order'], $form_fields['image_url'] );
    13841575
     1576        //duplicate_hook
    13851577        $media_meta = apply_filters( 'media_meta', '', $post );
    13861578
    13871579        $defaults = array(
     
    15451737        return;
    15461738}
    15471739
    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 */
     1745do_action( 'pre-upload-ui' );
    15491746
    15501747$post_params = array(
    15511748                "post_id" => $post_id,
     
    15551752                "short" => "1",
    15561753);
    15571754
    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 );
    15591766
    15601767$plupload_init = array(
    15611768        'runtimes' => 'html5,silverlight,flash,html4',
     
    15791786if ( wp_is_mobile() )
    15801787        $plupload_init['multi_selection'] = false;
    15811788
     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 */
    15821796$plupload_init = apply_filters( 'plupload_init', $plupload_init );
    15831797
    15841798?>
     
    16061820        <p class="drag-drop-buttons"><input id="plupload-browse-button" type="button" value="<?php esc_attr_e('Select Files'); ?>" class="button" /></p>
    16071821        </div>
    16081822</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 */
     1832do_action( 'post-plupload-upload-ui' ); ?>
    16101833</div>
    16111834
    16121835<div id="html-upload-ui" class="hide-if-js">
     
    16271850        <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>
    16281851<?php }
    16291852
    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' );
    16311862}
    16321863
    16331864/**
     
    16461877        $post_id = isset( $_REQUEST['post_id'] )? intval( $_REQUEST['post_id'] ) : 0;
    16471878
    16481879        $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         */
    16491889        $form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);
    16501890        $form_class = 'media-upload-form type-form validate';
    16511891
     
    17111951        $post_id = isset( $_REQUEST['post_id'] ) ? intval( $_REQUEST['post_id'] ) : 0;
    17121952
    17131953        $form_action_url = admin_url("media-upload.php?type=$type&tab=type&post_id=$post_id");
     1954        //duplicate_hook
    17141955        $form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);
    17151956        $form_class = 'media-upload-form type-form validate';
    17161957
     
    17411982                if ( f.alt.value )
    17421983                        alt = f.alt.value.replace(/'/g, '&#039;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
    17431984
    1744 <?php if ( ! apply_filters( 'disable_captions', '' ) ) { ?>
     1985<?php
     1986        //duplicate_hook
     1987        if ( ! apply_filters( 'disable_captions', '' ) ) {
     1988                ?>
    17451989                if ( f.caption.value ) {
    17461990                        caption = f.caption.value.replace(/\r\n|\r/g, '\n');
    17471991                        caption = caption.replace(/<[a-zA-Z0-9]+( [^<>]+)?>/g, function(a){
     
    18182062
    18192063<div id="media-items">
    18202064<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 */
     2074echo apply_filters( 'type_url_form_media', $form_html );
     2075?>
    18222076</div>
    18232077</div>
    18242078</form>
     
    18402094
    18412095        $post_id = intval($_REQUEST['post_id']);
    18422096        $form_action_url = admin_url("media-upload.php?type=$type&tab=gallery&post_id=$post_id");
     2097        //duplicate_hook
    18432098        $form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);
    18442099        $form_class = 'media-upload-form validate';
    18452100
     
    19862241        $post_id = isset( $_REQUEST['post_id'] ) ? intval( $_REQUEST['post_id'] ) : 0;
    19872242
    19882243        $form_action_url = admin_url("media-upload.php?type=$type&tab=library&post_id=$post_id");
     2244        //duplicate_hook
    19892245        $form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);
    19902246        $form_class = 'media-upload-form validate';
    19912247
     
    20492305
    20502306        $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>';
    20512307}
     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 */
    20522315echo implode(' | </li>', apply_filters( 'media_upload_mime_type_links', $type_links ) ) . '</li>';
    20532316unset($type_links);
    20542317?>
     
    21482411 * @return string the form html
    21492412 */
    21502413function wp_media_insert_url_form( $default_view = 'image' ) {
     2414        //duplicate_hook
    21512415        if ( !apply_filters( 'disable_captions', '' ) ) {
    21522416                $caption = '
    21532417                <tr class="image-only">
     
    24302694        $meta = wp_get_attachment_metadata( $post->ID );
    24312695        if ( isset( $meta['width'], $meta['height'] ) )
    24322696                $media_dims .= "<span id='media-dims-$post->ID'>{$meta['width']}&nbsp;&times;&nbsp;{$meta['height']}</span> ";
     2697        //duplicate_hook
    24332698        $media_dims = apply_filters( 'media_meta', $media_dims, $post );
    24342699
    24352700        $att_url = wp_get_attachment_url( $post->ID );