Make WordPress Core

Changeset 53715


Ignore:
Timestamp:
07/18/2022 05:35:51 PM (21 months ago)
Author:
SergeyBiryukov
Message:

Posts, Post Types: Standardize on $post parameter name where appropriate.

This renames the $post_id or $id parameters to $post for functions that accept a post ID or post object:

  • get_sample_permalink()
  • get_sample_permalink_html()
  • wp_check_post_lock()
  • wp_set_post_lock()
  • get_the_tags()
  • comment_class()
  • get_comment_class()
  • get_comments_link()
  • get_comments_number()
  • comments_number()
  • get_comments_number_text()
  • comments_open()
  • pings_open()
  • comment_form()
  • do_trackbacks()
  • pingback()
  • post_permalink()
  • get_post_permalink()
  • get_edit_post_link()
  • edit_post_link()
  • get_delete_post_link()
  • post_class()
  • get_post_class()
  • the_attachment_link()
  • wp_get_attachment_link()
  • wp_list_post_revisions()
  • check_and_publish_future_post()
  • add_ping()
  • get_pung()
  • get_to_ping()
  • wp_get_post_revisions()
  • wp_get_post_revisions_url()

Additionally, $revision_id is renamed to $revision in:

  • wp_restore_post_revision()
  • wp_delete_post_revision()

Includes minor documentation improvements for consistency and code layout fixes for better readability.

Follow-up to [1599], [1794], [2881], [3303], [3851], [5302], [6633], [6716], [6985], [7103], [7149], [7747], [8011], [8638], [8643], [8695], [9138], [9273], [11425], [11922], [11956], [12284], [12810], [12923], [13023], [13171], [25567], [27156], [27473], [28558], [28602], [33659], [38852], [47276], [47366], [48622], [49544], [49597], [52095].

See #56243, #55647.

Location:
trunk/src
Files:
12 edited

