Changeset 543520
- Timestamp:
- 05/12/2012 08:40:19 PM (14 years ago)
- Location:
- xml-rpc-modernization/trunk
- Files:
-
- 3 edited
-
class-wp-xmlrpc-server-ext.php (modified) (70 diffs)
-
readme.txt (modified) (5 diffs)
-
wp-xmlrpc-modernization.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
xml-rpc-modernization/trunk/class-wp-xmlrpc-server-ext.php
r510787 r543520 3 3 include_once( ABSPATH . WPINC . '/class-IXR.php' ); 4 4 include_once( ABSPATH . WPINC . '/class-wp-xmlrpc-server.php' ); 5 include_once( ABSPATH . WPINC . '/post-thumbnail-template.php' ); 5 6 6 7 class wp_xmlrpc_server_ext extends wp_xmlrpc_server { … … 8 9 function __construct() { 9 10 // hook filter to add the new methods after the existing ones are added in the parent constructor 10 add_filter( 'xmlrpc_methods' , array( &$this, 'xmlrpc_methods' ) ); 11 add_filter( 'xmlrpc_methods' , array( &$this, 'wxm_xmlrpc_methods' ) ); 12 13 // patch wp.uploadFile to return ID 14 add_filter( 'wp_handle_upload', array( &$this, 'wxm_handle_upload' ) ); 15 16 // add new options 17 add_filter( 'xmlrpc_blog_options', array( &$this, 'wxm_blog_options' ) ); 11 18 12 19 parent::__construct(); 13 20 } 14 21 15 function xmlrpc_methods( $methods ) {22 function wxm_xmlrpc_methods( $methods ) { 16 23 $new_methods = array(); 17 24 … … 30 37 $new_methods['wp.getPost'] = array( &$this, 'wp_getPost' ); 31 38 $new_methods['wp.getPosts'] = array( &$this, 'wp_getPosts' ); 32 $new_methods['wp.getPostTerms'] = array( &$this, 'wp_getPostTerms' );33 $new_methods['wp.setPostTerms'] = array( &$this, 'wp_setPostTerms' );34 39 $new_methods['wp.getPostType'] = array( &$this, 'wp_getPostType' ); 35 40 $new_methods['wp.getPostTypes'] = array( &$this, 'wp_getPostTypes' ); … … 51 56 } 52 57 58 function __call( $method, $args ) { 59 // depending on the version of WordPress, some methods in this class are already defined 60 // by the parent class. to avoid overriding the core versions, all methods in this class are 61 // namespaced. however, if the parent class is missing some methods, we intercept the call 62 // here and instead pass to the namespaced plugin version. 63 $wxm_method = 'wxm_' . ltrim( $method, "_" ); 64 if ( method_exists( $this, $wxm_method ) ) 65 return call_user_func_array( array( $this, $wxm_method ), $args ); 66 67 throw new Exception ( 'Call to undefined class method: ' . $method ); 68 } 69 70 /** 71 * Checks if the method received at least the minimum number of arguments. 72 * 73 * @param string|array $args Sanitize single string or array of strings. 74 * @param int $count Minimum number of arguments. 75 * @return boolean if $args contains at least $count arguments. 76 */ 77 protected function wxm_minimum_args( $args, $count ) { 78 if ( count( $args ) < $count ) { 79 $this->error = new IXR_Error( 400, __( 'Insufficient arguments passed to this XML-RPC method.' ) ); 80 return false; 81 } 82 83 return true; 84 } 85 53 86 /** 54 87 * Prepares user data for return in an XML-RPC object. … … 60 93 * @return array The prepared user data 61 94 */ 62 protected function _prepare_user( $user, $fields ) {95 protected function wxm_prepare_user( $user, $fields ) { 63 96 $contact_methods = _wp_get_user_contactmethods(); 64 97 … … 98 131 } 99 132 100 return apply_filters( 'xmlrpc_ _prepare_user', $_user, $user, $fields );133 return apply_filters( 'xmlrpc_prepare_user', $_user, $user, $fields ); 101 134 } 102 135 … … 109 142 * @return IXR_Date 110 143 */ 111 protected function _convert_date( $date ) {144 protected function wxm_convert_date( $date ) { 112 145 if ( $date === '0000-00-00 00:00:00' ) { 113 146 return new IXR_Date( '00000000T00:00:00Z' ); … … 117 150 118 151 /** 152 * Convert a WordPress gmt date string to an IXR_Date object. 153 * 154 * @access protected 155 * 156 * @param $date 157 * @return IXR_Date 158 */ 159 protected function wxm_convert_date_gmt( $date_gmt, $date ) { 160 if ( $date !== '0000-00-00 00:00:00' && $date_gmt === '0000-00-00 00:00:00' ) { 161 return new IXR_Date( get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $date, false ), 'Ymd\TH:i:s' ) ); 162 } 163 return $this->_convert_date( $date_gmt ); 164 } 165 166 /** 119 167 * Prepares post data for return in an XML-RPC object. 120 168 * … … 122 170 * 123 171 * @param array $post The unprepared post data 124 * @param array $fields The subset of post fields to return172 * @param array $fields The subset of post type fields to return 125 173 * @return array The prepared post data 126 174 */ 127 protected function _prepare_post( $post, $fields ) {175 protected function wxm_prepare_post( $post, $fields ) { 128 176 // holds the data for this post. built up based on $fields 129 177 $_post = array( 'post_id' => strval( $post['ID'] ) ); … … 133 181 'post_title' => $post['post_title'], 134 182 'post_date' => $this->_convert_date( $post['post_date'] ), 135 'post_date_gmt' => $this->_convert_date ( $post['post_date_gmt'] ),183 'post_date_gmt' => $this->_convert_date_gmt( $post['post_date_gmt'], $post['post_date'] ), 136 184 'post_modified' => $this->_convert_date( $post['post_modified'] ), 137 'post_modified_gmt' => $this->_convert_date ( $post['post_modified_gmt'] ),185 'post_modified_gmt' => $this->_convert_date_gmt( $post['post_modified_gmt'], $post['post_modified'] ), 138 186 'post_status' => $post['post_status'], 139 187 'post_type' => $post['post_type'], … … 147 195 'ping_status' => $post['ping_status'], 148 196 'sticky' => ( $post['post_type'] === 'post' && is_sticky( $post['ID'] ) ), 149 'featured_image' => get_post_meta( $post['ID'], '_thumbnail_id', true ),150 197 ); 198 199 // Thumbnail 200 $post_fields['post_thumbnail'] = array(); 201 $thumbnail_id = get_post_thumbnail_id( $post['ID'] ); 202 if ( $thumbnail_id ) { 203 $thumbnail_size = current_theme_supports('post-thumbnail') ? 'post-thumbnail' : 'thumbnail'; 204 $post_fields['post_thumbnail'] = $this->_prepare_media_item( get_post( $thumbnail_id ), $thumbnail_size ); 205 } 151 206 152 207 // Consider future posts as published … … 176 231 $_post['terms'][] = $this->_prepare_term( $term ); 177 232 } 178 }179 180 // backward compatiblity181 if ( $all_taxonomy_fields || in_array( 'tags', $fields ) ) {182 $tagnames = array();183 $tags = wp_get_post_tags( $post['ID'] );184 if ( ! empty( $tags ) ) {185 foreach ( $tags as $tag ) {186 $tagnames[] = $tag->name;187 }188 $tagnames = implode( ', ', $tagnames );189 } else {190 $tagnames = '';191 }192 $_post['tags'] = $tagnames;193 }194 195 // backward compatiblity196 if ( $all_taxonomy_fields || in_array( 'categories', $fields ) ) {197 $categories = array();198 $catids = wp_get_post_categories( $post['ID'] );199 foreach ( $catids as $catid ) {200 $categories[] = get_cat_name( $catid );201 }202 $_post['categories'] = $categories;203 233 } 204 234 … … 217 247 } 218 248 219 return apply_filters( 'xmlrpc_ _prepare_post', $_post, $post, $fields );249 return apply_filters( 'xmlrpc_prepare_post', $_post, $post, $fields ); 220 250 } 221 251 … … 224 254 * 225 255 * @access protected 226 .* 227 * @param array|object $taxonomy The unprepared taxonomy data 256 * 257 * @param object $taxonomy The unprepared taxonomy data 258 * @param array $fields The subset of taxonomy fields to return 228 259 * @return array The prepared taxonomy data 229 260 */ 230 protected function _prepare_taxonomy( $taxonomy ) { 231 $_taxonomy = (array) $taxonomy; 232 233 unset( $_taxonomy['update_count_callback'] ); 234 235 return apply_filters( 'xmlrpc__prepare_taxonomy', $_taxonomy, $taxonomy ); 261 protected function wxm_prepare_taxonomy( $taxonomy, $fields ) { 262 $_taxonomy = array( 263 'name' => $taxonomy->name, 264 'label' => $taxonomy->label, 265 'hierarchical' => (bool) $taxonomy->hierarchical, 266 'public' => (bool) $taxonomy->public, 267 'show_ui' => (bool) $taxonomy->show_ui, 268 '_builtin' => (bool) $taxonomy->_builtin, 269 ); 270 271 if ( in_array( 'labels', $fields ) ) 272 $_taxonomy['labels'] = (array) $taxonomy->labels; 273 274 if ( in_array( 'cap', $fields ) ) 275 $_taxonomy['cap'] = (array) $taxonomy->cap; 276 277 if ( in_array( 'object_type', $fields ) ) 278 $_taxonomy['object_type'] = array_unique( (array) $taxonomy->object_type ); 279 280 return apply_filters( 'xmlrpc_prepare_taxonomy', $_taxonomy, $taxonomy, $fields ); 236 281 } 237 282 … … 240 285 * 241 286 * @access protected 242 .*287 * 243 288 * @param array|object $term The unprepared term data 244 289 * @return array The prepared term data 245 290 */ 246 protected function _prepare_term( $term ) {291 protected function wxm_prepare_term( $term ) { 247 292 $_term = $term; 248 293 if ( ! is_array( $_term) ) 249 294 $_term = get_object_vars( $_term ); 250 295 251 return apply_filters( 'xmlrpc__prepare_term', $_term, $term ); 252 } 253 254 /** 255 * Prepares post type data for return in an XML-RPC object. 296 // For Intergers which may be largeer than XMLRPC supports ensure we return strings. 297 $_term['term_id'] = strval( $_term['term_id'] ); 298 $_term['term_group'] = strval( $_term['term_group'] ); 299 $_term['term_taxonomy_id'] = strval( $_term['term_taxonomy_id'] ); 300 $_term['parent'] = strval( $_term['parent'] ); 301 302 // Count we are happy to return as an Integer because people really shouldn't use Terms that much. 303 $_term['count'] = intval( $_term['count'] ); 304 305 return apply_filters( 'xmlrpc_prepare_term', $_term, $term ); 306 } 307 308 /** 309 * Get all the post type features 310 * 311 * @param string $post_type The post type 312 * @return array 313 */ 314 private function wxm_get_all_post_type_supports( $post_type ) { 315 if ( function_exists( 'get_all_post_type_supports' ) ) 316 return get_all_post_type_supports( $post_type ); 317 318 global $_wp_post_type_features; 319 320 if ( isset( $_wp_post_type_features[$post_type] ) ) 321 return $_wp_post_type_features[$post_type]; 322 323 return array(); 324 } 325 326 /** 327 * Prepares post data for return in an XML-RPC object. 256 328 * 257 329 * @access protected 258 330 * 259 * @param array|object $post_type The unprepared post type data 331 * @param object $post_type Post type object 332 * @param array $fields The subset of post fields to return 260 333 * @return array The prepared post type data 261 334 */ 262 protected function _prepare_post_type( $post_type ) { 263 $_post_type = (array) $post_type; 264 265 $_post_type['taxonomies'] = get_object_taxonomies( $_post_type['name'] ); 266 267 return apply_filters( 'xmlrpc__prepare_post_type', $_post_type, $post_type ); 335 protected function wxm_prepare_post_type( $post_type, $fields ) { 336 $_post_type = array( 337 'name' => $post_type->name, 338 'label' => $post_type->label, 339 'hierarchical' => (bool) $post_type->hierarchical, 340 'public' => (bool) $post_type->public, 341 'show_ui' => (bool) $post_type->show_ui, 342 '_builtin' => (bool) $post_type->_builtin, 343 'has_archive' => (bool) $post_type->has_archive, 344 'supports' => $this->wxm_get_all_post_type_supports( $post_type->name ), 345 ); 346 347 if ( in_array( 'labels', $fields ) ) { 348 $_post_type['labels'] = (array) $post_type->labels; 349 } 350 351 if ( in_array( 'cap', $fields ) ) { 352 $_post_type['cap'] = (array) $post_type->cap; 353 $_post_type['map_meta_cap'] = (bool) $post_type->map_meta_cap; 354 } 355 356 if ( in_array( 'menu', $fields ) ) { 357 $_post_type['menu_position'] = (int) $post_type->menu_position; 358 $_post_type['menu_icon'] = $post_type->menu_icon; 359 $_post_type['show_in_menu'] = (bool) $post_type->show_in_menu; 360 } 361 362 if ( in_array( 'taxonomies', $fields ) ) 363 $_post_type['taxonomies'] = get_object_taxonomies( $post_type->name, 'names' ); 364 365 return apply_filters( 'xmlrpc_prepare_post_type', $_post_type, $post_type ); 366 } 367 368 /** 369 * Prepares media item data for return in an XML-RPC object. 370 * 371 * @access protected 372 * 373 * @param object $media_item The unprepared media item data 374 * @param string $thumbnail_size The image size to use for the thumbnail URL 375 * @return array The prepared media item data 376 */ 377 protected function wxm_prepare_media_item( $media_item, $thumbnail_size='thumbnail' ) { 378 $_media_item = array( 379 'attachment_id' => strval( $media_item->ID ), 380 'date_created_gmt' => $this->_convert_date_gmt( $media_item->post_date_gmt, $media_item->post_date ), 381 'parent' => $media_item->post_parent, 382 'link' => wp_get_attachment_url( $media_item->ID ), 383 'title' => $media_item->post_title, 384 'caption' => $media_item->post_excerpt, 385 'description' => $media_item->post_content, 386 'metadata' => wp_get_attachment_metadata( $media_item->ID ), 387 ); 388 389 $thumbnail_src = image_downsize( $media_item->ID, $thumbnail_size ); 390 if ( $thumbnail_src ) 391 $_media_item['thumbnail'] = $thumbnail_src[0]; 392 else 393 $_media_item['thumbnail'] = $_media_item['link']; 394 395 return apply_filters( 'xmlrpc_prepare_media_item', $_media_item, $media_item, $thumbnail_size ); 268 396 } 269 397 … … 285 413 * - 'first_name' 286 414 * - 'last_name' 287 * - 'website' 415 * - 'url' 416 * - 'display_name' 417 * - 'nickname' 418 * - 'nicename' 419 * - 'bio' 288 420 * - boolean $send_mail optional. Defaults to false 289 421 * @return int user_id 290 422 */ 291 function wp_newUser( $args ) { 423 function wxm_wp_newUser( $args ) { 424 if ( ! $this->minimum_args( $args, 4 ) ) 425 return $this->error; 426 292 427 $this->escape( $args ); 293 428 … … 344 479 $user_data['user_url'] = $content_struct['url']; 345 480 481 if ( isset( $content_struct['display_name'] ) ) 482 $user_data['display_name'] = $content_struct['display_name']; 483 484 if ( isset( $content_struct['nickname'] ) ) 485 $user_data['nickname'] = $content_struct['nickname']; 486 487 if ( isset( $content_struct['nicename'] ) ) 488 $user_data['user_nicename'] = $content_struct['nicename']; 489 490 if ( isset( $content_struct['bio'] ) ) 491 $user_data['description'] = $content_struct['bio']; 492 346 493 $user_id = wp_insert_user( $user_data ); 347 494 … … 350 497 351 498 if ( ! $user_id ) 352 return new IXR_Error( 500, __( 'Sorry, the new user failed.' ) );499 return new IXR_Error( 500, __( 'Sorry, the new user creation failed.' ) ); 353 500 354 501 if ( $send_mail ) { … … 375 522 * - 'website' 376 523 * - 'role' 524 * - 'display_name' 377 525 * - 'nickname' 378 526 * - 'nicename' … … 383 531 * @return bool True, on success. 384 532 */ 385 function wp_editUser( $args ) { 533 function wxm_wp_editUser( $args ) { 534 if ( ! $this->minimum_args( $args, 5 ) ) 535 return $this->error; 536 386 537 $this->escape( $args ); 387 538 … … 443 594 $user_data['user_url'] = $content_struct['url']; 444 595 596 if ( isset( $content_struct['display_name'] ) ) 597 $user_data['display_name'] = $content_struct['display_name']; 598 445 599 if ( isset( $content_struct['nickname'] ) ) 446 600 $user_data['nickname'] = $content_struct['nickname']; … … 471 625 472 626 if ( ! $result ) 473 return new IXR_Error( 500, __( 'Sorry, the user cannot be updated. Something wrong happened.' ) );627 return new IXR_Error( 500, __( 'Sorry, the user cannot be updated.' ) ); 474 628 475 629 return true; … … 487 641 * @return True when user is deleted. 488 642 */ 489 function wp_deleteUser( $args ) { 643 function wxm_wp_deleteUser( $args ) { 644 if ( ! $this->minimum_args( $args, 4 ) ) 645 return $this->error; 646 490 647 $this->escape( $args ); 491 648 … … 557 714 * - 'user_contacts' 558 715 */ 559 function wp_getUser( $args ) { 716 function wxm_wp_getUser( $args ) { 717 if ( ! $this->minimum_args( $args, 4 ) ) 718 return $this->error; 719 560 720 $this->escape( $args ); 561 721 … … 608 768 * @return array users data 609 769 */ 610 function wp_getUsers( $args ) { 770 function wxm_wp_getUsers( $args ) { 771 if ( ! $this->minimum_args( $args, 3 ) ) 772 return $this->error; 773 611 774 $this->escape( $args ); 612 775 … … 665 828 * @return array (@see wp_getUser) 666 829 */ 667 function wp_getUserInfo( $args ) { 830 function wxm_wp_getUserInfo( $args ) { 831 if ( ! $this->minimum_args( $args, 3 ) ) 832 return $this->error; 833 668 834 $this->escape( $args ); 669 835 … … 710 876 * - ping_status - can be 'open' | 'closed' 711 877 * - sticky 712 * - featured_image - ID of a media item to use as thefeatured image878 * - post_thumbnail - ID of a media item to use as the post thumbnail/featured image 713 879 * - custom_fields - array, with each element containing 'key' and 'value' 714 880 * - terms - array, with taxonomy names as keys and arrays of term IDs as values … … 718 884 * @return string post_id 719 885 */ 720 function wp_newPost( $args ) { 886 function wxm_wp_newPost( $args ) { 887 if ( ! $this->minimum_args( $args, 4 ) ) 888 return $this->error; 889 721 890 $this->escape( $args ); 722 891 … … 739 908 * Helper method for filtering out elements from an array. 740 909 */ 741 function _is_greater_than_one( $count ){910 function wxm_is_greater_than_one( $count ) { 742 911 return $count > 1; 743 912 } … … 746 915 * Helper method for wp_newPost and wp_editPost, containing shared logic. 747 916 */ 748 function_insert_post( $user, $content_struct ) {917 protected function wxm_insert_post( $user, $content_struct ) { 749 918 $defaults = array( 'post_status' => 'draft', 'post_type' => 'post', 'post_author' => 0, 750 'post_password' => '', 'post_excerpt' => '', 'post_content' => '', 'post_title' => '' , 'sticky' => 0);919 'post_password' => '', 'post_excerpt' => '', 'post_content' => '', 'post_title' => '' ); 751 920 752 921 $post_data = wp_parse_args( $content_struct, $defaults ); 753 922 754 923 $post_type = get_post_type_object( $post_data['post_type'] ); 755 if ( ! ( (bool) $post_type ))924 if ( ! $post_type ) 756 925 return new IXR_Error( 403, __( 'Invalid post type' ) ); 757 926 758 $update = false; 759 if ( ! empty( $post_data[ 'ID' ] ) ) 760 $update = true; 927 $update = ! empty( $post_data['ID'] ); 761 928 762 929 if ( $update ) { 763 if ( ! current_user_can( $post_type->cap->edit_post, $post_data[ 'ID' ] ) ) 930 if ( ! get_post( $post_data['ID'] ) ) 931 return new IXR_Error( 401, __( 'Invalid post ID.' ) ); 932 if ( ! current_user_can( $post_type->cap->edit_post, $post_data['ID'] ) ) 764 933 return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); 934 if ( $post_data['post_type'] != get_post_type( $post_data['ID'] ) ) 935 return new IXR_Error( 401, __( 'The post type may not be changed.' ) ); 765 936 } else { 766 937 if ( ! current_user_can( $post_type->cap->edit_posts ) ) … … 774 945 case 'private': 775 946 if ( ! current_user_can( $post_type->cap->publish_posts ) ) 776 return new IXR_Error( 401, __( 'Sorry, you are not allowed to create private posts in this post type' ) );947 return new IXR_Error( 401, __( 'Sorry, you are not allowed to create private posts in this post type' ) ); 777 948 break; 778 949 case 'publish': 779 950 case 'future': 780 951 if ( ! current_user_can( $post_type->cap->publish_posts ) ) 781 return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish posts in this post type' ) );952 return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish posts in this post type' ) ); 782 953 break; 783 954 default: 784 955 $post_data['post_status'] = 'draft'; 785 break;956 break; 786 957 } 787 958 … … 802 973 } 803 974 804 if ( isset( $post_data['comment_status'] ) ) { 805 if ( ! post_type_supports( $post_data['post_type'], 'comments' ) || ( $post_data['comment_status'] != 'open' && $post_data['comment_status'] != 'closed' ) ) { 806 unset( $post_data['comment_status'] ); 807 } 808 } 809 810 if ( isset( $post_data['ping_status'] ) ) { 811 if ( ! post_type_supports( $post_data['post_type'], 'trackbacks' ) || ( $post_data['ping_status'] != 'open' && $post_data['ping_status'] != 'closed' ) ) { 812 unset( $post_data['ping_status'] ); 813 } 814 } 975 if ( isset( $post_data['comment_status'] ) && $post_data['comment_status'] != 'open' && $post_data['comment_status'] != 'closed' ) 976 unset( $post_data['comment_status'] ); 977 978 if ( isset( $post_data['ping_status'] ) && $post_data['ping_status'] != 'open' && $post_data['ping_status'] != 'closed' ) 979 unset( $post_data['ping_status'] ); 815 980 816 981 // Do some timestamp voodoo 817 982 if ( ! empty( $post_data['post_date_gmt'] ) ) { 818 983 // We know this is supposed to be GMT, so we're going to slap that Z on there by force 819 $dateCreated = str_replace( 'Z', '', $post_data['post_date_gmt']->getIso()) . 'Z';984 $dateCreated = rtrim( $post_data['post_date_gmt']->getIso(), 'Z' ) . 'Z'; 820 985 } elseif ( ! empty( $post_data['post_date'] ) ) { 821 986 $dateCreated = $post_data['post_date']->getIso(); … … 827 992 } 828 993 829 if ( ! isset( $post_data['ID'] ) ) {994 if ( ! isset( $post_data['ID'] ) ) 830 995 $post_data['ID'] = get_default_post_to_edit( $post_data['post_type'], true )->ID; 831 }832 996 $post_ID = $post_data['ID']; 833 997 834 $sticky = $post_data['sticky'] ? true : false; 835 836 if ( $post_data['post_type'] == 'post' && $sticky == true ) { 837 if ( ! current_user_can( $post_type->cap->edit_others_posts ) ) 838 return new IXR_Error( 401, __( 'Sorry, you are not allowed to stick this post.' ) ); 839 840 if ( $post_data['post_status'] != 'publish' ) 841 return new IXR_Error( 401, __( 'Only published posts can be made sticky.' ) ); 842 843 stick_post( $post_ID ); 844 } 845 846 if ( isset ( $post_data['featured_image'] ) ) { 998 if ( $post_data['post_type'] == 'post' ) { 999 // Private and password-protected posts cannot be stickied. 1000 if ( $post_data['post_status'] == 'private' || ! empty( $post_data['post_password'] ) ) { 1001 // Error if the client tried to stick the post, otherwise, silently unstick. 1002 if ( ! empty( $post_data['sticky'] ) ) 1003 return new IXR_Error( 401, __( 'Sorry, you cannot stick a private post.' ) ); 1004 if ( $update ) 1005 unstick_post( $post_ID ); 1006 } elseif ( isset( $post_data['sticky'] ) ) { 1007 if ( ! current_user_can( $post_type->cap->edit_others_posts ) ) 1008 return new IXR_Error( 401, __( 'Sorry, you are not allowed to stick this post.' ) ); 1009 if ( $post_data['sticky'] ) 1010 stick_post( $post_ID ); 1011 else 1012 unstick_post( $post_ID ); 1013 } 1014 } 1015 1016 if ( isset( $post_data['post_thumbnail'] ) ) { 847 1017 // empty value deletes, non-empty value adds/updates 848 if ( empty( $post_data['featured_image'] ) ) { 849 delete_post_meta( $post_ID, '_thumbnail_id' ); 850 } 851 else { 852 $image = get_post( intval( $post_data['featured_image'] ), ARRAY_A ); 853 if ( empty($image['ID'] ) ) 854 return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); 855 update_post_meta( $post_ID, '_thumbnail_id', $image['ID'] ); 856 } 857 unset( $content_struct['featured_image'] ); 858 } 859 860 if ( isset ( $post_data['custom_fields'] ) && post_type_supports( $post_data['post_type'], 'custom-fields' ) ) { 1018 if ( ! $post_data['post_thumbnail'] ) 1019 delete_post_thumbnail( $post_ID ); 1020 elseif ( ! set_post_thumbnail( $post_ID, $post_data['post_thumbnail'] ) ) 1021 return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); 1022 unset( $content_struct['post_thumbnail'] ); 1023 } 1024 1025 if ( isset( $post_data['custom_fields'] ) ) 861 1026 $this->set_custom_fields( $post_ID, $post_data['custom_fields'] ); 862 }863 1027 864 1028 if ( isset( $post_data['terms'] ) || isset( $post_data['terms_names'] ) ) { … … 912 1076 913 1077 // filter out non-ambiguous term names 914 $ambiguous_tax_term_counts = array_filter( $tax_term_names_count, array( $this, '_is_greater_than_one' ) );1078 $ambiguous_tax_term_counts = array_filter( $tax_term_names_count, array( $this, '_is_greater_than_one') ); 915 1079 916 1080 $ambiguous_terms = array_keys( $ambiguous_tax_term_counts ); … … 943 1107 944 1108 $post_data['tax_input'] = $terms; 945 unset( $post_data['terms'] ); 946 unset( $post_data['terms_names'] ); 1109 unset( $post_data['terms'], $post_data['terms_names'] ); 947 1110 } else { 948 1111 // do not allow direct submission of 'tax_input', clients must use 'terms' and/or 'terms_names' 949 unset( $post_data['tax_input'] );1112 unset( $post_data['tax_input'], $post_data['post_category'], $post_data['tags_input'] ); 950 1113 } 951 1114 … … 992 1155 * @return true on success 993 1156 */ 994 function wp_editPost( $args ) { 1157 function wxm_wp_editPost( $args ) { 1158 if ( ! $this->minimum_args( $args, 5 ) ) 1159 return $this->error; 1160 995 1161 $this->escape( $args ); 996 1162 997 $blog_id = (int) $args[0]; // we will support this in the near future1163 $blog_id = (int) $args[0]; 998 1164 $username = $args[1]; 999 1165 $password = $args[2]; … … 1006 1172 do_action( 'xmlrpc_call', 'wp.editPost' ); 1007 1173 1008 // User Capabilities are checked in _insert_post.1009 1010 1174 $post = get_post( $post_id, ARRAY_A ); 1011 1175 1012 if ( empty( $post[ "ID"] ) )1176 if ( empty( $post['ID'] ) ) 1013 1177 return new IXR_Error( 404, __( 'Invalid post ID.' ) ); 1014 1178 … … 1044 1208 * @return true on success 1045 1209 */ 1046 function wp_deletePost( $args ) { 1210 function wxm_wp_deletePost( $args ) { 1211 if ( ! $this->minimum_args( $args, 4 ) ) 1212 return $this->error; 1213 1047 1214 $this->escape( $args ); 1048 1215 … … 1115 1282 * - 'enclosure' 1116 1283 */ 1117 function wp_getPost( $args ) { 1284 function wxm_wp_getPost( $args ) { 1285 if ( ! $this->minimum_args( $args, 4 ) ) 1286 return $this->error; 1287 1118 1288 $this->escape( $args ); 1119 1289 … … 1135 1305 $post = wp_get_single_post( $post_id, ARRAY_A ); 1136 1306 1137 if ( empty( $post[ "ID"] ) )1307 if ( empty( $post['ID'] ) ) 1138 1308 return new IXR_Error( 404, __( 'Invalid post ID.' ) ); 1139 1309 … … 1165 1335 * - array $filter optional 1166 1336 * - array $fields optional 1167 * @return array cntains a collection of posts. 1168 */ 1169 function wp_getPosts( $args ) { 1337 * @return array contains a collection of posts. 1338 */ 1339 function wxm_wp_getPosts( $args ) { 1340 if ( ! $this->minimum_args( $args, 3 ) ) 1341 return $this->error; 1342 1170 1343 $this->escape( $args ); 1171 1344 … … 1217 1390 1218 1391 if ( ! $posts_list ) 1219 return array( );1392 return array(); 1220 1393 1221 1394 // holds all the posts data … … 1234 1407 1235 1408 /** 1236 * Retrieve post terms. 1237 * 1238 * The optional $group_by_taxonomy parameter specifies whether 1239 * the returned array should have terms grouped by taxonomy or 1240 * a flat list. 1241 * 1242 * @uses wp_get_object_terms() 1243 * @param array $args Method parameters. Contains: 1244 * - int $blog_id 1245 * - string $username 1246 * - string $password 1247 * - int $post_id 1248 * - bool $group_by_taxonomy optional 1249 * @return array term data 1250 */ 1251 function wp_getPostTerms( $args ) { 1252 $this->escape( $args ); 1253 1254 $blog_id = (int) $args[0]; 1255 $username = $args[1]; 1256 $password = $args[2]; 1257 $post_id = (int) $args[3]; 1258 $group_by_taxonomy = isset( $args[4] ) ? $args[4] : true; 1259 1260 if ( ! $user = $this->login( $username, $password ) ) 1261 return $this->error; 1262 1263 do_action( 'xmlrpc_call', 'wp.getPostTerms' ); 1264 1265 $post = wp_get_single_post( $post_id, ARRAY_A ); 1266 if ( empty( $post['ID'] ) ) 1267 return new IXR_Error( 404, __( 'Invalid post ID.' ) ); 1268 1269 $post_type = get_post_type_object( $post['post_type'] ); 1270 1271 if ( ! current_user_can( $post_type->cap->edit_post , $post_id ) ) 1272 return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); 1273 1274 $taxonomies = get_taxonomies( '' ); 1275 1276 $terms = wp_get_object_terms( $post_id , $taxonomies ); 1277 1278 if ( is_wp_error( $terms ) ) 1279 return new IXR_Error( 500 , $terms->get_error_message() ); 1280 1281 $struct = array(); 1282 1283 foreach ( $terms as $term ) { 1284 if ( $group_by_taxonomy ) { 1285 $taxonomy = $term->taxonomy; 1286 1287 if ( ! array_key_exists( $taxonomy, $struct ) ) 1288 $struct[$taxonomy] = array(); 1289 1290 $struct[$taxonomy][] = $this->prepare_term( $term ); 1291 } 1292 else { 1293 $struct[] = $this->prepare_term( $term ); 1294 } 1295 } 1296 1297 return $struct; 1298 } 1299 1300 /** 1301 * Set post terms. 1302 * 1303 * @uses wp_set_object_terms() 1304 * @param array $args Method parameters. Contains: 1305 * - int $blog_id 1306 * - string $username 1307 * - string $password 1308 * - int $post_id 1309 * - array $content_struct contains term_ids with taxonomy as keys 1310 * - bool $append 1311 * @return boolean true 1312 */ 1313 function wp_setPostTerms( $args ) { 1314 $this->escape( $args ); 1315 1316 $blog_id = (int) $args[0]; 1317 $username = $args[1]; 1318 $password = $args[2]; 1319 $post_ID = (int) $args[3]; 1320 $content_struct = $args[4]; 1321 $append = $args[5] ? true : false; 1322 1323 if ( ! $user = $this->login( $username, $password ) ) 1324 return $this->error; 1325 1326 do_action( 'xmlrpc_call', 'wp.setPostTerms' ); 1327 1328 $post = wp_get_single_post( $post_ID, ARRAY_A ); 1329 if ( empty( $post['ID'] ) ) 1330 return new IXR_Error( 404, __( 'Invalid post ID.' ) ); 1331 1332 $post_type = get_post_type_object( $post['post_type'] ); 1333 1334 if ( ! current_user_can( $post_type->cap->edit_post , $post_ID ) ) 1335 return new IXR_Error( 401, __( 'Sorry, You are not allowed to edit this post.' ) ); 1336 1337 $post_type_taxonomies = get_object_taxonomies( $post['post_type'] ); 1338 1339 $taxonomies = array_keys( $content_struct ); 1340 1341 // validating term ids 1342 foreach ( $taxonomies as $taxonomy ) { 1343 if ( ! in_array( $taxonomy , $post_type_taxonomies ) ) 1344 return new IXR_Error( 401, __( 'Sorry, one of the given taxonomy is not supported by the post type.' ) ); 1345 1346 $term_ids = $content_struct[$taxonomy]; 1347 foreach ( $term_ids as $term_id ) { 1348 1349 $term = get_term( $term_id, $taxonomy ); 1350 1351 if ( is_wp_error( $term ) ) 1352 return new IXR_Error( 500, $term->get_error_message() ); 1353 1354 if ( ! $term ) 1355 return new IXR_Error( 403, __( 'Invalid term ID' ) ); 1356 } 1357 } 1358 1359 foreach ( $taxonomies as $taxonomy ) { 1360 $term_ids = $content_struct[$taxonomy]; 1361 $term_ids = array_map( 'intval', $term_ids ); 1362 $term_ids = array_unique( $term_ids ); 1363 wp_set_object_terms( $post_ID , $term_ids, $taxonomy , $append ); 1364 } 1365 1366 return true; 1367 } 1368 1369 /** 1370 * Retrieve a post type. 1409 * Retrieves a post type 1371 1410 * 1372 1411 * @uses get_post_type_object() … … 1376 1415 * - string $password 1377 1416 * - string $post_type_name 1417 * - array $fields 1378 1418 * @return array contains: 1379 1419 * - 'labels' … … 1385 1425 * - 'menu_position' 1386 1426 * - 'taxonomies' 1387 */ 1388 function wp_getPostType( $args ) { 1427 * - 'supports' 1428 */ 1429 function wxm_wp_getPostType( $args ) { 1430 if ( ! $this->minimum_args( $args, 4 ) ) 1431 return $this->error; 1432 1389 1433 $this->escape( $args ); 1390 1434 … … 1394 1438 $post_type_name = $args[3]; 1395 1439 1396 if ( ! $user = $this->login( $username, $password ) ) 1440 if ( isset( $args[4] ) ) 1441 $fields = $args[4]; 1442 else 1443 $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostType' ); 1444 1445 if ( !$user = $this->login( $username, $password ) ) 1397 1446 return $this->error; 1398 1447 1399 1448 do_action( 'xmlrpc_call', 'wp.getPostType' ); 1400 1449 1401 if ( ! post_type_exists( $post_type_name ) )1450 if( ! post_type_exists( $post_type_name ) ) 1402 1451 return new IXR_Error( 403, __( 'Invalid post type.' ) ); 1403 1452 1404 1453 $post_type = get_post_type_object( $post_type_name ); 1405 1454 1406 if ( ! current_user_can( $post_type->cap->edit_posts ) )1455 if( ! current_user_can( $post_type->cap->edit_posts ) ) 1407 1456 return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post type.' ) ); 1408 1457 1409 return $this->_prepare_post_type( $post_type );1410 } 1411 1412 /** 1413 * Retrieve all post types.1458 return $this->_prepare_post_type( $post_type, $fields ); 1459 } 1460 1461 /** 1462 * Retrieves a post types 1414 1463 * 1415 1464 * @uses get_post_types() … … 1418 1467 * - string $username 1419 1468 * - string $password 1469 * - array $filter 1470 * - array $fields 1420 1471 * @return array 1421 1472 */ 1422 function wp_getPostTypes( $args ) { 1473 function wxm_wp_getPostTypes( $args ) { 1474 if ( ! $this->minimum_args( $args, 3 ) ) 1475 return $this->error; 1476 1423 1477 $this->escape( $args ); 1424 1478 … … 1426 1480 $username = $args[1]; 1427 1481 $password = $args[2]; 1482 $filter = isset( $args[3] ) ? $args[3] : array( 'public' => true ); 1483 1484 if ( isset( $args[4] ) ) 1485 $fields = $args[4]; 1486 else 1487 $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostTypes' ); 1428 1488 1429 1489 if ( ! $user = $this->login( $username, $password ) ) … … 1432 1492 do_action( 'xmlrpc_call', 'wp.getPostTypes' ); 1433 1493 1434 $post_types = get_post_types( '', 'objects' );1494 $post_types = get_post_types( $filter, 'objects' ); 1435 1495 1436 1496 $struct = array(); 1437 1497 1438 foreach ( $post_types as $post_type ) {1439 if ( ! current_user_can( $post_type->cap->edit_posts ) )1498 foreach( $post_types as $post_type ) { 1499 if( ! current_user_can( $post_type->cap->edit_posts ) ) 1440 1500 continue; 1441 1501 1442 $struct[ ] = $this->_prepare_post_type( $post_type);1502 $struct[$post_type->name] = $this->_prepare_post_type( $post_type, $fields ); 1443 1503 } 1444 1504 … … 1464 1524 * @return string term_id 1465 1525 */ 1466 function wp_newTerm( $args ) { 1526 function wxm_wp_newTerm( $args ) { 1527 if ( ! $this->minimum_args( $args, 4 ) ) 1528 return $this->error; 1529 1467 1530 $this->escape( $args ); 1468 1531 … … 1546 1609 * @return bool True, on success. 1547 1610 */ 1548 function wp_editTerm( $args ) { 1611 function wxm_wp_editTerm( $args ) { 1612 if ( ! $this->minimum_args( $args, 5 ) ) 1613 return $this->error; 1614 1549 1615 $this->escape( $args ); 1550 1616 … … 1633 1699 * @return boolean|IXR_Error If it suceeded true else a reason why not 1634 1700 */ 1635 function wp_deleteTerm( $args ) { 1701 function wxm_wp_deleteTerm( $args ) { 1702 if ( ! $this->minimum_args( $args, 5 ) ) 1703 return $this->error; 1704 1636 1705 $this->escape( $args ); 1637 1706 … … 1639 1708 $username = $args[1]; 1640 1709 $password = $args[2]; 1641 $taxonomy _name= $args[3];1710 $taxonomy = $args[3]; 1642 1711 $term_id = (int) $args[4]; 1643 1712 … … 1647 1716 do_action( 'xmlrpc_call', 'wp.deleteTerm' ); 1648 1717 1649 if ( ! taxonomy_exists( $taxonomy _name) )1718 if ( ! taxonomy_exists( $taxonomy ) ) 1650 1719 return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); 1651 1720 1652 $taxonomy = get_taxonomy( $taxonomy _name);1721 $taxonomy = get_taxonomy( $taxonomy ); 1653 1722 1654 1723 if ( ! current_user_can( $taxonomy->cap->delete_terms ) ) 1655 1724 return new IXR_Error( 401, __( 'You are not allowed to delete terms in this taxonomy.' ) ); 1656 1725 1657 $term = get_term( $term_id, $taxonomy _name );1726 $term = get_term( $term_id, $taxonomy->name ); 1658 1727 1659 1728 if ( is_wp_error( $term ) ) … … 1663 1732 return new IXR_Error( 404, __( 'Invalid term ID.' ) ); 1664 1733 1665 $result = wp_delete_term( $term_id, $taxonomy _name );1734 $result = wp_delete_term( $term_id, $taxonomy->name ); 1666 1735 1667 1736 if ( is_wp_error( $result ) ) … … 1682 1751 * - string $username 1683 1752 * - string $password 1684 * - string $taxonomy _name1753 * - string $taxonomy 1685 1754 * - string $term_id 1686 1755 * @return array contains: … … 1695 1764 * - 'count' 1696 1765 */ 1697 function wp_getTerm( $args ) { 1766 function wxm_wp_getTerm( $args ) { 1767 if ( ! $this->minimum_args( $args, 5 ) ) 1768 return $this->error; 1769 1698 1770 $this->escape( $args ); 1699 1771 … … 1701 1773 $username = $args[1]; 1702 1774 $password = $args[2]; 1703 $taxonomy _name= $args[3];1775 $taxonomy = $args[3]; 1704 1776 $term_id = (int) $args[4]; 1705 1777 … … 1709 1781 do_action( 'xmlrpc_call', 'wp.getTerm' ); 1710 1782 1711 if ( ! taxonomy_exists( $taxonomy _name) )1783 if ( ! taxonomy_exists( $taxonomy ) ) 1712 1784 return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); 1713 1785 1714 $taxonomy = get_taxonomy( $taxonomy _name);1786 $taxonomy = get_taxonomy( $taxonomy ); 1715 1787 1716 1788 if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) 1717 1789 return new IXR_Error( 401, __( 'You are not allowed to assign terms in this taxonomy.' ) ); 1718 1790 1719 $term = get_term( $term_id , $taxonomy _name, ARRAY_A );1791 $term = get_term( $term_id , $taxonomy->name, ARRAY_A ); 1720 1792 1721 1793 if ( is_wp_error( $term ) ) … … 1739 1811 * - string $username 1740 1812 * - string $password 1741 * - string $taxonomy _name1813 * - string $taxonomy 1742 1814 * - array $filter optional 1743 1815 * @return array terms 1744 1816 */ 1745 function wp_getTerms( $args ) { 1817 function wxm_wp_getTerms( $args ) { 1818 if ( ! $this->minimum_args( $args, 4 ) ) 1819 return $this->error; 1820 1746 1821 $this->escape( $args ); 1747 1822 … … 1749 1824 $username = $args[1]; 1750 1825 $password = $args[2]; 1751 $taxonomy _name= $args[3];1826 $taxonomy = $args[3]; 1752 1827 $filter = isset( $args[4] ) ? $args[4] : array(); 1753 1828 … … 1757 1832 do_action( 'xmlrpc_call', 'wp.getTerms' ); 1758 1833 1759 if ( ! taxonomy_exists( $taxonomy _name) )1834 if ( ! taxonomy_exists( $taxonomy ) ) 1760 1835 return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); 1761 1836 1762 $taxonomy = get_taxonomy( $taxonomy _name);1837 $taxonomy = get_taxonomy( $taxonomy ); 1763 1838 1764 1839 if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) … … 1788 1863 $query['search'] = $filter['search']; 1789 1864 1790 $terms = get_terms( $taxonomy _name, $query );1865 $terms = get_terms( $taxonomy->name, $query ); 1791 1866 1792 1867 if ( is_wp_error( $terms ) ) … … 1810 1885 * - string $username 1811 1886 * - string $password 1812 * - string $taxonomy _name1887 * - string $taxonomy 1813 1888 * @return array (@see get_taxonomy()) 1814 1889 */ 1815 function wp_getTaxonomy( $args ) { 1890 function wxm_wp_getTaxonomy( $args ) { 1891 if ( ! $this->minimum_args( $args, 4 ) ) 1892 return $this->error; 1893 1816 1894 $this->escape( $args ); 1817 1895 … … 1819 1897 $username = $args[1]; 1820 1898 $password = $args[2]; 1821 $taxonomy_name = $args[3]; 1899 $taxonomy = $args[3]; 1900 1901 if ( isset( $args[4] ) ) 1902 $fields = $args[4]; 1903 else 1904 $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomy' ); 1822 1905 1823 1906 if ( ! $user = $this->login( $username, $password ) ) … … 1826 1909 do_action( 'xmlrpc_call', 'wp.getTaxonomy' ); 1827 1910 1828 if ( ! taxonomy_exists( $taxonomy _name) )1911 if ( ! taxonomy_exists( $taxonomy ) ) 1829 1912 return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); 1830 1913 1831 $taxonomy = get_taxonomy( $taxonomy _name);1914 $taxonomy = get_taxonomy( $taxonomy ); 1832 1915 1833 1916 if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) 1834 1917 return new IXR_Error( 401, __( 'You are not allowed to assign terms in this taxonomy.' ) ); 1835 1918 1836 return $this->_prepare_taxonomy( $taxonomy );1919 return $this->_prepare_taxonomy( $taxonomy, $fields ); 1837 1920 } 1838 1921 … … 1847 1930 * @return array taxonomies 1848 1931 */ 1849 function wp_getTaxonomies( $args ) { 1932 function wxm_wp_getTaxonomies( $args ) { 1933 if ( ! $this->minimum_args( $args, 3 ) ) 1934 return $this->error; 1935 1850 1936 $this->escape( $args ); 1851 1937 … … 1853 1939 $username = $args[1]; 1854 1940 $password = $args[2]; 1941 $filter = isset( $args[3] ) ? $args[3] : array( 'public' => true ); 1942 1943 if ( isset( $args[4] ) ) 1944 $fields = $args[4]; 1945 else 1946 $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomies' ); 1855 1947 1856 1948 if ( ! $user = $this->login( $username, $password ) ) … … 1859 1951 do_action( 'xmlrpc_call', 'wp.getTaxonomies' ); 1860 1952 1861 $taxonomies = get_taxonomies( '', 'objects' );1953 $taxonomies = get_taxonomies( $filter, 'objects' ); 1862 1954 1863 1955 // holds all the taxonomy data … … 1869 1961 continue; 1870 1962 1871 $struct[] = $this->_prepare_taxonomy( $taxonomy );1963 $struct[] = $this->_prepare_taxonomy( $taxonomy, $fields ); 1872 1964 } 1873 1965 1874 1966 return $struct; 1875 1967 } 1968 1969 function wxm_handle_upload( $struct ) { 1970 $attachment_id = url_to_postid( $struct['url'] ); 1971 $struct['id'] = $attachment_id; 1972 return $struct; 1973 } 1974 1975 function wxm_blog_options( $options ) { 1976 $wp34_options = array( 1977 // Read only options 1978 'image_default_link_type' => array( 1979 'desc' => __( 'Image default link type' ), 1980 'readonly' => true, 1981 'option' => 'image_default_link_type' 1982 ), 1983 'image_default_size' => array( 1984 'desc' => __( 'Image default size' ), 1985 'readonly' => true, 1986 'option' => 'image_default_size' 1987 ), 1988 'image_default_align' => array( 1989 'desc' => __( 'Image default align' ), 1990 'readonly' => true, 1991 'option' => 'image_default_align' 1992 ), 1993 'template' => array( 1994 'desc' => __( 'Template' ), 1995 'readonly' => true, 1996 'option' => 'template' 1997 ), 1998 'stylesheet' => array( 1999 'desc' => __( 'Stylesheet' ), 2000 'readonly' => true, 2001 'option' => 'stylesheet' 2002 ), 2003 'post_thumbnail' => array( 2004 'desc' => __('Post Thumbnail'), 2005 'readonly' => true, 2006 'value' => current_theme_supports( 'post-thumbnails' ) 2007 ), 2008 2009 // Updatable options 2010 'default_comment_status' => array( 2011 'desc' => __( 'Allow people to post comments on new articles' ), 2012 'readonly' => false, 2013 'option' => 'default_comment_status' 2014 ), 2015 'default_ping_status' => array( 2016 'desc' => __( 'Allow link notifications from other blogs (pingbacks and trackbacks)' ), 2017 'readonly' => false, 2018 'option' => 'default_ping_status' 2019 ) 2020 ); 2021 2022 return array_merge( $wp34_options, $options ); 2023 } 1876 2024 } 1877 2025 -
xml-rpc-modernization/trunk/readme.txt
r510787 r543520 5 5 Tested up to: 3.4 6 6 Stable tag: trunk 7 License: GPLv2 or later 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html 7 9 8 10 This plugin updates the WordPress XML-RPC API to leverage the latest features of WordPress … … 11 13 == Description == 12 14 13 This plugin updates the WordPress XML-RPC API to leverage the latest features of WordPress14 and move beyond the historical Blogger/metaWeblog/MT APIs.15 This plugin brings XML-RPC API enhancements from the WordPress 3.4 release to previous versions 16 of WordPress (3.3 and earlier). It also adds new user management methods. 15 17 16 18 It is derived from Prasath Nadarajah's GSoC '11 project to expand WordPress' web services, 17 19 although the exposed API methods are not compatible (different parameter names/types/orders). 18 20 19 WARNING: This plugin is still experimental, use in production at your own risk. 21 = Methods = 20 22 21 = Methods = 23 New Methods: 22 24 23 25 * wp.newUser - create a new user … … 27 29 * wp.getUsers - retrieve a list of users 28 30 * wp.getUserInfo - get information about the requesting user 31 32 3.4 Methods for pre-3.4 sites: 33 29 34 * wp.newPost - create a new post (of any post type) 30 35 * wp.editPost - edit a post (of any post type) … … 34 39 * wp.getPostType - get information about a specific post type 35 40 * wp.getPostTypes - get a list of registered post types 36 * wp.getPostTerms - get terms associated with a post37 * wp.setPostTerms - set terms associated with a post38 41 * wp.getTaxonomy - get information about a specific taxonomy 39 42 * wp.getTaxonomies - get a list of registered taxonomies … … 45 48 46 49 == Changelog == 50 51 = 0.8 = 52 * Alignment with WordPress core progress (RC1). 53 * Removed wp.getPostTerms and wp.setPostTerms. 54 * Added 'id' to wp.uploadFile return value. 55 * Added new options for wp.getOptions and wp.setOptions to match 3.4 core. 56 * Added minimum argument count guards to users methods. 57 * Added additional fields to wp.newUser and wp.editUser. 47 58 48 59 = 0.7.5 = -
xml-rpc-modernization/trunk/wp-xmlrpc-modernization.php
r510787 r543520 4 4 * Plugin Name: wp-xmlrpc-modernization 5 5 * Description: This plugin extends the basic XML-RPC API exposed by WordPress. Derived from GSoC '11 project. 6 * Version: 0. 7.56 * Version: 0.8 7 7 * Author: Max Cutler 8 8 * Author URI: http://www.maxcutler.com
Note: See TracChangeset
for help on using the changeset viewer.