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 |
---|---|
451 | $this->escape( $args ); |
452 |
|
453 | $username = $args[0]; |
454 | $password = $args[1]; |
455 |
|
456 | if ( !$user = $this->login($username, $password) ) { |
457 | return $this->error; |
458 | } |
459 |
|
460 | do_action( 'xmlrpc_call', 'wp.getUsersBlogs' ); |
461 |
|
462 | $blogs = (array) get_blogs_of_user( $user->ID ); |
463 | $struct = array( ); |
464 |
|
465 | foreach( $blogs as $blog ) { |
466 | // Don't include blogs that aren't hosted at this site |
467 | if( $blog->site_id != $current_site->id ) |
468 | continue; |
469 |
|
Line | Code |
502 | $password = $args[3]; |
503 |
|
504 | if ( !$user = $this->login($username, $password) ) { |
505 | return $this->error; |
506 | } |
507 |
|
508 | if( !current_user_can( 'edit_page', $page_id ) ) |
509 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this page.' ) ); |
510 |
|
511 | do_action('xmlrpc_call', 'wp.getPage'); |
512 |
|
513 | // Lookup page info. |
514 | $page = get_page($page_id); |
515 |
|
516 | // If we found the page then format the data. |
517 | if($page->ID && ($page->post_type == "page")) { |
518 | // Get all of the page content and link. |
519 | $full_page = get_extended($page->post_content); |
520 | $link = post_permalink($page->ID); |
Line | Code |
604 | $num_pages = isset($args[3]) ? (int) $args[3] : 10; |
605 |
|
606 | if ( !$user = $this->login($username, $password) ) { |
607 | return $this->error; |
608 | } |
609 |
|
610 | if( !current_user_can( 'edit_pages' ) ) |
611 | return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) ); |
612 |
|
613 | do_action('xmlrpc_call', 'wp.getPages'); |
614 |
|
615 | $pages = get_posts( array('post_type' => 'page', 'post_status' => 'any', 'numberposts' => $num_pages) ); |
616 | $num_pages = count($pages); |
617 |
|
618 | // If we have pages, put together their info. |
619 | if($num_pages >= 1) { |
620 | $pages_struct = array(); |
621 |
|
622 | for($i = 0; $i < $num_pages; $i++) { |
Line | Code |
647 | $username = $this->escape($args[1]); |
648 | $password = $this->escape($args[2]); |
649 | $page = $args[3]; |
650 | $publish = $args[4]; |
651 |
|
652 | if ( !$user = $this->login($username, $password) ) { |
653 | return $this->error; |
654 | } |
655 |
|
656 | do_action('xmlrpc_call', 'wp.newPage'); |
657 |
|
658 | // Make sure the user is allowed to add new pages. |
659 | if(!current_user_can("publish_pages")) { |
660 | return(new IXR_Error(401, __("Sorry, you cannot add new pages."))); |
661 | } |
662 |
|
663 | // Mark this as content for a page. |
664 | $args[3]["post_type"] = "page"; |
665 |
|
Line | Code |
681 | $blog_id = (int) $args[0]; |
682 | $username = $args[1]; |
683 | $password = $args[2]; |
684 | $page_id = (int) $args[3]; |
685 |
|
686 | if ( !$user = $this->login($username, $password) ) { |
687 | return $this->error; |
688 | } |
689 |
|
690 | do_action('xmlrpc_call', 'wp.deletePage'); |
691 |
|
692 | // Get the current page based on the page_id and |
693 | // make sure it is a page and not a post. |
694 | $actual_page = wp_get_single_post($page_id, ARRAY_A); |
695 | if( |
696 | !$actual_page |
697 | || ($actual_page["post_type"] != "page") |
698 | ) { |
699 | return(new IXR_Error(404, __("Sorry, no such page."))); |
Line | Code |
728 | $username = $this->escape($args[2]); |
729 | $password = $this->escape($args[3]); |
730 | $content = $args[4]; |
731 | $publish = $args[5]; |
732 |
|
733 | if ( !$user = $this->login($username, $password) ) { |
734 | return $this->error; |
735 | } |
736 |
|
737 | do_action('xmlrpc_call', 'wp.editPage'); |
738 |
|
739 | // Get the page data and make sure it is a page. |
740 | $actual_page = wp_get_single_post($page_id, ARRAY_A); |
741 | if( |
742 | !$actual_page |
743 | || ($actual_page["post_type"] != "page") |
744 | ) { |
745 | return(new IXR_Error(404, __("Sorry, no such page."))); |
746 | } |
Line | Code |
784 | $password = $args[2]; |
785 |
|
786 | if ( !$user = $this->login($username, $password) ) { |
787 | return $this->error; |
788 | } |
789 |
|
790 | if( !current_user_can( 'edit_pages' ) ) |
791 | return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) ); |
792 |
|
793 | do_action('xmlrpc_call', 'wp.getPageList'); |
794 |
|
795 | // Get list of pages ids and titles |
796 | $page_list = $wpdb->get_results(" |
797 | SELECT ID page_id, |
798 | post_title page_title, |
799 | post_parent page_parent_id, |
800 | post_date_gmt, |
801 | post_date, |
802 | post_status |
Line | Code |
846 |
|
847 | if ( !$user = $this->login($username, $password) ) { |
848 | return $this->error; |
849 | } |
850 |
|
851 | if(!current_user_can("edit_posts")) { |
852 | return(new IXR_Error(401, __("Sorry, you cannot edit posts on this blog."))); |
853 | } |
854 |
|
855 | do_action('xmlrpc_call', 'wp.getAuthors'); |
856 |
|
857 | $authors = array(); |
858 | foreach( (array) get_users_of_blog() as $row ) { |
859 | $authors[] = array( |
860 | "user_id" => $row->user_id, |
861 | "user_login" => $row->user_login, |
862 | "display_name" => $row->display_name |
863 | ); |
864 | } |
Line | Code |
883 |
|
884 | if ( !$user = $this->login($username, $password) ) { |
885 | return $this->error; |
886 | } |
887 |
|
888 | if( !current_user_can( 'edit_posts' ) ) { |
889 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this blog in order to view tags.' ) ); |
890 | } |
891 |
|
892 | do_action( 'xmlrpc_call', 'wp.getKeywords' ); |
893 |
|
894 | $tags = array( ); |
895 |
|
896 | if( $all_tags = get_tags( ) ) { |
897 | foreach( (array) $all_tags as $tag ) { |
898 | $struct['tag_id'] = $tag->term_id; |
899 | $struct['name'] = $tag->name; |
900 | $struct['count'] = $tag->count; |
901 | $struct['slug'] = $tag->slug; |
Line | Code |
923 | $blog_id = (int) $args[0]; |
924 | $username = $args[1]; |
925 | $password = $args[2]; |
926 | $category = $args[3]; |
927 |
|
928 | if ( !$user = $this->login($username, $password) ) { |
929 | return $this->error; |
930 | } |
931 |
|
932 | do_action('xmlrpc_call', 'wp.newCategory'); |
933 |
|
934 | // Make sure the user is allowed to add a category. |
935 | if(!current_user_can("manage_categories")) { |
936 | return(new IXR_Error(401, __("Sorry, you do not have the right to add a category."))); |
937 | } |
938 |
|
939 | // If no slug was provided make it empty so that |
940 | // WordPress will generate one. |
941 | if(empty($category["slug"])) { |
Line | Code |
981 | $blog_id = (int) $args[0]; |
982 | $username = $args[1]; |
983 | $password = $args[2]; |
984 | $category_id = (int) $args[3]; |
985 |
|
986 | if ( !$user = $this->login($username, $password) ) { |
987 | return $this->error; |
988 | } |
989 |
|
990 | do_action('xmlrpc_call', 'wp.deleteCategory'); |
991 |
|
992 | if( !current_user_can("manage_categories") ) { |
993 | return new IXR_Error( 401, __( "Sorry, you do not have the right to delete a category." ) ); |
994 | } |
995 |
|
996 | return wp_delete_category( $category_id ); |
997 | } |
998 |
|
999 | /** |
Line | Code |
1014 | $max_results = (int) $args[4]; |
1015 |
|
1016 | if ( !$user = $this->login($username, $password) ) { |
1017 | return $this->error; |
1018 | } |
1019 |
|
1020 | if( !current_user_can( 'edit_posts' ) ) |
1021 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts to this blog in order to view categories.' ) ); |
1022 |
|
1023 | do_action('xmlrpc_call', 'wp.suggestCategories'); |
1024 |
|
1025 | $category_suggestions = array(); |
1026 | $args = array('get' => 'all', 'number' => $max_results, 'name__like' => $category); |
1027 | foreach ( (array) get_categories($args) as $cat ) { |
1028 | $category_suggestions[] = array( |
1029 | "category_id" => $cat->cat_ID, |
1030 | "category_name" => $cat->cat_name |
1031 | ); |
1032 | } |
Line | Code |
1051 | $comment_id = (int) $args[3]; |
1052 |
|
1053 | if ( !$user = $this->login($username, $password) ) { |
1054 | return $this->error; |
1055 | } |
1056 |
|
1057 | if ( !current_user_can( 'moderate_comments' ) ) |
1058 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this blog.' ) ); |
1059 |
|
1060 | do_action('xmlrpc_call', 'wp.getComment'); |
1061 |
|
1062 | if ( ! $comment = get_comment($comment_id) ) |
1063 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
1064 |
|
1065 | // Format page date. |
1066 | $comment_date = mysql2date("Ymd\TH:i:s", $comment->comment_date, false); |
1067 | $comment_date_gmt = mysql2date("Ymd\TH:i:s", $comment->comment_date_gmt, false); |
1068 |
|
1069 | if ( '0' == $comment->comment_approved ) |
Line | Code |
1114 | $struct = $args[3]; |
1115 |
|
1116 | if ( !$user = $this->login($username, $password) ) { |
1117 | return $this->error; |
1118 | } |
1119 |
|
1120 | if ( !current_user_can( 'moderate_comments' ) ) |
1121 | return new IXR_Error( 401, __( 'Sorry, you cannot edit comments.' ) ); |
1122 |
|
1123 | do_action('xmlrpc_call', 'wp.getComments'); |
1124 |
|
1125 | if ( isset($struct['status']) ) |
1126 | $status = $struct['status']; |
1127 | else |
1128 | $status = ''; |
1129 |
|
1130 | $post_id = ''; |
1131 | if ( isset($struct['post_id']) ) |
1132 | $post_id = absint($struct['post_id']); |
Line | Code |
1174 | $comment_ID = (int) $args[3]; |
1175 |
|
1176 | if ( !$user = $this->login($username, $password) ) { |
1177 | return $this->error; |
1178 | } |
1179 |
|
1180 | if ( !current_user_can( 'moderate_comments' ) ) |
1181 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this blog.' ) ); |
1182 |
|
1183 | do_action('xmlrpc_call', 'wp.deleteComment'); |
1184 |
|
1185 | if ( ! get_comment($comment_ID) ) |
1186 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
1187 |
|
1188 | return wp_delete_comment($comment_ID); |
1189 | } |
1190 |
|
1191 | /** |
1192 | * Edit comment. |
Line | Code |
1206 | $content_struct = $args[4]; |
1207 |
|
1208 | if ( !$user = $this->login($username, $password) ) { |
1209 | return $this->error; |
1210 | } |
1211 |
|
1212 | if ( !current_user_can( 'moderate_comments' ) ) |
1213 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this blog.' ) ); |
1214 |
|
1215 | do_action('xmlrpc_call', 'wp.editComment'); |
1216 |
|
1217 | if ( ! get_comment($comment_ID) ) |
1218 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
1219 |
|
1220 | if ( isset($content_struct['status']) ) { |
1221 | $statuses = get_comment_statuses(); |
1222 | $statuses = array_keys($statuses); |
1223 |
|
1224 | if ( ! in_array($content_struct['status'], $statuses) ) |
Line | Code |
1330 | elseif ( !is_email($comment['comment_author_email']) ) |
1331 | return new IXR_Error( 403, __( 'A valid email address is required' ) ); |
1332 | } |
1333 | } |
1334 |
|
1335 | $comment['comment_parent'] = isset($content_struct['comment_parent']) ? absint($content_struct['comment_parent']) : 0; |
1336 |
|
1337 | $comment['comment_content'] = $content_struct['content']; |
1338 |
|
1339 | do_action('xmlrpc_call', 'wp.newComment'); |
1340 |
|
1341 | return wp_new_comment($comment); |
1342 | } |
1343 |
|
1344 | /** |
1345 | * Retrieve all of the comment status. |
1346 | * |
1347 | * @since 2.7.0 |
1348 | * |
Line | Code |
1357 | $password = $args[2]; |
1358 |
|
1359 | if ( !$user = $this->login($username, $password) ) { |
1360 | return $this->error; |
1361 | } |
1362 |
|
1363 | if ( !current_user_can( 'moderate_comments' ) ) |
1364 | return new IXR_Error( 403, __( 'You are not allowed access to details about this blog.' ) ); |
1365 |
|
1366 | do_action('xmlrpc_call', 'wp.getCommentStatusList'); |
1367 |
|
1368 | return get_comment_statuses( ); |
1369 | } |
1370 |
|
1371 | /** |
1372 | * Retrieve comment count. |
1373 | * |
1374 | * @since 2.5.0 |
1375 | * |
Line | Code |
1386 |
|
1387 | if ( !$user = $this->login($username, $password) ) { |
1388 | return $this->error; |
1389 | } |
1390 |
|
1391 | if( !current_user_can( 'edit_posts' ) ) { |
1392 | return new IXR_Error( 403, __( 'You are not allowed access to details about comments.' ) ); |
1393 | } |
1394 |
|
1395 | do_action('xmlrpc_call', 'wp.getCommentCount'); |
1396 |
|
1397 | $count = wp_count_comments( $post_id ); |
1398 | return array( |
1399 | "approved" => $count->approved, |
1400 | "awaiting_moderation" => $count->moderated, |
1401 | "spam" => $count->spam, |
1402 | "total_comments" => $count->total_comments |
1403 | ); |
1404 | } |
Line | Code |
1420 |
|
1421 | if ( !$user = $this->login($username, $password) ) { |
1422 | return $this->error; |
1423 | } |
1424 |
|
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.getPostStatusList'); |
1430 |
|
1431 | return get_post_statuses( ); |
1432 | } |
1433 |
|
1434 | /** |
1435 | * Retrieve page statuses. |
1436 | * |
1437 | * @since 2.5.0 |
1438 | * |
Line | Code |
1448 |
|
1449 | if ( !$user = $this->login($username, $password) ) { |
1450 | return $this->error; |
1451 | } |
1452 |
|
1453 | if( !current_user_can( 'edit_posts' ) ) { |
1454 | return new IXR_Error( 403, __( 'You are not allowed access to details about this blog.' ) ); |
1455 | } |
1456 |
|
1457 | do_action('xmlrpc_call', 'wp.getPageStatusList'); |
1458 |
|
1459 | return get_page_statuses( ); |
1460 | } |
1461 |
|
1462 | /** |
1463 | * Retrieve page templates. |
1464 | * |
1465 | * @since 2.6.0 |
1466 | * |
Line | Code |
1599 | $this->escape($args); |
1600 |
|
1601 | $username = $args[1]; |
1602 | $password = $args[2]; |
1603 |
|
1604 | if ( !$user = $this->login($username, $password) ) { |
1605 | return $this->error; |
1606 | } |
1607 |
|
1608 | do_action('xmlrpc_call', 'blogger.getUsersBlogs'); |
1609 |
|
1610 | $is_admin = current_user_can('manage_options'); |
1611 |
|
1612 | $struct = array( |
1613 | 'isAdmin' => $is_admin, |
1614 | 'url' => get_option('home') . '/', |
1615 | 'blogid' => '1', |
1616 | 'blogName' => get_option('blogname'), |
1617 | 'xmlrpc' => site_url( 'xmlrpc.php' ) |
Line | Code |
1638 | $password = $args[2]; |
1639 |
|
1640 | if ( !$user = $this->login($username, $password) ) { |
1641 | return $this->error; |
1642 | } |
1643 |
|
1644 | if( !current_user_can( 'edit_posts' ) ) |
1645 | return new IXR_Error( 401, __( 'Sorry, you do not have access to user data on this blog.' ) ); |
1646 |
|
1647 | do_action('xmlrpc_call', 'blogger.getUserInfo'); |
1648 |
|
1649 | $struct = array( |
1650 | 'nickname' => $user->nickname, |
1651 | 'userid' => $user->ID, |
1652 | 'url' => $user->user_url, |
1653 | 'lastname' => $user->last_name, |
1654 | 'firstname' => $user->first_name |
1655 | ); |
1656 |
|
Line | Code |
1674 | $password = $args[3]; |
1675 |
|
1676 | if ( !$user = $this->login($username, $password) ) { |
1677 | return $this->error; |
1678 | } |
1679 |
|
1680 | if( !current_user_can( 'edit_post', $post_ID ) ) |
1681 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); |
1682 |
|
1683 | do_action('xmlrpc_call', 'blogger.getPost'); |
1684 |
|
1685 | $post_data = wp_get_single_post($post_ID, ARRAY_A); |
1686 |
|
1687 | $categories = implode(',', wp_get_post_categories($post_ID)); |
1688 |
|
1689 | $content = '<title>'.stripslashes($post_data['post_title']).'</title>'; |
1690 | $content .= '<category>'.$categories.'</category>'; |
1691 | $content .= stripslashes($post_data['post_content']); |
1692 |
|
Line | Code |
1715 | $blog_ID = (int) $args[1]; /* though we don't use it yet */ |
1716 | $username = $args[2]; |
1717 | $password = $args[3]; |
1718 | $num_posts = $args[4]; |
1719 |
|
1720 | if ( !$user = $this->login($username, $password) ) { |
1721 | return $this->error; |
1722 | } |
1723 |
|
1724 | do_action('xmlrpc_call', 'blogger.getRecentPosts'); |
1725 |
|
1726 | $posts_list = wp_get_recent_posts($num_posts); |
1727 |
|
1728 | if (!$posts_list) { |
1729 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
1730 | return $this->error; |
1731 | } |
1732 |
|
1733 | foreach ($posts_list as $entry) { |
Line | Code |
1773 | $blog_ID = (int) $args[1]; |
1774 | $username = $args[2]; |
1775 | $password = $args[3]; |
1776 | $template = $args[4]; /* could be 'main' or 'archiveIndex', but we don't use it */ |
1777 |
|
1778 | if ( !$user = $this->login($username, $password) ) { |
1779 | return $this->error; |
1780 | } |
1781 |
|
1782 | do_action('xmlrpc_call', 'blogger.getTemplate'); |
1783 |
|
1784 | if ( !current_user_can('edit_themes') ) { |
1785 | return new IXR_Error(401, __('Sorry, this user can not edit the template.')); |
1786 | } |
1787 |
|
1788 | /* warning: here we make the assumption that the blog's URL is on the same server */ |
1789 | $filename = get_option('home') . '/'; |
1790 | $filename = preg_replace('#https?://.+?/#', $_SERVER['DOCUMENT_ROOT'].'/', $filename); |
1791 |
|
Line | Code |
1815 | $username = $args[2]; |
1816 | $password = $args[3]; |
1817 | $content = $args[4]; |
1818 | $template = $args[5]; /* could be 'main' or 'archiveIndex', but we don't use it */ |
1819 |
|
1820 | if ( !$user = $this->login($username, $password) ) { |
1821 | return $this->error; |
1822 | } |
1823 |
|
1824 | do_action('xmlrpc_call', 'blogger.setTemplate'); |
1825 |
|
1826 | if ( !current_user_can('edit_themes') ) { |
1827 | return new IXR_Error(401, __('Sorry, this user cannot edit the template.')); |
1828 | } |
1829 |
|
1830 | /* warning: here we make the assumption that the blog's URL is on the same server */ |
1831 | $filename = get_option('home') . '/'; |
1832 | $filename = preg_replace('#https?://.+?/#', $_SERVER['DOCUMENT_ROOT'].'/', $filename); |
1833 |
|
Line | Code |
1857 | $username = $args[2]; |
1858 | $password = $args[3]; |
1859 | $content = $args[4]; |
1860 | $publish = $args[5]; |
1861 |
|
1862 | if ( !$user = $this->login($username, $password) ) { |
1863 | return $this->error; |
1864 | } |
1865 |
|
1866 | do_action('xmlrpc_call', 'blogger.newPost'); |
1867 |
|
1868 | $cap = ($publish) ? 'publish_posts' : 'edit_posts'; |
1869 | if ( !current_user_can($cap) ) |
1870 | return new IXR_Error(401, __('Sorry, you are not allowed to post on this blog.')); |
1871 |
|
1872 | $post_status = ($publish) ? 'publish' : 'draft'; |
1873 |
|
1874 | $post_author = $user->ID; |
1875 |
|
Line | Code |
1912 | $username = $args[2]; |
1913 | $password = $args[3]; |
1914 | $content = $args[4]; |
1915 | $publish = $args[5]; |
1916 |
|
1917 | if ( !$user = $this->login($username, $password) ) { |
1918 | return $this->error; |
1919 | } |
1920 |
|
1921 | do_action('xmlrpc_call', 'blogger.editPost'); |
1922 |
|
1923 | $actual_post = wp_get_single_post($post_ID,ARRAY_A); |
1924 |
|
1925 | if (!$actual_post || $actual_post['post_type'] != 'post') { |
1926 | return new IXR_Error(404, __('Sorry, no such post.')); |
1927 | } |
1928 |
|
1929 | $this->escape($actual_post); |
1930 |
|
Line | Code |
1966 | $post_ID = (int) $args[1]; |
1967 | $username = $args[2]; |
1968 | $password = $args[3]; |
1969 | $publish = $args[4]; |
1970 |
|
1971 | if ( !$user = $this->login($username, $password) ) { |
1972 | return $this->error; |
1973 | } |
1974 |
|
1975 | do_action('xmlrpc_call', 'blogger.deletePost'); |
1976 |
|
1977 | $actual_post = wp_get_single_post($post_ID,ARRAY_A); |
1978 |
|
1979 | if (!$actual_post || $actual_post['post_type'] != 'post') { |
1980 | return new IXR_Error(404, __('Sorry, no such post.')); |
1981 | } |
1982 |
|
1983 | if ( !current_user_can('edit_post', $post_ID) ) |
1984 | return new IXR_Error(401, __('Sorry, you do not have the right to delete this post.')); |
Line | Code |
2011 | $username = $args[1]; |
2012 | $password = $args[2]; |
2013 | $content_struct = $args[3]; |
2014 | $publish = $args[4]; |
2015 |
|
2016 | if ( !$user = $this->login($username, $password) ) { |
2017 | return $this->error; |
2018 | } |
2019 |
|
2020 | do_action('xmlrpc_call', 'metaWeblog.newPost'); |
2021 |
|
2022 | $cap = ( $publish ) ? 'publish_posts' : 'edit_posts'; |
2023 | $error_message = __( 'Sorry, you are not allowed to publish posts on this blog.' ); |
2024 | $post_type = 'post'; |
2025 | $page_template = ''; |
2026 | if( !empty( $content_struct['post_type'] ) ) { |
2027 | if( $content_struct['post_type'] == 'page' ) { |
2028 | $cap = ( $publish ) ? 'publish_pages' : 'edit_pages'; |
2029 | $error_message = __( 'Sorry, you are not allowed to publish pages on this blog.' ); |
Line | Code |
2308 | $username = $args[1]; |
2309 | $password = $args[2]; |
2310 | $content_struct = $args[3]; |
2311 | $publish = $args[4]; |
2312 |
|
2313 | if ( !$user = $this->login($username, $password) ) { |
2314 | return $this->error; |
2315 | } |
2316 |
|
2317 | do_action('xmlrpc_call', 'metaWeblog.editPost'); |
2318 |
|
2319 | $cap = ( $publish ) ? 'publish_posts' : 'edit_posts'; |
2320 | $error_message = __( 'Sorry, you are not allowed to publish posts on this blog.' ); |
2321 | $post_type = 'post'; |
2322 | $page_template = ''; |
2323 | if( !empty( $content_struct['post_type'] ) ) { |
2324 | if( $content_struct['post_type'] == 'page' ) { |
2325 | $cap = ( $publish ) ? 'publish_pages' : 'edit_pages'; |
2326 | $error_message = __( 'Sorry, you are not allowed to publish pages on this blog.' ); |
Line | Code |
2573 | $password = $args[2]; |
2574 |
|
2575 | if ( !$user = $this->login($username, $password) ) { |
2576 | return $this->error; |
2577 | } |
2578 |
|
2579 | if( !current_user_can( 'edit_post', $post_ID ) ) |
2580 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); |
2581 |
|
2582 | do_action('xmlrpc_call', 'metaWeblog.getPost'); |
2583 |
|
2584 | $postdata = wp_get_single_post($post_ID, ARRAY_A); |
2585 |
|
2586 | if ($postdata['post_date'] != '') { |
2587 | $post_date = mysql2date('Ymd\TH:i:s', $postdata['post_date'], false); |
2588 | $post_date_gmt = mysql2date('Ymd\TH:i:s', $postdata['post_date_gmt'], false); |
2589 |
|
2590 | // For drafts use the GMT version of the post date |
2591 | if ( $postdata['post_status'] == 'draft' ) { |
Line | Code |
2687 | $blog_ID = (int) $args[0]; |
2688 | $username = $args[1]; |
2689 | $password = $args[2]; |
2690 | $num_posts = (int) $args[3]; |
2691 |
|
2692 | if ( !$user = $this->login($username, $password) ) { |
2693 | return $this->error; |
2694 | } |
2695 |
|
2696 | do_action('xmlrpc_call', 'metaWeblog.getRecentPosts'); |
2697 |
|
2698 | $posts_list = wp_get_recent_posts($num_posts); |
2699 |
|
2700 | if (!$posts_list) { |
2701 | return array( ); |
2702 | } |
2703 |
|
2704 | foreach ($posts_list as $entry) { |
2705 | if( !current_user_can( 'edit_post', $entry['ID'] ) ) |
Line | Code |
2796 | $password = $args[2]; |
2797 |
|
2798 | if ( !$user = $this->login($username, $password) ) { |
2799 | return $this->error; |
2800 | } |
2801 |
|
2802 | if( !current_user_can( 'edit_posts' ) ) |
2803 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this blog in order to view categories.' ) ); |
2804 |
|
2805 | do_action('xmlrpc_call', 'metaWeblog.getCategories'); |
2806 |
|
2807 | $categories_struct = array(); |
2808 |
|
2809 | if ( $cats = get_categories('get=all') ) { |
2810 | foreach ( $cats as $cat ) { |
2811 | $struct['categoryId'] = $cat->term_id; |
2812 | $struct['parentId'] = $cat->parent; |
2813 | $struct['description'] = $cat->name; |
2814 | $struct['categoryDescription'] = $cat->description; |
Line | Code |
2847 | $type = $data['type']; |
2848 | $bits = $data['bits']; |
2849 |
|
2850 | logIO('O', '(MW) Received '.strlen($bits).' bytes'); |
2851 |
|
2852 | if ( !$user = $this->login($username, $password) ) { |
2853 | return $this->error; |
2854 | } |
2855 |
|
2856 | do_action('xmlrpc_call', 'metaWeblog.newMediaObject'); |
2857 |
|
2858 | if ( !current_user_can('upload_files') ) { |
2859 | logIO('O', '(MW) User does not have upload_files capability'); |
2860 | $this->error = new IXR_Error(401, __('You are not allowed to upload files to this site.')); |
2861 | return $this->error; |
2862 | } |
2863 |
|
2864 | if ( $upload_err = apply_filters( "pre_upload_error", false ) ) |
2865 | return new IXR_Error(500, $upload_err); |
Line | Code |
2926 | $blog_ID = (int) $args[0]; |
2927 | $username = $args[1]; |
2928 | $password = $args[2]; |
2929 | $num_posts = (int) $args[3]; |
2930 |
|
2931 | if ( !$user = $this->login($username, $password) ) { |
2932 | return $this->error; |
2933 | } |
2934 |
|
2935 | do_action('xmlrpc_call', 'mt.getRecentPostTitles'); |
2936 |
|
2937 | $posts_list = wp_get_recent_posts($num_posts); |
2938 |
|
2939 | if (!$posts_list) { |
2940 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
2941 | return $this->error; |
2942 | } |
2943 |
|
2944 | foreach ($posts_list as $entry) { |
Line | Code |
2988 | $password = $args[2]; |
2989 |
|
2990 | if ( !$user = $this->login($username, $password) ) { |
2991 | return $this->error; |
2992 | } |
2993 |
|
2994 | if( !current_user_can( 'edit_posts' ) ) |
2995 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this blog in order to view categories.' ) ); |
2996 |
|
2997 | do_action('xmlrpc_call', 'mt.getCategoryList'); |
2998 |
|
2999 | $categories_struct = array(); |
3000 |
|
3001 | if ( $cats = get_categories('hide_empty=0&hierarchical=0') ) { |
3002 | foreach ($cats as $cat) { |
3003 | $struct['categoryId'] = $cat->term_id; |
3004 | $struct['categoryName'] = $cat->name; |
3005 |
|
3006 | $categories_struct[] = $struct; |
Line | Code |
3027 | $password = $args[2]; |
3028 |
|
3029 | if ( !$user = $this->login($username, $password) ) { |
3030 | return $this->error; |
3031 | } |
3032 |
|
3033 | if( !current_user_can( 'edit_post', $post_ID ) ) |
3034 | return new IXR_Error( 401, __( 'Sorry, you can not edit this post.' ) ); |
3035 |
|
3036 | do_action('xmlrpc_call', 'mt.getPostCategories'); |
3037 |
|
3038 | $categories = array(); |
3039 | $catids = wp_get_post_categories(intval($post_ID)); |
3040 | // first listed category will be the primary category |
3041 | $isPrimary = true; |
3042 | foreach($catids as $catid) { |
3043 | $categories[] = array( |
3044 | 'categoryName' => get_cat_name($catid), |
3045 | 'categoryId' => (string) $catid, |
Line | Code |
3066 | $post_ID = (int) $args[0]; |
3067 | $username = $args[1]; |
3068 | $password = $args[2]; |
3069 | $categories = $args[3]; |
3070 |
|
3071 | if ( !$user = $this->login($username, $password) ) { |
3072 | return $this->error; |
3073 | } |
3074 |
|
3075 | do_action('xmlrpc_call', 'mt.setPostCategories'); |
3076 |
|
3077 | if ( !current_user_can('edit_post', $post_ID) ) |
3078 | return new IXR_Error(401, __('Sorry, you cannot edit this post.')); |
3079 |
|
3080 | foreach($categories as $cat) { |
3081 | $catids[] = $cat['categoryId']; |
3082 | } |
3083 |
|
3084 | wp_set_post_categories($post_ID, $catids); |
Line | Code |
3090 | * Retrieve an array of methods supported by this server. |
3091 | * |
3092 | * @since 1.5.0 |
3093 | * |
3094 | * @param array $args Method parameters. |
3095 | * @return array |
3096 | */ |
3097 | function mt_supportedMethods($args) { |
3098 |
|
3099 | do_action('xmlrpc_call', 'mt.supportedMethods'); |
3100 |
|
3101 | $supported_methods = array(); |
3102 | foreach($this->methods as $key=>$value) { |
3103 | $supported_methods[] = $key; |
3104 | } |
3105 |
|
3106 | return $supported_methods; |
3107 | } |
3108 |
|
3109 | /** |
3110 | * Retrieve an empty array because we don't support per-post text filters. |
3111 | * |
3112 | * @since 1.5.0 |
3113 | * |
3114 | * @param array $args Method parameters. |
3115 | */ |
3116 | function mt_supportedTextFilters($args) { |
3117 | do_action('xmlrpc_call', 'mt.supportedTextFilters'); |
3118 | return apply_filters('xmlrpc_text_filters', array()); |
3119 | } |
3120 |
|
3121 | /** |
3122 | * Retrieve trackbacks sent to a given post. |
3123 | * |
3124 | * @since 1.5.0 |
3125 | * |
3126 | * @param array $args Method parameters. |
3127 | * @return mixed |
3128 | */ |
3129 | function mt_getTrackbackPings($args) { |
3130 |
|
3131 | global $wpdb; |
3132 |
|
3133 | $post_ID = intval($args); |
3134 |
|
3135 | do_action('xmlrpc_call', 'mt.getTrackbackPings'); |
3136 |
|
3137 | $actual_post = wp_get_single_post($post_ID, ARRAY_A); |
3138 |
|
3139 | if (!$actual_post) { |
3140 | return new IXR_Error(404, __('Sorry, no such post.')); |
3141 | } |
3142 |
|
3143 | $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) ); |
3144 |
|
Line | Code |
3176 |
|
3177 | $post_ID = (int) $args[0]; |
3178 | $username = $args[1]; |
3179 | $password = $args[2]; |
3180 |
|
3181 | if ( !$user = $this->login($username, $password) ) { |
3182 | return $this->error; |
3183 | } |
3184 |
|
3185 | do_action('xmlrpc_call', 'mt.publishPost'); |
3186 |
|
3187 | if ( !current_user_can('edit_post', $post_ID) ) |
3188 | return new IXR_Error(401, __('Sorry, you cannot edit this post.')); |
3189 |
|
3190 | $postdata = wp_get_single_post($post_ID,ARRAY_A); |
3191 |
|
3192 | $postdata['post_status'] = 'publish'; |
3193 |
|
3194 | // retain old cats |
Line | Code |
3210 | * |
3211 | * @since 1.5.0 |
3212 | * |
3213 | * @param array $args Method parameters. |
3214 | * @return array |
3215 | */ |
3216 | function pingback_ping($args) { |
3217 | global $wpdb; |
3218 |
|
3219 | do_action('xmlrpc_call', 'pingback.ping'); |
3220 |
|
3221 | $this->escape($args); |
3222 |
|
3223 | $pagelinkedfrom = $args[0]; |
3224 | $pagelinkedto = $args[1]; |
3225 |
|
3226 | $title = ''; |
3227 |
|
3228 | $pagelinkedfrom = str_replace('&', '&', $pagelinkedfrom); |
Line | Code |
3382 | * @since 1.5.0 |
3383 | * |
3384 | * @param array $args Method parameters. |
3385 | * @return array |
3386 | */ |
3387 | function pingback_extensions_getPingbacks($args) { |
3388 |
|
3389 | global $wpdb; |
3390 |
|
3391 | do_action('xmlrpc_call', 'pingback.extensions.getPingbacks'); |
3392 |
|
3393 | $this->escape($args); |
3394 |
|
3395 | $url = $args; |
3396 |
|
3397 | $post_ID = url_to_postid($url); |
3398 | if (!$post_ID) { |
3399 | // We aren't sure that the resource is available and/or pingback enabled |
3400 | 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.')); |