Legend:

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

    r53559 r53715  
    13771377 * @since 2.5.0
    13781378 *
    1379  * @param int|WP_Post $id    Post ID or post object.
     1379 * @param int|WP_Post $post  Post ID or post object.
    13801380 * @param string|null $title Optional. Title to override the post's current title
    13811381 *                           when generating the post name. Default null.
     
    13881388 * }
    13891389 */
    1390 function get_sample_permalink( $id, $title = null, $name = null ) {
    1391     $post = get_post( $id );
     1390function get_sample_permalink( $post, $title = null, $name = null ) {
     1391    $post = get_post( $post );
     1392
    13921393    if ( ! $post ) {
    13931394        return array( '', '' );
     
    14691470 * @since 2.5.0
    14701471 *
    1471  * @param int|WP_Post $id        Post ID or post object.
     1472 * @param int|WP_Post $post      Post ID or post object.
    14721473 * @param string|null $new_title Optional. New title. Default null.
    14731474 * @param string|null $new_slug  Optional. New slug. Default null.
    14741475 * @return string The HTML of the sample permalink slug editor.
    14751476 */
    1476 function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) {
    1477     $post = get_post( $id );
     1477function get_sample_permalink_html( $post, $new_title = null, $new_slug = null ) {
     1478    $post = get_post( $post );
     1479
    14781480    if ( ! $post ) {
    14791481        return '';
     
    15121514        // Encourage a pretty permalink setting.
    15131515        if ( ! get_option( 'permalink_structure' ) && current_user_can( 'manage_options' )
    1514             && ! ( 'page' === get_option( 'show_on_front' ) && get_option( 'page_on_front' ) == $id )
     1516            && ! ( 'page' === get_option( 'show_on_front' ) && get_option( 'page_on_front' ) == $post->ID )
    15151517        ) {
    15161518            $return .= '<span id="change-permalinks"><a href="options-permalink.php" class="button button-small">' . __( 'Change Permalink Structure' ) . "</a></span>\n";
     
    16291631 * @since 2.5.0
    16301632 *
    1631  * @param int|WP_Post $post_id ID or object of the post to check for editing.
     1633 * @param int|WP_Post $post ID or object of the post to check for editing.
    16321634 * @return int|false ID of the user with lock. False if the post does not exist, post is not locked,
    16331635 *                   the user with lock does not exist, or the post is locked by current user.
    16341636 */
    1635 function wp_check_post_lock( $post_id ) {
    1636     $post = get_post( $post_id );
     1637function wp_check_post_lock( $post ) {
     1638    $post = get_post( $post );
     1639
    16371640    if ( ! $post ) {
    16381641        return false;
     
    16401643
    16411644    $lock = get_post_meta( $post->ID, '_edit_lock', true );
     1645
    16421646    if ( ! $lock ) {
    16431647        return false;
     
    16671671 * @since 2.5.0
    16681672 *
    1669  * @param int|WP_Post $post_id ID or object of the post being edited.
     1673 * @param int|WP_Post $post ID or object of the post being edited.
    16701674 * @return array|false {
    16711675 *     Array of the lock time and user ID. False if the post does not exist, or there
     
    16761680 * }
    16771681 */
    1678 function wp_set_post_lock( $post_id ) {
    1679     $post = get_post( $post_id );
     1682function wp_set_post_lock( $post ) {
     1683    $post = get_post( $post );
     1684
    16801685    if ( ! $post ) {
    16811686        return false;
     
    16831688
    16841689    $user_id = get_current_user_id();
     1690
    16851691    if ( 0 == $user_id ) {
    16861692        return false;
     
    17021708function _admin_notice_post_locked() {
    17031709    $post = get_post();
     1710
    17041711    if ( ! $post ) {
    17051712        return;
     
    17081715    $user    = null;
    17091716    $user_id = wp_check_post_lock( $post->ID );
     1717
    17101718    if ( $user_id ) {
    17111719        $user = get_userdata( $user_id );
     
    19371945
    19381946    $post = get_post( $post_ID );
     1947
    19391948    if ( ! $post ) {
    19401949        wp_die( __( 'Sorry, you are not allowed to edit this post.' ) );
  • trunk/src/wp-includes/category-template.php

    r53543 r53715  
    9191     *
    9292     * @since 3.1.0
    93      * @since 4.4.0 Added `$post_id` parameter.
     93     * @since 4.4.0 Added the `$post_id` parameter.
    9494     *
    9595     * @param WP_Term[] $categories An array of categories to return for the post.
    96      * @param int|false $post_id    ID of the post.
     96     * @param int|false $post_id    The post ID.
    9797     */
    9898    return apply_filters( 'get_the_categories', $categories, $post_id );
     
    134134 * @param string $separator Optional. Separator between the categories. By default, the links are placed
    135135 *                          in an unordered list. An empty string will result in the default behavior.
    136  * @param string $parents   Optional. How to display the parents.
    137  * @param int    $post_id   Optional. Post ID to retrieve categories.
     136 * @param string $parents   Optional. How to display the parents. Accepts 'multiple', 'single', or empty.
     137 *                          Default empty string.
     138 * @param int    $post_id   Optional. ID of the post to retrieve categories for. Defaults to the current post.
    138139 * @return string Category list for a post.
    139140 */
     
    152153     *
    153154     * @param WP_Term[] $categories An array of the post's categories.
    154      * @param int|bool  $post_id    ID of the post we're retrieving categories for.
    155      *                              When `false`, we assume the current post in the loop.
     155     * @param int|false $post_id    ID of the post to retrieve categories for.
     156     *                              When `false`, defaults to the current post in the loop.
    156157     */
    157158    $categories = apply_filters( 'the_category_list', get_the_category( $post_id ), $post_id );
     
    251252 * @param int|string|int[]|string[] $category Category ID, name, slug, or array of such
    252253 *                                            to check against.
    253  * @param int|object                $post     Optional. Post to check instead of the current post.
     254 * @param int|WP_Post               $post     Optional. Post to check. Defaults to the current post.
    254255 * @return bool True if the current post is in any of the given categories.
    255256 */
     
    269270 * @param string $separator Optional. Separator between the categories. By default, the links are placed
    270271 *                          in an unordered list. An empty string will result in the default behavior.
    271  * @param string $parents   Optional. How to display the parents.
    272  * @param int    $post_id   Optional. Post ID to retrieve categories.
     272 * @param string $parents   Optional. How to display the parents. Accepts 'multiple', 'single', or empty.
     273 *                          Default empty string.
     274 * @param int    $post_id   Optional. ID of the post to retrieve categories for. Defaults to the current post.
    273275 */
    274276function the_category( $separator = '', $parents = '', $post_id = false ) {
     
    11621164 * @since 2.3.0
    11631165 *
    1164  * @param int|WP_Post $post_id Post ID or object.
     1166 * @param int|WP_Post $post Post ID or object.
    11651167 * @return WP_Term[]|false|WP_Error Array of WP_Term objects on success, false if there are no terms
    11661168 *                                  or the post does not exist, WP_Error on failure.
    11671169 */
    1168 function get_the_tags( $post_id = 0 ) {
    1169     $terms = get_the_terms( $post_id, 'post_tag' );
     1170function get_the_tags( $post = 0 ) {
     1171    $terms = get_the_terms( $post, 'post_tag' );
    11701172
    11711173    /**
     
    12791281function get_the_terms( $post, $taxonomy ) {
    12801282    $post = get_post( $post );
     1283
    12811284    if ( ! $post ) {
    12821285        return false;
     
    12841287
    12851288    $terms = get_object_term_cache( $post->ID, $taxonomy );
     1289
    12861290    if ( false === $terms ) {
    12871291        $terms = wp_get_object_terms( $post->ID, $taxonomy );
     
    14771481 * @param string|int|array $category Optional. The category name/term_id/slug,
    14781482 *                                   or an array of them to check for. Default empty.
    1479  * @param int|object       $post     Optional. Post to check instead of the current post.
     1483 * @param int|WP_Post      $post     Optional. Post to check. Defaults to the current post.
    14801484 * @return bool True if the current post has any of the given categories
    14811485 *              (or any category, if no category specified). False otherwise.
     
    15041508 * @param string|int|array $tag  Optional. The tag name/term_id/slug,
    15051509 *                               or an array of them to check for. Default empty.
    1506  * @param int|object       $post Optional. Post to check instead of the current post.
     1510 * @param int|WP_Post      $post Optional. Post to check. Defaults to the current post.
    15071511 * @return bool True if the current post has any of the given tags
    15081512 *              (or any tag, if no tag specified). False otherwise.
     
    15251529 *                                   or an array of them to check for. Default empty.
    15261530 * @param string           $taxonomy Optional. Taxonomy name. Default empty.
    1527  * @param int|WP_Post      $post     Optional. Post to check instead of the current post.
     1531 * @param int|WP_Post      $post     Optional. Post to check. Defaults to the current post.
    15281532 * @return bool True if the current post has any of the given terms
    15291533 *              (or any term, if no term specified). False otherwise.
  • trunk/src/wp-includes/comment-template.php

    r53576 r53715  
    427427 *                                   Default empty.
    428428 * @param int|WP_Comment  $comment   Comment ID or WP_Comment object. Default current comment.
    429  * @param int|WP_Post     $post_id   Post ID or WP_Post object. Default current post.
     429 * @param int|WP_Post     $post      Post ID or WP_Post object. Default current post.
    430430 * @param bool            $display   Optional. Whether to print or return the output.
    431431 *                                   Default true.
    432432 * @return void|string Void if `$display` argument is true, comment classes if `$display` is false.
    433433 */
    434 function comment_class( $css_class = '', $comment = null, $post_id = null, $display = true ) {
     434function comment_class( $css_class = '', $comment = null, $post = null, $display = true ) {
    435435    // Separates classes with a single space, collates classes for comment DIV.
    436     $css_class = 'class="' . implode( ' ', get_comment_class( $css_class, $comment, $post_id ) ) . '"';
     436    $css_class = 'class="' . implode( ' ', get_comment_class( $css_class, $comment, $post ) ) . '"';
    437437
    438438    if ( $display ) {
     
    455455 * @param string|string[] $css_class  Optional. One or more classes to add to the class list. Default empty.
    456456 * @param int|WP_Comment  $comment_id Comment ID or WP_Comment object. Default current comment.
    457  * @param int|WP_Post     $post_id    Post ID or WP_Post object. Default current post.
     457 * @param int|WP_Post     $post       Post ID or WP_Post object. Default current post.
    458458 * @return string[] An array of classes.
    459459 */
    460 function get_comment_class( $css_class = '', $comment_id = null, $post_id = null ) {
     460function get_comment_class( $css_class = '', $comment_id = null, $post = null ) {
    461461    global $comment_alt, $comment_depth, $comment_thread_alt;
    462462
     
    477477        $classes[] = 'comment-author-' . sanitize_html_class( $user->user_nicename, $comment->user_id );
    478478        // For comment authors who are the author of the post.
    479         $post = get_post( $post_id );
    480         if ( $post ) {
    481             if ( $comment->user_id === $post->post_author ) {
     479        $_post = get_post( $post );
     480        if ( $_post ) {
     481            if ( $comment->user_id === $_post->post_author ) {
    482482                $classes[] = 'bypostauthor';
    483483            }
     
    535535     * @param string      $comment_id The comment ID as a numeric string.
    536536     * @param WP_Comment  $comment    The comment object.
    537      * @param int|WP_Post $post_id    The post ID or WP_Post object.
    538      */
    539     return apply_filters( 'comment_class', $classes, $css_class, $comment->comment_ID, $comment, $post_id );
     537     * @param int|WP_Post $post       The post ID or WP_Post object.
     538     */
     539    return apply_filters( 'comment_class', $classes, $css_class, $comment->comment_ID, $comment, $post );
    540540}
    541541
     
    809809 * @since 1.5.0
    810810 *
    811  * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post.
     811 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
    812812 * @return string The link to the comments.
    813813 */
    814 function get_comments_link( $post_id = 0 ) {
    815     $hash          = get_comments_number( $post_id ) ? '#comments' : '#respond';
    816     $comments_link = get_permalink( $post_id ) . $hash;
     814function get_comments_link( $post = 0 ) {
     815    $hash          = get_comments_number( $post ) ? '#comments' : '#respond';
     816    $comments_link = get_permalink( $post ) . $hash;
    817817
    818818    /**
     
    822822     *
    823823     * @param string      $comments_link Post comments permalink with '#comments' appended.
    824      * @param int|WP_Post $post_id       Post ID or WP_Post object.
    825      */
    826     return apply_filters( 'get_comments_link', $comments_link, $post_id );
     824     * @param int|WP_Post $post          Post ID or WP_Post object.
     825     */
     826    return apply_filters( 'get_comments_link', $comments_link, $post );
    827827}
    828828
     
    850850 * @since 1.5.0
    851851 *
    852  * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is the global `$post`.
     852 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is the global `$post`.
    853853 * @return string|int If the post exists, a numeric string representing the number of comments
    854854 *                    the post has, otherwise 0.
    855855 */
    856 function get_comments_number( $post_id = 0 ) {
    857     $post = get_post( $post_id );
    858 
    859     if ( ! $post ) {
    860         $count = 0;
    861     } else {
    862         $count   = $post->comment_count;
    863         $post_id = $post->ID;
    864     }
     856function get_comments_number( $post = 0 ) {
     857    $post = get_post( $post );
     858
     859    $count   = $post ? $post->comment_count : 0;
     860    $post_id = $post ? $post->ID : 0;
    865861
    866862    /**
     
    879875 *
    880876 * @since 0.71
    881  * @since 5.4.0 The `$deprecated` parameter was changed to `$post_id`.
    882  *
    883  * @param string|false $zero    Optional. Text for no comments. Default false.
    884  * @param string|false $one     Optional. Text for one comment. Default false.
    885  * @param string|false $more    Optional. Text for more than one comment. Default false.
    886  * @param int|WP_Post  $post_id Optional. Post ID or WP_Post object. Default is the global `$post`.
    887  */
    888 function comments_number( $zero = false, $one = false, $more = false, $post_id = 0 ) {
    889     echo get_comments_number_text( $zero, $one, $more, $post_id );
     877 * @since 5.4.0 The `$deprecated` parameter was changed to `$post`.
     878 *
     879 * @param string|false $zero Optional. Text for no comments. Default false.
     880 * @param string|false $one  Optional. Text for one comment. Default false.
     881 * @param string|false $more Optional. Text for more than one comment. Default false.
     882 * @param int|WP_Post  $post Optional. Post ID or WP_Post object. Default is the global `$post`.
     883 */
     884function comments_number( $zero = false, $one = false, $more = false, $post = 0 ) {
     885    echo get_comments_number_text( $zero, $one, $more, $post );
    890886}
    891887
     
    894890 *
    895891 * @since 4.0.0
    896  * @since 5.4.0 Added the `$post_id` parameter to allow using the function outside of the loop.
    897  *
    898  * @param string      $zero    Optional. Text for no comments. Default false.
    899  * @param string      $one     Optional. Text for one comment. Default false.
    900  * @param string      $more    Optional. Text for more than one comment. Default false.
    901  * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is the global `$post`.
     892 * @since 5.4.0 Added the `$post` parameter to allow using the function outside of the loop.
     893 *
     894 * @param string      $zero Optional. Text for no comments. Default false.
     895 * @param string      $one  Optional. Text for one comment. Default false.
     896 * @param string      $more Optional. Text for more than one comment. Default false.
     897 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is the global `$post`.
    902898 * @return string Language string for the number of comments a post has.
    903899 */
    904 function get_comments_number_text( $zero = false, $one = false, $more = false, $post_id = 0 ) {
    905     $number = get_comments_number( $post_id );
     900function get_comments_number_text( $zero = false, $one = false, $more = false, $post = 0 ) {
     901    $number = get_comments_number( $post );
    906902
    907903    if ( $number > 1 ) {
     
    12361232 * @since 1.5.0
    12371233 *
    1238  * @param int|WP_Post $post_id Post ID or WP_Post object. Default current post.
     1234 * @param int|WP_Post $post Post ID or WP_Post object. Default current post.
    12391235 * @return bool True if the comments are open.
    12401236 */
    1241 function comments_open( $post_id = null ) {
    1242 
    1243     $_post = get_post( $post_id );
     1237function comments_open( $post = null ) {
     1238    $_post = get_post( $post );
    12441239
    12451240    $post_id = $_post ? $_post->ID : 0;
     
    12661261 * @since 1.5.0
    12671262 *
    1268  * @param int|WP_Post $post_id Post ID or WP_Post object. Default current post.
     1263 * @param int|WP_Post $post Post ID or WP_Post object. Default current post.
    12691264 * @return bool True if pings are accepted
    12701265 */
    1271 function pings_open( $post_id = null ) {
    1272 
    1273     $_post = get_post( $post_id );
     1266function pings_open( $post = null ) {
     1267    $_post = get_post( $post );
    12741268
    12751269    $post_id = $_post ? $_post->ID : 0;
     
    15161510     *
    15171511     * @param array $comments Array of comments supplied to the comments template.
    1518      * @param int   $post_ID  Post ID.
     1512     * @param int   $post_id  Post ID.
    15191513     */
    15201514    $wp_query->comments = apply_filters( 'comments_array', $comments_flat, $post->ID );
     
    23252319 *     @type string $format               The comment form format. Default 'xhtml'. Accepts 'xhtml', 'html5'.
    23262320 * }
    2327  * @param int|WP_Post $post_id Post ID or WP_Post object to generate the form for. Default current post.
    2328  */
    2329 function comment_form( $args = array(), $post_id = null ) {
    2330     if ( null === $post_id ) {
    2331         $post_id = get_the_ID();
    2332     }
     2321 * @param int|WP_Post $post Post ID or WP_Post object to generate the form for. Default current post.
     2322 */
     2323function comment_form( $args = array(), $post = null ) {
     2324    $post = get_post( $post );
     2325
     2326    $post_id = $post ? $post->ID : get_the_ID();
    23332327
    23342328    // Exit the function when comments for the post are closed.
  • trunk/src/wp-includes/comment.php

    r53458 r53715  
    150150
    151151/**
    152  * Retrieves the approved comments for post $post_id.
     152 * Retrieves the approved comments for a post.
    153153 *
    154154 * @since 2.0.0
     
    860860 */
    861861function wp_check_comment_flood( $is_flood, $ip, $email, $date, $avoid_die = false ) {
    862 
    863862    global $wpdb;
    864863
     
    14481447function wp_delete_comment( $comment_id, $force_delete = false ) {
    14491448    global $wpdb;
     1449
    14501450    $comment = get_comment( $comment_id );
    14511451    if ( ! $comment ) {
     
    19921992function wp_insert_comment( $commentdata ) {
    19931993    global $wpdb;
     1994
    19941995    $data = wp_unslash( $commentdata );
    19951996
     
    26522653function wp_update_comment_count_now( $post_id ) {
    26532654    global $wpdb;
     2655
    26542656    $post_id = (int) $post_id;
     2657
    26552658    if ( ! $post_id ) {
    26562659        return false;
     
    26612664
    26622665    $post = get_post( $post_id );
     2666
    26632667    if ( ! $post ) {
    26642668        return false;
     
    28872891 *
    28882892 * @since 1.5.0
    2889  * @since 4.7.0 `$post_id` can be a WP_Post object.
     2893 * @since 4.7.0 `$post` can be a WP_Post object.
    28902894 *
    28912895 * @global wpdb $wpdb WordPress database abstraction object.
    28922896 *
    2893  * @param int|WP_Post $post_id Post object or ID to do trackbacks on.
    2894  */
    2895 function do_trackbacks( $post_id ) {
     2897 * @param int|WP_Post $post Post ID or object to do trackbacks on.
     2898 */
     2899function do_trackbacks( $post ) {
    28962900    global $wpdb;
    2897     $post = get_post( $post_id );
     2901
     2902    $post = get_post( $post );
     2903
    28982904    if ( ! $post ) {
    28992905        return false;
     
    29022908    $to_ping = get_to_ping( $post );
    29032909    $pinged  = get_pung( $post );
     2910
    29042911    if ( empty( $to_ping ) ) {
    29052912        $wpdb->update( $wpdb->posts, array( 'to_ping' => '' ), array( 'ID' => $post->ID ) );
     
    29482955 *
    29492956 * @param int $post_id Post ID.
    2950  * @return int Same as Post ID from parameter
     2957 * @return int Same post ID as provided.
    29512958 */
    29522959function generic_ping( $post_id = 0 ) {
     
    29682975 *
    29692976 * @since 0.71
    2970  * @since 4.7.0 `$post_id` can be a WP_Post object.
     2977 * @since 4.7.0 `$post` can be a WP_Post object.
    29712978 *
    29722979 * @param string      $content Post content to check for links. If empty will retrieve from post.
    2973  * @param int|WP_Post $post_id Post Object or ID.
    2974  */
    2975 function pingback( $content, $post_id ) {
     2980 * @param int|WP_Post $post    Post ID or object.
     2981 */
     2982function pingback( $content, $post ) {
    29762983    include_once ABSPATH . WPINC . '/class-IXR.php';
    29772984    include_once ABSPATH . WPINC . '/class-wp-http-ixr-client.php';
     
    29802987    $post_links = array();
    29812988
    2982     $post = get_post( $post_id );
     2989    $post = get_post( $post );
     2990
    29832991    if ( ! $post ) {
    29842992        return;
     
    30333041     * @param string[] $post_links Array of link URLs to be checked (passed by reference).
    30343042     * @param string[] $pung       Array of link URLs already pinged (passed by reference).
    3035      * @param int      $post_ID    The post ID.
     3043     * @param int      $post_id    The post ID.
    30363044     */
    30373045    do_action_ref_array( 'pre_ping', array( &$post_links, &$pung, $post->ID ) );
  • trunk/src/wp-includes/deprecated.php

    r53685 r53715  
    36323632 * @see get_permalink()
    36333633 *
    3634  * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post.
     3634 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
    36353635 * @return string|false
    36363636 */
    3637 function post_permalink( $post_id = 0 ) {
     3637function post_permalink( $post = 0 ) {
    36383638    _deprecated_function( __FUNCTION__, '4.4.0', 'get_permalink()' );
    36393639
    3640     return get_permalink( $post_id );
     3640    return get_permalink( $post );
    36413641}
    36423642
  • trunk/src/wp-includes/embed.php

    r53455 r53715  
    538538 * @since 4.4.0
    539539 *
    540  * @param WP_Post|int $post  Post object or ID.
     540 * @param WP_Post|int $post  Post ID or post object.
    541541 * @param int         $width The requested width.
    542542 * @return array|false Response data on success, false if post doesn't exist
  • trunk/src/wp-includes/general-template.php

    r53703 r53715  
    26812681 *                            was written. Accepts 'G', 'U', or PHP date format.
    26822682 *                            Defaults to the 'time_format' option.
    2683  * @param int|WP_Post $post   WP_Post object or ID. Default is global `$post` object.
     2683 * @param int|WP_Post $post   Post ID or post object. Default is global `$post` object.
    26842684 * @return string|int|false Formatted date string or Unix timestamp if `$format` is 'U' or 'G'.
    26852685 *                          False on failure.
     
    27172717 *                               was written. Accepts 'G', 'U', or PHP date format. Default 'U'.
    27182718 * @param bool        $gmt       Optional. Whether to retrieve the GMT time. Default false.
    2719  * @param int|WP_Post $post      WP_Post object or ID. Default is global `$post` object.
     2719 * @param int|WP_Post $post      Post ID or post object. Default is global `$post` object.
    27202720 * @param bool        $translate Whether to translate the time string. Default false.
    27212721 * @return string|int|false Formatted date string or Unix timestamp if `$format` is 'U' or 'G'.
     
    27782778 * @since 5.3.0
    27792779 *
    2780  * @param int|WP_Post $post   Optional. WP_Post object or ID. Default is global `$post` object.
     2780 * @param int|WP_Post $post   Optional. Post ID or post object. Default is global `$post` object.
    27812781 * @param string      $field  Optional. Published or modified time to use from database. Accepts 'date' or 'modified'.
    27822782 *                            Default 'date'.
     
    28232823 * @since 5.3.0
    28242824 *
    2825  * @param int|WP_Post $post  Optional. WP_Post object or ID. Default is global `$post` object.
     2825 * @param int|WP_Post $post  Optional. Post ID or post object. Default is global `$post` object.
    28262826 * @param string      $field Optional. Published or modified time to use from database. Accepts 'date' or 'modified'.
    28272827 *                           Default 'date'.
     
    29062906 *                               was modified. Accepts 'G', 'U', or PHP date format. Default 'U'.
    29072907 * @param bool        $gmt       Optional. Whether to retrieve the GMT time. Default false.
    2908  * @param int|WP_Post $post      WP_Post object or ID. Default is global `$post` object.
     2908 * @param int|WP_Post $post      Post ID or post object. Default is global `$post` object.
    29092909 * @param bool        $translate Whether to translate the time string. Default false.
    29102910 * @return string|int|false Formatted date string or Unix timestamp if `$format` is 'U' or 'G'.
  • trunk/src/wp-includes/link-template.php

    r53520 r53715  
    312312 * @global WP_Rewrite $wp_rewrite WordPress rewrite component.
    313313 *
    314  * @param int|WP_Post $id        Optional. Post ID or post object. Default is the global `$post`.
     314 * @param int|WP_Post $post      Optional. Post ID or post object. Default is the global `$post`.
    315315 * @param bool        $leavename Optional. Whether to keep post name. Default false.
    316316 * @param bool        $sample    Optional. Is it a sample permalink. Default false.
    317317 * @return string|WP_Error The post permalink.
    318318 */
    319 function get_post_permalink( $id = 0, $leavename = false, $sample = false ) {
     319function get_post_permalink( $post = 0, $leavename = false, $sample = false ) {
    320320    global $wp_rewrite;
    321321
    322     $post = get_post( $id );
     322    $post = get_post( $post );
    323323
    324324    if ( is_wp_error( $post ) ) {
     
    12991299
    13001300    $post_type_obj = get_post_type_object( $post_type );
     1301
    13011302    if ( ! $post_type_obj ) {
    13021303        return false;
     
    14031404function get_preview_post_link( $post = null, $query_args = array(), $preview_link = '' ) {
    14041405    $post = get_post( $post );
     1406
    14051407    if ( ! $post ) {
    14061408        return;
     
    14371439 * @since 2.3.0
    14381440 *
    1439  * @param int|WP_Post $id      Optional. Post ID or post object. Default is the global `$post`.
     1441 * @param int|WP_Post $post    Optional. Post ID or post object. Default is the global `$post`.
    14401442 * @param string      $context Optional. How to output the '&' character. Default '&amp;'.
    14411443 * @return string|null The edit post link for the given post. Null if the post type does not exist
    14421444 *                     or does not allow an editing UI.
    14431445 */
    1444 function get_edit_post_link( $id = 0, $context = 'display' ) {
    1445     $post = get_post( $id );
     1446function get_edit_post_link( $post = 0, $context = 'display' ) {
     1447    $post = get_post( $post );
     1448
    14461449    if ( ! $post ) {
    14471450        return;
     
    14571460
    14581461    $post_type_object = get_post_type_object( $post->post_type );
     1462
    14591463    if ( ! $post_type_object ) {
    14601464        return;
     
    14931497 * @param string      $before Optional. Display before edit link. Default empty.
    14941498 * @param string      $after  Optional. Display after edit link. Default empty.
    1495  * @param int|WP_Post $id     Optional. Post ID or post object. Default is the global `$post`.
     1499 * @param int|WP_Post $post   Optional. Post ID or post object. Default is the global `$post`.
    14961500 * @param string      $class  Optional. Add custom class to link. Default 'post-edit-link'.
    14971501 */
    1498 function edit_post_link( $text = null, $before = '', $after = '', $id = 0, $class = 'post-edit-link' ) {
    1499     $post = get_post( $id );
     1502function edit_post_link( $text = null, $before = '', $after = '', $post = 0, $class = 'post-edit-link' ) {
     1503    $post = get_post( $post );
     1504
    15001505    if ( ! $post ) {
    15011506        return;
     
    15031508
    15041509    $url = get_edit_post_link( $post->ID );
     1510
    15051511    if ( ! $url ) {
    15061512        return;
     
    15321538 * @since 2.9.0
    15331539 *
    1534  * @param int|WP_Post $id           Optional. Post ID or post object. Default is the global `$post`.
     1540 * @param int|WP_Post $post         Optional. Post ID or post object. Default is the global `$post`.
    15351541 * @param string      $deprecated   Not used.
    15361542 * @param bool        $force_delete Optional. Whether to bypass Trash and force deletion. Default false.
    15371543 * @return string|void The delete post link URL for the given post.
    15381544 */
    1539 function get_delete_post_link( $id = 0, $deprecated = '', $force_delete = false ) {
     1545function get_delete_post_link( $post = 0, $deprecated = '', $force_delete = false ) {
    15401546    if ( ! empty( $deprecated ) ) {
    15411547        _deprecated_argument( __FUNCTION__, '3.0.0' );
    15421548    }
    15431549
    1544     $post = get_post( $id );
     1550    $post = get_post( $post );
     1551
    15451552    if ( ! $post ) {
    15461553        return;
     
    15481555
    15491556    $post_type_object = get_post_type_object( $post->post_type );
     1557
    15501558    if ( ! $post_type_object ) {
    15511559        return;
     
    17891797
    17901798    $post = get_post();
     1799
    17911800    if ( ! $post || ! taxonomy_exists( $taxonomy ) ) {
    17921801        return null;
     
    21332142function get_boundary_post( $in_same_term = false, $excluded_terms = '', $start = true, $taxonomy = 'category' ) {
    21342143    $post = get_post();
     2144
    21352145    if ( ! $post || ! is_single() || is_attachment() || ! taxonomy_exists( $taxonomy ) ) {
    21362146        return null;
  • trunk/src/wp-includes/media.php

    r53685 r53715  
    43004300 *     Arguments for enqueuing media scripts.
    43014301 *
    4302  *     @type int|WP_Post $post A post object or ID.
     4302 *     @type int|WP_Post $post Post ID or post object.
    43034303 * }
    43044304 */
  • trunk/src/wp-includes/post-template.php

    r53656 r53715  
    118118    $post = get_post( $post );
    119119
    120     $title = isset( $post->post_title ) ? $post->post_title : '';
    121     $id    = isset( $post->ID ) ? $post->ID : 0;
     120    $post_title = isset( $post->post_title ) ? $post->post_title : '';
     121    $post_id    = isset( $post->ID ) ? $post->ID : 0;
    122122
    123123    if ( ! is_admin() ) {
     
    139139             */
    140140            $protected_title_format = apply_filters( 'protected_title_format', $prepend, $post );
    141             $title                  = sprintf( $protected_title_format, $title );
     141
     142            $post_title = sprintf( $protected_title_format, $post_title );
    142143        } elseif ( isset( $post->post_status ) && 'private' === $post->post_status ) {
    143144
     
    157158             */
    158159            $private_title_format = apply_filters( 'private_title_format', $prepend, $post );
    159             $title                = sprintf( $private_title_format, $title );
     160
     161            $post_title = sprintf( $private_title_format, $post_title );
    160162        }
    161163    }
     
    166168     * @since 0.71
    167169     *
    168      * @param string $title The post title.
    169      * @param int    $id    The post ID.
     170     * @param string $post_title The post title.
     171     * @param int    $post_id    The post ID.
    170172     */
    171     return apply_filters( 'the_title', $title, $id );
     173    return apply_filters( 'the_title', $post_title, $post_id );
    172174}
    173175
     
    188190    $post = get_post( $post );
    189191
    190     $guid = isset( $post->guid ) ? get_the_guid( $post ) : '';
    191     $id   = isset( $post->ID ) ? $post->ID : 0;
     192    $post_guid = isset( $post->guid ) ? get_the_guid( $post ) : '';
     193    $post_id   = isset( $post->ID ) ? $post->ID : 0;
    192194
    193195    /**
     
    198200     * @see get_the_guid()
    199201     *
    200      * @param string $guid Escaped Global Unique Identifier (guid) of the post.
    201      * @param int    $id   The post ID.
     202     * @param string $post_guid Escaped Global Unique Identifier (guid) of the post.
     203     * @param int    $post_id   The post ID.
    202204     */
    203     echo apply_filters( 'the_guid', $guid, $id );
     205    echo apply_filters( 'the_guid', $post_guid, $post_id );
    204206}
    205207
     
    219221    $post = get_post( $post );
    220222
    221     $guid = isset( $post->guid ) ? $post->guid : '';
    222     $id   = isset( $post->ID ) ? $post->ID : 0;
     223    $post_guid = isset( $post->guid ) ? $post->guid : '';
     224    $post_id   = isset( $post->ID ) ? $post->ID : 0;
    223225
    224226    /**
     
    227229     * @since 1.5.0
    228230     *
    229      * @param string $guid Global Unique Identifier (guid) of the post.
    230      * @param int    $id   The post ID.
     231     * @param string $post_guid Global Unique Identifier (guid) of the post.
     232     * @param int    $post_id   The post ID.
    231233     */
    232     return apply_filters( 'get_the_guid', $guid, $id );
     234    return apply_filters( 'get_the_guid', $post_guid, $post_id );
    233235}
    234236
     
    452454 * @since 2.7.0
    453455 *
    454  * @param string|string[] $class   One or more classes to add to the class list.
    455  * @param int|WP_Post     $post_id Optional. Post ID or post object. Defaults to the global `$post`.
    456  */
    457 function post_class( $class = '', $post_id = null ) {
     456 * @param string|string[] $class One or more classes to add to the class list.
     457 * @param int|WP_Post     $post  Optional. Post ID or post object. Defaults to the global `$post`.
     458 */
     459function post_class( $class = '', $post = null ) {
    458460    // Separates classes with a single space, collates classes for post DIV.
    459     echo 'class="' . esc_attr( implode( ' ', get_post_class( $class, $post_id ) ) ) . '"';
     461    echo 'class="' . esc_attr( implode( ' ', get_post_class( $class, $post ) ) ) . '"';
    460462}
    461463
     
    477479 * @since 4.2.0 Custom taxonomy class names were added.
    478480 *
    479  * @param string|string[] $class   Space-separated string or array of class names to add to the class list.
    480  * @param int|WP_Post     $post_id Optional. Post ID or post object.
     481 * @param string|string[] $class Space-separated string or array of class names to add to the class list.
     482 * @param int|WP_Post     $post  Optional. Post ID or post object.
    481483 * @return string[] Array of class names.
    482484 */
    483 function get_post_class( $class = '', $post_id = null ) {
    484     $post = get_post( $post_id );
     485function get_post_class( $class = '', $post = null ) {
     486    $post = get_post( $post );
    485487
    486488    $classes = array();
     
    15811583 * @since 2.0.0
    15821584 *
    1583  * @param int|WP_Post $id Optional. Post ID or post object.
    1584  * @param bool        $fullsize     Optional. Whether to use full size. Default false.
    1585  * @param bool        $deprecated   Deprecated. Not used.
    1586  * @param bool        $permalink    Optional. Whether to include permalink. Default false.
    1587  */
    1588 function the_attachment_link( $id = 0, $fullsize = false, $deprecated = false, $permalink = false ) {
     1585 * @param int|WP_Post $post      Optional. Post ID or post object.
     1586 * @param bool        $fullsize   Optional. Whether to use full size. Default false.
     1587 * @param bool        $deprecated Deprecated. Not used.
     1588 * @param bool        $permalink Optional. Whether to include permalink. Default false.
     1589 */
     1590function the_attachment_link( $post = 0, $fullsize = false, $deprecated = false, $permalink = false ) {
    15891591    if ( ! empty( $deprecated ) ) {
    15901592        _deprecated_argument( __FUNCTION__, '2.5.0' );
     
    15921594
    15931595    if ( $fullsize ) {
    1594         echo wp_get_attachment_link( $id, 'full', $permalink );
     1596        echo wp_get_attachment_link( $post, 'full', $permalink );
    15951597    } else {
    1596         echo wp_get_attachment_link( $id, 'thumbnail', $permalink );
     1598        echo wp_get_attachment_link( $post, 'thumbnail', $permalink );
    15971599    }
    15981600}
     
    16021604 *
    16031605 * @since 2.5.0
    1604  * @since 4.4.0 The `$id` parameter can now accept either a post ID or `WP_Post` object.
    1605  *
    1606  * @param int|WP_Post  $id        Optional. Post ID or post object.
     1606 * @since 4.4.0 The `$post` parameter can now accept either a post ID or `WP_Post` object.
     1607 *
     1608 * @param int|WP_Post  $post      Optional. Post ID or post object.
    16071609 * @param string|int[] $size      Optional. Image size. Accepts any registered image size name, or an array
    16081610 *                                of width and height values in pixels (in that order). Default 'thumbnail'.
     
    16141616 * @return string HTML content.
    16151617 */
    1616 function wp_get_attachment_link( $id = 0, $size = 'thumbnail', $permalink = false, $icon = false, $text = false, $attr = '' ) {
    1617     $_post = get_post( $id );
     1618function wp_get_attachment_link( $post = 0, $size = 'thumbnail', $permalink = false, $icon = false, $text = false, $attr = '' ) {
     1619    $_post = get_post( $post );
    16181620
    16191621    if ( empty( $_post ) || ( 'attachment' !== $_post->post_type ) || ! wp_get_attachment_url( $_post->ID ) ) {
     
    16421644        $link_text = esc_html( pathinfo( get_attached_file( $_post->ID ), PATHINFO_FILENAME ) );
    16431645    }
     1646
     1647    $link_html = "<a href='" . esc_url( $url ) . "'>$link_text</a>";
     1648
    16441649    /**
    16451650     * Filters a retrieved attachment page link.
     
    16491654     *
    16501655     * @param string       $link_html The page link HTML output.
    1651      * @param int|WP_Post  $id        Post ID or object. Can be 0 for the current global post.
     1656     * @param int|WP_Post  $post      Post ID or object. Can be 0 for the current global post.
    16521657     * @param string|int[] $size      Requested image size. Can be any registered image size name, or
    16531658     *                                an array of width and height values in pixels (in that order).
     
    16571662     * @param array|string $attr      Array or string of attributes.
    16581663     */
    1659     return apply_filters( 'wp_get_attachment_link', "<a href='" . esc_url( $url ) . "'>$link_text</a>", $id, $size, $permalink, $icon, $text, $attr );
     1664    return apply_filters( 'wp_get_attachment_link', $link_html, $post, $size, $permalink, $icon, $text, $attr );
    16601665}
    16611666
     
    18261831function wp_post_revision_title( $revision, $link = true ) {
    18271832    $revision = get_post( $revision );
     1833
    18281834    if ( ! $revision ) {
    18291835        return $revision;
     
    18671873function wp_post_revision_title_expanded( $revision, $link = true ) {
    18681874    $revision = get_post( $revision );
     1875
    18691876    if ( ! $revision ) {
    18701877        return $revision;
     
    19281935 * @since 2.6.0
    19291936 *
    1930  * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post.
    1931  * @param string      $type    'all' (default), 'revision' or 'autosave'
    1932  */
    1933 function wp_list_post_revisions( $post_id = 0, $type = 'all' ) {
    1934     $post = get_post( $post_id );
     1937 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
     1938 * @param string      $type 'all' (default), 'revision' or 'autosave'
     1939 */
     1940function wp_list_post_revisions( $post = 0, $type = 'all' ) {
     1941    $post = get_post( $post );
     1942
    19351943    if ( ! $post ) {
    19361944        return;
     
    19441952
    19451953    $revisions = wp_get_post_revisions( $post->ID );
     1954
    19461955    if ( ! $revisions ) {
    19471956        return;
  • trunk/src/wp-includes/post.php

    r53685 r53715  
    11451145            // Get parent status prior to trashing.
    11461146            $post_status = get_post_meta( $post->post_parent, '_wp_trash_meta_status', true );
     1147
    11471148            if ( ! $post_status ) {
    11481149                // Assume publish as above.
     
    22442245    if ( is_scalar( $post_type ) ) {
    22452246        $post_type = get_post_type_object( $post_type );
     2247
    22462248        if ( ! $post_type ) {
    22472249            return false;
     
    22872289    if ( is_scalar( $post_status ) ) {
    22882290        $post_status = get_post_status_object( $post_status );
     2291
    22892292        if ( ! $post_status ) {
    22902293            return false;
     
    25802583function get_post_custom( $post_id = 0 ) {
    25812584    $post_id = absint( $post_id );
     2585
    25822586    if ( ! $post_id ) {
    25832587        $post_id = get_the_ID();
     
    41904194     */
    41914195    $post_date = wp_resolve_post_date( $postarr['post_date'], $postarr['post_date_gmt'] );
     4196
    41924197    if ( ! $post_date ) {
    41934198        if ( $wp_error ) {
     
    48634868 * @since 2.5.0
    48644869 *
    4865  * @param int|WP_Post $post_id Post ID or post object.
    4866  */
    4867 function check_and_publish_future_post( $post_id ) {
    4868     $post = get_post( $post_id );
     4870 * @param int|WP_Post $post Post ID or post object.
     4871 */
     4872function check_and_publish_future_post( $post ) {
     4873    $post = get_post( $post );
    48694874
    48704875    if ( ! $post ) {
     
    48804885    // Uh oh, someone jumped the gun!
    48814886    if ( $time > time() ) {
    4882         wp_clear_scheduled_hook( 'publish_future_post', array( $post_id ) ); // Clear anything else in the system.
    4883         wp_schedule_single_event( $time, 'publish_future_post', array( $post_id ) );
     4887        wp_clear_scheduled_hook( 'publish_future_post', array( $post->ID ) ); // Clear anything else in the system.
     4888        wp_schedule_single_event( $time, 'publish_future_post', array( $post->ID ) );
    48844889        return;
    48854890    }
    48864891
    48874892    // wp_publish_post() returns no meaningful value.
    4888     wp_publish_post( $post_id );
     4893    wp_publish_post( $post->ID );
    48894894}
    48904895
     
    53765381function wp_after_insert_post( $post, $update, $post_before ) {
    53775382    $post = get_post( $post );
     5383
    53785384    if ( ! $post ) {
    53795385        return;
     
    54045410 *
    54055411 * @since 1.5.0
    5406  * @since 4.7.0 `$post_id` can be a WP_Post object.
     5412 * @since 4.7.0 `$post` can be a WP_Post object.
    54075413 * @since 4.7.0 `$uri` can be an array of URIs.
    54085414 *
    54095415 * @global wpdb $wpdb WordPress database abstraction object.
    54105416 *
    5411  * @param int|WP_Post  $post_id Post object or ID.
    5412  * @param string|array $uri     Ping URI or array of URIs.
     5417 * @param int|WP_Post  $post Post ID or post object.
     5418 * @param string|array $uri  Ping URI or array of URIs.
    54135419 * @return int|false How many rows were updated.
    54145420 */
    5415 function add_ping( $post_id, $uri ) {
     5421function add_ping( $post, $uri ) {
    54165422    global $wpdb;
    54175423
    5418     $post = get_post( $post_id );
     5424    $post = get_post( $post );
    54195425
    54205426    if ( ! $post ) {
     
    54875493 * @since 1.5.0
    54885494 *
    5489  * @since 4.7.0 `$post_id` can be a WP_Post object.
    5490  *
    5491  * @param int|WP_Post $post_id Post ID or object.
     5495 * @since 4.7.0 `$post` can be a WP_Post object.
     5496 *
     5497 * @param int|WP_Post $post Post ID or object.
    54925498 * @return string[]|false Array of URLs already pinged for the given post, false if the post is not found.
    54935499 */
    5494 function get_pung( $post_id ) {
    5495     $post = get_post( $post_id );
     5500function get_pung( $post ) {
     5501    $post = get_post( $post );
    54965502
    54975503    if ( ! $post ) {
     
    55165522 *
    55175523 * @since 1.5.0
    5518  * @since 4.7.0 `$post_id` can be a WP_Post object.
    5519  *
    5520  * @param int|WP_Post $post_id Post Object or ID
     5524 * @since 4.7.0 `$post` can be a WP_Post object.
     5525 *
     5526 * @param int|WP_Post $post Post ID or post object.
    55215527 * @return string[]|false List of URLs yet to ping.
    55225528 */
    5523 function get_to_ping( $post_id ) {
    5524     $post = get_post( $post_id );
     5529function get_to_ping( $post ) {
     5530    $post = get_post( $post );
    55255531
    55265532    if ( ! $post ) {
     
    70797085    foreach ( $post_types as $post_type ) {
    70807086        $post_type_obj = get_post_type_object( $post_type );
     7087
    70817088        if ( ! $post_type_obj ) {
    70827089            continue;
     
    70937100         */
    70947101        $cap = apply_filters_deprecated( 'pub_priv_sql_capability', array( '' ), '3.2.0' );
     7102
    70957103        if ( ! $cap ) {
    70967104            $cap = current_user_can( $post_type_obj->cap->read_private_posts );
     
    70997107        // Only need to check the cap if $public_only is false.
    71007108        $post_status_sql = "post_status = 'publish'";
     7109
    71017110        if ( false === $public_only ) {
    71027111            if ( $cap ) {
     
    76407649function wp_get_post_parent_id( $post = null ) {
    76417650    $post = get_post( $post );
     7651
    76427652    if ( ! $post || is_wp_error( $post ) ) {
    76437653        return false;
    76447654    }
     7655
    76457656    return (int) $post->post_parent;
    76467657}
  • trunk/src/wp-includes/revision.php

    r53300 r53715  
    113113
    114114    $post = get_post( $post_id );
     115
    115116    if ( ! $post ) {
    116117        return;
     
    276277function wp_is_post_revision( $post ) {
    277278    $post = wp_get_post_revision( $post );
     279
    278280    if ( ! $post ) {
    279281        return false;
     
    293295function wp_is_post_autosave( $post ) {
    294296    $post = wp_get_post_revision( $post );
     297
    295298    if ( ! $post ) {
    296299        return false;
     
    356359 * @since 2.6.0
    357360 *
    358  * @param int|WP_Post $post   The post ID or object.
     361 * @param int|WP_Post $post   Post ID or post object.
    359362 * @param string      $output Optional. The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which
    360363 *                            correspond to a WP_Post object, an associative array, or a numeric array,
     
    365368function wp_get_post_revision( &$post, $output = OBJECT, $filter = 'raw' ) {
    366369    $revision = get_post( $post, OBJECT, $filter );
     370
    367371    if ( ! $revision ) {
    368372        return $revision;
    369373    }
     374
    370375    if ( 'revision' !== $revision->post_type ) {
    371376        return null;
     
    392397 * @since 2.6.0
    393398 *
    394  * @param int|WP_Post $revision_id Revision ID or revision object.
    395  * @param array       $fields      Optional. What fields to restore from. Defaults to all.
     399 * @param int|WP_Post $revision Revision ID or revision object.
     400 * @param array       $fields   Optional. What fields to restore from. Defaults to all.
    396401 * @return int|false|null Null if error, false if no fields to restore, (int) post ID if success.
    397402 */
    398 function wp_restore_post_revision( $revision_id, $fields = null ) {
    399     $revision = wp_get_post_revision( $revision_id, ARRAY_A );
     403function wp_restore_post_revision( $revision, $fields = null ) {
     404    $revision = wp_get_post_revision( $revision, ARRAY_A );
     405
    400406    if ( ! $revision ) {
    401407        return $revision;
     
    420426
    421427    $post_id = wp_update_post( $update );
     428
    422429    if ( ! $post_id || is_wp_error( $post_id ) ) {
    423430        return $post_id;
     
    447454 * @since 2.6.0
    448455 *
    449  * @param int|WP_Post $revision_id Revision ID or revision object.
     456 * @param int|WP_Post $revision Revision ID or revision object.
    450457 * @return WP_Post|false|null Null or false if error, deleted post object if success.
    451458 */
    452 function wp_delete_post_revision( $revision_id ) {
    453     $revision = wp_get_post_revision( $revision_id );
     459function wp_delete_post_revision( $revision ) {
     460    $revision = wp_get_post_revision( $revision );
     461
    454462    if ( ! $revision ) {
    455463        return $revision;
     
    457465
    458466    $delete = wp_delete_post( $revision->ID );
     467
    459468    if ( $delete ) {
    460469        /**
     
    479488 * @see get_children()
    480489 *
    481  * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global `$post`.
    482  * @param array|null  $args    Optional. Arguments for retrieving post revisions. Default null.
     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.
    483492 * @return array An array of revisions, or an empty array if none.
    484493 */
    485 function wp_get_post_revisions( $post_id = 0, $args = null ) {
    486     $post = get_post( $post_id );
     494function wp_get_post_revisions( $post = 0, $args = null ) {
     495    $post = get_post( $post );
     496
    487497    if ( ! $post || empty( $post->ID ) ) {
    488498        return array();
     
    510520
    511521    $revisions = get_children( $args );
     522
    512523    if ( ! $revisions ) {
    513524        return array();
     
    522533 * @since 5.9.0
    523534 *
    524  * @param int|WP_Post $post_id Optional. 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`.
    525536 * @return null|string The URL for editing revisions on the given post, otherwise null.
    526537 */
    527 function wp_get_post_revisions_url( $post_id = 0 ) {
    528     $post = get_post( $post_id );
     538function wp_get_post_revisions_url( $post = 0 ) {
     539    $post = get_post( $post );
    529540
    530541    if ( ! $post instanceof WP_Post ) {
     
    685696function _wp_preview_terms_filter( $terms, $post_id, $taxonomy ) {
    686697    $post = get_post();
     698
    687699    if ( ! $post ) {
    688700        return $terms;
     
    720732function _wp_preview_post_thumbnail_filter( $value, $post_id, $meta_key ) {
    721733    $post = get_post();
     734
    722735    if ( ! $post ) {
    723736        return $value;
     
    735748
    736749    $thumbnail_id = (int) $_REQUEST['_thumbnail_id'];
     750
    737751    if ( $thumbnail_id <= 0 ) {
    738752        return '';
     
    784798    $now    = time();
    785799    $result = $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO `$wpdb->options` (`option_name`, `option_value`, `autoload`) VALUES (%s, %s, 'no') /* LOCK */", $lock, $now ) );
     800
    786801    if ( ! $result ) {
    787802        // If we couldn't get a lock, see how old the previous lock is.
    788803        $locked = get_option( $lock );
     804
    789805        if ( ! $locked ) {
    790806            // Can't write to the lock, and can't read the lock.
Note: See TracChangeset for help on using the changeset viewer.