Make WordPress Core

Changeset 55365


Ignore:
Timestamp:
02/19/2023 03:03:50 PM (22 months ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Rename $post_ID variable to $post_id in various files.

The $post_ID variable is technically allowed in WPCS, as there is a global of the same name that needs to remain for backward compatibility. However, this name is mostly a remnant of legacy code, and switching to $post_id where appropriate brings more consistency with the rest of core.

Additionally, this commit resolves a few WPCS warnings in core:

Variable "$post_IDs" is not in valid snake_case format

This affects:

  • Function parameters in:
    • add_meta()
    • post_preview()
    • WP_Embed::delete_oembed_caches()
    • WP_Embed::cache_oembed()
    • wp_get_post_cats()
    • wp_set_post_cats()
    • wp_unique_post_slug()
    • wp_set_post_categories()
    • wp_check_post_hierarchy_for_loops()
    • wp_add_trashed_suffix_to_post_name_for_trashed_posts()
    • wp_filter_wp_template_unique_post_slug()
    • wp_xmlrpc_server::add_enclosure_if_new()
    • wp_xmlrpc_server::attach_uploads()
    • wp_xmlrpc_server::mt_getTrackbackPings()
  • Internal variables in:
    • wp_ajax_inline_save()
    • wp_ajax_set_post_thumbnail()
    • wp_ajax_get_post_thumbnail_html()
    • edit_post()
    • bulk_edit_posts()
    • wp_write_post()
    • WP_Embed::shortcode()
    • wp_insert_post()
    • wp_xmlrpc_server::_insert_post()
    • wp_xmlrpc_server::blogger_getPost()
    • wp_xmlrpc_server::blogger_newPost()
    • wp_xmlrpc_server::blogger_editPost()
    • wp_xmlrpc_server::blogger_deletePost()
    • wp_xmlrpc_server::mw_getPost()
    • wp_xmlrpc_server::mw_newPost()
    • wp_xmlrpc_server::mw_editPost()
    • wp_xmlrpc_server::mt_getPostCategories()
    • wp_xmlrpc_server::mt_setPostCategories()
    • wp_xmlrpc_server::mt_publishPost()
    • wp_xmlrpc_server::pingback_ping()
  • Hook parameters in:
    • oembed_ttl
    • embed_oembed_html
    • wp_insert_post_parent
    • add_trashed_suffix_to_trashed_posts
    • pre_post_update
    • edit_attachment
    • attachment_updated
    • add_attachment
    • edit_post_{$post->post_type}
    • edit_post
    • post_updated
    • save_post_{$post->post_type}
    • save_post
    • wp_insert_post
    • pre_wp_unique_post_slug
    • wp_unique_post_slug
    • xmlrpc_call_success_blogger_newPost
    • xmlrpc_call_success_blogger_editPost
    • xmlrpc_call_success_blogger_deletePost
    • xmlrpc_call_success_mw_newPost
    • xmlrpc_call_success_mw_editPost

Note: The name change only affects variable names and DocBlocks.

The change does not affect the $post_ID global still used in a few places.

Follow-up to [51399], [52958], [53723], [53729], [55190], [55308], [55334].

Props mahekkalola, tanjimtc71, SergeyBiryukov.
Fixes #57692.

Location:
trunk
Files:
9 edited

Legend:

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

    r55258 r55365  
    20352035    }
    20362036
    2037     $post_ID = (int) $_POST['post_ID'];
     2037    $post_id = (int) $_POST['post_ID'];
    20382038
    20392039    if ( 'page' === $_POST['post_type'] ) {
    2040         if ( ! current_user_can( 'edit_page', $post_ID ) ) {
     2040        if ( ! current_user_can( 'edit_page', $post_id ) ) {
    20412041            wp_die( __( 'Sorry, you are not allowed to edit this page.' ) );
    20422042        }
    20432043    } else {
    2044         if ( ! current_user_can( 'edit_post', $post_ID ) ) {
     2044        if ( ! current_user_can( 'edit_post', $post_id ) ) {
    20452045            wp_die( __( 'Sorry, you are not allowed to edit this post.' ) );
    20462046        }
    20472047    }
    20482048
    2049     $last = wp_check_post_lock( $post_ID );
     2049    $last = wp_check_post_lock( $post_id );
    20502050    if ( $last ) {
    20512051        $last_user      = get_userdata( $last );
     
    20662066    $data = &$_POST;
    20672067
    2068     $post = get_post( $post_ID, ARRAY_A );
     2068    $post = get_post( $post_id, ARRAY_A );
    20692069
    20702070    // Since it's coming from the database.
     
    27002700    $json = ! empty( $_REQUEST['json'] ); // New-style request.
    27012701
    2702     $post_ID = (int) $_POST['post_id'];
    2703     if ( ! current_user_can( 'edit_post', $post_ID ) ) {
     2702    $post_id = (int) $_POST['post_id'];
     2703    if ( ! current_user_can( 'edit_post', $post_id ) ) {
    27042704        wp_die( -1 );
    27052705    }
     
    27082708
    27092709    if ( $json ) {
    2710         check_ajax_referer( "update-post_$post_ID" );
     2710        check_ajax_referer( "update-post_$post_id" );
    27112711    } else {
    2712         check_ajax_referer( "set_post_thumbnail-$post_ID" );
     2712        check_ajax_referer( "set_post_thumbnail-$post_id" );
    27132713    }
    27142714
    27152715    if ( '-1' == $thumbnail_id ) {
    2716         if ( delete_post_thumbnail( $post_ID ) ) {
    2717             $return = _wp_post_thumbnail_html( null, $post_ID );
     2716        if ( delete_post_thumbnail( $post_id ) ) {
     2717            $return = _wp_post_thumbnail_html( null, $post_id );
    27182718            $json ? wp_send_json_success( $return ) : wp_die( $return );
    27192719        } else {
     
    27222722    }
    27232723
    2724     if ( set_post_thumbnail( $post_ID, $thumbnail_id ) ) {
    2725         $return = _wp_post_thumbnail_html( $thumbnail_id, $post_ID );
     2724    if ( set_post_thumbnail( $post_id, $thumbnail_id ) ) {
     2725        $return = _wp_post_thumbnail_html( $thumbnail_id, $post_id );
    27262726        $json ? wp_send_json_success( $return ) : wp_die( $return );
    27272727    }
     
    27362736 */
    27372737function wp_ajax_get_post_thumbnail_html() {
    2738     $post_ID = (int) $_POST['post_id'];
    2739 
    2740     check_ajax_referer( "update-post_$post_ID" );
    2741 
    2742     if ( ! current_user_can( 'edit_post', $post_ID ) ) {
     2738    $post_id = (int) $_POST['post_id'];
     2739
     2740    check_ajax_referer( "update-post_$post_id" );
     2741
     2742    if ( ! current_user_can( 'edit_post', $post_id ) ) {
    27432743        wp_die( -1 );
    27442744    }
     
    27512751    }
    27522752
    2753     $return = _wp_post_thumbnail_html( $thumbnail_id, $post_ID );
     2753    $return = _wp_post_thumbnail_html( $thumbnail_id, $post_id );
    27542754    wp_send_json_success( $return );
    27552755}
  • trunk/src/wp-admin/includes/post.php

    r55265 r55365  
    253253    unset( $post_data['filter'] );
    254254
    255     $post_ID = (int) $post_data['post_ID'];
    256     $post    = get_post( $post_ID );
     255    $post_id = (int) $post_data['post_ID'];
     256    $post    = get_post( $post_id );
    257257
    258258    $post_data['post_type']      = $post->post_type;
     
    268268
    269269    $ptype = get_post_type_object( $post_data['post_type'] );
    270     if ( ! current_user_can( 'edit_post', $post_ID ) ) {
     270    if ( ! current_user_can( 'edit_post', $post_id ) ) {
    271271        if ( 'page' === $post_data['post_type'] ) {
    272272            wp_die( __( 'Sorry, you are not allowed to edit this page.' ) );
     
    278278    if ( post_type_supports( $ptype->name, 'revisions' ) ) {
    279279        $revisions = wp_get_post_revisions(
    280             $post_ID,
     280            $post_id,
    281281            array(
    282282                'order'          => 'ASC',
     
    288288        // Check if the revisions have been upgraded.
    289289        if ( $revisions && _wp_get_post_revision_version( $revision ) < 1 ) {
    290             _wp_upgrade_revisions_of_post( $post, wp_get_post_revisions( $post_ID ) );
     290            _wp_upgrade_revisions_of_post( $post, wp_get_post_revisions( $post_id ) );
    291291        }
    292292    }
     
    316316    // Post formats.
    317317    if ( isset( $post_data['post_format'] ) ) {
    318         set_post_format( $post_ID, $post_data['post_format'] );
     318        set_post_format( $post_id, $post_data['post_format'] );
    319319    }
    320320
     
    323323        $keyed = '_format_' . $format_meta_url;
    324324        if ( isset( $post_data[ $keyed ] ) ) {
    325             update_post_meta( $post_ID, $keyed, wp_slash( sanitize_url( wp_unslash( $post_data[ $keyed ] ) ) ) );
     325            update_post_meta( $post_id, $keyed, wp_slash( sanitize_url( wp_unslash( $post_data[ $keyed ] ) ) ) );
    326326        }
    327327    }
     
    333333        if ( isset( $post_data[ $keyed ] ) ) {
    334334            if ( current_user_can( 'unfiltered_html' ) ) {
    335                 update_post_meta( $post_ID, $keyed, $post_data[ $keyed ] );
     335                update_post_meta( $post_id, $keyed, $post_data[ $keyed ] );
    336336            } else {
    337                 update_post_meta( $post_ID, $keyed, wp_filter_post_kses( $post_data[ $keyed ] ) );
     337                update_post_meta( $post_id, $keyed, wp_filter_post_kses( $post_data[ $keyed ] ) );
    338338            }
    339339        }
     
    341341
    342342    if ( 'attachment' === $post_data['post_type'] && preg_match( '#^(audio|video)/#', $post_data['post_mime_type'] ) ) {
    343         $id3data = wp_get_attachment_metadata( $post_ID );
     343        $id3data = wp_get_attachment_metadata( $post_id );
    344344        if ( ! is_array( $id3data ) ) {
    345345            $id3data = array();
     
    351351            }
    352352        }
    353         wp_update_attachment_metadata( $post_ID, $id3data );
     353        wp_update_attachment_metadata( $post_id, $id3data );
    354354    }
    355355
     
    361361                continue;
    362362            }
    363             if ( $meta->post_id != $post_ID ) {
     363
     364            if ( $meta->post_id != $post_id ) {
    364365                continue;
    365366            }
    366             if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'edit_post_meta', $post_ID, $meta->meta_key ) ) {
     367
     368            if ( is_protected_meta( $meta->meta_key, 'post' )
     369                || ! current_user_can( 'edit_post_meta', $post_id, $meta->meta_key )
     370            ) {
    367371                continue;
    368372            }
    369             if ( is_protected_meta( $value['key'], 'post' ) || ! current_user_can( 'edit_post_meta', $post_ID, $value['key'] ) ) {
     373
     374            if ( is_protected_meta( $value['key'], 'post' )
     375                || ! current_user_can( 'edit_post_meta', $post_id, $value['key'] )
     376            ) {
    370377                continue;
    371378            }
     379
    372380            update_meta( $key, $value['key'], $value['value'] );
    373381        }
     
    380388                continue;
    381389            }
    382             if ( $meta->post_id != $post_ID ) {
     390
     391            if ( $meta->post_id != $post_id ) {
    383392                continue;
    384393            }
    385             if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'delete_post_meta', $post_ID, $meta->meta_key ) ) {
     394
     395            if ( is_protected_meta( $meta->meta_key, 'post' )
     396                || ! current_user_can( 'delete_post_meta', $post_id, $meta->meta_key )
     397            ) {
    386398                continue;
    387399            }
     400
    388401            delete_meta( $key );
    389402        }
     
    395408            $image_alt = wp_unslash( $post_data['_wp_attachment_image_alt'] );
    396409
    397             if ( get_post_meta( $post_ID, '_wp_attachment_image_alt', true ) !== $image_alt ) {
     410            if ( get_post_meta( $post_id, '_wp_attachment_image_alt', true ) !== $image_alt ) {
    398411                $image_alt = wp_strip_all_tags( $image_alt, true );
    399412
    400413                // update_post_meta() expects slashed.
    401                 update_post_meta( $post_ID, '_wp_attachment_image_alt', wp_slash( $image_alt ) );
    402             }
    403         }
    404 
    405         $attachment_data = isset( $post_data['attachments'][ $post_ID ] ) ? $post_data['attachments'][ $post_ID ] : array();
     414                update_post_meta( $post_id, '_wp_attachment_image_alt', wp_slash( $image_alt ) );
     415            }
     416        }
     417
     418        $attachment_data = isset( $post_data['attachments'][ $post_id ] ) ? $post_data['attachments'][ $post_id ] : array();
    406419
    407420        /** This filter is documented in wp-admin/includes/media.php */
     
    420433    }
    421434
    422     add_meta( $post_ID );
    423 
    424     update_post_meta( $post_ID, '_edit_last', get_current_user_id() );
     435    add_meta( $post_id );
     436
     437    update_post_meta( $post_id, '_edit_last', get_current_user_id() );
    425438
    426439    $success = wp_update_post( $translated );
     
    440453
    441454    // Now that we have an ID we can fix any attachment anchor hrefs.
    442     _fix_attachment_links( $post_ID );
    443 
    444     wp_set_post_lock( $post_ID );
     455    _fix_attachment_links( $post_id );
     456
     457    wp_set_post_lock( $post_id );
    445458
    446459    if ( current_user_can( $ptype->cap->edit_others_posts ) && current_user_can( $ptype->cap->publish_posts ) ) {
    447460        if ( ! empty( $post_data['sticky'] ) ) {
    448             stick_post( $post_ID );
     461            stick_post( $post_id );
    449462        } else {
    450             unstick_post( $post_ID );
    451         }
    452     }
    453 
    454     return $post_ID;
     463            unstick_post( $post_id );
     464        }
     465    }
     466
     467    return $post_id;
    455468}
    456469
     
    506519    }
    507520
    508     $post_IDs = array_map( 'intval', (array) $post_data['post'] );
     521    $post_ids = array_map( 'intval', (array) $post_data['post'] );
    509522
    510523    $reset = array(
     
    543556                continue;
    544557            }
     558
    545559            if ( is_taxonomy_hierarchical( $tax_name ) ) {
    546560                $tax_input[ $tax_name ] = array_map( 'absint', $terms );
     
    577591    $shared_post_data = $post_data;
    578592
    579     foreach ( $post_IDs as $post_ID ) {
     593    foreach ( $post_ids as $post_id ) {
    580594        // Start with fresh post data with each iteration.
    581595        $post_data = $shared_post_data;
    582596
    583         $post_type_object = get_post_type_object( get_post_type( $post_ID ) );
     597        $post_type_object = get_post_type_object( get_post_type( $post_id ) );
    584598
    585599        if ( ! isset( $post_type_object )
    586             || ( isset( $children ) && in_array( $post_ID, $children, true ) )
    587             || ! current_user_can( 'edit_post', $post_ID )
     600            || ( isset( $children ) && in_array( $post_id, $children, true ) )
     601            || ! current_user_can( 'edit_post', $post_id )
    588602        ) {
    589             $skipped[] = $post_ID;
     603            $skipped[] = $post_id;
    590604            continue;
    591605        }
    592606
    593         if ( wp_check_post_lock( $post_ID ) ) {
    594             $locked[] = $post_ID;
     607        if ( wp_check_post_lock( $post_id ) ) {
     608            $locked[] = $post_id;
    595609            continue;
    596610        }
    597611
    598         $post      = get_post( $post_ID );
     612        $post      = get_post( $post_id );
    599613        $tax_names = get_object_taxonomies( $post );
    600614
     
    613627
    614628            if ( $taxonomy_obj->hierarchical ) {
    615                 $current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array( 'fields' => 'ids' ) );
     629                $current_terms = (array) wp_get_object_terms( $post_id, $tax_name, array( 'fields' => 'ids' ) );
    616630            } else {
    617                 $current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array( 'fields' => 'names' ) );
     631                $current_terms = (array) wp_get_object_terms( $post_id, $tax_name, array( 'fields' => 'names' ) );
    618632            }
    619633
     
    622636
    623637        if ( isset( $new_cats ) && in_array( 'category', $tax_names, true ) ) {
    624             $cats                       = (array) wp_get_post_categories( $post_ID );
     638            $cats                       = (array) wp_get_post_categories( $post_id );
    625639            $post_data['post_category'] = array_unique( array_merge( $cats, $new_cats ) );
    626640            unset( $post_data['tax_input']['category'] );
    627641        }
    628642
    629         $post_data['post_ID']        = $post_ID;
     643        $post_data['post_ID']        = $post_id;
    630644        $post_data['post_type']      = $post->post_type;
    631645        $post_data['post_mime_type'] = $post->post_mime_type;
     
    639653        $post_data = _wp_translate_postdata( true, $post_data );
    640654        if ( is_wp_error( $post_data ) ) {
    641             $skipped[] = $post_ID;
     655            $skipped[] = $post_id;
    642656            continue;
    643657        }
     
    645659
    646660        if ( isset( $shared_post_data['post_format'] ) ) {
    647             set_post_format( $post_ID, $shared_post_data['post_format'] );
     661            set_post_format( $post_id, $shared_post_data['post_format'] );
    648662        }
    649663
     
    657671        if ( isset( $post_data['sticky'] ) && current_user_can( $ptype->cap->edit_others_posts ) ) {
    658672            if ( 'sticky' === $post_data['sticky'] ) {
    659                 stick_post( $post_ID );
     673                stick_post( $post_id );
    660674            } else {
    661                 unstick_post( $post_ID );
     675                unstick_post( $post_id );
    662676            }
    663677        }
     
    888902
    889903    // Create the post.
    890     $post_ID = wp_insert_post( $translated );
    891     if ( is_wp_error( $post_ID ) ) {
    892         return $post_ID;
    893     }
    894 
    895     if ( empty( $post_ID ) ) {
     904    $post_id = wp_insert_post( $translated );
     905    if ( is_wp_error( $post_id ) ) {
     906        return $post_id;
     907    }
     908
     909    if ( empty( $post_id ) ) {
    896910        return 0;
    897911    }
    898912
    899     add_meta( $post_ID );
    900 
    901     add_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']->ID );
     913    add_meta( $post_id );
     914
     915    add_post_meta( $post_id, '_edit_last', $GLOBALS['current_user']->ID );
    902916
    903917    // Now that we have an ID we can fix any attachment anchor hrefs.
    904     _fix_attachment_links( $post_ID );
    905 
    906     wp_set_post_lock( $post_ID );
    907 
    908     return $post_ID;
     918    _fix_attachment_links( $post_id );
     919
     920    wp_set_post_lock( $post_id );
     921
     922    return $post_id;
    909923}
    910924
     
    934948 * @since 1.2.0
    935949 *
    936  * @param int $post_ID
     950 * @param int $post_id
    937951 * @return int|bool
    938952 */
    939 function add_meta( $post_ID ) {
    940     $post_ID = (int) $post_ID;
     953function add_meta( $post_id ) {
     954    $post_id = (int) $post_id;
    941955
    942956    $metakeyselect = isset( $_POST['metakeyselect'] ) ? wp_unslash( trim( $_POST['metakeyselect'] ) ) : '';
     
    960974        }
    961975
    962         if ( is_protected_meta( $metakey, 'post' ) || ! current_user_can( 'add_post_meta', $post_ID, $metakey ) ) {
     976        if ( is_protected_meta( $metakey, 'post' ) || ! current_user_can( 'add_post_meta', $post_id, $metakey ) ) {
    963977            return false;
    964978        }
     
    966980        $metakey = wp_slash( $metakey );
    967981
    968         return add_post_meta( $post_ID, $metakey, $metavalue );
     982        return add_post_meta( $post_id, $metakey, $metavalue );
    969983    }
    970984
     
    19421956function post_preview() {
    19431957
    1944     $post_ID     = (int) $_POST['post_ID'];
    1945     $_POST['ID'] = $post_ID;
    1946 
    1947     $post = get_post( $post_ID );
     1958    $post_id     = (int) $_POST['post_ID'];
     1959    $_POST['ID'] = $post_id;
     1960
     1961    $post = get_post( $post_id );
    19481962
    19491963    if ( ! $post ) {
  • trunk/src/wp-includes/class-wp-embed.php

    r54319 r55365  
    223223        }
    224224
    225         $post_ID = ( ! empty( $post->ID ) ) ? $post->ID : null;
     225        $post_id = ( ! empty( $post->ID ) ) ? $post->ID : null;
    226226
    227227        // Potentially set by WP_Embed::cache_oembed().
    228228        if ( ! empty( $this->post_ID ) ) {
    229             $post_ID = $this->post_ID;
     229            $post_id = $this->post_ID;
    230230        }
    231231
     
    243243         * @param string $url     The attempted embed URL.
    244244         * @param array  $attr    An array of shortcode attributes.
    245          * @param int    $post_ID Post ID.
     245         * @param int    $post_id Post ID.
    246246         */
    247         $ttl = apply_filters( 'oembed_ttl', DAY_IN_SECONDS, $url, $attr, $post_ID );
     247        $ttl = apply_filters( 'oembed_ttl', DAY_IN_SECONDS, $url, $attr, $post_id );
    248248
    249249        $cache      = '';
     
    252252        $cached_post_id = $this->find_oembed_post_id( $key_suffix );
    253253
    254         if ( $post_ID ) {
    255             $cache      = get_post_meta( $post_ID, $cachekey, true );
    256             $cache_time = get_post_meta( $post_ID, $cachekey_time, true );
     254        if ( $post_id ) {
     255            $cache      = get_post_meta( $post_id, $cachekey, true );
     256            $cache_time = get_post_meta( $post_id, $cachekey_time, true );
    257257
    258258            if ( ! $cache_time ) {
     
    285285                 * @param string       $url     The attempted embed URL.
    286286                 * @param array        $attr    An array of shortcode attributes.
    287                  * @param int          $post_ID Post ID.
     287                 * @param int          $post_id Post ID.
    288288                 */
    289                 return apply_filters( 'embed_oembed_html', $cache, $url, $attr, $post_ID );
     289                return apply_filters( 'embed_oembed_html', $cache, $url, $attr, $post_id );
    290290            }
    291291        }
     
    306306        $html = wp_oembed_get( $url, $attr );
    307307
    308         if ( $post_ID ) {
     308        if ( $post_id ) {
    309309            if ( $html ) {
    310                 update_post_meta( $post_ID, $cachekey, $html );
    311                 update_post_meta( $post_ID, $cachekey_time, time() );
     310                update_post_meta( $post_id, $cachekey, $html );
     311                update_post_meta( $post_id, $cachekey_time, time() );
    312312            } elseif ( ! $cache ) {
    313                 update_post_meta( $post_ID, $cachekey, '{{unknown}}' );
     313                update_post_meta( $post_id, $cachekey, '{{unknown}}' );
    314314            }
    315315        } else {
     
    370370        if ( $html ) {
    371371            /** This filter is documented in wp-includes/class-wp-embed.php */
    372             return apply_filters( 'embed_oembed_html', $html, $url, $attr, $post_ID );
     372            return apply_filters( 'embed_oembed_html', $html, $url, $attr, $post_id );
    373373        }
    374374
     
    380380     * Deletes all oEmbed caches. Unused by core as of 4.0.0.
    381381     *
    382      * @param int $post_ID Post ID to delete the caches for.
    383      */
    384     public function delete_oembed_caches( $post_ID ) {
    385         $post_metas = get_post_custom_keys( $post_ID );
     382     * @param int $post_id Post ID to delete the caches for.
     383     */
     384    public function delete_oembed_caches( $post_id ) {
     385        $post_metas = get_post_custom_keys( $post_id );
    386386        if ( empty( $post_metas ) ) {
    387387            return;
     
    390390        foreach ( $post_metas as $post_meta_key ) {
    391391            if ( '_oembed_' === substr( $post_meta_key, 0, 8 ) ) {
    392                 delete_post_meta( $post_ID, $post_meta_key );
     392                delete_post_meta( $post_id, $post_meta_key );
    393393            }
    394394        }
     
    398398     * Triggers a caching of all oEmbed results.
    399399     *
    400      * @param int $post_ID Post ID to do the caching for.
    401      */
    402     public function cache_oembed( $post_ID ) {
    403         $post = get_post( $post_ID );
     400     * @param int $post_id Post ID to do the caching for.
     401     */
     402    public function cache_oembed( $post_id ) {
     403        $post = get_post( $post_id );
    404404
    405405        $post_types = get_post_types( array( 'show_ui' => true ) );
  • trunk/src/wp-includes/class-wp-xmlrpc-server.php

    r55316 r55365  
    15301530            $post_data['ID'] = get_default_post_to_edit( $post_data['post_type'], true )->ID;
    15311531        }
    1532         $post_ID = $post_data['ID'];
     1532        $post_id = $post_data['ID'];
    15331533
    15341534        if ( 'post' === $post_data['post_type'] ) {
     
    15421542            // Empty value deletes, non-empty value adds/updates.
    15431543            if ( ! $post_data['post_thumbnail'] ) {
    1544                 delete_post_thumbnail( $post_ID );
     1544                delete_post_thumbnail( $post_id );
    15451545            } elseif ( ! get_post( absint( $post_data['post_thumbnail'] ) ) ) {
    15461546                return new IXR_Error( 404, __( 'Invalid attachment ID.' ) );
    15471547            }
    1548             set_post_thumbnail( $post_ID, $post_data['post_thumbnail'] );
     1548            set_post_thumbnail( $post_id, $post_data['post_thumbnail'] );
    15491549            unset( $content_struct['post_thumbnail'] );
    15501550        }
    15511551
    15521552        if ( isset( $post_data['custom_fields'] ) ) {
    1553             $this->set_custom_fields( $post_ID, $post_data['custom_fields'] );
     1553            $this->set_custom_fields( $post_id, $post_data['custom_fields'] );
    15541554        }
    15551555
     
    16571657
    16581658        if ( isset( $post_data['post_format'] ) ) {
    1659             $format = set_post_format( $post_ID, $post_data['post_format'] );
     1659            $format = set_post_format( $post_id, $post_data['post_format'] );
    16601660
    16611661            if ( is_wp_error( $format ) ) {
     
    16681668        // Handle enclosures.
    16691669        $enclosure = isset( $post_data['enclosure'] ) ? $post_data['enclosure'] : null;
    1670         $this->add_enclosure_if_new( $post_ID, $enclosure );
    1671 
    1672         $this->attach_uploads( $post_ID, $post_data['post_content'] );
     1670        $this->add_enclosure_if_new( $post_id, $enclosure );
     1671
     1672        $this->attach_uploads( $post_id, $post_data['post_content'] );
    16731673
    16741674        /**
     
    16901690        );
    16911691
    1692         $post_ID = $update ? wp_update_post( $post_data, true ) : wp_insert_post( $post_data, true );
    1693         if ( is_wp_error( $post_ID ) ) {
    1694             return new IXR_Error( 500, $post_ID->get_error_message() );
    1695         }
    1696 
    1697         if ( ! $post_ID ) {
     1692        $post_id = $update ? wp_update_post( $post_data, true ) : wp_insert_post( $post_data, true );
     1693        if ( is_wp_error( $post_id ) ) {
     1694            return new IXR_Error( 500, $post_id->get_error_message() );
     1695        }
     1696
     1697        if ( ! $post_id ) {
    16981698            if ( $update ) {
    16991699                return new IXR_Error( 401, __( 'Sorry, the post could not be updated.' ) );
     
    17031703        }
    17041704
    1705         return (string) $post_ID;
     1705        return (string) $post_id;
    17061706    }
    17071707
     
    49434943        $this->escape( $args );
    49444944
    4945         $post_ID  = (int) $args[1];
     4945        $post_id  = (int) $args[1];
    49464946        $username = $args[2];
    49474947        $password = $args[3];
     
    49524952        }
    49534953
    4954         $post_data = get_post( $post_ID, ARRAY_A );
     4954        $post_data = get_post( $post_id, ARRAY_A );
    49554955        if ( ! $post_data ) {
    49564956            return new IXR_Error( 404, __( 'Invalid post ID.' ) );
    49574957        }
    49584958
    4959         if ( ! current_user_can( 'edit_post', $post_ID ) ) {
     4959        if ( ! current_user_can( 'edit_post', $post_id ) ) {
    49604960            return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
    49614961        }
     
    49644964        do_action( 'xmlrpc_call', 'blogger.getPost', $args, $this );
    49654965
    4966         $categories = implode( ',', wp_get_post_categories( $post_ID ) );
     4966        $categories = implode( ',', wp_get_post_categories( $post_id ) );
    49674967
    49684968        $content  = '<title>' . wp_unslash( $post_data['post_title'] ) . '</title>';
     
    51295129        $post_data = compact( 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status' );
    51305130
    5131         $post_ID = wp_insert_post( $post_data );
    5132         if ( is_wp_error( $post_ID ) ) {
    5133             return new IXR_Error( 500, $post_ID->get_error_message() );
    5134         }
    5135 
    5136         if ( ! $post_ID ) {
     5131        $post_id = wp_insert_post( $post_data );
     5132        if ( is_wp_error( $post_id ) ) {
     5133            return new IXR_Error( 500, $post_id->get_error_message() );
     5134        }
     5135
     5136        if ( ! $post_id ) {
    51375137            return new IXR_Error( 500, __( 'Sorry, the post could not be created.' ) );
    51385138        }
    51395139
    5140         $this->attach_uploads( $post_ID, $post_content );
     5140        $this->attach_uploads( $post_id, $post_content );
    51415141
    51425142        /**
     
    51455145         * @since 3.4.0
    51465146         *
    5147          * @param int   $post_ID ID of the new post.
     5147         * @param int   $post_id ID of the new post.
    51485148         * @param array $args    An array of new post arguments.
    51495149         */
    5150         do_action( 'xmlrpc_call_success_blogger_newPost', $post_ID, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
    5151 
    5152         return $post_ID;
     5150        do_action( 'xmlrpc_call_success_blogger_newPost', $post_id, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
     5151
     5152        return $post_id;
    51535153    }
    51545154
     
    51745174        $this->escape( $args );
    51755175
    5176         $post_ID  = (int) $args[1];
     5176        $post_id  = (int) $args[1];
    51775177        $username = $args[2];
    51785178        $password = $args[3];
     
    51885188        do_action( 'xmlrpc_call', 'blogger.editPost', $args, $this );
    51895189
    5190         $actual_post = get_post( $post_ID, ARRAY_A );
     5190        $actual_post = get_post( $post_id, ARRAY_A );
    51915191
    51925192        if ( ! $actual_post || 'post' !== $actual_post['post_type'] ) {
     
    51965196        $this->escape( $actual_post );
    51975197
    5198         if ( ! current_user_can( 'edit_post', $post_ID ) ) {
     5198        if ( ! current_user_can( 'edit_post', $post_id ) ) {
    51995199            return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
    52005200        }
     
    52245224         * @since 3.4.0
    52255225         *
    5226          * @param int   $post_ID ID of the updated post.
     5226         * @param int   $post_id ID of the updated post.
    52275227         * @param array $args    An array of arguments for the post to edit.
    52285228         */
    5229         do_action( 'xmlrpc_call_success_blogger_editPost', $post_ID, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
     5229        do_action( 'xmlrpc_call_success_blogger_editPost', $post_id, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
    52305230
    52315231        return true;
     
    52505250        $this->escape( $args );
    52515251
    5252         $post_ID  = (int) $args[1];
     5252        $post_id  = (int) $args[1];
    52535253        $username = $args[2];
    52545254        $password = $args[3];
     
    52625262        do_action( 'xmlrpc_call', 'blogger.deletePost', $args, $this );
    52635263
    5264         $actual_post = get_post( $post_ID, ARRAY_A );
     5264        $actual_post = get_post( $post_id, ARRAY_A );
    52655265
    52665266        if ( ! $actual_post || 'post' !== $actual_post['post_type'] ) {
     
    52685268        }
    52695269
    5270         if ( ! current_user_can( 'delete_post', $post_ID ) ) {
     5270        if ( ! current_user_can( 'delete_post', $post_id ) ) {
    52715271            return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) );
    52725272        }
    52735273
    5274         $result = wp_delete_post( $post_ID );
     5274        $result = wp_delete_post( $post_id );
    52755275
    52765276        if ( ! $result ) {
     
    52835283         * @since 3.4.0
    52845284         *
    5285          * @param int   $post_ID ID of the deleted post.
     5285         * @param int   $post_id ID of the deleted post.
    52865286         * @param array $args    An array of arguments to delete the post.
    52875287         */
    5288         do_action( 'xmlrpc_call_success_blogger_deletePost', $post_ID, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
     5288        do_action( 'xmlrpc_call_success_blogger_deletePost', $post_id, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
    52895289
    52905290        return true;
     
    55815581        $postdata = compact( 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'to_ping', 'post_type', 'post_name', 'post_password', 'post_parent', 'menu_order', 'tags_input', 'page_template' );
    55825582
    5583         $post_ID        = get_default_post_to_edit( $post_type, true )->ID;
    5584         $postdata['ID'] = $post_ID;
     5583        $post_id        = get_default_post_to_edit( $post_type, true )->ID;
     5584        $postdata['ID'] = $post_id;
    55855585
    55865586        // Only posts can be sticky.
     
    55955595
    55965596        if ( isset( $content_struct['custom_fields'] ) ) {
    5597             $this->set_custom_fields( $post_ID, $content_struct['custom_fields'] );
     5597            $this->set_custom_fields( $post_id, $content_struct['custom_fields'] );
    55985598        }
    55995599
    56005600        if ( isset( $content_struct['wp_post_thumbnail'] ) ) {
    5601             if ( set_post_thumbnail( $post_ID, $content_struct['wp_post_thumbnail'] ) === false ) {
     5601            if ( set_post_thumbnail( $post_id, $content_struct['wp_post_thumbnail'] ) === false ) {
    56025602                return new IXR_Error( 404, __( 'Invalid attachment ID.' ) );
    56035603            }
     
    56085608        // Handle enclosures.
    56095609        $thisEnclosure = isset( $content_struct['enclosure'] ) ? $content_struct['enclosure'] : null;
    5610         $this->add_enclosure_if_new( $post_ID, $thisEnclosure );
    5611 
    5612         $this->attach_uploads( $post_ID, $post_content );
     5610        $this->add_enclosure_if_new( $post_id, $thisEnclosure );
     5611
     5612        $this->attach_uploads( $post_id, $post_content );
    56135613
    56145614        // Handle post formats if assigned, value is validated earlier
    56155615        // in this function.
    56165616        if ( isset( $content_struct['wp_post_format'] ) ) {
    5617             set_post_format( $post_ID, $content_struct['wp_post_format'] );
    5618         }
    5619 
    5620         $post_ID = wp_insert_post( $postdata, true );
    5621         if ( is_wp_error( $post_ID ) ) {
    5622             return new IXR_Error( 500, $post_ID->get_error_message() );
    5623         }
    5624 
    5625         if ( ! $post_ID ) {
     5617            set_post_format( $post_id, $content_struct['wp_post_format'] );
     5618        }
     5619
     5620        $post_id = wp_insert_post( $postdata, true );
     5621        if ( is_wp_error( $post_id ) ) {
     5622            return new IXR_Error( 500, $post_id->get_error_message() );
     5623        }
     5624
     5625        if ( ! $post_id ) {
    56265626            return new IXR_Error( 500, __( 'Sorry, the post could not be created.' ) );
    56275627        }
     
    56325632         * @since 3.4.0
    56335633         *
    5634          * @param int   $post_ID ID of the new post.
     5634         * @param int   $post_id ID of the new post.
    56355635         * @param array $args    An array of arguments to create the new post.
    56365636         */
    5637         do_action( 'xmlrpc_call_success_mw_newPost', $post_ID, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
    5638 
    5639         return (string) $post_ID;
     5637        do_action( 'xmlrpc_call_success_mw_newPost', $post_id, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
     5638
     5639        return (string) $post_id;
    56405640    }
    56415641
     
    56455645     * @since 2.8.0
    56465646     *
    5647      * @param int   $post_ID   Post ID.
     5647     * @param int   $post_id   Post ID.
    56485648     * @param array $enclosure Enclosure data.
    56495649     */
    5650     public function add_enclosure_if_new( $post_ID, $enclosure ) {
     5650    public function add_enclosure_if_new( $post_id, $enclosure ) {
    56515651        if ( is_array( $enclosure ) && isset( $enclosure['url'] ) && isset( $enclosure['length'] ) && isset( $enclosure['type'] ) ) {
    56525652            $encstring  = $enclosure['url'] . "\n" . $enclosure['length'] . "\n" . $enclosure['type'] . "\n";
    56535653            $found      = false;
    5654             $enclosures = get_post_meta( $post_ID, 'enclosure' );
     5654            $enclosures = get_post_meta( $post_id, 'enclosure' );
    56555655            if ( $enclosures ) {
    56565656                foreach ( $enclosures as $enc ) {
     
    56635663            }
    56645664            if ( ! $found ) {
    5665                 add_post_meta( $post_ID, 'enclosure', $encstring );
     5665                add_post_meta( $post_id, 'enclosure', $encstring );
    56665666            }
    56675667        }
     
    56755675     * @global wpdb $wpdb WordPress database abstraction object.
    56765676     *
    5677      * @param int    $post_ID      Post ID.
     5677     * @param int    $post_id      Post ID.
    56785678     * @param string $post_content Post Content for attachment.
    56795679     */
    5680     public function attach_uploads( $post_ID, $post_content ) {
     5680    public function attach_uploads( $post_id, $post_content ) {
    56815681        global $wpdb;
    56825682
     
    56865686            foreach ( $attachments as $file ) {
    56875687                if ( ! empty( $file->guid ) && strpos( $post_content, $file->guid ) !== false ) {
    5688                     $wpdb->update( $wpdb->posts, array( 'post_parent' => $post_ID ), array( 'ID' => $file->ID ) );
     5688                    $wpdb->update( $wpdb->posts, array( 'post_parent' => $post_id ), array( 'ID' => $file->ID ) );
    56895689                }
    56905690            }
     
    57115711        $this->escape( $args );
    57125712
    5713         $post_ID        = (int) $args[0];
     5713        $post_id        = (int) $args[0];
    57145714        $username       = $args[1];
    57155715        $password       = $args[2];
     
    57255725        do_action( 'xmlrpc_call', 'metaWeblog.editPost', $args, $this );
    57265726
    5727         $postdata = get_post( $post_ID, ARRAY_A );
     5727        $postdata = get_post( $post_id, ARRAY_A );
    57285728
    57295729        /*
     
    57355735        }
    57365736
    5737         if ( ! current_user_can( 'edit_post', $post_ID ) ) {
     5737        if ( ! current_user_can( 'edit_post', $post_id ) ) {
    57385738            return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
    57395739        }
     
    59845984
    59855985        if ( isset( $content_struct['custom_fields'] ) ) {
    5986             $this->set_custom_fields( $post_ID, $content_struct['custom_fields'] );
     5986            $this->set_custom_fields( $post_id, $content_struct['custom_fields'] );
    59875987        }
    59885988
     
    59915991            // Empty value deletes, non-empty value adds/updates.
    59925992            if ( empty( $content_struct['wp_post_thumbnail'] ) ) {
    5993                 delete_post_thumbnail( $post_ID );
     5993                delete_post_thumbnail( $post_id );
    59945994            } else {
    5995                 if ( set_post_thumbnail( $post_ID, $content_struct['wp_post_thumbnail'] ) === false ) {
     5995                if ( set_post_thumbnail( $post_id, $content_struct['wp_post_thumbnail'] ) === false ) {
    59965996                    return new IXR_Error( 404, __( 'Invalid attachment ID.' ) );
    59975997                }
     
    60026002        // Handle enclosures.
    60036003        $thisEnclosure = isset( $content_struct['enclosure'] ) ? $content_struct['enclosure'] : null;
    6004         $this->add_enclosure_if_new( $post_ID, $thisEnclosure );
     6004        $this->add_enclosure_if_new( $post_id, $thisEnclosure );
    60056005
    60066006        $this->attach_uploads( $ID, $post_content );
     
    60086008        // Handle post formats if assigned, validation is handled earlier in this function.
    60096009        if ( isset( $content_struct['wp_post_format'] ) ) {
    6010             set_post_format( $post_ID, $content_struct['wp_post_format'] );
     6010            set_post_format( $post_id, $content_struct['wp_post_format'] );
    60116011        }
    60126012
     
    60166016         * @since 3.4.0
    60176017         *
    6018          * @param int   $post_ID ID of the updated post.
     6018         * @param int   $post_id ID of the updated post.
    60196019         * @param array $args    An array of arguments to update the post.
    60206020         */
    6021         do_action( 'xmlrpc_call_success_mw_editPost', $post_ID, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
     6021        do_action( 'xmlrpc_call_success_mw_editPost', $post_id, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
    60226022
    60236023        return true;
     
    60416041        $this->escape( $args );
    60426042
    6043         $post_ID  = (int) $args[0];
     6043        $post_id  = (int) $args[0];
    60446044        $username = $args[1];
    60456045        $password = $args[2];
     
    60506050        }
    60516051
    6052         $postdata = get_post( $post_ID, ARRAY_A );
     6052        $postdata = get_post( $post_id, ARRAY_A );
    60536053        if ( ! $postdata ) {
    60546054            return new IXR_Error( 404, __( 'Invalid post ID.' ) );
    60556055        }
    60566056
    6057         if ( ! current_user_can( 'edit_post', $post_ID ) ) {
     6057        if ( ! current_user_can( 'edit_post', $post_id ) ) {
    60586058            return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
    60596059        }
     
    60696069
    60706070            $categories = array();
    6071             $catids     = wp_get_post_categories( $post_ID );
     6071            $catids     = wp_get_post_categories( $post_id );
    60726072            foreach ( $catids as $catid ) {
    60736073                $categories[] = get_cat_name( $catid );
     
    60756075
    60766076            $tagnames = array();
    6077             $tags     = wp_get_post_tags( $post_ID );
     6077            $tags     = wp_get_post_tags( $post_id );
    60786078            if ( ! empty( $tags ) ) {
    60796079                foreach ( $tags as $tag ) {
     
    61006100
    61016101            // Get post format.
    6102             $post_format = get_post_format( $post_ID );
     6102            $post_format = get_post_format( $post_id );
    61036103            if ( empty( $post_format ) ) {
    61046104                $post_format = 'standard';
     
    61066106
    61076107            $sticky = false;
    6108             if ( is_sticky( $post_ID ) ) {
     6108            if ( is_sticky( $post_id ) ) {
    61096109                $sticky = true;
    61106110            }
    61116111
    61126112            $enclosure = array();
    6113             foreach ( (array) get_post_custom( $post_ID ) as $key => $val ) {
     6113            foreach ( (array) get_post_custom( $post_id ) as $key => $val ) {
    61146114                if ( 'enclosure' === $key ) {
    61156115                    foreach ( (array) $val as $enc ) {
     
    61466146                'date_created_gmt'       => $post_date_gmt,
    61476147                'post_status'            => $postdata['post_status'],
    6148                 'custom_fields'          => $this->get_custom_fields( $post_ID ),
     6148                'custom_fields'          => $this->get_custom_fields( $post_id ),
    61496149                'wp_post_format'         => $post_format,
    61506150                'sticky'                 => $sticky,
     
    66046604        $this->escape( $args );
    66056605
    6606         $post_ID  = (int) $args[0];
     6606        $post_id  = (int) $args[0];
    66076607        $username = $args[1];
    66086608        $password = $args[2];
     
    66136613        }
    66146614
    6615         if ( ! get_post( $post_ID ) ) {
     6615        if ( ! get_post( $post_id ) ) {
    66166616            return new IXR_Error( 404, __( 'Invalid post ID.' ) );
    66176617        }
    66186618
    6619         if ( ! current_user_can( 'edit_post', $post_ID ) ) {
     6619        if ( ! current_user_can( 'edit_post', $post_id ) ) {
    66206620            return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
    66216621        }
     
    66256625
    66266626        $categories = array();
    6627         $catids     = wp_get_post_categories( (int) $post_ID );
     6627        $catids     = wp_get_post_categories( (int) $post_id );
    66286628        // First listed category will be the primary category.
    66296629        $isPrimary = true;
     
    66586658        $this->escape( $args );
    66596659
    6660         $post_ID    = (int) $args[0];
     6660        $post_id    = (int) $args[0];
    66616661        $username   = $args[1];
    66626662        $password   = $args[2];
     
    66716671        do_action( 'xmlrpc_call', 'mt.setPostCategories', $args, $this );
    66726672
    6673         if ( ! get_post( $post_ID ) ) {
     6673        if ( ! get_post( $post_id ) ) {
    66746674            return new IXR_Error( 404, __( 'Invalid post ID.' ) );
    66756675        }
    66766676
    6677         if ( ! current_user_can( 'edit_post', $post_ID ) ) {
     6677        if ( ! current_user_can( 'edit_post', $post_id ) ) {
    66786678            return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
    66796679        }
     
    66846684        }
    66856685
    6686         wp_set_post_categories( $post_ID, $catids );
     6686        wp_set_post_categories( $post_id, $catids );
    66876687
    66886688        return true;
     
    67296729     * @global wpdb $wpdb WordPress database abstraction object.
    67306730     *
    6731      * @param int $post_ID
     6731     * @param int $post_id
    67326732     * @return array|IXR_Error
    67336733     */
    6734     public function mt_getTrackbackPings( $post_ID ) {
     6734    public function mt_getTrackbackPings( $post_id ) {
    67356735        global $wpdb;
    67366736
    67376737        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    6738         do_action( 'xmlrpc_call', 'mt.getTrackbackPings', $post_ID, $this );
    6739 
    6740         $actual_post = get_post( $post_ID, ARRAY_A );
     6738        do_action( 'xmlrpc_call', 'mt.getTrackbackPings', $post_id, $this );
     6739
     6740        $actual_post = get_post( $post_id, ARRAY_A );
    67416741
    67426742        if ( ! $actual_post ) {
     
    67446744        }
    67456745
    6746         $comments = $wpdb->get_results( $wpdb->prepare( "SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->comments WHERE comment_post_ID = %d", $post_ID ) );
     6746        $comments = $wpdb->get_results( $wpdb->prepare( "SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->comments WHERE comment_post_ID = %d", $post_id ) );
    67476747
    67486748        if ( ! $comments ) {
     
    67836783        $this->escape( $args );
    67846784
    6785         $post_ID  = (int) $args[0];
     6785        $post_id  = (int) $args[0];
    67866786        $username = $args[1];
    67876787        $password = $args[2];
     
    67956795        do_action( 'xmlrpc_call', 'mt.publishPost', $args, $this );
    67966796
    6797         $postdata = get_post( $post_ID, ARRAY_A );
     6797        $postdata = get_post( $post_id, ARRAY_A );
    67986798        if ( ! $postdata ) {
    67996799            return new IXR_Error( 404, __( 'Invalid post ID.' ) );
    68006800        }
    68016801
    6802         if ( ! current_user_can( 'publish_posts' ) || ! current_user_can( 'edit_post', $post_ID ) ) {
     6802        if ( ! current_user_can( 'publish_posts' ) || ! current_user_can( 'edit_post', $post_id ) ) {
    68036803            return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish this post.' ) );
    68046804        }
     
    68076807
    68086808        // Retain old categories.
    6809         $postdata['post_category'] = wp_get_post_categories( $post_ID );
     6809        $postdata['post_category'] = wp_get_post_categories( $post_id );
    68106810        $this->escape( $postdata );
    68116811
     
    68716871         */
    68726872        $urltest = parse_url( $pagelinkedto );
    6873         $post_ID = url_to_postid( $pagelinkedto );
    6874         if ( $post_ID ) {
     6873        $post_id = url_to_postid( $pagelinkedto );
     6874        if ( $post_id ) {
    68756875            // $way
    68766876        } elseif ( isset( $urltest['path'] ) && preg_match( '#p/[0-9]{1,}#', $urltest['path'], $match ) ) {
    68776877            // The path defines the post_ID (archives/p/XXXX).
    68786878            $blah    = explode( '/', $match[0] );
    6879             $post_ID = (int) $blah[1];
     6879            $post_id = (int) $blah[1];
    68806880        } elseif ( isset( $urltest['query'] ) && preg_match( '#p=[0-9]{1,}#', $urltest['query'], $match ) ) {
    68816881            // The query string defines the post_ID (?p=XXXX).
    68826882            $blah    = explode( '=', $match[0] );
    6883             $post_ID = (int) $blah[1];
     6883            $post_id = (int) $blah[1];
    68846884        } elseif ( isset( $urltest['fragment'] ) ) {
    68856885            // An #anchor is there, it's either...
    68866886            if ( (int) $urltest['fragment'] ) {
    68876887                // ...an integer #XXXX (simplest case),
    6888                 $post_ID = (int) $urltest['fragment'];
     6888                $post_id = (int) $urltest['fragment'];
    68896889            } elseif ( preg_match( '/post-[0-9]+/', $urltest['fragment'] ) ) {
    68906890                // ...a post ID in the form 'post-###',
    6891                 $post_ID = preg_replace( '/[^0-9]+/', '', $urltest['fragment'] );
     6891                $post_id = preg_replace( '/[^0-9]+/', '', $urltest['fragment'] );
    68926892            } elseif ( is_string( $urltest['fragment'] ) ) {
    68936893                // ...or a string #title, a little more complicated.
    68946894                $title   = preg_replace( '/[^a-z0-9]/i', '.', $urltest['fragment'] );
    68956895                $sql     = $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_title RLIKE %s", $title );
    6896                 $post_ID = $wpdb->get_var( $sql );
    6897                 if ( ! $post_ID ) {
     6896                $post_id = $wpdb->get_var( $sql );
     6897                if ( ! $post_id ) {
    68986898                    // Returning unknown error '0' is better than die()'ing.
    68996899                    return $this->pingback_error( 0, '' );
     
    69046904            return $this->pingback_error( 33, __( 'The specified target URL cannot be used as a target. It either does not exist, or it is not a pingback-enabled resource.' ) );
    69056905        }
    6906         $post_ID = (int) $post_ID;
    6907 
    6908         $post = get_post( $post_ID );
     6906        $post_id = (int) $post_id;
     6907
     6908        $post = get_post( $post_id );
    69096909
    69106910        if ( ! $post ) { // Post not found.
     
    69126912        }
    69136913
    6914         if ( url_to_postid( $pagelinkedfrom ) == $post_ID ) {
     6914        if ( url_to_postid( $pagelinkedfrom ) == $post_id ) {
    69156915            return $this->pingback_error( 0, __( 'The source URL and the target URL cannot both point to the same resource.' ) );
    69166916        }
     
    69226922
    69236923        // Let's check that the remote site didn't already pingback this entry.
    6924         if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_author_url = %s", $post_ID, $pagelinkedfrom ) ) ) {
     6924        if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_author_url = %s", $post_id, $pagelinkedfrom ) ) ) {
    69256925            return $this->pingback_error( 48, __( 'The pingback has already been registered.' ) );
    69266926        }
     
    70217021        $pagelinkedfrom = $this->escape( $pagelinkedfrom );
    70227022
    7023         $comment_post_id      = (int) $post_ID;
     7023        $comment_post_id      = (int) $post_id;
    70247024        $comment_author       = $title;
    70257025        $comment_author_email = '';
     
    70837083        $url = $this->escape( $url );
    70847084
    7085         $post_ID = url_to_postid( $url );
    7086         if ( ! $post_ID ) {
     7085        $post_id = url_to_postid( $url );
     7086        if ( ! $post_id ) {
    70877087            // We aren't sure that the resource is available and/or pingback enabled.
    70887088            return $this->pingback_error( 33, __( 'The specified target URL cannot be used as a target. It either does not exist, or it is not a pingback-enabled resource.' ) );
    70897089        }
    70907090
    7091         $actual_post = get_post( $post_ID, ARRAY_A );
     7091        $actual_post = get_post( $post_id, ARRAY_A );
    70927092
    70937093        if ( ! $actual_post ) {
     
    70967096        }
    70977097
    7098         $comments = $wpdb->get_results( $wpdb->prepare( "SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->comments WHERE comment_post_ID = %d", $post_ID ) );
     7098        $comments = $wpdb->get_results( $wpdb->prepare( "SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->comments WHERE comment_post_ID = %d", $post_id ) );
    70997099
    71007100        if ( ! $comments ) {
  • trunk/src/wp-includes/deprecated.php

    r55334 r55365  
    742742 *
    743743 * @param int $blogid Not Used
    744  * @param int $post_ID
     744 * @param int $post_id
    745745 * @return array
    746746 */
    747 function wp_get_post_cats($blogid = '1', $post_ID = 0) {
     747function wp_get_post_cats($blogid = '1', $post_id = 0) {
    748748    _deprecated_function( __FUNCTION__, '2.1.0', 'wp_get_post_categories()' );
    749     return wp_get_post_categories($post_ID);
     749    return wp_get_post_categories($post_id);
    750750}
    751751
     
    759759 *
    760760 * @param int $blogid Not used
    761  * @param int $post_ID
     761 * @param int $post_id
    762762 * @param array $post_categories
    763763 * @return bool|mixed
    764764 */
    765 function wp_set_post_cats($blogid = '1', $post_ID = 0, $post_categories = array()) {
     765function wp_set_post_cats($blogid = '1', $post_id = 0, $post_categories = array()) {
    766766    _deprecated_function( __FUNCTION__, '2.1.0', 'wp_set_post_categories()' );
    767     return wp_set_post_categories($post_ID, $post_categories);
     767    return wp_set_post_categories($post_id, $post_categories);
    768768}
    769769
  • trunk/src/wp-includes/post.php

    r55252 r55365  
    40944094
    40954095    // Are we updating or creating?
    4096     $post_ID = 0;
     4096    $post_id = 0;
    40974097    $update  = false;
    40984098    $guid    = $postarr['guid'];
     
    41024102
    41034103        // Get the post ID and GUID.
    4104         $post_ID     = $postarr['ID'];
    4105         $post_before = get_post( $post_ID );
     4104        $post_id     = $postarr['ID'];
     4105        $post_before = get_post( $post_id );
    41064106
    41074107        if ( is_null( $post_before ) ) {
     
    41124112        }
    41134113
    4114         $guid            = get_post_field( 'guid', $post_ID );
    4115         $previous_status = get_post_field( 'post_status', $post_ID );
     4114        $guid            = get_post_field( 'guid', $post_id );
     4115        $previous_status = get_post_field( 'post_status', $post_id );
    41164116    } else {
    41174117        $previous_status = 'new';
     
    41954195        if ( ! $update && $post_type_object && ! current_user_can( $post_type_object->cap->publish_posts ) ) {
    41964196            $post_name = '';
    4197         } elseif ( $update && ! current_user_can( 'publish_post', $post_ID ) ) {
     4197        } elseif ( $update && ! current_user_can( 'publish_post', $post_id ) ) {
    41984198            $post_name = '';
    41994199        }
     
    42144214        $check_name = sanitize_title( $post_name, '', 'old-save' );
    42154215
    4216         if ( $update && strtolower( urlencode( $post_name ) ) == $check_name && get_post_field( 'post_name', $post_ID ) == $check_name ) {
     4216        if ( $update && strtolower( urlencode( $post_name ) ) == $check_name && get_post_field( 'post_name', $post_id ) == $check_name ) {
    42174217            $post_name = $check_name;
    42184218        } else { // New post, or slug has changed.
     
    43094309    $new_postarr = array_merge(
    43104310        array(
    4311             'ID' => $post_ID,
     4311            'ID' => $post_id,
    43124312        ),
    43134313        compact( array_diff( array_keys( $defaults ), array( 'context', 'filter' ) ) )
     
    43204320     *
    43214321     * @param int   $post_parent Post parent ID.
    4322      * @param int   $post_ID     Post ID.
     4322     * @param int   $post_id     Post ID.
    43234323     * @param array $new_postarr Array of parsed post data.
    43244324     * @param array $postarr     Array of sanitized, but otherwise unmodified post data.
    43254325     */
    4326     $post_parent = apply_filters( 'wp_insert_post_parent', $post_parent, $post_ID, $new_postarr, $postarr );
     4326    $post_parent = apply_filters( 'wp_insert_post_parent', $post_parent, $post_id, $new_postarr, $postarr );
    43274327
    43284328    /*
     
    43314331     */
    43324332    if ( 'trash' === $previous_status && 'trash' !== $post_status ) {
    4333         $desired_post_slug = get_post_meta( $post_ID, '_wp_desired_post_slug', true );
     4333        $desired_post_slug = get_post_meta( $post_id, '_wp_desired_post_slug', true );
    43344334
    43354335        if ( $desired_post_slug ) {
    4336             delete_post_meta( $post_ID, '_wp_desired_post_slug' );
     4336            delete_post_meta( $post_id, '_wp_desired_post_slug' );
    43374337            $post_name = $desired_post_slug;
    43384338        }
     
    43484348         * @param bool   $add_trashed_suffix Whether to attempt to add the suffix.
    43494349         * @param string $post_name          The name of the post being updated.
    4350          * @param int    $post_ID            Post ID.
     4350         * @param int    $post_id            Post ID.
    43514351         */
    4352         $add_trashed_suffix = apply_filters( 'add_trashed_suffix_to_trashed_posts', true, $post_name, $post_ID );
     4352        $add_trashed_suffix = apply_filters( 'add_trashed_suffix_to_trashed_posts', true, $post_name, $post_id );
    43534353
    43544354        if ( $add_trashed_suffix ) {
    4355             wp_add_trashed_suffix_to_post_name_for_trashed_posts( $post_name, $post_ID );
     4355            wp_add_trashed_suffix_to_post_name_for_trashed_posts( $post_name, $post_id );
    43564356        }
    43574357    }
     
    43594359    // When trashing an existing post, change its slug to allow non-trashed posts to use it.
    43604360    if ( 'trash' === $post_status && 'trash' !== $previous_status && 'new' !== $previous_status ) {
    4361         $post_name = wp_add_trashed_suffix_to_post_name_for_post( $post_ID );
    4362     }
    4363 
    4364     $post_name = wp_unique_post_slug( $post_name, $post_ID, $post_status, $post_type, $post_parent );
     4361        $post_name = wp_add_trashed_suffix_to_post_name_for_post( $post_id );
     4362    }
     4363
     4364    $post_name = wp_unique_post_slug( $post_name, $post_id, $post_status, $post_type, $post_parent );
    43654365
    43664366    // Don't unslash.
     
    44374437
    44384438    $data  = wp_unslash( $data );
    4439     $where = array( 'ID' => $post_ID );
     4439    $where = array( 'ID' => $post_id );
    44404440
    44414441    if ( $update ) {
     
    44454445         * @since 2.5.0
    44464446         *
    4447          * @param int   $post_ID Post ID.
     4447         * @param int   $post_id Post ID.
    44484448         * @param array $data    Array of unslashed post data.
    44494449         */
    4450         do_action( 'pre_post_update', $post_ID, $data );
     4450        do_action( 'pre_post_update', $post_id, $data );
    44514451
    44524452        if ( false === $wpdb->update( $wpdb->posts, $data, $where ) ) {
     
    44874487        }
    44884488
    4489         $post_ID = (int) $wpdb->insert_id;
    4490 
    4491         // Use the newly generated $post_ID.
    4492         $where = array( 'ID' => $post_ID );
     4489        $post_id = (int) $wpdb->insert_id;
     4490
     4491        // Use the newly generated $post_id.
     4492        $where = array( 'ID' => $post_id );
    44934493    }
    44944494
    44954495    if ( empty( $data['post_name'] ) && ! in_array( $data['post_status'], array( 'draft', 'pending', 'auto-draft' ), true ) ) {
    4496         $data['post_name'] = wp_unique_post_slug( sanitize_title( $data['post_title'], $post_ID ), $post_ID, $data['post_status'], $post_type, $post_parent );
     4496        $data['post_name'] = wp_unique_post_slug( sanitize_title( $data['post_title'], $post_id ), $post_id, $data['post_status'], $post_type, $post_parent );
    44974497
    44984498        $wpdb->update( $wpdb->posts, array( 'post_name' => $data['post_name'] ), $where );
    4499         clean_post_cache( $post_ID );
     4499        clean_post_cache( $post_id );
    45004500    }
    45014501
    45024502    if ( is_object_in_taxonomy( $post_type, 'category' ) ) {
    4503         wp_set_post_categories( $post_ID, $post_category );
     4503        wp_set_post_categories( $post_id, $post_category );
    45044504    }
    45054505
    45064506    if ( isset( $postarr['tags_input'] ) && is_object_in_taxonomy( $post_type, 'post_tag' ) ) {
    4507         wp_set_post_tags( $post_ID, $postarr['tags_input'] );
     4507        wp_set_post_tags( $post_id, $postarr['tags_input'] );
    45084508    }
    45094509
     
    45204520
    45214521                // Passed custom taxonomy list overwrites the existing list if not empty.
    4522                 $terms = wp_get_object_terms( $post_ID, $taxonomy, array( 'fields' => 'ids' ) );
     4522                $terms = wp_get_object_terms( $post_id, $taxonomy, array( 'fields' => 'ids' ) );
    45234523                if ( ! empty( $terms ) && empty( $postarr['tax_input'][ $taxonomy ] ) ) {
    45244524                    $postarr['tax_input'][ $taxonomy ] = $terms;
     
    45524552
    45534553            if ( current_user_can( $taxonomy_obj->cap->assign_terms ) ) {
    4554                 wp_set_post_terms( $post_ID, $tags, $taxonomy );
     4554                wp_set_post_terms( $post_id, $tags, $taxonomy );
    45554555            }
    45564556        }
     
    45594559    if ( ! empty( $postarr['meta_input'] ) ) {
    45604560        foreach ( $postarr['meta_input'] as $field => $value ) {
    4561             update_post_meta( $post_ID, $field, $value );
    4562         }
    4563     }
    4564 
    4565     $current_guid = get_post_field( 'guid', $post_ID );
     4561            update_post_meta( $post_id, $field, $value );
     4562        }
     4563    }
     4564
     4565    $current_guid = get_post_field( 'guid', $post_id );
    45664566
    45674567    // Set GUID.
    45684568    if ( ! $update && '' === $current_guid ) {
    4569         $wpdb->update( $wpdb->posts, array( 'guid' => get_permalink( $post_ID ) ), $where );
     4569        $wpdb->update( $wpdb->posts, array( 'guid' => get_permalink( $post_id ) ), $where );
    45704570    }
    45714571
    45724572    if ( 'attachment' === $postarr['post_type'] ) {
    45734573        if ( ! empty( $postarr['file'] ) ) {
    4574             update_attached_file( $post_ID, $postarr['file'] );
     4574            update_attached_file( $post_id, $postarr['file'] );
    45754575        }
    45764576
    45774577        if ( ! empty( $postarr['context'] ) ) {
    4578             add_post_meta( $post_ID, '_wp_attachment_context', $postarr['context'], true );
     4578            add_post_meta( $post_id, '_wp_attachment_context', $postarr['context'], true );
    45794579        }
    45804580    }
     
    45854585
    45864586        if ( ! $thumbnail_support && 'attachment' === $post_type && $post_mime_type ) {
    4587             if ( wp_attachment_is( 'audio', $post_ID ) ) {
     4587            if ( wp_attachment_is( 'audio', $post_id ) ) {
    45884588                $thumbnail_support = post_type_supports( 'attachment:audio', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:audio' );
    4589             } elseif ( wp_attachment_is( 'video', $post_ID ) ) {
     4589            } elseif ( wp_attachment_is( 'video', $post_id ) ) {
    45904590                $thumbnail_support = post_type_supports( 'attachment:video', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:video' );
    45914591            }
     
    45954595            $thumbnail_id = (int) $postarr['_thumbnail_id'];
    45964596            if ( -1 === $thumbnail_id ) {
    4597                 delete_post_thumbnail( $post_ID );
     4597                delete_post_thumbnail( $post_id );
    45984598            } else {
    4599                 set_post_thumbnail( $post_ID, $thumbnail_id );
     4599                set_post_thumbnail( $post_id, $thumbnail_id );
    46004600            }
    46014601        }
    46024602    }
    46034603
    4604     clean_post_cache( $post_ID );
    4605 
    4606     $post = get_post( $post_ID );
     4604    clean_post_cache( $post_id );
     4605
     4606    $post = get_post( $post_id );
    46074607
    46084608    if ( ! empty( $postarr['page_template'] ) ) {
     
    46154615            }
    46164616
    4617             update_post_meta( $post_ID, '_wp_page_template', 'default' );
     4617            update_post_meta( $post_id, '_wp_page_template', 'default' );
    46184618        } else {
    4619             update_post_meta( $post_ID, '_wp_page_template', $postarr['page_template'] );
     4619            update_post_meta( $post_id, '_wp_page_template', $postarr['page_template'] );
    46204620        }
    46214621    }
     
    46304630             * @since 2.0.0
    46314631             *
    4632              * @param int $post_ID Attachment ID.
     4632             * @param int $post_id Attachment ID.
    46334633             */
    4634             do_action( 'edit_attachment', $post_ID );
    4635 
    4636             $post_after = get_post( $post_ID );
     4634            do_action( 'edit_attachment', $post_id );
     4635
     4636            $post_after = get_post( $post_id );
    46374637
    46384638            /**
     
    46414641             * @since 4.4.0
    46424642             *
    4643              * @param int     $post_ID      Post ID.
     4643             * @param int     $post_id      Post ID.
    46444644             * @param WP_Post $post_after   Post object following the update.
    46454645             * @param WP_Post $post_before  Post object before the update.
    46464646             */
    4647             do_action( 'attachment_updated', $post_ID, $post_after, $post_before );
     4647            do_action( 'attachment_updated', $post_id, $post_after, $post_before );
    46484648        } else {
    46494649
     
    46534653             * @since 2.0.0
    46544654             *
    4655              * @param int $post_ID Attachment ID.
     4655             * @param int $post_id Attachment ID.
    46564656             */
    4657             do_action( 'add_attachment', $post_ID );
    4658         }
    4659 
    4660         return $post_ID;
     4657            do_action( 'add_attachment', $post_id );
     4658        }
     4659
     4660        return $post_id;
    46614661    }
    46624662
     
    46754675         * @since 5.1.0
    46764676         *
    4677          * @param int     $post_ID Post ID.
     4677         * @param int     $post_id Post ID.
    46784678         * @param WP_Post $post    Post object.
    46794679         */
    4680         do_action( "edit_post_{$post->post_type}", $post_ID, $post );
     4680        do_action( "edit_post_{$post->post_type}", $post_id, $post );
    46814681
    46824682        /**
     
    46854685         * @since 1.2.0
    46864686         *
    4687          * @param int     $post_ID Post ID.
     4687         * @param int     $post_id Post ID.
    46884688         * @param WP_Post $post    Post object.
    46894689         */
    4690         do_action( 'edit_post', $post_ID, $post );
    4691 
    4692         $post_after = get_post( $post_ID );
     4690        do_action( 'edit_post', $post_id, $post );
     4691
     4692        $post_after = get_post( $post_id );
    46934693
    46944694        /**
     
    46974697         * @since 3.0.0
    46984698         *
    4699          * @param int     $post_ID      Post ID.
     4699         * @param int     $post_id      Post ID.
    47004700         * @param WP_Post $post_after   Post object following the update.
    47014701         * @param WP_Post $post_before  Post object before the update.
    47024702         */
    4703         do_action( 'post_updated', $post_ID, $post_after, $post_before );
     4703        do_action( 'post_updated', $post_id, $post_after, $post_before );
    47044704    }
    47054705
     
    47174717     * @since 3.7.0
    47184718     *
    4719      * @param int     $post_ID Post ID.
     4719     * @param int     $post_id Post ID.
    47204720     * @param WP_Post $post    Post object.
    47214721     * @param bool    $update  Whether this is an existing post being updated.
    47224722     */
    4723     do_action( "save_post_{$post->post_type}", $post_ID, $post, $update );
     4723    do_action( "save_post_{$post->post_type}", $post_id, $post, $update );
    47244724
    47254725    /**
     
    47284728     * @since 1.5.0
    47294729     *
    4730      * @param int     $post_ID Post ID.
     4730     * @param int     $post_id Post ID.
    47314731     * @param WP_Post $post    Post object.
    47324732     * @param bool    $update  Whether this is an existing post being updated.
    47334733     */
    4734     do_action( 'save_post', $post_ID, $post, $update );
     4734    do_action( 'save_post', $post_id, $post, $update );
    47354735
    47364736    /**
     
    47394739     * @since 2.0.0
    47404740     *
    4741      * @param int     $post_ID Post ID.
     4741     * @param int     $post_id Post ID.
    47424742     * @param WP_Post $post    Post object.
    47434743     * @param bool    $update  Whether this is an existing post being updated.
    47444744     */
    4745     do_action( 'wp_insert_post', $post_ID, $post, $update );
     4745    do_action( 'wp_insert_post', $post_id, $post, $update );
    47464746
    47474747    if ( $fire_after_hooks ) {
     
    47494749    }
    47504750
    4751     return $post_ID;
     4751    return $post_id;
    47524752}
    47534753
     
    49944994 *
    49954995 * @param string $slug        The desired slug (post_name).
    4996  * @param int    $post_ID     Post ID.
     4996 * @param int    $post_id     Post ID.
    49974997 * @param string $post_status No uniqueness checks are made if the post is still draft or pending.
    49984998 * @param string $post_type   Post type.
     
    50005000 * @return string Unique slug for the post, based on $post_name (with a -1, -2, etc. suffix)
    50015001 */
    5002 function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_parent ) {
     5002function wp_unique_post_slug( $slug, $post_id, $post_status, $post_type, $post_parent ) {
    50035003    if ( in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ), true )
    50045004        || ( 'inherit' === $post_status && 'revision' === $post_type ) || 'user_request' === $post_type
     
    50175017     * @param string|null $override_slug Short-circuit return value.
    50185018     * @param string      $slug          The desired slug (post_name).
    5019      * @param int         $post_ID       Post ID.
     5019     * @param int         $post_id       Post ID.
    50205020     * @param string      $post_status   The post status.
    50215021     * @param string      $post_type     Post type.
    50225022     * @param int         $post_parent   Post parent ID.
    50235023     */
    5024     $override_slug = apply_filters( 'pre_wp_unique_post_slug', null, $slug, $post_ID, $post_status, $post_type, $post_parent );
     5024    $override_slug = apply_filters( 'pre_wp_unique_post_slug', null, $slug, $post_id, $post_status, $post_type, $post_parent );
    50255025    if ( null !== $override_slug ) {
    50265026        return $override_slug;
     
    50395039        // Attachment slugs must be unique across all types.
    50405040        $check_sql       = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND ID != %d LIMIT 1";
    5041         $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_ID ) );
     5041        $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_id ) );
    50425042
    50435043        /**
     
    50585058            do {
    50595059                $alt_post_name   = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
    5060                 $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_ID ) );
     5060                $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_id ) );
    50615061                $suffix++;
    50625062            } while ( $post_name_check );
     
    50735073         */
    50745074        $check_sql       = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type IN ( %s, 'attachment' ) AND ID != %d AND post_parent = %d LIMIT 1";
    5075         $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_ID, $post_parent ) );
     5075        $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_id, $post_parent ) );
    50765076
    50775077        /**
     
    50955095            do {
    50965096                $alt_post_name   = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
    5097                 $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_type, $post_ID, $post_parent ) );
     5097                $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_type, $post_id, $post_parent ) );
    50985098                $suffix++;
    50995099            } while ( $post_name_check );
     
    51035103        // Post slugs must be unique across all posts.
    51045104        $check_sql       = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d LIMIT 1";
    5105         $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_ID ) );
    5106 
    5107         $post = get_post( $post_ID );
     5105        $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_id ) );
     5106
     5107        $post = get_post( $post_id );
    51085108
    51095109        // Prevent new post slugs that could result in URLs that conflict with date archives.
     
    51515151            do {
    51525152                $alt_post_name   = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
    5153                 $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_type, $post_ID ) );
     5153                $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_type, $post_id ) );
    51545154                $suffix++;
    51555155            } while ( $post_name_check );
     
    51645164     *
    51655165     * @param string $slug          The post slug.
    5166      * @param int    $post_ID       Post ID.
     5166     * @param int    $post_id       Post ID.
    51675167     * @param string $post_status   The post status.
    51685168     * @param string $post_type     Post type.
     
    51705170     * @param string $original_slug The original post slug.
    51715171     */
    5172     return apply_filters( 'wp_unique_post_slug', $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug );
     5172    return apply_filters( 'wp_unique_post_slug', $slug, $post_id, $post_status, $post_type, $post_parent, $original_slug );
    51735173}
    51745174
     
    52865286 * @since 2.1.0
    52875287 *
    5288  * @param int       $post_ID         Optional. The Post ID. Does not default to the ID
     5288 * @param int       $post_id         Optional. The Post ID. Does not default to the ID
    52895289 *                                   of the global $post. Default 0.
    52905290 * @param int[]|int $post_categories Optional. List of category IDs, or the ID of a single category.
     
    52945294 * @return array|false|WP_Error Array of term taxonomy IDs of affected categories. WP_Error or false on failure.
    52955295 */
    5296 function wp_set_post_categories( $post_ID = 0, $post_categories = array(), $append = false ) {
    5297     $post_ID     = (int) $post_ID;
    5298     $post_type   = get_post_type( $post_ID );
    5299     $post_status = get_post_status( $post_ID );
     5296function wp_set_post_categories( $post_id = 0, $post_categories = array(), $append = false ) {
     5297    $post_id     = (int) $post_id;
     5298    $post_type   = get_post_type( $post_id );
     5299    $post_status = get_post_status( $post_id );
    53005300
    53015301    // If $post_categories isn't already an array, make it one.
     
    53285328    }
    53295329
    5330     return wp_set_post_terms( $post_ID, $post_categories, 'category', $append );
     5330    return wp_set_post_terms( $post_id, $post_categories, 'category', $append );
    53315331}
    53325332
     
    76727672 *
    76737673 * @param int $post_parent ID of the parent for the post we're checking.
    7674  * @param int $post_ID     ID of the post we're checking.
     7674 * @param int $post_id     ID of the post we're checking.
    76757675 * @return int The new post_parent for the post, 0 otherwise.
    76767676 */
    7677 function wp_check_post_hierarchy_for_loops( $post_parent, $post_ID ) {
     7677function wp_check_post_hierarchy_for_loops( $post_parent, $post_id ) {
    76787678    // Nothing fancy here - bail.
    76797679    if ( ! $post_parent ) {
     
    76827682
    76837683    // New post can't cause a loop.
    7684     if ( ! $post_ID ) {
     7684    if ( ! $post_id ) {
    76857685        return $post_parent;
    76867686    }
    76877687
    76887688    // Can't be its own parent.
    7689     if ( $post_parent == $post_ID ) {
     7689    if ( $post_parent == $post_id ) {
    76907690        return 0;
    76917691    }
    76927692
    76937693    // Now look for larger loops.
    7694     $loop = wp_find_hierarchy_loop( 'wp_get_post_parent_id', $post_ID, $post_parent );
     7694    $loop = wp_find_hierarchy_loop( 'wp_get_post_parent_id', $post_id, $post_parent );
    76957695    if ( ! $loop ) {
    76967696        return $post_parent; // No loop.
     
    76987698
    76997699    // Setting $post_parent to the given value causes a loop.
    7700     if ( isset( $loop[ $post_ID ] ) ) {
     7700    if ( isset( $loop[ $post_id ] ) ) {
    77017701        return 0;
    77027702    }
    77037703
    7704     // There's a loop, but it doesn't contain $post_ID. Break the loop.
     7704    // There's a loop, but it doesn't contain $post_id. Break the loop.
    77057705    foreach ( array_keys( $loop ) as $loop_member ) {
    77067706        wp_update_post(
     
    79187918 *
    79197919 * @param string $post_name Post slug.
    7920  * @param int    $post_ID   Optional. Post ID that should be ignored. Default 0.
    7921  */
    7922 function wp_add_trashed_suffix_to_post_name_for_trashed_posts( $post_name, $post_ID = 0 ) {
     7920 * @param int    $post_id   Optional. Post ID that should be ignored. Default 0.
     7921 */
     7922function wp_add_trashed_suffix_to_post_name_for_trashed_posts( $post_name, $post_id = 0 ) {
    79237923    $trashed_posts_with_desired_slug = get_posts(
    79247924        array(
     
    79277927            'post_type'    => 'any',
    79287928            'nopaging'     => true,
    7929             'post__not_in' => array( $post_ID ),
     7929            'post__not_in' => array( $post_id ),
    79307930        )
    79317931    );
  • trunk/src/wp-includes/theme-templates.php

    r55276 r55365  
    4040 * @param string $override_slug The filtered value of the slug (starts as `null` from apply_filter).
    4141 * @param string $slug          The original/un-filtered slug (post_name).
    42  * @param int    $post_ID       Post ID.
     42 * @param int    $post_id       Post ID.
    4343 * @param string $post_status   No uniqueness checks are made if the post is still draft or pending.
    4444 * @param string $post_type     Post type.
    4545 * @return string The original, desired slug.
    4646 */
    47 function wp_filter_wp_template_unique_post_slug( $override_slug, $slug, $post_ID, $post_status, $post_type ) {
     47function wp_filter_wp_template_unique_post_slug( $override_slug, $slug, $post_id, $post_status, $post_type ) {
    4848    if ( 'wp_template' !== $post_type && 'wp_template_part' !== $post_type ) {
    4949        return $override_slug;
     
    6262     */
    6363    $theme = get_stylesheet();
    64     $terms = get_the_terms( $post_ID, 'wp_theme' );
     64    $terms = get_the_terms( $post_id, 'wp_theme' );
    6565    if ( $terms && ! is_wp_error( $terms ) ) {
    6666        $theme = $terms[0]->name;
     
    7272        'posts_per_page' => 1,
    7373        'no_found_rows'  => true,
    74         'post__not_in'   => array( $post_ID ),
     74        'post__not_in'   => array( $post_id ),
    7575        'tax_query'      => array(
    7676            array(
  • trunk/tests/phpunit/tests/post.php

    r55115 r55365  
    468468    }
    469469
    470     public function filter_pre_wp_unique_post_slug( $override_slug, $slug, $post_ID, $post_status, $post_type, $post_parent ) {
     470    public function filter_pre_wp_unique_post_slug( $override_slug, $slug, $post_id, $post_status, $post_type, $post_parent ) {
    471471        return 'override-slug-' . $post_type;
    472472    }
  • trunk/tests/phpunit/tests/term/isObjectInTerm.php

    r52836 r55365  
    120120        $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
    121121
    122         $post_ID = self::factory()->post->create();
    123         wp_set_object_terms( $post_ID, $t, 'wptests_tax' );
     122        $post_id = self::factory()->post->create();
     123        wp_set_object_terms( $post_id, $t, 'wptests_tax' );
    124124
    125125        $int_tax_name = $t . '_term_name';
    126126
    127         $this->assertFalse( is_object_in_term( $post_ID, 'wptests_tax', $int_tax_name ) );
     127        $this->assertFalse( is_object_in_term( $post_id, 'wptests_tax', $int_tax_name ) );
    128128
    129129        // Verify it works properly when the post is actually in the term.
    130         wp_set_object_terms( $post_ID, array( $int_tax_name ), 'wptests_tax' );
    131         $this->assertTrue( is_object_in_term( $post_ID, 'wptests_tax', $int_tax_name ) );
     130        wp_set_object_terms( $post_id, array( $int_tax_name ), 'wptests_tax' );
     131        $this->assertTrue( is_object_in_term( $post_id, 'wptests_tax', $int_tax_name ) );
    132132    }
    133133
Note: See TracChangeset for help on using the changeset viewer.