WordPress.org

Make WordPress Core

Changeset 27699


Ignore:
Timestamp:
03/25/2014 08:59:55 AM (4 years ago)
Author:
DrewAPicture
Message:

Inline documentation for hooks in wp-includes/revision.php.

Props adamsilverstein, DrewAPicture.
Fixes #26979.

File:
1 edited

Legend:

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

    r27683 r27699  
    1616 * @since 2.6.0
    1717 * @access private
    18  *
    19  * @uses apply_filters() Calls '_wp_post_revision_fields' on 'title', 'content' and 'excerpt' fields.
    2018 *
    2119 * @param array $post Optional a post array to be processed for insertion as a post revision.
     
    3432        );
    3533
    36         // Runs only once
     34        /**
     35         * Filter the list of fields saved in post revisions.
     36         *
     37         * Included by default: 'post_title', 'post_content' and 'post_excerpt'.
     38         *
     39         * Disallowed fields: 'ID', 'post_name', 'post_parent', 'post_date',
     40         * 'post_date_gmt', 'post_status', 'post_type', 'comment_count',
     41         * and 'post_author'.
     42         *
     43         * @since 2.6.0
     44         *
     45         * @param array $fields List of fields to revision. Contains 'post_title',
     46         *                      'post_content', and 'post_excerpt' by default.
     47         */
    3748        $fields = apply_filters( '_wp_post_revision_fields', $fields );
    3849
     
    100111        }
    101112
    102         if ( isset( $last_revision ) && apply_filters( 'wp_save_post_revision_check_for_changes', true, $last_revision, $post ) ) {
     113        /**
     114         * Filter whether the post has changed since the last revision.
     115         *
     116         * By default a revision is saved only if one of the revisioned fields has changed.
     117         * This filter can override that so a revision is saved even if nothing has changed.
     118         *
     119         * @since 3.6.0
     120         *
     121         * @param bool $check_for_changes Whether to check for changes before saving a new revision.
     122         *                                Default true.
     123         * @param int  $last_revision     ID of the last revision.
     124         * @param int  $post              Post ID.
     125         *
     126         */
     127        if ( isset( $last_revision ) && apply_filters( 'wp_save_post_revision_check_for_changes', $check_for_changes = true, $last_revision, $post ) ) {
    103128            $post_has_changed = false;
    104129
     
    238263        return $revision_id;
    239264
    240     if ( $revision_id )
     265    if ( $revision_id ) {
     266        /**
     267         * Fires once a revision has been saved.
     268         *
     269         * @since 2.6.0
     270         *
     271         * @param int $revision_id Post revision ID.
     272         */
    241273        do_action( '_wp_put_post_revision', $revision_id );
     274    }
    242275
    243276    return $revision_id;
     
    284317 * @uses wp_get_post_revision()
    285318 * @uses wp_update_post()
    286  * @uses do_action() Calls 'wp_restore_post_revision' on post ID and revision ID if wp_update_post()
    287  *  is successful.
    288319 *
    289320 * @param int|object $revision_id Revision ID or revision object.
     
    325356    update_post_meta( $post_id, '_edit_last', get_current_user_id() );
    326357
     358    /**
     359     * Fires after a post revision has been restored.
     360     *
     361     * @since 2.6.0
     362     *
     363     * @param int $post_id     Post ID.
     364     * @param int $revision_id Post revision ID.
     365     */
    327366    do_action( 'wp_restore_post_revision', $post_id, $revision['ID'] );
    328367
     
    351390        return $delete;
    352391
    353     if ( $delete )
     392    if ( $delete ) {
     393        /**
     394         * Fires once a post revision has been deleted.
     395         *
     396         * @since 2.6.0
     397         *
     398         * @param int          $revision_id Post revision ID.
     399         * @param object|array $revision    Post revision object or array.
     400         */
    354401        do_action( 'wp_delete_post_revision', $revision->ID, $revision );
     402    }
    355403
    356404    return $delete;
     
    407455 *
    408456 * @uses post_type_supports()
    409  * @uses apply_filters() Calls 'wp_revisions_to_keep' hook on the number of revisions.
    410457 *
    411458 * @param object $post The post object.
     
    423470        $num = 0;
    424471
     472    /**
     473     * Filter the number of revisions to save for the given post.
     474     *
     475     * Overrides the value of WP_POST_REVISIONS.
     476     *
     477     * @since 3.6.0
     478     *
     479     * @param int     $num  Number of revisions to store.
     480     * @param WP_Post $post Post object.
     481     */
    425482    return (int) apply_filters( 'wp_revisions_to_keep', $num, $post );
    426483}
Note: See TracChangeset for help on using the changeset viewer.