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 49 times in this file.
Line | Code |
---|---|
396 | $this->escape( $args ); |
397 |
|
398 | $username = $args[0]; |
399 | $password = $args[1]; |
400 |
|
401 | if ( !$user = $this->login($username, $password) ) |
402 | return $this->error; |
403 |
|
404 |
|
405 | do_action( 'xmlrpc_call', 'wp.getUsersBlogs' ); |
406 |
|
407 | $blogs = (array) get_blogs_of_user( $user->ID ); |
408 | $struct = array( ); |
409 |
|
410 | foreach ( $blogs as $blog ) { |
411 | // Don't include blogs that aren't hosted at this site |
412 | if ( $blog->site_id != $current_site->id ) |
413 | continue; |
414 |
|
Line | Code |
447 | $password = $args[3]; |
448 |
|
449 | if ( !$user = $this->login($username, $password) ) { |
450 | return $this->error; |
451 | } |
452 |
|
453 | if ( !current_user_can( 'edit_page', $page_id ) ) |
454 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this page.' ) ); |
455 |
|
456 | do_action('xmlrpc_call', 'wp.getPage'); |
457 |
|
458 | // Lookup page info. |
459 | $page = get_page($page_id); |
460 |
|
461 | // If we found the page then format the data. |
462 | if ( $page->ID && ($page->post_type == "page") ) { |
463 | // Get all of the page content and link. |
464 | $full_page = get_extended($page->post_content); |
465 | $link = post_permalink($page->ID); |
Line | Code |
547 | $password = $args[2]; |
548 | $num_pages = isset($args[3]) ? (int) $args[3] : 10; |
549 |
|
550 | if ( !$user = $this->login($username, $password) ) |
551 | return $this->error; |
552 |
|
553 | if ( !current_user_can( 'edit_pages' ) ) |
554 | return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) ); |
555 |
|
556 | do_action('xmlrpc_call', 'wp.getPages'); |
557 |
|
558 | $pages = get_posts( array('post_type' => 'page', 'post_status' => 'any', 'numberposts' => $num_pages) ); |
559 | $num_pages = count($pages); |
560 |
|
561 | // If we have pages, put together their info. |
562 | if ( $num_pages >= 1 ) { |
563 | $pages_struct = array(); |
564 |
|
565 | for ( $i = 0; $i < $num_pages; $i++ ) { |
Line | Code |
589 | // Items not escaped here will be escaped in newPost. |
590 | $username = $this->escape($args[1]); |
591 | $password = $this->escape($args[2]); |
592 | $page = $args[3]; |
593 | $publish = $args[4]; |
594 |
|
595 | if ( !$user = $this->login($username, $password) ) |
596 | return $this->error; |
597 |
|
598 | do_action('xmlrpc_call', 'wp.newPage'); |
599 |
|
600 | // Make sure the user is allowed to add new pages. |
601 | if ( !current_user_can("publish_pages") ) |
602 | return(new IXR_Error(401, __("Sorry, you cannot add new pages."))); |
603 |
|
604 | // Mark this as content for a page. |
605 | $args[3]["post_type"] = "page"; |
606 |
|
607 | // Let mw_newPost do all of the heavy lifting. |
Line | Code |
621 |
|
622 | $blog_id = (int) $args[0]; |
623 | $username = $args[1]; |
624 | $password = $args[2]; |
625 | $page_id = (int) $args[3]; |
626 |
|
627 | if ( !$user = $this->login($username, $password) ) |
628 | return $this->error; |
629 |
|
630 | do_action('xmlrpc_call', 'wp.deletePage'); |
631 |
|
632 | // Get the current page based on the page_id and |
633 | // make sure it is a page and not a post. |
634 | $actual_page = wp_get_single_post($page_id, ARRAY_A); |
635 | if ( !$actual_page || ($actual_page["post_type"] != "page") ) |
636 | return(new IXR_Error(404, __("Sorry, no such page."))); |
637 |
|
638 | // Make sure the user can delete pages. |
639 | if ( !current_user_can("delete_page", $page_id) ) |
Line | Code |
661 | $page_id = (int) $this->escape($args[1]); |
662 | $username = $this->escape($args[2]); |
663 | $password = $this->escape($args[3]); |
664 | $content = $args[4]; |
665 | $publish = $args[5]; |
666 |
|
667 | if ( !$user = $this->login($username, $password) ) |
668 | return $this->error; |
669 |
|
670 | do_action('xmlrpc_call', 'wp.editPage'); |
671 |
|
672 | // Get the page data and make sure it is a page. |
673 | $actual_page = wp_get_single_post($page_id, ARRAY_A); |
674 | if ( !$actual_page || ($actual_page["post_type"] != "page") ) |
675 | return(new IXR_Error(404, __("Sorry, no such page."))); |
676 |
|
677 | // Make sure the user is allowed to edit pages. |
678 | if ( !current_user_can("edit_page", $page_id) ) |
679 | return(new IXR_Error(401, __("Sorry, you do not have the right to edit this page."))); |
Line | Code |
711 | $username = $args[1]; |
712 | $password = $args[2]; |
713 |
|
714 | if ( !$user = $this->login($username, $password) ) |
715 | return $this->error; |
716 |
|
717 | if ( !current_user_can( 'edit_pages' ) ) |
718 | return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) ); |
719 |
|
720 | do_action('xmlrpc_call', 'wp.getPageList'); |
721 |
|
722 | // Get list of pages ids and titles |
723 | $page_list = $wpdb->get_results(" |
724 | SELECT ID page_id, |
725 | post_title page_title, |
726 | post_parent page_parent_id, |
727 | post_date_gmt, |
728 | post_date, |
729 | post_status |
Line | Code |
771 | $username = $args[1]; |
772 | $password = $args[2]; |
773 |
|
774 | if ( !$user = $this->login($username, $password) ) |
775 | return $this->error; |
776 |
|
777 | if ( !current_user_can("edit_posts") ) |
778 | return(new IXR_Error(401, __("Sorry, you cannot edit posts on this site."))); |
779 |
|
780 | do_action('xmlrpc_call', 'wp.getAuthors'); |
781 |
|
782 | $authors = array(); |
783 | foreach ( get_users( array( 'fields' => array('ID','user_login','display_name') ) ) as $user ) { |
784 | $authors[] = array( |
785 | "user_id" => $user->ID, |
786 | "user_login" => $user->user_login, |
787 | "display_name" => $user->display_name |
788 | ); |
789 | } |
Line | Code |
806 | $username = $args[1]; |
807 | $password = $args[2]; |
808 |
|
809 | if ( !$user = $this->login($username, $password) ) |
810 | return $this->error; |
811 |
|
812 | if ( !current_user_can( 'edit_posts' ) ) |
813 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view tags.' ) ); |
814 |
|
815 | do_action( 'xmlrpc_call', 'wp.getKeywords' ); |
816 |
|
817 | $tags = array( ); |
818 |
|
819 | if ( $all_tags = get_tags() ) { |
820 | foreach( (array) $all_tags as $tag ) { |
821 | $struct['tag_id'] = $tag->term_id; |
822 | $struct['name'] = $tag->name; |
823 | $struct['count'] = $tag->count; |
824 | $struct['slug'] = $tag->slug; |
Line | Code |
845 |
|
846 | $blog_id = (int) $args[0]; |
847 | $username = $args[1]; |
848 | $password = $args[2]; |
849 | $category = $args[3]; |
850 |
|
851 | if ( !$user = $this->login($username, $password) ) |
852 | return $this->error; |
853 |
|
854 | do_action('xmlrpc_call', 'wp.newCategory'); |
855 |
|
856 | // Make sure the user is allowed to add a category. |
857 | if ( !current_user_can("manage_categories") ) |
858 | return(new IXR_Error(401, __("Sorry, you do not have the right to add a category."))); |
859 |
|
860 | // If no slug was provided make it empty so that |
861 | // WordPress will generate one. |
862 | if ( empty($category["slug"]) ) |
863 | $category["slug"] = ""; |
Line | Code |
904 |
|
905 | $blog_id = (int) $args[0]; |
906 | $username = $args[1]; |
907 | $password = $args[2]; |
908 | $category_id = (int) $args[3]; |
909 |
|
910 | if ( !$user = $this->login($username, $password) ) |
911 | return $this->error; |
912 |
|
913 | do_action('xmlrpc_call', 'wp.deleteCategory'); |
914 |
|
915 | if ( !current_user_can("manage_categories") ) |
916 | return new IXR_Error( 401, __( "Sorry, you do not have the right to delete a category." ) ); |
917 |
|
918 | return wp_delete_term( $category_id, 'category' ); |
919 | } |
920 |
|
921 | /** |
922 | * Retrieve category list. |
Line | Code |
935 | $category = $args[3]; |
936 | $max_results = (int) $args[4]; |
937 |
|
938 | if ( !$user = $this->login($username, $password) ) |
939 | return $this->error; |
940 |
|
941 | if ( !current_user_can( 'edit_posts' ) ) |
942 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts to this site in order to view categories.' ) ); |
943 |
|
944 | do_action('xmlrpc_call', 'wp.suggestCategories'); |
945 |
|
946 | $category_suggestions = array(); |
947 | $args = array('get' => 'all', 'number' => $max_results, 'name__like' => $category); |
948 | foreach ( (array) get_categories($args) as $cat ) { |
949 | $category_suggestions[] = array( |
950 | "category_id" => $cat->term_id, |
951 | "category_name" => $cat->name |
952 | ); |
953 | } |
Line | Code |
971 | $password = $args[2]; |
972 | $comment_id = (int) $args[3]; |
973 |
|
974 | if ( !$user = $this->login($username, $password) ) |
975 | return $this->error; |
976 |
|
977 | if ( !current_user_can( 'moderate_comments' ) ) |
978 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
979 |
|
980 | do_action('xmlrpc_call', 'wp.getComment'); |
981 |
|
982 | if ( ! $comment = get_comment($comment_id) ) |
983 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
984 |
|
985 | // Format page date. |
986 | $comment_date = mysql2date("Ymd\TH:i:s", $comment->comment_date, false); |
987 | $comment_date_gmt = mysql2date("Ymd\TH:i:s", $comment->comment_date_gmt, false); |
988 |
|
989 | if ( '0' == $comment->comment_approved ) |
Line | Code |
1034 | $password = $args[2]; |
1035 | $struct = $args[3]; |
1036 |
|
1037 | if ( !$user = $this->login($username, $password) ) |
1038 | return $this->error; |
1039 |
|
1040 | if ( !current_user_can( 'moderate_comments' ) ) |
1041 | return new IXR_Error( 401, __( 'Sorry, you cannot edit comments.' ) ); |
1042 |
|
1043 | do_action('xmlrpc_call', 'wp.getComments'); |
1044 |
|
1045 | if ( isset($struct['status']) ) |
1046 | $status = $struct['status']; |
1047 | else |
1048 | $status = ''; |
1049 |
|
1050 | $post_id = ''; |
1051 | if ( isset($struct['post_id']) ) |
1052 | $post_id = absint($struct['post_id']); |
Line | Code |
1096 | if ( !$user = $this->login($username, $password) ) |
1097 | return $this->error; |
1098 |
|
1099 | if ( !current_user_can( 'moderate_comments' ) ) |
1100 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
1101 |
|
1102 | if ( !current_user_can( 'edit_comment', $comment_ID ) ) |
1103 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
1104 |
|
1105 | do_action('xmlrpc_call', 'wp.deleteComment'); |
1106 |
|
1107 | if ( ! get_comment($comment_ID) ) |
1108 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
1109 |
|
1110 | return wp_delete_comment($comment_ID); |
1111 | } |
1112 |
|
1113 | /** |
1114 | * Edit comment. |
Line | Code |
1130 | if ( !$user = $this->login($username, $password) ) |
1131 | return $this->error; |
1132 |
|
1133 | if ( !current_user_can( 'moderate_comments' ) ) |
1134 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
1135 |
|
1136 | if ( !current_user_can( 'edit_comment', $comment_ID ) ) |
1137 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
1138 |
|
1139 | do_action('xmlrpc_call', 'wp.editComment'); |
1140 |
|
1141 | if ( ! get_comment($comment_ID) ) |
1142 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
1143 |
|
1144 | if ( isset($content_struct['status']) ) { |
1145 | $statuses = get_comment_statuses(); |
1146 | $statuses = array_keys($statuses); |
1147 |
|
1148 | if ( ! in_array($content_struct['status'], $statuses) ) |
Line | Code |
1254 | elseif ( !is_email($comment['comment_author_email']) ) |
1255 | return new IXR_Error( 403, __( 'A valid email address is required' ) ); |
1256 | } |
1257 | } |
1258 |
|
1259 | $comment['comment_parent'] = isset($content_struct['comment_parent']) ? absint($content_struct['comment_parent']) : 0; |
1260 |
|
1261 | $comment['comment_content'] = isset($content_struct['content']) ? $content_struct['content'] : null; |
1262 |
|
1263 | do_action('xmlrpc_call', 'wp.newComment'); |
1264 |
|
1265 | return wp_new_comment($comment); |
1266 | } |
1267 |
|
1268 | /** |
1269 | * Retrieve all of the comment status. |
1270 | * |
1271 | * @since 2.7.0 |
1272 | * |
Line | Code |
1280 | $username = $args[1]; |
1281 | $password = $args[2]; |
1282 |
|
1283 | if ( !$user = $this->login($username, $password) ) |
1284 | return $this->error; |
1285 |
|
1286 | if ( !current_user_can( 'moderate_comments' ) ) |
1287 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
1288 |
|
1289 | do_action('xmlrpc_call', 'wp.getCommentStatusList'); |
1290 |
|
1291 | return get_comment_statuses( ); |
1292 | } |
1293 |
|
1294 | /** |
1295 | * Retrieve comment count. |
1296 | * |
1297 | * @since 2.5.0 |
1298 | * |
Line | Code |
1307 | $password = $args[2]; |
1308 | $post_id = (int) $args[3]; |
1309 |
|
1310 | if ( !$user = $this->login($username, $password) ) |
1311 | return $this->error; |
1312 |
|
1313 | if ( !current_user_can( 'edit_posts' ) ) |
1314 | return new IXR_Error( 403, __( 'You are not allowed access to details about comments.' ) ); |
1315 |
|
1316 | do_action('xmlrpc_call', 'wp.getCommentCount'); |
1317 |
|
1318 | $count = wp_count_comments( $post_id ); |
1319 | return array( |
1320 | "approved" => $count->approved, |
1321 | "awaiting_moderation" => $count->moderated, |
1322 | "spam" => $count->spam, |
1323 | "total_comments" => $count->total_comments |
1324 | ); |
1325 | } |
Line | Code |
1339 | $username = $args[1]; |
1340 | $password = $args[2]; |
1341 |
|
1342 | if ( !$user = $this->login($username, $password) ) |
1343 | return $this->error; |
1344 |
|
1345 | if ( !current_user_can( 'edit_posts' ) ) |
1346 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
1347 |
|
1348 | do_action('xmlrpc_call', 'wp.getPostStatusList'); |
1349 |
|
1350 | return get_post_statuses( ); |
1351 | } |
1352 |
|
1353 | /** |
1354 | * Retrieve page statuses. |
1355 | * |
1356 | * @since 2.5.0 |
1357 | * |
Line | Code |
1365 | $username = $args[1]; |
1366 | $password = $args[2]; |
1367 |
|
1368 | if ( !$user = $this->login($username, $password) ) |
1369 | return $this->error; |
1370 |
|
1371 | if ( !current_user_can( 'edit_pages' ) ) |
1372 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
1373 |
|
1374 | do_action('xmlrpc_call', 'wp.getPageStatusList'); |
1375 |
|
1376 | return get_page_statuses( ); |
1377 | } |
1378 |
|
1379 | /** |
1380 | * Retrieve page templates. |
1381 | * |
1382 | * @since 2.6.0 |
1383 | * |
Line | Code |
1518 | $password = $args[2]; |
1519 | $attachment_id = (int) $args[3]; |
1520 |
|
1521 | if ( !$user = $this->login($username, $password) ) |
1522 | return $this->error; |
1523 |
|
1524 | if ( !current_user_can( 'upload_files' ) ) |
1525 | return new IXR_Error( 403, __( 'You are not allowed to upload files on this site.' ) ); |
1526 |
|
1527 | do_action('xmlrpc_call', 'wp.getMediaItem'); |
1528 |
|
1529 | if ( ! $attachment = get_post($attachment_id) ) |
1530 | return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); |
1531 |
|
1532 | // Format page date. |
1533 | $attachment_date = mysql2date("Ymd\TH:i:s", $attachment->post_date, false); |
1534 | $attachment_date_gmt = mysql2date("Ymd\TH:i:s", $attachment->post_date_gmt, false); |
1535 |
|
1536 | $link = wp_get_attachment_url($attachment->ID); |
Line | Code |
1582 | $password = $args[2]; |
1583 | $struct = isset( $args[3] ) ? $args[3] : array() ; |
1584 |
|
1585 | if ( !$user = $this->login($username, $password) ) |
1586 | return $this->error; |
1587 |
|
1588 | if ( !current_user_can( 'upload_files' ) ) |
1589 | return new IXR_Error( 401, __( 'Sorry, you cannot upload files.' ) ); |
1590 |
|
1591 | do_action('xmlrpc_call', 'wp.getMediaLibrary'); |
1592 |
|
1593 | $parent_id = ( isset($struct['parent_id']) ) ? absint($struct['parent_id']) : '' ; |
1594 | $mime_type = ( isset($struct['mime_type']) ) ? $struct['mime_type'] : '' ; |
1595 | $offset = ( isset($struct['offset']) ) ? absint($struct['offset']) : 0 ; |
1596 | $number = ( isset($struct['number']) ) ? absint($struct['number']) : -1 ; |
1597 |
|
1598 | $attachments = get_posts( array('post_type' => 'attachment', 'post_parent' => $parent_id, 'offset' => $offset, 'numberposts' => $number, 'post_mime_type' => $mime_type ) ); |
1599 | $num_attachments = count($attachments); |
1600 |
|
Line | Code |
1624 | $this->escape( $args ); |
1625 |
|
1626 | $blog_id = (int) $args[0]; |
1627 | $username = $args[1]; |
1628 | $password = $args[2]; |
1629 |
|
1630 | if ( !$user = $this->login( $username, $password ) ) |
1631 | return $this->error; |
1632 |
|
1633 | do_action( 'xmlrpc_call', 'wp.getPostFormats' ); |
1634 | return get_post_format_strings(); |
1635 | } |
1636 |
|
1637 | /* Blogger API functions. |
1638 | * specs on http://plant.blogger.com/api and http://groups.yahoo.com/group/bloggerDev/ |
1639 | */ |
1640 |
|
1641 | /** |
1642 | * Retrieve blogs that user owns. |
Line | Code |
1654 |
|
1655 | $this->escape($args); |
1656 |
|
1657 | $username = $args[1]; |
1658 | $password = $args[2]; |
1659 |
|
1660 | if ( !$user = $this->login($username, $password) ) |
1661 | return $this->error; |
1662 |
|
1663 | do_action('xmlrpc_call', 'blogger.getUsersBlogs'); |
1664 |
|
1665 | $is_admin = current_user_can('manage_options'); |
1666 |
|
1667 | $struct = array( |
1668 | 'isAdmin' => $is_admin, |
1669 | 'url' => get_option('home') . '/', |
1670 | 'blogid' => '1', |
1671 | 'blogName' => get_option('blogname'), |
1672 | 'xmlrpc' => site_url( 'xmlrpc.php' ) |
Line | Code |
1721 | $username = $args[1]; |
1722 | $password = $args[2]; |
1723 |
|
1724 | if ( !$user = $this->login($username, $password) ) |
1725 | return $this->error; |
1726 |
|
1727 | if ( !current_user_can( 'edit_posts' ) ) |
1728 | return new IXR_Error( 401, __( 'Sorry, you do not have access to user data on this site.' ) ); |
1729 |
|
1730 | do_action('xmlrpc_call', 'blogger.getUserInfo'); |
1731 |
|
1732 | $struct = array( |
1733 | 'nickname' => $user->nickname, |
1734 | 'userid' => $user->ID, |
1735 | 'url' => $user->user_url, |
1736 | 'lastname' => $user->last_name, |
1737 | 'firstname' => $user->first_name |
1738 | ); |
1739 |
|
Line | Code |
1756 | $username = $args[2]; |
1757 | $password = $args[3]; |
1758 |
|
1759 | if ( !$user = $this->login($username, $password) ) |
1760 | return $this->error; |
1761 |
|
1762 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
1763 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); |
1764 |
|
1765 | do_action('xmlrpc_call', 'blogger.getPost'); |
1766 |
|
1767 | $post_data = wp_get_single_post($post_ID, ARRAY_A); |
1768 |
|
1769 | $categories = implode(',', wp_get_post_categories($post_ID)); |
1770 |
|
1771 | $content = '<title>'.stripslashes($post_data['post_title']).'</title>'; |
1772 | $content .= '<category>'.$categories.'</category>'; |
1773 | $content .= stripslashes($post_data['post_content']); |
1774 |
|
Line | Code |
1800 | $password = $args[3]; |
1801 | if ( isset( $args[4] ) ) |
1802 | $query = array( 'numberposts' => absint( $args[4] ) ); |
1803 | else |
1804 | $query = array(); |
1805 |
|
1806 | if ( !$user = $this->login($username, $password) ) |
1807 | return $this->error; |
1808 |
|
1809 | do_action('xmlrpc_call', 'blogger.getRecentPosts'); |
1810 |
|
1811 | $posts_list = wp_get_recent_posts( $query ); |
1812 |
|
1813 | if ( !$posts_list ) { |
1814 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
1815 | return $this->error; |
1816 | } |
1817 |
|
1818 | foreach ($posts_list as $entry) { |
Line | Code |
1857 |
|
1858 | $blog_ID = (int) $args[1]; |
1859 | $username = $args[2]; |
1860 | $password = $args[3]; |
1861 | $template = $args[4]; /* could be 'main' or 'archiveIndex', but we don't use it */ |
1862 |
|
1863 | if ( !$user = $this->login($username, $password) ) |
1864 | return $this->error; |
1865 |
|
1866 | do_action('xmlrpc_call', 'blogger.getTemplate'); |
1867 |
|
1868 | if ( !current_user_can('edit_themes') ) |
1869 | return new IXR_Error(401, __('Sorry, this user can not edit the template.')); |
1870 |
|
1871 | /* warning: here we make the assumption that the blog's URL is on the same server */ |
1872 | $filename = get_option('home') . '/'; |
1873 | $filename = preg_replace('#https?://.+?/#', $_SERVER['DOCUMENT_ROOT'].'/', $filename); |
1874 |
|
1875 | $f = fopen($filename, 'r'); |
Line | Code |
1897 | $blog_ID = (int) $args[1]; |
1898 | $username = $args[2]; |
1899 | $password = $args[3]; |
1900 | $content = $args[4]; |
1901 | $template = $args[5]; /* could be 'main' or 'archiveIndex', but we don't use it */ |
1902 |
|
1903 | if ( !$user = $this->login($username, $password) ) |
1904 | return $this->error; |
1905 |
|
1906 | do_action('xmlrpc_call', 'blogger.setTemplate'); |
1907 |
|
1908 | if ( !current_user_can('edit_themes') ) |
1909 | return new IXR_Error(401, __('Sorry, this user cannot edit the template.')); |
1910 |
|
1911 | /* warning: here we make the assumption that the blog's URL is on the same server */ |
1912 | $filename = get_option('home') . '/'; |
1913 | $filename = preg_replace('#https?://.+?/#', $_SERVER['DOCUMENT_ROOT'].'/', $filename); |
1914 |
|
1915 | if ($f = fopen($filename, 'w+')) { |
Line | Code |
1937 | $blog_ID = (int) $args[1]; /* though we don't use it yet */ |
1938 | $username = $args[2]; |
1939 | $password = $args[3]; |
1940 | $content = $args[4]; |
1941 | $publish = $args[5]; |
1942 |
|
1943 | if ( !$user = $this->login($username, $password) ) |
1944 | return $this->error; |
1945 |
|
1946 | do_action('xmlrpc_call', 'blogger.newPost'); |
1947 |
|
1948 | $cap = ($publish) ? 'publish_posts' : 'edit_posts'; |
1949 | if ( !current_user_can($cap) ) |
1950 | return new IXR_Error(401, __('Sorry, you are not allowed to post on this site.')); |
1951 |
|
1952 | $post_status = ($publish) ? 'publish' : 'draft'; |
1953 |
|
1954 | $post_author = $user->ID; |
1955 |
|
Line | Code |
1991 | $post_ID = (int) $args[1]; |
1992 | $username = $args[2]; |
1993 | $password = $args[3]; |
1994 | $content = $args[4]; |
1995 | $publish = $args[5]; |
1996 |
|
1997 | if ( !$user = $this->login($username, $password) ) |
1998 | return $this->error; |
1999 |
|
2000 | do_action('xmlrpc_call', 'blogger.editPost'); |
2001 |
|
2002 | $actual_post = wp_get_single_post($post_ID,ARRAY_A); |
2003 |
|
2004 | if ( !$actual_post || $actual_post['post_type'] != 'post' ) |
2005 | return new IXR_Error(404, __('Sorry, no such post.')); |
2006 |
|
2007 | $this->escape($actual_post); |
2008 |
|
2009 | if ( !current_user_can('edit_post', $post_ID) ) |
Line | Code |
2043 |
|
2044 | $post_ID = (int) $args[1]; |
2045 | $username = $args[2]; |
2046 | $password = $args[3]; |
2047 | $publish = $args[4]; |
2048 |
|
2049 | if ( !$user = $this->login($username, $password) ) |
2050 | return $this->error; |
2051 |
|
2052 | do_action('xmlrpc_call', 'blogger.deletePost'); |
2053 |
|
2054 | $actual_post = wp_get_single_post($post_ID,ARRAY_A); |
2055 |
|
2056 | if ( !$actual_post || $actual_post['post_type'] != 'post' ) |
2057 | return new IXR_Error(404, __('Sorry, no such post.')); |
2058 |
|
2059 | if ( !current_user_can('delete_post', $post_ID) ) |
2060 | return new IXR_Error(401, __('Sorry, you do not have the right to delete this post.')); |
2061 |
|
Line | Code |
2085 | $blog_ID = (int) $args[0]; // we will support this in the near future |
2086 | $username = $args[1]; |
2087 | $password = $args[2]; |
2088 | $content_struct = $args[3]; |
2089 | $publish = isset( $args[4] ) ? $args[4] : 0; |
2090 |
|
2091 | if ( !$user = $this->login($username, $password) ) |
2092 | return $this->error; |
2093 |
|
2094 | do_action('xmlrpc_call', 'metaWeblog.newPost'); |
2095 |
|
2096 | $page_template = ''; |
2097 | if ( !empty( $content_struct['post_type'] ) ) { |
2098 | if ( $content_struct['post_type'] == 'page' ) { |
2099 | if ( $publish ) |
2100 | $cap = 'publish_pages'; |
2101 | elseif ('publish' == $content_struct['page_status']) |
2102 | $cap = 'publish_pages'; |
2103 | else |
Line | Code |
2397 | $post_ID = (int) $args[0]; |
2398 | $username = $args[1]; |
2399 | $password = $args[2]; |
2400 | $content_struct = $args[3]; |
2401 | $publish = $args[4]; |
2402 |
|
2403 | if ( !$user = $this->login($username, $password) ) |
2404 | return $this->error; |
2405 |
|
2406 | do_action('xmlrpc_call', 'metaWeblog.editPost'); |
2407 |
|
2408 | $cap = ( $publish ) ? 'publish_posts' : 'edit_posts'; |
2409 | $error_message = __( 'Sorry, you are not allowed to publish posts on this site.' ); |
2410 | $post_type = 'post'; |
2411 | $page_template = ''; |
2412 | if ( !empty( $content_struct['post_type'] ) ) { |
2413 | if ( $content_struct['post_type'] == 'page' ) { |
2414 | if ( $publish || 'publish' == $content_struct['page_status'] ) |
2415 | $cap = 'publish_pages'; |
Line | Code |
2676 | $username = $args[1]; |
2677 | $password = $args[2]; |
2678 |
|
2679 | if ( !$user = $this->login($username, $password) ) |
2680 | return $this->error; |
2681 |
|
2682 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
2683 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); |
2684 |
|
2685 | do_action('xmlrpc_call', 'metaWeblog.getPost'); |
2686 |
|
2687 | $postdata = wp_get_single_post($post_ID, ARRAY_A); |
2688 |
|
2689 | if ($postdata['post_date'] != '') { |
2690 | $post_date = mysql2date('Ymd\TH:i:s', $postdata['post_date'], false); |
2691 | $post_date_gmt = mysql2date('Ymd\TH:i:s', $postdata['post_date_gmt'], false); |
2692 |
|
2693 | // For drafts use the GMT version of the post date |
2694 | if ( $postdata['post_status'] == 'draft' ) |
Line | Code |
2796 | $password = $args[2]; |
2797 | if ( isset( $args[3] ) ) |
2798 | $query = array( 'numberposts' => absint( $args[3] ) ); |
2799 | else |
2800 | $query = array(); |
2801 |
|
2802 | if ( !$user = $this->login($username, $password) ) |
2803 | return $this->error; |
2804 |
|
2805 | do_action('xmlrpc_call', 'metaWeblog.getRecentPosts'); |
2806 |
|
2807 | $posts_list = wp_get_recent_posts( $query ); |
2808 |
|
2809 | if ( !$posts_list ) |
2810 | return array( ); |
2811 |
|
2812 | foreach ($posts_list as $entry) { |
2813 | if ( !current_user_can( 'edit_post', $entry['ID'] ) ) |
2814 | continue; |
Line | Code |
2906 | $username = $args[1]; |
2907 | $password = $args[2]; |
2908 |
|
2909 | if ( !$user = $this->login($username, $password) ) |
2910 | return $this->error; |
2911 |
|
2912 | if ( !current_user_can( 'edit_posts' ) ) |
2913 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
2914 |
|
2915 | do_action('xmlrpc_call', 'metaWeblog.getCategories'); |
2916 |
|
2917 | $categories_struct = array(); |
2918 |
|
2919 | if ( $cats = get_categories(array('get' => 'all')) ) { |
2920 | foreach ( $cats as $cat ) { |
2921 | $struct['categoryId'] = $cat->term_id; |
2922 | $struct['parentId'] = $cat->parent; |
2923 | $struct['description'] = $cat->name; |
2924 | $struct['categoryDescription'] = $cat->description; |
Line | Code |
2956 | $name = sanitize_file_name( $data['name'] ); |
2957 | $type = $data['type']; |
2958 | $bits = $data['bits']; |
2959 |
|
2960 | logIO('O', '(MW) Received '.strlen($bits).' bytes'); |
2961 |
|
2962 | if ( !$user = $this->login($username, $password) ) |
2963 | return $this->error; |
2964 |
|
2965 | do_action('xmlrpc_call', 'metaWeblog.newMediaObject'); |
2966 |
|
2967 | if ( !current_user_can('upload_files') ) { |
2968 | logIO('O', '(MW) User does not have upload_files capability'); |
2969 | $this->error = new IXR_Error(401, __('You are not allowed to upload files to this site.')); |
2970 | return $this->error; |
2971 | } |
2972 |
|
2973 | if ( $upload_err = apply_filters( "pre_upload_error", false ) ) |
2974 | return new IXR_Error(500, $upload_err); |
Line | Code |
3037 | $password = $args[2]; |
3038 | if ( isset( $args[3] ) ) |
3039 | $query = array( 'numberposts' => absint( $args[3] ) ); |
3040 | else |
3041 | $query = array(); |
3042 |
|
3043 | if ( !$user = $this->login($username, $password) ) |
3044 | return $this->error; |
3045 |
|
3046 | do_action('xmlrpc_call', 'mt.getRecentPostTitles'); |
3047 |
|
3048 | $posts_list = wp_get_recent_posts( $query ); |
3049 |
|
3050 | if ( !$posts_list ) { |
3051 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
3052 | return $this->error; |
3053 | } |
3054 |
|
3055 | foreach ($posts_list as $entry) { |
Line | Code |
3097 | $username = $args[1]; |
3098 | $password = $args[2]; |
3099 |
|
3100 | if ( !$user = $this->login($username, $password) ) |
3101 | return $this->error; |
3102 |
|
3103 | if ( !current_user_can( 'edit_posts' ) ) |
3104 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
3105 |
|
3106 | do_action('xmlrpc_call', 'mt.getCategoryList'); |
3107 |
|
3108 | $categories_struct = array(); |
3109 |
|
3110 | if ( $cats = get_categories(array('hide_empty' => 0, 'hierarchical' => 0)) ) { |
3111 | foreach ( $cats as $cat ) { |
3112 | $struct['categoryId'] = $cat->term_id; |
3113 | $struct['categoryName'] = $cat->name; |
3114 |
|
3115 | $categories_struct[] = $struct; |
Line | Code |
3135 | $username = $args[1]; |
3136 | $password = $args[2]; |
3137 |
|
3138 | if ( !$user = $this->login($username, $password) ) |
3139 | return $this->error; |
3140 |
|
3141 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
3142 | return new IXR_Error( 401, __( 'Sorry, you can not edit this post.' ) ); |
3143 |
|
3144 | do_action('xmlrpc_call', 'mt.getPostCategories'); |
3145 |
|
3146 | $categories = array(); |
3147 | $catids = wp_get_post_categories(intval($post_ID)); |
3148 | // first listed category will be the primary category |
3149 | $isPrimary = true; |
3150 | foreach ( $catids as $catid ) { |
3151 | $categories[] = array( |
3152 | 'categoryName' => get_cat_name($catid), |
3153 | 'categoryId' => (string) $catid, |
Line | Code |
3173 |
|
3174 | $post_ID = (int) $args[0]; |
3175 | $username = $args[1]; |
3176 | $password = $args[2]; |
3177 | $categories = $args[3]; |
3178 |
|
3179 | if ( !$user = $this->login($username, $password) ) |
3180 | return $this->error; |
3181 |
|
3182 | do_action('xmlrpc_call', 'mt.setPostCategories'); |
3183 |
|
3184 | if ( !current_user_can('edit_post', $post_ID) ) |
3185 | return new IXR_Error(401, __('Sorry, you cannot edit this post.')); |
3186 |
|
3187 | foreach ( $categories as $cat ) { |
3188 | $catids[] = $cat['categoryId']; |
3189 | } |
3190 |
|
3191 | wp_set_post_categories($post_ID, $catids); |
Line | Code |
3197 | * Retrieve an array of methods supported by this server. |
3198 | * |
3199 | * @since 1.5.0 |
3200 | * |
3201 | * @param array $args Method parameters. |
3202 | * @return array |
3203 | */ |
3204 | function mt_supportedMethods($args) { |
3205 |
|
3206 | do_action('xmlrpc_call', 'mt.supportedMethods'); |
3207 |
|
3208 | $supported_methods = array(); |
3209 | foreach ( $this->methods as $key => $value ) { |
3210 | $supported_methods[] = $key; |
3211 | } |
3212 |
|
3213 | return $supported_methods; |
3214 | } |
3215 |
|
3216 | /** |
3217 | * Retrieve an empty array because we don't support per-post text filters. |
3218 | * |
3219 | * @since 1.5.0 |
3220 | * |
3221 | * @param array $args Method parameters. |
3222 | */ |
3223 | function mt_supportedTextFilters($args) { |
3224 | do_action('xmlrpc_call', 'mt.supportedTextFilters'); |
3225 | return apply_filters('xmlrpc_text_filters', array()); |
3226 | } |
3227 |
|
3228 | /** |
3229 | * Retrieve trackbacks sent to a given post. |
3230 | * |
3231 | * @since 1.5.0 |
3232 | * |
3233 | * @param array $args Method parameters. |
3234 | * @return mixed |
3235 | */ |
3236 | function mt_getTrackbackPings($args) { |
3237 |
|
3238 | global $wpdb; |
3239 |
|
3240 | $post_ID = intval($args); |
3241 |
|
3242 | do_action('xmlrpc_call', 'mt.getTrackbackPings'); |
3243 |
|
3244 | $actual_post = wp_get_single_post($post_ID, ARRAY_A); |
3245 |
|
3246 | if ( !$actual_post ) |
3247 | return new IXR_Error(404, __('Sorry, no such post.')); |
3248 |
|
3249 | $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) ); |
3250 |
|
3251 | if ( !$comments ) |
Line | Code |
3280 | $this->escape($args); |
3281 |
|
3282 | $post_ID = (int) $args[0]; |
3283 | $username = $args[1]; |
3284 | $password = $args[2]; |
3285 |
|
3286 | if ( !$user = $this->login($username, $password) ) |
3287 | return $this->error; |
3288 |
|
3289 | do_action('xmlrpc_call', 'mt.publishPost'); |
3290 |
|
3291 | if ( !current_user_can('publish_posts') || !current_user_can('edit_post', $post_ID) ) |
3292 | return new IXR_Error(401, __('Sorry, you cannot publish this post.')); |
3293 |
|
3294 | $postdata = wp_get_single_post($post_ID,ARRAY_A); |
3295 |
|
3296 | $postdata['post_status'] = 'publish'; |
3297 |
|
3298 | // retain old cats |
Line | Code |
3314 | * |
3315 | * @since 1.5.0 |
3316 | * |
3317 | * @param array $args Method parameters. |
3318 | * @return array |
3319 | */ |
3320 | function pingback_ping($args) { |
3321 | global $wpdb; |
3322 |
|
3323 | do_action('xmlrpc_call', 'pingback.ping'); |
3324 |
|
3325 | $this->escape($args); |
3326 |
|
3327 | $pagelinkedfrom = $args[0]; |
3328 | $pagelinkedto = $args[1]; |
3329 |
|
3330 | $title = ''; |
3331 |
|
3332 | $pagelinkedfrom = str_replace('&', '&', $pagelinkedfrom); |
Line | Code |
3485 | * @since 1.5.0 |
3486 | * |
3487 | * @param array $args Method parameters. |
3488 | * @return array |
3489 | */ |
3490 | function pingback_extensions_getPingbacks($args) { |
3491 |
|
3492 | global $wpdb; |
3493 |
|
3494 | do_action('xmlrpc_call', 'pingback.extensions.getPingbacks'); |
3495 |
|
3496 | $this->escape($args); |
3497 |
|
3498 | $url = $args; |
3499 |
|
3500 | $post_ID = url_to_postid($url); |
3501 | if ( !$post_ID ) { |
3502 | // We aren't sure that the resource is available and/or pingback enabled |
3503 | 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.')); |