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 |
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 ( ! get_comment($comment_ID) ) |
1138 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
1139 |
|
1140 | if ( !current_user_can( 'edit_comment', $comment_ID ) ) |
1141 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
1142 |
|
1143 | do_action('xmlrpc_call', 'wp.deleteComment'); |
1144 |
|
1145 | return wp_delete_comment($comment_ID); |
1146 | } |
1147 |
|
1148 | /** |
1149 | * Edit comment. |
1150 | * |
1151 | * Besides the common blog_id, username, and password arguments, it takes a |
1152 | * comment_id integer and a content_struct array as last argument. |
Line | Code |
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 ( ! get_comment($comment_ID) ) |
1188 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
1189 |
|
1190 | if ( !current_user_can( 'edit_comment', $comment_ID ) ) |
1191 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
1192 |
|
1193 | do_action('xmlrpc_call', 'wp.editComment'); |
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) ) |
1200 | return new IXR_Error( 401, __( 'Invalid comment status.' ) ); |
1201 | $comment_approved = $content_struct['status']; |
1202 | } |
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 |
2488 | $post_ID = (int) $args[0]; |
2489 | $username = $args[1]; |
2490 | $password = $args[2]; |
2491 | $content_struct = $args[3]; |
2492 | $publish = $args[4]; |
2493 |
|
2494 | if ( !$user = $this->login($username, $password) ) |
2495 | return $this->error; |
2496 |
|
2497 | do_action('xmlrpc_call', 'metaWeblog.editPost'); |
2498 |
|
2499 | $cap = ( $publish ) ? 'publish_posts' : 'edit_posts'; |
2500 | $error_message = __( 'Sorry, you are not allowed to publish posts on this site.' ); |
2501 | $post_type = 'post'; |
2502 | $page_template = ''; |
2503 | if ( !empty( $content_struct['post_type'] ) ) { |
2504 | if ( $content_struct['post_type'] == 'page' ) { |
2505 | if ( $publish || 'publish' == $content_struct['page_status'] ) |
2506 | $cap = 'publish_pages'; |
Line | Code |
2764 | $username = $args[1]; |
2765 | $password = $args[2]; |
2766 |
|
2767 | if ( !$user = $this->login($username, $password) ) |
2768 | return $this->error; |
2769 |
|
2770 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
2771 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); |
2772 |
|
2773 | do_action('xmlrpc_call', 'metaWeblog.getPost'); |
2774 |
|
2775 | $postdata = wp_get_single_post($post_ID, ARRAY_A); |
2776 |
|
2777 | if ($postdata['post_date'] != '') { |
2778 | $post_date = mysql2date('Ymd\TH:i:s', $postdata['post_date'], false); |
2779 | $post_date_gmt = mysql2date('Ymd\TH:i:s', $postdata['post_date_gmt'], false); |
2780 |
|
2781 | // For drafts use the GMT version of the post date |
2782 | if ( $postdata['post_status'] == 'draft' ) |
Line | Code |
2884 | $password = $args[2]; |
2885 | if ( isset( $args[3] ) ) |
2886 | $query = array( 'numberposts' => absint( $args[3] ) ); |
2887 | else |
2888 | $query = array(); |
2889 |
|
2890 | if ( !$user = $this->login($username, $password) ) |
2891 | return $this->error; |
2892 |
|
2893 | do_action('xmlrpc_call', 'metaWeblog.getRecentPosts'); |
2894 |
|
2895 | $posts_list = wp_get_recent_posts( $query ); |
2896 |
|
2897 | if ( !$posts_list ) |
2898 | return array( ); |
2899 |
|
2900 | foreach ($posts_list as $entry) { |
2901 | if ( !current_user_can( 'edit_post', $entry['ID'] ) ) |
2902 | continue; |
Line | Code |
2994 | $username = $args[1]; |
2995 | $password = $args[2]; |
2996 |
|
2997 | if ( !$user = $this->login($username, $password) ) |
2998 | return $this->error; |
2999 |
|
3000 | if ( !current_user_can( 'edit_posts' ) ) |
3001 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
3002 |
|
3003 | do_action('xmlrpc_call', 'metaWeblog.getCategories'); |
3004 |
|
3005 | $categories_struct = array(); |
3006 |
|
3007 | if ( $cats = get_categories(array('get' => 'all')) ) { |
3008 | foreach ( $cats as $cat ) { |
3009 | $struct['categoryId'] = $cat->term_id; |
3010 | $struct['parentId'] = $cat->parent; |
3011 | $struct['description'] = $cat->name; |
3012 | $struct['categoryDescription'] = $cat->description; |
Line | Code |
3044 | $name = sanitize_file_name( $data['name'] ); |
3045 | $type = $data['type']; |
3046 | $bits = $data['bits']; |
3047 |
|
3048 | logIO('O', '(MW) Received '.strlen($bits).' bytes'); |
3049 |
|
3050 | if ( !$user = $this->login($username, $password) ) |
3051 | return $this->error; |
3052 |
|
3053 | do_action('xmlrpc_call', 'metaWeblog.newMediaObject'); |
3054 |
|
3055 | if ( !current_user_can('upload_files') ) { |
3056 | logIO('O', '(MW) User does not have upload_files capability'); |
3057 | $this->error = new IXR_Error(401, __('You are not allowed to upload files to this site.')); |
3058 | return $this->error; |
3059 | } |
3060 |
|
3061 | if ( $upload_err = apply_filters( 'pre_upload_error', false ) ) |
3062 | return new IXR_Error(500, $upload_err); |
Line | Code |
3125 | $password = $args[2]; |
3126 | if ( isset( $args[3] ) ) |
3127 | $query = array( 'numberposts' => absint( $args[3] ) ); |
3128 | else |
3129 | $query = array(); |
3130 |
|
3131 | if ( !$user = $this->login($username, $password) ) |
3132 | return $this->error; |
3133 |
|
3134 | do_action('xmlrpc_call', 'mt.getRecentPostTitles'); |
3135 |
|
3136 | $posts_list = wp_get_recent_posts( $query ); |
3137 |
|
3138 | if ( !$posts_list ) { |
3139 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
3140 | return $this->error; |
3141 | } |
3142 |
|
3143 | foreach ($posts_list as $entry) { |
Line | Code |
3186 | $username = $args[1]; |
3187 | $password = $args[2]; |
3188 |
|
3189 | if ( !$user = $this->login($username, $password) ) |
3190 | return $this->error; |
3191 |
|
3192 | if ( !current_user_can( 'edit_posts' ) ) |
3193 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
3194 |
|
3195 | do_action('xmlrpc_call', 'mt.getCategoryList'); |
3196 |
|
3197 | $categories_struct = array(); |
3198 |
|
3199 | if ( $cats = get_categories(array('hide_empty' => 0, 'hierarchical' => 0)) ) { |
3200 | foreach ( $cats as $cat ) { |
3201 | $struct['categoryId'] = $cat->term_id; |
3202 | $struct['categoryName'] = $cat->name; |
3203 |
|
3204 | $categories_struct[] = $struct; |
Line | Code |
3224 | $username = $args[1]; |
3225 | $password = $args[2]; |
3226 |
|
3227 | if ( !$user = $this->login($username, $password) ) |
3228 | return $this->error; |
3229 |
|
3230 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
3231 | return new IXR_Error( 401, __( 'Sorry, you can not edit this post.' ) ); |
3232 |
|
3233 | do_action('xmlrpc_call', 'mt.getPostCategories'); |
3234 |
|
3235 | $categories = array(); |
3236 | $catids = wp_get_post_categories(intval($post_ID)); |
3237 | // first listed category will be the primary category |
3238 | $isPrimary = true; |
3239 | foreach ( $catids as $catid ) { |
3240 | $categories[] = array( |
3241 | 'categoryName' => get_cat_name($catid), |
3242 | 'categoryId' => (string) $catid, |
Line | Code |
3262 |
|
3263 | $post_ID = (int) $args[0]; |
3264 | $username = $args[1]; |
3265 | $password = $args[2]; |
3266 | $categories = $args[3]; |
3267 |
|
3268 | if ( !$user = $this->login($username, $password) ) |
3269 | return $this->error; |
3270 |
|
3271 | do_action('xmlrpc_call', 'mt.setPostCategories'); |
3272 |
|
3273 | if ( !current_user_can('edit_post', $post_ID) ) |
3274 | return new IXR_Error(401, __('Sorry, you cannot edit this post.')); |
3275 |
|
3276 | foreach ( $categories as $cat ) { |
3277 | $catids[] = $cat['categoryId']; |
3278 | } |
3279 |
|
3280 | wp_set_post_categories($post_ID, $catids); |
Line | Code |
3286 | * Retrieve an array of methods supported by this server. |
3287 | * |
3288 | * @since 1.5.0 |
3289 | * |
3290 | * @param array $args Method parameters. |
3291 | * @return array |
3292 | */ |
3293 | function mt_supportedMethods($args) { |
3294 |
|
3295 | do_action('xmlrpc_call', 'mt.supportedMethods'); |
3296 |
|
3297 | $supported_methods = array(); |
3298 | foreach ( $this->methods as $key => $value ) { |
3299 | $supported_methods[] = $key; |
3300 | } |
3301 |
|
3302 | return $supported_methods; |
3303 | } |
3304 |
|
3305 | /** |
3306 | * Retrieve an empty array because we don't support per-post text filters. |
3307 | * |
3308 | * @since 1.5.0 |
3309 | * |
3310 | * @param array $args Method parameters. |
3311 | */ |
3312 | function mt_supportedTextFilters($args) { |
3313 | do_action('xmlrpc_call', 'mt.supportedTextFilters'); |
3314 | return apply_filters('xmlrpc_text_filters', array()); |
3315 | } |
3316 |
|
3317 | /** |
3318 | * Retrieve trackbacks sent to a given post. |
3319 | * |
3320 | * @since 1.5.0 |
3321 | * |
3322 | * @param array $args Method parameters. |
3323 | * @return mixed |
3324 | */ |
3325 | function mt_getTrackbackPings($args) { |
3326 |
|
3327 | global $wpdb; |
3328 |
|
3329 | $post_ID = intval($args); |
3330 |
|
3331 | do_action('xmlrpc_call', 'mt.getTrackbackPings'); |
3332 |
|
3333 | $actual_post = wp_get_single_post($post_ID, ARRAY_A); |
3334 |
|
3335 | if ( !$actual_post ) |
3336 | return new IXR_Error(404, __('Sorry, no such post.')); |
3337 |
|
3338 | $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) ); |
3339 |
|
3340 | if ( !$comments ) |
Line | Code |
3369 | $this->escape($args); |
3370 |
|
3371 | $post_ID = (int) $args[0]; |
3372 | $username = $args[1]; |
3373 | $password = $args[2]; |
3374 |
|
3375 | if ( !$user = $this->login($username, $password) ) |
3376 | return $this->error; |
3377 |
|
3378 | do_action('xmlrpc_call', 'mt.publishPost'); |
3379 |
|
3380 | if ( !current_user_can('publish_posts') || !current_user_can('edit_post', $post_ID) ) |
3381 | return new IXR_Error(401, __('Sorry, you cannot publish this post.')); |
3382 |
|
3383 | $postdata = wp_get_single_post($post_ID,ARRAY_A); |
3384 |
|
3385 | $postdata['post_status'] = 'publish'; |
3386 |
|
3387 | // retain old cats |
Line | Code |
3403 | * |
3404 | * @since 1.5.0 |
3405 | * |
3406 | * @param array $args Method parameters. |
3407 | * @return array |
3408 | */ |
3409 | function pingback_ping($args) { |
3410 | global $wpdb; |
3411 |
|
3412 | do_action('xmlrpc_call', 'pingback.ping'); |
3413 |
|
3414 | $this->escape($args); |
3415 |
|
3416 | $pagelinkedfrom = $args[0]; |
3417 | $pagelinkedto = $args[1]; |
3418 |
|
3419 | $title = ''; |
3420 |
|
3421 | $pagelinkedfrom = str_replace('&', '&', $pagelinkedfrom); |
Line | Code |
3574 | * @since 1.5.0 |
3575 | * |
3576 | * @param array $args Method parameters. |
3577 | * @return array |
3578 | */ |
3579 | function pingback_extensions_getPingbacks($args) { |
3580 |
|
3581 | global $wpdb; |
3582 |
|
3583 | do_action('xmlrpc_call', 'pingback.extensions.getPingbacks'); |
3584 |
|
3585 | $this->escape($args); |
3586 |
|
3587 | $url = $args; |
3588 |
|
3589 | $post_ID = url_to_postid($url); |
3590 | if ( !$post_ID ) { |
3591 | // We aren't sure that the resource is available and/or pingback enabled |
3592 | 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.')); |