Make WordPress Core


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

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

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

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

Variable "$post_IDs" is not in valid snake_case format

This affects:

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

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

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

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

Props mahekkalola, tanjimtc71, SergeyBiryukov.
Fixes #57692.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-xmlrpc-server.php

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