199 'demo.addTwoNumbers' => 'this:addTwoNumbers' |
199 'demo.addTwoNumbers' => 'this:addTwoNumbers' |
200 ); |
200 ); |
201 |
201 |
202 $this->initialise_blog_option_info( ); |
202 $this->initialise_blog_option_info( ); |
203 $this->methods = apply_filters('xmlrpc_methods', $this->methods); |
203 $this->methods = apply_filters('xmlrpc_methods', $this->methods); |
|
204 } |
|
205 |
|
206 function serve_request() { |
204 $this->IXR_Server($this->methods); |
207 $this->IXR_Server($this->methods); |
205 } |
208 } |
206 |
209 |
207 /** |
210 /** |
208 * Test XMLRPC API by saying, "Hello!" to client. |
211 * Test XMLRPC API by saying, "Hello!" to client. |
417 ), |
420 ), |
418 'time_format' => array( |
421 'time_format' => array( |
419 'desc' => __( 'Time Format' ), |
422 'desc' => __( 'Time Format' ), |
420 'readonly' => false, |
423 'readonly' => false, |
421 'option' => 'time_format' |
424 'option' => 'time_format' |
|
425 ), |
|
426 'users_can_register' => array( |
|
427 'desc' => __( 'Allow new users to sign up' ), |
|
428 'readonly' => false, |
|
429 'option' => 'users_can_register' |
422 ) |
430 ) |
423 ); |
431 ); |
424 |
432 |
425 $this->blog_options = apply_filters( 'xmlrpc_blog_options', $this->blog_options ); |
433 $this->blog_options = apply_filters( 'xmlrpc_blog_options', $this->blog_options ); |
426 } |
434 } |
591 $this->escape($args); |
599 $this->escape($args); |
592 |
600 |
593 $blog_id = (int) $args[0]; |
601 $blog_id = (int) $args[0]; |
594 $username = $args[1]; |
602 $username = $args[1]; |
595 $password = $args[2]; |
603 $password = $args[2]; |
596 $num_pages = (int) $args[3]; |
604 $num_pages = isset($args[3]) ? (int) $args[3] : 10; |
597 |
605 |
598 if ( !$user = $this->login($username, $password) ) { |
606 if ( !$user = $this->login($username, $password) ) { |
599 return $this->error; |
607 return $this->error; |
600 } |
608 } |
601 |
609 |
602 if( !current_user_can( 'edit_pages' ) ) |
610 if( !current_user_can( 'edit_pages' ) ) |
603 return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) ); |
611 return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) ); |
604 |
612 |
605 do_action('xmlrpc_call', 'wp.getPages'); |
613 do_action('xmlrpc_call', 'wp.getPages'); |
606 |
614 |
607 $page_limit = 10; |
615 $pages = get_posts( array('post_type' => 'page', 'post_status' => 'any', 'numberposts' => $num_pages) ); |
608 if( isset( $num_pages ) ) { |
|
609 $page_limit = $num_pages; |
|
610 } |
|
611 |
|
612 $pages = get_posts( array('post_type' => 'page', 'post_status' => 'all', 'numberposts' => $page_limit) ); |
|
613 $num_pages = count($pages); |
616 $num_pages = count($pages); |
614 |
617 |
615 // If we have pages, put together their info. |
618 // If we have pages, put together their info. |
616 if($num_pages >= 1) { |
619 if($num_pages >= 1) { |
617 $pages_struct = array(); |
620 $pages_struct = array(); |
1061 |
1064 |
1062 // Format page date. |
1065 // Format page date. |
1063 $comment_date = mysql2date("Ymd\TH:i:s", $comment->comment_date, false); |
1066 $comment_date = mysql2date("Ymd\TH:i:s", $comment->comment_date, false); |
1064 $comment_date_gmt = mysql2date("Ymd\TH:i:s", $comment->comment_date_gmt, false); |
1067 $comment_date_gmt = mysql2date("Ymd\TH:i:s", $comment->comment_date_gmt, false); |
1065 |
1068 |
1066 if ( 0 == $comment->comment_approved ) |
1069 if ( '0' == $comment->comment_approved ) |
1067 $comment_status = 'hold'; |
1070 $comment_status = 'hold'; |
1068 else if ( 'spam' == $comment->comment_approved ) |
1071 else if ( 'spam' == $comment->comment_approved ) |
1069 $comment_status = 'spam'; |
1072 $comment_status = 'spam'; |
1070 else if ( 1 == $comment->comment_approved ) |
1073 else if ( '1' == $comment->comment_approved ) |
1071 $comment_status = 'approve'; |
1074 $comment_status = 'approve'; |
1072 else |
1075 else |
1073 $comment_status = $comment->comment_approved; |
1076 $comment_status = $comment->comment_approved; |
1074 |
1077 |
1075 $link = get_comment_link($comment); |
1078 $link = get_comment_link($comment); |
1562 if( !current_user_can( 'manage_options' ) ) |
1565 if( !current_user_can( 'manage_options' ) ) |
1563 return new IXR_Error( 403, __( 'You are not allowed to update options.' ) ); |
1566 return new IXR_Error( 403, __( 'You are not allowed to update options.' ) ); |
1564 |
1567 |
1565 foreach( $options as $o_name => $o_value ) { |
1568 foreach( $options as $o_name => $o_value ) { |
1566 $option_names[] = $o_name; |
1569 $option_names[] = $o_name; |
1567 if( empty( $o_value ) ) |
|
1568 continue; |
|
1569 |
|
1570 if( !array_key_exists( $o_name, $this->blog_options ) ) |
1570 if( !array_key_exists( $o_name, $this->blog_options ) ) |
1571 continue; |
1571 continue; |
1572 |
1572 |
1573 if( $this->blog_options[$o_name]['readonly'] == true ) |
1573 if( $this->blog_options[$o_name]['readonly'] == true ) |
1574 continue; |
1574 continue; |
2090 } |
2090 } |
2091 $post_author = $content_struct["wp_author_id"]; |
2091 $post_author = $content_struct["wp_author_id"]; |
2092 } |
2092 } |
2093 |
2093 |
2094 $post_title = $content_struct['title']; |
2094 $post_title = $content_struct['title']; |
2095 $post_content = apply_filters( 'content_save_pre', $content_struct['description'] ); |
2095 $post_content = $content_struct['description']; |
2096 |
2096 |
2097 $post_status = $publish ? 'publish' : 'draft'; |
2097 $post_status = $publish ? 'publish' : 'draft'; |
2098 |
2098 |
2099 if( isset( $content_struct["{$post_type}_status"] ) ) { |
2099 if( isset( $content_struct["{$post_type}_status"] ) ) { |
2100 switch( $content_struct["{$post_type}_status"] ) { |
2100 switch( $content_struct["{$post_type}_status"] ) { |
2280 */ |
2280 */ |
2281 function attach_uploads( $post_ID, $post_content ) { |
2281 function attach_uploads( $post_ID, $post_content ) { |
2282 global $wpdb; |
2282 global $wpdb; |
2283 |
2283 |
2284 // find any unattached files |
2284 // find any unattached files |
2285 $attachments = $wpdb->get_results( "SELECT ID, guid FROM {$wpdb->posts} WHERE post_parent = '-1' AND post_type = 'attachment'" ); |
2285 $attachments = $wpdb->get_results( "SELECT ID, guid FROM {$wpdb->posts} WHERE post_parent = '0' AND post_type = 'attachment'" ); |
2286 if( is_array( $attachments ) ) { |
2286 if( is_array( $attachments ) ) { |
2287 foreach( $attachments as $file ) { |
2287 foreach( $attachments as $file ) { |
2288 if( strpos( $post_content, $file->guid ) !== false ) { |
2288 if( strpos( $post_content, $file->guid ) !== false ) { |
2289 $wpdb->update($wpdb->posts, array('post_parent' => $post_ID), array('ID' => $file->ID) ); |
2289 $wpdb->update($wpdb->posts, array('post_parent' => $post_ID), array('ID' => $file->ID) ); |
2290 } |
2290 } |
2457 } |
2457 } |
2458 } |
2458 } |
2459 } |
2459 } |
2460 |
2460 |
2461 $post_title = $content_struct['title']; |
2461 $post_title = $content_struct['title']; |
2462 $post_content = apply_filters( 'content_save_pre', $content_struct['description'] ); |
2462 $post_content = $content_struct['description']; |
2463 $catnames = $content_struct['categories']; |
2463 $catnames = $content_struct['categories']; |
2464 |
2464 |
2465 $post_category = array(); |
2465 $post_category = array(); |
2466 |
2466 |
2467 if (is_array($catnames)) { |
2467 if (is_array($catnames)) { |
2887 $errorString = sprintf(__('Could not write file %1$s (%2$s)'), $name, $upload['error']); |
2887 $errorString = sprintf(__('Could not write file %1$s (%2$s)'), $name, $upload['error']); |
2888 logIO('O', '(MW) ' . $errorString); |
2888 logIO('O', '(MW) ' . $errorString); |
2889 return new IXR_Error(500, $errorString); |
2889 return new IXR_Error(500, $errorString); |
2890 } |
2890 } |
2891 // Construct the attachment array |
2891 // Construct the attachment array |
2892 // attach to post_id -1 |
2892 // attach to post_id 0 |
2893 $post_id = -1; |
2893 $post_id = 0; |
2894 $attachment = array( |
2894 $attachment = array( |
2895 'post_title' => $name, |
2895 'post_title' => $name, |
2896 'post_content' => '', |
2896 'post_content' => '', |
2897 'post_type' => 'attachment', |
2897 'post_type' => 'attachment', |
2898 'post_parent' => $post_id, |
2898 'post_parent' => $post_id, |