WP hooks navigation: Home/browse • Actions index • Filters index
To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).
The best way to understand what a hook does is to look at where it occurs in the source code.
do_action( "hook_name" )apply_filters( "hook_name", "what_to_filter" ).Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.
This hook occurs 46 times in this file.
| Line | Code |
|---|---|
| 443 | $this->escape( $args ); |
| 444 | |
| 445 | $username = $args[0]; |
| 446 | $password = $args[1]; |
| 447 | |
| 448 | if ( !$user = $this->login($username, $password) ) { |
| 449 | return $this->error; |
| 450 | } |
| 451 | |
| 452 | do_action( 'xmlrpc_call', 'wp.getUsersBlogs' ); |
| 453 | |
| 454 | $blogs = (array) get_blogs_of_user( $user->ID ); |
| 455 | $struct = array( ); |
| 456 | |
| 457 | foreach( $blogs as $blog ) { |
| 458 | // Don't include blogs that aren't hosted at this site |
| 459 | if( $blog->site_id != $current_site->id ) |
| 460 | continue; |
| 461 | |
| Line | Code |
| 494 | $password = $args[3]; |
| 495 | |
| 496 | if ( !$user = $this->login($username, $password) ) { |
| 497 | return $this->error; |
| 498 | } |
| 499 | |
| 500 | if( !current_user_can( 'edit_page', $page_id ) ) |
| 501 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this page.' ) ); |
| 502 | |
| 503 | do_action('xmlrpc_call', 'wp.getPage'); |
| 504 | |
| 505 | // Lookup page info. |
| 506 | $page = get_page($page_id); |
| 507 | |
| 508 | // If we found the page then format the data. |
| 509 | if($page->ID && ($page->post_type == "page")) { |
| 510 | // Get all of the page content and link. |
| 511 | $full_page = get_extended($page->post_content); |
| 512 | $link = post_permalink($page->ID); |
| Line | Code |
| 591 | $num_pages = (int) $args[3]; |
| 592 | |
| 593 | if ( !$user = $this->login($username, $password) ) { |
| 594 | return $this->error; |
| 595 | } |
| 596 | |
| 597 | if( !current_user_can( 'edit_pages' ) ) |
| 598 | return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) ); |
| 599 | |
| 600 | do_action('xmlrpc_call', 'wp.getPages'); |
| 601 | |
| 602 | $page_limit = 10; |
| 603 | if( isset( $num_pages ) ) { |
| 604 | $page_limit = $num_pages; |
| 605 | } |
| 606 | |
| 607 | $pages = get_posts( array('post_type' => 'page', 'post_status' => 'all', 'numberposts' => $page_limit) ); |
| 608 | $num_pages = count($pages); |
| 609 | |
| Line | Code |
| 639 | $username = $this->escape($args[1]); |
| 640 | $password = $this->escape($args[2]); |
| 641 | $page = $args[3]; |
| 642 | $publish = $args[4]; |
| 643 | |
| 644 | if ( !$user = $this->login($username, $password) ) { |
| 645 | return $this->error; |
| 646 | } |
| 647 | |
| 648 | do_action('xmlrpc_call', 'wp.newPage'); |
| 649 | |
| 650 | // Make sure the user is allowed to add new pages. |
| 651 | if(!current_user_can("publish_pages")) { |
| 652 | return(new IXR_Error(401, __("Sorry, you cannot add new pages."))); |
| 653 | } |
| 654 | |
| 655 | // Mark this as content for a page. |
| 656 | $args[3]["post_type"] = "page"; |
| 657 | |
| Line | Code |
| 673 | $blog_id = (int) $args[0]; |
| 674 | $username = $args[1]; |
| 675 | $password = $args[2]; |
| 676 | $page_id = (int) $args[3]; |
| 677 | |
| 678 | if ( !$user = $this->login($username, $password) ) { |
| 679 | return $this->error; |
| 680 | } |
| 681 | |
| 682 | do_action('xmlrpc_call', 'wp.deletePage'); |
| 683 | |
| 684 | // Get the current page based on the page_id and |
| 685 | // make sure it is a page and not a post. |
| 686 | $actual_page = wp_get_single_post($page_id, ARRAY_A); |
| 687 | if( |
| 688 | !$actual_page |
| 689 | || ($actual_page["post_type"] != "page") |
| 690 | ) { |
| 691 | return(new IXR_Error(404, __("Sorry, no such page."))); |
| Line | Code |
| 720 | $username = $this->escape($args[2]); |
| 721 | $password = $this->escape($args[3]); |
| 722 | $content = $args[4]; |
| 723 | $publish = $args[5]; |
| 724 | |
| 725 | if ( !$user = $this->login($username, $password) ) { |
| 726 | return $this->error; |
| 727 | } |
| 728 | |
| 729 | do_action('xmlrpc_call', 'wp.editPage'); |
| 730 | |
| 731 | // Get the page data and make sure it is a page. |
| 732 | $actual_page = wp_get_single_post($page_id, ARRAY_A); |
| 733 | if( |
| 734 | !$actual_page |
| 735 | || ($actual_page["post_type"] != "page") |
| 736 | ) { |
| 737 | return(new IXR_Error(404, __("Sorry, no such page."))); |
| 738 | } |
| Line | Code |
| 776 | $password = $args[2]; |
| 777 | |
| 778 | if ( !$user = $this->login($username, $password) ) { |
| 779 | return $this->error; |
| 780 | } |
| 781 | |
| 782 | if( !current_user_can( 'edit_pages' ) ) |
| 783 | return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) ); |
| 784 | |
| 785 | do_action('xmlrpc_call', 'wp.getPageList'); |
| 786 | |
| 787 | // Get list of pages ids and titles |
| 788 | $page_list = $wpdb->get_results(" |
| 789 | SELECT ID page_id, |
| 790 | post_title page_title, |
| 791 | post_parent page_parent_id, |
| 792 | post_date_gmt, |
| 793 | post_date |
| 794 | FROM {$wpdb->posts} |
| Line | Code |
| 830 | |
| 831 | if ( !$user = $this->login($username, $password) ) { |
| 832 | return $this->error; |
| 833 | } |
| 834 | |
| 835 | if(!current_user_can("edit_posts")) { |
| 836 | return(new IXR_Error(401, __("Sorry, you cannot edit posts on this blog."))); |
| 837 | } |
| 838 | |
| 839 | do_action('xmlrpc_call', 'wp.getAuthors'); |
| 840 | |
| 841 | $authors = array(); |
| 842 | foreach( (array) get_users_of_blog() as $row ) { |
| 843 | $authors[] = array( |
| 844 | "user_id" => $row->user_id, |
| 845 | "user_login" => $row->user_login, |
| 846 | "display_name" => $row->display_name |
| 847 | ); |
| 848 | } |
| Line | Code |
| 867 | |
| 868 | if ( !$user = $this->login($username, $password) ) { |
| 869 | return $this->error; |
| 870 | } |
| 871 | |
| 872 | if( !current_user_can( 'edit_posts' ) ) { |
| 873 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this blog in order to view tags.' ) ); |
| 874 | } |
| 875 | |
| 876 | do_action( 'xmlrpc_call', 'wp.getKeywords' ); |
| 877 | |
| 878 | $tags = array( ); |
| 879 | |
| 880 | if( $all_tags = get_tags( ) ) { |
| 881 | foreach( (array) $all_tags as $tag ) { |
| 882 | $struct['tag_id'] = $tag->term_id; |
| 883 | $struct['name'] = $tag->name; |
| 884 | $struct['count'] = $tag->count; |
| 885 | $struct['slug'] = $tag->slug; |
| Line | Code |
| 907 | $blog_id = (int) $args[0]; |
| 908 | $username = $args[1]; |
| 909 | $password = $args[2]; |
| 910 | $category = $args[3]; |
| 911 | |
| 912 | if ( !$user = $this->login($username, $password) ) { |
| 913 | return $this->error; |
| 914 | } |
| 915 | |
| 916 | do_action('xmlrpc_call', 'wp.newCategory'); |
| 917 | |
| 918 | // Make sure the user is allowed to add a category. |
| 919 | if(!current_user_can("manage_categories")) { |
| 920 | return(new IXR_Error(401, __("Sorry, you do not have the right to add a category."))); |
| 921 | } |
| 922 | |
| 923 | // If no slug was provided make it empty so that |
| 924 | // WordPress will generate one. |
| 925 | if(empty($category["slug"])) { |
| Line | Code |
| 965 | $blog_id = (int) $args[0]; |
| 966 | $username = $args[1]; |
| 967 | $password = $args[2]; |
| 968 | $category_id = (int) $args[3]; |
| 969 | |
| 970 | if ( !$user = $this->login($username, $password) ) { |
| 971 | return $this->error; |
| 972 | } |
| 973 | |
| 974 | do_action('xmlrpc_call', 'wp.deleteCategory'); |
| 975 | |
| 976 | if( !current_user_can("manage_categories") ) { |
| 977 | return new IXR_Error( 401, __( "Sorry, you do not have the right to delete a category." ) ); |
| 978 | } |
| 979 | |
| 980 | return wp_delete_category( $category_id ); |
| 981 | } |
| 982 | |
| 983 | /** |
| Line | Code |
| 998 | $max_results = (int) $args[4]; |
| 999 | |
| 1000 | if ( !$user = $this->login($username, $password) ) { |
| 1001 | return $this->error; |
| 1002 | } |
| 1003 | |
| 1004 | if( !current_user_can( 'edit_posts' ) ) |
| 1005 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts to this blog in order to view categories.' ) ); |
| 1006 | |
| 1007 | do_action('xmlrpc_call', 'wp.suggestCategories'); |
| 1008 | |
| 1009 | $category_suggestions = array(); |
| 1010 | $args = array('get' => 'all', 'number' => $max_results, 'name__like' => $category); |
| 1011 | foreach ( (array) get_categories($args) as $cat ) { |
| 1012 | $category_suggestions[] = array( |
| 1013 | "category_id" => $cat->cat_ID, |
| 1014 | "category_name" => $cat->cat_name |
| 1015 | ); |
| 1016 | } |
| Line | Code |
| 1035 | $comment_id = (int) $args[3]; |
| 1036 | |
| 1037 | if ( !$user = $this->login($username, $password) ) { |
| 1038 | return $this->error; |
| 1039 | } |
| 1040 | |
| 1041 | if ( !current_user_can( 'moderate_comments' ) ) |
| 1042 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this blog.' ) ); |
| 1043 | |
| 1044 | do_action('xmlrpc_call', 'wp.getComment'); |
| 1045 | |
| 1046 | if ( ! $comment = get_comment($comment_id) ) |
| 1047 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 1048 | |
| 1049 | // Format page date. |
| 1050 | $comment_date = mysql2date("Ymd\TH:i:s", $comment->comment_date, false); |
| 1051 | $comment_date_gmt = mysql2date("Ymd\TH:i:s", $comment->comment_date_gmt, false); |
| 1052 | |
| 1053 | if ( 0 == $comment->comment_approved ) |
| Line | Code |
| 1098 | $struct = $args[3]; |
| 1099 | |
| 1100 | if ( !$user = $this->login($username, $password) ) { |
| 1101 | return $this->error; |
| 1102 | } |
| 1103 | |
| 1104 | if ( !current_user_can( 'moderate_comments' ) ) |
| 1105 | return new IXR_Error( 401, __( 'Sorry, you cannot edit comments.' ) ); |
| 1106 | |
| 1107 | do_action('xmlrpc_call', 'wp.getComments'); |
| 1108 | |
| 1109 | if ( isset($struct['status']) ) |
| 1110 | $status = $struct['status']; |
| 1111 | else |
| 1112 | $status = ''; |
| 1113 | |
| 1114 | $post_id = ''; |
| 1115 | if ( isset($struct['post_id']) ) |
| 1116 | $post_id = absint($struct['post_id']); |
| Line | Code |
| 1158 | $comment_ID = (int) $args[3]; |
| 1159 | |
| 1160 | if ( !$user = $this->login($username, $password) ) { |
| 1161 | return $this->error; |
| 1162 | } |
| 1163 | |
| 1164 | if ( !current_user_can( 'moderate_comments' ) ) |
| 1165 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this blog.' ) ); |
| 1166 | |
| 1167 | do_action('xmlrpc_call', 'wp.deleteComment'); |
| 1168 | |
| 1169 | if ( ! get_comment($comment_ID) ) |
| 1170 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 1171 | |
| 1172 | return wp_delete_comment($comment_ID); |
| 1173 | } |
| 1174 | |
| 1175 | /** |
| 1176 | * Edit comment. |
| Line | Code |
| 1190 | $content_struct = $args[4]; |
| 1191 | |
| 1192 | if ( !$user = $this->login($username, $password) ) { |
| 1193 | return $this->error; |
| 1194 | } |
| 1195 | |
| 1196 | if ( !current_user_can( 'moderate_comments' ) ) |
| 1197 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this blog.' ) ); |
| 1198 | |
| 1199 | do_action('xmlrpc_call', 'wp.editComment'); |
| 1200 | |
| 1201 | if ( ! get_comment($comment_ID) ) |
| 1202 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 1203 | |
| 1204 | if ( isset($content_struct['status']) ) { |
| 1205 | $statuses = get_comment_statuses(); |
| 1206 | $statuses = array_keys($statuses); |
| 1207 | |
| 1208 | if ( ! in_array($content_struct['status'], $statuses) ) |
| Line | Code |
| 1314 | elseif ( !is_email($comment['comment_author_email']) ) |
| 1315 | return new IXR_Error( 403, __( 'A valid email address is required' ) ); |
| 1316 | } |
| 1317 | } |
| 1318 | |
| 1319 | $comment['comment_parent'] = isset($content_struct['comment_parent']) ? absint($content_struct['comment_parent']) : 0; |
| 1320 | |
| 1321 | $comment['comment_content'] = $content_struct['content']; |
| 1322 | |
| 1323 | do_action('xmlrpc_call', 'wp.newComment'); |
| 1324 | |
| 1325 | return wp_new_comment($comment); |
| 1326 | } |
| 1327 | |
| 1328 | /** |
| 1329 | * Retrieve all of the comment status. |
| 1330 | * |
| 1331 | * @since 2.7.0 |
| 1332 | * |
| Line | Code |
| 1341 | $password = $args[2]; |
| 1342 | |
| 1343 | if ( !$user = $this->login($username, $password) ) { |
| 1344 | return $this->error; |
| 1345 | } |
| 1346 | |
| 1347 | if ( !current_user_can( 'moderate_comments' ) ) |
| 1348 | return new IXR_Error( 403, __( 'You are not allowed access to details about this blog.' ) ); |
| 1349 | |
| 1350 | do_action('xmlrpc_call', 'wp.getCommentStatusList'); |
| 1351 | |
| 1352 | return get_comment_statuses( ); |
| 1353 | } |
| 1354 | |
| 1355 | /** |
| 1356 | * Retrieve comment count. |
| 1357 | * |
| 1358 | * @since 2.5.0 |
| 1359 | * |
| Line | Code |
| 1370 | |
| 1371 | if ( !$user = $this->login($username, $password) ) { |
| 1372 | return $this->error; |
| 1373 | } |
| 1374 | |
| 1375 | if( !current_user_can( 'edit_posts' ) ) { |
| 1376 | return new IXR_Error( 403, __( 'You are not allowed access to details about comments.' ) ); |
| 1377 | } |
| 1378 | |
| 1379 | do_action('xmlrpc_call', 'wp.getCommentCount'); |
| 1380 | |
| 1381 | $count = wp_count_comments( $post_id ); |
| 1382 | return array( |
| 1383 | "approved" => $count->approved, |
| 1384 | "awaiting_moderation" => $count->moderated, |
| 1385 | "spam" => $count->spam, |
| 1386 | "total_comments" => $count->total_comments |
| 1387 | ); |
| 1388 | } |
| Line | Code |
| 1404 | |
| 1405 | if ( !$user = $this->login($username, $password) ) { |
| 1406 | return $this->error; |
| 1407 | } |
| 1408 | |
| 1409 | if( !current_user_can( 'edit_posts' ) ) { |
| 1410 | return new IXR_Error( 403, __( 'You are not allowed access to details about this blog.' ) ); |
| 1411 | } |
| 1412 | |
| 1413 | do_action('xmlrpc_call', 'wp.getPostStatusList'); |
| 1414 | |
| 1415 | return get_post_statuses( ); |
| 1416 | } |
| 1417 | |
| 1418 | /** |
| 1419 | * Retrieve page statuses. |
| 1420 | * |
| 1421 | * @since 2.5.0 |
| 1422 | * |
| Line | Code |
| 1432 | |
| 1433 | if ( !$user = $this->login($username, $password) ) { |
| 1434 | return $this->error; |
| 1435 | } |
| 1436 | |
| 1437 | if( !current_user_can( 'edit_posts' ) ) { |
| 1438 | return new IXR_Error( 403, __( 'You are not allowed access to details about this blog.' ) ); |
| 1439 | } |
| 1440 | |
| 1441 | do_action('xmlrpc_call', 'wp.getPageStatusList'); |
| 1442 | |
| 1443 | return get_page_statuses( ); |
| 1444 | } |
| 1445 | |
| 1446 | /** |
| 1447 | * Retrieve page templates. |
| 1448 | * |
| 1449 | * @since 2.6.0 |
| 1450 | * |
| Line | Code |
| 1586 | $this->escape($args); |
| 1587 | |
| 1588 | $username = $args[1]; |
| 1589 | $password = $args[2]; |
| 1590 | |
| 1591 | if ( !$user = $this->login($username, $password) ) { |
| 1592 | return $this->error; |
| 1593 | } |
| 1594 | |
| 1595 | do_action('xmlrpc_call', 'blogger.getUsersBlogs'); |
| 1596 | |
| 1597 | $is_admin = current_user_can('manage_options'); |
| 1598 | |
| 1599 | $struct = array( |
| 1600 | 'isAdmin' => $is_admin, |
| 1601 | 'url' => get_option('home') . '/', |
| 1602 | 'blogid' => '1', |
| 1603 | 'blogName' => get_option('blogname'), |
| 1604 | 'xmlrpc' => site_url( 'xmlrpc.php' ) |
| Line | Code |
| 1625 | $password = $args[2]; |
| 1626 | |
| 1627 | if ( !$user = $this->login($username, $password) ) { |
| 1628 | return $this->error; |
| 1629 | } |
| 1630 | |
| 1631 | if( !current_user_can( 'edit_posts' ) ) |
| 1632 | return new IXR_Error( 401, __( 'Sorry, you do not have access to user data on this blog.' ) ); |
| 1633 | |
| 1634 | do_action('xmlrpc_call', 'blogger.getUserInfo'); |
| 1635 | |
| 1636 | $struct = array( |
| 1637 | 'nickname' => $user->nickname, |
| 1638 | 'userid' => $user->ID, |
| 1639 | 'url' => $user->user_url, |
| 1640 | 'lastname' => $user->last_name, |
| 1641 | 'firstname' => $user->first_name |
| 1642 | ); |
| 1643 | |
| Line | Code |
| 1661 | $password = $args[3]; |
| 1662 | |
| 1663 | if ( !$user = $this->login($username, $password) ) { |
| 1664 | return $this->error; |
| 1665 | } |
| 1666 | |
| 1667 | if( !current_user_can( 'edit_post', $post_ID ) ) |
| 1668 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); |
| 1669 | |
| 1670 | do_action('xmlrpc_call', 'blogger.getPost'); |
| 1671 | |
| 1672 | $post_data = wp_get_single_post($post_ID, ARRAY_A); |
| 1673 | |
| 1674 | $categories = implode(',', wp_get_post_categories($post_ID)); |
| 1675 | |
| 1676 | $content = '<title>'.stripslashes($post_data['post_title']).'</title>'; |
| 1677 | $content .= '<category>'.$categories.'</category>'; |
| 1678 | $content .= stripslashes($post_data['post_content']); |
| 1679 | |
| Line | Code |
| 1702 | $blog_ID = (int) $args[1]; /* though we don't use it yet */ |
| 1703 | $username = $args[2]; |
| 1704 | $password = $args[3]; |
| 1705 | $num_posts = $args[4]; |
| 1706 | |
| 1707 | if ( !$user = $this->login($username, $password) ) { |
| 1708 | return $this->error; |
| 1709 | } |
| 1710 | |
| 1711 | do_action('xmlrpc_call', 'blogger.getRecentPosts'); |
| 1712 | |
| 1713 | $posts_list = wp_get_recent_posts($num_posts); |
| 1714 | |
| 1715 | if (!$posts_list) { |
| 1716 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
| 1717 | return $this->error; |
| 1718 | } |
| 1719 | |
| 1720 | foreach ($posts_list as $entry) { |
| Line | Code |
| 1760 | $blog_ID = (int) $args[1]; |
| 1761 | $username = $args[2]; |
| 1762 | $password = $args[3]; |
| 1763 | $template = $args[4]; /* could be 'main' or 'archiveIndex', but we don't use it */ |
| 1764 | |
| 1765 | if ( !$user = $this->login($username, $password) ) { |
| 1766 | return $this->error; |
| 1767 | } |
| 1768 | |
| 1769 | do_action('xmlrpc_call', 'blogger.getTemplate'); |
| 1770 | |
| 1771 | if ( !current_user_can('edit_themes') ) { |
| 1772 | return new IXR_Error(401, __('Sorry, this user can not edit the template.')); |
| 1773 | } |
| 1774 | |
| 1775 | /* warning: here we make the assumption that the blog's URL is on the same server */ |
| 1776 | $filename = get_option('home') . '/'; |
| 1777 | $filename = preg_replace('#https?://.+?/#', $_SERVER['DOCUMENT_ROOT'].'/', $filename); |
| 1778 | |
| Line | Code |
| 1802 | $username = $args[2]; |
| 1803 | $password = $args[3]; |
| 1804 | $content = $args[4]; |
| 1805 | $template = $args[5]; /* could be 'main' or 'archiveIndex', but we don't use it */ |
| 1806 | |
| 1807 | if ( !$user = $this->login($username, $password) ) { |
| 1808 | return $this->error; |
| 1809 | } |
| 1810 | |
| 1811 | do_action('xmlrpc_call', 'blogger.setTemplate'); |
| 1812 | |
| 1813 | if ( !current_user_can('edit_themes') ) { |
| 1814 | return new IXR_Error(401, __('Sorry, this user cannot edit the template.')); |
| 1815 | } |
| 1816 | |
| 1817 | /* warning: here we make the assumption that the blog's URL is on the same server */ |
| 1818 | $filename = get_option('home') . '/'; |
| 1819 | $filename = preg_replace('#https?://.+?/#', $_SERVER['DOCUMENT_ROOT'].'/', $filename); |
| 1820 | |
| Line | Code |
| 1844 | $username = $args[2]; |
| 1845 | $password = $args[3]; |
| 1846 | $content = $args[4]; |
| 1847 | $publish = $args[5]; |
| 1848 | |
| 1849 | if ( !$user = $this->login($username, $password) ) { |
| 1850 | return $this->error; |
| 1851 | } |
| 1852 | |
| 1853 | do_action('xmlrpc_call', 'blogger.newPost'); |
| 1854 | |
| 1855 | $cap = ($publish) ? 'publish_posts' : 'edit_posts'; |
| 1856 | if ( !current_user_can($cap) ) |
| 1857 | return new IXR_Error(401, __('Sorry, you are not allowed to post on this blog.')); |
| 1858 | |
| 1859 | $post_status = ($publish) ? 'publish' : 'draft'; |
| 1860 | |
| 1861 | $post_author = $user->ID; |
| 1862 | |
| Line | Code |
| 1899 | $username = $args[2]; |
| 1900 | $password = $args[3]; |
| 1901 | $content = $args[4]; |
| 1902 | $publish = $args[5]; |
| 1903 | |
| 1904 | if ( !$user = $this->login($username, $password) ) { |
| 1905 | return $this->error; |
| 1906 | } |
| 1907 | |
| 1908 | do_action('xmlrpc_call', 'blogger.editPost'); |
| 1909 | |
| 1910 | $actual_post = wp_get_single_post($post_ID,ARRAY_A); |
| 1911 | |
| 1912 | if (!$actual_post || $actual_post['post_type'] != 'post') { |
| 1913 | return new IXR_Error(404, __('Sorry, no such post.')); |
| 1914 | } |
| 1915 | |
| 1916 | $this->escape($actual_post); |
| 1917 | |
| Line | Code |
| 1953 | $post_ID = (int) $args[1]; |
| 1954 | $username = $args[2]; |
| 1955 | $password = $args[3]; |
| 1956 | $publish = $args[4]; |
| 1957 | |
| 1958 | if ( !$user = $this->login($username, $password) ) { |
| 1959 | return $this->error; |
| 1960 | } |
| 1961 | |
| 1962 | do_action('xmlrpc_call', 'blogger.deletePost'); |
| 1963 | |
| 1964 | $actual_post = wp_get_single_post($post_ID,ARRAY_A); |
| 1965 | |
| 1966 | if (!$actual_post || $actual_post['post_type'] != 'post') { |
| 1967 | return new IXR_Error(404, __('Sorry, no such post.')); |
| 1968 | } |
| 1969 | |
| 1970 | if ( !current_user_can('edit_post', $post_ID) ) |
| 1971 | return new IXR_Error(401, __('Sorry, you do not have the right to delete this post.')); |
| Line | Code |
| 1998 | $username = $args[1]; |
| 1999 | $password = $args[2]; |
| 2000 | $content_struct = $args[3]; |
| 2001 | $publish = $args[4]; |
| 2002 | |
| 2003 | if ( !$user = $this->login($username, $password) ) { |
| 2004 | return $this->error; |
| 2005 | } |
| 2006 | |
| 2007 | do_action('xmlrpc_call', 'metaWeblog.newPost'); |
| 2008 | |
| 2009 | $cap = ( $publish ) ? 'publish_posts' : 'edit_posts'; |
| 2010 | $error_message = __( 'Sorry, you are not allowed to publish posts on this blog.' ); |
| 2011 | $post_type = 'post'; |
| 2012 | $page_template = ''; |
| 2013 | if( !empty( $content_struct['post_type'] ) ) { |
| 2014 | if( $content_struct['post_type'] == 'page' ) { |
| 2015 | $cap = ( $publish ) ? 'publish_pages' : 'edit_pages'; |
| 2016 | $error_message = __( 'Sorry, you are not allowed to publish pages on this blog.' ); |
| Line | Code |
| 2295 | $username = $args[1]; |
| 2296 | $password = $args[2]; |
| 2297 | $content_struct = $args[3]; |
| 2298 | $publish = $args[4]; |
| 2299 | |
| 2300 | if ( !$user = $this->login($username, $password) ) { |
| 2301 | return $this->error; |
| 2302 | } |
| 2303 | |
| 2304 | do_action('xmlrpc_call', 'metaWeblog.editPost'); |
| 2305 | |
| 2306 | $cap = ( $publish ) ? 'publish_posts' : 'edit_posts'; |
| 2307 | $error_message = __( 'Sorry, you are not allowed to publish posts on this blog.' ); |
| 2308 | $post_type = 'post'; |
| 2309 | $page_template = ''; |
| 2310 | if( !empty( $content_struct['post_type'] ) ) { |
| 2311 | if( $content_struct['post_type'] == 'page' ) { |
| 2312 | $cap = ( $publish ) ? 'publish_pages' : 'edit_pages'; |
| 2313 | $error_message = __( 'Sorry, you are not allowed to publish pages on this blog.' ); |
| Line | Code |
| 2560 | $password = $args[2]; |
| 2561 | |
| 2562 | if ( !$user = $this->login($username, $password) ) { |
| 2563 | return $this->error; |
| 2564 | } |
| 2565 | |
| 2566 | if( !current_user_can( 'edit_post', $post_ID ) ) |
| 2567 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); |
| 2568 | |
| 2569 | do_action('xmlrpc_call', 'metaWeblog.getPost'); |
| 2570 | |
| 2571 | $postdata = wp_get_single_post($post_ID, ARRAY_A); |
| 2572 | |
| 2573 | if ($postdata['post_date'] != '') { |
| 2574 | $post_date = mysql2date('Ymd\TH:i:s', $postdata['post_date'], false); |
| 2575 | $post_date_gmt = mysql2date('Ymd\TH:i:s', $postdata['post_date_gmt'], false); |
| 2576 | |
| 2577 | $categories = array(); |
| 2578 | $catids = wp_get_post_categories($post_ID); |
| Line | Code |
| 2669 | $blog_ID = (int) $args[0]; |
| 2670 | $username = $args[1]; |
| 2671 | $password = $args[2]; |
| 2672 | $num_posts = (int) $args[3]; |
| 2673 | |
| 2674 | if ( !$user = $this->login($username, $password) ) { |
| 2675 | return $this->error; |
| 2676 | } |
| 2677 | |
| 2678 | do_action('xmlrpc_call', 'metaWeblog.getRecentPosts'); |
| 2679 | |
| 2680 | $posts_list = wp_get_recent_posts($num_posts); |
| 2681 | |
| 2682 | if (!$posts_list) { |
| 2683 | return array( ); |
| 2684 | } |
| 2685 | |
| 2686 | foreach ($posts_list as $entry) { |
| 2687 | if( !current_user_can( 'edit_post', $entry['ID'] ) ) |
| Line | Code |
| 2773 | $password = $args[2]; |
| 2774 | |
| 2775 | if ( !$user = $this->login($username, $password) ) { |
| 2776 | return $this->error; |
| 2777 | } |
| 2778 | |
| 2779 | if( !current_user_can( 'edit_posts' ) ) |
| 2780 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this blog in order to view categories.' ) ); |
| 2781 | |
| 2782 | do_action('xmlrpc_call', 'metaWeblog.getCategories'); |
| 2783 | |
| 2784 | $categories_struct = array(); |
| 2785 | |
| 2786 | if ( $cats = get_categories('get=all') ) { |
| 2787 | foreach ( $cats as $cat ) { |
| 2788 | $struct['categoryId'] = $cat->term_id; |
| 2789 | $struct['parentId'] = $cat->parent; |
| 2790 | $struct['description'] = $cat->name; |
| 2791 | $struct['categoryDescription'] = $cat->description; |
| Line | Code |
| 2824 | $type = $data['type']; |
| 2825 | $bits = $data['bits']; |
| 2826 | |
| 2827 | logIO('O', '(MW) Received '.strlen($bits).' bytes'); |
| 2828 | |
| 2829 | if ( !$user = $this->login($username, $password) ) { |
| 2830 | return $this->error; |
| 2831 | } |
| 2832 | |
| 2833 | do_action('xmlrpc_call', 'metaWeblog.newMediaObject'); |
| 2834 | |
| 2835 | if ( !current_user_can('upload_files') ) { |
| 2836 | logIO('O', '(MW) User does not have upload_files capability'); |
| 2837 | $this->error = new IXR_Error(401, __('You are not allowed to upload files to this site.')); |
| 2838 | return $this->error; |
| 2839 | } |
| 2840 | |
| 2841 | if ( $upload_err = apply_filters( "pre_upload_error", false ) ) |
| 2842 | return new IXR_Error(500, $upload_err); |
| Line | Code |
| 2903 | $blog_ID = (int) $args[0]; |
| 2904 | $username = $args[1]; |
| 2905 | $password = $args[2]; |
| 2906 | $num_posts = (int) $args[3]; |
| 2907 | |
| 2908 | if ( !$user = $this->login($username, $password) ) { |
| 2909 | return $this->error; |
| 2910 | } |
| 2911 | |
| 2912 | do_action('xmlrpc_call', 'mt.getRecentPostTitles'); |
| 2913 | |
| 2914 | $posts_list = wp_get_recent_posts($num_posts); |
| 2915 | |
| 2916 | if (!$posts_list) { |
| 2917 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
| 2918 | return $this->error; |
| 2919 | } |
| 2920 | |
| 2921 | foreach ($posts_list as $entry) { |
| Line | Code |
| 2960 | $password = $args[2]; |
| 2961 | |
| 2962 | if ( !$user = $this->login($username, $password) ) { |
| 2963 | return $this->error; |
| 2964 | } |
| 2965 | |
| 2966 | if( !current_user_can( 'edit_posts' ) ) |
| 2967 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this blog in order to view categories.' ) ); |
| 2968 | |
| 2969 | do_action('xmlrpc_call', 'mt.getCategoryList'); |
| 2970 | |
| 2971 | $categories_struct = array(); |
| 2972 | |
| 2973 | if ( $cats = get_categories('hide_empty=0&hierarchical=0') ) { |
| 2974 | foreach ($cats as $cat) { |
| 2975 | $struct['categoryId'] = $cat->term_id; |
| 2976 | $struct['categoryName'] = $cat->name; |
| 2977 | |
| 2978 | $categories_struct[] = $struct; |
| Line | Code |
| 2999 | $password = $args[2]; |
| 3000 | |
| 3001 | if ( !$user = $this->login($username, $password) ) { |
| 3002 | return $this->error; |
| 3003 | } |
| 3004 | |
| 3005 | if( !current_user_can( 'edit_post', $post_ID ) ) |
| 3006 | return new IXR_Error( 401, __( 'Sorry, you can not edit this post.' ) ); |
| 3007 | |
| 3008 | do_action('xmlrpc_call', 'mt.getPostCategories'); |
| 3009 | |
| 3010 | $categories = array(); |
| 3011 | $catids = wp_get_post_categories(intval($post_ID)); |
| 3012 | // first listed category will be the primary category |
| 3013 | $isPrimary = true; |
| 3014 | foreach($catids as $catid) { |
| 3015 | $categories[] = array( |
| 3016 | 'categoryName' => get_cat_name($catid), |
| 3017 | 'categoryId' => (string) $catid, |
| Line | Code |
| 3038 | $post_ID = (int) $args[0]; |
| 3039 | $username = $args[1]; |
| 3040 | $password = $args[2]; |
| 3041 | $categories = $args[3]; |
| 3042 | |
| 3043 | if ( !$user = $this->login($username, $password) ) { |
| 3044 | return $this->error; |
| 3045 | } |
| 3046 | |
| 3047 | do_action('xmlrpc_call', 'mt.setPostCategories'); |
| 3048 | |
| 3049 | if ( !current_user_can('edit_post', $post_ID) ) |
| 3050 | return new IXR_Error(401, __('Sorry, you cannot edit this post.')); |
| 3051 | |
| 3052 | foreach($categories as $cat) { |
| 3053 | $catids[] = $cat['categoryId']; |
| 3054 | } |
| 3055 | |
| 3056 | wp_set_post_categories($post_ID, $catids); |
| Line | Code |
| 3062 | * Retrieve an array of methods supported by this server. |
| 3063 | * |
| 3064 | * @since 1.5.0 |
| 3065 | * |
| 3066 | * @param array $args Method parameters. |
| 3067 | * @return array |
| 3068 | */ |
| 3069 | function mt_supportedMethods($args) { |
| 3070 | |
| 3071 | do_action('xmlrpc_call', 'mt.supportedMethods'); |
| 3072 | |
| 3073 | $supported_methods = array(); |
| 3074 | foreach($this->methods as $key=>$value) { |
| 3075 | $supported_methods[] = $key; |
| 3076 | } |
| 3077 | |
| 3078 | return $supported_methods; |
| 3079 | } |
| 3080 | |
| 3081 | /** |
| 3082 | * Retrieve an empty array because we don't support per-post text filters. |
| 3083 | * |
| 3084 | * @since 1.5.0 |
| 3085 | * |
| 3086 | * @param array $args Method parameters. |
| 3087 | */ |
| 3088 | function mt_supportedTextFilters($args) { |
| 3089 | do_action('xmlrpc_call', 'mt.supportedTextFilters'); |
| 3090 | return apply_filters('xmlrpc_text_filters', array()); |
| 3091 | } |
| 3092 | |
| 3093 | /** |
| 3094 | * Retrieve trackbacks sent to a given post. |
| 3095 | * |
| 3096 | * @since 1.5.0 |
| 3097 | * |
| 3098 | * @param array $args Method parameters. |
| 3099 | * @return mixed |
| 3100 | */ |
| 3101 | function mt_getTrackbackPings($args) { |
| 3102 | |
| 3103 | global $wpdb; |
| 3104 | |
| 3105 | $post_ID = intval($args); |
| 3106 | |
| 3107 | do_action('xmlrpc_call', 'mt.getTrackbackPings'); |
| 3108 | |
| 3109 | $actual_post = wp_get_single_post($post_ID, ARRAY_A); |
| 3110 | |
| 3111 | if (!$actual_post) { |
| 3112 | return new IXR_Error(404, __('Sorry, no such post.')); |
| 3113 | } |
| 3114 | |
| 3115 | $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) ); |
| 3116 | |
| Line | Code |
| 3148 | |
| 3149 | $post_ID = (int) $args[0]; |
| 3150 | $username = $args[1]; |
| 3151 | $password = $args[2]; |
| 3152 | |
| 3153 | if ( !$user = $this->login($username, $password) ) { |
| 3154 | return $this->error; |
| 3155 | } |
| 3156 | |
| 3157 | do_action('xmlrpc_call', 'mt.publishPost'); |
| 3158 | |
| 3159 | if ( !current_user_can('edit_post', $post_ID) ) |
| 3160 | return new IXR_Error(401, __('Sorry, you cannot edit this post.')); |
| 3161 | |
| 3162 | $postdata = wp_get_single_post($post_ID,ARRAY_A); |
| 3163 | |
| 3164 | $postdata['post_status'] = 'publish'; |
| 3165 | |
| 3166 | // retain old cats |
| Line | Code |
| 3182 | * |
| 3183 | * @since 1.5.0 |
| 3184 | * |
| 3185 | * @param array $args Method parameters. |
| 3186 | * @return array |
| 3187 | */ |
| 3188 | function pingback_ping($args) { |
| 3189 | global $wpdb; |
| 3190 | |
| 3191 | do_action('xmlrpc_call', 'pingback.ping'); |
| 3192 | |
| 3193 | $this->escape($args); |
| 3194 | |
| 3195 | $pagelinkedfrom = $args[0]; |
| 3196 | $pagelinkedto = $args[1]; |
| 3197 | |
| 3198 | $title = ''; |
| 3199 | |
| 3200 | $pagelinkedfrom = str_replace('&', '&', $pagelinkedfrom); |
| Line | Code |
| 3354 | * @since 1.5.0 |
| 3355 | * |
| 3356 | * @param array $args Method parameters. |
| 3357 | * @return array |
| 3358 | */ |
| 3359 | function pingback_extensions_getPingbacks($args) { |
| 3360 | |
| 3361 | global $wpdb; |
| 3362 | |
| 3363 | do_action('xmlrpc_call', 'pingback.extensions.getPingbacks'); |
| 3364 | |
| 3365 | $this->escape($args); |
| 3366 | |
| 3367 | $url = $args; |
| 3368 | |
| 3369 | $post_ID = url_to_postid($url); |
| 3370 | if (!$post_ID) { |
| 3371 | // We aren't sure that the resource is available and/or pingback enabled |
| 3372 | 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.')); |