Changeset 30181
- Timestamp:
- 11/03/2014 03:03:30 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-xmlrpc-server.php
r30153 r30181 22 22 */ 23 23 class wp_xmlrpc_server extends IXR_Server { 24 24 /** 25 * @var array 26 */ 27 public $methods; 28 /** 29 * @var array 30 */ 31 public $blog_options; 32 /** 33 * @var IXR_Error 34 */ 35 public $error; 25 36 /** 26 37 * Register all of the XMLRPC methods that XMLRPC server understands. … … 193 204 * @param string $username User's username. 194 205 * @param string $password User's password. 195 * @return mixedWP_User object if authentication passed, false otherwise206 * @return WP_User|bool WP_User object if authentication passed, false otherwise 196 207 */ 197 208 public function login( $username, $password ) { … … 506 517 * - username 507 518 * - password 508 * @return array . Contains:519 * @return array|IXR_Error Array contains: 509 520 * - 'isAdmin' 510 521 * - 'url' … … 1090 1101 * - enclosure 1091 1102 * - any other fields supported by wp_insert_post() 1092 * @return string post_id1103 * @return string|IXR_Error post_id 1093 1104 */ 1094 1105 public function wp_newPost( $args ) { … … 1146 1157 * 1147 1158 * @param WP_User $user The post author if post_author isn't set in $content_struct. 1148 * @param array $content_struct Post data to insert.1159 * @param array|IXR_Error $content_struct Post data to insert. 1149 1160 */ 1150 1161 protected function _insert_post( $user, $content_struct ) { … … 1398 1409 * - int $post_id 1399 1410 * - array $content_struct 1400 * @return true on success1411 * @return bool|IXR_Error true on success 1401 1412 */ 1402 1413 public function wp_editPost( $args ) { … … 1460 1471 * - string $password 1461 1472 * - int $post_id 1462 * @return true on success1473 * @return bool|IXR_Error true on success 1463 1474 */ 1464 1475 public function wp_deletePost( $args ) { … … 1514 1525 * - int $post_id 1515 1526 * - array $fields optional 1516 * @return array contains (based on $fields parameter):1527 * @return array|IXR_Error Array contains (based on $fields parameter): 1517 1528 * - 'post_id' 1518 1529 * - 'post_title' … … 1601 1612 * - array $filter optional 1602 1613 * - array $fields optional 1603 * @return array contains a collection of posts.1614 * @return array|IXR_Error Array contains a collection of posts. 1604 1615 */ 1605 1616 public function wp_getPosts( $args ) { … … 1697 1708 * - 'description' 1698 1709 * - 'slug' 1699 * @return string term_id1710 * @return string|IXR_Error term_id 1700 1711 */ 1701 1712 public function wp_newTerm( $args ) { … … 1784 1795 * - 'description' 1785 1796 * - 'slug' 1786 * @return bool True, on success.1797 * @return bool|IXR_Error True, on success. 1787 1798 */ 1788 1799 public function wp_editTerm( $args ) { … … 1934 1945 * - string $taxonomy 1935 1946 * - string $term_id 1936 * @return array contains:1947 * @return array|IXR_Error Array contains: 1937 1948 * - 'term_id' 1938 1949 * - 'name' … … 1996 2007 * - string $taxonomy 1997 2008 * - array $filter optional 1998 * @return array terms2009 * @return array|IXR_Error terms 1999 2010 */ 2000 2011 public function wp_getTerms( $args ) { … … 2071 2082 * - string $password 2072 2083 * - string $taxonomy 2073 * @return array (@see get_taxonomy())2084 * @return array|IXR_Error (@see get_taxonomy()) 2074 2085 */ 2075 2086 public function wp_getTaxonomy( $args ) { … … 2183 2194 * - int $user_id 2184 2195 * - array $fields optional 2185 * @return array contains (based on $fields parameter):2196 * @return array|IXR_Error Array contains (based on $fields parameter): 2186 2197 * - 'user_id' 2187 2198 * - 'username' … … 2257 2268 * - array $filter optional 2258 2269 * - array $fields optional 2259 * @return array users data2270 * @return array|IXR_Error users data 2260 2271 */ 2261 2272 public function wp_getUsers( $args ) { … … 2327 2338 * - string $password 2328 2339 * - array $fields optional 2329 * @return array (@see wp_getUser)2340 * @return array|IXR_Error (@see wp_getUser) 2330 2341 */ 2331 2342 public function wp_getProfile( $args ) { … … 2376 2387 * - 'nicename' 2377 2388 * - 'bio' 2378 * @return bool True, on success.2389 * @return bool|IXR_Error True, on success. 2379 2390 */ 2380 2391 public function wp_editProfile( $args ) { … … 2444 2455 * - username 2445 2456 * - password 2446 * @return array 2457 * @return array|IXR_Error 2447 2458 */ 2448 2459 public function wp_getPage($args) { … … 2487 2498 * - password 2488 2499 * - num_pages 2489 * @return array 2500 * @return array|IXR_Error 2490 2501 */ 2491 2502 public function wp_getPages($args) { … … 2517 2528 } 2518 2529 2519 return($pages_struct); 2520 } 2521 // If no pages were found return an error. 2522 else { 2523 return(array()); 2524 } 2530 return $pages_struct; 2531 } 2532 2533 return array(); 2525 2534 } 2526 2535 … … 2531 2540 * 2532 2541 * @param array $args Method parameters. See {@link wp_xmlrpc_server::mw_newPost()} 2533 * @return unknown2542 * @return int|IXR_Error 2534 2543 */ 2535 2544 public function wp_newPage($args) { … … 2550 2559 2551 2560 // Let mw_newPost do all of the heavy lifting. 2552 return ($this->mw_newPost($args));2561 return $this->mw_newPost( $args ); 2553 2562 } 2554 2563 … … 2559 2568 * 2560 2569 * @param array $args Method parameters. 2561 * @return bool True, if success.2570 * @return bool|IXR_Error True, if success. 2562 2571 */ 2563 2572 public function wp_deletePage($args) { … … 2578 2587 $actual_page = get_post($page_id, ARRAY_A); 2579 2588 if ( !$actual_page || ($actual_page['post_type'] != 'page') ) 2580 return (new IXR_Error(404, __('Sorry, no such page.')));2589 return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); 2581 2590 2582 2591 // Make sure the user can delete pages. 2583 2592 if ( !current_user_can('delete_page', $page_id) ) 2584 return (new IXR_Error(401, __('Sorry, you do not have the right to delete this page.')));2593 return new IXR_Error( 401, __( 'Sorry, you do not have the right to delete this page.' ) ); 2585 2594 2586 2595 // Attempt to delete the page. 2587 2596 $result = wp_delete_post($page_id); 2588 2597 if ( !$result ) 2589 return (new IXR_Error(500, __('Failed to delete the page.')));2598 return new IXR_Error( 500, __( 'Failed to delete the page.' ) ); 2590 2599 2591 2600 /** … … 2599 2608 do_action( 'xmlrpc_call_success_wp_deletePage', $page_id, $args ); 2600 2609 2601 return (true);2610 return true; 2602 2611 } 2603 2612 … … 2608 2617 * 2609 2618 * @param array $args Method parameters. 2610 * @return unknown2619 * @return array|IXR_Error 2611 2620 */ 2612 2621 public function wp_editPage($args) { … … 2627 2636 $actual_page = get_post($page_id, ARRAY_A); 2628 2637 if ( !$actual_page || ($actual_page['post_type'] != 'page') ) 2629 return (new IXR_Error(404, __('Sorry, no such page.')));2638 return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); 2630 2639 2631 2640 // Make sure the user is allowed to edit pages. 2632 2641 if ( !current_user_can('edit_page', $page_id) ) 2633 return (new IXR_Error(401, __('Sorry, you do not have the right to edit this page.')));2642 return new IXR_Error( 401, __( 'Sorry, you do not have the right to edit this page.' ) ); 2634 2643 2635 2644 // Mark this as content for a page. … … 2646 2655 2647 2656 // Let mw_editPost do all of the heavy lifting. 2648 return ($this->mw_editPost($args));2657 return $this->mw_editPost( $args ); 2649 2658 } 2650 2659 … … 2655 2664 * 2656 2665 * @param array $args Method parameters. 2657 * @return unknown2666 * @return array|IXR_Error 2658 2667 */ 2659 2668 public function wp_getPageList($args) { … … 2698 2707 } 2699 2708 2700 return ($page_list);2709 return $page_list; 2701 2710 } 2702 2711 … … 2707 2716 * 2708 2717 * @param array $args Method parameters. 2709 * @return array 2718 * @return array|IXR_Error 2710 2719 */ 2711 2720 public function wp_getAuthors($args) { … … 2720 2729 2721 2730 if ( !current_user_can('edit_posts') ) 2722 return (new IXR_Error(401, __('Sorry, you cannot edit posts on this site.')));2731 return new IXR_Error( 401, __( 'Sorry, you cannot edit posts on this site.' ) ); 2723 2732 2724 2733 /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ … … 2743 2752 * 2744 2753 * @param array $args Method parameters. 2745 * @return array 2754 * @return array|IXR_Error 2746 2755 */ 2747 2756 public function wp_getTags( $args ) { … … 2785 2794 * 2786 2795 * @param array $args Method parameters. 2787 * @return int Category ID.2796 * @return int|IXR_Error Category ID. 2788 2797 */ 2789 2798 public function wp_newCategory($args) { … … 2802 2811 // Make sure the user is allowed to add a category. 2803 2812 if ( !current_user_can('manage_categories') ) 2804 return (new IXR_Error(401, __('Sorry, you do not have the right to add a category.')));2813 return new IXR_Error(401, __('Sorry, you do not have the right to add a category.')); 2805 2814 2806 2815 // If no slug was provided make it empty so that … … 2830 2839 return (int) $cat_id->get_error_data(); 2831 2840 else 2832 return (new IXR_Error(500, __('Sorry, the new category failed.')));2841 return new IXR_Error(500, __('Sorry, the new category failed.')); 2833 2842 } elseif ( ! $cat_id ) { 2834 return (new IXR_Error(500, __('Sorry, the new category failed.')));2843 return new IXR_Error(500, __('Sorry, the new category failed.')); 2835 2844 } 2836 2845 … … 2854 2863 * 2855 2864 * @param array $args Method parameters. 2856 * @return mixedSee {@link wp_delete_term()} for return info.2865 * @return bool|IXR_Error See {@link wp_delete_term()} for return info. 2857 2866 */ 2858 2867 public function wp_deleteCategory($args) { … … 2895 2904 * 2896 2905 * @param array $args Method parameters. 2897 * @return array 2906 * @return array|IXR_Error 2898 2907 */ 2899 2908 public function wp_suggestCategories($args) { … … 2923 2932 } 2924 2933 2925 return ($category_suggestions);2934 return $category_suggestions; 2926 2935 } 2927 2936 … … 2932 2941 * 2933 2942 * @param array $args Method parameters. 2934 * @return array 2943 * @return array|IXR_Error 2935 2944 */ 2936 2945 public function wp_getComment($args) { … … 2973 2982 * 2974 2983 * @param array $args Method parameters. 2975 * @return array .Contains a collection of comments. See {@link wp_xmlrpc_server::wp_getComment()} for a description of each item contents2984 * @return array|IXR_Error Contains a collection of comments. See {@link wp_xmlrpc_server::wp_getComment()} for a description of each item contents 2976 2985 */ 2977 2986 public function wp_getComments($args) { … … 3033 3042 * - password 3034 3043 * - comment_id 3035 * @return mixed{@link wp_delete_comment()}3044 * @return bool|IXR_Error {@link wp_delete_comment()} 3036 3045 */ 3037 3046 public function wp_deleteComment($args) { … … 3096 3105 * - comment_id 3097 3106 * - content_struct 3098 * @return bool True, on success.3107 * @return bool|IXR_Error True, on success. 3099 3108 */ 3100 3109 public function wp_editComment($args) { … … 3179 3188 * 3180 3189 * @param array $args Method parameters. 3181 * @return mixed{@link wp_new_comment()}3190 * @return int|IXR_Error {@link wp_new_comment()} 3182 3191 */ 3183 3192 public function wp_newComment($args) { … … 3281 3290 * 3282 3291 * @param array $args Method parameters. 3283 * @return array 3292 * @return array|IXR_Error 3284 3293 */ 3285 3294 public function wp_getCommentStatusList($args) { … … 3307 3316 * 3308 3317 * @param array $args Method parameters. 3309 * @return array 3318 * @return array|IXR_Error 3310 3319 */ 3311 3320 public function wp_getCommentCount( $args ) { … … 3340 3349 * 3341 3350 * @param array $args Method parameters. 3342 * @return array 3351 * @return array|IXR_Error 3343 3352 */ 3344 3353 public function wp_getPostStatusList( $args ) { … … 3366 3375 * 3367 3376 * @param array $args Method parameters. 3368 * @return array 3377 * @return array|IXR_Error 3369 3378 */ 3370 3379 public function wp_getPageStatusList( $args ) { … … 3392 3401 * 3393 3402 * @param array $args Method parameters. 3394 * @return array 3403 * @return array|IXR_Error 3395 3404 */ 3396 3405 public function wp_getPageTemplates( $args ) { … … 3418 3427 * 3419 3428 * @param array $args Method parameters. 3420 * @return array 3429 * @return array|IXR_Error 3421 3430 */ 3422 3431 public function wp_getOptions( $args ) { … … 3471 3480 * 3472 3481 * @param array $args Method parameters. 3473 * @return unknown3482 * @return array|IXR_Error 3474 3483 */ 3475 3484 public function wp_setOptions( $args ) { … … 3512 3521 * - password 3513 3522 * - attachment_id 3514 * @return array . Associative array containing:3523 * @return array|IXR_Error Associative array contains: 3515 3524 * - 'date_created_gmt' 3516 3525 * - 'parent' … … 3565 3574 * - password 3566 3575 * - filter 3567 * @return array .Contains a collection of media items. See {@link wp_xmlrpc_server::wp_getMediaItem()} for a description of each item contents3576 * @return array|IXR_Error Contains a collection of media items. See {@link wp_xmlrpc_server::wp_getMediaItem()} for a description of each item contents 3568 3577 */ 3569 3578 public function wp_getMediaLibrary($args) { … … 3607 3616 * - username 3608 3617 * - password 3609 * @return array 3618 * @return array|IXR_Error 3610 3619 */ 3611 3620 public function wp_getPostFormats( $args ) { … … 3656 3665 * - string $post_type_name 3657 3666 * - array $fields 3658 * @return array contains:3667 * @return array|IXR_Error Array contains: 3659 3668 * - 'labels' 3660 3669 * - 'description' … … 3720 3729 * - array $filter 3721 3730 * - array $fields 3722 * @return array 3731 * @return array|IXR_Error 3723 3732 */ 3724 3733 public function wp_getPostTypes( $args ) { … … 3776 3785 * - int $post_id 3777 3786 * - array $fields 3778 * @return array contains a collection of posts.3787 * @return array|IXR_Error contains a collection of posts. 3779 3788 */ 3780 3789 public function wp_getRevisions( $args ) { … … 3851 3860 * - string $password 3852 3861 * - int $post_id 3853 * @return bool false if there was an error restoring, true if success.3862 * @return bool|IXR_Error false if there was an error restoring, true if success. 3854 3863 */ 3855 3864 public function wp_restoreRevision( $args ) { … … 3902 3911 * 3903 3912 * @param array $args Method parameters. 3904 * @return array 3913 * @return array|IXR_Error 3905 3914 */ 3906 3915 public function blogger_getUsersBlogs($args) { … … 3936 3945 * 3937 3946 * @access protected 3947 * 3948 * @return array|IXR_Error 3938 3949 */ 3939 3950 protected function _multisite_getUsersBlogs($args) { … … 3969 3980 * 3970 3981 * @param array $args Method parameters. 3971 * @return array 3982 * @return array|IXR_Error 3972 3983 */ 3973 3984 public function blogger_getUserInfo($args) { … … 4004 4015 * 4005 4016 * @param array $args Method parameters. 4006 * @return array 4017 * @return array|IXR_Error 4007 4018 */ 4008 4019 public function blogger_getPost($args) { … … 4049 4060 * 4050 4061 * @param array $args Method parameters. 4051 * @return array 4062 * @return array|IXR_Error 4052 4063 */ 4053 4064 public function blogger_getRecentPosts($args) { … … 4107 4118 * @since 1.5.0 4108 4119 * @deprecated 3.5.0 4120 * @return IXR_Error 4109 4121 */ 4110 4122 public function blogger_getTemplate($args) { … … 4117 4129 * @since 1.5.0 4118 4130 * @deprecated 3.5.0 4131 * @return IXR_Error 4119 4132 */ 4120 4133 public function blogger_setTemplate($args) { … … 4128 4141 * 4129 4142 * @param array $args Method parameters. 4130 * @return int 4143 * @return int|IXR_Error 4131 4144 */ 4132 4145 public function blogger_newPost($args) { … … 4190 4203 * 4191 4204 * @param array $args Method parameters. 4192 * @return bool true when done.4205 * @return bool|IXR_Error true when done. 4193 4206 */ 4194 4207 public function blogger_editPost( $args ) { … … 4258 4271 * 4259 4272 * @param array $args Method parameters. 4260 * @return bool True when post is deleted.4273 * @return bool|IXR_Error True when post is deleted. 4261 4274 */ 4262 4275 public function blogger_deletePost($args) { … … 4337 4350 * - content_struct 4338 4351 * - publish 4339 * @return int 4352 * @return int|IXR_Error 4340 4353 */ 4341 4354 public function mw_newPost($args) { … … 4428 4441 case "post": 4429 4442 if ( !current_user_can( 'edit_others_posts' ) ) 4430 return ( new IXR_Error( 401, __( 'You are not allowed to create posts as this user.' )) );4443 return new IXR_Error( 401, __( 'You are not allowed to create posts as this user.' ) ); 4431 4444 break; 4432 4445 case "page": 4433 4446 if ( !current_user_can( 'edit_others_pages' ) ) 4434 return ( new IXR_Error( 401, __( 'You are not allowed to create pages as this user.' )) );4447 return new IXR_Error( 401, __( 'You are not allowed to create pages as this user.' ) ); 4435 4448 break; 4436 4449 default: 4437 return ( new IXR_Error( 401, __( 'Invalid post type' )) );4450 return new IXR_Error( 401, __( 'Invalid post type' ) ); 4438 4451 break; 4439 4452 } … … 4663 4676 * 4664 4677 * @param array $args Method parameters. 4665 * @return bool True on success.4678 * @return bool|IXR_Error True on success. 4666 4679 */ 4667 4680 public function mw_editPost($args) { … … 4748 4761 case 'post': 4749 4762 if ( !current_user_can('edit_others_posts') ) 4750 return (new IXR_Error(401, __('You are not allowed to change the post author as this user.')));4763 return new IXR_Error( 401, __( 'You are not allowed to change the post author as this user.' ) ); 4751 4764 break; 4752 4765 case 'page': 4753 4766 if ( !current_user_can('edit_others_pages') ) 4754 return (new IXR_Error(401, __('You are not allowed to change the page author as this user.')));4767 return new IXR_Error( 401, __( 'You are not allowed to change the page author as this user.' ) ); 4755 4768 break; 4756 4769 default: 4757 return (new IXR_Error(401, __('Invalid post type')));4770 return new IXR_Error( 401, __( 'Invalid post type' ) ); 4758 4771 break; 4759 4772 } … … 4950 4963 * 4951 4964 * @param array $args Method parameters. 4952 * @return array 4965 * @return array|IXR_Error 4953 4966 */ 4954 4967 public function mw_getPost($args) { … … 5075 5088 * 5076 5089 * @param array $args Method parameters. 5077 * @return array 5090 * @return array|IXR_Error 5078 5091 */ 5079 5092 public function mw_getRecentPosts($args) { … … 5187 5200 * 5188 5201 * @param array $args Method parameters. 5189 * @return array 5202 * @return array|IXR_Error 5190 5203 */ 5191 5204 public function mw_getCategories($args) { … … 5235 5248 * 5236 5249 * @param array $args Method parameters. 5237 * @return array 5250 * @return array|IXR_Error 5238 5251 */ 5239 5252 public function mw_newMediaObject($args) { … … 5348 5361 * 5349 5362 * @param array $args Method parameters. 5350 * @return array 5363 * @return array|IXR_Error 5351 5364 */ 5352 5365 public function mt_getRecentPostTitles($args) { … … 5374 5387 } 5375 5388 5376 $ struct= array();5389 $recent_posts = array(); 5377 5390 5378 5391 foreach ($posts_list as $entry) { … … 5383 5396 $post_date_gmt = $this->_convert_date_gmt( $entry['post_date_gmt'], $entry['post_date'] ); 5384 5397 5385 $ struct[] = array(5398 $recent_posts[] = array( 5386 5399 'dateCreated' => $post_date, 5387 5400 'userid' => $entry['post_author'], … … 5391 5404 'date_created_gmt' => $post_date_gmt 5392 5405 ); 5393 5394 }5395 5396 $recent_posts = array();5397 for ( $j=0; $j<count($struct); $j++ ) {5398 array_push($recent_posts, $struct[$j]);5399 5406 } 5400 5407 … … 5408 5415 * 5409 5416 * @param array $args Method parameters. 5410 * @return array 5417 * @return array|IXR_Error 5411 5418 */ 5412 5419 public function mt_getCategoryList($args) { … … 5447 5454 * 5448 5455 * @param array $args Method parameters. 5449 * @return array 5456 * @return array|IXR_Error 5450 5457 */ 5451 5458 public function mt_getPostCategories($args) { … … 5491 5498 * 5492 5499 * @param array $args Method parameters. 5493 * @return bool True on success.5500 * @return bool|IXR_Error True on success. 5494 5501 */ 5495 5502 public function mt_setPostCategories($args) { … … 5572 5579 * 5573 5580 * @param array $args Method parameters. 5574 * @return mixed5581 * @return array|IXR_Error 5575 5582 */ 5576 5583 public function mt_getTrackbackPings($args) { … … 5615 5622 * 5616 5623 * @param array $args Method parameters. 5617 * @return int 5624 * @return int|IXR_Error 5618 5625 */ 5619 5626 public function mt_publishPost($args) { … … 5660 5667 * 5661 5668 * @param array $args Method parameters. 5662 * @return array5669 * @return string|IXR_Error 5663 5670 */ 5664 5671 public function pingback_ping($args) { … … 5868 5875 * 5869 5876 * @param array $args Method parameters. 5870 * @return array 5877 * @return array|IXR_Error 5871 5878 */ 5872 5879 public function pingback_extensions_getPingbacks($args) {
Note: See TracChangeset
for help on using the changeset viewer.