mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
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.
git-svn-id: https://develop.svn.wordpress.org/trunk@55365 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -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 = '[…] ' . esc_html( $excerpt ) . ' […]';
|
||||
$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();
|
||||
|
||||
Reference in New Issue
Block a user