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 46 times in this file.
Line | Code |
---|---|
414 |
|
415 | $this->escape( $args ); |
416 |
|
417 | $username = $args[0]; |
418 | $password = $args[1]; |
419 |
|
420 | if( !$this->login_pass_ok( $username, $password ) ) |
421 | return $this->error; |
422 |
|
423 | do_action( 'xmlrpc_call', 'wp.getUsersBlogs' ); |
424 |
|
425 | $user = set_current_user( 0, $username ); |
426 |
|
427 | $blogs = (array) get_blogs_of_user( $user->ID ); |
428 | $struct = array( ); |
429 |
|
430 | foreach( $blogs as $blog ) { |
431 | // Don't include blogs that aren't hosted at this site |
432 | if( $blog->site_id != $current_site->id ) |
Line | Code |
468 |
|
469 | if(!$this->login_pass_ok($username, $password)) { |
470 | return($this->error); |
471 | } |
472 |
|
473 | set_current_user( 0, $username ); |
474 | if( !current_user_can( 'edit_page', $page_id ) ) |
475 | return new IXR_Error( 401, __( 'Sorry, you can not edit this page.' ) ); |
476 |
|
477 | do_action('xmlrpc_call', 'wp.getPage'); |
478 |
|
479 | // Lookup page info. |
480 | $page = get_page($page_id); |
481 |
|
482 | // If we found the page then format the data. |
483 | if($page->ID && ($page->post_type == "page")) { |
484 | // Get all of the page content and link. |
485 | $full_page = get_extended($page->post_content); |
486 | $link = post_permalink($page->ID); |
Line | Code |
566 |
|
567 | if(!$this->login_pass_ok($username, $password)) { |
568 | return($this->error); |
569 | } |
570 |
|
571 | set_current_user( 0, $username ); |
572 | if( !current_user_can( 'edit_pages' ) ) |
573 | return new IXR_Error( 401, __( 'Sorry, you can not edit pages.' ) ); |
574 |
|
575 | do_action('xmlrpc_call', 'wp.getPages'); |
576 |
|
577 | $page_limit = 10; |
578 | if( isset( $num_pages ) ) { |
579 | $page_limit = $num_pages; |
580 | } |
581 |
|
582 | $pages = get_posts( "post_type=page&post_status=all&numberposts={$page_limit}" ); |
583 | $num_pages = count($pages); |
584 |
|
Line | Code |
614 | $username = $this->escape($args[1]); |
615 | $password = $this->escape($args[2]); |
616 | $page = $args[3]; |
617 | $publish = $args[4]; |
618 |
|
619 | if(!$this->login_pass_ok($username, $password)) { |
620 | return($this->error); |
621 | } |
622 |
|
623 | do_action('xmlrpc_call', 'wp.newPage'); |
624 |
|
625 | // Set the user context and check if they are allowed |
626 | // to add new pages. |
627 | $user = set_current_user(0, $username); |
628 | if(!current_user_can("publish_pages")) { |
629 | return(new IXR_Error(401, __("Sorry, you can not add new pages."))); |
630 | } |
631 |
|
632 | // Mark this as content for a page. |
Line | Code |
650 | $blog_id = (int) $args[0]; |
651 | $username = $args[1]; |
652 | $password = $args[2]; |
653 | $page_id = (int) $args[3]; |
654 |
|
655 | if(!$this->login_pass_ok($username, $password)) { |
656 | return($this->error); |
657 | } |
658 |
|
659 | do_action('xmlrpc_call', 'wp.deletePage'); |
660 |
|
661 | // Get the current page based on the page_id and |
662 | // make sure it is a page and not a post. |
663 | $actual_page = wp_get_single_post($page_id, ARRAY_A); |
664 | if( |
665 | !$actual_page |
666 | || ($actual_page["post_type"] != "page") |
667 | ) { |
668 | return(new IXR_Error(404, __("Sorry, no such page."))); |
Line | Code |
698 | $username = $this->escape($args[2]); |
699 | $password = $this->escape($args[3]); |
700 | $content = $args[4]; |
701 | $publish = $args[5]; |
702 |
|
703 | if(!$this->login_pass_ok($username, $password)) { |
704 | return($this->error); |
705 | } |
706 |
|
707 | do_action('xmlrpc_call', 'wp.editPage'); |
708 |
|
709 | // Get the page data and make sure it is a page. |
710 | $actual_page = wp_get_single_post($page_id, ARRAY_A); |
711 | if( |
712 | !$actual_page |
713 | || ($actual_page["post_type"] != "page") |
714 | ) { |
715 | return(new IXR_Error(404, __("Sorry, no such page."))); |
716 | } |
Line | Code |
756 |
|
757 | if(!$this->login_pass_ok($username, $password)) { |
758 | return($this->error); |
759 | } |
760 |
|
761 | set_current_user( 0, $username ); |
762 | if( !current_user_can( 'edit_pages' ) ) |
763 | return new IXR_Error( 401, __( 'Sorry, you can not edit pages.' ) ); |
764 |
|
765 | do_action('xmlrpc_call', 'wp.getPageList'); |
766 |
|
767 | // Get list of pages ids and titles |
768 | $page_list = $wpdb->get_results(" |
769 | SELECT ID page_id, |
770 | post_title page_title, |
771 | post_parent page_parent_id, |
772 | post_date_gmt, |
773 | post_date |
774 | FROM {$wpdb->posts} |
Line | Code |
811 | if(!$this->login_pass_ok($username, $password)) { |
812 | return($this->error); |
813 | } |
814 |
|
815 | set_current_user(0, $username); |
816 | if(!current_user_can("edit_posts")) { |
817 | return(new IXR_Error(401, __("Sorry, you can not edit posts on this blog."))); |
818 | } |
819 |
|
820 | do_action('xmlrpc_call', 'wp.getAuthors'); |
821 |
|
822 | $authors = array(); |
823 | foreach( (array) get_users_of_blog() as $row ) { |
824 | $authors[] = array( |
825 | "user_id" => $row->user_id, |
826 | "user_login" => $row->user_login, |
827 | "display_name" => $row->display_name |
828 | ); |
829 | } |
Line | Code |
849 | if( !$this->login_pass_ok( $username, $password ) ) { |
850 | return $this->error; |
851 | } |
852 |
|
853 | set_current_user( 0, $username ); |
854 | if( !current_user_can( 'edit_posts' ) ) { |
855 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this blog in order to view tags.' ) ); |
856 | } |
857 |
|
858 | do_action( 'xmlrpc_call', 'wp.getKeywords' ); |
859 |
|
860 | $tags = array( ); |
861 |
|
862 | if( $all_tags = get_tags( ) ) { |
863 | foreach( (array) $all_tags as $tag ) { |
864 | $struct['tag_id'] = $tag->term_id; |
865 | $struct['name'] = $tag->name; |
866 | $struct['count'] = $tag->count; |
867 | $struct['slug'] = $tag->slug; |
Line | Code |
889 | $blog_id = (int) $args[0]; |
890 | $username = $args[1]; |
891 | $password = $args[2]; |
892 | $category = $args[3]; |
893 |
|
894 | if(!$this->login_pass_ok($username, $password)) { |
895 | return($this->error); |
896 | } |
897 |
|
898 | do_action('xmlrpc_call', 'wp.newCategory'); |
899 |
|
900 | // Set the user context and make sure they are |
901 | // allowed to add a category. |
902 | set_current_user(0, $username); |
903 | if(!current_user_can("manage_categories")) { |
904 | return(new IXR_Error(401, __("Sorry, you do not have the right to add a category."))); |
905 | } |
906 |
|
907 | // If no slug was provided make it empty so that |
Line | Code |
949 | $blog_id = (int) $args[0]; |
950 | $username = $args[1]; |
951 | $password = $args[2]; |
952 | $category_id = (int) $args[3]; |
953 |
|
954 | if( !$this->login_pass_ok( $username, $password ) ) { |
955 | return $this->error; |
956 | } |
957 |
|
958 | do_action('xmlrpc_call', 'wp.deleteCategory'); |
959 |
|
960 | set_current_user(0, $username); |
961 | if( !current_user_can("manage_categories") ) { |
962 | return new IXR_Error( 401, __( "Sorry, you do not have the right to delete a category." ) ); |
963 | } |
964 |
|
965 | return wp_delete_category( $category_id ); |
966 | } |
967 |
|
Line | Code |
984 |
|
985 | if(!$this->login_pass_ok($username, $password)) { |
986 | return($this->error); |
987 | } |
988 |
|
989 | set_current_user(0, $username); |
990 | if( !current_user_can( 'edit_posts' ) ) |
991 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts to this blog in order to view categories.' ) ); |
992 |
|
993 | do_action('xmlrpc_call', 'wp.suggestCategories'); |
994 |
|
995 | $category_suggestions = array(); |
996 | $args = array('get' => 'all', 'number' => $max_results, 'name__like' => $category); |
997 | foreach ( (array) get_categories($args) as $cat ) { |
998 | $category_suggestions[] = array( |
999 | "category_id" => $cat->cat_ID, |
1000 | "category_name" => $cat->cat_name |
1001 | ); |
1002 | } |
Line | Code |
1021 | $comment_id = (int) $args[3]; |
1022 |
|
1023 | if ( !$this->login_pass_ok( $username, $password ) ) |
1024 | return $this->error; |
1025 |
|
1026 | set_current_user( 0, $username ); |
1027 | if ( !current_user_can( 'moderate_comments' ) ) |
1028 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this blog.' ) ); |
1029 |
|
1030 | do_action('xmlrpc_call', 'wp.getComment'); |
1031 |
|
1032 | if ( ! $comment = get_comment($comment_id) ) |
1033 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
1034 |
|
1035 | // Format page date. |
1036 | $comment_date = mysql2date("Ymd\TH:i:s", $comment->comment_date); |
1037 | $comment_date_gmt = mysql2date("Ymd\TH:i:s", $comment->comment_date_gmt); |
1038 |
|
1039 | if ( 0 == $comment->comment_approved ) |
Line | Code |
1084 | $struct = $args[3]; |
1085 |
|
1086 | if ( !$this->login_pass_ok($username, $password) ) |
1087 | return($this->error); |
1088 |
|
1089 | set_current_user( 0, $username ); |
1090 | if ( !current_user_can( 'moderate_comments' ) ) |
1091 | return new IXR_Error( 401, __( 'Sorry, you can not edit comments.' ) ); |
1092 |
|
1093 | do_action('xmlrpc_call', 'wp.getComments'); |
1094 |
|
1095 | if ( isset($struct['status']) ) |
1096 | $status = $struct['status']; |
1097 | else |
1098 | $status = ''; |
1099 |
|
1100 | $post_id = ''; |
1101 | if ( isset($struct['post_id']) ) |
1102 | $post_id = absint($struct['post_id']); |
Line | Code |
1144 | $comment_ID = (int) $args[3]; |
1145 |
|
1146 | if ( !$this->login_pass_ok( $username, $password ) ) |
1147 | return $this->error; |
1148 |
|
1149 | set_current_user( 0, $username ); |
1150 | if ( !current_user_can( 'moderate_comments' ) ) |
1151 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this blog.' ) ); |
1152 |
|
1153 | do_action('xmlrpc_call', 'wp.deleteComment'); |
1154 |
|
1155 | if ( ! get_comment($comment_ID) ) |
1156 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
1157 |
|
1158 | return wp_delete_comment($comment_ID); |
1159 | } |
1160 |
|
1161 | /** |
1162 | * Edit comment. |
Line | Code |
1176 | $content_struct = $args[4]; |
1177 |
|
1178 | if ( !$this->login_pass_ok( $username, $password ) ) |
1179 | return $this->error; |
1180 |
|
1181 | set_current_user( 0, $username ); |
1182 | if ( !current_user_can( 'moderate_comments' ) ) |
1183 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this blog.' ) ); |
1184 |
|
1185 | do_action('xmlrpc_call', 'wp.editComment'); |
1186 |
|
1187 | if ( ! get_comment($comment_ID) ) |
1188 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
1189 |
|
1190 | if ( isset($content_struct['status']) ) { |
1191 | $statuses = get_comment_statuses(); |
1192 | $statuses = array_keys($statuses); |
1193 |
|
1194 | if ( ! in_array($content_struct['status'], $statuses) ) |
Line | Code |
1299 | elseif ( !is_email($comment['comment_author_email']) ) |
1300 | return new IXR_Error( 403, __( 'A valid email address is required' ) ); |
1301 | } |
1302 | } |
1303 |
|
1304 | $comment['comment_parent'] = isset($content_struct['comment_parent']) ? absint($content_struct['comment_parent']) : 0; |
1305 |
|
1306 | $comment['comment_content'] = $content_struct['content']; |
1307 |
|
1308 | do_action('xmlrpc_call', 'wp.newComment'); |
1309 |
|
1310 | return wp_new_comment($comment); |
1311 | } |
1312 |
|
1313 | /** |
1314 | * Retrieve all of the comment status. |
1315 | * |
1316 | * @since 2.7.0 |
1317 | * |
Line | Code |
1326 | $password = $args[2]; |
1327 |
|
1328 | if ( !$this->login_pass_ok( $username, $password ) ) |
1329 | return $this->error; |
1330 |
|
1331 | set_current_user( 0, $username ); |
1332 | if ( !current_user_can( 'moderate_comments' ) ) |
1333 | return new IXR_Error( 403, __( 'You are not allowed access to details about this blog.' ) ); |
1334 |
|
1335 | do_action('xmlrpc_call', 'wp.getCommentStatusList'); |
1336 |
|
1337 | return get_comment_statuses( ); |
1338 | } |
1339 |
|
1340 | /** |
1341 | * Retrieve comment count. |
1342 | * |
1343 | * @since 2.5.0 |
1344 | * |
Line | Code |
1356 | if( !$this->login_pass_ok( $username, $password ) ) { |
1357 | return $this->error; |
1358 | } |
1359 |
|
1360 | set_current_user( 0, $username ); |
1361 | if( !current_user_can( 'edit_posts' ) ) { |
1362 | return new IXR_Error( 403, __( 'You are not allowed access to details about comments.' ) ); |
1363 | } |
1364 |
|
1365 | do_action('xmlrpc_call', 'wp.getCommentCount'); |
1366 |
|
1367 | $count = wp_count_comments( $post_id ); |
1368 | return array( |
1369 | "approved" => $count->approved, |
1370 | "awaiting_moderation" => $count->moderated, |
1371 | "spam" => $count->spam, |
1372 | "total_comments" => $count->total_comments |
1373 | ); |
1374 | } |
Line | Code |
1391 | if( !$this->login_pass_ok( $username, $password ) ) { |
1392 | return $this->error; |
1393 | } |
1394 |
|
1395 | set_current_user( 0, $username ); |
1396 | if( !current_user_can( 'edit_posts' ) ) { |
1397 | return new IXR_Error( 403, __( 'You are not allowed access to details about this blog.' ) ); |
1398 | } |
1399 |
|
1400 | do_action('xmlrpc_call', 'wp.getPostStatusList'); |
1401 |
|
1402 | return get_post_statuses( ); |
1403 | } |
1404 |
|
1405 | /** |
1406 | * Retrieve page statuses. |
1407 | * |
1408 | * @since 2.5.0 |
1409 | * |
Line | Code |
1420 | if( !$this->login_pass_ok( $username, $password ) ) { |
1421 | return $this->error; |
1422 | } |
1423 |
|
1424 | set_current_user( 0, $username ); |
1425 | if( !current_user_can( 'edit_posts' ) ) { |
1426 | return new IXR_Error( 403, __( 'You are not allowed access to details about this blog.' ) ); |
1427 | } |
1428 |
|
1429 | do_action('xmlrpc_call', 'wp.getPageStatusList'); |
1430 |
|
1431 | return get_page_statuses( ); |
1432 | } |
1433 |
|
1434 | /** |
1435 | * Retrieve page templates. |
1436 | * |
1437 | * @since 2.6.0 |
1438 | * |
Line | Code |
1576 | $this->escape($args); |
1577 |
|
1578 | $user_login = $args[1]; |
1579 | $user_pass = $args[2]; |
1580 |
|
1581 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
1582 | return $this->error; |
1583 | } |
1584 |
|
1585 | do_action('xmlrpc_call', 'blogger.getUsersBlogs'); |
1586 |
|
1587 | set_current_user(0, $user_login); |
1588 | $is_admin = current_user_can('manage_options'); |
1589 |
|
1590 | $struct = array( |
1591 | 'isAdmin' => $is_admin, |
1592 | 'url' => get_option('home') . '/', |
1593 | 'blogid' => '1', |
1594 | 'blogName' => get_option('blogname'), |
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_posts' ) ) |
1624 | return new IXR_Error( 401, __( 'Sorry, you do not have access to user data on this blog.' ) ); |
1625 |
|
1626 | do_action('xmlrpc_call', 'blogger.getUserInfo'); |
1627 |
|
1628 | $user_data = get_userdatabylogin($user_login); |
1629 |
|
1630 | $struct = array( |
1631 | 'nickname' => $user_data->nickname, |
1632 | 'userid' => $user_data->ID, |
1633 | 'url' => $user_data->user_url, |
1634 | 'lastname' => $user_data->last_name, |
1635 | 'firstname' => $user_data->first_name |
Line | Code |
1656 |
|
1657 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
1658 | return $this->error; |
1659 | } |
1660 |
|
1661 | set_current_user( 0, $user_login ); |
1662 | if( !current_user_can( 'edit_post', $post_ID ) ) |
1663 | return new IXR_Error( 401, __( 'Sorry, you can not edit this post.' ) ); |
1664 |
|
1665 | do_action('xmlrpc_call', 'blogger.getPost'); |
1666 |
|
1667 | $post_data = wp_get_single_post($post_ID, ARRAY_A); |
1668 |
|
1669 | $categories = implode(',', wp_get_post_categories($post_ID)); |
1670 |
|
1671 | $content = '<title>'.stripslashes($post_data['post_title']).'</title>'; |
1672 | $content .= '<category>'.$categories.'</category>'; |
1673 | $content .= stripslashes($post_data['post_content']); |
1674 |
|
Line | Code |
1697 | $blog_ID = (int) $args[1]; /* though we don't use it yet */ |
1698 | $user_login = $args[2]; |
1699 | $user_pass = $args[3]; |
1700 | $num_posts = $args[4]; |
1701 |
|
1702 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
1703 | return $this->error; |
1704 | } |
1705 |
|
1706 | do_action('xmlrpc_call', 'blogger.getRecentPosts'); |
1707 |
|
1708 | $posts_list = wp_get_recent_posts($num_posts); |
1709 |
|
1710 | set_current_user( 0, $user_login ); |
1711 |
|
1712 | if (!$posts_list) { |
1713 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
1714 | return $this->error; |
1715 | } |
Line | Code |
1757 | $blog_ID = (int) $args[1]; |
1758 | $user_login = $args[2]; |
1759 | $user_pass = $args[3]; |
1760 | $template = $args[4]; /* could be 'main' or 'archiveIndex', but we don't use it */ |
1761 |
|
1762 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
1763 | return $this->error; |
1764 | } |
1765 |
|
1766 | do_action('xmlrpc_call', 'blogger.getTemplate'); |
1767 |
|
1768 | set_current_user(0, $user_login); |
1769 | if ( !current_user_can('edit_themes') ) { |
1770 | return new IXR_Error(401, __('Sorry, this user can not edit the template.')); |
1771 | } |
1772 |
|
1773 | /* warning: here we make the assumption that the blog's URL is on the same server */ |
1774 | $filename = get_option('home') . '/'; |
1775 | $filename = preg_replace('#https?://.+?/#', $_SERVER['DOCUMENT_ROOT'].'/', $filename); |
Line | Code |
1800 | $user_login = $args[2]; |
1801 | $user_pass = $args[3]; |
1802 | $content = $args[4]; |
1803 | $template = $args[5]; /* could be 'main' or 'archiveIndex', but we don't use it */ |
1804 |
|
1805 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
1806 | return $this->error; |
1807 | } |
1808 |
|
1809 | do_action('xmlrpc_call', 'blogger.setTemplate'); |
1810 |
|
1811 | set_current_user(0, $user_login); |
1812 | if ( !current_user_can('edit_themes') ) { |
1813 | return new IXR_Error(401, __('Sorry, this user can not edit the template.')); |
1814 | } |
1815 |
|
1816 | /* warning: here we make the assumption that the blog's URL is on the same server */ |
1817 | $filename = get_option('home') . '/'; |
1818 | $filename = preg_replace('#https?://.+?/#', $_SERVER['DOCUMENT_ROOT'].'/', $filename); |
Line | Code |
1843 | $user_login = $args[2]; |
1844 | $user_pass = $args[3]; |
1845 | $content = $args[4]; |
1846 | $publish = $args[5]; |
1847 |
|
1848 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
1849 | return $this->error; |
1850 | } |
1851 |
|
1852 | do_action('xmlrpc_call', 'blogger.newPost'); |
1853 |
|
1854 | $cap = ($publish) ? 'publish_posts' : 'edit_posts'; |
1855 | $user = set_current_user(0, $user_login); |
1856 | if ( !current_user_can($cap) ) |
1857 | return new IXR_Error(401, __('Sorry, you are not allowed to post on this blog.')); |
1858 |
|
1859 | $post_status = ($publish) ? 'publish' : 'draft'; |
1860 |
|
1861 | $post_author = $user->ID; |
Line | Code |
1899 | $user_login = $args[2]; |
1900 | $user_pass = $args[3]; |
1901 | $content = $args[4]; |
1902 | $publish = $args[5]; |
1903 |
|
1904 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
1905 | return $this->error; |
1906 | } |
1907 |
|
1908 | do_action('xmlrpc_call', 'blogger.editPost'); |
1909 |
|
1910 | $actual_post = wp_get_single_post($post_ID,ARRAY_A); |
1911 |
|
1912 | if (!$actual_post || $actual_post['post_type'] != 'post') { |
1913 | return new IXR_Error(404, __('Sorry, no such post.')); |
1914 | } |
1915 |
|
1916 | $this->escape($actual_post); |
1917 |
|
Line | Code |
1954 | $post_ID = (int) $args[1]; |
1955 | $user_login = $args[2]; |
1956 | $user_pass = $args[3]; |
1957 | $publish = $args[4]; |
1958 |
|
1959 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
1960 | return $this->error; |
1961 | } |
1962 |
|
1963 | do_action('xmlrpc_call', 'blogger.deletePost'); |
1964 |
|
1965 | $actual_post = wp_get_single_post($post_ID,ARRAY_A); |
1966 |
|
1967 | if (!$actual_post || $actual_post['post_type'] != 'post') { |
1968 | return new IXR_Error(404, __('Sorry, no such post.')); |
1969 | } |
1970 |
|
1971 | set_current_user(0, $user_login); |
1972 | if ( !current_user_can('edit_post', $post_ID) ) |
Line | Code |
2001 | $user_pass = $args[2]; |
2002 | $content_struct = $args[3]; |
2003 | $publish = $args[4]; |
2004 |
|
2005 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
2006 | return $this->error; |
2007 | } |
2008 | $user = set_current_user(0, $user_login); |
2009 |
|
2010 | do_action('xmlrpc_call', 'metaWeblog.newPost'); |
2011 |
|
2012 | $cap = ( $publish ) ? 'publish_posts' : 'edit_posts'; |
2013 | $error_message = __( 'Sorry, you are not allowed to publish posts on this blog.' ); |
2014 | $post_type = 'post'; |
2015 | $page_template = ''; |
2016 | if( !empty( $content_struct['post_type'] ) ) { |
2017 | if( $content_struct['post_type'] == 'page' ) { |
2018 | $cap = ( $publish ) ? 'publish_pages' : 'edit_pages'; |
2019 | $error_message = __( 'Sorry, you are not allowed to publish pages on this blog.' ); |
Line | Code |
2274 | $user_pass = $args[2]; |
2275 | $content_struct = $args[3]; |
2276 | $publish = $args[4]; |
2277 |
|
2278 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
2279 | return $this->error; |
2280 | } |
2281 | $user = set_current_user(0, $user_login); |
2282 |
|
2283 | do_action('xmlrpc_call', 'metaWeblog.editPost'); |
2284 |
|
2285 | $cap = ( $publish ) ? 'publish_posts' : 'edit_posts'; |
2286 | $error_message = __( 'Sorry, you are not allowed to publish posts on this blog.' ); |
2287 | $post_type = 'post'; |
2288 | $page_template = ''; |
2289 | if( !empty( $content_struct['post_type'] ) ) { |
2290 | if( $content_struct['post_type'] == 'page' ) { |
2291 | $cap = ( $publish ) ? 'publish_pages' : 'edit_pages'; |
2292 | $error_message = __( 'Sorry, you are not allowed to publish pages on this blog.' ); |
Line | Code |
2536 |
|
2537 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
2538 | return $this->error; |
2539 | } |
2540 |
|
2541 | set_current_user( 0, $user_login ); |
2542 | if( !current_user_can( 'edit_post', $post_ID ) ) |
2543 | return new IXR_Error( 401, __( 'Sorry, you can not edit this post.' ) ); |
2544 |
|
2545 | do_action('xmlrpc_call', 'metaWeblog.getPost'); |
2546 |
|
2547 | $postdata = wp_get_single_post($post_ID, ARRAY_A); |
2548 |
|
2549 | if ($postdata['post_date'] != '') { |
2550 | $post_date = mysql2date('Ymd\TH:i:s', $postdata['post_date']); |
2551 | $post_date_gmt = mysql2date('Ymd\TH:i:s', $postdata['post_date_gmt']); |
2552 |
|
2553 | $categories = array(); |
2554 | $catids = wp_get_post_categories($post_ID); |
Line | Code |
2640 | $blog_ID = (int) $args[0]; |
2641 | $user_login = $args[1]; |
2642 | $user_pass = $args[2]; |
2643 | $num_posts = (int) $args[3]; |
2644 |
|
2645 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
2646 | return $this->error; |
2647 | } |
2648 |
|
2649 | do_action('xmlrpc_call', 'metaWeblog.getRecentPosts'); |
2650 |
|
2651 | $posts_list = wp_get_recent_posts($num_posts); |
2652 |
|
2653 | if (!$posts_list) { |
2654 | return array( ); |
2655 | } |
2656 |
|
2657 | set_current_user( 0, $user_login ); |
2658 |
|
Line | Code |
2747 |
|
2748 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
2749 | return $this->error; |
2750 | } |
2751 |
|
2752 | set_current_user( 0, $user_login ); |
2753 | if( !current_user_can( 'edit_posts' ) ) |
2754 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this blog in order to view categories.' ) ); |
2755 |
|
2756 | do_action('xmlrpc_call', 'metaWeblog.getCategories'); |
2757 |
|
2758 | $categories_struct = array(); |
2759 |
|
2760 | if ( $cats = get_categories('get=all') ) { |
2761 | foreach ( $cats as $cat ) { |
2762 | $struct['categoryId'] = $cat->term_id; |
2763 | $struct['parentId'] = $cat->parent; |
2764 | $struct['description'] = $cat->description; |
2765 | $struct['categoryName'] = $cat->name; |
Line | Code |
2796 | $name = sanitize_file_name( $data['name'] ); |
2797 | $type = $data['type']; |
2798 | $bits = $data['bits']; |
2799 |
|
2800 | logIO('O', '(MW) Received '.strlen($bits).' bytes'); |
2801 |
|
2802 | if ( !$this->login_pass_ok($user_login, $user_pass) ) |
2803 | return $this->error; |
2804 |
|
2805 | do_action('xmlrpc_call', 'metaWeblog.newMediaObject'); |
2806 |
|
2807 | set_current_user(0, $user_login); |
2808 | if ( !current_user_can('upload_files') ) { |
2809 | logIO('O', '(MW) User does not have upload_files capability'); |
2810 | $this->error = new IXR_Error(401, __('You are not allowed to upload files to this site.')); |
2811 | return $this->error; |
2812 | } |
2813 |
|
2814 | if ( $upload_err = apply_filters( "pre_upload_error", false ) ) |
Line | Code |
2876 | $blog_ID = (int) $args[0]; |
2877 | $user_login = $args[1]; |
2878 | $user_pass = $args[2]; |
2879 | $num_posts = (int) $args[3]; |
2880 |
|
2881 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
2882 | return $this->error; |
2883 | } |
2884 |
|
2885 | do_action('xmlrpc_call', 'mt.getRecentPostTitles'); |
2886 |
|
2887 | $posts_list = wp_get_recent_posts($num_posts); |
2888 |
|
2889 | if (!$posts_list) { |
2890 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
2891 | return $this->error; |
2892 | } |
2893 |
|
2894 | set_current_user( 0, $user_login ); |
Line | Code |
2936 |
|
2937 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
2938 | return $this->error; |
2939 | } |
2940 |
|
2941 | set_current_user( 0, $user_login ); |
2942 | if( !current_user_can( 'edit_posts' ) ) |
2943 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this blog in order to view categories.' ) ); |
2944 |
|
2945 | do_action('xmlrpc_call', 'mt.getCategoryList'); |
2946 |
|
2947 | $categories_struct = array(); |
2948 |
|
2949 | if ( $cats = get_categories('hide_empty=0&hierarchical=0') ) { |
2950 | foreach ($cats as $cat) { |
2951 | $struct['categoryId'] = $cat->term_id; |
2952 | $struct['categoryName'] = $cat->name; |
2953 |
|
2954 | $categories_struct[] = $struct; |
Line | Code |
2976 |
|
2977 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
2978 | return $this->error; |
2979 | } |
2980 |
|
2981 | set_current_user( 0, $user_login ); |
2982 | if( !current_user_can( 'edit_post', $post_ID ) ) |
2983 | return new IXR_Error( 401, __( 'Sorry, you can not edit this post.' ) ); |
2984 |
|
2985 | do_action('xmlrpc_call', 'mt.getPostCategories'); |
2986 |
|
2987 | $categories = array(); |
2988 | $catids = wp_get_post_categories(intval($post_ID)); |
2989 | // first listed category will be the primary category |
2990 | $isPrimary = true; |
2991 | foreach($catids as $catid) { |
2992 | $categories[] = array( |
2993 | 'categoryName' => get_cat_name($catid), |
2994 | 'categoryId' => (string) $catid, |
Line | Code |
3015 | $post_ID = (int) $args[0]; |
3016 | $user_login = $args[1]; |
3017 | $user_pass = $args[2]; |
3018 | $categories = $args[3]; |
3019 |
|
3020 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
3021 | return $this->error; |
3022 | } |
3023 |
|
3024 | do_action('xmlrpc_call', 'mt.setPostCategories'); |
3025 |
|
3026 | set_current_user(0, $user_login); |
3027 | if ( !current_user_can('edit_post', $post_ID) ) |
3028 | return new IXR_Error(401, __('Sorry, you can not edit this post.')); |
3029 |
|
3030 | foreach($categories as $cat) { |
3031 | $catids[] = $cat['categoryId']; |
3032 | } |
3033 |
|
Line | Code |
3040 | * Retrieve an array of methods supported by this server. |
3041 | * |
3042 | * @since 1.5.0 |
3043 | * |
3044 | * @param array $args Method parameters. |
3045 | * @return array |
3046 | */ |
3047 | function mt_supportedMethods($args) { |
3048 |
|
3049 | do_action('xmlrpc_call', 'mt.supportedMethods'); |
3050 |
|
3051 | $supported_methods = array(); |
3052 | foreach($this->methods as $key=>$value) { |
3053 | $supported_methods[] = $key; |
3054 | } |
3055 |
|
3056 | return $supported_methods; |
3057 | } |
3058 |
|
3059 | /** |
3060 | * Retrieve an empty array because we don't support per-post text filters. |
3061 | * |
3062 | * @since 1.5.0 |
3063 | * |
3064 | * @param array $args Method parameters. |
3065 | */ |
3066 | function mt_supportedTextFilters($args) { |
3067 | do_action('xmlrpc_call', 'mt.supportedTextFilters'); |
3068 | return apply_filters('xmlrpc_text_filters', array()); |
3069 | } |
3070 |
|
3071 | /** |
3072 | * Retrieve trackbacks sent to a given post. |
3073 | * |
3074 | * @since 1.5.0 |
3075 | * |
3076 | * @param array $args Method parameters. |
3077 | * @return mixed |
3078 | */ |
3079 | function mt_getTrackbackPings($args) { |
3080 |
|
3081 | global $wpdb; |
3082 |
|
3083 | $post_ID = intval($args); |
3084 |
|
3085 | do_action('xmlrpc_call', 'mt.getTrackbackPings'); |
3086 |
|
3087 | $actual_post = wp_get_single_post($post_ID, ARRAY_A); |
3088 |
|
3089 | if (!$actual_post) { |
3090 | return new IXR_Error(404, __('Sorry, no such post.')); |
3091 | } |
3092 |
|
3093 | $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) ); |
3094 |
|
Line | Code |
3126 |
|
3127 | $post_ID = (int) $args[0]; |
3128 | $user_login = $args[1]; |
3129 | $user_pass = $args[2]; |
3130 |
|
3131 | if (!$this->login_pass_ok($user_login, $user_pass)) { |
3132 | return $this->error; |
3133 | } |
3134 |
|
3135 | do_action('xmlrpc_call', 'mt.publishPost'); |
3136 |
|
3137 | set_current_user(0, $user_login); |
3138 | if ( !current_user_can('edit_post', $post_ID) ) |
3139 | return new IXR_Error(401, __('Sorry, you can not edit this post.')); |
3140 |
|
3141 | $postdata = wp_get_single_post($post_ID,ARRAY_A); |
3142 |
|
3143 | $postdata['post_status'] = 'publish'; |
3144 |
|
Line | Code |
3161 | * |
3162 | * @since 1.5.0 |
3163 | * |
3164 | * @param array $args Method parameters. |
3165 | * @return array |
3166 | */ |
3167 | function pingback_ping($args) { |
3168 | global $wpdb; |
3169 |
|
3170 | do_action('xmlrpc_call', 'pingback.ping'); |
3171 |
|
3172 | $this->escape($args); |
3173 |
|
3174 | $pagelinkedfrom = $args[0]; |
3175 | $pagelinkedto = $args[1]; |
3176 |
|
3177 | $title = ''; |
3178 |
|
3179 | $pagelinkedfrom = str_replace('&', '&', $pagelinkedfrom); |
Line | Code |
3333 | * @since 1.5.0 |
3334 | * |
3335 | * @param array $args Method parameters. |
3336 | * @return array |
3337 | */ |
3338 | function pingback_extensions_getPingbacks($args) { |
3339 |
|
3340 | global $wpdb; |
3341 |
|
3342 | do_action('xmlrpc_call', 'pingback.extensions.getPingsbacks'); |
3343 |
|
3344 | $this->escape($args); |
3345 |
|
3346 | $url = $args; |
3347 |
|
3348 | $post_ID = url_to_postid($url); |
3349 | if (!$post_ID) { |
3350 | // We aren't sure that the resource is available and/or pingback enabled |
3351 | 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.')); |