Ticket #26979: 26979.3.diff
| File 26979.3.diff, 4.5 KB (added by , 12 years ago) |
|---|
-
src/wp-includes/revision.php
16 16 * @since 2.6.0 17 17 * @access private 18 18 * 19 * @uses apply_filters() Calls '_wp_post_revision_fields' on 'title', 'content' and 'excerpt' fields.20 *21 19 * @param array $post Optional a post array to be processed for insertion as a post revision. 22 20 * @param bool $autosave optional Is the revision an autosave? 23 21 * @return array Post array ready to be inserted as a post revision or array of fields that can be versioned. … … 33 31 'post_excerpt' => __( 'Excerpt' ), 34 32 ); 35 33 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 * 48 */ 37 49 $fields = apply_filters( '_wp_post_revision_fields', $fields ); 38 50 39 51 // WP uses these internally either in versioning or elsewhere - they cannot be versioned … … 99 111 } 100 112 } 101 113 102 if ( isset( $last_revision ) && apply_filters( 'wp_save_post_revision_check_for_changes', true, $last_revision, $post ) ) { 114 /** 115 * Filter whether the post has changed since the last revision. 116 * 117 * By default a revision is saved only if one of the revisioned fields has changed. 118 * This filter can override that so a revision is saved even if nothing has changed. 119 * 120 * @since 3.6.0 121 * 122 * @param bool $check_for_changes Whether to check for changes before saving a new revision. 123 * Default true. 124 * @param int $last_revision ID of the last revision. 125 * @param int $post Post ID. 126 * 127 */ 128 if ( isset( $last_revision ) && apply_filters( 'wp_save_post_revision_check_for_changes', $check_for_changes = true, $last_revision, $post ) ) { 103 129 $post_has_changed = false; 104 130 105 131 foreach ( array_keys( _wp_post_revision_fields() ) as $field ) { … … 237 263 if ( is_wp_error($revision_id) ) 238 264 return $revision_id; 239 265 240 if ( $revision_id ) 266 if ( $revision_id ) { 267 /** 268 * Fires once a revision has been saved. 269 * 270 * @since 2.6.0 271 * 272 * @param int $revision_id Post revision ID. 273 */ 241 274 do_action( '_wp_put_post_revision', $revision_id ); 275 } 242 276 243 277 return $revision_id; 244 278 } … … 283 317 * 284 318 * @uses wp_get_post_revision() 285 319 * @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.288 320 * 289 321 * @param int|object $revision_id Revision ID or revision object. 290 322 * @param array $fields Optional. What fields to restore from. Defaults to all. … … 324 356 // Update last edit user 325 357 update_post_meta( $post_id, '_edit_last', get_current_user_id() ); 326 358 359 /** 360 * Fires after a post revision has been restored. 361 * 362 * @since 2.6.0 363 * 364 * @param int $post_id Post ID. 365 * @param int $revision_id Post revision ID. 366 */ 327 367 do_action( 'wp_restore_post_revision', $post_id, $revision['ID'] ); 328 368 329 369 return $post_id; … … 350 390 if ( is_wp_error( $delete ) ) 351 391 return $delete; 352 392 353 if ( $delete ) 393 if ( $delete ) { 394 /** 395 * Fires once a post revision has been deleted. 396 * 397 * @since 2.6.0 398 * 399 * @param int $revision_id Post revision ID. 400 * @param object|array $revision Post revision object or array. 401 */ 354 402 do_action( 'wp_delete_post_revision', $revision->ID, $revision ); 403 } 355 404 356 405 return $delete; 357 406 } … … 406 455 * @since 3.6.0 407 456 * 408 457 * @uses post_type_supports() 409 * @uses apply_filters() Calls 'wp_revisions_to_keep' hook on the number of revisions.410 458 * 411 459 * @param object $post The post object. 412 460 * @return int The number of revisions to keep. … … 422 470 if ( ! post_type_supports( $post->post_type, 'revisions' ) ) 423 471 $num = 0; 424 472 473 /** 474 * Filter the number of revisions to save for the given post. 475 * 476 * Overrides the value of WP_POST_REVISIONS. 477 * 478 * @since 3.6.0 479 * 480 * @param int $num Number of revisions to store. 481 * @param WP_Post $post Post object. 482 */ 425 483 return (int) apply_filters( 'wp_revisions_to_keep', $num, $post ); 426 484 } 427 485