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 |
---|---|
403 | $this->escape( $args ); |
404 |
|
405 | $username = $args[0]; |
406 | $password = $args[1]; |
407 |
|
408 | if ( !$user = $this->login($username, $password) ) |
409 | return $this->error; |
410 |
|
411 |
|
412 | do_action( 'xmlrpc_call', 'wp.getUsersBlogs' ); |
413 |
|
414 | $blogs = (array) get_blogs_of_user( $user->ID ); |
415 | $struct = array( ); |
416 |
|
417 | foreach ( $blogs as $blog ) { |
418 | // Don't include blogs that aren't hosted at this site |
419 | if ( $blog->site_id != $current_site->id ) |
420 | continue; |
421 |
|
Line | Code |
458 | $password = $args[3]; |
459 |
|
460 | if ( !$user = $this->login($username, $password) ) { |
461 | return $this->error; |
462 | } |
463 |
|
464 | if ( !current_user_can( 'edit_page', $page_id ) ) |
465 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this page.' ) ); |
466 |
|
467 | do_action('xmlrpc_call', 'wp.getPage'); |
468 |
|
469 | // Lookup page info. |
470 | $page = get_page($page_id); |
471 |
|
472 | // If we found the page then format the data. |
473 | if ( $page->ID && ($page->post_type == 'page') ) { |
474 | // Get all of the page content and link. |
475 | $full_page = get_extended($page->post_content); |
476 | $link = post_permalink($page->ID); |
Line | Code |
562 | $password = $args[2]; |
563 | $num_pages = isset($args[3]) ? (int) $args[3] : 10; |
564 |
|
565 | if ( !$user = $this->login($username, $password) ) |
566 | return $this->error; |
567 |
|
568 | if ( !current_user_can( 'edit_pages' ) ) |
569 | return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) ); |
570 |
|
571 | do_action('xmlrpc_call', 'wp.getPages'); |
572 |
|
573 | $pages = get_posts( array('post_type' => 'page', 'post_status' => 'any', 'numberposts' => $num_pages) ); |
574 | $num_pages = count($pages); |
575 |
|
576 | // If we have pages, put together their info. |
577 | if ( $num_pages >= 1 ) { |
578 | $pages_struct = array(); |
579 |
|
580 | for ( $i = 0; $i < $num_pages; $i++ ) { |
Line | Code |
604 | // Items not escaped here will be escaped in newPost. |
605 | $username = $this->escape($args[1]); |
606 | $password = $this->escape($args[2]); |
607 | $page = $args[3]; |
608 | $publish = $args[4]; |
609 |
|
610 | if ( !$user = $this->login($username, $password) ) |
611 | return $this->error; |
612 |
|
613 | do_action('xmlrpc_call', 'wp.newPage'); |
614 |
|
615 | // Make sure the user is allowed to add new pages. |
616 | if ( !current_user_can('publish_pages') ) |
617 | return(new IXR_Error(401, __('Sorry, you cannot add new pages.'))); |
618 |
|
619 | // Mark this as content for a page. |
620 | $args[3]["post_type"] = 'page'; |
621 |
|
622 | // Let mw_newPost do all of the heavy lifting. |
Line | Code |
636 |
|
637 | $blog_id = (int) $args[0]; |
638 | $username = $args[1]; |
639 | $password = $args[2]; |
640 | $page_id = (int) $args[3]; |
641 |
|
642 | if ( !$user = $this->login($username, $password) ) |
643 | return $this->error; |
644 |
|
645 | do_action('xmlrpc_call', 'wp.deletePage'); |
646 |
|
647 | // Get the current page based on the page_id and |
648 | // make sure it is a page and not a post. |
649 | $actual_page = wp_get_single_post($page_id, ARRAY_A); |
650 | if ( !$actual_page || ($actual_page['post_type'] != 'page') ) |
651 | return(new IXR_Error(404, __('Sorry, no such page.'))); |
652 |
|
653 | // Make sure the user can delete pages. |
654 | if ( !current_user_can('delete_page', $page_id) ) |
Line | Code |
676 | $page_id = (int) $this->escape($args[1]); |
677 | $username = $this->escape($args[2]); |
678 | $password = $this->escape($args[3]); |
679 | $content = $args[4]; |
680 | $publish = $args[5]; |
681 |
|
682 | if ( !$user = $this->login($username, $password) ) |
683 | return $this->error; |
684 |
|
685 | do_action('xmlrpc_call', 'wp.editPage'); |
686 |
|
687 | // Get the page data and make sure it is a page. |
688 | $actual_page = wp_get_single_post($page_id, ARRAY_A); |
689 | if ( !$actual_page || ($actual_page['post_type'] != 'page') ) |
690 | return(new IXR_Error(404, __('Sorry, no such page.'))); |
691 |
|
692 | // Make sure the user is allowed to edit pages. |
693 | if ( !current_user_can('edit_page', $page_id) ) |
694 | return(new IXR_Error(401, __('Sorry, you do not have the right to edit this page.'))); |
Line | Code |
726 | $username = $args[1]; |
727 | $password = $args[2]; |
728 |
|
729 | if ( !$user = $this->login($username, $password) ) |
730 | return $this->error; |
731 |
|
732 | if ( !current_user_can( 'edit_pages' ) ) |
733 | return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) ); |
734 |
|
735 | do_action('xmlrpc_call', 'wp.getPageList'); |
736 |
|
737 | // Get list of pages ids and titles |
738 | $page_list = $wpdb->get_results(" |
739 | SELECT ID page_id, |
740 | post_title page_title, |
741 | post_parent page_parent_id, |
742 | post_date_gmt, |
743 | post_date, |
744 | post_status |
Line | Code |
786 | $username = $args[1]; |
787 | $password = $args[2]; |
788 |
|
789 | if ( !$user = $this->login($username, $password) ) |
790 | return $this->error; |
791 |
|
792 | if ( !current_user_can('edit_posts') ) |
793 | return(new IXR_Error(401, __('Sorry, you cannot edit posts on this site.'))); |
794 |
|
795 | do_action('xmlrpc_call', 'wp.getAuthors'); |
796 |
|
797 | $authors = array(); |
798 | foreach ( get_users( array( 'fields' => array('ID','user_login','display_name') ) ) as $user ) { |
799 | $authors[] = array( |
800 | 'user_id' => $user->ID, |
801 | 'user_login' => $user->user_login, |
802 | 'display_name' => $user->display_name |
803 | ); |
804 | } |
Line | Code |
821 | $username = $args[1]; |
822 | $password = $args[2]; |
823 |
|
824 | if ( !$user = $this->login($username, $password) ) |
825 | return $this->error; |
826 |
|
827 | if ( !current_user_can( 'edit_posts' ) ) |
828 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view tags.' ) ); |
829 |
|
830 | do_action( 'xmlrpc_call', 'wp.getKeywords' ); |
831 |
|
832 | $tags = array( ); |
833 |
|
834 | if ( $all_tags = get_tags() ) { |
835 | foreach( (array) $all_tags as $tag ) { |
836 | $struct['tag_id'] = $tag->term_id; |
837 | $struct['name'] = $tag->name; |
838 | $struct['count'] = $tag->count; |
839 | $struct['slug'] = $tag->slug; |
Line | Code |
860 |
|
861 | $blog_id = (int) $args[0]; |
862 | $username = $args[1]; |
863 | $password = $args[2]; |
864 | $category = $args[3]; |
865 |
|
866 | if ( !$user = $this->login($username, $password) ) |
867 | return $this->error; |
868 |
|
869 | do_action('xmlrpc_call', 'wp.newCategory'); |
870 |
|
871 | // Make sure the user is allowed to add a category. |
872 | if ( !current_user_can('manage_categories') ) |
873 | return(new IXR_Error(401, __('Sorry, you do not have the right to add a category.'))); |
874 |
|
875 | // If no slug was provided make it empty so that |
876 | // WordPress will generate one. |
877 | if ( empty($category['slug']) ) |
878 | $category['slug'] = ''; |
Line | Code |
919 |
|
920 | $blog_id = (int) $args[0]; |
921 | $username = $args[1]; |
922 | $password = $args[2]; |
923 | $category_id = (int) $args[3]; |
924 |
|
925 | if ( !$user = $this->login($username, $password) ) |
926 | return $this->error; |
927 |
|
928 | do_action('xmlrpc_call', 'wp.deleteCategory'); |
929 |
|
930 | if ( !current_user_can('manage_categories') ) |
931 | return new IXR_Error( 401, __( 'Sorry, you do not have the right to delete a category.' ) ); |
932 |
|
933 | return wp_delete_term( $category_id, 'category' ); |
934 | } |
935 |
|
936 | /** |
937 | * Retrieve category list. |
Line | Code |
950 | $category = $args[3]; |
951 | $max_results = (int) $args[4]; |
952 |
|
953 | if ( !$user = $this->login($username, $password) ) |
954 | return $this->error; |
955 |
|
956 | if ( !current_user_can( 'edit_posts' ) ) |
957 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts to this site in order to view categories.' ) ); |
958 |
|
959 | do_action('xmlrpc_call', 'wp.suggestCategories'); |
960 |
|
961 | $category_suggestions = array(); |
962 | $args = array('get' => 'all', 'number' => $max_results, 'name__like' => $category); |
963 | foreach ( (array) get_categories($args) as $cat ) { |
964 | $category_suggestions[] = array( |
965 | 'category_id' => $cat->term_id, |
966 | 'category_name' => $cat->name |
967 | ); |
968 | } |
Line | Code |
986 | $password = $args[2]; |
987 | $comment_id = (int) $args[3]; |
988 |
|
989 | if ( !$user = $this->login($username, $password) ) |
990 | return $this->error; |
991 |
|
992 | if ( !current_user_can( 'moderate_comments' ) ) |
993 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
994 |
|
995 | do_action('xmlrpc_call', 'wp.getComment'); |
996 |
|
997 | if ( ! $comment = get_comment($comment_id) ) |
998 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
999 |
|
1000 | // Format page date. |
1001 | $comment_date = mysql2date('Ymd\TH:i:s', $comment->comment_date, false); |
1002 | $comment_date_gmt = mysql2date('Ymd\TH:i:s', $comment->comment_date_gmt, false); |
1003 |
|
1004 | if ( '0' == $comment->comment_approved ) |
Line | Code |
1060 | $password = $args[2]; |
1061 | $struct = $args[3]; |
1062 |
|
1063 | if ( !$user = $this->login($username, $password) ) |
1064 | return $this->error; |
1065 |
|
1066 | if ( !current_user_can( 'moderate_comments' ) ) |
1067 | return new IXR_Error( 401, __( 'Sorry, you cannot edit comments.' ) ); |
1068 |
|
1069 | do_action('xmlrpc_call', 'wp.getComments'); |
1070 |
|
1071 | if ( isset($struct['status']) ) |
1072 | $status = $struct['status']; |
1073 | else |
1074 | $status = ''; |
1075 |
|
1076 | $post_id = ''; |
1077 | if ( isset($struct['post_id']) ) |
1078 | $post_id = absint($struct['post_id']); |
Line | Code |
1131 | if ( !$user = $this->login($username, $password) ) |
1132 | return $this->error; |
1133 |
|
1134 | if ( !current_user_can( 'moderate_comments' ) ) |
1135 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
1136 |
|
1137 | if ( !current_user_can( 'edit_comment', $comment_ID ) ) |
1138 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
1139 |
|
1140 | do_action('xmlrpc_call', 'wp.deleteComment'); |
1141 |
|
1142 | if ( ! get_comment($comment_ID) ) |
1143 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
1144 |
|
1145 | return wp_delete_comment($comment_ID); |
1146 | } |
1147 |
|
1148 | /** |
1149 | * Edit comment. |
Line | Code |
1181 | if ( !$user = $this->login($username, $password) ) |
1182 | return $this->error; |
1183 |
|
1184 | if ( !current_user_can( 'moderate_comments' ) ) |
1185 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
1186 |
|
1187 | if ( !current_user_can( 'edit_comment', $comment_ID ) ) |
1188 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
1189 |
|
1190 | do_action('xmlrpc_call', 'wp.editComment'); |
1191 |
|
1192 | if ( ! get_comment($comment_ID) ) |
1193 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
1194 |
|
1195 | if ( isset($content_struct['status']) ) { |
1196 | $statuses = get_comment_statuses(); |
1197 | $statuses = array_keys($statuses); |
1198 |
|
1199 | if ( ! in_array($content_struct['status'], $statuses) ) |
Line | Code |
1305 | elseif ( !is_email($comment['comment_author_email']) ) |
1306 | return new IXR_Error( 403, __( 'A valid email address is required' ) ); |
1307 | } |
1308 | } |
1309 |
|
1310 | $comment['comment_parent'] = isset($content_struct['comment_parent']) ? absint($content_struct['comment_parent']) : 0; |
1311 |
|
1312 | $comment['comment_content'] = isset($content_struct['content']) ? $content_struct['content'] : null; |
1313 |
|
1314 | do_action('xmlrpc_call', 'wp.newComment'); |
1315 |
|
1316 | return wp_new_comment($comment); |
1317 | } |
1318 |
|
1319 | /** |
1320 | * Retrieve all of the comment status. |
1321 | * |
1322 | * @since 2.7.0 |
1323 | * |
Line | Code |
1331 | $username = $args[1]; |
1332 | $password = $args[2]; |
1333 |
|
1334 | if ( !$user = $this->login($username, $password) ) |
1335 | return $this->error; |
1336 |
|
1337 | if ( !current_user_can( 'moderate_comments' ) ) |
1338 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
1339 |
|
1340 | do_action('xmlrpc_call', 'wp.getCommentStatusList'); |
1341 |
|
1342 | return get_comment_statuses( ); |
1343 | } |
1344 |
|
1345 | /** |
1346 | * Retrieve comment count. |
1347 | * |
1348 | * @since 2.5.0 |
1349 | * |
Line | Code |
1358 | $password = $args[2]; |
1359 | $post_id = (int) $args[3]; |
1360 |
|
1361 | if ( !$user = $this->login($username, $password) ) |
1362 | return $this->error; |
1363 |
|
1364 | if ( !current_user_can( 'edit_posts' ) ) |
1365 | return new IXR_Error( 403, __( 'You are not allowed access to details about comments.' ) ); |
1366 |
|
1367 | do_action('xmlrpc_call', 'wp.getCommentCount'); |
1368 |
|
1369 | $count = wp_count_comments( $post_id ); |
1370 | return array( |
1371 | 'approved' => $count->approved, |
1372 | 'awaiting_moderation' => $count->moderated, |
1373 | 'spam' => $count->spam, |
1374 | 'total_comments' => $count->total_comments |
1375 | ); |
1376 | } |
Line | Code |
1390 | $username = $args[1]; |
1391 | $password = $args[2]; |
1392 |
|
1393 | if ( !$user = $this->login($username, $password) ) |
1394 | return $this->error; |
1395 |
|
1396 | if ( !current_user_can( 'edit_posts' ) ) |
1397 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
1398 |
|
1399 | do_action('xmlrpc_call', 'wp.getPostStatusList'); |
1400 |
|
1401 | return get_post_statuses( ); |
1402 | } |
1403 |
|
1404 | /** |
1405 | * Retrieve page statuses. |
1406 | * |
1407 | * @since 2.5.0 |
1408 | * |
Line | Code |
1416 | $username = $args[1]; |
1417 | $password = $args[2]; |
1418 |
|
1419 | if ( !$user = $this->login($username, $password) ) |
1420 | return $this->error; |
1421 |
|
1422 | if ( !current_user_can( 'edit_pages' ) ) |
1423 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
1424 |
|
1425 | do_action('xmlrpc_call', 'wp.getPageStatusList'); |
1426 |
|
1427 | return get_page_statuses( ); |
1428 | } |
1429 |
|
1430 | /** |
1431 | * Retrieve page templates. |
1432 | * |
1433 | * @since 2.6.0 |
1434 | * |
Line | Code |
1569 | $password = $args[2]; |
1570 | $attachment_id = (int) $args[3]; |
1571 |
|
1572 | if ( !$user = $this->login($username, $password) ) |
1573 | return $this->error; |
1574 |
|
1575 | if ( !current_user_can( 'upload_files' ) ) |
1576 | return new IXR_Error( 403, __( 'You are not allowed to upload files to this site.' ) ); |
1577 |
|
1578 | do_action('xmlrpc_call', 'wp.getMediaItem'); |
1579 |
|
1580 | if ( ! $attachment = get_post($attachment_id) ) |
1581 | return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); |
1582 |
|
1583 | // Format page date. |
1584 | $attachment_date = mysql2date('Ymd\TH:i:s', $attachment->post_date, false); |
1585 | $attachment_date_gmt = mysql2date('Ymd\TH:i:s', $attachment->post_date_gmt, false); |
1586 |
|
1587 | $link = wp_get_attachment_url($attachment->ID); |
Line | Code |
1633 | $password = $args[2]; |
1634 | $struct = isset( $args[3] ) ? $args[3] : array() ; |
1635 |
|
1636 | if ( !$user = $this->login($username, $password) ) |
1637 | return $this->error; |
1638 |
|
1639 | if ( !current_user_can( 'upload_files' ) ) |
1640 | return new IXR_Error( 401, __( 'Sorry, you cannot upload files.' ) ); |
1641 |
|
1642 | do_action('xmlrpc_call', 'wp.getMediaLibrary'); |
1643 |
|
1644 | $parent_id = ( isset($struct['parent_id']) ) ? absint($struct['parent_id']) : '' ; |
1645 | $mime_type = ( isset($struct['mime_type']) ) ? $struct['mime_type'] : '' ; |
1646 | $offset = ( isset($struct['offset']) ) ? absint($struct['offset']) : 0 ; |
1647 | $number = ( isset($struct['number']) ) ? absint($struct['number']) : -1 ; |
1648 |
|
1649 | $attachments = get_posts( array('post_type' => 'attachment', 'post_parent' => $parent_id, 'offset' => $offset, 'numberposts' => $number, 'post_mime_type' => $mime_type ) ); |
1650 | $num_attachments = count($attachments); |
1651 |
|
Line | Code |
1675 | $this->escape( $args ); |
1676 |
|
1677 | $blog_id = (int) $args[0]; |
1678 | $username = $args[1]; |
1679 | $password = $args[2]; |
1680 |
|
1681 | if ( !$user = $this->login( $username, $password ) ) |
1682 | return $this->error; |
1683 |
|
1684 | do_action( 'xmlrpc_call', 'wp.getPostFormats' ); |
1685 |
|
1686 | $formats = get_post_format_strings(); |
1687 |
|
1688 | # find out if they want a list of currently supports formats |
1689 | if ( isset( $args[3] ) && is_array( $args[3] ) ) { |
1690 | if ( $args[3]['show-supported'] ) { |
1691 | if ( current_theme_supports( 'post-formats' ) ) { |
1692 | $supported = get_theme_support( 'post-formats' ); |
1693 |
|
Line | Code |
1722 |
|
1723 | $this->escape($args); |
1724 |
|
1725 | $username = $args[1]; |
1726 | $password = $args[2]; |
1727 |
|
1728 | if ( !$user = $this->login($username, $password) ) |
1729 | return $this->error; |
1730 |
|
1731 | do_action('xmlrpc_call', 'blogger.getUsersBlogs'); |
1732 |
|
1733 | $is_admin = current_user_can('manage_options'); |
1734 |
|
1735 | $struct = array( |
1736 | 'isAdmin' => $is_admin, |
1737 | 'url' => get_option('home') . '/', |
1738 | 'blogid' => '1', |
1739 | 'blogName' => get_option('blogname'), |
1740 | 'xmlrpc' => site_url( 'xmlrpc.php' ) |
Line | Code |
1789 | $username = $args[1]; |
1790 | $password = $args[2]; |
1791 |
|
1792 | if ( !$user = $this->login($username, $password) ) |
1793 | return $this->error; |
1794 |
|
1795 | if ( !current_user_can( 'edit_posts' ) ) |
1796 | return new IXR_Error( 401, __( 'Sorry, you do not have access to user data on this site.' ) ); |
1797 |
|
1798 | do_action('xmlrpc_call', 'blogger.getUserInfo'); |
1799 |
|
1800 | $struct = array( |
1801 | 'nickname' => $user->nickname, |
1802 | 'userid' => $user->ID, |
1803 | 'url' => $user->user_url, |
1804 | 'lastname' => $user->last_name, |
1805 | 'firstname' => $user->first_name |
1806 | ); |
1807 |
|
Line | Code |
1824 | $username = $args[2]; |
1825 | $password = $args[3]; |
1826 |
|
1827 | if ( !$user = $this->login($username, $password) ) |
1828 | return $this->error; |
1829 |
|
1830 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
1831 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); |
1832 |
|
1833 | do_action('xmlrpc_call', 'blogger.getPost'); |
1834 |
|
1835 | $post_data = wp_get_single_post($post_ID, ARRAY_A); |
1836 |
|
1837 | $categories = implode(',', wp_get_post_categories($post_ID)); |
1838 |
|
1839 | $content = '<title>'.stripslashes($post_data['post_title']).'</title>'; |
1840 | $content .= '<category>'.$categories.'</category>'; |
1841 | $content .= stripslashes($post_data['post_content']); |
1842 |
|
Line | Code |
1868 | $password = $args[3]; |
1869 | if ( isset( $args[4] ) ) |
1870 | $query = array( 'numberposts' => absint( $args[4] ) ); |
1871 | else |
1872 | $query = array(); |
1873 |
|
1874 | if ( !$user = $this->login($username, $password) ) |
1875 | return $this->error; |
1876 |
|
1877 | do_action('xmlrpc_call', 'blogger.getRecentPosts'); |
1878 |
|
1879 | $posts_list = wp_get_recent_posts( $query ); |
1880 |
|
1881 | if ( !$posts_list ) { |
1882 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
1883 | return $this->error; |
1884 | } |
1885 |
|
1886 | foreach ($posts_list as $entry) { |
Line | Code |
1925 |
|
1926 | $blog_ID = (int) $args[1]; |
1927 | $username = $args[2]; |
1928 | $password = $args[3]; |
1929 | $template = $args[4]; /* could be 'main' or 'archiveIndex', but we don't use it */ |
1930 |
|
1931 | if ( !$user = $this->login($username, $password) ) |
1932 | return $this->error; |
1933 |
|
1934 | do_action('xmlrpc_call', 'blogger.getTemplate'); |
1935 |
|
1936 | if ( !current_user_can('edit_themes') ) |
1937 | return new IXR_Error(401, __('Sorry, this user can not edit the template.')); |
1938 |
|
1939 | /* warning: here we make the assumption that the blog's URL is on the same server */ |
1940 | $filename = get_option('home') . '/'; |
1941 | $filename = preg_replace('#https?://.+?/#', $_SERVER['DOCUMENT_ROOT'].'/', $filename); |
1942 |
|
1943 | $f = fopen($filename, 'r'); |
Line | Code |
1965 | $blog_ID = (int) $args[1]; |
1966 | $username = $args[2]; |
1967 | $password = $args[3]; |
1968 | $content = $args[4]; |
1969 | $template = $args[5]; /* could be 'main' or 'archiveIndex', but we don't use it */ |
1970 |
|
1971 | if ( !$user = $this->login($username, $password) ) |
1972 | return $this->error; |
1973 |
|
1974 | do_action('xmlrpc_call', 'blogger.setTemplate'); |
1975 |
|
1976 | if ( !current_user_can('edit_themes') ) |
1977 | return new IXR_Error(401, __('Sorry, this user cannot edit the template.')); |
1978 |
|
1979 | /* warning: here we make the assumption that the blog's URL is on the same server */ |
1980 | $filename = get_option('home') . '/'; |
1981 | $filename = preg_replace('#https?://.+?/#', $_SERVER['DOCUMENT_ROOT'].'/', $filename); |
1982 |
|
1983 | if ($f = fopen($filename, 'w+')) { |
Line | Code |
2005 | $blog_ID = (int) $args[1]; /* though we don't use it yet */ |
2006 | $username = $args[2]; |
2007 | $password = $args[3]; |
2008 | $content = $args[4]; |
2009 | $publish = $args[5]; |
2010 |
|
2011 | if ( !$user = $this->login($username, $password) ) |
2012 | return $this->error; |
2013 |
|
2014 | do_action('xmlrpc_call', 'blogger.newPost'); |
2015 |
|
2016 | $cap = ($publish) ? 'publish_posts' : 'edit_posts'; |
2017 | if ( !current_user_can($cap) ) |
2018 | return new IXR_Error(401, __('Sorry, you are not allowed to post on this site.')); |
2019 |
|
2020 | $post_status = ($publish) ? 'publish' : 'draft'; |
2021 |
|
2022 | $post_author = $user->ID; |
2023 |
|
Line | Code |
2059 | $post_ID = (int) $args[1]; |
2060 | $username = $args[2]; |
2061 | $password = $args[3]; |
2062 | $content = $args[4]; |
2063 | $publish = $args[5]; |
2064 |
|
2065 | if ( !$user = $this->login($username, $password) ) |
2066 | return $this->error; |
2067 |
|
2068 | do_action('xmlrpc_call', 'blogger.editPost'); |
2069 |
|
2070 | $actual_post = wp_get_single_post($post_ID,ARRAY_A); |
2071 |
|
2072 | if ( !$actual_post || $actual_post['post_type'] != 'post' ) |
2073 | return new IXR_Error(404, __('Sorry, no such post.')); |
2074 |
|
2075 | $this->escape($actual_post); |
2076 |
|
2077 | if ( !current_user_can('edit_post', $post_ID) ) |
Line | Code |
2111 |
|
2112 | $post_ID = (int) $args[1]; |
2113 | $username = $args[2]; |
2114 | $password = $args[3]; |
2115 | $publish = $args[4]; |
2116 |
|
2117 | if ( !$user = $this->login($username, $password) ) |
2118 | return $this->error; |
2119 |
|
2120 | do_action('xmlrpc_call', 'blogger.deletePost'); |
2121 |
|
2122 | $actual_post = wp_get_single_post($post_ID,ARRAY_A); |
2123 |
|
2124 | if ( !$actual_post || $actual_post['post_type'] != 'post' ) |
2125 | return new IXR_Error(404, __('Sorry, no such post.')); |
2126 |
|
2127 | if ( !current_user_can('delete_post', $post_ID) ) |
2128 | return new IXR_Error(401, __('Sorry, you do not have the right to delete this post.')); |
2129 |
|
Line | Code |
2179 | $blog_ID = (int) $args[0]; // we will support this in the near future |
2180 | $username = $args[1]; |
2181 | $password = $args[2]; |
2182 | $content_struct = $args[3]; |
2183 | $publish = isset( $args[4] ) ? $args[4] : 0; |
2184 |
|
2185 | if ( !$user = $this->login($username, $password) ) |
2186 | return $this->error; |
2187 |
|
2188 | do_action('xmlrpc_call', 'metaWeblog.newPost'); |
2189 |
|
2190 | $page_template = ''; |
2191 | if ( !empty( $content_struct['post_type'] ) ) { |
2192 | if ( $content_struct['post_type'] == 'page' ) { |
2193 | if ( $publish ) |
2194 | $cap = 'publish_pages'; |
2195 | elseif ('publish' == $content_struct['page_status']) |
2196 | $cap = 'publish_pages'; |
2197 | else |
Line | Code |
2487 | $post_ID = (int) $args[0]; |
2488 | $username = $args[1]; |
2489 | $password = $args[2]; |
2490 | $content_struct = $args[3]; |
2491 | $publish = $args[4]; |
2492 |
|
2493 | if ( !$user = $this->login($username, $password) ) |
2494 | return $this->error; |
2495 |
|
2496 | do_action('xmlrpc_call', 'metaWeblog.editPost'); |
2497 |
|
2498 | $cap = ( $publish ) ? 'publish_posts' : 'edit_posts'; |
2499 | $error_message = __( 'Sorry, you are not allowed to publish posts on this site.' ); |
2500 | $post_type = 'post'; |
2501 | $page_template = ''; |
2502 | if ( !empty( $content_struct['post_type'] ) ) { |
2503 | if ( $content_struct['post_type'] == 'page' ) { |
2504 | if ( $publish || 'publish' == $content_struct['page_status'] ) |
2505 | $cap = 'publish_pages'; |
Line | Code |
2763 | $username = $args[1]; |
2764 | $password = $args[2]; |
2765 |
|
2766 | if ( !$user = $this->login($username, $password) ) |
2767 | return $this->error; |
2768 |
|
2769 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
2770 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); |
2771 |
|
2772 | do_action('xmlrpc_call', 'metaWeblog.getPost'); |
2773 |
|
2774 | $postdata = wp_get_single_post($post_ID, ARRAY_A); |
2775 |
|
2776 | if ($postdata['post_date'] != '') { |
2777 | $post_date = mysql2date('Ymd\TH:i:s', $postdata['post_date'], false); |
2778 | $post_date_gmt = mysql2date('Ymd\TH:i:s', $postdata['post_date_gmt'], false); |
2779 |
|
2780 | // For drafts use the GMT version of the post date |
2781 | if ( $postdata['post_status'] == 'draft' ) |
Line | Code |
2883 | $password = $args[2]; |
2884 | if ( isset( $args[3] ) ) |
2885 | $query = array( 'numberposts' => absint( $args[3] ) ); |
2886 | else |
2887 | $query = array(); |
2888 |
|
2889 | if ( !$user = $this->login($username, $password) ) |
2890 | return $this->error; |
2891 |
|
2892 | do_action('xmlrpc_call', 'metaWeblog.getRecentPosts'); |
2893 |
|
2894 | $posts_list = wp_get_recent_posts( $query ); |
2895 |
|
2896 | if ( !$posts_list ) |
2897 | return array( ); |
2898 |
|
2899 | foreach ($posts_list as $entry) { |
2900 | if ( !current_user_can( 'edit_post', $entry['ID'] ) ) |
2901 | continue; |
Line | Code |
2993 | $username = $args[1]; |
2994 | $password = $args[2]; |
2995 |
|
2996 | if ( !$user = $this->login($username, $password) ) |
2997 | return $this->error; |
2998 |
|
2999 | if ( !current_user_can( 'edit_posts' ) ) |
3000 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
3001 |
|
3002 | do_action('xmlrpc_call', 'metaWeblog.getCategories'); |
3003 |
|
3004 | $categories_struct = array(); |
3005 |
|
3006 | if ( $cats = get_categories(array('get' => 'all')) ) { |
3007 | foreach ( $cats as $cat ) { |
3008 | $struct['categoryId'] = $cat->term_id; |
3009 | $struct['parentId'] = $cat->parent; |
3010 | $struct['description'] = $cat->name; |
3011 | $struct['categoryDescription'] = $cat->description; |
Line | Code |
3043 | $name = sanitize_file_name( $data['name'] ); |
3044 | $type = $data['type']; |
3045 | $bits = $data['bits']; |
3046 |
|
3047 | logIO('O', '(MW) Received '.strlen($bits).' bytes'); |
3048 |
|
3049 | if ( !$user = $this->login($username, $password) ) |
3050 | return $this->error; |
3051 |
|
3052 | do_action('xmlrpc_call', 'metaWeblog.newMediaObject'); |
3053 |
|
3054 | if ( !current_user_can('upload_files') ) { |
3055 | logIO('O', '(MW) User does not have upload_files capability'); |
3056 | $this->error = new IXR_Error(401, __('You are not allowed to upload files to this site.')); |
3057 | return $this->error; |
3058 | } |
3059 |
|
3060 | if ( $upload_err = apply_filters( 'pre_upload_error', false ) ) |
3061 | return new IXR_Error(500, $upload_err); |
Line | Code |
3124 | $password = $args[2]; |
3125 | if ( isset( $args[3] ) ) |
3126 | $query = array( 'numberposts' => absint( $args[3] ) ); |
3127 | else |
3128 | $query = array(); |
3129 |
|
3130 | if ( !$user = $this->login($username, $password) ) |
3131 | return $this->error; |
3132 |
|
3133 | do_action('xmlrpc_call', 'mt.getRecentPostTitles'); |
3134 |
|
3135 | $posts_list = wp_get_recent_posts( $query ); |
3136 |
|
3137 | if ( !$posts_list ) { |
3138 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
3139 | return $this->error; |
3140 | } |
3141 |
|
3142 | foreach ($posts_list as $entry) { |
Line | Code |
3185 | $username = $args[1]; |
3186 | $password = $args[2]; |
3187 |
|
3188 | if ( !$user = $this->login($username, $password) ) |
3189 | return $this->error; |
3190 |
|
3191 | if ( !current_user_can( 'edit_posts' ) ) |
3192 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
3193 |
|
3194 | do_action('xmlrpc_call', 'mt.getCategoryList'); |
3195 |
|
3196 | $categories_struct = array(); |
3197 |
|
3198 | if ( $cats = get_categories(array('hide_empty' => 0, 'hierarchical' => 0)) ) { |
3199 | foreach ( $cats as $cat ) { |
3200 | $struct['categoryId'] = $cat->term_id; |
3201 | $struct['categoryName'] = $cat->name; |
3202 |
|
3203 | $categories_struct[] = $struct; |
Line | Code |
3223 | $username = $args[1]; |
3224 | $password = $args[2]; |
3225 |
|
3226 | if ( !$user = $this->login($username, $password) ) |
3227 | return $this->error; |
3228 |
|
3229 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
3230 | return new IXR_Error( 401, __( 'Sorry, you can not edit this post.' ) ); |
3231 |
|
3232 | do_action('xmlrpc_call', 'mt.getPostCategories'); |
3233 |
|
3234 | $categories = array(); |
3235 | $catids = wp_get_post_categories(intval($post_ID)); |
3236 | // first listed category will be the primary category |
3237 | $isPrimary = true; |
3238 | foreach ( $catids as $catid ) { |
3239 | $categories[] = array( |
3240 | 'categoryName' => get_cat_name($catid), |
3241 | 'categoryId' => (string) $catid, |
Line | Code |
3261 |
|
3262 | $post_ID = (int) $args[0]; |
3263 | $username = $args[1]; |
3264 | $password = $args[2]; |
3265 | $categories = $args[3]; |
3266 |
|
3267 | if ( !$user = $this->login($username, $password) ) |
3268 | return $this->error; |
3269 |
|
3270 | do_action('xmlrpc_call', 'mt.setPostCategories'); |
3271 |
|
3272 | if ( !current_user_can('edit_post', $post_ID) ) |
3273 | return new IXR_Error(401, __('Sorry, you cannot edit this post.')); |
3274 |
|
3275 | foreach ( $categories as $cat ) { |
3276 | $catids[] = $cat['categoryId']; |
3277 | } |
3278 |
|
3279 | wp_set_post_categories($post_ID, $catids); |
Line | Code |
3285 | * Retrieve an array of methods supported by this server. |
3286 | * |
3287 | * @since 1.5.0 |
3288 | * |
3289 | * @param array $args Method parameters. |
3290 | * @return array |
3291 | */ |
3292 | function mt_supportedMethods($args) { |
3293 |
|
3294 | do_action('xmlrpc_call', 'mt.supportedMethods'); |
3295 |
|
3296 | $supported_methods = array(); |
3297 | foreach ( $this->methods as $key => $value ) { |
3298 | $supported_methods[] = $key; |
3299 | } |
3300 |
|
3301 | return $supported_methods; |
3302 | } |
3303 |
|
3304 | /** |
3305 | * Retrieve an empty array because we don't support per-post text filters. |
3306 | * |
3307 | * @since 1.5.0 |
3308 | * |
3309 | * @param array $args Method parameters. |
3310 | */ |
3311 | function mt_supportedTextFilters($args) { |
3312 | do_action('xmlrpc_call', 'mt.supportedTextFilters'); |
3313 | return apply_filters('xmlrpc_text_filters', array()); |
3314 | } |
3315 |
|
3316 | /** |
3317 | * Retrieve trackbacks sent to a given post. |
3318 | * |
3319 | * @since 1.5.0 |
3320 | * |
3321 | * @param array $args Method parameters. |
3322 | * @return mixed |
3323 | */ |
3324 | function mt_getTrackbackPings($args) { |
3325 |
|
3326 | global $wpdb; |
3327 |
|
3328 | $post_ID = intval($args); |
3329 |
|
3330 | do_action('xmlrpc_call', 'mt.getTrackbackPings'); |
3331 |
|
3332 | $actual_post = wp_get_single_post($post_ID, ARRAY_A); |
3333 |
|
3334 | if ( !$actual_post ) |
3335 | return new IXR_Error(404, __('Sorry, no such post.')); |
3336 |
|
3337 | $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) ); |
3338 |
|
3339 | if ( !$comments ) |
Line | Code |
3368 | $this->escape($args); |
3369 |
|
3370 | $post_ID = (int) $args[0]; |
3371 | $username = $args[1]; |
3372 | $password = $args[2]; |
3373 |
|
3374 | if ( !$user = $this->login($username, $password) ) |
3375 | return $this->error; |
3376 |
|
3377 | do_action('xmlrpc_call', 'mt.publishPost'); |
3378 |
|
3379 | if ( !current_user_can('publish_posts') || !current_user_can('edit_post', $post_ID) ) |
3380 | return new IXR_Error(401, __('Sorry, you cannot publish this post.')); |
3381 |
|
3382 | $postdata = wp_get_single_post($post_ID,ARRAY_A); |
3383 |
|
3384 | $postdata['post_status'] = 'publish'; |
3385 |
|
3386 | // retain old cats |
Line | Code |
3402 | * |
3403 | * @since 1.5.0 |
3404 | * |
3405 | * @param array $args Method parameters. |
3406 | * @return array |
3407 | */ |
3408 | function pingback_ping($args) { |
3409 | global $wpdb; |
3410 |
|
3411 | do_action('xmlrpc_call', 'pingback.ping'); |
3412 |
|
3413 | $this->escape($args); |
3414 |
|
3415 | $pagelinkedfrom = $args[0]; |
3416 | $pagelinkedto = $args[1]; |
3417 |
|
3418 | $title = ''; |
3419 |
|
3420 | $pagelinkedfrom = str_replace('&', '&', $pagelinkedfrom); |
Line | Code |
3573 | * @since 1.5.0 |
3574 | * |
3575 | * @param array $args Method parameters. |
3576 | * @return array |
3577 | */ |
3578 | function pingback_extensions_getPingbacks($args) { |
3579 |
|
3580 | global $wpdb; |
3581 |
|
3582 | do_action('xmlrpc_call', 'pingback.extensions.getPingbacks'); |
3583 |
|
3584 | $this->escape($args); |
3585 |
|
3586 | $url = $args; |
3587 |
|
3588 | $post_ID = url_to_postid($url); |
3589 | if ( !$post_ID ) { |
3590 | // We aren't sure that the resource is available and/or pingback enabled |
3591 | 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.')); |