Changes from branches/3.1/wp-includes/class-wp-xmlrpc-server.php at r18014 to trunk/wp-includes/class-wp-xmlrpc-server.php at r18254
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/class-wp-xmlrpc-server.php
r18014 r18254 25 25 * Register all of the XMLRPC methods that XMLRPC server understands. 26 26 * 27 * PHP4 constructor and sets up server and method property. Passes XMLRPC27 * 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 wp_xmlrpc_server() {35 function __construct() { 36 36 $this->methods = array( 37 37 // WordPress API … … 383 383 * @since 2.6.0 384 384 * 385 * @param array $args Method parameters. 386 * @return array 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 387 394 */ 388 395 function wp_getUsersBlogs( $args ) { … … 436 443 * @since 2.2.0 437 444 * 438 * @param array $args Method parameters. 445 * @param array $args Method parameters. Contains: 446 * - blog_id 447 * - page_id 448 * - username 449 * - password 439 450 * @return array 440 451 */ … … 460 471 461 472 // If we found the page then format the data. 462 if ( $page->ID && ($page->post_type == "page") ) {473 if ( $page->ID && ($page->post_type == 'page') ) { 463 474 // Get all of the page content and link. 464 475 $full_page = get_extended($page->post_content); … … 477 488 478 489 // Format page date. 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);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); 481 492 482 493 // For drafts use the GMT version of the date … … 498 509 499 510 $page_struct = array( 500 "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_template511 '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_template 524 535 ); 525 536 … … 528 539 // If the page doesn't exist indicate that. 529 540 else { 530 return(new IXR_Error(404, __( "Sorry, no such page.")));541 return(new IXR_Error(404, __('Sorry, no such page.'))); 531 542 } 532 543 } … … 537 548 * @since 2.2.0 538 549 * 539 * @param array $args Method parameters. 550 * @param array $args Method parameters. Contains: 551 * - blog_id 552 * - username 553 * - password 554 * - num_pages 540 555 * @return array 541 556 */ … … 583 598 * @since 2.2.0 584 599 * 585 * @param array $args Method parameters. 600 * @param array $args Method parameters. See {@link wp_xmlrpc_server::mw_newPost()} 586 601 * @return unknown 587 602 */ … … 599 614 600 615 // Make sure the user is allowed to add new pages. 601 if ( !current_user_can( "publish_pages") )602 return(new IXR_Error(401, __( "Sorry, you cannot add new pages.")));616 if ( !current_user_can('publish_pages') ) 617 return(new IXR_Error(401, __('Sorry, you cannot add new pages.'))); 603 618 604 619 // Mark this as content for a page. 605 $args[3]["post_type"] = "page";620 $args[3]["post_type"] = 'page'; 606 621 607 622 // Let mw_newPost do all of the heavy lifting. … … 633 648 // make sure it is a page and not a post. 634 649 $actual_page = wp_get_single_post($page_id, ARRAY_A); 635 if ( !$actual_page || ($actual_page[ "post_type"] != "page") )636 return(new IXR_Error(404, __( "Sorry, no such page.")));650 if ( !$actual_page || ($actual_page['post_type'] != 'page') ) 651 return(new IXR_Error(404, __('Sorry, no such page.'))); 637 652 638 653 // Make sure the user can delete pages. 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.")));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.'))); 641 656 642 657 // Attempt to delete the page. 643 658 $result = wp_delete_post($page_id); 644 659 if ( !$result ) 645 return(new IXR_Error(500, __( "Failed to delete the page.")));660 return(new IXR_Error(500, __('Failed to delete the page.'))); 646 661 647 662 return(true); … … 672 687 // Get the page data and make sure it is a page. 673 688 $actual_page = wp_get_single_post($page_id, ARRAY_A); 674 if ( !$actual_page || ($actual_page[ "post_type"] != "page") )675 return(new IXR_Error(404, __( "Sorry, no such page.")));689 if ( !$actual_page || ($actual_page['post_type'] != 'page') ) 690 return(new IXR_Error(404, __('Sorry, no such page.'))); 676 691 677 692 // Make sure the user is allowed to edit pages. 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.")));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.'))); 680 695 681 696 // Mark this as content for a page. 682 $content[ "post_type"] = "page";697 $content['post_type'] = 'page'; 683 698 684 699 // Arrange args in the way mw_editPost understands. … … 736 751 $num_pages = count($page_list); 737 752 for ( $i = 0; $i < $num_pages; $i++ ) { 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);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); 740 755 741 756 $page_list[$i]->dateCreated = new IXR_Date($post_date); … … 775 790 return $this->error; 776 791 777 if ( !current_user_can( "edit_posts") )778 return(new IXR_Error(401, __( "Sorry, you cannot edit posts on this site.")));792 if ( !current_user_can('edit_posts') ) 793 return(new IXR_Error(401, __('Sorry, you cannot edit posts on this site.'))); 779 794 780 795 do_action('xmlrpc_call', 'wp.getAuthors'); … … 783 798 foreach ( get_users( array( 'fields' => array('ID','user_login','display_name') ) ) as $user ) { 784 799 $authors[] = array( 785 "user_id"=> $user->ID,786 "user_login"=> $user->user_login,787 "display_name"=> $user->display_name800 'user_id' => $user->ID, 801 'user_login' => $user->user_login, 802 'display_name' => $user->display_name 788 803 ); 789 804 } … … 855 870 856 871 // Make sure the user is allowed 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.")));872 if ( !current_user_can('manage_categories') ) 873 return(new IXR_Error(401, __('Sorry, you do not have the right to add a category.'))); 859 874 860 875 // If no slug was provided make it empty so that 861 876 // WordPress will generate one. 862 if ( empty($category[ "slug"]) )863 $category[ "slug"] = "";877 if ( empty($category['slug']) ) 878 $category['slug'] = ''; 864 879 865 880 // If no parent_id was provided make it empty 866 881 // so that it will be a top level page (no parent). 867 if ( !isset($category[ "parent_id"]) )868 $category[ "parent_id"] = "";882 if ( !isset($category['parent_id']) ) 883 $category['parent_id'] = ''; 869 884 870 885 // If no description was provided make it empty. … … 873 888 874 889 $new_category = array( 875 "cat_name" => $category["name"],876 "category_nicename" => $category["slug"],877 "category_parent" => $category["parent_id"],878 "category_description" => $category["description"]890 'cat_name' => $category['name'], 891 'category_nicename' => $category['slug'], 892 'category_parent' => $category['parent_id'], 893 'category_description' => $category['description'] 879 894 ); 880 895 … … 884 899 return (int) $cat_id->get_error_data(); 885 900 else 886 return(new IXR_Error(500, __( "Sorry, the new category failed.")));901 return(new IXR_Error(500, __('Sorry, the new category failed.'))); 887 902 } elseif ( ! $cat_id ) { 888 return(new IXR_Error(500, __( "Sorry, the new category failed.")));903 return(new IXR_Error(500, __('Sorry, the new category failed.'))); 889 904 } 890 905 … … 913 928 do_action('xmlrpc_call', 'wp.deleteCategory'); 914 929 915 if ( !current_user_can( "manage_categories") )916 return new IXR_Error( 401, __( "Sorry, you do not have the right to delete a category.") );930 if ( !current_user_can('manage_categories') ) 931 return new IXR_Error( 401, __( 'Sorry, you do not have the right to delete a category.' ) ); 917 932 918 933 return wp_delete_term( $category_id, 'category' ); … … 948 963 foreach ( (array) get_categories($args) as $cat ) { 949 964 $category_suggestions[] = array( 950 "category_id"=> $cat->term_id,951 "category_name"=> $cat->name965 'category_id' => $cat->term_id, 966 'category_name' => $cat->name 952 967 ); 953 968 } … … 984 999 985 1000 // Format page date. 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);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); 988 1003 989 1004 if ( '0' == $comment->comment_approved ) … … 999 1014 1000 1015 $comment_struct = array( 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,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, 1015 1030 ); 1016 1031 … … 1021 1036 * Retrieve comments. 1022 1037 * 1038 * Besides the common blog_id, username, and password arguments, it takes a filter 1039 * 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 * 1023 1049 * @since 2.7.0 1024 1050 * 1025 1051 * @param array $args Method parameters. 1026 * @return array 1052 * @return array. Contains a collection of comments. See {@link wp_xmlrpc_server::wp_getComment()} for a description of each item contents 1027 1053 */ 1028 1054 function wp_getComments($args) { … … 1068 1094 $comments_struct = array(); 1069 1095 1096 // FIXME: we already have the comments, why query them again? 1070 1097 for ( $i = 0; $i < $num_comments; $i++ ) { 1071 1098 $comment = wp_xmlrpc_server::wp_getComment(array( … … 1079 1106 1080 1107 /** 1081 * Remove comment. 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. 1082 1113 * 1083 1114 * @since 2.7.0 1084 1115 * 1085 * @param array $args Method parameters. 1116 * @param array $args Method parameters. Contains: 1117 * - blog_id 1118 * - username 1119 * - password 1120 * - comment_id 1086 1121 * @return mixed {@link wp_delete_comment()} 1087 1122 */ … … 1114 1149 * Edit comment. 1115 1150 * 1151 * Besides the common blog_id, username, and password arguments, it takes a 1152 * 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 details 1161 * 1116 1162 * @since 2.7.0 1117 1163 * 1118 * @param array $args Method parameters. 1164 * @param array $args. Contains: 1165 * - blog_id 1166 * - username 1167 * - password 1168 * - comment_id 1169 * - content_struct 1119 1170 * @return bool True, on success. 1120 1171 */ … … 1318 1369 $count = wp_count_comments( $post_id ); 1319 1370 return array( 1320 "approved"=> $count->approved,1321 "awaiting_moderation"=> $count->moderated,1322 "spam"=> $count->spam,1323 "total_comments"=> $count->total_comments1371 'approved' => $count->approved, 1372 'awaiting_moderation' => $count->moderated, 1373 'spam' => $count->spam, 1374 'total_comments' => $count->total_comments 1324 1375 ); 1325 1376 } … … 1523 1574 1524 1575 if ( !current_user_can( 'upload_files' ) ) 1525 return new IXR_Error( 403, __( 'You are not allowed to upload files onthis site.' ) );1576 return new IXR_Error( 403, __( 'You are not allowed to upload files to this site.' ) ); 1526 1577 1527 1578 do_action('xmlrpc_call', 'wp.getMediaItem'); … … 1531 1582 1532 1583 // Format page date. 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);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); 1535 1586 1536 1587 $link = wp_get_attachment_url($attachment->ID); … … 1538 1589 1539 1590 $attachment_struct = array( 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),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), 1548 1599 ); 1549 1600 … … 1632 1683 1633 1684 do_action( 'xmlrpc_call', 'wp.getPostFormats' ); 1634 return get_post_format_strings(); 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; 1635 1703 } 1636 1704 … … 2075 2143 * Create a new post. 2076 2144 * 2145 * The 'content_struct' argument must contain: 2146 * - title 2147 * - description 2148 * - mt_excerpt 2149 * - mt_text_more 2150 * - mt_keywords 2151 * - mt_tb_ping_urls 2152 * - categories 2153 * 2154 * Also, it can optionally contain: 2155 * - wp_slug 2156 * - wp_password 2157 * - wp_page_parent_id 2158 * - wp_page_order 2159 * - wp_author_id 2160 * - 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_gmt 2164 * - dateCreated 2165 * 2077 2166 * @since 1.5.0 2078 2167 * 2079 * @param array $args Method parameters. 2168 * @param array $args Method parameters. Contains: 2169 * - blog_id 2170 * - username 2171 * - password 2172 * - content_struct 2173 * - publish 2080 2174 * @return int 2081 2175 */ … … 2145 2239 // one has been provided. 2146 2240 $post_name = ""; 2147 if ( isset($content_struct[ "wp_slug"]) )2148 $post_name = $content_struct[ "wp_slug"];2241 if ( isset($content_struct['wp_slug']) ) 2242 $post_name = $content_struct['wp_slug']; 2149 2243 2150 2244 // Only use a password if one was given. 2151 if ( isset($content_struct[ "wp_password"]) )2152 $post_password = $content_struct[ "wp_password"];2245 if ( isset($content_struct['wp_password']) ) 2246 $post_password = $content_struct['wp_password']; 2153 2247 2154 2248 // Only set a post parent if one was provided. 2155 if ( isset($content_struct[ "wp_page_parent_id"]) )2156 $post_parent = $content_struct[ "wp_page_parent_id"];2249 if ( isset($content_struct['wp_page_parent_id']) ) 2250 $post_parent = $content_struct['wp_page_parent_id']; 2157 2251 2158 2252 // Only set the menu_order if it was provided. 2159 if ( isset($content_struct[ "wp_page_order"]) )2160 $menu_order = $content_struct[ "wp_page_order"];2253 if ( isset($content_struct['wp_page_order']) ) 2254 $menu_order = $content_struct['wp_page_order']; 2161 2255 2162 2256 $post_author = $user->ID; 2163 2257 2164 2258 // If an author id was provided then use it instead. 2165 if ( isset($content_struct[ "wp_author_id"]) && ($user->ID != $content_struct["wp_author_id"]) ) {2259 if ( isset($content_struct['wp_author_id']) && ($user->ID != $content_struct['wp_author_id']) ) { 2166 2260 switch ( $post_type ) { 2167 2261 case "post": 2168 if ( !current_user_can( "edit_others_posts") )2169 return(new IXR_Error(401, __( "You are not allowed to post as this user")));2262 if ( !current_user_can('edit_others_posts') ) 2263 return(new IXR_Error(401, __('You are not allowed to post as this user'))); 2170 2264 break; 2171 2265 case "page": 2172 if ( !current_user_can( "edit_others_pages") )2173 return(new IXR_Error(401, __( "You are not allowed to create pages as this user")));2266 if ( !current_user_can('edit_others_pages') ) 2267 return(new IXR_Error(401, __('You are not allowed to create pages as this user'))); 2174 2268 break; 2175 2269 default: 2176 return(new IXR_Error(401, __( "Invalid post type.")));2270 return(new IXR_Error(401, __('Invalid post type.'))); 2177 2271 break; 2178 2272 } 2179 $post_author = $content_struct[ "wp_author_id"];2273 $post_author = $content_struct['wp_author_id']; 2180 2274 } 2181 2275 … … 2188 2282 switch ( $content_struct["{$post_type}_status"] ) { 2189 2283 case 'draft': 2284 case 'pending': 2190 2285 case 'private': 2191 2286 case 'publish': 2192 2287 $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"];2198 2288 break; 2199 2289 default: … … 2208 2298 $tags_input = isset($content_struct['mt_keywords']) ? $content_struct['mt_keywords'] : null; 2209 2299 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";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'; 2215 2305 break; 2216 case "open":2217 $comment_status = "open";2306 case 'open': 2307 $comment_status = 'open'; 2218 2308 break; 2219 2309 default: 2220 $comment_status = get_option( "default_comment_status");2310 $comment_status = get_option('default_comment_status'); 2221 2311 break; 2222 2312 } 2223 2313 } else { 2224 switch ( (int) $content_struct[ "mt_allow_comments"] ) {2314 switch ( (int) $content_struct['mt_allow_comments'] ) { 2225 2315 case 0: 2226 2316 case 2: 2227 $comment_status = "closed";2317 $comment_status = 'closed'; 2228 2318 break; 2229 2319 case 1: 2230 $comment_status = "open";2320 $comment_status = 'open'; 2231 2321 break; 2232 2322 default: 2233 $comment_status = get_option( "default_comment_status");2323 $comment_status = get_option('default_comment_status'); 2234 2324 break; 2235 2325 } 2236 2326 } 2237 2327 } else { 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"]) ) {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']) ) { 2243 2333 switch ( $content_struct['mt_allow_pings'] ) { 2244 case "closed":2245 $ping_status = "closed";2334 case 'closed': 2335 $ping_status = 'closed'; 2246 2336 break; 2247 case "open":2248 $ping_status = "open";2337 case 'open': 2338 $ping_status = 'open'; 2249 2339 break; 2250 2340 default: 2251 $ping_status = get_option( "default_ping_status");2341 $ping_status = get_option('default_ping_status'); 2252 2342 break; 2253 2343 } 2254 2344 } else { 2255 switch ( (int) $content_struct[ "mt_allow_pings"] ) {2345 switch ( (int) $content_struct['mt_allow_pings'] ) { 2256 2346 case 0: 2257 $ping_status = "closed";2347 $ping_status = 'closed'; 2258 2348 break; 2259 2349 case 1: 2260 $ping_status = "open";2350 $ping_status = 'open'; 2261 2351 break; 2262 2352 default: 2263 $ping_status = get_option( "default_ping_status");2353 $ping_status = get_option('default_ping_status'); 2264 2354 break; 2265 2355 } 2266 2356 } 2267 2357 } else { 2268 $ping_status = get_option( "default_ping_status");2358 $ping_status = get_option('default_ping_status'); 2269 2359 } 2270 2360 2271 2361 if ( $post_more ) 2272 $post_content = $post_content . "<!--more-->". $post_more;2362 $post_content = $post_content . '<!--more-->' . $post_more; 2273 2363 2274 2364 $to_ping = null; … … 2457 2547 // created (which was the old behavior). 2458 2548 if ( empty($postdata["ID"]) ) 2459 return(new IXR_Error(404, __( "Invalid post ID.")));2549 return(new IXR_Error(404, __('Invalid post ID.'))); 2460 2550 2461 2551 $this->escape($postdata); … … 2464 2554 // Let WordPress manage slug if none was provided. 2465 2555 $post_name = ""; 2466 if ( isset($content_struct["wp_slug"]) ) 2467 $post_name = $content_struct["wp_slug"]; 2556 $post_name = $postdata['post_name']; 2557 if ( isset($content_struct['wp_slug']) ) 2558 $post_name = $content_struct['wp_slug']; 2468 2559 2469 2560 // Only use a password if one was given. 2470 if ( isset($content_struct[ "wp_password"]) )2471 $post_password = $content_struct[ "wp_password"];2561 if ( isset($content_struct['wp_password']) ) 2562 $post_password = $content_struct['wp_password']; 2472 2563 2473 2564 // Only set a post parent if one was given. 2474 if ( isset($content_struct[ "wp_page_parent_id"]) )2475 $post_parent = $content_struct[ "wp_page_parent_id"];2565 if ( isset($content_struct['wp_page_parent_id']) ) 2566 $post_parent = $content_struct['wp_page_parent_id']; 2476 2567 2477 2568 // Only set the menu_order if it was given. 2478 if ( isset($content_struct[ "wp_page_order"]) )2479 $menu_order = $content_struct[ "wp_page_order"];2480 2481 $post_author = $postdata[ "post_author"];2569 if ( isset($content_struct['wp_page_order']) ) 2570 $menu_order = $content_struct['wp_page_order']; 2571 2572 $post_author = $postdata['post_author']; 2482 2573 2483 2574 // Only set the post_author if one is set. 2484 if ( isset($content_struct[ "wp_author_id"]) && ($user->ID != $content_struct["wp_author_id"]) ) {2575 if ( isset($content_struct['wp_author_id']) && ($user->ID != $content_struct['wp_author_id']) ) { 2485 2576 switch ( $post_type ) { 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.")));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.'))); 2489 2580 break; 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.")));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.'))); 2493 2584 break; 2494 2585 default: 2495 return(new IXR_Error(401, __( "Invalid post type.")));2586 return(new IXR_Error(401, __('Invalid post type.'))); 2496 2587 break; 2497 2588 } 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";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'; 2506 2597 break; 2507 case "open":2508 $comment_status = "open";2598 case 'open': 2599 $comment_status = 'open'; 2509 2600 break; 2510 2601 default: 2511 $comment_status = get_option( "default_comment_status");2602 $comment_status = get_option('default_comment_status'); 2512 2603 break; 2513 2604 } 2514 2605 } else { 2515 switch ( (int) $content_struct[ "mt_allow_comments"] ) {2606 switch ( (int) $content_struct['mt_allow_comments'] ) { 2516 2607 case 0: 2517 2608 case 2: 2518 $comment_status = "closed";2609 $comment_status = 'closed'; 2519 2610 break; 2520 2611 case 1: 2521 $comment_status = "open";2612 $comment_status = 'open'; 2522 2613 break; 2523 2614 default: 2524 $comment_status = get_option( "default_comment_status");2615 $comment_status = get_option('default_comment_status'); 2525 2616 break; 2526 2617 } … … 2528 2619 } 2529 2620 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";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'; 2535 2626 break; 2536 case "open":2537 $ping_status = "open";2627 case 'open': 2628 $ping_status = 'open'; 2538 2629 break; 2539 2630 default: 2540 $ping_status = get_option( "default_ping_status");2631 $ping_status = get_option('default_ping_status'); 2541 2632 break; 2542 2633 } … … 2544 2635 switch ( (int) $content_struct["mt_allow_pings"] ) { 2545 2636 case 0: 2546 $ping_status = "closed";2637 $ping_status = 'closed'; 2547 2638 break; 2548 2639 case 1: 2549 $ping_status = "open";2640 $ping_status = 'open'; 2550 2641 break; 2551 2642 default: 2552 $ping_status = get_option( "default_ping_status");2643 $ping_status = get_option('default_ping_status'); 2553 2644 break; 2554 2645 } … … 2576 2667 switch( $content_struct["{$post_type}_status"] ) { 2577 2668 case 'draft': 2669 case 'pending': 2578 2670 case 'private': 2579 2671 case 'publish': 2580 2672 $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"];2586 2673 break; 2587 2674 default: … … 2971 3058 } 2972 3059 2973 if ( $upload_err = apply_filters( "pre_upload_error", false ) )3060 if ( $upload_err = apply_filters( 'pre_upload_error', false ) ) 2974 3061 return new IXR_Error(500, $upload_err); 2975 3062 2976 if ( !empty($data[ "overwrite"]) && ($data["overwrite"] == true) ) {3063 if ( !empty($data['overwrite']) && ($data['overwrite'] == true) ) { 2977 3064 // Get postmeta info on the object. 2978 3065 $old_file = $wpdb->get_row(" … … 2988 3075 // Make sure the new name is different by pre-pending the 2989 3076 // previous post id. 2990 $filename = preg_replace( "/^wpid\d+-/", "", $name);3077 $filename = preg_replace('/^wpid\d+-/', '', $name); 2991 3078 $name = "wpid{$old_file->ID}-{$filename}"; 2992 3079 } … … 3069 3156 'postid' => (string) $entry['ID'], 3070 3157 'title' => $entry['post_title'], 3158 'post_status' => $entry['post_status'], 3071 3159 'date_created_gmt' => new IXR_Date($post_date_gmt) 3072 3160 );
Note: See TracChangeset
for help on using the changeset viewer.