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 |
602 | $password = $args[2]; |
603 | $num_pages = isset($args[3]) ? (int) $args[3] : 10; |
604 |
|
605 | if ( !$user = $this->login($username, $password) ) |
606 | return $this->error; |
607 |
|
608 | if ( !current_user_can( 'edit_pages' ) ) |
609 | return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) ); |
610 |
|
611 | do_action('xmlrpc_call', 'wp.getPages'); |
612 |
|
613 | $pages = get_posts( array('post_type' => 'page', 'post_status' => 'any', 'numberposts' => $num_pages) ); |
614 | $num_pages = count($pages); |
615 |
|
616 | // If we have pages, put together their info. |
617 | if ( $num_pages >= 1 ) { |
618 | $pages_struct = array(); |
619 |
|
620 | for ( $i = 0; $i < $num_pages; $i++ ) { |
Line | Code |
644 | // Items not escaped here will be escaped in newPost. |
645 | $username = $this->escape($args[1]); |
646 | $password = $this->escape($args[2]); |
647 | $page = $args[3]; |
648 | $publish = $args[4]; |
649 |
|
650 | if ( !$user = $this->login($username, $password) ) |
651 | return $this->error; |
652 |
|
653 | do_action('xmlrpc_call', 'wp.newPage'); |
654 |
|
655 | // Make sure the user is allowed to add new pages. |
656 | if ( !current_user_can("publish_pages") ) |
657 | return(new IXR_Error(401, __("Sorry, you cannot add new pages."))); |
658 |
|
659 | // Mark this as content for a page. |
660 | $args[3]["post_type"] = "page"; |
661 |
|
662 | // Let mw_newPost do all of the heavy lifting. |
Line | Code |
676 |
|
677 | $blog_id = (int) $args[0]; |
678 | $username = $args[1]; |
679 | $password = $args[2]; |
680 | $page_id = (int) $args[3]; |
681 |
|
682 | if ( !$user = $this->login($username, $password) ) |
683 | return $this->error; |
684 |
|
685 | do_action('xmlrpc_call', 'wp.deletePage'); |
686 |
|
687 | // Get the current page based on the page_id and |
688 | // make sure it is a page and not a post. |
689 | $actual_page = wp_get_single_post($page_id, ARRAY_A); |
690 | if ( !$actual_page || ($actual_page["post_type"] != "page") ) |
691 | return(new IXR_Error(404, __("Sorry, no such page."))); |
692 |
|
693 | // Make sure the user can delete pages. |
694 | if ( !current_user_can("delete_page", $page_id) ) |
Line | Code |
716 | $page_id = (int) $this->escape($args[1]); |
717 | $username = $this->escape($args[2]); |
718 | $password = $this->escape($args[3]); |
719 | $content = $args[4]; |
720 | $publish = $args[5]; |
721 |
|
722 | if ( !$user = $this->login($username, $password) ) |
723 | return $this->error; |
724 |
|
725 | do_action('xmlrpc_call', 'wp.editPage'); |
726 |
|
727 | // Get the page data and make sure it is a page. |
728 | $actual_page = wp_get_single_post($page_id, ARRAY_A); |
729 | if ( !$actual_page || ($actual_page["post_type"] != "page") ) |
730 | return(new IXR_Error(404, __("Sorry, no such page."))); |
731 |
|
732 | // Make sure the user is allowed to edit pages. |
733 | if ( !current_user_can("edit_page", $page_id) ) |
734 | return(new IXR_Error(401, __("Sorry, you do not have the right to edit this page."))); |
Line | Code |
766 | $username = $args[1]; |
767 | $password = $args[2]; |
768 |
|
769 | if ( !$user = $this->login($username, $password) ) |
770 | return $this->error; |
771 |
|
772 | if ( !current_user_can( 'edit_pages' ) ) |
773 | return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) ); |
774 |
|
775 | do_action('xmlrpc_call', 'wp.getPageList'); |
776 |
|
777 | // Get list of pages ids and titles |
778 | $page_list = $wpdb->get_results(" |
779 | SELECT ID page_id, |
780 | post_title page_title, |
781 | post_parent page_parent_id, |
782 | post_date_gmt, |
783 | post_date, |
784 | post_status |
Line | Code |
826 | $username = $args[1]; |
827 | $password = $args[2]; |
828 |
|
829 | if ( !$user = $this->login($username, $password) ) |
830 | return $this->error; |
831 |
|
832 | if ( !current_user_can("edit_posts") ) |
833 | return(new IXR_Error(401, __("Sorry, you cannot edit posts on this site."))); |
834 |
|
835 | do_action('xmlrpc_call', 'wp.getAuthors'); |
836 |
|
837 | $authors = array(); |
838 | foreach ( (array) get_users_of_blog() as $row ) { |
839 | $authors[] = array( |
840 | "user_id" => $row->user_id, |
841 | "user_login" => $row->user_login, |
842 | "display_name" => $row->display_name |
843 | ); |
844 | } |
Line | Code |
861 | $username = $args[1]; |
862 | $password = $args[2]; |
863 |
|
864 | if ( !$user = $this->login($username, $password) ) |
865 | return $this->error; |
866 |
|
867 | if ( !current_user_can( 'edit_posts' ) ) |
868 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view tags.' ) ); |
869 |
|
870 | do_action( 'xmlrpc_call', 'wp.getKeywords' ); |
871 |
|
872 | $tags = array( ); |
873 |
|
874 | if ( $all_tags = get_tags() ) { |
875 | foreach( (array) $all_tags as $tag ) { |
876 | $struct['tag_id'] = $tag->term_id; |
877 | $struct['name'] = $tag->name; |
878 | $struct['count'] = $tag->count; |
879 | $struct['slug'] = $tag->slug; |
Line | Code |
900 |
|
901 | $blog_id = (int) $args[0]; |
902 | $username = $args[1]; |
903 | $password = $args[2]; |
904 | $category = $args[3]; |
905 |
|
906 | if ( !$user = $this->login($username, $password) ) |
907 | return $this->error; |
908 |
|
909 | do_action('xmlrpc_call', 'wp.newCategory'); |
910 |
|
911 | // Make sure the user is allowed to add a category. |
912 | if ( !current_user_can("manage_categories") ) |
913 | return(new IXR_Error(401, __("Sorry, you do not have the right to add a category."))); |
914 |
|
915 | // If no slug was provided make it empty so that |
916 | // WordPress will generate one. |
917 | if ( empty($category["slug"]) ) |
918 | $category["slug"] = ""; |
Line | Code |
953 |
|
954 | $blog_id = (int) $args[0]; |
955 | $username = $args[1]; |
956 | $password = $args[2]; |
957 | $category_id = (int) $args[3]; |
958 |
|
959 | if ( !$user = $this->login($username, $password) ) |
960 | return $this->error; |
961 |
|
962 | do_action('xmlrpc_call', 'wp.deleteCategory'); |
963 |
|
964 | if ( !current_user_can("manage_categories") ) |
965 | return new IXR_Error( 401, __( "Sorry, you do not have the right to delete a category." ) ); |
966 |
|
967 | return wp_delete_category( $category_id ); |
968 | } |
969 |
|
970 | /** |
971 | * Retrieve category list. |
Line | Code |
984 | $category = $args[3]; |
985 | $max_results = (int) $args[4]; |
986 |
|
987 | if ( !$user = $this->login($username, $password) ) |
988 | return $this->error; |
989 |
|
990 | if ( !current_user_can( 'edit_posts' ) ) |
991 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts to this site 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 |
1020 | $password = $args[2]; |
1021 | $comment_id = (int) $args[3]; |
1022 |
|
1023 | if ( !$user = $this->login($username, $password) ) |
1024 | return $this->error; |
1025 |
|
1026 | if ( !current_user_can( 'moderate_comments' ) ) |
1027 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
1028 |
|
1029 | do_action('xmlrpc_call', 'wp.getComment'); |
1030 |
|
1031 | if ( ! $comment = get_comment($comment_id) ) |
1032 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
1033 |
|
1034 | // Format page date. |
1035 | $comment_date = mysql2date("Ymd\TH:i:s", $comment->comment_date, false); |
1036 | $comment_date_gmt = mysql2date("Ymd\TH:i:s", $comment->comment_date_gmt, false); |
1037 |
|
1038 | if ( '0' == $comment->comment_approved ) |
Line | Code |
1083 | $password = $args[2]; |
1084 | $struct = $args[3]; |
1085 |
|
1086 | if ( !$user = $this->login($username, $password) ) |
1087 | return $this->error; |
1088 |
|
1089 | if ( !current_user_can( 'moderate_comments' ) ) |
1090 | return new IXR_Error( 401, __( 'Sorry, you cannot edit comments.' ) ); |
1091 |
|
1092 | do_action('xmlrpc_call', 'wp.getComments'); |
1093 |
|
1094 | if ( isset($struct['status']) ) |
1095 | $status = $struct['status']; |
1096 | else |
1097 | $status = ''; |
1098 |
|
1099 | $post_id = ''; |
1100 | if ( isset($struct['post_id']) ) |
1101 | $post_id = absint($struct['post_id']); |
Line | Code |
1142 | $password = $args[2]; |
1143 | $comment_ID = (int) $args[3]; |
1144 |
|
1145 | if ( !$user = $this->login($username, $password) ) |
1146 | return $this->error; |
1147 |
|
1148 | if ( !current_user_can( 'moderate_comments' ) ) |
1149 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
1150 |
|
1151 | do_action('xmlrpc_call', 'wp.deleteComment'); |
1152 |
|
1153 | if ( ! get_comment($comment_ID) ) |
1154 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
1155 |
|
1156 | return wp_delete_comment($comment_ID); |
1157 | } |
1158 |
|
1159 | /** |
1160 | * Edit comment. |
Line | Code |
1173 | $comment_ID = (int) $args[3]; |
1174 | $content_struct = $args[4]; |
1175 |
|
1176 | if ( !$user = $this->login($username, $password) ) |
1177 | return $this->error; |
1178 |
|
1179 | if ( !current_user_can( 'moderate_comments' ) ) |
1180 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
1181 |
|
1182 | do_action('xmlrpc_call', 'wp.editComment'); |
1183 |
|
1184 | if ( ! get_comment($comment_ID) ) |
1185 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
1186 |
|
1187 | if ( isset($content_struct['status']) ) { |
1188 | $statuses = get_comment_statuses(); |
1189 | $statuses = array_keys($statuses); |
1190 |
|
1191 | if ( ! in_array($content_struct['status'], $statuses) ) |
Line | Code |
1297 | elseif ( !is_email($comment['comment_author_email']) ) |
1298 | return new IXR_Error( 403, __( 'A valid email address is required' ) ); |
1299 | } |
1300 | } |
1301 |
|
1302 | $comment['comment_parent'] = isset($content_struct['comment_parent']) ? absint($content_struct['comment_parent']) : 0; |
1303 |
|
1304 | $comment['comment_content'] = $content_struct['content']; |
1305 |
|
1306 | do_action('xmlrpc_call', 'wp.newComment'); |
1307 |
|
1308 | return wp_new_comment($comment); |
1309 | } |
1310 |
|
1311 | /** |
1312 | * Retrieve all of the comment status. |
1313 | * |
1314 | * @since 2.7.0 |
1315 | * |
Line | Code |
1323 | $username = $args[1]; |
1324 | $password = $args[2]; |
1325 |
|
1326 | if ( !$user = $this->login($username, $password) ) |
1327 | return $this->error; |
1328 |
|
1329 | if ( !current_user_can( 'moderate_comments' ) ) |
1330 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
1331 |
|
1332 | do_action('xmlrpc_call', 'wp.getCommentStatusList'); |
1333 |
|
1334 | return get_comment_statuses( ); |
1335 | } |
1336 |
|
1337 | /** |
1338 | * Retrieve comment count. |
1339 | * |
1340 | * @since 2.5.0 |
1341 | * |
Line | Code |
1350 | $password = $args[2]; |
1351 | $post_id = (int) $args[3]; |
1352 |
|
1353 | if ( !$user = $this->login($username, $password) ) |
1354 | return $this->error; |
1355 |
|
1356 | if ( !current_user_can( 'edit_posts' ) ) |
1357 | return new IXR_Error( 403, __( 'You are not allowed access to details about comments.' ) ); |
1358 |
|
1359 | do_action('xmlrpc_call', 'wp.getCommentCount'); |
1360 |
|
1361 | $count = wp_count_comments( $post_id ); |
1362 | return array( |
1363 | "approved" => $count->approved, |
1364 | "awaiting_moderation" => $count->moderated, |
1365 | "spam" => $count->spam, |
1366 | "total_comments" => $count->total_comments |
1367 | ); |
1368 | } |
Line | Code |
1382 | $username = $args[1]; |
1383 | $password = $args[2]; |
1384 |
|
1385 | if ( !$user = $this->login($username, $password) ) |
1386 | return $this->error; |
1387 |
|
1388 | if ( !current_user_can( 'edit_posts' ) ) |
1389 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
1390 |
|
1391 | do_action('xmlrpc_call', 'wp.getPostStatusList'); |
1392 |
|
1393 | return get_post_statuses( ); |
1394 | } |
1395 |
|
1396 | /** |
1397 | * Retrieve page statuses. |
1398 | * |
1399 | * @since 2.5.0 |
1400 | * |
Line | Code |
1408 | $username = $args[1]; |
1409 | $password = $args[2]; |
1410 |
|
1411 | if ( !$user = $this->login($username, $password) ) |
1412 | return $this->error; |
1413 |
|
1414 | if ( !current_user_can( 'edit_posts' ) ) |
1415 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
1416 |
|
1417 | do_action('xmlrpc_call', 'wp.getPageStatusList'); |
1418 |
|
1419 | return get_page_statuses( ); |
1420 | } |
1421 |
|
1422 | /** |
1423 | * Retrieve page templates. |
1424 | * |
1425 | * @since 2.6.0 |
1426 | * |
Line | Code |
1553 |
|
1554 | $this->escape($args); |
1555 |
|
1556 | $username = $args[1]; |
1557 | $password = $args[2]; |
1558 |
|
1559 | if ( !$user = $this->login($username, $password) ) |
1560 | return $this->error; |
1561 |
|
1562 | do_action('xmlrpc_call', 'blogger.getUsersBlogs'); |
1563 |
|
1564 | $is_admin = current_user_can('manage_options'); |
1565 |
|
1566 | $struct = array( |
1567 | 'isAdmin' => $is_admin, |
1568 | 'url' => get_option('home') . '/', |
1569 | 'blogid' => '1', |
1570 | 'blogName' => get_option('blogname'), |
1571 | 'xmlrpc' => site_url( 'xmlrpc.php' ) |
Line | Code |
1620 | $username = $args[1]; |
1621 | $password = $args[2]; |
1622 |
|
1623 | if ( !$user = $this->login($username, $password) ) |
1624 | return $this->error; |
1625 |
|
1626 | if ( !current_user_can( 'edit_posts' ) ) |
1627 | return new IXR_Error( 401, __( 'Sorry, you do not have access to user data on this site.' ) ); |
1628 |
|
1629 | do_action('xmlrpc_call', 'blogger.getUserInfo'); |
1630 |
|
1631 | $struct = array( |
1632 | 'nickname' => $user->nickname, |
1633 | 'userid' => $user->ID, |
1634 | 'url' => $user->user_url, |
1635 | 'lastname' => $user->last_name, |
1636 | 'firstname' => $user->first_name |
1637 | ); |
1638 |
|
Line | Code |
1655 | $username = $args[2]; |
1656 | $password = $args[3]; |
1657 |
|
1658 | if ( !$user = $this->login($username, $password) ) |
1659 | return $this->error; |
1660 |
|
1661 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
1662 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); |
1663 |
|
1664 | do_action('xmlrpc_call', 'blogger.getPost'); |
1665 |
|
1666 | $post_data = wp_get_single_post($post_ID, ARRAY_A); |
1667 |
|
1668 | $categories = implode(',', wp_get_post_categories($post_ID)); |
1669 |
|
1670 | $content = '<title>'.stripslashes($post_data['post_title']).'</title>'; |
1671 | $content .= '<category>'.$categories.'</category>'; |
1672 | $content .= stripslashes($post_data['post_content']); |
1673 |
|
Line | Code |
1695 |
|
1696 | $blog_ID = (int) $args[1]; /* though we don't use it yet */ |
1697 | $username = $args[2]; |
1698 | $password = $args[3]; |
1699 | $num_posts = $args[4]; |
1700 |
|
1701 | if ( !$user = $this->login($username, $password) ) |
1702 | return $this->error; |
1703 |
|
1704 | do_action('xmlrpc_call', 'blogger.getRecentPosts'); |
1705 |
|
1706 | $posts_list = wp_get_recent_posts($num_posts); |
1707 |
|
1708 | if ( !$posts_list ) { |
1709 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
1710 | return $this->error; |
1711 | } |
1712 |
|
1713 | foreach ($posts_list as $entry) { |
Line | Code |
1752 |
|
1753 | $blog_ID = (int) $args[1]; |
1754 | $username = $args[2]; |
1755 | $password = $args[3]; |
1756 | $template = $args[4]; /* could be 'main' or 'archiveIndex', but we don't use it */ |
1757 |
|
1758 | if ( !$user = $this->login($username, $password) ) |
1759 | return $this->error; |
1760 |
|
1761 | do_action('xmlrpc_call', 'blogger.getTemplate'); |
1762 |
|
1763 | if ( !current_user_can('edit_themes') ) |
1764 | return new IXR_Error(401, __('Sorry, this user can not edit the template.')); |
1765 |
|
1766 | /* warning: here we make the assumption that the blog's URL is on the same server */ |
1767 | $filename = get_option('home') . '/'; |
1768 | $filename = preg_replace('#https?://.+?/#', $_SERVER['DOCUMENT_ROOT'].'/', $filename); |
1769 |
|
1770 | $f = fopen($filename, 'r'); |
Line | Code |
1792 | $blog_ID = (int) $args[1]; |
1793 | $username = $args[2]; |
1794 | $password = $args[3]; |
1795 | $content = $args[4]; |
1796 | $template = $args[5]; /* could be 'main' or 'archiveIndex', but we don't use it */ |
1797 |
|
1798 | if ( !$user = $this->login($username, $password) ) |
1799 | return $this->error; |
1800 |
|
1801 | do_action('xmlrpc_call', 'blogger.setTemplate'); |
1802 |
|
1803 | if ( !current_user_can('edit_themes') ) |
1804 | return new IXR_Error(401, __('Sorry, this user cannot edit the template.')); |
1805 |
|
1806 | /* warning: here we make the assumption that the blog's URL is on the same server */ |
1807 | $filename = get_option('home') . '/'; |
1808 | $filename = preg_replace('#https?://.+?/#', $_SERVER['DOCUMENT_ROOT'].'/', $filename); |
1809 |
|
1810 | if ($f = fopen($filename, 'w+')) { |
Line | Code |
1832 | $blog_ID = (int) $args[1]; /* though we don't use it yet */ |
1833 | $username = $args[2]; |
1834 | $password = $args[3]; |
1835 | $content = $args[4]; |
1836 | $publish = $args[5]; |
1837 |
|
1838 | if ( !$user = $this->login($username, $password) ) |
1839 | return $this->error; |
1840 |
|
1841 | do_action('xmlrpc_call', 'blogger.newPost'); |
1842 |
|
1843 | $cap = ($publish) ? 'publish_posts' : 'edit_posts'; |
1844 | if ( !current_user_can($cap) ) |
1845 | return new IXR_Error(401, __('Sorry, you are not allowed to post on this site.')); |
1846 |
|
1847 | $post_status = ($publish) ? 'publish' : 'draft'; |
1848 |
|
1849 | $post_author = $user->ID; |
1850 |
|
Line | Code |
1886 | $post_ID = (int) $args[1]; |
1887 | $username = $args[2]; |
1888 | $password = $args[3]; |
1889 | $content = $args[4]; |
1890 | $publish = $args[5]; |
1891 |
|
1892 | if ( !$user = $this->login($username, $password) ) |
1893 | return $this->error; |
1894 |
|
1895 | do_action('xmlrpc_call', 'blogger.editPost'); |
1896 |
|
1897 | $actual_post = wp_get_single_post($post_ID,ARRAY_A); |
1898 |
|
1899 | if ( !$actual_post || $actual_post['post_type'] != 'post' ) |
1900 | return new IXR_Error(404, __('Sorry, no such post.')); |
1901 |
|
1902 | $this->escape($actual_post); |
1903 |
|
1904 | if ( !current_user_can('edit_post', $post_ID) ) |
Line | Code |
1938 |
|
1939 | $post_ID = (int) $args[1]; |
1940 | $username = $args[2]; |
1941 | $password = $args[3]; |
1942 | $publish = $args[4]; |
1943 |
|
1944 | if ( !$user = $this->login($username, $password) ) |
1945 | return $this->error; |
1946 |
|
1947 | do_action('xmlrpc_call', 'blogger.deletePost'); |
1948 |
|
1949 | $actual_post = wp_get_single_post($post_ID,ARRAY_A); |
1950 |
|
1951 | if ( !$actual_post || $actual_post['post_type'] != 'post' ) |
1952 | return new IXR_Error(404, __('Sorry, no such post.')); |
1953 |
|
1954 | if ( !current_user_can('edit_post', $post_ID) ) |
1955 | return new IXR_Error(401, __('Sorry, you do not have the right to delete this post.')); |
1956 |
|
Line | Code |
1980 | $blog_ID = (int) $args[0]; // we will support this in the near future |
1981 | $username = $args[1]; |
1982 | $password = $args[2]; |
1983 | $content_struct = $args[3]; |
1984 | $publish = $args[4]; |
1985 |
|
1986 | if ( !$user = $this->login($username, $password) ) |
1987 | return $this->error; |
1988 |
|
1989 | do_action('xmlrpc_call', 'metaWeblog.newPost'); |
1990 |
|
1991 | $cap = ( $publish ) ? 'publish_posts' : 'edit_posts'; |
1992 | $error_message = __( 'Sorry, you are not allowed to publish posts on this site.' ); |
1993 | $post_type = 'post'; |
1994 | $page_template = ''; |
1995 | if ( !empty( $content_struct['post_type'] ) ) { |
1996 | if ( $content_struct['post_type'] == 'page' ) { |
1997 | $cap = ( $publish ) ? 'publish_pages' : 'edit_pages'; |
1998 | $error_message = __( 'Sorry, you are not allowed to publish pages on this site.' ); |
Line | Code |
2255 | $post_ID = (int) $args[0]; |
2256 | $username = $args[1]; |
2257 | $password = $args[2]; |
2258 | $content_struct = $args[3]; |
2259 | $publish = $args[4]; |
2260 |
|
2261 | if ( !$user = $this->login($username, $password) ) |
2262 | return $this->error; |
2263 |
|
2264 | do_action('xmlrpc_call', 'metaWeblog.editPost'); |
2265 |
|
2266 | $cap = ( $publish ) ? 'publish_posts' : 'edit_posts'; |
2267 | $error_message = __( 'Sorry, you are not allowed to publish posts on this site.' ); |
2268 | $post_type = 'post'; |
2269 | $page_template = ''; |
2270 | if ( !empty( $content_struct['post_type'] ) ) { |
2271 | if ( $content_struct['post_type'] == 'page' ) { |
2272 | $cap = ( $publish ) ? 'publish_pages' : 'edit_pages'; |
2273 | $error_message = __( 'Sorry, you are not allowed to publish pages on this site.' ); |
Line | Code |
2501 | $username = $args[1]; |
2502 | $password = $args[2]; |
2503 |
|
2504 | if ( !$user = $this->login($username, $password) ) |
2505 | return $this->error; |
2506 |
|
2507 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
2508 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); |
2509 |
|
2510 | do_action('xmlrpc_call', 'metaWeblog.getPost'); |
2511 |
|
2512 | $postdata = wp_get_single_post($post_ID, ARRAY_A); |
2513 |
|
2514 | if ($postdata['post_date'] != '') { |
2515 | $post_date = mysql2date('Ymd\TH:i:s', $postdata['post_date'], false); |
2516 | $post_date_gmt = mysql2date('Ymd\TH:i:s', $postdata['post_date_gmt'], false); |
2517 |
|
2518 | // For drafts use the GMT version of the post date |
2519 | if ( $postdata['post_status'] == 'draft' ) |
Line | Code |
2612 |
|
2613 | $blog_ID = (int) $args[0]; |
2614 | $username = $args[1]; |
2615 | $password = $args[2]; |
2616 | $num_posts = (int) $args[3]; |
2617 |
|
2618 | if ( !$user = $this->login($username, $password) ) |
2619 | return $this->error; |
2620 |
|
2621 | do_action('xmlrpc_call', 'metaWeblog.getRecentPosts'); |
2622 |
|
2623 | $posts_list = wp_get_recent_posts($num_posts); |
2624 |
|
2625 | if ( !$posts_list ) |
2626 | return array( ); |
2627 |
|
2628 | foreach ($posts_list as $entry) { |
2629 | if ( !current_user_can( 'edit_post', $entry['ID'] ) ) |
2630 | continue; |
Line | Code |
2716 | $username = $args[1]; |
2717 | $password = $args[2]; |
2718 |
|
2719 | if ( !$user = $this->login($username, $password) ) |
2720 | return $this->error; |
2721 |
|
2722 | if ( !current_user_can( 'edit_posts' ) ) |
2723 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
2724 |
|
2725 | do_action('xmlrpc_call', 'metaWeblog.getCategories'); |
2726 |
|
2727 | $categories_struct = array(); |
2728 |
|
2729 | if ( $cats = get_categories(array('get' => 'all')) ) { |
2730 | foreach ( $cats as $cat ) { |
2731 | $struct['categoryId'] = $cat->term_id; |
2732 | $struct['parentId'] = $cat->parent; |
2733 | $struct['description'] = $cat->name; |
2734 | $struct['categoryDescription'] = $cat->description; |
Line | Code |
2766 | $name = sanitize_file_name( $data['name'] ); |
2767 | $type = $data['type']; |
2768 | $bits = $data['bits']; |
2769 |
|
2770 | logIO('O', '(MW) Received '.strlen($bits).' bytes'); |
2771 |
|
2772 | if ( !$user = $this->login($username, $password) ) |
2773 | return $this->error; |
2774 |
|
2775 | do_action('xmlrpc_call', 'metaWeblog.newMediaObject'); |
2776 |
|
2777 | if ( !current_user_can('upload_files') ) { |
2778 | logIO('O', '(MW) User does not have upload_files capability'); |
2779 | $this->error = new IXR_Error(401, __('You are not allowed to upload files to this site.')); |
2780 | return $this->error; |
2781 | } |
2782 |
|
2783 | if ( $upload_err = apply_filters( "pre_upload_error", false ) ) |
2784 | return new IXR_Error(500, $upload_err); |
Line | Code |
2844 |
|
2845 | $blog_ID = (int) $args[0]; |
2846 | $username = $args[1]; |
2847 | $password = $args[2]; |
2848 | $num_posts = (int) $args[3]; |
2849 |
|
2850 | if ( !$user = $this->login($username, $password) ) |
2851 | return $this->error; |
2852 |
|
2853 | do_action('xmlrpc_call', 'mt.getRecentPostTitles'); |
2854 |
|
2855 | $posts_list = wp_get_recent_posts($num_posts); |
2856 |
|
2857 | if ( !$posts_list ) { |
2858 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
2859 | return $this->error; |
2860 | } |
2861 |
|
2862 | foreach ($posts_list as $entry) { |
Line | Code |
2904 | $username = $args[1]; |
2905 | $password = $args[2]; |
2906 |
|
2907 | if ( !$user = $this->login($username, $password) ) |
2908 | return $this->error; |
2909 |
|
2910 | if ( !current_user_can( 'edit_posts' ) ) |
2911 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
2912 |
|
2913 | do_action('xmlrpc_call', 'mt.getCategoryList'); |
2914 |
|
2915 | $categories_struct = array(); |
2916 |
|
2917 | if ( $cats = get_categories(array('hide_empty' => 0, 'hierarchical' => 0)) ) { |
2918 | foreach ( $cats as $cat ) { |
2919 | $struct['categoryId'] = $cat->term_id; |
2920 | $struct['categoryName'] = $cat->name; |
2921 |
|
2922 | $categories_struct[] = $struct; |
Line | Code |
2942 | $username = $args[1]; |
2943 | $password = $args[2]; |
2944 |
|
2945 | if ( !$user = $this->login($username, $password) ) |
2946 | return $this->error; |
2947 |
|
2948 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
2949 | return new IXR_Error( 401, __( 'Sorry, you can not edit this post.' ) ); |
2950 |
|
2951 | do_action('xmlrpc_call', 'mt.getPostCategories'); |
2952 |
|
2953 | $categories = array(); |
2954 | $catids = wp_get_post_categories(intval($post_ID)); |
2955 | // first listed category will be the primary category |
2956 | $isPrimary = true; |
2957 | foreach ( $catids as $catid ) { |
2958 | $categories[] = array( |
2959 | 'categoryName' => get_cat_name($catid), |
2960 | 'categoryId' => (string) $catid, |
Line | Code |
2980 |
|
2981 | $post_ID = (int) $args[0]; |
2982 | $username = $args[1]; |
2983 | $password = $args[2]; |
2984 | $categories = $args[3]; |
2985 |
|
2986 | if ( !$user = $this->login($username, $password) ) |
2987 | return $this->error; |
2988 |
|
2989 | do_action('xmlrpc_call', 'mt.setPostCategories'); |
2990 |
|
2991 | if ( !current_user_can('edit_post', $post_ID) ) |
2992 | return new IXR_Error(401, __('Sorry, you cannot edit this post.')); |
2993 |
|
2994 | foreach ( $categories as $cat ) { |
2995 | $catids[] = $cat['categoryId']; |
2996 | } |
2997 |
|
2998 | wp_set_post_categories($post_ID, $catids); |
Line | Code |
3004 | * Retrieve an array of methods supported by this server. |
3005 | * |
3006 | * @since 1.5.0 |
3007 | * |
3008 | * @param array $args Method parameters. |
3009 | * @return array |
3010 | */ |
3011 | function mt_supportedMethods($args) { |
3012 |
|
3013 | do_action('xmlrpc_call', 'mt.supportedMethods'); |
3014 |
|
3015 | $supported_methods = array(); |
3016 | foreach ( $this->methods as $key => $value ) { |
3017 | $supported_methods[] = $key; |
3018 | } |
3019 |
|
3020 | return $supported_methods; |
3021 | } |
3022 |
|
3023 | /** |
3024 | * Retrieve an empty array because we don't support per-post text filters. |
3025 | * |
3026 | * @since 1.5.0 |
3027 | * |
3028 | * @param array $args Method parameters. |
3029 | */ |
3030 | function mt_supportedTextFilters($args) { |
3031 | do_action('xmlrpc_call', 'mt.supportedTextFilters'); |
3032 | return apply_filters('xmlrpc_text_filters', array()); |
3033 | } |
3034 |
|
3035 | /** |
3036 | * Retrieve trackbacks sent to a given post. |
3037 | * |
3038 | * @since 1.5.0 |
3039 | * |
3040 | * @param array $args Method parameters. |
3041 | * @return mixed |
3042 | */ |
3043 | function mt_getTrackbackPings($args) { |
3044 |
|
3045 | global $wpdb; |
3046 |
|
3047 | $post_ID = intval($args); |
3048 |
|
3049 | do_action('xmlrpc_call', 'mt.getTrackbackPings'); |
3050 |
|
3051 | $actual_post = wp_get_single_post($post_ID, ARRAY_A); |
3052 |
|
3053 | if ( !$actual_post ) |
3054 | return new IXR_Error(404, __('Sorry, no such post.')); |
3055 |
|
3056 | $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) ); |
3057 |
|
3058 | if ( !$comments ) |
Line | Code |
3087 | $this->escape($args); |
3088 |
|
3089 | $post_ID = (int) $args[0]; |
3090 | $username = $args[1]; |
3091 | $password = $args[2]; |
3092 |
|
3093 | if ( !$user = $this->login($username, $password) ) |
3094 | return $this->error; |
3095 |
|
3096 | do_action('xmlrpc_call', 'mt.publishPost'); |
3097 |
|
3098 | if ( !current_user_can('edit_post', $post_ID) ) |
3099 | return new IXR_Error(401, __('Sorry, you cannot edit this post.')); |
3100 |
|
3101 | $postdata = wp_get_single_post($post_ID,ARRAY_A); |
3102 |
|
3103 | $postdata['post_status'] = 'publish'; |
3104 |
|
3105 | // retain old cats |
Line | Code |
3121 | * |
3122 | * @since 1.5.0 |
3123 | * |
3124 | * @param array $args Method parameters. |
3125 | * @return array |
3126 | */ |
3127 | function pingback_ping($args) { |
3128 | global $wpdb; |
3129 |
|
3130 | do_action('xmlrpc_call', 'pingback.ping'); |
3131 |
|
3132 | $this->escape($args); |
3133 |
|
3134 | $pagelinkedfrom = $args[0]; |
3135 | $pagelinkedto = $args[1]; |
3136 |
|
3137 | $title = ''; |
3138 |
|
3139 | $pagelinkedfrom = str_replace('&', '&', $pagelinkedfrom); |
Line | Code |
3291 | * @since 1.5.0 |
3292 | * |
3293 | * @param array $args Method parameters. |
3294 | * @return array |
3295 | */ |
3296 | function pingback_extensions_getPingbacks($args) { |
3297 |
|
3298 | global $wpdb; |
3299 |
|
3300 | do_action('xmlrpc_call', 'pingback.extensions.getPingbacks'); |
3301 |
|
3302 | $this->escape($args); |
3303 |
|
3304 | $url = $args; |
3305 |
|
3306 | $post_ID = url_to_postid($url); |
3307 | if ( !$post_ID ) { |
3308 | // We aren't sure that the resource is available and/or pingback enabled |
3309 | 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.')); |