Skip to content

Commit

Permalink
Coding Standards: Rename the $ID variable in wp_xmlrpc_server met…
Browse files Browse the repository at this point in the history
…hods.

This resolves a WPCS warning:
{{{
Variable "$ID" is not in valid snake_case format, try "$i_d"
}}}

Follow-up to [28448].

See #62279.

git-svn-id: https://develop.svn.wordpress.org/trunk@59697 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
SergeyBiryukov committed Jan 24, 2025
1 parent 9548718 commit 530e8fd
Showing 1 changed file with 58 additions and 11 deletions.
69 changes: 58 additions & 11 deletions src/wp-includes/class-wp-xmlrpc-server.php
Original file line number Diff line number Diff line change
Expand Up @@ -5143,7 +5143,15 @@ public function blogger_newPost( $args ) {
$post_date = current_time( 'mysql' );
$post_date_gmt = current_time( 'mysql', 1 );

$post_data = compact( 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status' );
$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 ) ) {
Expand Down Expand Up @@ -5595,7 +5603,26 @@ public function mw_newPost( $args ) {
}
}

$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' );
$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;
Expand Down Expand Up @@ -5777,7 +5804,7 @@ public function mw_editPost( $args ) {

$this->escape( $postdata );

$ID = $postdata['ID'];
$post_id = $postdata['ID'];
$post_content = $postdata['post_content'];
$post_title = $postdata['post_title'];
$post_excerpt = $postdata['post_excerpt'];
Expand Down Expand Up @@ -5979,7 +6006,27 @@ public function mw_editPost( $args ) {
}

// We've got all the data -- post it.
$newpost = compact( 'ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'edit_date', 'post_date', 'post_date_gmt', 'to_ping', 'post_name', 'post_password', 'post_parent', 'menu_order', 'post_author', 'tags_input', 'page_template' );
$newpost = compact(
'post_id',
'post_content',
'post_title',
'post_category',
'post_status',
'post_excerpt',
'comment_status',
'ping_status',
'edit_date',
'post_date',
'post_date_gmt',
'to_ping',
'post_name',
'post_password',
'post_parent',
'menu_order',
'post_author',
'tags_input',
'page_template'
);

$result = wp_update_post( $newpost, true );
if ( is_wp_error( $result ) ) {
Expand Down Expand Up @@ -6022,7 +6069,7 @@ public function mw_editPost( $args ) {
$enclosure = isset( $content_struct['enclosure'] ) ? $content_struct['enclosure'] : null;
$this->add_enclosure_if_new( $post_id, $enclosure );

$this->attach_uploads( $ID, $post_content );
$this->attach_uploads( $post_id, $post_content );

// Handle post formats if assigned, validation is handled earlier in this function.
if ( isset( $content_struct['wp_post_format'] ) ) {
Expand Down Expand Up @@ -6458,20 +6505,20 @@ public function mw_newMediaObject( $args ) {
);

// Save the data.
$id = wp_insert_attachment( $attachment, $upload['file'], $post_id );
wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $upload['file'] ) );
$attachment_id = wp_insert_attachment( $attachment, $upload['file'], $post_id );
wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $upload['file'] ) );

/**
* Fires after a new attachment has been added via the XML-RPC MovableType API.
*
* @since 3.4.0
*
* @param int $id ID of the new attachment.
* @param array $args An array of arguments to add the attachment.
* @param int $attachment_id ID of the new attachment.
* @param array $args An array of arguments to add the attachment.
*/
do_action( 'xmlrpc_call_success_mw_newMediaObject', $id, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
do_action( 'xmlrpc_call_success_mw_newMediaObject', $attachment_id, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase

$struct = $this->_prepare_media_item( get_post( $id ) );
$struct = $this->_prepare_media_item( get_post( $attachment_id ) );

// Deprecated values.
$struct['id'] = $struct['attachment_id'];
Expand Down

0 comments on commit 530e8fd

Please sign in to comment.