Changeset 53715 for trunk/src/wp-includes/revision.php
- Timestamp:
- 07/18/2022 05:35:51 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/revision.php
r53300 r53715 113 113 114 114 $post = get_post( $post_id ); 115 115 116 if ( ! $post ) { 116 117 return; … … 276 277 function wp_is_post_revision( $post ) { 277 278 $post = wp_get_post_revision( $post ); 279 278 280 if ( ! $post ) { 279 281 return false; … … 293 295 function wp_is_post_autosave( $post ) { 294 296 $post = wp_get_post_revision( $post ); 297 295 298 if ( ! $post ) { 296 299 return false; … … 356 359 * @since 2.6.0 357 360 * 358 * @param int|WP_Post $post The post ID orobject.361 * @param int|WP_Post $post Post ID or post object. 359 362 * @param string $output Optional. The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which 360 363 * correspond to a WP_Post object, an associative array, or a numeric array, … … 365 368 function wp_get_post_revision( &$post, $output = OBJECT, $filter = 'raw' ) { 366 369 $revision = get_post( $post, OBJECT, $filter ); 370 367 371 if ( ! $revision ) { 368 372 return $revision; 369 373 } 374 370 375 if ( 'revision' !== $revision->post_type ) { 371 376 return null; … … 392 397 * @since 2.6.0 393 398 * 394 * @param int|WP_Post $revision _idRevision ID or revision object.395 * @param array $fields 399 * @param int|WP_Post $revision Revision ID or revision object. 400 * @param array $fields Optional. What fields to restore from. Defaults to all. 396 401 * @return int|false|null Null if error, false if no fields to restore, (int) post ID if success. 397 402 */ 398 function wp_restore_post_revision( $revision_id, $fields = null ) { 399 $revision = wp_get_post_revision( $revision_id, ARRAY_A ); 403 function wp_restore_post_revision( $revision, $fields = null ) { 404 $revision = wp_get_post_revision( $revision, ARRAY_A ); 405 400 406 if ( ! $revision ) { 401 407 return $revision; … … 420 426 421 427 $post_id = wp_update_post( $update ); 428 422 429 if ( ! $post_id || is_wp_error( $post_id ) ) { 423 430 return $post_id; … … 447 454 * @since 2.6.0 448 455 * 449 * @param int|WP_Post $revision _idRevision ID or revision object.456 * @param int|WP_Post $revision Revision ID or revision object. 450 457 * @return WP_Post|false|null Null or false if error, deleted post object if success. 451 458 */ 452 function wp_delete_post_revision( $revision_id ) { 453 $revision = wp_get_post_revision( $revision_id ); 459 function wp_delete_post_revision( $revision ) { 460 $revision = wp_get_post_revision( $revision ); 461 454 462 if ( ! $revision ) { 455 463 return $revision; … … 457 465 458 466 $delete = wp_delete_post( $revision->ID ); 467 459 468 if ( $delete ) { 460 469 /** … … 479 488 * @see get_children() 480 489 * 481 * @param int|WP_Post $post _idOptional. Post ID or WP_Post object. Default is global `$post`.482 * @param array|null $args 490 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global `$post`. 491 * @param array|null $args Optional. Arguments for retrieving post revisions. Default null. 483 492 * @return array An array of revisions, or an empty array if none. 484 493 */ 485 function wp_get_post_revisions( $post_id = 0, $args = null ) { 486 $post = get_post( $post_id ); 494 function wp_get_post_revisions( $post = 0, $args = null ) { 495 $post = get_post( $post ); 496 487 497 if ( ! $post || empty( $post->ID ) ) { 488 498 return array(); … … 510 520 511 521 $revisions = get_children( $args ); 522 512 523 if ( ! $revisions ) { 513 524 return array(); … … 522 533 * @since 5.9.0 523 534 * 524 * @param int|WP_Post $post _idOptional. Post ID or WP_Post object. Default is global `$post`.535 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global `$post`. 525 536 * @return null|string The URL for editing revisions on the given post, otherwise null. 526 537 */ 527 function wp_get_post_revisions_url( $post _id= 0 ) {528 $post = get_post( $post _id);538 function wp_get_post_revisions_url( $post = 0 ) { 539 $post = get_post( $post ); 529 540 530 541 if ( ! $post instanceof WP_Post ) { … … 685 696 function _wp_preview_terms_filter( $terms, $post_id, $taxonomy ) { 686 697 $post = get_post(); 698 687 699 if ( ! $post ) { 688 700 return $terms; … … 720 732 function _wp_preview_post_thumbnail_filter( $value, $post_id, $meta_key ) { 721 733 $post = get_post(); 734 722 735 if ( ! $post ) { 723 736 return $value; … … 735 748 736 749 $thumbnail_id = (int) $_REQUEST['_thumbnail_id']; 750 737 751 if ( $thumbnail_id <= 0 ) { 738 752 return ''; … … 784 798 $now = time(); 785 799 $result = $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO `$wpdb->options` (`option_name`, `option_value`, `autoload`) VALUES (%s, %s, 'no') /* LOCK */", $lock, $now ) ); 800 786 801 if ( ! $result ) { 787 802 // If we couldn't get a lock, see how old the previous lock is. 788 803 $locked = get_option( $lock ); 804 789 805 if ( ! $locked ) { 790 806 // Can't write to the lock, and can't read the lock.
Note: See TracChangeset
for help on using the changeset viewer.