Make WordPress Core


Ignore:
Timestamp:
03/24/2014 01:48:40 AM (11 years ago)
Author:
DrewAPicture
Message:

Inline documentation for hooks in wp-admin/includes/post.php.

Also moves the primary PHPDoc for the edit_posts_per_page hook to wp-admin/includes/post.php.

Props kpdesign for some cleanup.
Fixes #27431.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/post.php

    r27612 r27667  
    275275
    276276        $attachment_data = isset( $post_data['attachments'][ $post_ID ] ) ? $post_data['attachments'][ $post_ID ] : array();
     277
    277278        /** This filter is documented in wp-admin/includes/media.php */
    278279        $post_data = apply_filters( 'attachment_fields_to_save', $post_data, $attachment_data );
     
    496497    }
    497498
     499    /**
     500     * Filter the default post content initially used in the "Write Post" form.
     501     *
     502     * @since 1.5.0
     503     *
     504     * @param string  $post_content Default post content.
     505     * @param WP_Post $post         Post object.
     506     */
    498507    $post->post_content = apply_filters( 'default_content', $post_content, $post );
    499     $post->post_title   = apply_filters( 'default_title',   $post_title, $post   );
     508
     509    /**
     510     * Filter the default post title initially used in the "Write Post" form.
     511     *
     512     * @since 1.5.0
     513     *
     514     * @param string  $post_title Default post title.
     515     * @param WP_Post $post       Post object.
     516     */
     517    $post->post_title = apply_filters( 'default_title', $post_title, $post );
     518
     519    /**
     520     * Filter the default post excerpt initially used in the "Write Post" form.
     521     *
     522     * @since 1.5.0
     523     *
     524     * @param string  $post_excerpt Default post excerpt.
     525     * @param WP_Post $post         Post object.
     526     */
    500527    $post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt, $post );
    501528    $post->post_name = '';
     
    866893        $posts_per_page = 20;
    867894
     895    /**
     896     * Filter the number of items per page to show for a specific 'per_page' type.
     897     *
     898     * The dynamic hook name, $per_page, refers to a hook name comprised of the post type,
     899     * preceded by 'edit_', and succeeded by '_per_page', e.g. 'edit_$post_type_per_page'.
     900     *
     901     * Some examples of filter hooks generated here include: 'edit_attachment_per_page',
     902     * 'edit_post_per_page', 'edit_page_per_page', etc.
     903     *
     904     * @since 3.0.0
     905     *
     906     * @param int $posts_per_page Number of posts to display per page for the given 'per_page'
     907     *                            type. Default 20.
     908     */
    868909    $posts_per_page = apply_filters( $per_page, $posts_per_page );
     910
     911    /**
     912     * Filter the number of posts displayed per page when specifically listing "posts".
     913     *
     914     * @since 2.8.0
     915     *
     916     * @param int    $per_page  Number of posts to be displayed. Default 20.
     917     * @param string $post_type The post type.
     918     */
    869919    $posts_per_page = apply_filters( 'edit_posts_per_page', $posts_per_page, $post_type );
    870920
     
    907957 *
    908958 * @since 2.5.0
    909  * @uses apply_filters() Calls 'upload_per_page' on posts_per_page argument
    910959 *
    911960 * @param array|bool $q Array of query variables to use to build the query or false to use $_GET superglobal.
     
    928977    if ( empty( $media_per_page ) || $media_per_page < 1 )
    929978        $media_per_page = 20;
     979
     980    /**
     981     * Filter the number of items to list per page when listing media items.
     982     *
     983     * @since 2.9.0
     984     *
     985     * @param int $media_per_page Number of media to list. Default 20.
     986     */
    930987    $q['posts_per_page'] = apply_filters( 'upload_per_page', $media_per_page );
    931988
     
    9671024    }
    9681025
     1026    /**
     1027     * Filter the postbox classes for a specific screen and screen ID combo.
     1028     *
     1029     * The dynamic portions of the hook name, $page, and $id, refer to
     1030     * the screen, and screen ID, respectively.
     1031     *
     1032     * @since 3.2.0
     1033     *
     1034     * @param array $classes An array of postbox classes.
     1035     */
    9691036    $classes = apply_filters( "postbox_classes_{$page}_{$id}", $classes );
    9701037    return implode( ' ', $classes );
     
    10181085        $uri = strrev( stristr( strrev( $uri ), '/' ) );
    10191086        $uri = untrailingslashit($uri);
     1087
     1088        /** This filter is documented in wp-admin/edit-tag-form.php */
    10201089        $uri = apply_filters( 'editable_slug', $uri );
    10211090        if ( !empty($uri) )
     
    10241093    }
    10251094
    1026     $permalink = array($permalink, apply_filters('editable_slug', $post->post_name));
     1095    /** This filter is documented in wp-admin/edit-tag-form.php */
     1096    $permalink = array( $permalink, apply_filters( 'editable_slug', $post->post_name ) );
    10271097    $post->post_status = $original_status;
    10281098    $post->post_date = $original_date;
     
    10681138            $return .= "<span id='view-post-btn'><a href='$permalink' class='button button-small'>$view_post</a></span>\n";
    10691139
    1070         $return = apply_filters('get_sample_permalink_html', $return, $id, $new_title, $new_slug);
     1140        /**
     1141         * Filter the sample permalink HTML markup.
     1142         *
     1143         * @since 2.9.0
     1144         *
     1145         * @param string      $return    Sample permalink HTML markup.
     1146         * @param int|WP_Post $id        Post object or ID.
     1147         * @param string      $new_title New sample permalink title.
     1148         * @param string      $new_slug  New sample permalink slug.
     1149         */
     1150        $return = apply_filters( 'get_sample_permalink_html', $return, $id, $new_title, $new_slug );
    10711151
    10721152        return $return;
     
    11001180    }
    11011181
    1102     $return = apply_filters('get_sample_permalink_html', $return, $id, $new_title, $new_slug);
     1182    /** This filter is documented in wp-admin/includes/post.php */
     1183    $return = apply_filters( 'get_sample_permalink_html', $return, $id, $new_title, $new_slug );
    11031184
    11041185    return $return;
     
    11381219    }
    11391220
     1221    /**
     1222     * Filter the admin post thumbnail HTML markup to return.
     1223     *
     1224     * @since 2.9.0
     1225     *
     1226     * @param string $content Admin post thumbnail HTML markup.
     1227     * @param int    $post_id Post ID.
     1228     */
    11401229    return apply_filters( 'admin_post_thumbnail_html', $content, $post->ID );
    11411230}
     
    11601249    $user = isset( $lock[1] ) ? $lock[1] : get_post_meta( $post->ID, '_edit_last', true );
    11611250
     1251    /** This filter is documented in wp-admin/includes/ajax-actions.php */
    11621252    $time_window = apply_filters( 'wp_check_post_lock_window', 150 );
    11631253
     
    12041294
    12051295    if ( $user ) {
     1296
     1297        /**
     1298         * Filter whether to show the post locked dialog.
     1299         *
     1300         * Returning a falsey value to the filter will short-circuit displaying the dialog.
     1301         *
     1302         * @since 3.6.0
     1303         *
     1304         * @param bool         $display Whether to display the dialog. Default true.
     1305         * @param WP_User|bool $user    WP_User object on success, false otherwise.
     1306         */
    12061307        if ( ! apply_filters( 'show_post_locked_dialog', true, $post, $user ) )
    12071308            return;
     
    12461347        }
    12471348
     1349        /** This filter is documented in wp-admin/includes/meta-boxes.php */
    12481350        $preview_link = apply_filters( 'preview_post_link', $preview_link );
     1351
     1352        /**
     1353         * Filter whether to allow the post lock to be overridden.
     1354         *
     1355         * Returning a falsey value to the filter will disable the ability
     1356         * to override the post lock.
     1357         *
     1358         * @since 3.6.0
     1359         *
     1360         * @param bool    $override Whether to allow overriding post locks. Default true.
     1361         * @param WP_Post $post     Post object.
     1362         * @param WP_User $user     User object.
     1363         */
    12491364        $override = apply_filters( 'override_post_lock', true, $post, $user );
    12501365        $tab_last = $override ? '' : ' wp-tab-last';
     
    12601375        ?>
    12611376        </p>
    1262         <?php do_action( 'post_locked_dialog', $post ); ?>
     1377        <?php
     1378        /**
     1379         * Fires inside the post locked dialog before the buttons are displayed.
     1380         *
     1381         * @since 3.6.0
     1382         *
     1383         * @param WP_Post $post Post object.
     1384         */
     1385        do_action( 'post_locked_dialog', $post );
     1386        ?>
    12631387        <p>
    12641388        <a class="button" href="<?php echo esc_url( $sendback ); ?>"><?php echo $sendback_text; ?></a>
     
    12881412            <span class="locked-saved hidden"><?php _e('Your latest changes were saved as a revision.'); ?></span>
    12891413            </p>
    1290             <?php do_action( 'post_lock_lost_dialog', $post ); ?>
     1414            <?php
     1415            /**
     1416             * Fires inside the dialog displayed when a user has lost the post lock.
     1417             *
     1418             * @since 3.6.0
     1419             *
     1420             * @param WP_Post $post Post object.
     1421             */
     1422            do_action( 'post_lock_lost_dialog', $post );
     1423            ?>
    12911424            <p><a class="button button-primary wp-tab-last" href="<?php echo esc_url( $sendback ); ?>"><?php echo $sendback_text; ?></a></p>
    12921425        </div>
     
    14151548
    14161549    $url = add_query_arg( $query_args, get_permalink( $post->ID ) );
     1550
     1551    /** This filter is documented in wp-admin/includes/meta-boxes.php */
    14171552    return apply_filters( 'preview_post_link', $url );
    14181553}
Note: See TracChangeset for help on using the changeset viewer.