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

The `$post_ID` variable is [546f59c678/WordPress/Sniffs/NamingConventions/ValidVariableNameSniff.php (L54) 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.
Built from https://develop.svn.wordpress.org/trunk@55365


git-svn-id: http://core.svn.wordpress.org/trunk@54898 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2023-02-19 15:05:22 +00:00
parent 454752d283
commit 1553e3fa00
8 changed files with 325 additions and 311 deletions

View File

@ -2034,19 +2034,19 @@ function wp_ajax_inline_save() {
wp_die();
}
$post_ID = (int) $_POST['post_ID'];
$post_id = (int) $_POST['post_ID'];
if ( 'page' === $_POST['post_type'] ) {
if ( ! current_user_can( 'edit_page', $post_ID ) ) {
if ( ! current_user_can( 'edit_page', $post_id ) ) {
wp_die( __( 'Sorry, you are not allowed to edit this page.' ) );
}
} else {
if ( ! current_user_can( 'edit_post', $post_ID ) ) {
if ( ! current_user_can( 'edit_post', $post_id ) ) {
wp_die( __( 'Sorry, you are not allowed to edit this post.' ) );
}
}
$last = wp_check_post_lock( $post_ID );
$last = wp_check_post_lock( $post_id );
if ( $last ) {
$last_user = get_userdata( $last );
$last_user_name = $last_user ? $last_user->display_name : __( 'Someone' );
@ -2065,7 +2065,7 @@ function wp_ajax_inline_save() {
$data = &$_POST;
$post = get_post( $post_ID, ARRAY_A );
$post = get_post( $post_id, ARRAY_A );
// Since it's coming from the database.
$post = wp_slash( $post );
@ -2699,30 +2699,30 @@ function wp_ajax_image_editor() {
function wp_ajax_set_post_thumbnail() {
$json = ! empty( $_REQUEST['json'] ); // New-style request.
$post_ID = (int) $_POST['post_id'];
if ( ! current_user_can( 'edit_post', $post_ID ) ) {
$post_id = (int) $_POST['post_id'];
if ( ! current_user_can( 'edit_post', $post_id ) ) {
wp_die( -1 );
}
$thumbnail_id = (int) $_POST['thumbnail_id'];
if ( $json ) {
check_ajax_referer( "update-post_$post_ID" );
check_ajax_referer( "update-post_$post_id" );
} else {
check_ajax_referer( "set_post_thumbnail-$post_ID" );
check_ajax_referer( "set_post_thumbnail-$post_id" );
}
if ( '-1' == $thumbnail_id ) {
if ( delete_post_thumbnail( $post_ID ) ) {
$return = _wp_post_thumbnail_html( null, $post_ID );
if ( delete_post_thumbnail( $post_id ) ) {
$return = _wp_post_thumbnail_html( null, $post_id );
$json ? wp_send_json_success( $return ) : wp_die( $return );
} else {
wp_die( 0 );
}
}
if ( set_post_thumbnail( $post_ID, $thumbnail_id ) ) {
$return = _wp_post_thumbnail_html( $thumbnail_id, $post_ID );
if ( set_post_thumbnail( $post_id, $thumbnail_id ) ) {
$return = _wp_post_thumbnail_html( $thumbnail_id, $post_id );
$json ? wp_send_json_success( $return ) : wp_die( $return );
}
@ -2735,11 +2735,11 @@ function wp_ajax_set_post_thumbnail() {
* @since 4.6.0
*/
function wp_ajax_get_post_thumbnail_html() {
$post_ID = (int) $_POST['post_id'];
$post_id = (int) $_POST['post_id'];
check_ajax_referer( "update-post_$post_ID" );
check_ajax_referer( "update-post_$post_id" );
if ( ! current_user_can( 'edit_post', $post_ID ) ) {
if ( ! current_user_can( 'edit_post', $post_id ) ) {
wp_die( -1 );
}
@ -2750,7 +2750,7 @@ function wp_ajax_get_post_thumbnail_html() {
$thumbnail_id = null;
}
$return = _wp_post_thumbnail_html( $thumbnail_id, $post_ID );
$return = _wp_post_thumbnail_html( $thumbnail_id, $post_id );
wp_send_json_success( $return );
}

View File

@ -252,8 +252,8 @@ function edit_post( $post_data = null ) {
// Clear out any data in internal vars.
unset( $post_data['filter'] );
$post_ID = (int) $post_data['post_ID'];
$post = get_post( $post_ID );
$post_id = (int) $post_data['post_ID'];
$post = get_post( $post_id );
$post_data['post_type'] = $post->post_type;
$post_data['post_mime_type'] = $post->post_mime_type;
@ -267,7 +267,7 @@ function edit_post( $post_data = null ) {
}
$ptype = get_post_type_object( $post_data['post_type'] );
if ( ! current_user_can( 'edit_post', $post_ID ) ) {
if ( ! current_user_can( 'edit_post', $post_id ) ) {
if ( 'page' === $post_data['post_type'] ) {
wp_die( __( 'Sorry, you are not allowed to edit this page.' ) );
} else {
@ -277,7 +277,7 @@ function edit_post( $post_data = null ) {
if ( post_type_supports( $ptype->name, 'revisions' ) ) {
$revisions = wp_get_post_revisions(
$post_ID,
$post_id,
array(
'order' => 'ASC',
'posts_per_page' => 1,
@ -287,7 +287,7 @@ function edit_post( $post_data = null ) {
// Check if the revisions have been upgraded.
if ( $revisions && _wp_get_post_revision_version( $revision ) < 1 ) {
_wp_upgrade_revisions_of_post( $post, wp_get_post_revisions( $post_ID ) );
_wp_upgrade_revisions_of_post( $post, wp_get_post_revisions( $post_id ) );
}
}
@ -315,14 +315,14 @@ function edit_post( $post_data = null ) {
// Post formats.
if ( isset( $post_data['post_format'] ) ) {
set_post_format( $post_ID, $post_data['post_format'] );
set_post_format( $post_id, $post_data['post_format'] );
}
$format_meta_urls = array( 'url', 'link_url', 'quote_source_url' );
foreach ( $format_meta_urls as $format_meta_url ) {
$keyed = '_format_' . $format_meta_url;
if ( isset( $post_data[ $keyed ] ) ) {
update_post_meta( $post_ID, $keyed, wp_slash( sanitize_url( wp_unslash( $post_data[ $keyed ] ) ) ) );
update_post_meta( $post_id, $keyed, wp_slash( sanitize_url( wp_unslash( $post_data[ $keyed ] ) ) ) );
}
}
@ -332,15 +332,15 @@ function edit_post( $post_data = null ) {
$keyed = '_format_' . $key;
if ( isset( $post_data[ $keyed ] ) ) {
if ( current_user_can( 'unfiltered_html' ) ) {
update_post_meta( $post_ID, $keyed, $post_data[ $keyed ] );
update_post_meta( $post_id, $keyed, $post_data[ $keyed ] );
} else {
update_post_meta( $post_ID, $keyed, wp_filter_post_kses( $post_data[ $keyed ] ) );
update_post_meta( $post_id, $keyed, wp_filter_post_kses( $post_data[ $keyed ] ) );
}
}
}
if ( 'attachment' === $post_data['post_type'] && preg_match( '#^(audio|video)/#', $post_data['post_mime_type'] ) ) {
$id3data = wp_get_attachment_metadata( $post_ID );
$id3data = wp_get_attachment_metadata( $post_id );
if ( ! is_array( $id3data ) ) {
$id3data = array();
}
@ -350,7 +350,7 @@ function edit_post( $post_data = null ) {
$id3data[ $key ] = sanitize_text_field( wp_unslash( $post_data[ 'id3_' . $key ] ) );
}
}
wp_update_attachment_metadata( $post_ID, $id3data );
wp_update_attachment_metadata( $post_id, $id3data );
}
// Meta stuff.
@ -360,15 +360,23 @@ function edit_post( $post_data = null ) {
if ( ! $meta ) {
continue;
}
if ( $meta->post_id != $post_ID ) {
if ( $meta->post_id != $post_id ) {
continue;
}
if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'edit_post_meta', $post_ID, $meta->meta_key ) ) {
if ( is_protected_meta( $meta->meta_key, 'post' )
|| ! current_user_can( 'edit_post_meta', $post_id, $meta->meta_key )
) {
continue;
}
if ( is_protected_meta( $value['key'], 'post' ) || ! current_user_can( 'edit_post_meta', $post_ID, $value['key'] ) ) {
if ( is_protected_meta( $value['key'], 'post' )
|| ! current_user_can( 'edit_post_meta', $post_id, $value['key'] )
) {
continue;
}
update_meta( $key, $value['key'], $value['value'] );
}
}
@ -379,12 +387,17 @@ function edit_post( $post_data = null ) {
if ( ! $meta ) {
continue;
}
if ( $meta->post_id != $post_ID ) {
if ( $meta->post_id != $post_id ) {
continue;
}
if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'delete_post_meta', $post_ID, $meta->meta_key ) ) {
if ( is_protected_meta( $meta->meta_key, 'post' )
|| ! current_user_can( 'delete_post_meta', $post_id, $meta->meta_key )
) {
continue;
}
delete_meta( $key );
}
}
@ -394,15 +407,15 @@ function edit_post( $post_data = null ) {
if ( isset( $post_data['_wp_attachment_image_alt'] ) ) {
$image_alt = wp_unslash( $post_data['_wp_attachment_image_alt'] );
if ( get_post_meta( $post_ID, '_wp_attachment_image_alt', true ) !== $image_alt ) {
if ( get_post_meta( $post_id, '_wp_attachment_image_alt', true ) !== $image_alt ) {
$image_alt = wp_strip_all_tags( $image_alt, true );
// update_post_meta() expects slashed.
update_post_meta( $post_ID, '_wp_attachment_image_alt', wp_slash( $image_alt ) );
update_post_meta( $post_id, '_wp_attachment_image_alt', wp_slash( $image_alt ) );
}
}
$attachment_data = isset( $post_data['attachments'][ $post_ID ] ) ? $post_data['attachments'][ $post_ID ] : array();
$attachment_data = isset( $post_data['attachments'][ $post_id ] ) ? $post_data['attachments'][ $post_id ] : array();
/** This filter is documented in wp-admin/includes/media.php */
$translated = apply_filters( 'attachment_fields_to_save', $translated, $attachment_data );
@ -419,9 +432,9 @@ function edit_post( $post_data = null ) {
}
}
add_meta( $post_ID );
add_meta( $post_id );
update_post_meta( $post_ID, '_edit_last', get_current_user_id() );
update_post_meta( $post_id, '_edit_last', get_current_user_id() );
$success = wp_update_post( $translated );
@ -439,19 +452,19 @@ function edit_post( $post_data = null ) {
}
// Now that we have an ID we can fix any attachment anchor hrefs.
_fix_attachment_links( $post_ID );
_fix_attachment_links( $post_id );
wp_set_post_lock( $post_ID );
wp_set_post_lock( $post_id );
if ( current_user_can( $ptype->cap->edit_others_posts ) && current_user_can( $ptype->cap->publish_posts ) ) {
if ( ! empty( $post_data['sticky'] ) ) {
stick_post( $post_ID );
stick_post( $post_id );
} else {
unstick_post( $post_ID );
unstick_post( $post_id );
}
}
return $post_ID;
return $post_id;
}
/**
@ -505,7 +518,7 @@ function bulk_edit_posts( $post_data = null ) {
}
}
$post_IDs = array_map( 'intval', (array) $post_data['post'] );
$post_ids = array_map( 'intval', (array) $post_data['post'] );
$reset = array(
'post_author',
@ -542,6 +555,7 @@ function bulk_edit_posts( $post_data = null ) {
if ( empty( $terms ) ) {
continue;
}
if ( is_taxonomy_hierarchical( $tax_name ) ) {
$tax_input[ $tax_name ] = array_map( 'absint', $terms );
} else {
@ -576,26 +590,26 @@ function bulk_edit_posts( $post_data = null ) {
$locked = array();
$shared_post_data = $post_data;
foreach ( $post_IDs as $post_ID ) {
foreach ( $post_ids as $post_id ) {
// Start with fresh post data with each iteration.
$post_data = $shared_post_data;
$post_type_object = get_post_type_object( get_post_type( $post_ID ) );
$post_type_object = get_post_type_object( get_post_type( $post_id ) );
if ( ! isset( $post_type_object )
|| ( isset( $children ) && in_array( $post_ID, $children, true ) )
|| ! current_user_can( 'edit_post', $post_ID )
|| ( isset( $children ) && in_array( $post_id, $children, true ) )
|| ! current_user_can( 'edit_post', $post_id )
) {
$skipped[] = $post_ID;
$skipped[] = $post_id;
continue;
}
if ( wp_check_post_lock( $post_ID ) ) {
$locked[] = $post_ID;
if ( wp_check_post_lock( $post_id ) ) {
$locked[] = $post_id;
continue;
}
$post = get_post( $post_ID );
$post = get_post( $post_id );
$tax_names = get_object_taxonomies( $post );
foreach ( $tax_names as $tax_name ) {
@ -612,21 +626,21 @@ function bulk_edit_posts( $post_data = null ) {
}
if ( $taxonomy_obj->hierarchical ) {
$current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array( 'fields' => 'ids' ) );
$current_terms = (array) wp_get_object_terms( $post_id, $tax_name, array( 'fields' => 'ids' ) );
} else {
$current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array( 'fields' => 'names' ) );
$current_terms = (array) wp_get_object_terms( $post_id, $tax_name, array( 'fields' => 'names' ) );
}
$post_data['tax_input'][ $tax_name ] = array_merge( $current_terms, $new_terms );
}
if ( isset( $new_cats ) && in_array( 'category', $tax_names, true ) ) {
$cats = (array) wp_get_post_categories( $post_ID );
$cats = (array) wp_get_post_categories( $post_id );
$post_data['post_category'] = array_unique( array_merge( $cats, $new_cats ) );
unset( $post_data['tax_input']['category'] );
}
$post_data['post_ID'] = $post_ID;
$post_data['post_ID'] = $post_id;
$post_data['post_type'] = $post->post_type;
$post_data['post_mime_type'] = $post->post_mime_type;
@ -638,13 +652,13 @@ function bulk_edit_posts( $post_data = null ) {
$post_data = _wp_translate_postdata( true, $post_data );
if ( is_wp_error( $post_data ) ) {
$skipped[] = $post_ID;
$skipped[] = $post_id;
continue;
}
$post_data = _wp_get_allowed_postdata( $post_data );
if ( isset( $shared_post_data['post_format'] ) ) {
set_post_format( $post_ID, $shared_post_data['post_format'] );
set_post_format( $post_id, $shared_post_data['post_format'] );
}
// Prevent wp_insert_post() from overwriting post format with the old data.
@ -656,9 +670,9 @@ function bulk_edit_posts( $post_data = null ) {
if ( isset( $post_data['sticky'] ) && current_user_can( $ptype->cap->edit_others_posts ) ) {
if ( 'sticky' === $post_data['sticky'] ) {
stick_post( $post_ID );
stick_post( $post_id );
} else {
unstick_post( $post_ID );
unstick_post( $post_id );
}
}
}
@ -887,25 +901,25 @@ function wp_write_post() {
$translated = _wp_get_allowed_postdata( $translated );
// Create the post.
$post_ID = wp_insert_post( $translated );
if ( is_wp_error( $post_ID ) ) {
return $post_ID;
$post_id = wp_insert_post( $translated );
if ( is_wp_error( $post_id ) ) {
return $post_id;
}
if ( empty( $post_ID ) ) {
if ( empty( $post_id ) ) {
return 0;
}
add_meta( $post_ID );
add_meta( $post_id );
add_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']->ID );
add_post_meta( $post_id, '_edit_last', $GLOBALS['current_user']->ID );
// Now that we have an ID we can fix any attachment anchor hrefs.
_fix_attachment_links( $post_ID );
_fix_attachment_links( $post_id );
wp_set_post_lock( $post_ID );
wp_set_post_lock( $post_id );
return $post_ID;
return $post_id;
}
/**
@ -933,11 +947,11 @@ function write_post() {
*
* @since 1.2.0
*
* @param int $post_ID
* @param int $post_id
* @return int|bool
*/
function add_meta( $post_ID ) {
$post_ID = (int) $post_ID;
function add_meta( $post_id ) {
$post_id = (int) $post_id;
$metakeyselect = isset( $_POST['metakeyselect'] ) ? wp_unslash( trim( $_POST['metakeyselect'] ) ) : '';
$metakeyinput = isset( $_POST['metakeyinput'] ) ? wp_unslash( trim( $_POST['metakeyinput'] ) ) : '';
@ -959,13 +973,13 @@ function add_meta( $post_ID ) {
$metakey = $metakeyinput; // Default.
}
if ( is_protected_meta( $metakey, 'post' ) || ! current_user_can( 'add_post_meta', $post_ID, $metakey ) ) {
if ( is_protected_meta( $metakey, 'post' ) || ! current_user_can( 'add_post_meta', $post_id, $metakey ) ) {
return false;
}
$metakey = wp_slash( $metakey );
return add_post_meta( $post_ID, $metakey, $metavalue );
return add_post_meta( $post_id, $metakey, $metavalue );
}
return false;
@ -1941,10 +1955,10 @@ function wp_create_post_autosave( $post_data ) {
*/
function post_preview() {
$post_ID = (int) $_POST['post_ID'];
$_POST['ID'] = $post_ID;
$post_id = (int) $_POST['post_ID'];
$_POST['ID'] = $post_id;
$post = get_post( $post_ID );
$post = get_post( $post_id );
if ( ! $post ) {
wp_die( __( 'Sorry, you are not allowed to edit this post.' ) );

View File

@ -222,11 +222,11 @@ class WP_Embed {
return $embed_handler_html;
}
$post_ID = ( ! empty( $post->ID ) ) ? $post->ID : null;
$post_id = ( ! empty( $post->ID ) ) ? $post->ID : null;
// Potentially set by WP_Embed::cache_oembed().
if ( ! empty( $this->post_ID ) ) {
$post_ID = $this->post_ID;
$post_id = $this->post_ID;
}
// Check for a cached result (stored as custom post or in the post meta).
@ -242,18 +242,18 @@ class WP_Embed {
* @param int $time Time to live (in seconds).
* @param string $url The attempted embed URL.
* @param array $attr An array of shortcode attributes.
* @param int $post_ID Post ID.
* @param int $post_id Post ID.
*/
$ttl = apply_filters( 'oembed_ttl', DAY_IN_SECONDS, $url, $attr, $post_ID );
$ttl = apply_filters( 'oembed_ttl', DAY_IN_SECONDS, $url, $attr, $post_id );
$cache = '';
$cache_time = 0;
$cached_post_id = $this->find_oembed_post_id( $key_suffix );
if ( $post_ID ) {
$cache = get_post_meta( $post_ID, $cachekey, true );
$cache_time = get_post_meta( $post_ID, $cachekey_time, true );
if ( $post_id ) {
$cache = get_post_meta( $post_id, $cachekey, true );
$cache_time = get_post_meta( $post_id, $cachekey_time, true );
if ( ! $cache_time ) {
$cache_time = 0;
@ -284,9 +284,9 @@ class WP_Embed {
* @param string|false $cache The cached HTML result, stored in post meta.
* @param string $url The attempted embed URL.
* @param array $attr An array of shortcode attributes.
* @param int $post_ID Post ID.
* @param int $post_id Post ID.
*/
return apply_filters( 'embed_oembed_html', $cache, $url, $attr, $post_ID );
return apply_filters( 'embed_oembed_html', $cache, $url, $attr, $post_id );
}
}
@ -305,12 +305,12 @@ class WP_Embed {
// Use oEmbed to get the HTML.
$html = wp_oembed_get( $url, $attr );
if ( $post_ID ) {
if ( $post_id ) {
if ( $html ) {
update_post_meta( $post_ID, $cachekey, $html );
update_post_meta( $post_ID, $cachekey_time, time() );
update_post_meta( $post_id, $cachekey, $html );
update_post_meta( $post_id, $cachekey_time, time() );
} elseif ( ! $cache ) {
update_post_meta( $post_ID, $cachekey, '{{unknown}}' );
update_post_meta( $post_id, $cachekey, '{{unknown}}' );
}
} else {
$has_kses = false !== has_filter( 'content_save_pre', 'wp_filter_post_kses' );
@ -369,7 +369,7 @@ class WP_Embed {
// If there was a result, return it.
if ( $html ) {
/** This filter is documented in wp-includes/class-wp-embed.php */
return apply_filters( 'embed_oembed_html', $html, $url, $attr, $post_ID );
return apply_filters( 'embed_oembed_html', $html, $url, $attr, $post_id );
}
// Still unknown.
@ -379,17 +379,17 @@ class WP_Embed {
/**
* Deletes all oEmbed caches. Unused by core as of 4.0.0.
*
* @param int $post_ID Post ID to delete the caches for.
* @param int $post_id Post ID to delete the caches for.
*/
public function delete_oembed_caches( $post_ID ) {
$post_metas = get_post_custom_keys( $post_ID );
public function delete_oembed_caches( $post_id ) {
$post_metas = get_post_custom_keys( $post_id );
if ( empty( $post_metas ) ) {
return;
}
foreach ( $post_metas as $post_meta_key ) {
if ( '_oembed_' === substr( $post_meta_key, 0, 8 ) ) {
delete_post_meta( $post_ID, $post_meta_key );
delete_post_meta( $post_id, $post_meta_key );
}
}
}
@ -397,10 +397,10 @@ class WP_Embed {
/**
* Triggers a caching of all oEmbed results.
*
* @param int $post_ID Post ID to do the caching for.
* @param int $post_id Post ID to do the caching for.
*/
public function cache_oembed( $post_ID ) {
$post = get_post( $post_ID );
public function cache_oembed( $post_id ) {
$post = get_post( $post_id );
$post_types = get_post_types( array( 'show_ui' => true ) );

View File

@ -1529,7 +1529,7 @@ class wp_xmlrpc_server extends IXR_Server {
if ( ! isset( $post_data['ID'] ) ) {
$post_data['ID'] = get_default_post_to_edit( $post_data['post_type'], true )->ID;
}
$post_ID = $post_data['ID'];
$post_id = $post_data['ID'];
if ( 'post' === $post_data['post_type'] ) {
$error = $this->_toggle_sticky( $post_data, $update );
@ -1541,16 +1541,16 @@ class wp_xmlrpc_server extends IXR_Server {
if ( isset( $post_data['post_thumbnail'] ) ) {
// Empty value deletes, non-empty value adds/updates.
if ( ! $post_data['post_thumbnail'] ) {
delete_post_thumbnail( $post_ID );
delete_post_thumbnail( $post_id );
} elseif ( ! get_post( absint( $post_data['post_thumbnail'] ) ) ) {
return new IXR_Error( 404, __( 'Invalid attachment ID.' ) );
}
set_post_thumbnail( $post_ID, $post_data['post_thumbnail'] );
set_post_thumbnail( $post_id, $post_data['post_thumbnail'] );
unset( $content_struct['post_thumbnail'] );
}
if ( isset( $post_data['custom_fields'] ) ) {
$this->set_custom_fields( $post_ID, $post_data['custom_fields'] );
$this->set_custom_fields( $post_id, $post_data['custom_fields'] );
}
if ( isset( $post_data['terms'] ) || isset( $post_data['terms_names'] ) ) {
@ -1656,7 +1656,7 @@ class wp_xmlrpc_server extends IXR_Server {
}
if ( isset( $post_data['post_format'] ) ) {
$format = set_post_format( $post_ID, $post_data['post_format'] );
$format = set_post_format( $post_id, $post_data['post_format'] );
if ( is_wp_error( $format ) ) {
return new IXR_Error( 500, $format->get_error_message() );
@ -1667,9 +1667,9 @@ class wp_xmlrpc_server extends IXR_Server {
// Handle enclosures.
$enclosure = isset( $post_data['enclosure'] ) ? $post_data['enclosure'] : null;
$this->add_enclosure_if_new( $post_ID, $enclosure );
$this->add_enclosure_if_new( $post_id, $enclosure );
$this->attach_uploads( $post_ID, $post_data['post_content'] );
$this->attach_uploads( $post_id, $post_data['post_content'] );
/**
* Filters post data array to be inserted via XML-RPC.
@ -1689,12 +1689,12 @@ class wp_xmlrpc_server extends IXR_Server {
}
);
$post_ID = $update ? wp_update_post( $post_data, true ) : wp_insert_post( $post_data, true );
if ( is_wp_error( $post_ID ) ) {
return new IXR_Error( 500, $post_ID->get_error_message() );
$post_id = $update ? wp_update_post( $post_data, true ) : wp_insert_post( $post_data, true );
if ( is_wp_error( $post_id ) ) {
return new IXR_Error( 500, $post_id->get_error_message() );
}
if ( ! $post_ID ) {
if ( ! $post_id ) {
if ( $update ) {
return new IXR_Error( 401, __( 'Sorry, the post could not be updated.' ) );
} else {
@ -1702,7 +1702,7 @@ class wp_xmlrpc_server extends IXR_Server {
}
}
return (string) $post_ID;
return (string) $post_id;
}
/**
@ -4942,7 +4942,7 @@ class wp_xmlrpc_server extends IXR_Server {
public function blogger_getPost( $args ) {
$this->escape( $args );
$post_ID = (int) $args[1];
$post_id = (int) $args[1];
$username = $args[2];
$password = $args[3];
@ -4951,19 +4951,19 @@ class wp_xmlrpc_server extends IXR_Server {
return $this->error;
}
$post_data = get_post( $post_ID, ARRAY_A );
$post_data = get_post( $post_id, ARRAY_A );
if ( ! $post_data ) {
return new IXR_Error( 404, __( 'Invalid post ID.' ) );
}
if ( ! current_user_can( 'edit_post', $post_ID ) ) {
if ( ! current_user_can( 'edit_post', $post_id ) ) {
return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
}
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'blogger.getPost', $args, $this );
$categories = implode( ',', wp_get_post_categories( $post_ID ) );
$categories = implode( ',', wp_get_post_categories( $post_id ) );
$content = '<title>' . wp_unslash( $post_data['post_title'] ) . '</title>';
$content .= '<category>' . $categories . '</category>';
@ -5128,28 +5128,28 @@ class wp_xmlrpc_server extends IXR_Server {
$post_data = compact( 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status' );
$post_ID = wp_insert_post( $post_data );
if ( is_wp_error( $post_ID ) ) {
return new IXR_Error( 500, $post_ID->get_error_message() );
$post_id = wp_insert_post( $post_data );
if ( is_wp_error( $post_id ) ) {
return new IXR_Error( 500, $post_id->get_error_message() );
}
if ( ! $post_ID ) {
if ( ! $post_id ) {
return new IXR_Error( 500, __( 'Sorry, the post could not be created.' ) );
}
$this->attach_uploads( $post_ID, $post_content );
$this->attach_uploads( $post_id, $post_content );
/**
* Fires after a new post has been successfully created via the XML-RPC Blogger API.
*
* @since 3.4.0
*
* @param int $post_ID ID of the new post.
* @param int $post_id ID of the new post.
* @param array $args An array of new post arguments.
*/
do_action( 'xmlrpc_call_success_blogger_newPost', $post_ID, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
do_action( 'xmlrpc_call_success_blogger_newPost', $post_id, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
return $post_ID;
return $post_id;
}
/**
@ -5173,7 +5173,7 @@ class wp_xmlrpc_server extends IXR_Server {
$this->escape( $args );
$post_ID = (int) $args[1];
$post_id = (int) $args[1];
$username = $args[2];
$password = $args[3];
$content = $args[4];
@ -5187,7 +5187,7 @@ class wp_xmlrpc_server extends IXR_Server {
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'blogger.editPost', $args, $this );
$actual_post = get_post( $post_ID, ARRAY_A );
$actual_post = get_post( $post_id, ARRAY_A );
if ( ! $actual_post || 'post' !== $actual_post['post_type'] ) {
return new IXR_Error( 404, __( 'Sorry, no such post.' ) );
@ -5195,7 +5195,7 @@ class wp_xmlrpc_server extends IXR_Server {
$this->escape( $actual_post );
if ( ! current_user_can( 'edit_post', $post_ID ) ) {
if ( ! current_user_can( 'edit_post', $post_id ) ) {
return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
}
if ( 'publish' === $actual_post['post_status'] && ! current_user_can( 'publish_posts' ) ) {
@ -5223,10 +5223,10 @@ class wp_xmlrpc_server extends IXR_Server {
*
* @since 3.4.0
*
* @param int $post_ID ID of the updated post.
* @param int $post_id ID of the updated post.
* @param array $args An array of arguments for the post to edit.
*/
do_action( 'xmlrpc_call_success_blogger_editPost', $post_ID, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
do_action( 'xmlrpc_call_success_blogger_editPost', $post_id, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
return true;
}
@ -5249,7 +5249,7 @@ class wp_xmlrpc_server extends IXR_Server {
public function blogger_deletePost( $args ) {
$this->escape( $args );
$post_ID = (int) $args[1];
$post_id = (int) $args[1];
$username = $args[2];
$password = $args[3];
@ -5261,17 +5261,17 @@ class wp_xmlrpc_server extends IXR_Server {
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'blogger.deletePost', $args, $this );
$actual_post = get_post( $post_ID, ARRAY_A );
$actual_post = get_post( $post_id, ARRAY_A );
if ( ! $actual_post || 'post' !== $actual_post['post_type'] ) {
return new IXR_Error( 404, __( 'Sorry, no such post.' ) );
}
if ( ! current_user_can( 'delete_post', $post_ID ) ) {
if ( ! current_user_can( 'delete_post', $post_id ) ) {
return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) );
}
$result = wp_delete_post( $post_ID );
$result = wp_delete_post( $post_id );
if ( ! $result ) {
return new IXR_Error( 500, __( 'Sorry, the post could not be deleted.' ) );
@ -5282,10 +5282,10 @@ class wp_xmlrpc_server extends IXR_Server {
*
* @since 3.4.0
*
* @param int $post_ID ID of the deleted post.
* @param int $post_id ID of the deleted post.
* @param array $args An array of arguments to delete the post.
*/
do_action( 'xmlrpc_call_success_blogger_deletePost', $post_ID, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
do_action( 'xmlrpc_call_success_blogger_deletePost', $post_id, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
return true;
}
@ -5580,8 +5580,8 @@ class wp_xmlrpc_server extends IXR_Server {
$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' );
$post_ID = get_default_post_to_edit( $post_type, true )->ID;
$postdata['ID'] = $post_ID;
$post_id = get_default_post_to_edit( $post_type, true )->ID;
$postdata['ID'] = $post_id;
// Only posts can be sticky.
if ( 'post' === $post_type && isset( $content_struct['sticky'] ) ) {
@ -5594,11 +5594,11 @@ class wp_xmlrpc_server extends IXR_Server {
}
if ( isset( $content_struct['custom_fields'] ) ) {
$this->set_custom_fields( $post_ID, $content_struct['custom_fields'] );
$this->set_custom_fields( $post_id, $content_struct['custom_fields'] );
}
if ( isset( $content_struct['wp_post_thumbnail'] ) ) {
if ( set_post_thumbnail( $post_ID, $content_struct['wp_post_thumbnail'] ) === false ) {
if ( set_post_thumbnail( $post_id, $content_struct['wp_post_thumbnail'] ) === false ) {
return new IXR_Error( 404, __( 'Invalid attachment ID.' ) );
}
@ -5607,22 +5607,22 @@ class wp_xmlrpc_server extends IXR_Server {
// Handle enclosures.
$thisEnclosure = isset( $content_struct['enclosure'] ) ? $content_struct['enclosure'] : null;
$this->add_enclosure_if_new( $post_ID, $thisEnclosure );
$this->add_enclosure_if_new( $post_id, $thisEnclosure );
$this->attach_uploads( $post_ID, $post_content );
$this->attach_uploads( $post_id, $post_content );
// Handle post formats if assigned, value is validated earlier
// in this function.
if ( isset( $content_struct['wp_post_format'] ) ) {
set_post_format( $post_ID, $content_struct['wp_post_format'] );
set_post_format( $post_id, $content_struct['wp_post_format'] );
}
$post_ID = wp_insert_post( $postdata, true );
if ( is_wp_error( $post_ID ) ) {
return new IXR_Error( 500, $post_ID->get_error_message() );
$post_id = wp_insert_post( $postdata, true );
if ( is_wp_error( $post_id ) ) {
return new IXR_Error( 500, $post_id->get_error_message() );
}
if ( ! $post_ID ) {
if ( ! $post_id ) {
return new IXR_Error( 500, __( 'Sorry, the post could not be created.' ) );
}
@ -5631,12 +5631,12 @@ class wp_xmlrpc_server extends IXR_Server {
*
* @since 3.4.0
*
* @param int $post_ID ID of the new post.
* @param int $post_id ID of the new post.
* @param array $args An array of arguments to create the new post.
*/
do_action( 'xmlrpc_call_success_mw_newPost', $post_ID, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
do_action( 'xmlrpc_call_success_mw_newPost', $post_id, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
return (string) $post_ID;
return (string) $post_id;
}
/**
@ -5644,14 +5644,14 @@ class wp_xmlrpc_server extends IXR_Server {
*
* @since 2.8.0
*
* @param int $post_ID Post ID.
* @param int $post_id Post ID.
* @param array $enclosure Enclosure data.
*/
public function add_enclosure_if_new( $post_ID, $enclosure ) {
public function add_enclosure_if_new( $post_id, $enclosure ) {
if ( is_array( $enclosure ) && isset( $enclosure['url'] ) && isset( $enclosure['length'] ) && isset( $enclosure['type'] ) ) {
$encstring = $enclosure['url'] . "\n" . $enclosure['length'] . "\n" . $enclosure['type'] . "\n";
$found = false;
$enclosures = get_post_meta( $post_ID, 'enclosure' );
$enclosures = get_post_meta( $post_id, 'enclosure' );
if ( $enclosures ) {
foreach ( $enclosures as $enc ) {
// This method used to omit the trailing new line. #23219
@ -5662,7 +5662,7 @@ class wp_xmlrpc_server extends IXR_Server {
}
}
if ( ! $found ) {
add_post_meta( $post_ID, 'enclosure', $encstring );
add_post_meta( $post_id, 'enclosure', $encstring );
}
}
}
@ -5674,10 +5674,10 @@ class wp_xmlrpc_server extends IXR_Server {
*
* @global wpdb $wpdb WordPress database abstraction object.
*
* @param int $post_ID Post ID.
* @param int $post_id Post ID.
* @param string $post_content Post Content for attachment.
*/
public function attach_uploads( $post_ID, $post_content ) {
public function attach_uploads( $post_id, $post_content ) {
global $wpdb;
// Find any unattached files.
@ -5685,7 +5685,7 @@ class wp_xmlrpc_server extends IXR_Server {
if ( is_array( $attachments ) ) {
foreach ( $attachments as $file ) {
if ( ! empty( $file->guid ) && strpos( $post_content, $file->guid ) !== false ) {
$wpdb->update( $wpdb->posts, array( 'post_parent' => $post_ID ), array( 'ID' => $file->ID ) );
$wpdb->update( $wpdb->posts, array( 'post_parent' => $post_id ), array( 'ID' => $file->ID ) );
}
}
}
@ -5710,7 +5710,7 @@ class wp_xmlrpc_server extends IXR_Server {
public function mw_editPost( $args ) {
$this->escape( $args );
$post_ID = (int) $args[0];
$post_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
$content_struct = $args[3];
@ -5724,7 +5724,7 @@ class wp_xmlrpc_server extends IXR_Server {
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'metaWeblog.editPost', $args, $this );
$postdata = get_post( $post_ID, ARRAY_A );
$postdata = get_post( $post_id, ARRAY_A );
/*
* If there is no post data for the give post ID, stop now and return an error.
@ -5734,7 +5734,7 @@ class wp_xmlrpc_server extends IXR_Server {
return new IXR_Error( 404, __( 'Invalid post ID.' ) );
}
if ( ! current_user_can( 'edit_post', $post_ID ) ) {
if ( ! current_user_can( 'edit_post', $post_id ) ) {
return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
}
@ -5983,16 +5983,16 @@ class wp_xmlrpc_server extends IXR_Server {
}
if ( isset( $content_struct['custom_fields'] ) ) {
$this->set_custom_fields( $post_ID, $content_struct['custom_fields'] );
$this->set_custom_fields( $post_id, $content_struct['custom_fields'] );
}
if ( isset( $content_struct['wp_post_thumbnail'] ) ) {
// Empty value deletes, non-empty value adds/updates.
if ( empty( $content_struct['wp_post_thumbnail'] ) ) {
delete_post_thumbnail( $post_ID );
delete_post_thumbnail( $post_id );
} else {
if ( set_post_thumbnail( $post_ID, $content_struct['wp_post_thumbnail'] ) === false ) {
if ( set_post_thumbnail( $post_id, $content_struct['wp_post_thumbnail'] ) === false ) {
return new IXR_Error( 404, __( 'Invalid attachment ID.' ) );
}
}
@ -6001,13 +6001,13 @@ class wp_xmlrpc_server extends IXR_Server {
// Handle enclosures.
$thisEnclosure = isset( $content_struct['enclosure'] ) ? $content_struct['enclosure'] : null;
$this->add_enclosure_if_new( $post_ID, $thisEnclosure );
$this->add_enclosure_if_new( $post_id, $thisEnclosure );
$this->attach_uploads( $ID, $post_content );
// Handle post formats if assigned, validation is handled earlier in this function.
if ( isset( $content_struct['wp_post_format'] ) ) {
set_post_format( $post_ID, $content_struct['wp_post_format'] );
set_post_format( $post_id, $content_struct['wp_post_format'] );
}
/**
@ -6015,10 +6015,10 @@ class wp_xmlrpc_server extends IXR_Server {
*
* @since 3.4.0
*
* @param int $post_ID ID of the updated post.
* @param int $post_id ID of the updated post.
* @param array $args An array of arguments to update the post.
*/
do_action( 'xmlrpc_call_success_mw_editPost', $post_ID, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
do_action( 'xmlrpc_call_success_mw_editPost', $post_id, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
return true;
}
@ -6040,7 +6040,7 @@ class wp_xmlrpc_server extends IXR_Server {
public function mw_getPost( $args ) {
$this->escape( $args );
$post_ID = (int) $args[0];
$post_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
@ -6049,12 +6049,12 @@ class wp_xmlrpc_server extends IXR_Server {
return $this->error;
}
$postdata = get_post( $post_ID, ARRAY_A );
$postdata = get_post( $post_id, ARRAY_A );
if ( ! $postdata ) {
return new IXR_Error( 404, __( 'Invalid post ID.' ) );
}
if ( ! current_user_can( 'edit_post', $post_ID ) ) {
if ( ! current_user_can( 'edit_post', $post_id ) ) {
return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
}
@ -6068,13 +6068,13 @@ class wp_xmlrpc_server extends IXR_Server {
$post_modified_gmt = $this->_convert_date_gmt( $postdata['post_modified_gmt'], $postdata['post_modified'] );
$categories = array();
$catids = wp_get_post_categories( $post_ID );
$catids = wp_get_post_categories( $post_id );
foreach ( $catids as $catid ) {
$categories[] = get_cat_name( $catid );
}
$tagnames = array();
$tags = wp_get_post_tags( $post_ID );
$tags = wp_get_post_tags( $post_id );
if ( ! empty( $tags ) ) {
foreach ( $tags as $tag ) {
$tagnames[] = $tag->name;
@ -6099,18 +6099,18 @@ class wp_xmlrpc_server extends IXR_Server {
}
// Get post format.
$post_format = get_post_format( $post_ID );
$post_format = get_post_format( $post_id );
if ( empty( $post_format ) ) {
$post_format = 'standard';
}
$sticky = false;
if ( is_sticky( $post_ID ) ) {
if ( is_sticky( $post_id ) ) {
$sticky = true;
}
$enclosure = array();
foreach ( (array) get_post_custom( $post_ID ) as $key => $val ) {
foreach ( (array) get_post_custom( $post_id ) as $key => $val ) {
if ( 'enclosure' === $key ) {
foreach ( (array) $val as $enc ) {
$encdata = explode( "\n", $enc );
@ -6145,7 +6145,7 @@ class wp_xmlrpc_server extends IXR_Server {
'wp_author_display_name' => $author->display_name,
'date_created_gmt' => $post_date_gmt,
'post_status' => $postdata['post_status'],
'custom_fields' => $this->get_custom_fields( $post_ID ),
'custom_fields' => $this->get_custom_fields( $post_id ),
'wp_post_format' => $post_format,
'sticky' => $sticky,
'date_modified' => $post_modified,
@ -6603,7 +6603,7 @@ class wp_xmlrpc_server extends IXR_Server {
public function mt_getPostCategories( $args ) {
$this->escape( $args );
$post_ID = (int) $args[0];
$post_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
@ -6612,11 +6612,11 @@ class wp_xmlrpc_server extends IXR_Server {
return $this->error;
}
if ( ! get_post( $post_ID ) ) {
if ( ! get_post( $post_id ) ) {
return new IXR_Error( 404, __( 'Invalid post ID.' ) );
}
if ( ! current_user_can( 'edit_post', $post_ID ) ) {
if ( ! current_user_can( 'edit_post', $post_id ) ) {
return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
}
@ -6624,7 +6624,7 @@ class wp_xmlrpc_server extends IXR_Server {
do_action( 'xmlrpc_call', 'mt.getPostCategories', $args, $this );
$categories = array();
$catids = wp_get_post_categories( (int) $post_ID );
$catids = wp_get_post_categories( (int) $post_id );
// First listed category will be the primary category.
$isPrimary = true;
foreach ( $catids as $catid ) {
@ -6657,7 +6657,7 @@ class wp_xmlrpc_server extends IXR_Server {
public function mt_setPostCategories( $args ) {
$this->escape( $args );
$post_ID = (int) $args[0];
$post_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
$categories = $args[3];
@ -6670,11 +6670,11 @@ class wp_xmlrpc_server extends IXR_Server {
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'mt.setPostCategories', $args, $this );
if ( ! get_post( $post_ID ) ) {
if ( ! get_post( $post_id ) ) {
return new IXR_Error( 404, __( 'Invalid post ID.' ) );
}
if ( ! current_user_can( 'edit_post', $post_ID ) ) {
if ( ! current_user_can( 'edit_post', $post_id ) ) {
return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
}
@ -6683,7 +6683,7 @@ class wp_xmlrpc_server extends IXR_Server {
$catids[] = $cat['categoryId'];
}
wp_set_post_categories( $post_ID, $catids );
wp_set_post_categories( $post_id, $catids );
return true;
}
@ -6728,22 +6728,22 @@ class wp_xmlrpc_server extends IXR_Server {
*
* @global wpdb $wpdb WordPress database abstraction object.
*
* @param int $post_ID
* @param int $post_id
* @return array|IXR_Error
*/
public function mt_getTrackbackPings( $post_ID ) {
public function mt_getTrackbackPings( $post_id ) {
global $wpdb;
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'mt.getTrackbackPings', $post_ID, $this );
do_action( 'xmlrpc_call', 'mt.getTrackbackPings', $post_id, $this );
$actual_post = get_post( $post_ID, ARRAY_A );
$actual_post = get_post( $post_id, ARRAY_A );
if ( ! $actual_post ) {
return new IXR_Error( 404, __( 'Sorry, no such post.' ) );
}
$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 ) );
$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 ) );
if ( ! $comments ) {
return array();
@ -6782,7 +6782,7 @@ class wp_xmlrpc_server extends IXR_Server {
public function mt_publishPost( $args ) {
$this->escape( $args );
$post_ID = (int) $args[0];
$post_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
@ -6794,19 +6794,19 @@ class wp_xmlrpc_server extends IXR_Server {
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'mt.publishPost', $args, $this );
$postdata = get_post( $post_ID, ARRAY_A );
$postdata = get_post( $post_id, ARRAY_A );
if ( ! $postdata ) {
return new IXR_Error( 404, __( 'Invalid post ID.' ) );
}
if ( ! current_user_can( 'publish_posts' ) || ! current_user_can( 'edit_post', $post_ID ) ) {
if ( ! current_user_can( 'publish_posts' ) || ! current_user_can( 'edit_post', $post_id ) ) {
return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish this post.' ) );
}
$postdata['post_status'] = 'publish';
// Retain old categories.
$postdata['post_category'] = wp_get_post_categories( $post_ID );
$postdata['post_category'] = wp_get_post_categories( $post_id );
$this->escape( $postdata );
return wp_update_post( $postdata );
@ -6870,31 +6870,31 @@ class wp_xmlrpc_server extends IXR_Server {
* If so, then let's use it and drop the old code.
*/
$urltest = parse_url( $pagelinkedto );
$post_ID = url_to_postid( $pagelinkedto );
if ( $post_ID ) {
$post_id = url_to_postid( $pagelinkedto );
if ( $post_id ) {
// $way
} elseif ( isset( $urltest['path'] ) && preg_match( '#p/[0-9]{1,}#', $urltest['path'], $match ) ) {
// The path defines the post_ID (archives/p/XXXX).
$blah = explode( '/', $match[0] );
$post_ID = (int) $blah[1];
$post_id = (int) $blah[1];
} elseif ( isset( $urltest['query'] ) && preg_match( '#p=[0-9]{1,}#', $urltest['query'], $match ) ) {
// The query string defines the post_ID (?p=XXXX).
$blah = explode( '=', $match[0] );
$post_ID = (int) $blah[1];
$post_id = (int) $blah[1];
} elseif ( isset( $urltest['fragment'] ) ) {
// An #anchor is there, it's either...
if ( (int) $urltest['fragment'] ) {
// ...an integer #XXXX (simplest case),
$post_ID = (int) $urltest['fragment'];
$post_id = (int) $urltest['fragment'];
} elseif ( preg_match( '/post-[0-9]+/', $urltest['fragment'] ) ) {
// ...a post ID in the form 'post-###',
$post_ID = preg_replace( '/[^0-9]+/', '', $urltest['fragment'] );
$post_id = preg_replace( '/[^0-9]+/', '', $urltest['fragment'] );
} elseif ( is_string( $urltest['fragment'] ) ) {
// ...or a string #title, a little more complicated.
$title = preg_replace( '/[^a-z0-9]/i', '.', $urltest['fragment'] );
$sql = $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_title RLIKE %s", $title );
$post_ID = $wpdb->get_var( $sql );
if ( ! $post_ID ) {
$post_id = $wpdb->get_var( $sql );
if ( ! $post_id ) {
// Returning unknown error '0' is better than die()'ing.
return $this->pingback_error( 0, '' );
}
@ -6903,15 +6903,15 @@ class wp_xmlrpc_server extends IXR_Server {
// TODO: Attempt to extract a post ID from the given URL.
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.' ) );
}
$post_ID = (int) $post_ID;
$post_id = (int) $post_id;
$post = get_post( $post_ID );
$post = get_post( $post_id );
if ( ! $post ) { // Post not found.
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.' ) );
}
if ( url_to_postid( $pagelinkedfrom ) == $post_ID ) {
if ( url_to_postid( $pagelinkedfrom ) == $post_id ) {
return $this->pingback_error( 0, __( 'The source URL and the target URL cannot both point to the same resource.' ) );
}
@ -6921,7 +6921,7 @@ class wp_xmlrpc_server extends IXR_Server {
}
// Let's check that the remote site didn't already pingback this entry.
if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_author_url = %s", $post_ID, $pagelinkedfrom ) ) ) {
if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_author_url = %s", $post_id, $pagelinkedfrom ) ) ) {
return $this->pingback_error( 48, __( 'The pingback has already been registered.' ) );
}
@ -7020,7 +7020,7 @@ class wp_xmlrpc_server extends IXR_Server {
$context = '[&#8230;] ' . esc_html( $excerpt ) . ' [&#8230;]';
$pagelinkedfrom = $this->escape( $pagelinkedfrom );
$comment_post_id = (int) $post_ID;
$comment_post_id = (int) $post_id;
$comment_author = $title;
$comment_author_email = '';
$this->escape( $comment_author );
@ -7082,20 +7082,20 @@ class wp_xmlrpc_server extends IXR_Server {
$url = $this->escape( $url );
$post_ID = url_to_postid( $url );
if ( ! $post_ID ) {
$post_id = url_to_postid( $url );
if ( ! $post_id ) {
// We aren't sure that the resource is available and/or pingback enabled.
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.' ) );
}
$actual_post = get_post( $post_ID, ARRAY_A );
$actual_post = get_post( $post_id, ARRAY_A );
if ( ! $actual_post ) {
// No such post = resource not found.
return $this->pingback_error( 32, __( 'The specified target URL does not exist.' ) );
}
$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 ) );
$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 ) );
if ( ! $comments ) {
return array();

View File

@ -741,12 +741,12 @@ function list_authors($optioncount = false, $exclude_admin = true, $show_fullnam
* @see wp_get_post_categories()
*
* @param int $blogid Not Used
* @param int $post_ID
* @param int $post_id
* @return array
*/
function wp_get_post_cats($blogid = '1', $post_ID = 0) {
function wp_get_post_cats($blogid = '1', $post_id = 0) {
_deprecated_function( __FUNCTION__, '2.1.0', 'wp_get_post_categories()' );
return wp_get_post_categories($post_ID);
return wp_get_post_categories($post_id);
}
/**
@ -758,13 +758,13 @@ function wp_get_post_cats($blogid = '1', $post_ID = 0) {
* @see wp_set_post_categories()
*
* @param int $blogid Not used
* @param int $post_ID
* @param int $post_id
* @param array $post_categories
* @return bool|mixed
*/
function wp_set_post_cats($blogid = '1', $post_ID = 0, $post_categories = array()) {
function wp_set_post_cats($blogid = '1', $post_id = 0, $post_categories = array()) {
_deprecated_function( __FUNCTION__, '2.1.0', 'wp_set_post_categories()' );
return wp_set_post_categories($post_ID, $post_categories);
return wp_set_post_categories($post_id, $post_categories);
}
/**

View File

@ -4093,7 +4093,7 @@ function wp_insert_post( $postarr, $wp_error = false, $fire_after_hooks = true )
$postarr = sanitize_post( $postarr, 'db' );
// Are we updating or creating?
$post_ID = 0;
$post_id = 0;
$update = false;
$guid = $postarr['guid'];
@ -4101,8 +4101,8 @@ function wp_insert_post( $postarr, $wp_error = false, $fire_after_hooks = true )
$update = true;
// Get the post ID and GUID.
$post_ID = $postarr['ID'];
$post_before = get_post( $post_ID );
$post_id = $postarr['ID'];
$post_before = get_post( $post_id );
if ( is_null( $post_before ) ) {
if ( $wp_error ) {
@ -4111,8 +4111,8 @@ function wp_insert_post( $postarr, $wp_error = false, $fire_after_hooks = true )
return 0;
}
$guid = get_post_field( 'guid', $post_ID );
$previous_status = get_post_field( 'post_status', $post_ID );
$guid = get_post_field( 'guid', $post_id );
$previous_status = get_post_field( 'post_status', $post_id );
} else {
$previous_status = 'new';
$post_before = null;
@ -4194,7 +4194,7 @@ function wp_insert_post( $postarr, $wp_error = false, $fire_after_hooks = true )
if ( ! $update && $post_type_object && ! current_user_can( $post_type_object->cap->publish_posts ) ) {
$post_name = '';
} elseif ( $update && ! current_user_can( 'publish_post', $post_ID ) ) {
} elseif ( $update && ! current_user_can( 'publish_post', $post_id ) ) {
$post_name = '';
}
}
@ -4213,7 +4213,7 @@ function wp_insert_post( $postarr, $wp_error = false, $fire_after_hooks = true )
// On updates, we need to check to see if it's using the old, fixed sanitization context.
$check_name = sanitize_title( $post_name, '', 'old-save' );
if ( $update && strtolower( urlencode( $post_name ) ) == $check_name && get_post_field( 'post_name', $post_ID ) == $check_name ) {
if ( $update && strtolower( urlencode( $post_name ) ) == $check_name && get_post_field( 'post_name', $post_id ) == $check_name ) {
$post_name = $check_name;
} else { // New post, or slug has changed.
$post_name = sanitize_title( $post_name );
@ -4308,7 +4308,7 @@ function wp_insert_post( $postarr, $wp_error = false, $fire_after_hooks = true )
$new_postarr = array_merge(
array(
'ID' => $post_ID,
'ID' => $post_id,
),
compact( array_diff( array_keys( $defaults ), array( 'context', 'filter' ) ) )
);
@ -4319,21 +4319,21 @@ function wp_insert_post( $postarr, $wp_error = false, $fire_after_hooks = true )
* @since 3.1.0
*
* @param int $post_parent Post parent ID.
* @param int $post_ID Post ID.
* @param int $post_id Post ID.
* @param array $new_postarr Array of parsed post data.
* @param array $postarr Array of sanitized, but otherwise unmodified post data.
*/
$post_parent = apply_filters( 'wp_insert_post_parent', $post_parent, $post_ID, $new_postarr, $postarr );
$post_parent = apply_filters( 'wp_insert_post_parent', $post_parent, $post_id, $new_postarr, $postarr );
/*
* If the post is being untrashed and it has a desired slug stored in post meta,
* reassign it.
*/
if ( 'trash' === $previous_status && 'trash' !== $post_status ) {
$desired_post_slug = get_post_meta( $post_ID, '_wp_desired_post_slug', true );
$desired_post_slug = get_post_meta( $post_id, '_wp_desired_post_slug', true );
if ( $desired_post_slug ) {
delete_post_meta( $post_ID, '_wp_desired_post_slug' );
delete_post_meta( $post_id, '_wp_desired_post_slug' );
$post_name = $desired_post_slug;
}
}
@ -4347,21 +4347,21 @@ function wp_insert_post( $postarr, $wp_error = false, $fire_after_hooks = true )
*
* @param bool $add_trashed_suffix Whether to attempt to add the suffix.
* @param string $post_name The name of the post being updated.
* @param int $post_ID Post ID.
* @param int $post_id Post ID.
*/
$add_trashed_suffix = apply_filters( 'add_trashed_suffix_to_trashed_posts', true, $post_name, $post_ID );
$add_trashed_suffix = apply_filters( 'add_trashed_suffix_to_trashed_posts', true, $post_name, $post_id );
if ( $add_trashed_suffix ) {
wp_add_trashed_suffix_to_post_name_for_trashed_posts( $post_name, $post_ID );
wp_add_trashed_suffix_to_post_name_for_trashed_posts( $post_name, $post_id );
}
}
// When trashing an existing post, change its slug to allow non-trashed posts to use it.
if ( 'trash' === $post_status && 'trash' !== $previous_status && 'new' !== $previous_status ) {
$post_name = wp_add_trashed_suffix_to_post_name_for_post( $post_ID );
$post_name = wp_add_trashed_suffix_to_post_name_for_post( $post_id );
}
$post_name = wp_unique_post_slug( $post_name, $post_ID, $post_status, $post_type, $post_parent );
$post_name = wp_unique_post_slug( $post_name, $post_id, $post_status, $post_type, $post_parent );
// Don't unslash.
$post_mime_type = isset( $postarr['post_mime_type'] ) ? $postarr['post_mime_type'] : '';
@ -4436,7 +4436,7 @@ function wp_insert_post( $postarr, $wp_error = false, $fire_after_hooks = true )
}
$data = wp_unslash( $data );
$where = array( 'ID' => $post_ID );
$where = array( 'ID' => $post_id );
if ( $update ) {
/**
@ -4444,10 +4444,10 @@ function wp_insert_post( $postarr, $wp_error = false, $fire_after_hooks = true )
*
* @since 2.5.0
*
* @param int $post_ID Post ID.
* @param int $post_id Post ID.
* @param array $data Array of unslashed post data.
*/
do_action( 'pre_post_update', $post_ID, $data );
do_action( 'pre_post_update', $post_id, $data );
if ( false === $wpdb->update( $wpdb->posts, $data, $where ) ) {
if ( $wp_error ) {
@ -4486,25 +4486,25 @@ function wp_insert_post( $postarr, $wp_error = false, $fire_after_hooks = true )
}
}
$post_ID = (int) $wpdb->insert_id;
$post_id = (int) $wpdb->insert_id;
// Use the newly generated $post_ID.
$where = array( 'ID' => $post_ID );
// Use the newly generated $post_id.
$where = array( 'ID' => $post_id );
}
if ( empty( $data['post_name'] ) && ! in_array( $data['post_status'], array( 'draft', 'pending', 'auto-draft' ), true ) ) {
$data['post_name'] = wp_unique_post_slug( sanitize_title( $data['post_title'], $post_ID ), $post_ID, $data['post_status'], $post_type, $post_parent );
$data['post_name'] = wp_unique_post_slug( sanitize_title( $data['post_title'], $post_id ), $post_id, $data['post_status'], $post_type, $post_parent );
$wpdb->update( $wpdb->posts, array( 'post_name' => $data['post_name'] ), $where );
clean_post_cache( $post_ID );
clean_post_cache( $post_id );
}
if ( is_object_in_taxonomy( $post_type, 'category' ) ) {
wp_set_post_categories( $post_ID, $post_category );
wp_set_post_categories( $post_id, $post_category );
}
if ( isset( $postarr['tags_input'] ) && is_object_in_taxonomy( $post_type, 'post_tag' ) ) {
wp_set_post_tags( $post_ID, $postarr['tags_input'] );
wp_set_post_tags( $post_id, $postarr['tags_input'] );
}
// Add default term for all associated custom taxonomies.
@ -4519,7 +4519,7 @@ function wp_insert_post( $postarr, $wp_error = false, $fire_after_hooks = true )
}
// Passed custom taxonomy list overwrites the existing list if not empty.
$terms = wp_get_object_terms( $post_ID, $taxonomy, array( 'fields' => 'ids' ) );
$terms = wp_get_object_terms( $post_id, $taxonomy, array( 'fields' => 'ids' ) );
if ( ! empty( $terms ) && empty( $postarr['tax_input'][ $taxonomy ] ) ) {
$postarr['tax_input'][ $taxonomy ] = $terms;
}
@ -4551,31 +4551,31 @@ function wp_insert_post( $postarr, $wp_error = false, $fire_after_hooks = true )
}
if ( current_user_can( $taxonomy_obj->cap->assign_terms ) ) {
wp_set_post_terms( $post_ID, $tags, $taxonomy );
wp_set_post_terms( $post_id, $tags, $taxonomy );
}
}
}
if ( ! empty( $postarr['meta_input'] ) ) {
foreach ( $postarr['meta_input'] as $field => $value ) {
update_post_meta( $post_ID, $field, $value );
update_post_meta( $post_id, $field, $value );
}
}
$current_guid = get_post_field( 'guid', $post_ID );
$current_guid = get_post_field( 'guid', $post_id );
// Set GUID.
if ( ! $update && '' === $current_guid ) {
$wpdb->update( $wpdb->posts, array( 'guid' => get_permalink( $post_ID ) ), $where );
$wpdb->update( $wpdb->posts, array( 'guid' => get_permalink( $post_id ) ), $where );
}
if ( 'attachment' === $postarr['post_type'] ) {
if ( ! empty( $postarr['file'] ) ) {
update_attached_file( $post_ID, $postarr['file'] );
update_attached_file( $post_id, $postarr['file'] );
}
if ( ! empty( $postarr['context'] ) ) {
add_post_meta( $post_ID, '_wp_attachment_context', $postarr['context'], true );
add_post_meta( $post_id, '_wp_attachment_context', $postarr['context'], true );
}
}
@ -4584,9 +4584,9 @@ function wp_insert_post( $postarr, $wp_error = false, $fire_after_hooks = true )
$thumbnail_support = current_theme_supports( 'post-thumbnails', $post_type ) && post_type_supports( $post_type, 'thumbnail' ) || 'revision' === $post_type;
if ( ! $thumbnail_support && 'attachment' === $post_type && $post_mime_type ) {
if ( wp_attachment_is( 'audio', $post_ID ) ) {
if ( wp_attachment_is( 'audio', $post_id ) ) {
$thumbnail_support = post_type_supports( 'attachment:audio', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:audio' );
} elseif ( wp_attachment_is( 'video', $post_ID ) ) {
} elseif ( wp_attachment_is( 'video', $post_id ) ) {
$thumbnail_support = post_type_supports( 'attachment:video', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:video' );
}
}
@ -4594,16 +4594,16 @@ function wp_insert_post( $postarr, $wp_error = false, $fire_after_hooks = true )
if ( $thumbnail_support ) {
$thumbnail_id = (int) $postarr['_thumbnail_id'];
if ( -1 === $thumbnail_id ) {
delete_post_thumbnail( $post_ID );
delete_post_thumbnail( $post_id );
} else {
set_post_thumbnail( $post_ID, $thumbnail_id );
set_post_thumbnail( $post_id, $thumbnail_id );
}
}
}
clean_post_cache( $post_ID );
clean_post_cache( $post_id );
$post = get_post( $post_ID );
$post = get_post( $post_id );
if ( ! empty( $postarr['page_template'] ) ) {
$post->page_template = $postarr['page_template'];
@ -4614,9 +4614,9 @@ function wp_insert_post( $postarr, $wp_error = false, $fire_after_hooks = true )
return new WP_Error( 'invalid_page_template', __( 'Invalid page template.' ) );
}
update_post_meta( $post_ID, '_wp_page_template', 'default' );
update_post_meta( $post_id, '_wp_page_template', 'default' );
} else {
update_post_meta( $post_ID, '_wp_page_template', $postarr['page_template'] );
update_post_meta( $post_id, '_wp_page_template', $postarr['page_template'] );
}
}
@ -4629,22 +4629,22 @@ function wp_insert_post( $postarr, $wp_error = false, $fire_after_hooks = true )
*
* @since 2.0.0
*
* @param int $post_ID Attachment ID.
* @param int $post_id Attachment ID.
*/
do_action( 'edit_attachment', $post_ID );
do_action( 'edit_attachment', $post_id );
$post_after = get_post( $post_ID );
$post_after = get_post( $post_id );
/**
* Fires once an existing attachment has been updated.
*
* @since 4.4.0
*
* @param int $post_ID Post ID.
* @param int $post_id Post ID.
* @param WP_Post $post_after Post object following the update.
* @param WP_Post $post_before Post object before the update.
*/
do_action( 'attachment_updated', $post_ID, $post_after, $post_before );
do_action( 'attachment_updated', $post_id, $post_after, $post_before );
} else {
/**
@ -4652,12 +4652,12 @@ function wp_insert_post( $postarr, $wp_error = false, $fire_after_hooks = true )
*
* @since 2.0.0
*
* @param int $post_ID Attachment ID.
* @param int $post_id Attachment ID.
*/
do_action( 'add_attachment', $post_ID );
do_action( 'add_attachment', $post_id );
}
return $post_ID;
return $post_id;
}
if ( $update ) {
@ -4674,33 +4674,33 @@ function wp_insert_post( $postarr, $wp_error = false, $fire_after_hooks = true )
*
* @since 5.1.0
*
* @param int $post_ID Post ID.
* @param int $post_id Post ID.
* @param WP_Post $post Post object.
*/
do_action( "edit_post_{$post->post_type}", $post_ID, $post );
do_action( "edit_post_{$post->post_type}", $post_id, $post );
/**
* Fires once an existing post has been updated.
*
* @since 1.2.0
*
* @param int $post_ID Post ID.
* @param int $post_id Post ID.
* @param WP_Post $post Post object.
*/
do_action( 'edit_post', $post_ID, $post );
do_action( 'edit_post', $post_id, $post );
$post_after = get_post( $post_ID );
$post_after = get_post( $post_id );
/**
* Fires once an existing post has been updated.
*
* @since 3.0.0
*
* @param int $post_ID Post ID.
* @param int $post_id Post ID.
* @param WP_Post $post_after Post object following the update.
* @param WP_Post $post_before Post object before the update.
*/
do_action( 'post_updated', $post_ID, $post_after, $post_before );
do_action( 'post_updated', $post_id, $post_after, $post_before );
}
/**
@ -4716,39 +4716,39 @@ function wp_insert_post( $postarr, $wp_error = false, $fire_after_hooks = true )
*
* @since 3.7.0
*
* @param int $post_ID Post ID.
* @param int $post_id Post ID.
* @param WP_Post $post Post object.
* @param bool $update Whether this is an existing post being updated.
*/
do_action( "save_post_{$post->post_type}", $post_ID, $post, $update );
do_action( "save_post_{$post->post_type}", $post_id, $post, $update );
/**
* Fires once a post has been saved.
*
* @since 1.5.0
*
* @param int $post_ID Post ID.
* @param int $post_id Post ID.
* @param WP_Post $post Post object.
* @param bool $update Whether this is an existing post being updated.
*/
do_action( 'save_post', $post_ID, $post, $update );
do_action( 'save_post', $post_id, $post, $update );
/**
* Fires once a post has been saved.
*
* @since 2.0.0
*
* @param int $post_ID Post ID.
* @param int $post_id Post ID.
* @param WP_Post $post Post object.
* @param bool $update Whether this is an existing post being updated.
*/
do_action( 'wp_insert_post', $post_ID, $post, $update );
do_action( 'wp_insert_post', $post_id, $post, $update );
if ( $fire_after_hooks ) {
wp_after_insert_post( $post, $update, $post_before );
}
return $post_ID;
return $post_id;
}
/**
@ -4993,13 +4993,13 @@ function wp_resolve_post_date( $post_date = '', $post_date_gmt = '' ) {
* @global WP_Rewrite $wp_rewrite WordPress rewrite component.
*
* @param string $slug The desired slug (post_name).
* @param int $post_ID Post ID.
* @param int $post_id Post ID.
* @param string $post_status No uniqueness checks are made if the post is still draft or pending.
* @param string $post_type Post type.
* @param int $post_parent Post parent ID.
* @return string Unique slug for the post, based on $post_name (with a -1, -2, etc. suffix)
*/
function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_parent ) {
function wp_unique_post_slug( $slug, $post_id, $post_status, $post_type, $post_parent ) {
if ( in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ), true )
|| ( 'inherit' === $post_status && 'revision' === $post_type ) || 'user_request' === $post_type
) {
@ -5016,12 +5016,12 @@ function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_p
*
* @param string|null $override_slug Short-circuit return value.
* @param string $slug The desired slug (post_name).
* @param int $post_ID Post ID.
* @param int $post_id Post ID.
* @param string $post_status The post status.
* @param string $post_type Post type.
* @param int $post_parent Post parent ID.
*/
$override_slug = apply_filters( 'pre_wp_unique_post_slug', null, $slug, $post_ID, $post_status, $post_type, $post_parent );
$override_slug = apply_filters( 'pre_wp_unique_post_slug', null, $slug, $post_id, $post_status, $post_type, $post_parent );
if ( null !== $override_slug ) {
return $override_slug;
}
@ -5038,7 +5038,7 @@ function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_p
if ( 'attachment' === $post_type ) {
// Attachment slugs must be unique across all types.
$check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND ID != %d LIMIT 1";
$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_ID ) );
$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_id ) );
/**
* Filters whether the post slug would make a bad attachment slug.
@ -5057,7 +5057,7 @@ function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_p
$suffix = 2;
do {
$alt_post_name = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_ID ) );
$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_id ) );
$suffix++;
} while ( $post_name_check );
$slug = $alt_post_name;
@ -5072,7 +5072,7 @@ function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_p
* namespace than posts so page slugs are allowed to overlap post slugs.
*/
$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";
$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_ID, $post_parent ) );
$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_id, $post_parent ) );
/**
* Filters whether the post slug would make a bad hierarchical post slug.
@ -5094,7 +5094,7 @@ function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_p
$suffix = 2;
do {
$alt_post_name = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_type, $post_ID, $post_parent ) );
$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_type, $post_id, $post_parent ) );
$suffix++;
} while ( $post_name_check );
$slug = $alt_post_name;
@ -5102,9 +5102,9 @@ function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_p
} else {
// Post slugs must be unique across all posts.
$check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d LIMIT 1";
$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_ID ) );
$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_id ) );
$post = get_post( $post_ID );
$post = get_post( $post_id );
// Prevent new post slugs that could result in URLs that conflict with date archives.
$conflicts_with_date_archive = false;
@ -5150,7 +5150,7 @@ function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_p
$suffix = 2;
do {
$alt_post_name = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_type, $post_ID ) );
$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_type, $post_id ) );
$suffix++;
} while ( $post_name_check );
$slug = $alt_post_name;
@ -5163,13 +5163,13 @@ function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_p
* @since 3.3.0
*
* @param string $slug The post slug.
* @param int $post_ID Post ID.
* @param int $post_id Post ID.
* @param string $post_status The post status.
* @param string $post_type Post type.
* @param int $post_parent Post parent ID
* @param string $original_slug The original post slug.
*/
return apply_filters( 'wp_unique_post_slug', $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug );
return apply_filters( 'wp_unique_post_slug', $slug, $post_id, $post_status, $post_type, $post_parent, $original_slug );
}
/**
@ -5285,7 +5285,7 @@ function wp_set_post_terms( $post_id = 0, $terms = '', $taxonomy = 'post_tag', $
*
* @since 2.1.0
*
* @param int $post_ID Optional. The Post ID. Does not default to the ID
* @param int $post_id Optional. The Post ID. Does not default to the ID
* of the global $post. Default 0.
* @param int[]|int $post_categories Optional. List of category IDs, or the ID of a single category.
* Default empty array.
@ -5293,10 +5293,10 @@ function wp_set_post_terms( $post_id = 0, $terms = '', $taxonomy = 'post_tag', $
* If false, replace the categories with the new categories.
* @return array|false|WP_Error Array of term taxonomy IDs of affected categories. WP_Error or false on failure.
*/
function wp_set_post_categories( $post_ID = 0, $post_categories = array(), $append = false ) {
$post_ID = (int) $post_ID;
$post_type = get_post_type( $post_ID );
$post_status = get_post_status( $post_ID );
function wp_set_post_categories( $post_id = 0, $post_categories = array(), $append = false ) {
$post_id = (int) $post_id;
$post_type = get_post_type( $post_id );
$post_status = get_post_status( $post_id );
// If $post_categories isn't already an array, make it one.
$post_categories = (array) $post_categories;
@ -5327,7 +5327,7 @@ function wp_set_post_categories( $post_ID = 0, $post_categories = array(), $appe
return true;
}
return wp_set_post_terms( $post_ID, $post_categories, 'category', $append );
return wp_set_post_terms( $post_id, $post_categories, 'category', $append );
}
/**
@ -7671,37 +7671,37 @@ function wp_get_post_parent_id( $post = null ) {
* @see wp_find_hierarchy_loop()
*
* @param int $post_parent ID of the parent for the post we're checking.
* @param int $post_ID ID of the post we're checking.
* @param int $post_id ID of the post we're checking.
* @return int The new post_parent for the post, 0 otherwise.
*/
function wp_check_post_hierarchy_for_loops( $post_parent, $post_ID ) {
function wp_check_post_hierarchy_for_loops( $post_parent, $post_id ) {
// Nothing fancy here - bail.
if ( ! $post_parent ) {
return 0;
}
// New post can't cause a loop.
if ( ! $post_ID ) {
if ( ! $post_id ) {
return $post_parent;
}
// Can't be its own parent.
if ( $post_parent == $post_ID ) {
if ( $post_parent == $post_id ) {
return 0;
}
// Now look for larger loops.
$loop = wp_find_hierarchy_loop( 'wp_get_post_parent_id', $post_ID, $post_parent );
$loop = wp_find_hierarchy_loop( 'wp_get_post_parent_id', $post_id, $post_parent );
if ( ! $loop ) {
return $post_parent; // No loop.
}
// Setting $post_parent to the given value causes a loop.
if ( isset( $loop[ $post_ID ] ) ) {
if ( isset( $loop[ $post_id ] ) ) {
return 0;
}
// There's a loop, but it doesn't contain $post_ID. Break the loop.
// There's a loop, but it doesn't contain $post_id. Break the loop.
foreach ( array_keys( $loop ) as $loop_member ) {
wp_update_post(
array(
@ -7917,16 +7917,16 @@ function _prime_post_caches( $ids, $update_term_cache = true, $update_meta_cache
* @access private
*
* @param string $post_name Post slug.
* @param int $post_ID Optional. Post ID that should be ignored. Default 0.
* @param int $post_id Optional. Post ID that should be ignored. Default 0.
*/
function wp_add_trashed_suffix_to_post_name_for_trashed_posts( $post_name, $post_ID = 0 ) {
function wp_add_trashed_suffix_to_post_name_for_trashed_posts( $post_name, $post_id = 0 ) {
$trashed_posts_with_desired_slug = get_posts(
array(
'name' => $post_name,
'post_status' => 'trash',
'post_type' => 'any',
'nopaging' => true,
'post__not_in' => array( $post_ID ),
'post__not_in' => array( $post_id ),
)
);

View File

@ -39,12 +39,12 @@ function wp_set_unique_slug_on_create_template_part( $post_id ) {
*
* @param string $override_slug The filtered value of the slug (starts as `null` from apply_filter).
* @param string $slug The original/un-filtered slug (post_name).
* @param int $post_ID Post ID.
* @param int $post_id Post ID.
* @param string $post_status No uniqueness checks are made if the post is still draft or pending.
* @param string $post_type Post type.
* @return string The original, desired slug.
*/
function wp_filter_wp_template_unique_post_slug( $override_slug, $slug, $post_ID, $post_status, $post_type ) {
function wp_filter_wp_template_unique_post_slug( $override_slug, $slug, $post_id, $post_status, $post_type ) {
if ( 'wp_template' !== $post_type && 'wp_template_part' !== $post_type ) {
return $override_slug;
}
@ -61,7 +61,7 @@ function wp_filter_wp_template_unique_post_slug( $override_slug, $slug, $post_ID
* to the entity. So for now we use the currently activated theme for creation.
*/
$theme = get_stylesheet();
$terms = get_the_terms( $post_ID, 'wp_theme' );
$terms = get_the_terms( $post_id, 'wp_theme' );
if ( $terms && ! is_wp_error( $terms ) ) {
$theme = $terms[0]->name;
}
@ -71,7 +71,7 @@ function wp_filter_wp_template_unique_post_slug( $override_slug, $slug, $post_ID
'post_type' => $post_type,
'posts_per_page' => 1,
'no_found_rows' => true,
'post__not_in' => array( $post_ID ),
'post__not_in' => array( $post_id ),
'tax_query' => array(
array(
'taxonomy' => 'wp_theme',

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.2-beta2-55364';
$wp_version = '6.2-beta2-55365';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.