Changeset 20856
- Timestamp:
- 05/23/2012 08:40:40 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/class-wp-xmlrpc-server.php
r20846 r20856 826 826 827 827 /** 828 * Prepares comment data for return in an XML-RPC object. 829 * 830 * @access protected 831 * 832 * @param object $comment The unprepared comment data 833 * @return array The prepared comment data 834 */ 835 protected function _prepare_comment( $comment ) { 836 // Format page date. 837 $comment_date = $this->_convert_date( $comment->comment_date ); 838 $comment_date_gmt = $this->_convert_date_gmt( $comment->comment_date_gmt, $comment->comment_date ); 839 840 if ( '0' == $comment->comment_approved ) 841 $comment_status = 'hold'; 842 else if ( 'spam' == $comment->comment_approved ) 843 $comment_status = 'spam'; 844 else if ( '1' == $comment->comment_approved ) 845 $comment_status = 'approve'; 846 else 847 $comment_status = $comment->comment_approved; 848 849 $_comment = array( 850 'date_created_gmt' => $comment_date_gmt, 851 'user_id' => $comment->user_id, 852 'comment_id' => $comment->comment_ID, 853 'parent' => $comment->comment_parent, 854 'status' => $comment_status, 855 'content' => $comment->comment_content, 856 'link' => get_comment_link($comment), 857 'post_id' => $comment->comment_post_ID, 858 'post_title' => get_the_title($comment->comment_post_ID), 859 'author' => $comment->comment_author, 860 'author_url' => $comment->comment_author_url, 861 'author_email' => $comment->comment_author_email, 862 'author_ip' => $comment->comment_author_IP, 863 'type' => $comment->comment_type, 864 ); 865 866 return apply_filters( 'xmlrpc_prepare_comment', $_comment, $comment ); 867 } 868 869 /** 828 870 * Create a new post for any registered post type. 829 871 * … … 2362 2404 return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); 2363 2405 2364 // Format page date. 2365 $comment_date = $this->_convert_date( $comment->comment_date ); 2366 $comment_date_gmt = $this->_convert_date_gmt( $comment->comment_date_gmt, $comment->comment_date ); 2367 2368 if ( '0' == $comment->comment_approved ) 2369 $comment_status = 'hold'; 2370 else if ( 'spam' == $comment->comment_approved ) 2371 $comment_status = 'spam'; 2372 else if ( '1' == $comment->comment_approved ) 2373 $comment_status = 'approve'; 2374 else 2375 $comment_status = $comment->comment_approved; 2376 2377 $link = get_comment_link($comment); 2378 2379 $comment_struct = array( 2380 'date_created_gmt' => $comment_date_gmt, 2381 'user_id' => $comment->user_id, 2382 'comment_id' => $comment->comment_ID, 2383 'parent' => $comment->comment_parent, 2384 'status' => $comment_status, 2385 'content' => $comment->comment_content, 2386 'link' => $link, 2387 'post_id' => $comment->comment_post_ID, 2388 'post_title' => get_the_title($comment->comment_post_ID), 2389 'author' => $comment->comment_author, 2390 'author_url' => $comment->comment_author_url, 2391 'author_email' => $comment->comment_author_email, 2392 'author_ip' => $comment->comment_author_IP, 2393 'type' => $comment->comment_type, 2394 ); 2395 2396 return $comment_struct; 2406 return $this->_prepare_comment( $comment ); 2397 2407 } 2398 2408 … … 2417 2427 */ 2418 2428 function wp_getComments($args) { 2419 $raw_args = $args;2420 2429 $this->escape($args); 2421 2430 … … 2423 2432 $username = $args[1]; 2424 2433 $password = $args[2]; 2425 $struct = $args[3];2434 $struct = isset( $args[3] ) ? $args[3] : array(); 2426 2435 2427 2436 if ( !$user = $this->login($username, $password) ) … … 2451 2460 2452 2461 $comments = get_comments( array('status' => $status, 'post_id' => $post_id, 'offset' => $offset, 'number' => $number ) ); 2453 $num_comments = count($comments);2454 2455 if ( ! $num_comments )2456 return array();2457 2462 2458 2463 $comments_struct = array(); 2459 2464 2460 // FIXME: we already have the comments, why query them again? 2461 for ( $i = 0; $i < $num_comments; $i++ ) { 2462 $comment = wp_xmlrpc_server::wp_getComment(array( 2463 $raw_args[0], $raw_args[1], $raw_args[2], $comments[$i]->comment_ID, 2464 )); 2465 $comments_struct[] = $comment; 2465 foreach ( $comments as $comment ) { 2466 $comments_struct[] = $this->_prepare_comment( $comment ); 2466 2467 } 2467 2468
Note: See TracChangeset
for help on using the changeset viewer.