WP hooks navigation: Home/browse • Actions index • Filters index
To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).
The best way to understand what a hook does is to look at where it occurs in the source code.
do_action( "hook_name" )
apply_filters( "hook_name", "what_to_filter" )
.Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.
This hook occurs 39 times in this file.
Line | Code |
---|---|
329 |
|
330 | $this->escape( $args ); |
331 |
|
332 | $username = $args[0]; |
333 | $password = $args[1]; |
334 |
|
335 | if( !$this->login_pass_ok( $username, $password ) ) |
336 | return $this->error; |
337 |
|
338 | do_action( 'xmlrpc_call', 'wp.getUsersBlogs' ); |
339 |
|
340 | $user = set_current_user( 0, $username ); |
341 |
|
342 | $blogs = (array) get_blogs_of_user( $user->ID ); |
343 | $struct = array( ); |
344 |
|
345 | foreach( $blogs as $blog ) { |
346 | // Don't include blogs that aren't hosted at this site |
347 | if( $blog->site_id != 1 ) |
Line | Code |
377 |
|
378 | if(!$this->login_pass_ok($username, $password)) { |
379 | return($this->error); |
380 | } |
381 |
|
382 | set_current_user( 0, $username ); |
383 | if( !current_user_can( 'edit_page', $page_id ) ) |
384 | return new IXR_Error( 401, __( 'Sorry, you can not edit this page.' ) ); |
385 |
|
386 | do_action('xmlrpc_call', 'wp.getPage'); |
387 |
|
388 | // Lookup page info. |
389 | $page = get_page($page_id); |
390 |
|
391 | // If we found the page then format the data. |
392 | if($page->ID && ($page->post_type == "page")) { |
393 | // Get all of the page content and link. |
394 | $full_page = get_extended($page->post_content); |
395 | $link = post_permalink($page->ID); |
Line | Code |
470 |
|
471 | if(!$this->login_pass_ok($username, $password)) { |
472 | return($this->error); |
473 | } |
474 |
|
475 | set_current_user( 0, $username ); |
476 | if( !current_user_can( 'edit_pages' ) ) |
477 | return new IXR_Error( 401, __( 'Sorry, you can not edit pages.' ) ); |
478 |
|
479 | do_action('xmlrpc_call', 'wp.getPages'); |
480 |
|
481 | // Lookup info on pages. |
482 | $pages = get_pages(); |
483 | $num_pages = count($pages); |
484 |
|
485 | // If we have pages, put together their info. |
486 | if($num_pages >= 1) { |
487 | $pages_struct = array(); |
488 |
|
Line | Code |
510 | $username = $this->escape($args[1]); |
511 | $password = $this->escape($args[2]); |
512 | $page = $args[3]; |
513 | $publish = $args[4]; |
514 |
|
515 | if(!$this->login_pass_ok($username, $password)) { |
516 | return($this->error); |
517 | } |
518 |
|
519 | do_action('xmlrpc_call', 'wp.newPage'); |
520 |
|
521 | // Set the user context and check if they are allowed |
522 | // to add new pages. |
523 | $user = set_current_user(0, $username); |
524 | if(!current_user_can("publish_pages")) { |
525 | return(new IXR_Error(401, __("Sorry, you can not add new pages."))); |
526 | } |
527 |
|
528 | // Mark this as content for a page. |
Line | Code |
542 | $blog_id = (int) $args[0]; |
543 | $username = $args[1]; |
544 | $password = $args[2]; |
545 | $page_id = (int) $args[3]; |
546 |
|
547 | if(!$this->login_pass_ok($username, $password)) { |
548 | return($this->error); |
549 | } |
550 |
|
551 | do_action('xmlrpc_call', 'wp.deletePage'); |
552 |
|
553 | // Get the current page based on the page_id and |
554 | // make sure it is a page and not a post. |
555 | $actual_page = wp_get_single_post($page_id, ARRAY_A); |
556 | if( |
557 | !$actual_page |
558 | || ($actual_page["post_type"] != "page") |
559 | ) { |
560 | return(new IXR_Error(404, __("Sorry, no such page."))); |
Line | Code |
586 | $username = $this->escape($args[2]); |
587 | $password = $this->escape($args[3]); |
588 | $content = $args[4]; |
589 | $publish = $args[5]; |
590 |
|
591 | if(!$this->login_pass_ok($username, $password)) { |
592 | return($this->error); |
593 | } |
594 |
|
595 | do_action('xmlrpc_call', 'wp.editPage'); |
596 |
|
597 | // Get the page data and make sure it is a page. |
598 | $actual_page = wp_get_single_post($page_id, ARRAY_A); |
599 | if( |
600 | !$actual_page |
601 | || ($actual_page["post_type"] != "page") |
602 | ) { |
603 | return(new IXR_Error(404, __("Sorry, no such page."))); |
604 | } |
Line | Code |
640 |
|
641 | if(!$this->login_pass_ok($username, $password)) { |
642 | return($this->error); |
643 | } |
644 |
|
645 | set_current_user( 0, $username ); |
646 | if( !current_user_can( 'edit_pages' ) ) |
647 | return new IXR_Error( 401, __( 'Sorry, you can not edit pages.' ) ); |
648 |
|
649 | do_action('xmlrpc_call', 'wp.getPageList'); |
650 |
|
651 | // Get list of pages ids and titles |
652 | $page_list = $wpdb->get_results(" |
653 | SELECT ID page_id, |
654 | post_title page_title, |
655 | post_parent page_parent_id, |
656 | post_date_gmt, |
657 | post_date |
658 | FROM {$wpdb->posts} |
Line | Code |
691 | if(!$this->login_pass_ok($username, $password)) { |
692 | return($this->error); |
693 | } |
694 |
|
695 | set_current_user(0, $username); |
696 | if(!current_user_can("edit_posts")) { |
697 | return(new IXR_Error(401, __("Sorry, you can not edit posts on this blog."))); |
698 | } |
699 |
|
700 | do_action('xmlrpc_call', 'wp.getAuthors'); |
701 |
|
702 | $authors = array(); |
703 | foreach( (array) get_users_of_blog() as $row ) { |
704 | $authors[] = array( |
705 | "user_id" => $row->user_id, |
706 | "user_login" => $row->user_login, |
707 | "display_name" => $row->display_name |
708 | ); |
709 | } |
Line | Code |
721 | $blog_id = (int) $args[0]; |
722 | $username = $args[1]; |
723 | $password = $args[2]; |
724 | $category = $args[3]; |
725 |
|
726 | if(!$this->login_pass_ok($username, $password)) { |
727 | return($this->error); |
728 | } |
729 |
|
730 | do_action('xmlrpc_call', 'wp.newCategory'); |
731 |
|
732 | // Set the user context and make sure they are |
733 | // allowed to add a category. |
734 | set_current_user(0, $username); |
735 | if(!current_user_can("manage_categories")) { |
736 | return(new IXR_Error(401, __("Sorry, you do not have the right to add a category."))); |
737 | } |
738 |
|
739 | // If no slug was provided make it empty so that |
Line | Code |
777 | $blog_id = (int) $args[0]; |
778 | $username = $args[1]; |
779 | $password = $args[2]; |
780 | $category_id = (int) $args[3]; |
781 |
|
782 | if( !$this->login_pass_ok( $username, $password ) ) { |
783 | return $this->error; |
784 | } |
785 |
|
786 | do_action('xmlrpc_call', 'wp.deleteCategory'); |
787 |
|
788 | set_current_user(0, $username); |
789 | if( !current_user_can("manage_categories") ) { |
790 | return new IXR_Error( 401, __( "Sorry, you do not have the right to delete a category." ) ); |
791 | } |
792 |
|
793 | return wp_delete_category( $category_id ); |
794 | } |
795 |
|
Line | Code |
809 |
|
810 | if(!$this->login_pass_ok($username, $password)) { |
811 | return($this->error); |
812 | } |
813 |
|
814 | set_current_user(0, $username); |
815 | if( !current_user_can( 'edit_posts' ) ) |
816 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts to this blog in order to view categories.' ) ); |
817 |
|
818 | do_action('xmlrpc_call', 'wp.suggestCategories'); |
819 |
|
820 | $category_suggestions = array(); |
821 | $args = array('get' => 'all', 'number' => $max_results, 'name__like' => $category); |
822 | foreach ( (array) get_categories($args) as $cat ) { |
823 | $category_suggestions[] = array( |
824 | "category_id" => $cat->cat_ID, |
825 | "category_name" => $cat->cat_name |
826 | ); |
827 | } |
Line | Code |
840 | if( !$this->login_pass_ok( $username, $password ) ) { |
841 | return $this->error; |
842 | } |
843 |
|
844 | set_current_user( 0, $username ); |
845 | if( !current_user_can( 'edit_posts' ) ) { |
846 | return new IXR_Error( 403, __( 'You are not allowed access to details about comments.' ) ); |
847 | } |
848 |
|
849 | do_action('xmlrpc_call', 'wp.getCommentCount'); |
850 |
|
851 | $count = wp_count_comments( $post_id ); |
852 | return array( |
853 | "approved" => $count->approved, |
854 | "awaiting_moderation" => $count->moderated, |
855 | "spam" => $count->spam, |
856 | "total_comments" => $count->total_comments |
857 | ); |
858 | } |
Line | Code |
868 | if( !$this->login_pass_ok( $username, $password ) ) { |
869 | return $this->error; |
870 | } |
871 |
|
872 | set_current_user( 0, $username ); |
873 | if( !current_user_can( 'edit_posts' ) ) { |
874 | return new IXR_Error( 403, __( 'You are not allowed access to details about this blog.' ) ); |
875 | } |
876 |
|
877 | do_action('xmlrpc_call', 'wp.getPostStatusList'); |
878 |
|
879 | return get_post_statuses( ); |
880 | } |
881 |
|
882 |
|
883 | function wp_getPageStatusList( $args ) { |
884 | $this->escape( $args ); |
885 |
|
886 | $blog_id = (int) $args[0]; |
Line | Code |
890 | if( !$this->login_pass_ok( $username, $password ) ) { |
891 | return $this->error; |
892 | } |
893 |
|
894 | set_current_user( 0, $username ); |
895 | if( !current_user_can( 'edit_posts' ) ) { |
896 | return new IXR_Error( 403, __( 'You are not allowed access to details about this blog.' ) ); |
897 | } |
898 |
|
899 | do_action('xmlrpc_call', 'wp.getPageStatusList'); |
900 |
|
901 | return get_page_statuses( ); |
902 | } |
903 |
|
904 | function wp_getPageTemplates( $args ) { |
905 | $this->escape( $args ); |
906 |
|
907 | $blog_id = (int) $args[0]; |
908 | $username = $args[1]; |
Line | Code |
1006 | $this->escape($args); |
1007 |
|
1008 | $user_login = $args[1]; |
1009 | $user_pass = $args[2]; |
1010 |
|
1011 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
1012 | return $this->error; |
1013 | } |
1014 |
|
1015 | do_action('xmlrpc_call', 'blogger.getUsersBlogs'); |
1016 |
|
1017 | set_current_user(0, $user_login); |
1018 | $is_admin = current_user_can('manage_options'); |
1019 |
|
1020 | $struct = array( |
1021 | 'isAdmin' => $is_admin, |
1022 | 'url' => get_option('home') . '/', |
1023 | 'blogid' => '1', |
1024 | 'blogName' => get_option('blogname'), |
Line | Code |
1039 |
|
1040 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
1041 | return $this->error; |
1042 | } |
1043 |
|
1044 | set_current_user( 0, $user_login ); |
1045 | if( !current_user_can( 'edit_posts' ) ) |
1046 | return new IXR_Error( 401, __( 'Sorry, you do not have access to user data on this blog.' ) ); |
1047 |
|
1048 | do_action('xmlrpc_call', 'blogger.getUserInfo'); |
1049 |
|
1050 | $user_data = get_userdatabylogin($user_login); |
1051 |
|
1052 | $struct = array( |
1053 | 'nickname' => $user_data->nickname, |
1054 | 'userid' => $user_data->ID, |
1055 | 'url' => $user_data->user_url, |
1056 | 'lastname' => $user_data->last_name, |
1057 | 'firstname' => $user_data->first_name |
Line | Code |
1072 |
|
1073 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
1074 | return $this->error; |
1075 | } |
1076 |
|
1077 | set_current_user( 0, $user_login ); |
1078 | if( !current_user_can( 'edit_post', $post_ID ) ) |
1079 | return new IXR_Error( 401, __( 'Sorry, you can not edit this post.' ) ); |
1080 |
|
1081 | do_action('xmlrpc_call', 'blogger.getPost'); |
1082 |
|
1083 | $post_data = wp_get_single_post($post_ID, ARRAY_A); |
1084 |
|
1085 | $categories = implode(',', wp_get_post_categories($post_ID)); |
1086 |
|
1087 | $content = '<title>'.stripslashes($post_data['post_title']).'</title>'; |
1088 | $content .= '<category>'.$categories.'</category>'; |
1089 | $content .= stripslashes($post_data['post_content']); |
1090 |
|
Line | Code |
1107 | $blog_ID = (int) $args[1]; /* though we don't use it yet */ |
1108 | $user_login = $args[2]; |
1109 | $user_pass = $args[3]; |
1110 | $num_posts = $args[4]; |
1111 |
|
1112 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
1113 | return $this->error; |
1114 | } |
1115 |
|
1116 | do_action('xmlrpc_call', 'blogger.getRecentPosts'); |
1117 |
|
1118 | $posts_list = wp_get_recent_posts($num_posts); |
1119 |
|
1120 | set_current_user( 0, $user_login ); |
1121 |
|
1122 | if (!$posts_list) { |
1123 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
1124 | return $this->error; |
1125 | } |
Line | Code |
1161 | $blog_ID = (int) $args[1]; |
1162 | $user_login = $args[2]; |
1163 | $user_pass = $args[3]; |
1164 | $template = $args[4]; /* could be 'main' or 'archiveIndex', but we don't use it */ |
1165 |
|
1166 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
1167 | return $this->error; |
1168 | } |
1169 |
|
1170 | do_action('xmlrpc_call', 'blogger.getTemplate'); |
1171 |
|
1172 | set_current_user(0, $user_login); |
1173 | if ( !current_user_can('edit_themes') ) { |
1174 | return new IXR_Error(401, __('Sorry, this user can not edit the template.')); |
1175 | } |
1176 |
|
1177 | /* warning: here we make the assumption that the blog's URL is on the same server */ |
1178 | $filename = get_option('home') . '/'; |
1179 | $filename = preg_replace('#https?://.+?/#', $_SERVER['DOCUMENT_ROOT'].'/', $filename); |
Line | Code |
1198 | $user_login = $args[2]; |
1199 | $user_pass = $args[3]; |
1200 | $content = $args[4]; |
1201 | $template = $args[5]; /* could be 'main' or 'archiveIndex', but we don't use it */ |
1202 |
|
1203 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
1204 | return $this->error; |
1205 | } |
1206 |
|
1207 | do_action('xmlrpc_call', 'blogger.setTemplate'); |
1208 |
|
1209 | set_current_user(0, $user_login); |
1210 | if ( !current_user_can('edit_themes') ) { |
1211 | return new IXR_Error(401, __('Sorry, this user can not edit the template.')); |
1212 | } |
1213 |
|
1214 | /* warning: here we make the assumption that the blog's URL is on the same server */ |
1215 | $filename = get_option('home') . '/'; |
1216 | $filename = preg_replace('#https?://.+?/#', $_SERVER['DOCUMENT_ROOT'].'/', $filename); |
Line | Code |
1235 | $user_login = $args[2]; |
1236 | $user_pass = $args[3]; |
1237 | $content = $args[4]; |
1238 | $publish = $args[5]; |
1239 |
|
1240 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
1241 | return $this->error; |
1242 | } |
1243 |
|
1244 | do_action('xmlrpc_call', 'blogger.newPost'); |
1245 |
|
1246 | $cap = ($publish) ? 'publish_posts' : 'edit_posts'; |
1247 | $user = set_current_user(0, $user_login); |
1248 | if ( !current_user_can($cap) ) |
1249 | return new IXR_Error(401, __('Sorry, you are not allowed to post on this blog.')); |
1250 |
|
1251 | $post_status = ($publish) ? 'publish' : 'draft'; |
1252 |
|
1253 | $post_author = $user->ID; |
Line | Code |
1284 | $user_login = $args[2]; |
1285 | $user_pass = $args[3]; |
1286 | $content = $args[4]; |
1287 | $publish = $args[5]; |
1288 |
|
1289 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
1290 | return $this->error; |
1291 | } |
1292 |
|
1293 | do_action('xmlrpc_call', 'blogger.editPost'); |
1294 |
|
1295 | $actual_post = wp_get_single_post($post_ID,ARRAY_A); |
1296 |
|
1297 | if (!$actual_post) { |
1298 | return new IXR_Error(404, __('Sorry, no such post.')); |
1299 | } |
1300 |
|
1301 | $this->escape($actual_post); |
1302 |
|
Line | Code |
1333 | $post_ID = (int) $args[1]; |
1334 | $user_login = $args[2]; |
1335 | $user_pass = $args[3]; |
1336 | $publish = $args[4]; |
1337 |
|
1338 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
1339 | return $this->error; |
1340 | } |
1341 |
|
1342 | do_action('xmlrpc_call', 'blogger.deletePost'); |
1343 |
|
1344 | $actual_post = wp_get_single_post($post_ID,ARRAY_A); |
1345 |
|
1346 | if (!$actual_post) { |
1347 | return new IXR_Error(404, __('Sorry, no such post.')); |
1348 | } |
1349 |
|
1350 | set_current_user(0, $user_login); |
1351 | if ( !current_user_can('edit_post', $post_ID) ) |
Line | Code |
1375 | $user_pass = $args[2]; |
1376 | $content_struct = $args[3]; |
1377 | $publish = $args[4]; |
1378 |
|
1379 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
1380 | return $this->error; |
1381 | } |
1382 | $user = set_current_user(0, $user_login); |
1383 |
|
1384 | do_action('xmlrpc_call', 'metaWeblog.newPost'); |
1385 |
|
1386 | $cap = ( $publish ) ? 'publish_posts' : 'edit_posts'; |
1387 | $error_message = __( 'Sorry, you are not allowed to publish posts on this blog.' ); |
1388 | $post_type = 'post'; |
1389 | $page_template = ''; |
1390 | if( !empty( $content_struct['post_type'] ) ) { |
1391 | if( $content_struct['post_type'] == 'page' ) { |
1392 | $cap = ( $publish ) ? 'publish_pages' : 'edit_pages'; |
1393 | $error_message = __( 'Sorry, you are not allowed to publish pages on this blog.' ); |
Line | Code |
1633 | $user_pass = $args[2]; |
1634 | $content_struct = $args[3]; |
1635 | $publish = $args[4]; |
1636 |
|
1637 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
1638 | return $this->error; |
1639 | } |
1640 | $user = set_current_user(0, $user_login); |
1641 |
|
1642 | do_action('xmlrpc_call', 'metaWeblog.editPost'); |
1643 |
|
1644 | $cap = ( $publish ) ? 'publish_posts' : 'edit_posts'; |
1645 | $error_message = __( 'Sorry, you are not allowed to publish posts on this blog.' ); |
1646 | $post_type = 'post'; |
1647 | $page_template = ''; |
1648 | if( !empty( $content_struct['post_type'] ) ) { |
1649 | if( $content_struct['post_type'] == 'page' ) { |
1650 | $cap = ( $publish ) ? 'publish_pages' : 'edit_pages'; |
1651 | $error_message = __( 'Sorry, you are not allowed to publish pages on this blog.' ); |
Line | Code |
1889 |
|
1890 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
1891 | return $this->error; |
1892 | } |
1893 |
|
1894 | set_current_user( 0, $user_login ); |
1895 | if( !current_user_can( 'edit_post', $post_ID ) ) |
1896 | return new IXR_Error( 401, __( 'Sorry, you can not edit this post.' ) ); |
1897 |
|
1898 | do_action('xmlrpc_call', 'metaWeblog.getPost'); |
1899 |
|
1900 | $postdata = wp_get_single_post($post_ID, ARRAY_A); |
1901 |
|
1902 | if ($postdata['post_date'] != '') { |
1903 | $post_date = mysql2date('Ymd\TH:i:s', $postdata['post_date']); |
1904 | $post_date_gmt = mysql2date('Ymd\TH:i:s', $postdata['post_date_gmt']); |
1905 |
|
1906 | $categories = array(); |
1907 | $catids = wp_get_post_categories($post_ID); |
Line | Code |
1972 | $blog_ID = (int) $args[0]; |
1973 | $user_login = $args[1]; |
1974 | $user_pass = $args[2]; |
1975 | $num_posts = (int) $args[3]; |
1976 |
|
1977 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
1978 | return $this->error; |
1979 | } |
1980 |
|
1981 | do_action('xmlrpc_call', 'metaWeblog.getRecentPosts'); |
1982 |
|
1983 | $posts_list = wp_get_recent_posts($num_posts); |
1984 |
|
1985 | if (!$posts_list) { |
1986 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
1987 | return $this->error; |
1988 | } |
1989 |
|
1990 | set_current_user( 0, $user_login ); |
Line | Code |
2074 |
|
2075 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
2076 | return $this->error; |
2077 | } |
2078 |
|
2079 | set_current_user( 0, $user_login ); |
2080 | if( !current_user_can( 'edit_posts' ) ) |
2081 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this blog in order to view categories.' ) ); |
2082 |
|
2083 | do_action('xmlrpc_call', 'metaWeblog.getCategories'); |
2084 |
|
2085 | $categories_struct = array(); |
2086 |
|
2087 | if ( $cats = get_categories('get=all') ) { |
2088 | foreach ( $cats as $cat ) { |
2089 | $struct['categoryId'] = $cat->term_id; |
2090 | $struct['parentId'] = $cat->parent; |
2091 | $struct['description'] = $cat->name; |
2092 | $struct['categoryName'] = $cat->name; |
Line | Code |
2116 | $name = sanitize_file_name( $data['name'] ); |
2117 | $type = $data['type']; |
2118 | $bits = $data['bits']; |
2119 |
|
2120 | logIO('O', '(MW) Received '.strlen($bits).' bytes'); |
2121 |
|
2122 | if ( !$this->login_pass_ok($user_login, $user_pass) ) |
2123 | return $this->error; |
2124 |
|
2125 | do_action('xmlrpc_call', 'metaWeblog.newMediaObject'); |
2126 |
|
2127 | set_current_user(0, $user_login); |
2128 | if ( !current_user_can('upload_files') ) { |
2129 | logIO('O', '(MW) User does not have upload_files capability'); |
2130 | $this->error = new IXR_Error(401, __('You are not allowed to upload files to this site.')); |
2131 | return $this->error; |
2132 | } |
2133 |
|
2134 | if ( $upload_err = apply_filters( "pre_upload_error", false ) ) |
Line | Code |
2190 | $blog_ID = (int) $args[0]; |
2191 | $user_login = $args[1]; |
2192 | $user_pass = $args[2]; |
2193 | $num_posts = (int) $args[3]; |
2194 |
|
2195 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
2196 | return $this->error; |
2197 | } |
2198 |
|
2199 | do_action('xmlrpc_call', 'mt.getRecentPostTitles'); |
2200 |
|
2201 | $posts_list = wp_get_recent_posts($num_posts); |
2202 |
|
2203 | if (!$posts_list) { |
2204 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
2205 | return $this->error; |
2206 | } |
2207 |
|
2208 | set_current_user( 0, $user_login ); |
Line | Code |
2244 |
|
2245 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
2246 | return $this->error; |
2247 | } |
2248 |
|
2249 | set_current_user( 0, $user_login ); |
2250 | if( !current_user_can( 'edit_posts' ) ) |
2251 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this blog in order to view categories.' ) ); |
2252 |
|
2253 | do_action('xmlrpc_call', 'mt.getCategoryList'); |
2254 |
|
2255 | $categories_struct = array(); |
2256 |
|
2257 | if ( $cats = get_categories('hide_empty=0&hierarchical=0') ) { |
2258 | foreach ($cats as $cat) { |
2259 | $struct['categoryId'] = $cat->term_id; |
2260 | $struct['categoryName'] = $cat->name; |
2261 |
|
2262 | $categories_struct[] = $struct; |
Line | Code |
2278 |
|
2279 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
2280 | return $this->error; |
2281 | } |
2282 |
|
2283 | set_current_user( 0, $user_login ); |
2284 | if( !current_user_can( 'edit_post', $post_ID ) ) |
2285 | return new IXR_Error( 401, __( 'Sorry, you can not edit this post.' ) ); |
2286 |
|
2287 | do_action('xmlrpc_call', 'mt.getPostCategories'); |
2288 |
|
2289 | $categories = array(); |
2290 | $catids = wp_get_post_categories(intval($post_ID)); |
2291 | // first listed category will be the primary category |
2292 | $isPrimary = true; |
2293 | foreach($catids as $catid) { |
2294 | $categories[] = array( |
2295 | 'categoryName' => get_cat_name($catid), |
2296 | 'categoryId' => (string) $catid, |
Line | Code |
2311 | $post_ID = (int) $args[0]; |
2312 | $user_login = $args[1]; |
2313 | $user_pass = $args[2]; |
2314 | $categories = $args[3]; |
2315 |
|
2316 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
2317 | return $this->error; |
2318 | } |
2319 |
|
2320 | do_action('xmlrpc_call', 'mt.setPostCategories'); |
2321 |
|
2322 | set_current_user(0, $user_login); |
2323 | if ( !current_user_can('edit_post', $post_ID) ) |
2324 | return new IXR_Error(401, __('Sorry, you can not edit this post.')); |
2325 |
|
2326 | foreach($categories as $cat) { |
2327 | $catids[] = $cat['categoryId']; |
2328 | } |
2329 |
|
2330 | wp_set_post_categories($post_ID, $catids); |
2331 |
|
2332 | return true; |
2333 | } |
2334 |
|
2335 |
|
2336 | /* mt.supportedMethods ...returns an array of methods supported by this server */ |
2337 | function mt_supportedMethods($args) { |
2338 |
|
2339 | do_action('xmlrpc_call', 'mt.supportedMethods'); |
2340 |
|
2341 | $supported_methods = array(); |
2342 | foreach($this->methods as $key=>$value) { |
2343 | $supported_methods[] = $key; |
2344 | } |
2345 |
|
2346 | return $supported_methods; |
2347 | } |
2348 |
|
2349 |
|
2350 | /* mt.supportedTextFilters ...returns an empty array because we don't |
2351 | support per-post text filters yet */ |
2352 | function mt_supportedTextFilters($args) { |
2353 | do_action('xmlrpc_call', 'mt.supportedTextFilters'); |
2354 | return apply_filters('xmlrpc_text_filters', array()); |
2355 | } |
2356 |
|
2357 |
|
2358 | /* mt.getTrackbackPings ...returns trackbacks sent to a given post */ |
2359 | function mt_getTrackbackPings($args) { |
2360 |
|
2361 | global $wpdb; |
2362 |
|
2363 | $post_ID = intval($args); |
2364 |
|
2365 | do_action('xmlrpc_call', 'mt.getTrackbackPings'); |
2366 |
|
2367 | $actual_post = wp_get_single_post($post_ID, ARRAY_A); |
2368 |
|
2369 | if (!$actual_post) { |
2370 | return new IXR_Error(404, __('Sorry, no such post.')); |
2371 | } |
2372 |
|
2373 | $comments = $wpdb->get_results( $wpdb->prepare("SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->comments WHERE comment_post_ID = %d", $post_ID) ); |
2374 |
|
Line | Code |
2400 |
|
2401 | $post_ID = (int) $args[0]; |
2402 | $user_login = $args[1]; |
2403 | $user_pass = $args[2]; |
2404 |
|
2405 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
2406 | return $this->error; |
2407 | } |
2408 |
|
2409 | do_action('xmlrpc_call', 'mt.publishPost'); |
2410 |
|
2411 | set_current_user(0, $user_login); |
2412 | if ( !current_user_can('edit_post', $post_ID) ) |
2413 | return new IXR_Error(401, __('Sorry, you can not edit this post.')); |
2414 |
|
2415 | $postdata = wp_get_single_post($post_ID,ARRAY_A); |
2416 |
|
2417 | $postdata['post_status'] = 'publish'; |
2418 |
|
Line | Code |
2430 |
|
2431 | /* PingBack functions |
2432 | * specs on www.hixie.ch/specs/pingback/pingback |
2433 | */ |
2434 |
|
2435 | /* pingback.ping gets a pingback and registers it */ |
2436 | function pingback_ping($args) { |
2437 | global $wpdb; |
2438 |
|
2439 | do_action('xmlrpc_call', 'pingback.ping'); |
2440 |
|
2441 | $this->escape($args); |
2442 |
|
2443 | $pagelinkedfrom = $args[0]; |
2444 | $pagelinkedto = $args[1]; |
2445 |
|
2446 | $title = ''; |
2447 |
|
2448 | $pagelinkedfrom = str_replace('&', '&', $pagelinkedfrom); |
Line | Code |
2596 |
|
2597 |
|
2598 | /* pingback.extensions.getPingbacks returns an array of URLs |
2599 | that pingbacked the given URL |
2600 | specs on http://www.aquarionics.com/misc/archives/blogite/0198.html */ |
2601 | function pingback_extensions_getPingbacks($args) { |
2602 |
|
2603 | global $wpdb; |
2604 |
|
2605 | do_action('xmlrpc_call', 'pingback.extensions.getPingsbacks'); |
2606 |
|
2607 | $this->escape($args); |
2608 |
|
2609 | $url = $args; |
2610 |
|
2611 | $post_ID = url_to_postid($url); |
2612 | if (!$post_ID) { |
2613 | // We aren't sure that the resource is available and/or pingback enabled |
2614 | return new IXR_Error(33, __('The specified target URL cannot be used as a target. It either doesn\'t exist, or it is not a pingback-enabled resource.')); |