diff -r 7b1b88e27a20 -r 48c4eec2b7e6 wp/wp-includes/class-wp-xmlrpc-server.php --- a/wp/wp-includes/class-wp-xmlrpc-server.php Thu Sep 29 08:06:27 2022 +0200 +++ b/wp/wp-includes/class-wp-xmlrpc-server.php Fri Sep 05 18:40:08 2025 +0200 @@ -1,6 +1,6 @@ 'this:mw_getCategories', 'metaWeblog.newMediaObject' => 'this:mw_newMediaObject', - // MetaWeblog API aliases for Blogger API. - // See http://www.xmlrpc.com/stories/storyReader$2460 + /* + * MetaWeblog API aliases for Blogger API. + * See http://www.xmlrpc.com/stories/storyReader$2460 + */ 'metaWeblog.deletePost' => 'this:blogger_deletePost', 'metaWeblog.getUsersBlogs' => 'this:blogger_getUsersBlogs', @@ -176,9 +179,9 @@ } /** - * Set wp_xmlrpc_server::$is_enabled property. - * - * Determine whether the xmlrpc server is enabled on this WordPress install + * Sets wp_xmlrpc_server::$is_enabled property. + * + * Determines whether the xmlrpc server is enabled on this WordPress install * and set the is_enabled property accordingly. * * @since 5.7.3 @@ -197,8 +200,8 @@ * Filters whether XML-RPC methods requiring authentication are enabled. * * Contrary to the way it's named, this filter does not control whether XML-RPC is *fully* - * enabled, rather, it only controls whether XML-RPC methods requiring authentication - such - * as for publishing purposes - are enabled. + * enabled, rather, it only controls whether XML-RPC methods requiring authentication - + * such as for publishing purposes - are enabled. * * Further, the filter does not control whether pingbacks or other custom endpoints that don't * require authentication are enabled. This behavior is expected, and due to how parity was matched @@ -219,7 +222,7 @@ } /** - * Make private/protected methods readable for backward compatibility. + * Makes private/protected methods readable for backward compatibility. * * @since 4.0.0 * @@ -244,7 +247,7 @@ } /** - * Test XMLRPC API by saying, "Hello!" to client. + * Tests XMLRPC API by saying, "Hello!" to client. * * @since 1.5.0 * @@ -255,15 +258,15 @@ } /** - * Test XMLRPC API by adding two numbers for client. + * Tests XMLRPC API by adding two numbers for client. * * @since 1.5.0 * * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $number1 A number to add. - * @type int $number2 A second number to add. + * @type int $0 A number to add. + * @type int $1 A second number to add. * } * @return int Sum of the two given numbers. */ @@ -274,13 +277,13 @@ } /** - * Log user in. + * Logs user in. * * @since 2.8.0 * * @param string $username User's username. * @param string $password User's password. - * @return WP_User|false WP_User object if authentication passed, false otherwise + * @return WP_User|false WP_User object if authentication passed, false otherwise. */ public function login( $username, $password ) { if ( ! $this->is_enabled ) { @@ -317,7 +320,7 @@ } /** - * Check user's credentials. Deprecated. + * Checks user's credentials. Deprecated. * * @since 1.5.0 * @deprecated 2.8.0 Use wp_xmlrpc_server::login() @@ -332,7 +335,7 @@ } /** - * Escape string or array of strings for database. + * Escapes string or array of strings for database. * * @since 1.5.2 * @@ -355,9 +358,9 @@ } /** - * Send error response to client. - * - * Send an XML error response to the client. If the endpoint is enabled + * Sends error response to client. + * + * Sends an XML error response to the client. If the endpoint is enabled * an HTTP 200 response is always sent per the XML-RPC specification. * * @since 5.7.3 @@ -379,7 +382,7 @@ } /** - * Retrieve custom fields for post. + * Retrieves custom fields for post. * * @since 2.5.0 * @@ -408,7 +411,7 @@ } /** - * Set custom fields for post. + * Sets custom fields for post. * * @since 2.5.0 * @@ -446,7 +449,7 @@ } /** - * Retrieve custom fields for a term. + * Retrieves custom fields for a term. * * @since 4.9.0 * @@ -475,7 +478,7 @@ } /** - * Set custom fields for a term. + * Sets custom fields for a term. * * @since 4.9.0 * @@ -508,7 +511,7 @@ } /** - * Set up blog options property. + * Sets up blog options property. * * Passes property through {@see 'xmlrpc_blog_options'} filter. * @@ -677,15 +680,15 @@ } /** - * Retrieve the blogs of the user. + * Retrieves the blogs of the user. * * @since 2.6.0 * * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type string $username Username. - * @type string $password Password. + * @type string $0 Username. + * @type string $1 Password. * } * @return array|IXR_Error Array contains: * - 'isAdmin' @@ -867,7 +870,7 @@ } /** - * Convert a WordPress date string to an IXR_Date object. + * Converts a WordPress date string to an IXR_Date object. * * @param string $date Date string to convert. * @return IXR_Date IXR_Date object. @@ -880,7 +883,7 @@ } /** - * Convert a WordPress GMT date string to an IXR_Date object. + * Converts a WordPress GMT date string to an IXR_Date object. * * @param string $date_gmt WordPress GMT date string. * @param string $date Date string. @@ -1064,6 +1067,7 @@ 'description' => $media_item->post_content, 'metadata' => wp_get_attachment_metadata( $media_item->ID ), 'type' => $media_item->post_mime_type, + 'alt' => get_post_meta( $media_item->ID, '_wp_attachment_image_alt', true ), ); $thumbnail_src = image_downsize( $media_item->ID, $thumbnail_size ); @@ -1260,7 +1264,7 @@ } /** - * Create a new post for any registered post type. + * Creates a new post for any registered post type. * * @since 3.4.0 * @@ -1269,10 +1273,10 @@ * @param array $args { * Method arguments. Note: top-level arguments must be ordered as documented. * - * @type int $blog_id Blog ID (unused). - * @type string $username Username. - * @type string $password Password. - * @type array $content_struct { + * @type int $0 Blog ID (unused). + * @type string $1 Username. + * @type string $2 Password. + * @type array $3 { * Content struct for adding a new post. See wp_insert_post() for information on * additional post fields * @@ -1360,8 +1364,8 @@ } /** - * Encapsulate the logic for sticking a post - * and determining if the user has permission to do so + * Encapsulates the logic for sticking a post and determining if + * the user has permission to do so. * * @since 4.3.0 * @@ -1411,19 +1415,19 @@ $defaults = array( 'post_status' => 'draft', 'post_type' => 'post', - 'post_author' => null, - 'post_password' => null, - 'post_excerpt' => null, - 'post_content' => null, - 'post_title' => null, - 'post_date' => null, - 'post_date_gmt' => null, + 'post_author' => 0, + 'post_password' => '', + 'post_excerpt' => '', + 'post_content' => '', + 'post_title' => '', + 'post_date' => '', + 'post_date_gmt' => '', 'post_format' => null, 'post_name' => null, 'post_thumbnail' => null, - 'post_parent' => null, - 'ping_status' => null, - 'comment_status' => null, + 'post_parent' => 0, + 'ping_status' => '', + 'comment_status' => '', 'custom_fields' => null, 'terms_names' => null, 'terms' => null, @@ -1498,11 +1502,11 @@ $post_data['post_author'] = $user->ID; } - if ( isset( $post_data['comment_status'] ) && 'open' !== $post_data['comment_status'] && 'closed' !== $post_data['comment_status'] ) { + if ( 'open' !== $post_data['comment_status'] && 'closed' !== $post_data['comment_status'] ) { unset( $post_data['comment_status'] ); } - if ( isset( $post_data['ping_status'] ) && 'open' !== $post_data['ping_status'] && 'closed' !== $post_data['ping_status'] ) { + if ( 'open' !== $post_data['ping_status'] && 'closed' !== $post_data['ping_status'] ) { unset( $post_data['ping_status'] ); } @@ -1528,7 +1532,7 @@ 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 ); @@ -1540,16 +1544,16 @@ 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'] ) ) { @@ -1655,7 +1659,7 @@ } 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() ); @@ -1666,9 +1670,9 @@ // Handle enclosures. $enclosure = isset( $post_data['enclosure'] ) ? $post_data['enclosure'] : null; - $this->add_enclosure_if_new( $post_ID, $enclosure ); - - $this->attach_uploads( $post_ID, $post_data['post_content'] ); + $this->add_enclosure_if_new( $post_id, $enclosure ); + + $this->attach_uploads( $post_id, $post_data['post_content'] ); /** * Filters post data array to be inserted via XML-RPC. @@ -1680,12 +1684,20 @@ */ $post_data = apply_filters( 'xmlrpc_wp_insert_post_data', $post_data, $content_struct ); - $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 ) { + // Remove all null values to allow for using the insert/update post default values for those keys instead. + $post_data = array_filter( + $post_data, + static function ( $value ) { + return null !== $value; + } + ); + + $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 ( $update ) { return new IXR_Error( 401, __( 'Sorry, the post could not be updated.' ) ); } else { @@ -1693,11 +1705,11 @@ } } - return (string) $post_ID; + return (string) $post_id; } /** - * Edit a post for any registered post type. + * Edits a post for any registered post type. * * The $content_struct parameter only needs to contain fields that * should be changed. All other fields will retain their existing values. @@ -1707,11 +1719,11 @@ * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id Blog ID (unused). - * @type string $username Username. - * @type string $password Password. - * @type int $post_id Post ID. - * @type array $content_struct Extra content arguments. + * @type int $0 Blog ID (unused). + * @type string $1 Username. + * @type string $2 Password. + * @type int $3 Post ID. + * @type array $4 Extra content arguments. * } * @return true|IXR_Error True on success, IXR_Error on failure. */ @@ -1783,7 +1795,7 @@ } /** - * Delete a post for any registered post type. + * Deletes a post for any registered post type. * * @since 3.4.0 * @@ -1792,10 +1804,10 @@ * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id Blog ID (unused). - * @type string $username Username. - * @type string $password Password. - * @type int $post_id Post ID. + * @type int $0 Blog ID (unused). + * @type string $1 Username. + * @type string $2 Password. + * @type int $3 Post ID. * } * @return true|IXR_Error True on success, IXR_Error instance on failure. */ @@ -1837,7 +1849,7 @@ } /** - * Retrieve a post. + * Retrieves a post. * * @since 3.4.0 * @@ -1855,11 +1867,11 @@ * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id Blog ID (unused). - * @type string $username Username. - * @type string $password Password. - * @type int $post_id Post ID. - * @type array $fields The subset of post type fields to return. + * @type int $0 Blog ID (unused). + * @type string $1 Username. + * @type string $2 Password. + * @type int $3 Post ID. + * @type array $4 Optional. The subset of post type fields to return. * } * @return array|IXR_Error Array contains (based on $fields parameter): * - 'post_id' @@ -1900,11 +1912,12 @@ $fields = $args[4]; } else { /** - * Filters the list of post query fields used by the given XML-RPC method. + * Filters the default post query fields used by the given XML-RPC method. * * @since 3.4.0 * - * @param array $fields Array of post fields. Default array contains 'post', 'terms', and 'custom_fields'. + * @param array $fields An array of post fields to retrieve. By default, + * contains 'post', 'terms', and 'custom_fields'. * @param string $method Method name. */ $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPost' ); @@ -1932,7 +1945,7 @@ } /** - * Retrieve posts. + * Retrieves posts. * * @since 3.4.0 * @@ -1943,15 +1956,15 @@ * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id Blog ID (unused). - * @type string $username Username. - * @type string $password Password. - * @type array $filter Optional. Modifies the query used to retrieve posts. Accepts 'post_type', - * 'post_status', 'number', 'offset', 'orderby', 's', and 'order'. - * Default empty array. - * @type array $fields Optional. The subset of post type fields to return in the response array. + * @type int $0 Blog ID (unused). + * @type string $1 Username. + * @type string $2 Password. + * @type array $3 Optional. Modifies the query used to retrieve posts. Accepts 'post_type', + * 'post_status', 'number', 'offset', 'orderby', 's', and 'order'. + * Default empty array. + * @type array $4 Optional. The subset of post type fields to return in the response array. * } - * @return array|IXR_Error Array contains a collection of posts. + * @return array|IXR_Error Array containing a collection of posts. */ public function wp_getPosts( $args ) { if ( ! $this->minimum_args( $args, 3 ) ) { @@ -2041,7 +2054,7 @@ } /** - * Create a new term. + * Creates a new term. * * @since 3.4.0 * @@ -2050,12 +2063,12 @@ * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id Blog ID (unused). - * @type string $username Username. - * @type string $password Password. - * @type array $content_struct Content struct for adding a new term. The struct must contain - * the term 'name' and 'taxonomy'. Optional accepted values include - * 'parent', 'description', and 'slug'. + * @type int $0 Blog ID (unused). + * @type string $1 Username. + * @type string $2 Password. + * @type array $3 Content struct for adding a new term. The struct must contain + * the term 'name' and 'taxonomy'. Optional accepted values include + * 'parent', 'description', and 'slug'. * } * @return int|IXR_Error The term ID on success, or an IXR_Error object on failure. */ @@ -2144,7 +2157,7 @@ } /** - * Edit a term. + * Edits a term. * * @since 3.4.0 * @@ -2153,13 +2166,13 @@ * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id Blog ID (unused). - * @type string $username Username. - * @type string $password Password. - * @type int $term_id Term ID. - * @type array $content_struct Content struct for editing a term. The struct must contain the - * term ''taxonomy'. Optional accepted values include 'name', 'parent', - * 'description', and 'slug'. + * @type int $0 Blog ID (unused). + * @type string $1 Username. + * @type string $2 Password. + * @type int $3 Term ID. + * @type array $4 Content struct for editing a term. The struct must contain the + * term 'taxonomy'. Optional accepted values include 'name', 'parent', + * 'description', and 'slug'. * } * @return true|IXR_Error True on success, IXR_Error instance on failure. */ @@ -2262,7 +2275,7 @@ } /** - * Delete a term. + * Deletes a term. * * @since 3.4.0 * @@ -2271,11 +2284,11 @@ * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id Blog ID (unused). - * @type string $username Username. - * @type string $password Password. - * @type string $taxonomy_name Taxonomy name. - * @type int $term_id Term ID. + * @type int $0 Blog ID (unused). + * @type string $1 Username. + * @type string $2 Password. + * @type string $3 Taxonomy name. + * @type int $4 Term ID. * } * @return true|IXR_Error True on success, IXR_Error instance on failure. */ @@ -2332,7 +2345,7 @@ } /** - * Retrieve a term. + * Retrieves a term. * * @since 3.4.0 * @@ -2341,11 +2354,11 @@ * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id Blog ID (unused). - * @type string $username Username. - * @type string $password Password. - * @type string $taxonomy Taxonomy name. - * @type string $term_id Term ID. + * @type int $0 Blog ID (unused). + * @type string $1 Username. + * @type string $2 Password. + * @type string $3 Taxonomy name. + * @type int $4 Term ID. * } * @return array|IXR_Error IXR_Error on failure, array on success, containing: * - 'term_id' @@ -2402,7 +2415,7 @@ } /** - * Retrieve all terms for a taxonomy. + * Retrieves all terms for a taxonomy. * * @since 3.4.0 * @@ -2414,12 +2427,12 @@ * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id Blog ID (unused). - * @type string $username Username. - * @type string $password Password. - * @type string $taxonomy Taxonomy name. - * @type array $filter Optional. Modifies the query used to retrieve posts. Accepts 'number', - * 'offset', 'orderby', 'order', 'hide_empty', and 'search'. Default empty array. + * @type int $0 Blog ID (unused). + * @type string $1 Username. + * @type string $2 Password. + * @type string $3 Taxonomy name. + * @type array $4 Optional. Modifies the query used to retrieve posts. Accepts 'number', + * 'offset', 'orderby', 'order', 'hide_empty', and 'search'. Default empty array. * } * @return array|IXR_Error An associative array of terms data on success, IXR_Error instance otherwise. */ @@ -2497,7 +2510,7 @@ } /** - * Retrieve a taxonomy. + * Retrieves a taxonomy. * * @since 3.4.0 * @@ -2506,13 +2519,13 @@ * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id Blog ID (unused). - * @type string $username Username. - * @type string $password Password. - * @type string $taxonomy Taxonomy name. - * @type array $fields Optional. Array of taxonomy fields to limit to in the return. - * Accepts 'labels', 'cap', 'menu', and 'object_type'. - * Default empty array. + * @type int $0 Blog ID (unused). + * @type string $1 Username. + * @type string $2 Password. + * @type string $3 Taxonomy name. + * @type array $4 Optional. Array of taxonomy fields to limit to in the return. + * Accepts 'labels', 'cap', 'menu', and 'object_type'. + * Default empty array. * } * @return array|IXR_Error An array of taxonomy data on success, IXR_Error instance otherwise. */ @@ -2531,11 +2544,12 @@ $fields = $args[4]; } else { /** - * Filters the taxonomy query fields used by the given XML-RPC method. + * Filters the default taxonomy query fields used by the given XML-RPC method. * * @since 3.4.0 * - * @param array $fields An array of taxonomy fields to retrieve. + * @param array $fields An array of taxonomy fields to retrieve. By default, + * contains 'labels', 'cap', and 'object_type'. * @param string $method The method name. */ $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomy' ); @@ -2563,7 +2577,7 @@ } /** - * Retrieve all taxonomies. + * Retrieves all taxonomies. * * @since 3.4.0 * @@ -2572,11 +2586,11 @@ * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id Blog ID (unused). - * @type string $username Username. - * @type string $password Password. - * @type array $filter Optional. An array of arguments for retrieving taxonomies. - * @type array $fields Optional. The subset of taxonomy fields to return. + * @type int $0 Blog ID (unused). + * @type string $1 Username. + * @type string $2 Password. + * @type array $3 Optional. An array of arguments for retrieving taxonomies. + * @type array $4 Optional. The subset of taxonomy fields to return. * } * @return array|IXR_Error An associative array of taxonomy data with returned fields determined * by `$fields`, or an IXR_Error instance on failure. @@ -2625,7 +2639,7 @@ } /** - * Retrieve a user. + * Retrieves a user. * * The optional $fields parameter specifies what fields will be included * in the response array. This should be a list of field names. 'user_id' will @@ -2640,11 +2654,11 @@ * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id (unused) - * @type string $username - * @type string $password - * @type int $user_id - * @type array $fields (optional) + * @type int $0 Blog ID (unused). + * @type string $1 Username. + * @type string $2 Password. + * @type int $3 User ID. + * @type array $4 Optional. Array of fields to return. * } * @return array|IXR_Error Array contains (based on $fields parameter): * - 'user_id' @@ -2679,7 +2693,7 @@ * * @since 3.5.0 * - * @param array $fields User query fields for given method. Default 'all'. + * @param array $fields An array of user fields to retrieve. By default, contains 'all'. * @param string $method The method name. */ $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUser' ); @@ -2707,7 +2721,7 @@ } /** - * Retrieve users. + * Retrieves users. * * The optional $filter parameter modifies the query used to retrieve users. * Accepted keys are 'number' (default: 50), 'offset' (default: 0), 'role', @@ -2722,11 +2736,11 @@ * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id (unused) - * @type string $username - * @type string $password - * @type array $filter (optional) - * @type array $fields (optional) + * @type int $0 Blog ID (unused). + * @type string $1 Username. + * @type string $2 Password. + * @type array $3 Optional. Arguments for the user query. + * @type array $4 Optional. Fields to return. * } * @return array|IXR_Error users data */ @@ -2797,17 +2811,17 @@ } /** - * Retrieve information about the requesting user. + * Retrieves information about the requesting user. * * @uses get_userdata() * * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id (unused) - * @type string $username - * @type string $password - * @type array $fields (optional) + * @type int $0 Blog ID (unused). + * @type string $1 Username + * @type string $2 Password + * @type array $3 Optional. Fields to return. * } * @return array|IXR_Error (@see wp_getUser) */ @@ -2846,17 +2860,17 @@ } /** - * Edit user's profile. + * Edits user's profile. * * @uses wp_update_user() * * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id (unused) - * @type string $username - * @type string $password - * @type array $content_struct It can optionally contain: + * @type int $0 Blog ID (unused). + * @type string $1 Username. + * @type string $2 Password. + * @type array $3 Content struct. It can optionally contain: * - 'first_name' * - 'last_name' * - 'website' @@ -2937,17 +2951,17 @@ } /** - * Retrieve page. + * Retrieves a page. * * @since 2.2.0 * * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id (unused) - * @type int $page_id - * @type string $username - * @type string $password + * @type int $0 Blog ID (unused). + * @type int $1 Page ID. + * @type string $2 Username. + * @type string $3 Password. * } * @return array|IXR_Error */ @@ -2985,17 +2999,17 @@ } /** - * Retrieve Pages. + * Retrieves Pages. * * @since 2.2.0 * * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id (unused) - * @type string $username - * @type string $password - * @type int $num_pages + * @type int $0 Blog ID (unused). + * @type string $1 Username. + * @type string $2 Password. + * @type int $3 Optional. Number of pages. Default 10. * } * @return array|IXR_Error */ @@ -3044,7 +3058,7 @@ } /** - * Create new page. + * Creates a new page. * * @since 2.2.0 * @@ -3053,10 +3067,10 @@ * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id (unused) - * @type string $username - * @type string $password - * @type array $content_struct + * @type int $0 Blog ID (unused). + * @type string $1 Username. + * @type string $2 Password. + * @type array $3 Content struct. * } * @return int|IXR_Error */ @@ -3081,17 +3095,17 @@ } /** - * Delete page. + * Deletes a page. * * @since 2.2.0 * * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id (unused) - * @type string $username - * @type string $password - * @type int $page_id + * @type int $0 Blog ID (unused). + * @type string $1 Username. + * @type string $2 Password. + * @type int $3 Page ID. * } * @return true|IXR_Error True, if success. */ @@ -3110,8 +3124,10 @@ /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ do_action( 'xmlrpc_call', 'wp.deletePage', $args, $this ); - // Get the current page based on the 'page_id' and - // make sure it is a page and not a post. + /* + * Get the current page based on the 'page_id' and + * make sure it is a page and not a post. + */ $actual_page = get_post( $page_id, ARRAY_A ); if ( ! $actual_page || ( 'page' !== $actual_page['post_type'] ) ) { return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); @@ -3142,19 +3158,19 @@ } /** - * Edit page. + * Edits a page. * * @since 2.2.0 * * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id (unused) - * @type int $page_id - * @type string $username - * @type string $password - * @type string $content - * @type string $publish + * @type int $0 Blog ID (unused). + * @type int $1 Page ID. + * @type string $2 Username. + * @type string $3 Password. + * @type string $4 Content. + * @type int $5 Publish flag. 0 for draft, 1 for publish. * } * @return array|IXR_Error */ @@ -3205,7 +3221,7 @@ } /** - * Retrieve page list. + * Retrieves page list. * * @since 2.2.0 * @@ -3214,9 +3230,9 @@ * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id (unused) - * @type string $username - * @type string $password + * @type int $0 Blog ID (unused). + * @type string $1 Username. + * @type string $2 Password. * } * @return array|IXR_Error */ @@ -3270,16 +3286,16 @@ } /** - * Retrieve authors list. + * Retrieves authors list. * * @since 2.2.0 * * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id (unused) - * @type string $username - * @type string $password + * @type int $0 Blog ID (unused). + * @type string $1 Username. + * @type string $2 Password. * } * @return array|IXR_Error */ @@ -3314,16 +3330,16 @@ } /** - * Get list of all tags + * Gets the list of all tags. * * @since 2.7.0 * * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id (unused) - * @type string $username - * @type string $password + * @type int $0 Blog ID (unused). + * @type string $1 Username. + * @type string $2 Password. * } * @return array|IXR_Error */ @@ -3366,17 +3382,17 @@ } /** - * Create new category. + * Creates a new category. * * @since 2.2.0 * * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id (unused) - * @type string $username - * @type string $password - * @type array $category + * @type int $0 Blog ID (unused). + * @type string $1 Username. + * @type string $2 Password. + * @type array $3 Category. * } * @return int|IXR_Error Category ID. */ @@ -3400,14 +3416,18 @@ return new IXR_Error( 401, __( 'Sorry, you are not allowed to add a category.' ) ); } - // If no slug was provided, make it empty - // so that WordPress will generate one. + /* + * If no slug was provided, make it empty + * so that WordPress will generate one. + */ if ( empty( $category['slug'] ) ) { $category['slug'] = ''; } - // If no parent_id was provided, make it empty - // so that it will be a top-level page (no parent). + /* + * If no parent_id was provided, make it empty + * so that it will be a top-level page (no parent). + */ if ( ! isset( $category['parent_id'] ) ) { $category['parent_id'] = ''; } @@ -3449,17 +3469,17 @@ } /** - * Remove category. + * Deletes a category. * * @since 2.5.0 * * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id (unused) - * @type string $username - * @type string $password - * @type int $category_id + * @type int $0 Blog ID (unused). + * @type string $1 Username. + * @type string $2 Password. + * @type int $3 Category ID. * } * @return bool|IXR_Error See wp_delete_term() for return info. */ @@ -3500,18 +3520,18 @@ } /** - * Retrieve category list. + * Retrieves category list. * * @since 2.2.0 * * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id (unused) - * @type string $username - * @type string $password - * @type array $category - * @type int $max_results + * @type int $0 Blog ID (unused). + * @type string $1 Username. + * @type string $2 Password. + * @type array $3 Category + * @type int $4 Max number of results. * } * @return array|IXR_Error */ @@ -3552,17 +3572,17 @@ } /** - * Retrieve comment. + * Retrieves a comment. * * @since 2.7.0 * * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id (unused) - * @type string $username - * @type string $password - * @type int $comment_id + * @type int $0 Blog ID (unused). + * @type string $1 Username. + * @type string $2 Password. + * @type int $3 Comment ID. * } * @return array|IXR_Error */ @@ -3594,30 +3614,33 @@ } /** - * Retrieve comments. - * - * Besides the common blog_id (unused), username, and password arguments, it takes a filter - * array as last argument. + * Retrieves comments. + * + * Besides the common blog_id (unused), username, and password arguments, + * it takes a filter array as the last argument. * * Accepted 'filter' keys are 'status', 'post_id', 'offset', and 'number'. * * The defaults are as follows: - * - 'status' - Default is ''. Filter by status (e.g., 'approve', 'hold') - * - 'post_id' - Default is ''. The post where the comment is posted. Empty string shows all comments. - * - 'number' - Default is 10. Total number of media items to retrieve. - * - 'offset' - Default is 0. See WP_Query::query() for more. + * - 'status' - Default is ''. Filter by status (e.g., 'approve', 'hold') + * - 'post_id' - Default is ''. The post where the comment is posted. + * Empty string shows all comments. + * - 'number' - Default is 10. Total number of media items to retrieve. + * - 'offset' - Default is 0. See WP_Query::query() for more. * * @since 2.7.0 * * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id (unused) - * @type string $username - * @type string $password - * @type array $struct + * @type int $0 Blog ID (unused). + * @type string $1 Username. + * @type string $2 Password. + * @type array $3 Optional. Query arguments. * } - * @return array|IXR_Error Contains a collection of comments. See wp_xmlrpc_server::wp_getComment() for a description of each item contents + * @return array|IXR_Error Array containing a collection of comments. + * See wp_xmlrpc_server::wp_getComment() for a description + * of each item contents. */ public function wp_getComments( $args ) { $this->escape( $args ); @@ -3689,7 +3712,7 @@ } /** - * Delete a comment. + * Deletes a comment. * * By default, the comment will be moved to the Trash instead of deleted. * See wp_delete_comment() for more information on this behavior. @@ -3699,10 +3722,10 @@ * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id (unused) - * @type string $username - * @type string $password - * @type int $comment_ID + * @type int $0 Blog ID (unused). + * @type string $1 Username. + * @type string $2 Password. + * @type int $3 Comment ID. * } * @return bool|IXR_Error See wp_delete_comment(). */ @@ -3711,25 +3734,25 @@ $username = $args[1]; $password = $args[2]; - $comment_ID = (int) $args[3]; + $comment_id = (int) $args[3]; $user = $this->login( $username, $password ); if ( ! $user ) { return $this->error; } - if ( ! get_comment( $comment_ID ) ) { + if ( ! get_comment( $comment_id ) ) { return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); } - if ( ! current_user_can( 'edit_comment', $comment_ID ) ) { + if ( ! current_user_can( 'edit_comment', $comment_id ) ) { return new IXR_Error( 403, __( 'Sorry, you are not allowed to delete this comment.' ) ); } /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ do_action( 'xmlrpc_call', 'wp.deleteComment', $args, $this ); - $status = wp_delete_comment( $comment_ID ); + $status = wp_delete_comment( $comment_id ); if ( $status ) { /** @@ -3737,20 +3760,20 @@ * * @since 3.4.0 * - * @param int $comment_ID ID of the deleted comment. + * @param int $comment_id ID of the deleted comment. * @param array $args An array of arguments to delete the comment. */ - do_action( 'xmlrpc_call_success_wp_deleteComment', $comment_ID, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase + do_action( 'xmlrpc_call_success_wp_deleteComment', $comment_id, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase } return $status; } /** - * Edit comment. - * - * Besides the common blog_id (unused), username, and password arguments, it takes a - * comment_id integer and a content_struct array as last argument. + * Edits a comment. + * + * Besides the common blog_id (unused), username, and password arguments, + * it takes a comment_id integer and a content_struct array as the last argument. * * The allowed keys in the content_struct array are: * - 'author' @@ -3758,18 +3781,18 @@ * - 'author_email' * - 'content' * - 'date_created_gmt' - * - 'status'. Common statuses are 'approve', 'hold', 'spam'. See get_comment_statuses() for more details + * - 'status'. Common statuses are 'approve', 'hold', 'spam'. See get_comment_statuses() for more details. * * @since 2.7.0 * * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id (unused) - * @type string $username - * @type string $password - * @type int $comment_ID - * @type array $content_struct + * @type int $0 Blog ID (unused). + * @type string $1 Username. + * @type string $2 Password. + * @type int $3 Comment ID. + * @type array $4 Content structure. * } * @return true|IXR_Error True, on success. */ @@ -3778,7 +3801,7 @@ $username = $args[1]; $password = $args[2]; - $comment_ID = (int) $args[3]; + $comment_id = (int) $args[3]; $content_struct = $args[4]; $user = $this->login( $username, $password ); @@ -3786,18 +3809,18 @@ return $this->error; } - if ( ! get_comment( $comment_ID ) ) { + if ( ! get_comment( $comment_id ) ) { return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); } - if ( ! current_user_can( 'edit_comment', $comment_ID ) ) { + if ( ! current_user_can( 'edit_comment', $comment_id ) ) { return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) ); } /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ do_action( 'xmlrpc_call', 'wp.editComment', $args, $this ); $comment = array( - 'comment_ID' => $comment_ID, + 'comment_ID' => $comment_id, ); if ( isset( $content_struct['status'] ) ) { @@ -3849,27 +3872,27 @@ * * @since 3.4.0 * - * @param int $comment_ID ID of the updated comment. + * @param int $comment_id ID of the updated comment. * @param array $args An array of arguments to update the comment. */ - do_action( 'xmlrpc_call_success_wp_editComment', $comment_ID, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase + do_action( 'xmlrpc_call_success_wp_editComment', $comment_id, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase return true; } /** - * Create new comment. + * Creates a new comment. * * @since 2.7.0 * * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id (unused) - * @type string $username - * @type string $password - * @type string|int $post - * @type array $content_struct + * @type int $0 Blog ID (unused). + * @type string $1 Username. + * @type string $2 Password. + * @type string|int $3 Post ID or URL. + * @type array $4 Content structure. * } * @return int|IXR_Error See wp_new_comment(). */ @@ -3950,7 +3973,7 @@ $comment['comment_author'] = $this->escape( $display_name ); $comment['comment_author_email'] = $this->escape( $user_email ); $comment['comment_author_url'] = $this->escape( $user_url ); - $comment['user_ID'] = $user->ID; + $comment['user_id'] = $user->ID; } else { $comment['comment_author'] = ''; if ( isset( $content_struct['author'] ) ) { @@ -3967,7 +3990,7 @@ $comment['comment_author_url'] = $content_struct['author_url']; } - $comment['user_ID'] = 0; + $comment['user_id'] = 0; if ( get_option( 'require_name_email' ) ) { if ( strlen( $comment['comment_author_email'] ) < 6 || '' === $comment['comment_author'] ) { @@ -3990,12 +4013,12 @@ /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ do_action( 'xmlrpc_call', 'wp.newComment', $args, $this ); - $comment_ID = wp_new_comment( $comment, true ); - if ( is_wp_error( $comment_ID ) ) { - return new IXR_Error( 403, $comment_ID->get_error_message() ); - } - - if ( ! $comment_ID ) { + $comment_id = wp_new_comment( $comment, true ); + if ( is_wp_error( $comment_id ) ) { + return new IXR_Error( 403, $comment_id->get_error_message() ); + } + + if ( ! $comment_id ) { return new IXR_Error( 403, __( 'Something went wrong.' ) ); } @@ -4004,25 +4027,25 @@ * * @since 3.4.0 * - * @param int $comment_ID ID of the new comment. + * @param int $comment_id ID of the new comment. * @param array $args An array of new comment arguments. */ - do_action( 'xmlrpc_call_success_wp_newComment', $comment_ID, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase - - return $comment_ID; + do_action( 'xmlrpc_call_success_wp_newComment', $comment_id, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase + + return $comment_id; } /** - * Retrieve all of the comment status. + * Retrieves all of the comment status. * * @since 2.7.0 * * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id (unused) - * @type string $username - * @type string $password + * @type int $0 Blog ID (unused). + * @type string $1 Username. + * @type string $2 Password. * } * @return array|IXR_Error */ @@ -4048,17 +4071,17 @@ } /** - * Retrieve comment count. + * Retrieves comment counts. * * @since 2.5.0 * * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id (unused) - * @type string $username - * @type string $password - * @type int $post_id + * @type int $0 Blog ID (unused). + * @type string $1 Username. + * @type string $2 Password. + * @type int $3 Post ID. * } * @return array|IXR_Error */ @@ -4097,16 +4120,16 @@ } /** - * Retrieve post statuses. + * Retrieves post statuses. * * @since 2.5.0 * * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id (unused) - * @type string $username - * @type string $password + * @type int $0 Blog ID (unused). + * @type string $1 Username. + * @type string $2 Password. * } * @return array|IXR_Error */ @@ -4132,16 +4155,16 @@ } /** - * Retrieve page statuses. + * Retrieves page statuses. * * @since 2.5.0 * * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id (unused) - * @type string $username - * @type string $password + * @type int $0 Blog ID (unused). + * @type string $1 Username. + * @type string $2 Password. * } * @return array|IXR_Error */ @@ -4167,16 +4190,16 @@ } /** - * Retrieve page templates. + * Retrieves page templates. * * @since 2.6.0 * * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id (unused) - * @type string $username - * @type string $password + * @type int $0 Blog ID (unused). + * @type string $1 Username. + * @type string $2 Password. * } * @return array|IXR_Error */ @@ -4202,17 +4225,17 @@ } /** - * Retrieve blog options. + * Retrieves blog options. * * @since 2.6.0 * * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id (unused) - * @type string $username - * @type string $password - * @type array $options + * @type int $0 Blog ID (unused). + * @type string $1 Username. + * @type string $2 Password. + * @type array $3 Optional. Options. * } * @return array|IXR_Error */ @@ -4229,7 +4252,7 @@ } // If no specific options where asked for, return all of them. - if ( count( $options ) == 0 ) { + if ( count( $options ) === 0 ) { $options = array_keys( $this->blog_options ); } @@ -4237,7 +4260,7 @@ } /** - * Retrieve blog options value from list. + * Retrieves blog options value from list. * * @since 2.6.0 * @@ -4266,17 +4289,17 @@ } /** - * Update blog options. + * Updates blog options. * * @since 2.6.0 * * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id (unused) - * @type string $username - * @type string $password - * @type array $options + * @type int $0 Blog ID (unused). + * @type string $1 Username. + * @type string $2 Password. + * @type array $3 Options. * } * @return array|IXR_Error */ @@ -4315,17 +4338,17 @@ } /** - * Retrieve a media item by ID + * Retrieves a media item by ID. * * @since 3.1.0 * * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id (unused) - * @type string $username - * @type string $password - * @type int $attachment_id + * @type int $0 Blog ID (unused). + * @type string $1 Username. + * @type string $2 Password. + * @type int $3 Attachment ID. * } * @return array|IXR_Error Associative array contains: * - 'date_created_gmt' @@ -4365,17 +4388,18 @@ } /** - * Retrieves a collection of media library items (or attachments) - * - * Besides the common blog_id (unused), username, and password arguments, it takes a filter - * array as last argument. + * Retrieves a collection of media library items (or attachments). + * + * Besides the common blog_id (unused), username, and password arguments, + * it takes a filter array as the last argument. * * Accepted 'filter' keys are 'parent_id', 'mime_type', 'offset', and 'number'. * * The defaults are as follows: - * - 'number' - Default is 5. Total number of media items to retrieve. - * - 'offset' - Default is 0. See WP_Query::query() for more. - * - 'parent_id' - Default is ''. The post where the media item is attached. Empty string shows all media items. 0 shows unattached media items. + * - 'number' - Default is 5. Total number of media items to retrieve. + * - 'offset' - Default is 0. See WP_Query::query() for more. + * - 'parent_id' - Default is ''. The post where the media item is attached. + * Empty string shows all media items. 0 shows unattached media items. * - 'mime_type' - Default is ''. Filter by mime type (e.g., 'image/jpeg', 'application/pdf') * * @since 3.1.0 @@ -4383,12 +4407,14 @@ * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id (unused) - * @type string $username - * @type string $password - * @type array $struct + * @type int $0 Blog ID (unused). + * @type string $1 Username. + * @type string $2 Password. + * @type array $3 Optional. Query arguments. * } - * @return array|IXR_Error Contains a collection of media items. See wp_xmlrpc_server::wp_getMediaItem() for a description of each item contents + * @return array|IXR_Error Array containing a collection of media items. + * See wp_xmlrpc_server::wp_getMediaItem() for a description + * of each item contents. */ public function wp_getMediaLibrary( $args ) { $this->escape( $args ); @@ -4441,9 +4467,9 @@ * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id (unused) - * @type string $username - * @type string $password + * @type int $0 Blog ID (unused). + * @type string $1 Username. + * @type string $2 Password. * } * @return array|IXR_Error List of post formats, otherwise IXR_Error object. */ @@ -4486,7 +4512,7 @@ } /** - * Retrieves a post type + * Retrieves a post type. * * @since 3.4.0 * @@ -4495,11 +4521,11 @@ * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id (unused) - * @type string $username - * @type string $password - * @type string $post_type_name - * @type array $fields (optional) + * @type int $0 Blog ID (unused). + * @type string $1 Username. + * @type string $2 Password. + * @type string $3 Post type name. + * @type array $4 Optional. Fields to fetch. * } * @return array|IXR_Error Array contains: * - 'labels' @@ -4527,11 +4553,12 @@ $fields = $args[4]; } else { /** - * Filters the default query fields used by the given XML-RPC method. + * Filters the default post type query fields used by the given XML-RPC method. * * @since 3.4.0 * - * @param array $fields An array of post type query fields for the given method. + * @param array $fields An array of post type fields to retrieve. By default, + * contains 'labels', 'cap', and 'taxonomies'. * @param string $method The method name. */ $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostType' ); @@ -4559,7 +4586,7 @@ } /** - * Retrieves a post types + * Retrieves post types. * * @since 3.4.0 * @@ -4568,11 +4595,11 @@ * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id (unused) - * @type string $username - * @type string $password - * @type array $filter (optional) - * @type array $fields (optional) + * @type int $0 Blog ID (unused). + * @type string $1 Username. + * @type string $2 Password. + * @type array $3 Optional. Query arguments. + * @type array $4 Optional. Fields to fetch. * } * @return array|IXR_Error */ @@ -4618,7 +4645,7 @@ } /** - * Retrieve revisions for a specific post. + * Retrieves revisions for a specific post. * * @since 3.5.0 * @@ -4631,13 +4658,13 @@ * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id (unused) - * @type string $username - * @type string $password - * @type int $post_id - * @type array $fields (optional) + * @type int $0 Blog ID (unused). + * @type string $1 Username. + * @type string $2 Password. + * @type int $3 Post ID. + * @type array $4 Optional. Fields to fetch. * } - * @return array|IXR_Error contains a collection of posts. + * @return array|IXR_Error Array containing a collection of posts. */ public function wp_getRevisions( $args ) { if ( ! $this->minimum_args( $args, 4 ) ) { @@ -4658,7 +4685,8 @@ * * @since 3.5.0 * - * @param array $field An array of revision query fields. + * @param array $field An array of revision fields to retrieve. By default, + * contains 'post_date' and 'post_date_gmt'. * @param string $method The method name. */ $fields = apply_filters( 'xmlrpc_default_revision_fields', array( 'post_date', 'post_date_gmt' ), 'wp.getRevisions' ); @@ -4711,7 +4739,7 @@ } /** - * Restore a post revision + * Restores a post revision. * * @since 3.5.0 * @@ -4720,10 +4748,10 @@ * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id (unused) - * @type string $username - * @type string $password - * @type int $revision_id + * @type int $0 Blog ID (unused). + * @type string $1 Username. + * @type string $2 Password. + * @type int $3 Revision ID. * } * @return bool|IXR_Error false if there was an error restoring, true if success. */ @@ -4780,7 +4808,7 @@ */ /** - * Retrieve blogs that user owns. + * Retrieves blogs that user owns. * * Will make more sense once we support multiple blogs. * @@ -4789,9 +4817,9 @@ * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id (unused) - * @type string $username - * @type string $password + * @type int $0 Blog ID (unused). + * @type string $1 Username. + * @type string $2 Password. * } * @return array|IXR_Error */ @@ -4831,15 +4859,16 @@ } /** - * Private function for retrieving a users blogs for multisite setups + * Private function for retrieving a users blogs for multisite setups. * * @since 3.0.0 * * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type string $username Username. - * @type string $password Password. + * @type int $0 Blog ID (unused). + * @type string $1 Username. + * @type string $2 Password. * } * @return array|IXR_Error */ @@ -4849,19 +4878,16 @@ $domain = $current_blog->domain; $path = $current_blog->path . 'xmlrpc.php'; - $rpc = new IXR_Client( set_url_scheme( "http://{$domain}{$path}" ) ); - $rpc->query( 'wp.getUsersBlogs', $args[1], $args[2] ); - $blogs = $rpc->getResponse(); - - if ( isset( $blogs['faultCode'] ) ) { - return new IXR_Error( $blogs['faultCode'], $blogs['faultString'] ); + $blogs = $this->wp_getUsersBlogs( $args ); + if ( $blogs instanceof IXR_Error ) { + return $blogs; } if ( $_SERVER['HTTP_HOST'] == $domain && $_SERVER['REQUEST_URI'] == $path ) { return $blogs; } else { foreach ( (array) $blogs as $blog ) { - if ( strpos( $blog['url'], $_SERVER['HTTP_HOST'] ) ) { + if ( str_contains( $blog['url'], $_SERVER['HTTP_HOST'] ) ) { return array( $blog ); } } @@ -4870,7 +4896,7 @@ } /** - * Retrieve user's data. + * Retrieves user's data. * * Gives your client some info about you, so you don't have to. * @@ -4879,9 +4905,9 @@ * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id (unused) - * @type string $username - * @type string $password + * @type int $0 Blog ID (unused). + * @type string $1 Username. + * @type string $2 Password. * } * @return array|IXR_Error */ @@ -4915,24 +4941,24 @@ } /** - * Retrieve post. + * Retrieves a post. * * @since 1.5.0 * * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * - * @type int $blog_id (unused) - * @type int $post_ID - * @type string $username - * @type string $password + * @type int $0 Blog ID (unused). + * @type int $1 Post ID. + * @type string $2 Username. + * @type string $3 Password. * } * @return array|IXR_Error */ public function blogger_getPost( $args ) { $this->escape( $args ); - $post_ID = (int) $args[1]; + $post_id = (int) $args[1]; $username = $args[2]; $password = $args[3]; @@ -4941,19 +4967,19 @@ 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 = '