WordPress.org

Make WordPress Core

Changeset 34575


Ignore:
Timestamp:
09/26/2015 04:44:51 AM (6 years ago)
Author:
wonderboymusic
Message:

XML-RPC: In wp_xmlrpc_server::wp_getComments(), allow post_type to be passed as part of $struct.

Props nprasath002.
Fixes #20026.

File:
1 edited

Legend:

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

    r34574 r34575  
    32153215        $struct   = isset( $args[3] ) ? $args[3] : array();
    32163216
    3217         if ( ! $user = $this->login($username, $password ) )
    3218             return $this->error;
     3217        if ( ! $user = $this->login( $username, $password ) ) {
     3218            return $this->error;
     3219        }
    32193220
    32203221        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    32213222        do_action( 'xmlrpc_call', 'wp.getComments' );
    32223223
    3223         if ( isset( $struct['status'] ) )
     3224        if ( isset( $struct['status'] ) ) {
    32243225            $status = $struct['status'];
    3225         else
     3226        } else {
    32263227            $status = '';
     3228        }
    32273229
    32283230        if ( ! current_user_can( 'moderate_comments' ) && 'approve' !== $status ) {
     
    32313233
    32323234        $post_id = '';
    3233         if ( isset($struct['post_id']) )
    3234             $post_id = absint($struct['post_id']);
     3235        if ( isset( $struct['post_id'] ) ) {
     3236            $post_id = absint( $struct['post_id'] );
     3237        }
     3238
     3239        $post_type = '';
     3240        if ( isset( $struct['post_type'] ) ) {
     3241            $post_type_object = get_post_type_object( $struct['post_type'] );
     3242            if ( ! $post_type_object || ! post_type_supports( $post_type_object->name, 'comments' ) ) {
     3243                return new IXR_Error( 404, __( 'Invalid post type.' ) );
     3244            }
     3245            $post_type = $struct['post_type'];
     3246        }
    32353247
    32363248        $offset = 0;
    3237         if ( isset($struct['offset']) )
    3238             $offset = absint($struct['offset']);
     3249        if ( isset( $struct['offset'] ) ) {
     3250            $offset = absint( $struct['offset'] );
     3251        }
    32393252
    32403253        $number = 10;
    3241         if ( isset($struct['number']) )
    3242             $number = absint($struct['number']);
    3243 
    3244         $comments = get_comments( array( 'status' => $status, 'post_id' => $post_id, 'offset' => $offset, 'number' => $number ) );
     3254        if ( isset( $struct['number'] ) ) {
     3255            $number = absint( $struct['number'] );
     3256        }
     3257
     3258        $comments = get_comments( array(
     3259            'status' => $status,
     3260            'post_id' => $post_id,
     3261            'offset' => $offset,
     3262            'number' => $number,
     3263            'post_type' => $post_type,
     3264        ) );
    32453265
    32463266        $comments_struct = array();
Note: See TracChangeset for help on using the changeset viewer.