Make WordPress Core

Ticket #26979: 26979.2.diff

File 26979.2.diff, 2.7 KB (added by adamsilverstein, 12 years ago)

docs corrections, cleanup

  • src/wp-includes/revision.php

     
    3333                        'post_excerpt' => __( 'Excerpt' ),
    3434                );
    3535
    36                 // Runs only once
     36                /**
     37                 * Filter the list of fields saved in post revisions.
     38                 *
     39                 * Included by default: 'post_title', 'post_content' and 'post_excerpt'.
     40                 *
     41                 * Dissalowed: 'ID', 'post_name', 'post_parent', 'post_date', 'post_date_gmt', 'post_status', 'post_type',
     42                 *     'comment_count' and 'post_author'.
     43                 *
     44                 * @since 2.5.1
     45                 *
     46                 * @param array $fields List of fields to revision. Contains 'post_title', 'post_content',
     47                 *                      and 'post_excerpt' by default.
     48                 *
     49                 */
    3750                $fields = apply_filters( '_wp_post_revision_fields', $fields );
    3851
    3952                // WP uses these internally either in versioning or elsewhere - they cannot be versioned
     
    99112                        }
    100113                }
    101114
    102                 if ( isset( $last_revision ) && apply_filters( 'wp_save_post_revision_check_for_changes', true, $last_revision, $post ) ) {
     115                /**
     116                 * Override check for chages in revisioned fields before saving a new revision.
     117                 *
     118                 * By default a revision is saved only if one of the revisioned fields has changed.
     119                 * This filter can override that so a revision is saved even if nothing has changed.
     120                 *
     121                 * @since 3.6.0
     122                 *
     123                 * @param boolean $check_for_changes Check for changes before saving revision? Default true.
     124                 *                                   Return false to bypass and save a new revision regardless.
     125                 * @param int     $last_revision     The ID of the last revision.
     126                 * @param int     $post              The ID of the post being saved as a revision.
     127                 *
     128                 */
     129                if ( isset( $last_revision ) && apply_filters( 'wp_save_post_revision_check_for_changes', $check_for_changes = true, $last_revision, $post ) ) {
    103130                        $post_has_changed = false;
    104131
    105132                        foreach ( array_keys( _wp_post_revision_fields() ) as $field ) {
     
    422449        if ( ! post_type_supports( $post->post_type, 'revisions' ) )
    423450                $num = 0;
    424451
     452        /**
     453         * Filter the number of revisions to save.
     454         *
     455         * Allows setting the number of revisions to save, overriding the default behaviour of saving
     456         * an unlimited number of revsions. Overrides WP_POST_REVISIONS setting from wp-config.php (if any).
     457         *
     458         * @since 3.6.0
     459         *
     460         * @param int    $num  The number of revisions the store, overrides WP_POST_REVISIONS value.
     461         *                     Older revisions are discarded when a new revision is added.
     462         * @param object $post The post object.
     463         *
     464         */
    425465        return (int) apply_filters( 'wp_revisions_to_keep', $num, $post );
    426466}
    427467