XML-RPC: In `wp_xmlrpc_server::wp_getComments()`, allow `post_type` to be passed as part of `$struct`.
Props nprasath002. Fixes #20026. Built from https://develop.svn.wordpress.org/trunk@34575 git-svn-id: http://core.svn.wordpress.org/trunk@34539 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
c8b308a647
commit
ffe7f0ec5a
|
@ -3214,34 +3214,54 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
$password = $args[2];
|
$password = $args[2];
|
||||||
$struct = isset( $args[3] ) ? $args[3] : array();
|
$struct = isset( $args[3] ) ? $args[3] : array();
|
||||||
|
|
||||||
if ( ! $user = $this->login($username, $password ) )
|
if ( ! $user = $this->login( $username, $password ) ) {
|
||||||
return $this->error;
|
return $this->error;
|
||||||
|
}
|
||||||
|
|
||||||
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
|
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
|
||||||
do_action( 'xmlrpc_call', 'wp.getComments' );
|
do_action( 'xmlrpc_call', 'wp.getComments' );
|
||||||
|
|
||||||
if ( isset( $struct['status'] ) )
|
if ( isset( $struct['status'] ) ) {
|
||||||
$status = $struct['status'];
|
$status = $struct['status'];
|
||||||
else
|
} else {
|
||||||
$status = '';
|
$status = '';
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! current_user_can( 'moderate_comments' ) && 'approve' !== $status ) {
|
if ( ! current_user_can( 'moderate_comments' ) && 'approve' !== $status ) {
|
||||||
return new IXR_Error( 401, __( 'Invalid comment status.' ) );
|
return new IXR_Error( 401, __( 'Invalid comment status.' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
$post_id = '';
|
$post_id = '';
|
||||||
if ( isset($struct['post_id']) )
|
if ( isset( $struct['post_id'] ) ) {
|
||||||
$post_id = absint($struct['post_id']);
|
$post_id = absint( $struct['post_id'] );
|
||||||
|
}
|
||||||
|
|
||||||
|
$post_type = '';
|
||||||
|
if ( isset( $struct['post_type'] ) ) {
|
||||||
|
$post_type_object = get_post_type_object( $struct['post_type'] );
|
||||||
|
if ( ! $post_type_object || ! post_type_supports( $post_type_object->name, 'comments' ) ) {
|
||||||
|
return new IXR_Error( 404, __( 'Invalid post type.' ) );
|
||||||
|
}
|
||||||
|
$post_type = $struct['post_type'];
|
||||||
|
}
|
||||||
|
|
||||||
$offset = 0;
|
$offset = 0;
|
||||||
if ( isset($struct['offset']) )
|
if ( isset( $struct['offset'] ) ) {
|
||||||
$offset = absint($struct['offset']);
|
$offset = absint( $struct['offset'] );
|
||||||
|
}
|
||||||
|
|
||||||
$number = 10;
|
$number = 10;
|
||||||
if ( isset($struct['number']) )
|
if ( isset( $struct['number'] ) ) {
|
||||||
$number = absint($struct['number']);
|
$number = absint( $struct['number'] );
|
||||||
|
}
|
||||||
|
|
||||||
$comments = get_comments( array( 'status' => $status, 'post_id' => $post_id, 'offset' => $offset, 'number' => $number ) );
|
$comments = get_comments( array(
|
||||||
|
'status' => $status,
|
||||||
|
'post_id' => $post_id,
|
||||||
|
'offset' => $offset,
|
||||||
|
'number' => $number,
|
||||||
|
'post_type' => $post_type,
|
||||||
|
) );
|
||||||
|
|
||||||
$comments_struct = array();
|
$comments_struct = array();
|
||||||
if ( is_array( $comments ) ) {
|
if ( is_array( $comments ) ) {
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.4-alpha-34574';
|
$wp_version = '4.4-alpha-34575';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue