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 38 times in this file.
Line | Code |
---|---|
231 |
|
232 | if(!$this->login_pass_ok($username, $password)) { |
233 | return($this->error); |
234 | } |
235 |
|
236 | set_current_user( 0, $username ); |
237 | if( !current_user_can( 'edit_page', $page_id ) ) |
238 | return new IXR_Error( 401, __( 'Sorry, you can not edit this page.' ) ); |
239 |
|
240 | do_action('xmlrpc_call', 'wp.getPage'); |
241 |
|
242 | // Lookup page info. |
243 | $page = get_page($page_id); |
244 |
|
245 | // If we found the page then format the data. |
246 | if($page->ID && ($page->post_type == "page")) { |
247 | // Get all of the page content and link. |
248 | $full_page = get_extended($page->post_content); |
249 | $link = post_permalink($page->ID); |
Line | Code |
319 |
|
320 | if(!$this->login_pass_ok($username, $password)) { |
321 | return($this->error); |
322 | } |
323 |
|
324 | set_current_user( 0, $username ); |
325 | if( !current_user_can( 'edit_pages' ) ) |
326 | return new IXR_Error( 401, __( 'Sorry, you can not edit pages.' ) ); |
327 |
|
328 | do_action('xmlrpc_call', 'wp.getPages'); |
329 |
|
330 | // Lookup info on pages. |
331 | $pages = get_pages(); |
332 | $num_pages = count($pages); |
333 |
|
334 | // If we have pages, put together their info. |
335 | if($num_pages >= 1) { |
336 | $pages_struct = array(); |
337 |
|
Line | Code |
359 | $username = $this->escape($args[1]); |
360 | $password = $this->escape($args[2]); |
361 | $page = $args[3]; |
362 | $publish = $args[4]; |
363 |
|
364 | if(!$this->login_pass_ok($username, $password)) { |
365 | return($this->error); |
366 | } |
367 |
|
368 | do_action('xmlrpc_call', 'wp.newPage'); |
369 |
|
370 | // Set the user context and check if they are allowed |
371 | // to add new pages. |
372 | $user = set_current_user(0, $username); |
373 | if(!current_user_can("publish_pages")) { |
374 | return(new IXR_Error(401, __("Sorry, you can not add new pages."))); |
375 | } |
376 |
|
377 | // Mark this as content for a page. |
Line | Code |
391 | $blog_id = (int) $args[0]; |
392 | $username = $args[1]; |
393 | $password = $args[2]; |
394 | $page_id = (int) $args[3]; |
395 |
|
396 | if(!$this->login_pass_ok($username, $password)) { |
397 | return($this->error); |
398 | } |
399 |
|
400 | do_action('xmlrpc_call', 'wp.deletePage'); |
401 |
|
402 | // Get the current page based on the page_id and |
403 | // make sure it is a page and not a post. |
404 | $actual_page = wp_get_single_post($page_id, ARRAY_A); |
405 | if( |
406 | !$actual_page |
407 | || ($actual_page["post_type"] != "page") |
408 | ) { |
409 | return(new IXR_Error(404, __("Sorry, no such page."))); |
Line | Code |
435 | $username = $this->escape($args[2]); |
436 | $password = $this->escape($args[3]); |
437 | $content = $args[4]; |
438 | $publish = $args[5]; |
439 |
|
440 | if(!$this->login_pass_ok($username, $password)) { |
441 | return($this->error); |
442 | } |
443 |
|
444 | do_action('xmlrpc_call', 'wp.editPage'); |
445 |
|
446 | // Get the page data and make sure it is a page. |
447 | $actual_page = wp_get_single_post($page_id, ARRAY_A); |
448 | if( |
449 | !$actual_page |
450 | || ($actual_page["post_type"] != "page") |
451 | ) { |
452 | return(new IXR_Error(404, __("Sorry, no such page."))); |
453 | } |
Line | Code |
489 |
|
490 | if(!$this->login_pass_ok($username, $password)) { |
491 | return($this->error); |
492 | } |
493 |
|
494 | set_current_user( 0, $username ); |
495 | if( !current_user_can( 'edit_pages' ) ) |
496 | return new IXR_Error( 401, __( 'Sorry, you can not edit pages.' ) ); |
497 |
|
498 | do_action('xmlrpc_call', 'wp.getPageList'); |
499 |
|
500 | // Get list of pages ids and titles |
501 | $page_list = $wpdb->get_results(" |
502 | SELECT ID page_id, |
503 | post_title page_title, |
504 | post_parent page_parent_id, |
505 | post_date_gmt, |
506 | post_date |
507 | FROM {$wpdb->posts} |
Line | Code |
540 | if(!$this->login_pass_ok($username, $password)) { |
541 | return($this->error); |
542 | } |
543 |
|
544 | set_current_user(0, $username); |
545 | if(!current_user_can("edit_posts")) { |
546 | return(new IXR_Error(401, __("Sorry, you can not edit posts on this blog."))); |
547 | } |
548 |
|
549 | do_action('xmlrpc_call', 'wp.getAuthors'); |
550 |
|
551 | $authors = array(); |
552 | foreach( (array) get_users_of_blog() as $row ) { |
553 | $authors[] = array( |
554 | "user_id" => $row->user_id, |
555 | "user_login" => $row->user_login, |
556 | "display_name" => $row->display_name |
557 | ); |
558 | } |
Line | Code |
570 | $blog_id = (int) $args[0]; |
571 | $username = $args[1]; |
572 | $password = $args[2]; |
573 | $category = $args[3]; |
574 |
|
575 | if(!$this->login_pass_ok($username, $password)) { |
576 | return($this->error); |
577 | } |
578 |
|
579 | do_action('xmlrpc_call', 'wp.newCategory'); |
580 |
|
581 | // Set the user context and make sure they are |
582 | // allowed to add a category. |
583 | set_current_user(0, $username); |
584 | if(!current_user_can("manage_categories")) { |
585 | return(new IXR_Error(401, __("Sorry, you do not have the right to add a category."))); |
586 | } |
587 |
|
588 | // If no slug was provided make it empty so that |
Line | Code |
626 | $blog_id = (int) $args[0]; |
627 | $username = $args[1]; |
628 | $password = $args[2]; |
629 | $category_id = (int) $args[3]; |
630 |
|
631 | if( !$this->login_pass_ok( $username, $password ) ) { |
632 | return $this->error; |
633 | } |
634 |
|
635 | do_action('xmlrpc_call', 'wp.deleteCategory'); |
636 |
|
637 | set_current_user(0, $username); |
638 | if( !current_user_can("manage_categories") ) { |
639 | return new IXR_Error( 401, __( "Sorry, you do not have the right to delete a category." ) ); |
640 | } |
641 |
|
642 | return wp_delete_category( $category_id ); |
643 | } |
644 |
|
Line | Code |
658 |
|
659 | if(!$this->login_pass_ok($username, $password)) { |
660 | return($this->error); |
661 | } |
662 |
|
663 | set_current_user(0, $username); |
664 | if( !current_user_can( 'edit_posts' ) ) |
665 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts to this blog in order to view categories.' ) ); |
666 |
|
667 | do_action('xmlrpc_call', 'wp.suggestCategories'); |
668 |
|
669 | $category_suggestions = array(); |
670 | $args = array('get' => 'all', 'number' => $max_results, 'name__like' => $category); |
671 | foreach ( (array) get_categories($args) as $cat ) { |
672 | $category_suggestions[] = array( |
673 | "category_id" => $cat->cat_ID, |
674 | "category_name" => $cat->cat_name |
675 | ); |
676 | } |
Line | Code |
689 | if( !$this->login_pass_ok( $username, $password ) ) { |
690 | return new IXR_Error( 403, __( 'Bad login/pass combination.' ) ); |
691 | } |
692 |
|
693 | set_current_user( 0, $username ); |
694 | if( !current_user_can( 'edit_posts' ) ) { |
695 | return new IXR_Error( 403, __( 'You are not allowed access to details about comments.' ) ); |
696 | } |
697 |
|
698 | do_action('xmlrpc_call', 'wp.getCommentCount'); |
699 |
|
700 | return get_comment_count( $post_id ); |
701 | } |
702 |
|
703 |
|
704 | function wp_getPostStatusList( $args ) { |
705 | $this->escape( $args ); |
706 |
|
707 | $blog_id = (int) $args[0]; |
Line | Code |
711 | if( !$this->login_pass_ok( $username, $password ) ) { |
712 | return new IXR_Error( 403, __( 'Bad login/pass combination.' ) ); |
713 | } |
714 |
|
715 | set_current_user( 0, $username ); |
716 | if( !current_user_can( 'edit_posts' ) ) { |
717 | return new IXR_Error( 403, __( 'You are not allowed access to details about this blog.' ) ); |
718 | } |
719 |
|
720 | do_action('xmlrpc_call', 'wp.getPostStatusList'); |
721 |
|
722 | return get_post_statuses( ); |
723 | } |
724 |
|
725 |
|
726 | function wp_getPageStatusList( $args ) { |
727 | $this->escape( $args ); |
728 |
|
729 | $blog_id = (int) $args[0]; |
Line | Code |
733 | if( !$this->login_pass_ok( $username, $password ) ) { |
734 | return new IXR_Error( 403, __( 'Bad login/pass combination.' ) ); |
735 | } |
736 |
|
737 | set_current_user( 0, $username ); |
738 | if( !current_user_can( 'edit_posts' ) ) { |
739 | return new IXR_Error( 403, __( 'You are not allowed access to details about this blog.' ) ); |
740 | } |
741 |
|
742 | do_action('xmlrpc_call', 'wp.getPageStatusList'); |
743 |
|
744 | return get_page_statuses( ); |
745 | } |
746 |
|
747 |
|
748 | /* Blogger API functions |
749 | * specs on http://plant.blogger.com/api and http://groups.yahoo.com/group/bloggerDev/ |
750 | */ |
751 |
|
Line | Code |
756 | $this->escape($args); |
757 |
|
758 | $user_login = $args[1]; |
759 | $user_pass = $args[2]; |
760 |
|
761 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
762 | return $this->error; |
763 | } |
764 |
|
765 | do_action('xmlrpc_call', 'blogger.getUsersBlogs'); |
766 |
|
767 | set_current_user(0, $user_login); |
768 | $is_admin = current_user_can('level_8'); |
769 |
|
770 | $struct = array( |
771 | 'isAdmin' => $is_admin, |
772 | 'url' => get_option('home') . '/', |
773 | 'blogid' => '1', |
774 | 'blogName' => get_option('blogname') |
Line | Code |
788 |
|
789 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
790 | return $this->error; |
791 | } |
792 |
|
793 | set_current_user( 0, $user_login ); |
794 | if( !current_user_can( 'edit_posts' ) ) |
795 | return new IXR_Error( 401, __( 'Sorry, you do not have access to user data on this blog.' ) ); |
796 |
|
797 | do_action('xmlrpc_call', 'blogger.getUserInfo'); |
798 |
|
799 | $user_data = get_userdatabylogin($user_login); |
800 |
|
801 | $struct = array( |
802 | 'nickname' => $user_data->nickname, |
803 | 'userid' => $user_data->ID, |
804 | 'url' => $user_data->user_url, |
805 | 'lastname' => $user_data->last_name, |
806 | 'firstname' => $user_data->first_name |
Line | Code |
821 |
|
822 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
823 | return $this->error; |
824 | } |
825 |
|
826 | set_current_user( 0, $user_login ); |
827 | if( !current_user_can( 'edit_post', $post_ID ) ) |
828 | return new IXR_Error( 401, __( 'Sorry, you can not edit this post.' ) ); |
829 |
|
830 | do_action('xmlrpc_call', 'blogger.getPost'); |
831 |
|
832 | $post_data = wp_get_single_post($post_ID, ARRAY_A); |
833 |
|
834 | $categories = implode(',', wp_get_post_categories($post_ID)); |
835 |
|
836 | $content = '<title>'.stripslashes($post_data['post_title']).'</title>'; |
837 | $content .= '<category>'.$categories.'</category>'; |
838 | $content .= stripslashes($post_data['post_content']); |
839 |
|
Line | Code |
856 | $blog_ID = (int) $args[1]; /* though we don't use it yet */ |
857 | $user_login = $args[2]; |
858 | $user_pass = $args[3]; |
859 | $num_posts = $args[4]; |
860 |
|
861 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
862 | return $this->error; |
863 | } |
864 |
|
865 | do_action('xmlrpc_call', 'blogger.getRecentPosts'); |
866 |
|
867 | $posts_list = wp_get_recent_posts($num_posts); |
868 |
|
869 | set_current_user( 0, $user_login ); |
870 |
|
871 | if (!$posts_list) { |
872 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
873 | return $this->error; |
874 | } |
Line | Code |
910 | $blog_ID = (int) $args[1]; |
911 | $user_login = $args[2]; |
912 | $user_pass = $args[3]; |
913 | $template = $args[4]; /* could be 'main' or 'archiveIndex', but we don't use it */ |
914 |
|
915 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
916 | return $this->error; |
917 | } |
918 |
|
919 | do_action('xmlrpc_call', 'blogger.getTemplate'); |
920 |
|
921 | set_current_user(0, $user_login); |
922 | if ( !current_user_can('edit_themes') ) { |
923 | return new IXR_Error(401, __('Sorry, this user can not edit the template.')); |
924 | } |
925 |
|
926 | /* warning: here we make the assumption that the blog's URL is on the same server */ |
927 | $filename = get_option('home') . '/'; |
928 | $filename = preg_replace('#https?://.+?/#', $_SERVER['DOCUMENT_ROOT'].'/', $filename); |
Line | Code |
947 | $user_login = $args[2]; |
948 | $user_pass = $args[3]; |
949 | $content = $args[4]; |
950 | $template = $args[5]; /* could be 'main' or 'archiveIndex', but we don't use it */ |
951 |
|
952 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
953 | return $this->error; |
954 | } |
955 |
|
956 | do_action('xmlrpc_call', 'blogger.setTemplate'); |
957 |
|
958 | set_current_user(0, $user_login); |
959 | if ( !current_user_can('edit_themes') ) { |
960 | return new IXR_Error(401, __('Sorry, this user can not edit the template.')); |
961 | } |
962 |
|
963 | /* warning: here we make the assumption that the blog's URL is on the same server */ |
964 | $filename = get_option('home') . '/'; |
965 | $filename = preg_replace('#https?://.+?/#', $_SERVER['DOCUMENT_ROOT'].'/', $filename); |
Line | Code |
984 | $user_login = $args[2]; |
985 | $user_pass = $args[3]; |
986 | $content = $args[4]; |
987 | $publish = $args[5]; |
988 |
|
989 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
990 | return $this->error; |
991 | } |
992 |
|
993 | do_action('xmlrpc_call', 'blogger.newPost'); |
994 |
|
995 | $cap = ($publish) ? 'publish_posts' : 'edit_posts'; |
996 | $user = set_current_user(0, $user_login); |
997 | if ( !current_user_can($cap) ) |
998 | return new IXR_Error(401, __('Sorry, you are not allowed to post on this blog.')); |
999 |
|
1000 | $post_status = ($publish) ? 'publish' : 'draft'; |
1001 |
|
1002 | $post_author = $user->ID; |
Line | Code |
1033 | $user_login = $args[2]; |
1034 | $user_pass = $args[3]; |
1035 | $content = $args[4]; |
1036 | $publish = $args[5]; |
1037 |
|
1038 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
1039 | return $this->error; |
1040 | } |
1041 |
|
1042 | do_action('xmlrpc_call', 'blogger.editPost'); |
1043 |
|
1044 | $actual_post = wp_get_single_post($post_ID,ARRAY_A); |
1045 |
|
1046 | if (!$actual_post) { |
1047 | return new IXR_Error(404, __('Sorry, no such post.')); |
1048 | } |
1049 |
|
1050 | $this->escape($actual_post); |
1051 |
|
Line | Code |
1082 | $post_ID = (int) $args[1]; |
1083 | $user_login = $args[2]; |
1084 | $user_pass = $args[3]; |
1085 | $publish = $args[4]; |
1086 |
|
1087 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
1088 | return $this->error; |
1089 | } |
1090 |
|
1091 | do_action('xmlrpc_call', 'blogger.deletePost'); |
1092 |
|
1093 | $actual_post = wp_get_single_post($post_ID,ARRAY_A); |
1094 |
|
1095 | if (!$actual_post) { |
1096 | return new IXR_Error(404, __('Sorry, no such post.')); |
1097 | } |
1098 |
|
1099 | set_current_user(0, $user_login); |
1100 | if ( !current_user_can('edit_post', $post_ID) ) |
Line | Code |
1124 | $user_pass = $args[2]; |
1125 | $content_struct = $args[3]; |
1126 | $publish = $args[4]; |
1127 |
|
1128 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
1129 | return $this->error; |
1130 | } |
1131 | $user = set_current_user(0, $user_login); |
1132 |
|
1133 | do_action('xmlrpc_call', 'metaWeblog.newPost'); |
1134 |
|
1135 | $cap = ( $publish ) ? 'publish_posts' : 'edit_posts'; |
1136 | $error_message = __( 'Sorry, you are not allowed to publish posts on this blog.' ); |
1137 | $post_type = 'post'; |
1138 | if( !empty( $content_struct['post_type'] ) ) { |
1139 | if( $content_struct['post_type'] == 'page' ) { |
1140 | $cap = ( $publish ) ? 'publish_pages' : 'edit_pages'; |
1141 | $error_message = __( 'Sorry, you are not allowed to publish pages on this blog.' ); |
1142 | $post_type = 'page'; |
Line | Code |
1373 | $user_pass = $args[2]; |
1374 | $content_struct = $args[3]; |
1375 | $publish = $args[4]; |
1376 |
|
1377 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
1378 | return $this->error; |
1379 | } |
1380 | $user = set_current_user(0, $user_login); |
1381 |
|
1382 | do_action('xmlrpc_call', 'metaWeblog.editPost'); |
1383 |
|
1384 | $cap = ( $publish ) ? 'publish_posts' : 'edit_posts'; |
1385 | $error_message = __( 'Sorry, you are not allowed to publish posts on this blog.' ); |
1386 | $post_type = 'post'; |
1387 | if( !empty( $content_struct['post_type'] ) ) { |
1388 | if( $content_struct['post_type'] == 'page' ) { |
1389 | $cap = ( $publish ) ? 'publish_pages' : 'edit_pages'; |
1390 | $error_message = __( 'Sorry, you are not allowed to publish pages on this blog.' ); |
1391 | $post_type = 'page'; |
Line | Code |
1617 |
|
1618 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
1619 | return $this->error; |
1620 | } |
1621 |
|
1622 | set_current_user( 0, $user_login ); |
1623 | if( !current_user_can( 'edit_post', $post_ID ) ) |
1624 | return new IXR_Error( 401, __( 'Sorry, you can not edit this post.' ) ); |
1625 |
|
1626 | do_action('xmlrpc_call', 'metaWeblog.getPost'); |
1627 |
|
1628 | $postdata = wp_get_single_post($post_ID, ARRAY_A); |
1629 |
|
1630 | if ($postdata['post_date'] != '') { |
1631 | $post_date = mysql2date('Ymd\TH:i:s', $postdata['post_date']); |
1632 | $post_date_gmt = mysql2date('Ymd\TH:i:s', $postdata['post_date_gmt']); |
1633 |
|
1634 | $categories = array(); |
1635 | $catids = wp_get_post_categories($post_ID); |
Line | Code |
1700 | $blog_ID = (int) $args[0]; |
1701 | $user_login = $args[1]; |
1702 | $user_pass = $args[2]; |
1703 | $num_posts = (int) $args[3]; |
1704 |
|
1705 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
1706 | return $this->error; |
1707 | } |
1708 |
|
1709 | do_action('xmlrpc_call', 'metaWeblog.getRecentPosts'); |
1710 |
|
1711 | $posts_list = wp_get_recent_posts($num_posts); |
1712 |
|
1713 | if (!$posts_list) { |
1714 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
1715 | return $this->error; |
1716 | } |
1717 |
|
1718 | set_current_user( 0, $user_login ); |
Line | Code |
1802 |
|
1803 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
1804 | return $this->error; |
1805 | } |
1806 |
|
1807 | set_current_user( 0, $user_login ); |
1808 | if( !current_user_can( 'edit_posts' ) ) |
1809 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this blog in order to view categories.' ) ); |
1810 |
|
1811 | do_action('xmlrpc_call', 'metaWeblog.getCategories'); |
1812 |
|
1813 | $categories_struct = array(); |
1814 |
|
1815 | if ( $cats = get_categories('get=all') ) { |
1816 | foreach ( $cats as $cat ) { |
1817 | $struct['categoryId'] = $cat->term_id; |
1818 | $struct['parentId'] = $cat->parent; |
1819 | $struct['description'] = $cat->name; |
1820 | $struct['categoryName'] = $cat->name; |
Line | Code |
1844 | $name = sanitize_file_name( $data['name'] ); |
1845 | $type = $data['type']; |
1846 | $bits = $data['bits']; |
1847 |
|
1848 | logIO('O', '(MW) Received '.strlen($bits).' bytes'); |
1849 |
|
1850 | if ( !$this->login_pass_ok($user_login, $user_pass) ) |
1851 | return $this->error; |
1852 |
|
1853 | do_action('xmlrpc_call', 'metaWeblog.newMediaObject'); |
1854 |
|
1855 | set_current_user(0, $user_login); |
1856 | if ( !current_user_can('upload_files') ) { |
1857 | logIO('O', '(MW) User does not have upload_files capability'); |
1858 | $this->error = new IXR_Error(401, __('You are not allowed to upload files to this site.')); |
1859 | return $this->error; |
1860 | } |
1861 |
|
1862 | if ( $upload_err = apply_filters( "pre_upload_error", false ) ) |
Line | Code |
1918 | $blog_ID = (int) $args[0]; |
1919 | $user_login = $args[1]; |
1920 | $user_pass = $args[2]; |
1921 | $num_posts = (int) $args[3]; |
1922 |
|
1923 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
1924 | return $this->error; |
1925 | } |
1926 |
|
1927 | do_action('xmlrpc_call', 'mt.getRecentPostTitles'); |
1928 |
|
1929 | $posts_list = wp_get_recent_posts($num_posts); |
1930 |
|
1931 | if (!$posts_list) { |
1932 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
1933 | return $this->error; |
1934 | } |
1935 |
|
1936 | set_current_user( 0, $user_login ); |
Line | Code |
1972 |
|
1973 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
1974 | return $this->error; |
1975 | } |
1976 |
|
1977 | set_current_user( 0, $user_login ); |
1978 | if( !current_user_can( 'edit_posts' ) ) |
1979 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this blog in order to view categories.' ) ); |
1980 |
|
1981 | do_action('xmlrpc_call', 'mt.getCategoryList'); |
1982 |
|
1983 | $categories_struct = array(); |
1984 |
|
1985 | if ( $cats = get_categories('hide_empty=0&hierarchical=0') ) { |
1986 | foreach ($cats as $cat) { |
1987 | $struct['categoryId'] = $cat->term_id; |
1988 | $struct['categoryName'] = $cat->name; |
1989 |
|
1990 | $categories_struct[] = $struct; |
Line | Code |
2006 |
|
2007 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
2008 | return $this->error; |
2009 | } |
2010 |
|
2011 | set_current_user( 0, $user_login ); |
2012 | if( !current_user_can( 'edit_post', $post_ID ) ) |
2013 | return new IXR_Error( 401, __( 'Sorry, you can not edit this post.' ) ); |
2014 |
|
2015 | do_action('xmlrpc_call', 'mt.getPostCategories'); |
2016 |
|
2017 | $categories = array(); |
2018 | $catids = wp_get_post_categories(intval($post_ID)); |
2019 | // first listed category will be the primary category |
2020 | $isPrimary = true; |
2021 | foreach($catids as $catid) { |
2022 | $categories[] = array( |
2023 | 'categoryName' => get_cat_name($catid), |
2024 | 'categoryId' => (string) $catid, |
Line | Code |
2039 | $post_ID = (int) $args[0]; |
2040 | $user_login = $args[1]; |
2041 | $user_pass = $args[2]; |
2042 | $categories = $args[3]; |
2043 |
|
2044 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
2045 | return $this->error; |
2046 | } |
2047 |
|
2048 | do_action('xmlrpc_call', 'mt.setPostCategories'); |
2049 |
|
2050 | set_current_user(0, $user_login); |
2051 | if ( !current_user_can('edit_post', $post_ID) ) |
2052 | return new IXR_Error(401, __('Sorry, you can not edit this post.')); |
2053 |
|
2054 | foreach($categories as $cat) { |
2055 | $catids[] = $cat['categoryId']; |
2056 | } |
2057 |
|
2058 | wp_set_post_categories($post_ID, $catids); |
2059 |
|
2060 | return true; |
2061 | } |
2062 |
|
2063 |
|
2064 | /* mt.supportedMethods ...returns an array of methods supported by this server */ |
2065 | function mt_supportedMethods($args) { |
2066 |
|
2067 | do_action('xmlrpc_call', 'mt.supportedMethods'); |
2068 |
|
2069 | $supported_methods = array(); |
2070 | foreach($this->methods as $key=>$value) { |
2071 | $supported_methods[] = $key; |
2072 | } |
2073 |
|
2074 | return $supported_methods; |
2075 | } |
2076 |
|
2077 |
|
2078 | /* mt.supportedTextFilters ...returns an empty array because we don't |
2079 | support per-post text filters yet */ |
2080 | function mt_supportedTextFilters($args) { |
2081 | do_action('xmlrpc_call', 'mt.supportedTextFilters'); |
2082 | return apply_filters('xmlrpc_text_filters', array()); |
2083 | } |
2084 |
|
2085 |
|
2086 | /* mt.getTrackbackPings ...returns trackbacks sent to a given post */ |
2087 | function mt_getTrackbackPings($args) { |
2088 |
|
2089 | global $wpdb; |
2090 |
|
2091 | $post_ID = intval($args); |
2092 |
|
2093 | do_action('xmlrpc_call', 'mt.getTrackbackPings'); |
2094 |
|
2095 | $actual_post = wp_get_single_post($post_ID, ARRAY_A); |
2096 |
|
2097 | if (!$actual_post) { |
2098 | return new IXR_Error(404, __('Sorry, no such post.')); |
2099 | } |
2100 |
|
2101 | $comments = $wpdb->get_results("SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->comments WHERE comment_post_ID = $post_ID"); |
2102 |
|
Line | Code |
2128 |
|
2129 | $post_ID = (int) $args[0]; |
2130 | $user_login = $args[1]; |
2131 | $user_pass = $args[2]; |
2132 |
|
2133 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
2134 | return $this->error; |
2135 | } |
2136 |
|
2137 | do_action('xmlrpc_call', 'mt.publishPost'); |
2138 |
|
2139 | set_current_user(0, $user_login); |
2140 | if ( !current_user_can('edit_post', $post_ID) ) |
2141 | return new IXR_Error(401, __('Sorry, you can not edit this post.')); |
2142 |
|
2143 | $postdata = wp_get_single_post($post_ID,ARRAY_A); |
2144 |
|
2145 | $postdata['post_status'] = 'publish'; |
2146 |
|
Line | Code |
2158 |
|
2159 | /* PingBack functions |
2160 | * specs on www.hixie.ch/specs/pingback/pingback |
2161 | */ |
2162 |
|
2163 | /* pingback.ping gets a pingback and registers it */ |
2164 | function pingback_ping($args) { |
2165 | global $wpdb; |
2166 |
|
2167 | do_action('xmlrpc_call', 'pingback.ping'); |
2168 |
|
2169 | $this->escape($args); |
2170 |
|
2171 | $pagelinkedfrom = $args[0]; |
2172 | $pagelinkedto = $args[1]; |
2173 |
|
2174 | $title = ''; |
2175 |
|
2176 | $pagelinkedfrom = str_replace('&', '&', $pagelinkedfrom); |
Line | Code |
2324 |
|
2325 |
|
2326 | /* pingback.extensions.getPingbacks returns an array of URLs |
2327 | that pingbacked the given URL |
2328 | specs on http://www.aquarionics.com/misc/archives/blogite/0198.html */ |
2329 | function pingback_extensions_getPingbacks($args) { |
2330 |
|
2331 | global $wpdb; |
2332 |
|
2333 | do_action('xmlrpc_call', 'pingback.extensions.getPingsbacks'); |
2334 |
|
2335 | $this->escape($args); |
2336 |
|
2337 | $url = $args; |
2338 |
|
2339 | $post_ID = url_to_postid($url); |
2340 | if (!$post_ID) { |
2341 | // We aren't sure that the resource is available and/or pingback enabled |
2342 | 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.')); |