Changes from trunk/wp-includes/class-wp-xmlrpc-server.php at r18254 to branches/3.1/wp-includes/class-wp-xmlrpc-server.php at r18014
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.1/wp-includes/class-wp-xmlrpc-server.php
r18254 r18014 25 25 * Register all of the XMLRPC methods that XMLRPC server understands. 26 26 * 27 * Sets up server and method property. Passes XMLRPC27 * PHP4 constructor and sets up server and method property. Passes XMLRPC 28 28 * methods through the 'xmlrpc_methods' filter to allow plugins to extend 29 29 * or replace XMLRPC methods. … … 33 33 * @return wp_xmlrpc_server 34 34 */ 35 function __construct() {35 function wp_xmlrpc_server() { 36 36 $this->methods = array( 37 37 // WordPress API … … 383 383 * @since 2.6.0 384 384 * 385 * @param array $args Method parameters. Contains: 386 * - username 387 * - password 388 * @return array. Contains: 389 * - 'isAdmin' 390 * - 'url' 391 * - 'blogid' 392 * - 'blogName' 393 * - 'xmlrpc' - url of xmlrpc endpoint 385 * @param array $args Method parameters. 386 * @return array 394 387 */ 395 388 function wp_getUsersBlogs( $args ) { … … 443 436 * @since 2.2.0 444 437 * 445 * @param array $args Method parameters. Contains: 446 * - blog_id 447 * - page_id 448 * - username 449 * - password 438 * @param array $args Method parameters. 450 439 * @return array 451 440 */ … … 471 460 472 461 // If we found the page then format the data. 473 if ( $page->ID && ($page->post_type == 'page') ) {462 if ( $page->ID && ($page->post_type == "page") ) { 474 463 // Get all of the page content and link. 475 464 $full_page = get_extended($page->post_content); … … 488 477 489 478 // Format page date. 490 $page_date = mysql2date( 'Ymd\TH:i:s', $page->post_date, false);491 $page_date_gmt = mysql2date( 'Ymd\TH:i:s', $page->post_date_gmt, false);479 $page_date = mysql2date("Ymd\TH:i:s", $page->post_date, false); 480 $page_date_gmt = mysql2date("Ymd\TH:i:s", $page->post_date_gmt, false); 492 481 493 482 // For drafts use the GMT version of the date … … 509 498 510 499 $page_struct = array( 511 'dateCreated'=> new IXR_Date($page_date),512 'userid'=> $page->post_author,513 'page_id'=> $page->ID,514 'page_status'=> $page->post_status,515 'description' => $full_page['main'],516 'title'=> $page->post_title,517 'link'=> $link,518 'permaLink'=> $link,519 'categories'=> $categories,520 'excerpt'=> $page->post_excerpt,521 'text_more' => $full_page['extended'],522 'mt_allow_comments'=> $allow_comments,523 'mt_allow_pings'=> $allow_pings,524 'wp_slug'=> $page->post_name,525 'wp_password'=> $page->post_password,526 'wp_author'=> $author->display_name,527 'wp_page_parent_id'=> $page->post_parent,528 'wp_page_parent_title'=> $parent_title,529 'wp_page_order'=> $page->menu_order,530 'wp_author_id'=> $author->ID,531 'wp_author_display_name'=> $author->display_name,532 'date_created_gmt'=> new IXR_Date($page_date_gmt),533 'custom_fields'=> $this->get_custom_fields($page_id),534 'wp_page_template'=> $page_template500 "dateCreated" => new IXR_Date($page_date), 501 "userid" => $page->post_author, 502 "page_id" => $page->ID, 503 "page_status" => $page->post_status, 504 "description" => $full_page["main"], 505 "title" => $page->post_title, 506 "link" => $link, 507 "permaLink" => $link, 508 "categories" => $categories, 509 "excerpt" => $page->post_excerpt, 510 "text_more" => $full_page["extended"], 511 "mt_allow_comments" => $allow_comments, 512 "mt_allow_pings" => $allow_pings, 513 "wp_slug" => $page->post_name, 514 "wp_password" => $page->post_password, 515 "wp_author" => $author->display_name, 516 "wp_page_parent_id" => $page->post_parent, 517 "wp_page_parent_title" => $parent_title, 518 "wp_page_order" => $page->menu_order, 519 "wp_author_id" => $author->ID, 520 "wp_author_display_name" => $author->display_name, 521 "date_created_gmt" => new IXR_Date($page_date_gmt), 522 "custom_fields" => $this->get_custom_fields($page_id), 523 "wp_page_template" => $page_template 535 524 ); 536 525 … … 539 528 // If the page doesn't exist indicate that. 540 529 else { 541 return(new IXR_Error(404, __( 'Sorry, no such page.')));530 return(new IXR_Error(404, __("Sorry, no such page."))); 542 531 } 543 532 } … … 548 537 * @since 2.2.0 549 538 * 550 * @param array $args Method parameters. Contains: 551 * - blog_id 552 * - username 553 * - password 554 * - num_pages 539 * @param array $args Method parameters. 555 540 * @return array 556 541 */ … … 598 583 * @since 2.2.0 599 584 * 600 * @param array $args Method parameters. See {@link wp_xmlrpc_server::mw_newPost()}585 * @param array $args Method parameters. 601 586 * @return unknown 602 587 */ … … 614 599 615 600 // Make sure the user is allowed to add new pages. 616 if ( !current_user_can( 'publish_pages') )617 return(new IXR_Error(401, __( 'Sorry, you cannot add new pages.')));601 if ( !current_user_can("publish_pages") ) 602 return(new IXR_Error(401, __("Sorry, you cannot add new pages."))); 618 603 619 604 // Mark this as content for a page. 620 $args[3]["post_type"] = 'page';605 $args[3]["post_type"] = "page"; 621 606 622 607 // Let mw_newPost do all of the heavy lifting. … … 648 633 // make sure it is a page and not a post. 649 634 $actual_page = wp_get_single_post($page_id, ARRAY_A); 650 if ( !$actual_page || ($actual_page[ 'post_type'] != 'page') )651 return(new IXR_Error(404, __( 'Sorry, no such page.')));635 if ( !$actual_page || ($actual_page["post_type"] != "page") ) 636 return(new IXR_Error(404, __("Sorry, no such page."))); 652 637 653 638 // Make sure the user can delete pages. 654 if ( !current_user_can( 'delete_page', $page_id) )655 return(new IXR_Error(401, __( 'Sorry, you do not have the right to delete this page.')));639 if ( !current_user_can("delete_page", $page_id) ) 640 return(new IXR_Error(401, __("Sorry, you do not have the right to delete this page."))); 656 641 657 642 // Attempt to delete the page. 658 643 $result = wp_delete_post($page_id); 659 644 if ( !$result ) 660 return(new IXR_Error(500, __( 'Failed to delete the page.')));645 return(new IXR_Error(500, __("Failed to delete the page."))); 661 646 662 647 return(true); … … 687 672 // Get the page data and make sure it is a page. 688 673 $actual_page = wp_get_single_post($page_id, ARRAY_A); 689 if ( !$actual_page || ($actual_page[ 'post_type'] != 'page') )690 return(new IXR_Error(404, __( 'Sorry, no such page.')));674 if ( !$actual_page || ($actual_page["post_type"] != "page") ) 675 return(new IXR_Error(404, __("Sorry, no such page."))); 691 676 692 677 // Make sure the user is allowed to edit pages. 693 if ( !current_user_can( 'edit_page', $page_id) )694 return(new IXR_Error(401, __( 'Sorry, you do not have the right to edit this page.')));678 if ( !current_user_can("edit_page", $page_id) ) 679 return(new IXR_Error(401, __("Sorry, you do not have the right to edit this page."))); 695 680 696 681 // Mark this as content for a page. 697 $content[ 'post_type'] = 'page';682 $content["post_type"] = "page"; 698 683 699 684 // Arrange args in the way mw_editPost understands. … … 751 736 $num_pages = count($page_list); 752 737 for ( $i = 0; $i < $num_pages; $i++ ) { 753 $post_date = mysql2date( 'Ymd\TH:i:s', $page_list[$i]->post_date, false);754 $post_date_gmt = mysql2date( 'Ymd\TH:i:s', $page_list[$i]->post_date_gmt, false);738 $post_date = mysql2date("Ymd\TH:i:s", $page_list[$i]->post_date, false); 739 $post_date_gmt = mysql2date("Ymd\TH:i:s", $page_list[$i]->post_date_gmt, false); 755 740 756 741 $page_list[$i]->dateCreated = new IXR_Date($post_date); … … 790 775 return $this->error; 791 776 792 if ( !current_user_can( 'edit_posts') )793 return(new IXR_Error(401, __( 'Sorry, you cannot edit posts on this site.')));777 if ( !current_user_can("edit_posts") ) 778 return(new IXR_Error(401, __("Sorry, you cannot edit posts on this site."))); 794 779 795 780 do_action('xmlrpc_call', 'wp.getAuthors'); … … 798 783 foreach ( get_users( array( 'fields' => array('ID','user_login','display_name') ) ) as $user ) { 799 784 $authors[] = array( 800 'user_id'=> $user->ID,801 'user_login'=> $user->user_login,802 'display_name'=> $user->display_name785 "user_id" => $user->ID, 786 "user_login" => $user->user_login, 787 "display_name" => $user->display_name 803 788 ); 804 789 } … … 870 855 871 856 // Make sure the user is allowed to add a category. 872 if ( !current_user_can( 'manage_categories') )873 return(new IXR_Error(401, __( 'Sorry, you do not have the right to add a category.')));857 if ( !current_user_can("manage_categories") ) 858 return(new IXR_Error(401, __("Sorry, you do not have the right to add a category."))); 874 859 875 860 // If no slug was provided make it empty so that 876 861 // WordPress will generate one. 877 if ( empty($category[ 'slug']) )878 $category[ 'slug'] = '';862 if ( empty($category["slug"]) ) 863 $category["slug"] = ""; 879 864 880 865 // If no parent_id was provided make it empty 881 866 // so that it will be a top level page (no parent). 882 if ( !isset($category[ 'parent_id']) )883 $category[ 'parent_id'] = '';867 if ( !isset($category["parent_id"]) ) 868 $category["parent_id"] = ""; 884 869 885 870 // If no description was provided make it empty. … … 888 873 889 874 $new_category = array( 890 'cat_name' => $category['name'],891 'category_nicename' => $category['slug'],892 'category_parent' => $category['parent_id'],893 'category_description' => $category['description']875 "cat_name" => $category["name"], 876 "category_nicename" => $category["slug"], 877 "category_parent" => $category["parent_id"], 878 "category_description" => $category["description"] 894 879 ); 895 880 … … 899 884 return (int) $cat_id->get_error_data(); 900 885 else 901 return(new IXR_Error(500, __( 'Sorry, the new category failed.')));886 return(new IXR_Error(500, __("Sorry, the new category failed."))); 902 887 } elseif ( ! $cat_id ) { 903 return(new IXR_Error(500, __( 'Sorry, the new category failed.')));888 return(new IXR_Error(500, __("Sorry, the new category failed."))); 904 889 } 905 890 … … 928 913 do_action('xmlrpc_call', 'wp.deleteCategory'); 929 914 930 if ( !current_user_can( 'manage_categories') )931 return new IXR_Error( 401, __( 'Sorry, you do not have the right to delete a category.') );915 if ( !current_user_can("manage_categories") ) 916 return new IXR_Error( 401, __( "Sorry, you do not have the right to delete a category." ) ); 932 917 933 918 return wp_delete_term( $category_id, 'category' ); … … 963 948 foreach ( (array) get_categories($args) as $cat ) { 964 949 $category_suggestions[] = array( 965 'category_id'=> $cat->term_id,966 'category_name'=> $cat->name950 "category_id" => $cat->term_id, 951 "category_name" => $cat->name 967 952 ); 968 953 } … … 999 984 1000 985 // Format page date. 1001 $comment_date = mysql2date( 'Ymd\TH:i:s', $comment->comment_date, false);1002 $comment_date_gmt = mysql2date( 'Ymd\TH:i:s', $comment->comment_date_gmt, false);986 $comment_date = mysql2date("Ymd\TH:i:s", $comment->comment_date, false); 987 $comment_date_gmt = mysql2date("Ymd\TH:i:s", $comment->comment_date_gmt, false); 1003 988 1004 989 if ( '0' == $comment->comment_approved ) … … 1014 999 1015 1000 $comment_struct = array( 1016 'date_created_gmt'=> new IXR_Date($comment_date_gmt),1017 'user_id'=> $comment->user_id,1018 'comment_id'=> $comment->comment_ID,1019 'parent'=> $comment->comment_parent,1020 'status'=> $comment_status,1021 'content'=> $comment->comment_content,1022 'link'=> $link,1023 'post_id'=> $comment->comment_post_ID,1024 'post_title'=> get_the_title($comment->comment_post_ID),1025 'author'=> $comment->comment_author,1026 'author_url'=> $comment->comment_author_url,1027 'author_email'=> $comment->comment_author_email,1028 'author_ip'=> $comment->comment_author_IP,1029 'type'=> $comment->comment_type,1001 "date_created_gmt" => new IXR_Date($comment_date_gmt), 1002 "user_id" => $comment->user_id, 1003 "comment_id" => $comment->comment_ID, 1004 "parent" => $comment->comment_parent, 1005 "status" => $comment_status, 1006 "content" => $comment->comment_content, 1007 "link" => $link, 1008 "post_id" => $comment->comment_post_ID, 1009 "post_title" => get_the_title($comment->comment_post_ID), 1010 "author" => $comment->comment_author, 1011 "author_url" => $comment->comment_author_url, 1012 "author_email" => $comment->comment_author_email, 1013 "author_ip" => $comment->comment_author_IP, 1014 "type" => $comment->comment_type, 1030 1015 ); 1031 1016 … … 1036 1021 * Retrieve comments. 1037 1022 * 1038 * Besides the common blog_id, username, and password arguments, it takes a filter1039 * array as last argument.1040 *1041 * Accepted 'filter' keys are 'status', 'post_id', 'offset', and 'number'.1042 *1043 * The defaults are as follows:1044 * - 'status' - Default is ''. Filter by status (e.g., 'approve', 'hold')1045 * - 'post_id' - Default is ''. The post where the comment is posted. Empty string shows all comments.1046 * - 'number' - Default is 10. Total number of media items to retrieve.1047 * - 'offset' - Default is 0. See {@link WP_Query::query()} for more.1048 *1049 1023 * @since 2.7.0 1050 1024 * 1051 1025 * @param array $args Method parameters. 1052 * @return array . Contains a collection of comments. See {@link wp_xmlrpc_server::wp_getComment()} for a description of each item contents1026 * @return array 1053 1027 */ 1054 1028 function wp_getComments($args) { … … 1094 1068 $comments_struct = array(); 1095 1069 1096 // FIXME: we already have the comments, why query them again?1097 1070 for ( $i = 0; $i < $num_comments; $i++ ) { 1098 1071 $comment = wp_xmlrpc_server::wp_getComment(array( … … 1106 1079 1107 1080 /** 1108 * Delete a comment. 1109 * 1110 * By default, the comment will be moved to the trash instead of deleted. 1111 * See {@link wp_delete_comment()} for more information on 1112 * this behavior. 1081 * Remove comment. 1113 1082 * 1114 1083 * @since 2.7.0 1115 1084 * 1116 * @param array $args Method parameters. Contains: 1117 * - blog_id 1118 * - username 1119 * - password 1120 * - comment_id 1085 * @param array $args Method parameters. 1121 1086 * @return mixed {@link wp_delete_comment()} 1122 1087 */ … … 1149 1114 * Edit comment. 1150 1115 * 1151 * Besides the common blog_id, username, and password arguments, it takes a1152 * comment_id integer and a content_struct array as last argument.1153 *1154 * The allowed keys in the content_struct array are:1155 * - 'author'1156 * - 'author_url'1157 * - 'author_email'1158 * - 'content'1159 * - 'date_created_gmt'1160 * - 'status'. Common statuses are 'approve', 'hold', 'spam'. See {@link get_comment_statuses()} for more details1161 *1162 1116 * @since 2.7.0 1163 1117 * 1164 * @param array $args. Contains: 1165 * - blog_id 1166 * - username 1167 * - password 1168 * - comment_id 1169 * - content_struct 1118 * @param array $args Method parameters. 1170 1119 * @return bool True, on success. 1171 1120 */ … … 1369 1318 $count = wp_count_comments( $post_id ); 1370 1319 return array( 1371 'approved'=> $count->approved,1372 'awaiting_moderation'=> $count->moderated,1373 'spam'=> $count->spam,1374 'total_comments'=> $count->total_comments1320 "approved" => $count->approved, 1321 "awaiting_moderation" => $count->moderated, 1322 "spam" => $count->spam, 1323 "total_comments" => $count->total_comments 1375 1324 ); 1376 1325 } … … 1574 1523 1575 1524 if ( !current_user_can( 'upload_files' ) ) 1576 return new IXR_Error( 403, __( 'You are not allowed to upload files tothis site.' ) );1525 return new IXR_Error( 403, __( 'You are not allowed to upload files on this site.' ) ); 1577 1526 1578 1527 do_action('xmlrpc_call', 'wp.getMediaItem'); … … 1582 1531 1583 1532 // Format page date. 1584 $attachment_date = mysql2date( 'Ymd\TH:i:s', $attachment->post_date, false);1585 $attachment_date_gmt = mysql2date( 'Ymd\TH:i:s', $attachment->post_date_gmt, false);1533 $attachment_date = mysql2date("Ymd\TH:i:s", $attachment->post_date, false); 1534 $attachment_date_gmt = mysql2date("Ymd\TH:i:s", $attachment->post_date_gmt, false); 1586 1535 1587 1536 $link = wp_get_attachment_url($attachment->ID); … … 1589 1538 1590 1539 $attachment_struct = array( 1591 'date_created_gmt'=> new IXR_Date($attachment_date_gmt),1592 'parent'=> $attachment->post_parent,1593 'link'=> $link,1594 'thumbnail'=> $thumbnail_link,1595 'title'=> $attachment->post_title,1596 'caption'=> $attachment->post_excerpt,1597 'description'=> $attachment->post_content,1598 'metadata'=> wp_get_attachment_metadata($attachment->ID),1540 "date_created_gmt" => new IXR_Date($attachment_date_gmt), 1541 "parent" => $attachment->post_parent, 1542 "link" => $link, 1543 "thumbnail" => $thumbnail_link, 1544 "title" => $attachment->post_title, 1545 "caption" => $attachment->post_excerpt, 1546 "description" => $attachment->post_content, 1547 "metadata" => wp_get_attachment_metadata($attachment->ID), 1599 1548 ); 1600 1549 … … 1683 1632 1684 1633 do_action( 'xmlrpc_call', 'wp.getPostFormats' ); 1685 1686 $formats = get_post_format_strings(); 1687 1688 # find out if they want a list of currently supports formats 1689 if ( isset( $args[3] ) && is_array( $args[3] ) ) { 1690 if ( $args[3]['show-supported'] ) { 1691 if ( current_theme_supports( 'post-formats' ) ) { 1692 $supported = get_theme_support( 'post-formats' ); 1693 1694 $data['all'] = $formats; 1695 $data['supported'] = $supported[0]; 1696 1697 $formats = $data; 1698 } 1699 } 1700 } 1701 1702 return $formats; 1634 return get_post_format_strings(); 1703 1635 } 1704 1636 … … 2143 2075 * Create a new post. 2144 2076 * 2145 * The 'content_struct' argument must contain:2146 * - title2147 * - description2148 * - mt_excerpt2149 * - mt_text_more2150 * - mt_keywords2151 * - mt_tb_ping_urls2152 * - categories2153 *2154 * Also, it can optionally contain:2155 * - wp_slug2156 * - wp_password2157 * - wp_page_parent_id2158 * - wp_page_order2159 * - wp_author_id2160 * - post_status | page_status - can be 'draft', 'private', 'publish', or 'pending'2161 * - mt_allow_comments - can be 'open' or 'closed'2162 * - mt_allow_pings - can be 'open' or 'closed'2163 * - date_created_gmt2164 * - dateCreated2165 *2166 2077 * @since 1.5.0 2167 2078 * 2168 * @param array $args Method parameters. Contains: 2169 * - blog_id 2170 * - username 2171 * - password 2172 * - content_struct 2173 * - publish 2079 * @param array $args Method parameters. 2174 2080 * @return int 2175 2081 */ … … 2239 2145 // one has been provided. 2240 2146 $post_name = ""; 2241 if ( isset($content_struct[ 'wp_slug']) )2242 $post_name = $content_struct[ 'wp_slug'];2147 if ( isset($content_struct["wp_slug"]) ) 2148 $post_name = $content_struct["wp_slug"]; 2243 2149 2244 2150 // Only use a password if one was given. 2245 if ( isset($content_struct[ 'wp_password']) )2246 $post_password = $content_struct[ 'wp_password'];2151 if ( isset($content_struct["wp_password"]) ) 2152 $post_password = $content_struct["wp_password"]; 2247 2153 2248 2154 // Only set a post parent if one was provided. 2249 if ( isset($content_struct[ 'wp_page_parent_id']) )2250 $post_parent = $content_struct[ 'wp_page_parent_id'];2155 if ( isset($content_struct["wp_page_parent_id"]) ) 2156 $post_parent = $content_struct["wp_page_parent_id"]; 2251 2157 2252 2158 // Only set the menu_order if it was provided. 2253 if ( isset($content_struct[ 'wp_page_order']) )2254 $menu_order = $content_struct[ 'wp_page_order'];2159 if ( isset($content_struct["wp_page_order"]) ) 2160 $menu_order = $content_struct["wp_page_order"]; 2255 2161 2256 2162 $post_author = $user->ID; 2257 2163 2258 2164 // If an author id was provided then use it instead. 2259 if ( isset($content_struct[ 'wp_author_id']) && ($user->ID != $content_struct['wp_author_id']) ) {2165 if ( isset($content_struct["wp_author_id"]) && ($user->ID != $content_struct["wp_author_id"]) ) { 2260 2166 switch ( $post_type ) { 2261 2167 case "post": 2262 if ( !current_user_can( 'edit_others_posts') )2263 return(new IXR_Error(401, __( 'You are not allowed to post as this user')));2168 if ( !current_user_can("edit_others_posts") ) 2169 return(new IXR_Error(401, __("You are not allowed to post as this user"))); 2264 2170 break; 2265 2171 case "page": 2266 if ( !current_user_can( 'edit_others_pages') )2267 return(new IXR_Error(401, __( 'You are not allowed to create pages as this user')));2172 if ( !current_user_can("edit_others_pages") ) 2173 return(new IXR_Error(401, __("You are not allowed to create pages as this user"))); 2268 2174 break; 2269 2175 default: 2270 return(new IXR_Error(401, __( 'Invalid post type.')));2176 return(new IXR_Error(401, __("Invalid post type."))); 2271 2177 break; 2272 2178 } 2273 $post_author = $content_struct[ 'wp_author_id'];2179 $post_author = $content_struct["wp_author_id"]; 2274 2180 } 2275 2181 … … 2282 2188 switch ( $content_struct["{$post_type}_status"] ) { 2283 2189 case 'draft': 2284 case 'pending':2285 2190 case 'private': 2286 2191 case 'publish': 2287 2192 $post_status = $content_struct["{$post_type}_status"]; 2193 break; 2194 case 'pending': 2195 // Pending is only valid for posts, not pages. 2196 if ( $post_type === 'post' ) 2197 $post_status = $content_struct["{$post_type}_status"]; 2288 2198 break; 2289 2199 default: … … 2298 2208 $tags_input = isset($content_struct['mt_keywords']) ? $content_struct['mt_keywords'] : null; 2299 2209 2300 if ( isset($content_struct[ 'mt_allow_comments']) ) {2301 if ( !is_numeric($content_struct[ 'mt_allow_comments']) ) {2302 switch ( $content_struct[ 'mt_allow_comments'] ) {2303 case 'closed':2304 $comment_status = 'closed';2210 if ( isset($content_struct["mt_allow_comments"]) ) { 2211 if ( !is_numeric($content_struct["mt_allow_comments"]) ) { 2212 switch ( $content_struct["mt_allow_comments"] ) { 2213 case "closed": 2214 $comment_status = "closed"; 2305 2215 break; 2306 case 'open':2307 $comment_status = 'open';2216 case "open": 2217 $comment_status = "open"; 2308 2218 break; 2309 2219 default: 2310 $comment_status = get_option( 'default_comment_status');2220 $comment_status = get_option("default_comment_status"); 2311 2221 break; 2312 2222 } 2313 2223 } else { 2314 switch ( (int) $content_struct[ 'mt_allow_comments'] ) {2224 switch ( (int) $content_struct["mt_allow_comments"] ) { 2315 2225 case 0: 2316 2226 case 2: 2317 $comment_status = 'closed';2227 $comment_status = "closed"; 2318 2228 break; 2319 2229 case 1: 2320 $comment_status = 'open';2230 $comment_status = "open"; 2321 2231 break; 2322 2232 default: 2323 $comment_status = get_option( 'default_comment_status');2233 $comment_status = get_option("default_comment_status"); 2324 2234 break; 2325 2235 } 2326 2236 } 2327 2237 } else { 2328 $comment_status = get_option( 'default_comment_status');2329 } 2330 2331 if ( isset($content_struct[ 'mt_allow_pings']) ) {2332 if ( !is_numeric($content_struct[ 'mt_allow_pings']) ) {2238 $comment_status = get_option("default_comment_status"); 2239 } 2240 2241 if ( isset($content_struct["mt_allow_pings"]) ) { 2242 if ( !is_numeric($content_struct["mt_allow_pings"]) ) { 2333 2243 switch ( $content_struct['mt_allow_pings'] ) { 2334 case 'closed':2335 $ping_status = 'closed';2244 case "closed": 2245 $ping_status = "closed"; 2336 2246 break; 2337 case 'open':2338 $ping_status = 'open';2247 case "open": 2248 $ping_status = "open"; 2339 2249 break; 2340 2250 default: 2341 $ping_status = get_option( 'default_ping_status');2251 $ping_status = get_option("default_ping_status"); 2342 2252 break; 2343 2253 } 2344 2254 } else { 2345 switch ( (int) $content_struct[ 'mt_allow_pings'] ) {2255 switch ( (int) $content_struct["mt_allow_pings"] ) { 2346 2256 case 0: 2347 $ping_status = 'closed';2257 $ping_status = "closed"; 2348 2258 break; 2349 2259 case 1: 2350 $ping_status = 'open';2260 $ping_status = "open"; 2351 2261 break; 2352 2262 default: 2353 $ping_status = get_option( 'default_ping_status');2263 $ping_status = get_option("default_ping_status"); 2354 2264 break; 2355 2265 } 2356 2266 } 2357 2267 } else { 2358 $ping_status = get_option( 'default_ping_status');2268 $ping_status = get_option("default_ping_status"); 2359 2269 } 2360 2270 2361 2271 if ( $post_more ) 2362 $post_content = $post_content . '<!--more-->'. $post_more;2272 $post_content = $post_content . "<!--more-->" . $post_more; 2363 2273 2364 2274 $to_ping = null; … … 2547 2457 // created (which was the old behavior). 2548 2458 if ( empty($postdata["ID"]) ) 2549 return(new IXR_Error(404, __( 'Invalid post ID.')));2459 return(new IXR_Error(404, __("Invalid post ID."))); 2550 2460 2551 2461 $this->escape($postdata); … … 2554 2464 // Let WordPress manage slug if none was provided. 2555 2465 $post_name = ""; 2556 $post_name = $postdata['post_name']; 2557 if ( isset($content_struct['wp_slug']) ) 2558 $post_name = $content_struct['wp_slug']; 2466 if ( isset($content_struct["wp_slug"]) ) 2467 $post_name = $content_struct["wp_slug"]; 2559 2468 2560 2469 // Only use a password if one was given. 2561 if ( isset($content_struct[ 'wp_password']) )2562 $post_password = $content_struct[ 'wp_password'];2470 if ( isset($content_struct["wp_password"]) ) 2471 $post_password = $content_struct["wp_password"]; 2563 2472 2564 2473 // Only set a post parent if one was given. 2565 if ( isset($content_struct[ 'wp_page_parent_id']) )2566 $post_parent = $content_struct[ 'wp_page_parent_id'];2474 if ( isset($content_struct["wp_page_parent_id"]) ) 2475 $post_parent = $content_struct["wp_page_parent_id"]; 2567 2476 2568 2477 // Only set the menu_order if it was given. 2569 if ( isset($content_struct[ 'wp_page_order']) )2570 $menu_order = $content_struct[ 'wp_page_order'];2571 2572 $post_author = $postdata[ 'post_author'];2478 if ( isset($content_struct["wp_page_order"]) ) 2479 $menu_order = $content_struct["wp_page_order"]; 2480 2481 $post_author = $postdata["post_author"]; 2573 2482 2574 2483 // Only set the post_author if one is set. 2575 if ( isset($content_struct[ 'wp_author_id']) && ($user->ID != $content_struct['wp_author_id']) ) {2484 if ( isset($content_struct["wp_author_id"]) && ($user->ID != $content_struct["wp_author_id"]) ) { 2576 2485 switch ( $post_type ) { 2577 case 'post':2578 if ( !current_user_can( 'edit_others_posts') )2579 return(new IXR_Error(401, __( 'You are not allowed to change the post author as this user.')));2486 case "post": 2487 if ( !current_user_can("edit_others_posts") ) 2488 return(new IXR_Error(401, __("You are not allowed to change the post author as this user."))); 2580 2489 break; 2581 case 'page':2582 if ( !current_user_can( 'edit_others_pages') )2583 return(new IXR_Error(401, __( 'You are not allowed to change the page author as this user.')));2490 case "page": 2491 if ( !current_user_can("edit_others_pages") ) 2492 return(new IXR_Error(401, __("You are not allowed to change the page author as this user."))); 2584 2493 break; 2585 2494 default: 2586 return(new IXR_Error(401, __( 'Invalid post type.')));2495 return(new IXR_Error(401, __("Invalid post type."))); 2587 2496 break; 2588 2497 } 2589 $post_author = $content_struct[ 'wp_author_id'];2590 } 2591 2592 if ( isset($content_struct[ 'mt_allow_comments']) ) {2593 if ( !is_numeric($content_struct[ 'mt_allow_comments']) ) {2594 switch ( $content_struct[ 'mt_allow_comments'] ) {2595 case 'closed':2596 $comment_status = 'closed';2498 $post_author = $content_struct["wp_author_id"]; 2499 } 2500 2501 if ( isset($content_struct["mt_allow_comments"]) ) { 2502 if ( !is_numeric($content_struct["mt_allow_comments"]) ) { 2503 switch ( $content_struct["mt_allow_comments"] ) { 2504 case "closed": 2505 $comment_status = "closed"; 2597 2506 break; 2598 case 'open':2599 $comment_status = 'open';2507 case "open": 2508 $comment_status = "open"; 2600 2509 break; 2601 2510 default: 2602 $comment_status = get_option( 'default_comment_status');2511 $comment_status = get_option("default_comment_status"); 2603 2512 break; 2604 2513 } 2605 2514 } else { 2606 switch ( (int) $content_struct[ 'mt_allow_comments'] ) {2515 switch ( (int) $content_struct["mt_allow_comments"] ) { 2607 2516 case 0: 2608 2517 case 2: 2609 $comment_status = 'closed';2518 $comment_status = "closed"; 2610 2519 break; 2611 2520 case 1: 2612 $comment_status = 'open';2521 $comment_status = "open"; 2613 2522 break; 2614 2523 default: 2615 $comment_status = get_option( 'default_comment_status');2524 $comment_status = get_option("default_comment_status"); 2616 2525 break; 2617 2526 } … … 2619 2528 } 2620 2529 2621 if ( isset($content_struct[ 'mt_allow_pings']) ) {2622 if ( !is_numeric($content_struct[ 'mt_allow_pings']) ) {2623 switch ( $content_struct[ 'mt_allow_pings'] ) {2624 case 'closed':2625 $ping_status = 'closed';2530 if ( isset($content_struct["mt_allow_pings"]) ) { 2531 if ( !is_numeric($content_struct["mt_allow_pings"]) ) { 2532 switch ( $content_struct["mt_allow_pings"] ) { 2533 case "closed": 2534 $ping_status = "closed"; 2626 2535 break; 2627 case 'open':2628 $ping_status = 'open';2536 case "open": 2537 $ping_status = "open"; 2629 2538 break; 2630 2539 default: 2631 $ping_status = get_option( 'default_ping_status');2540 $ping_status = get_option("default_ping_status"); 2632 2541 break; 2633 2542 } … … 2635 2544 switch ( (int) $content_struct["mt_allow_pings"] ) { 2636 2545 case 0: 2637 $ping_status = 'closed';2546 $ping_status = "closed"; 2638 2547 break; 2639 2548 case 1: 2640 $ping_status = 'open';2549 $ping_status = "open"; 2641 2550 break; 2642 2551 default: 2643 $ping_status = get_option( 'default_ping_status');2552 $ping_status = get_option("default_ping_status"); 2644 2553 break; 2645 2554 } … … 2667 2576 switch( $content_struct["{$post_type}_status"] ) { 2668 2577 case 'draft': 2669 case 'pending':2670 2578 case 'private': 2671 2579 case 'publish': 2672 2580 $post_status = $content_struct["{$post_type}_status"]; 2581 break; 2582 case 'pending': 2583 // Pending is only valid for posts, not pages. 2584 if ( $post_type === 'post' ) 2585 $post_status = $content_struct["{$post_type}_status"]; 2673 2586 break; 2674 2587 default: … … 3058 2971 } 3059 2972 3060 if ( $upload_err = apply_filters( 'pre_upload_error', false ) )2973 if ( $upload_err = apply_filters( "pre_upload_error", false ) ) 3061 2974 return new IXR_Error(500, $upload_err); 3062 2975 3063 if ( !empty($data[ 'overwrite']) && ($data['overwrite'] == true) ) {2976 if ( !empty($data["overwrite"]) && ($data["overwrite"] == true) ) { 3064 2977 // Get postmeta info on the object. 3065 2978 $old_file = $wpdb->get_row(" … … 3075 2988 // Make sure the new name is different by pre-pending the 3076 2989 // previous post id. 3077 $filename = preg_replace( '/^wpid\d+-/', '', $name);2990 $filename = preg_replace("/^wpid\d+-/", "", $name); 3078 2991 $name = "wpid{$old_file->ID}-{$filename}"; 3079 2992 } … … 3156 3069 'postid' => (string) $entry['ID'], 3157 3070 'title' => $entry['post_title'], 3158 'post_status' => $entry['post_status'],3159 3071 'date_created_gmt' => new IXR_Date($post_date_gmt) 3160 3072 );
Note: See TracChangeset
for help on using the changeset viewer.