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 67 times in this file.
| Line | Code |
|---|---|
| 594 | * the method logic begins. |
| 595 | * |
| 596 | * All built-in XML-RPC methods use the action xmlrpc_call, with a parameter |
| 597 | * equal to the method's name, e.g., wp.getUsersBlogs, wp.newPost, etc. |
| 598 | * |
| 599 | * @since 2.5.0 |
| 600 | * |
| 601 | * @param string $name The method name. |
| 602 | */ |
| 603 | do_action( 'xmlrpc_call', 'wp.getUsersBlogs' ); |
| 604 | |
| 605 | $blogs = (array) get_blogs_of_user( $user->ID ); |
| 606 | $struct = array(); |
| 607 | $primary_blog_id = 0; |
| 608 | $active_blog = get_active_blog_for_user( $user->ID ); |
| 609 | if ( $active_blog ) { |
| 610 | $primary_blog_id = (int) $active_blog->blog_id; |
| 611 | } |
| 612 | |
| Line | Code |
| 1201 | if ( isset( $content_struct['post_date_gmt'] ) && ! ( $content_struct['post_date_gmt'] instanceof IXR_Date ) ) { |
| 1202 | if ( $content_struct['post_date_gmt'] == '0000-00-00 00:00:00' || isset( $content_struct['post_date'] ) ) { |
| 1203 | unset( $content_struct['post_date_gmt'] ); |
| 1204 | } else { |
| 1205 | $content_struct['post_date_gmt'] = $this->_convert_date( $content_struct['post_date_gmt'] ); |
| 1206 | } |
| 1207 | } |
| 1208 | |
| 1209 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1210 | do_action( 'xmlrpc_call', 'wp.newPost' ); |
| 1211 | |
| 1212 | unset( $content_struct['ID'] ); |
| 1213 | |
| 1214 | return $this->_insert_post( $user, $content_struct ); |
| 1215 | } |
| 1216 | |
| 1217 | /** |
| 1218 | * Helper method for filtering out elements from an array. |
| 1219 | * |
| Line | Code |
| 1531 | $username = $args[1]; |
| 1532 | $password = $args[2]; |
| 1533 | $post_id = (int) $args[3]; |
| 1534 | $content_struct = $args[4]; |
| 1535 | |
| 1536 | if ( ! $user = $this->login( $username, $password ) ) |
| 1537 | return $this->error; |
| 1538 | |
| 1539 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1540 | do_action( 'xmlrpc_call', 'wp.editPost' ); |
| 1541 | |
| 1542 | $post = get_post( $post_id, ARRAY_A ); |
| 1543 | |
| 1544 | if ( empty( $post['ID'] ) ) |
| 1545 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 1546 | |
| 1547 | if ( isset( $content_struct['if_not_modified_since'] ) ) { |
| 1548 | // If the post has been modified since the date provided, return an error. |
| 1549 | if ( mysql2date( 'U', $post['post_modified_gmt'] ) > $content_struct['if_not_modified_since']->getTimestamp() ) { |
| Line | Code |
| 1598 | |
| 1599 | $username = $args[1]; |
| 1600 | $password = $args[2]; |
| 1601 | $post_id = (int) $args[3]; |
| 1602 | |
| 1603 | if ( ! $user = $this->login( $username, $password ) ) |
| 1604 | return $this->error; |
| 1605 | |
| 1606 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1607 | do_action( 'xmlrpc_call', 'wp.deletePost' ); |
| 1608 | |
| 1609 | $post = get_post( $post_id, ARRAY_A ); |
| 1610 | if ( empty( $post['ID'] ) ) { |
| 1611 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 1612 | } |
| 1613 | |
| 1614 | if ( ! current_user_can( 'delete_post', $post_id ) ) { |
| 1615 | return new IXR_Error( 401, __( 'Sorry, you do not have the right to delete this post.' ) ); |
| 1616 | } |
| Line | Code |
| 1695 | * @param string $method Method name. |
| 1696 | */ |
| 1697 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPost' ); |
| 1698 | } |
| 1699 | |
| 1700 | if ( ! $user = $this->login( $username, $password ) ) |
| 1701 | return $this->error; |
| 1702 | |
| 1703 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1704 | do_action( 'xmlrpc_call', 'wp.getPost' ); |
| 1705 | |
| 1706 | $post = get_post( $post_id, ARRAY_A ); |
| 1707 | |
| 1708 | if ( empty( $post['ID'] ) ) |
| 1709 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 1710 | |
| 1711 | if ( ! current_user_can( 'edit_post', $post_id ) ) |
| 1712 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); |
| 1713 | |
| Line | Code |
| 1751 | } else { |
| 1752 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1753 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPosts' ); |
| 1754 | } |
| 1755 | |
| 1756 | if ( ! $user = $this->login( $username, $password ) ) |
| 1757 | return $this->error; |
| 1758 | |
| 1759 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1760 | do_action( 'xmlrpc_call', 'wp.getPosts' ); |
| 1761 | |
| 1762 | $query = array(); |
| 1763 | |
| 1764 | if ( isset( $filter['post_type'] ) ) { |
| 1765 | $post_type = get_post_type_object( $filter['post_type'] ); |
| 1766 | if ( ! ( (bool) $post_type ) ) |
| 1767 | return new IXR_Error( 403, __( 'The post type specified is not valid' ) ); |
| 1768 | } else { |
| 1769 | $post_type = get_post_type_object( 'post' ); |
| Line | Code |
| 1839 | |
| 1840 | $username = $args[1]; |
| 1841 | $password = $args[2]; |
| 1842 | $content_struct = $args[3]; |
| 1843 | |
| 1844 | if ( ! $user = $this->login( $username, $password ) ) |
| 1845 | return $this->error; |
| 1846 | |
| 1847 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1848 | do_action( 'xmlrpc_call', 'wp.newTerm' ); |
| 1849 | |
| 1850 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) |
| 1851 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
| 1852 | |
| 1853 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
| 1854 | |
| 1855 | if ( ! current_user_can( $taxonomy->cap->manage_terms ) ) |
| 1856 | return new IXR_Error( 401, __( 'You are not allowed to create terms in this taxonomy.' ) ); |
| 1857 | |
| Line | Code |
| 1926 | $username = $args[1]; |
| 1927 | $password = $args[2]; |
| 1928 | $term_id = (int) $args[3]; |
| 1929 | $content_struct = $args[4]; |
| 1930 | |
| 1931 | if ( ! $user = $this->login( $username, $password ) ) |
| 1932 | return $this->error; |
| 1933 | |
| 1934 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1935 | do_action( 'xmlrpc_call', 'wp.editTerm' ); |
| 1936 | |
| 1937 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) |
| 1938 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
| 1939 | |
| 1940 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
| 1941 | |
| 1942 | if ( ! current_user_can( $taxonomy->cap->edit_terms ) ) |
| 1943 | return new IXR_Error( 401, __( 'You are not allowed to edit terms in this taxonomy.' ) ); |
| 1944 | |
| Line | Code |
| 2022 | $username = $args[1]; |
| 2023 | $password = $args[2]; |
| 2024 | $taxonomy = $args[3]; |
| 2025 | $term_id = (int) $args[4]; |
| 2026 | |
| 2027 | if ( ! $user = $this->login( $username, $password ) ) |
| 2028 | return $this->error; |
| 2029 | |
| 2030 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2031 | do_action( 'xmlrpc_call', 'wp.deleteTerm' ); |
| 2032 | |
| 2033 | if ( ! taxonomy_exists( $taxonomy ) ) |
| 2034 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
| 2035 | |
| 2036 | $taxonomy = get_taxonomy( $taxonomy ); |
| 2037 | |
| 2038 | if ( ! current_user_can( $taxonomy->cap->delete_terms ) ) |
| 2039 | return new IXR_Error( 401, __( 'You are not allowed to delete terms in this taxonomy.' ) ); |
| 2040 | |
| Line | Code |
| 2093 | $username = $args[1]; |
| 2094 | $password = $args[2]; |
| 2095 | $taxonomy = $args[3]; |
| 2096 | $term_id = (int) $args[4]; |
| 2097 | |
| 2098 | if ( ! $user = $this->login( $username, $password ) ) |
| 2099 | return $this->error; |
| 2100 | |
| 2101 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2102 | do_action( 'xmlrpc_call', 'wp.getTerm' ); |
| 2103 | |
| 2104 | if ( ! taxonomy_exists( $taxonomy ) ) |
| 2105 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
| 2106 | |
| 2107 | $taxonomy = get_taxonomy( $taxonomy ); |
| 2108 | |
| 2109 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
| 2110 | return new IXR_Error( 401, __( 'You are not allowed to assign terms in this taxonomy.' ) ); |
| 2111 | |
| Line | Code |
| 2151 | $username = $args[1]; |
| 2152 | $password = $args[2]; |
| 2153 | $taxonomy = $args[3]; |
| 2154 | $filter = isset( $args[4] ) ? $args[4] : array(); |
| 2155 | |
| 2156 | if ( ! $user = $this->login( $username, $password ) ) |
| 2157 | return $this->error; |
| 2158 | |
| 2159 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2160 | do_action( 'xmlrpc_call', 'wp.getTerms' ); |
| 2161 | |
| 2162 | if ( ! taxonomy_exists( $taxonomy ) ) |
| 2163 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
| 2164 | |
| 2165 | $taxonomy = get_taxonomy( $taxonomy ); |
| 2166 | |
| 2167 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
| 2168 | return new IXR_Error( 401, __( 'You are not allowed to assign terms in this taxonomy.' ) ); |
| 2169 | |
| Line | Code |
| 2246 | * @param string $method The method name. |
| 2247 | */ |
| 2248 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomy' ); |
| 2249 | } |
| 2250 | |
| 2251 | if ( ! $user = $this->login( $username, $password ) ) |
| 2252 | return $this->error; |
| 2253 | |
| 2254 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2255 | do_action( 'xmlrpc_call', 'wp.getTaxonomy' ); |
| 2256 | |
| 2257 | if ( ! taxonomy_exists( $taxonomy ) ) |
| 2258 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
| 2259 | |
| 2260 | $taxonomy = get_taxonomy( $taxonomy ); |
| 2261 | |
| 2262 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
| 2263 | return new IXR_Error( 401, __( 'You are not allowed to assign terms in this taxonomy.' ) ); |
| 2264 | |
| Line | Code |
| 2299 | } else { |
| 2300 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2301 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomies' ); |
| 2302 | } |
| 2303 | |
| 2304 | if ( ! $user = $this->login( $username, $password ) ) |
| 2305 | return $this->error; |
| 2306 | |
| 2307 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2308 | do_action( 'xmlrpc_call', 'wp.getTaxonomies' ); |
| 2309 | |
| 2310 | $taxonomies = get_taxonomies( $filter, 'objects' ); |
| 2311 | |
| 2312 | // holds all the taxonomy data |
| 2313 | $struct = array(); |
| 2314 | |
| 2315 | foreach ( $taxonomies as $taxonomy ) { |
| 2316 | // capability check for post_types |
| 2317 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
| Line | Code |
| 2381 | * @param string $method The method name. |
| 2382 | */ |
| 2383 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUser' ); |
| 2384 | } |
| 2385 | |
| 2386 | if ( ! $user = $this->login( $username, $password ) ) |
| 2387 | return $this->error; |
| 2388 | |
| 2389 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2390 | do_action( 'xmlrpc_call', 'wp.getUser' ); |
| 2391 | |
| 2392 | if ( ! current_user_can( 'edit_user', $user_id ) ) |
| 2393 | return new IXR_Error( 401, __( 'Sorry, you cannot edit users.' ) ); |
| 2394 | |
| 2395 | $user_data = get_userdata( $user_id ); |
| 2396 | |
| 2397 | if ( ! $user_data ) |
| 2398 | return new IXR_Error( 404, __( 'Invalid user ID.' ) ); |
| 2399 | |
| Line | Code |
| 2439 | } else { |
| 2440 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2441 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUsers' ); |
| 2442 | } |
| 2443 | |
| 2444 | if ( ! $user = $this->login( $username, $password ) ) |
| 2445 | return $this->error; |
| 2446 | |
| 2447 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2448 | do_action( 'xmlrpc_call', 'wp.getUsers' ); |
| 2449 | |
| 2450 | if ( ! current_user_can( 'list_users' ) ) |
| 2451 | return new IXR_Error( 401, __( 'You are not allowed to browse users.' ) ); |
| 2452 | |
| 2453 | $query = array( 'fields' => 'all_with_meta' ); |
| 2454 | |
| 2455 | $query['number'] = ( isset( $filter['number'] ) ) ? absint( $filter['number'] ) : 50; |
| 2456 | $query['offset'] = ( isset( $filter['offset'] ) ) ? absint( $filter['offset'] ) : 0; |
| 2457 | |
| Line | Code |
| 2512 | } else { |
| 2513 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2514 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getProfile' ); |
| 2515 | } |
| 2516 | |
| 2517 | if ( ! $user = $this->login( $username, $password ) ) |
| 2518 | return $this->error; |
| 2519 | |
| 2520 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2521 | do_action( 'xmlrpc_call', 'wp.getProfile' ); |
| 2522 | |
| 2523 | if ( ! current_user_can( 'edit_user', $user->ID ) ) |
| 2524 | return new IXR_Error( 401, __( 'Sorry, you cannot edit your profile.' ) ); |
| 2525 | |
| 2526 | $user_data = get_userdata( $user->ID ); |
| 2527 | |
| 2528 | return $this->_prepare_user( $user_data, $fields ); |
| 2529 | } |
| 2530 | |
| Line | Code |
| 2558 | |
| 2559 | $username = $args[1]; |
| 2560 | $password = $args[2]; |
| 2561 | $content_struct = $args[3]; |
| 2562 | |
| 2563 | if ( ! $user = $this->login( $username, $password ) ) |
| 2564 | return $this->error; |
| 2565 | |
| 2566 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2567 | do_action( 'xmlrpc_call', 'wp.editProfile' ); |
| 2568 | |
| 2569 | if ( ! current_user_can( 'edit_user', $user->ID ) ) |
| 2570 | return new IXR_Error( 401, __( 'Sorry, you cannot edit your profile.' ) ); |
| 2571 | |
| 2572 | // holds data of the user |
| 2573 | $user_data = array(); |
| 2574 | $user_data['ID'] = $user->ID; |
| 2575 | |
| 2576 | // only set the user details if it was given |
| Line | Code |
| 2634 | |
| 2635 | $page = get_post($page_id); |
| 2636 | if ( ! $page ) |
| 2637 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 2638 | |
| 2639 | if ( !current_user_can( 'edit_page', $page_id ) ) |
| 2640 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this page.' ) ); |
| 2641 | |
| 2642 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2643 | do_action( 'xmlrpc_call', 'wp.getPage' ); |
| 2644 | |
| 2645 | // If we found the page then format the data. |
| 2646 | if ( $page->ID && ($page->post_type == 'page') ) { |
| 2647 | return $this->_prepare_page( $page ); |
| 2648 | } |
| 2649 | // If the page doesn't exist indicate that. |
| 2650 | else { |
| 2651 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
| 2652 | } |
| Line | Code |
| 2675 | $num_pages = isset($args[3]) ? (int) $args[3] : 10; |
| 2676 | |
| 2677 | if ( !$user = $this->login($username, $password) ) |
| 2678 | return $this->error; |
| 2679 | |
| 2680 | if ( !current_user_can( 'edit_pages' ) ) |
| 2681 | return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) ); |
| 2682 | |
| 2683 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2684 | do_action( 'xmlrpc_call', 'wp.getPages' ); |
| 2685 | |
| 2686 | $pages = get_posts( array('post_type' => 'page', 'post_status' => 'any', 'numberposts' => $num_pages) ); |
| 2687 | $num_pages = count($pages); |
| 2688 | |
| 2689 | // If we have pages, put together their info. |
| 2690 | if ( $num_pages >= 1 ) { |
| 2691 | $pages_struct = array(); |
| 2692 | |
| 2693 | foreach ($pages as $page) { |
| Line | Code |
| 2721 | public function wp_newPage( $args ) { |
| 2722 | // Items not escaped here will be escaped in newPost. |
| 2723 | $username = $this->escape( $args[1] ); |
| 2724 | $password = $this->escape( $args[2] ); |
| 2725 | |
| 2726 | if ( !$user = $this->login($username, $password) ) |
| 2727 | return $this->error; |
| 2728 | |
| 2729 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2730 | do_action( 'xmlrpc_call', 'wp.newPage' ); |
| 2731 | |
| 2732 | // Mark this as content for a page. |
| 2733 | $args[3]["post_type"] = 'page'; |
| 2734 | |
| 2735 | // Let mw_newPost do all of the heavy lifting. |
| 2736 | return $this->mw_newPost( $args ); |
| 2737 | } |
| 2738 | |
| 2739 | /** |
| Line | Code |
| 2756 | |
| 2757 | $username = $args[1]; |
| 2758 | $password = $args[2]; |
| 2759 | $page_id = (int) $args[3]; |
| 2760 | |
| 2761 | if ( !$user = $this->login($username, $password) ) |
| 2762 | return $this->error; |
| 2763 | |
| 2764 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2765 | do_action( 'xmlrpc_call', 'wp.deletePage' ); |
| 2766 | |
| 2767 | // Get the current page based on the page_id and |
| 2768 | // make sure it is a page and not a post. |
| 2769 | $actual_page = get_post($page_id, ARRAY_A); |
| 2770 | if ( !$actual_page || ($actual_page['post_type'] != 'page') ) |
| 2771 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
| 2772 | |
| 2773 | // Make sure the user can delete pages. |
| 2774 | if ( !current_user_can('delete_page', $page_id) ) |
| Line | Code |
| 2819 | |
| 2820 | $escaped_username = $this->escape( $username ); |
| 2821 | $escaped_password = $this->escape( $password ); |
| 2822 | |
| 2823 | if ( !$user = $this->login( $escaped_username, $escaped_password ) ) { |
| 2824 | return $this->error; |
| 2825 | } |
| 2826 | |
| 2827 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2828 | do_action( 'xmlrpc_call', 'wp.editPage' ); |
| 2829 | |
| 2830 | // Get the page data and make sure it is a page. |
| 2831 | $actual_page = get_post($page_id, ARRAY_A); |
| 2832 | if ( !$actual_page || ($actual_page['post_type'] != 'page') ) |
| 2833 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
| 2834 | |
| 2835 | // Make sure the user is allowed to edit pages. |
| 2836 | if ( !current_user_can('edit_page', $page_id) ) |
| 2837 | return new IXR_Error( 401, __( 'Sorry, you do not have the right to edit this page.' ) ); |
| Line | Code |
| 2877 | $password = $args[2]; |
| 2878 | |
| 2879 | if ( !$user = $this->login($username, $password) ) |
| 2880 | return $this->error; |
| 2881 | |
| 2882 | if ( !current_user_can( 'edit_pages' ) ) |
| 2883 | return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) ); |
| 2884 | |
| 2885 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2886 | do_action( 'xmlrpc_call', 'wp.getPageList' ); |
| 2887 | |
| 2888 | // Get list of pages ids and titles |
| 2889 | $page_list = $wpdb->get_results(" |
| 2890 | SELECT ID page_id, |
| 2891 | post_title page_title, |
| 2892 | post_parent page_parent_id, |
| 2893 | post_date_gmt, |
| 2894 | post_date, |
| 2895 | post_status |
| Line | Code |
| 2933 | $password = $args[2]; |
| 2934 | |
| 2935 | if ( !$user = $this->login($username, $password) ) |
| 2936 | return $this->error; |
| 2937 | |
| 2938 | if ( !current_user_can('edit_posts') ) |
| 2939 | return new IXR_Error( 401, __( 'Sorry, you cannot edit posts on this site.' ) ); |
| 2940 | |
| 2941 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2942 | do_action( 'xmlrpc_call', 'wp.getAuthors' ); |
| 2943 | |
| 2944 | $authors = array(); |
| 2945 | foreach ( get_users( array( 'fields' => array('ID','user_login','display_name') ) ) as $user ) { |
| 2946 | $authors[] = array( |
| 2947 | 'user_id' => $user->ID, |
| 2948 | 'user_login' => $user->user_login, |
| 2949 | 'display_name' => $user->display_name |
| 2950 | ); |
| 2951 | } |
| Line | Code |
| 2974 | $password = $args[2]; |
| 2975 | |
| 2976 | if ( !$user = $this->login($username, $password) ) |
| 2977 | return $this->error; |
| 2978 | |
| 2979 | if ( !current_user_can( 'edit_posts' ) ) |
| 2980 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view tags.' ) ); |
| 2981 | |
| 2982 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2983 | do_action( 'xmlrpc_call', 'wp.getKeywords' ); |
| 2984 | |
| 2985 | $tags = array(); |
| 2986 | |
| 2987 | if ( $all_tags = get_tags() ) { |
| 2988 | foreach ( (array) $all_tags as $tag ) { |
| 2989 | $struct = array(); |
| 2990 | $struct['tag_id'] = $tag->term_id; |
| 2991 | $struct['name'] = $tag->name; |
| 2992 | $struct['count'] = $tag->count; |
| Line | Code |
| 3021 | |
| 3022 | $username = $args[1]; |
| 3023 | $password = $args[2]; |
| 3024 | $category = $args[3]; |
| 3025 | |
| 3026 | if ( !$user = $this->login($username, $password) ) |
| 3027 | return $this->error; |
| 3028 | |
| 3029 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3030 | do_action( 'xmlrpc_call', 'wp.newCategory' ); |
| 3031 | |
| 3032 | // Make sure the user is allowed to add a category. |
| 3033 | if ( !current_user_can('manage_categories') ) |
| 3034 | return new IXR_Error(401, __('Sorry, you do not have the right to add a category.')); |
| 3035 | |
| 3036 | // If no slug was provided make it empty so that |
| 3037 | // WordPress will generate one. |
| 3038 | if ( empty($category['slug']) ) |
| 3039 | $category['slug'] = ''; |
| Line | Code |
| 3097 | |
| 3098 | $username = $args[1]; |
| 3099 | $password = $args[2]; |
| 3100 | $category_id = (int) $args[3]; |
| 3101 | |
| 3102 | if ( !$user = $this->login($username, $password) ) |
| 3103 | return $this->error; |
| 3104 | |
| 3105 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3106 | do_action( 'xmlrpc_call', 'wp.deleteCategory' ); |
| 3107 | |
| 3108 | if ( !current_user_can('manage_categories') ) |
| 3109 | return new IXR_Error( 401, __( 'Sorry, you do not have the right to delete a category.' ) ); |
| 3110 | |
| 3111 | $status = wp_delete_term( $category_id, 'category' ); |
| 3112 | |
| 3113 | if ( true == $status ) { |
| 3114 | /** |
| 3115 | * Fires after a category has been successfully deleted via XML-RPC. |
| Line | Code |
| 3150 | $max_results = (int) $args[4]; |
| 3151 | |
| 3152 | if ( !$user = $this->login($username, $password) ) |
| 3153 | return $this->error; |
| 3154 | |
| 3155 | if ( !current_user_can( 'edit_posts' ) ) |
| 3156 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
| 3157 | |
| 3158 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3159 | do_action( 'xmlrpc_call', 'wp.suggestCategories' ); |
| 3160 | |
| 3161 | $category_suggestions = array(); |
| 3162 | $args = array('get' => 'all', 'number' => $max_results, 'name__like' => $category); |
| 3163 | foreach ( (array) get_categories($args) as $cat ) { |
| 3164 | $category_suggestions[] = array( |
| 3165 | 'category_id' => $cat->term_id, |
| 3166 | 'category_name' => $cat->name |
| 3167 | ); |
| 3168 | } |
| Line | Code |
| 3191 | $username = $args[1]; |
| 3192 | $password = $args[2]; |
| 3193 | $comment_id = (int) $args[3]; |
| 3194 | |
| 3195 | if ( ! $user = $this->login( $username, $password ) ) { |
| 3196 | return $this->error; |
| 3197 | } |
| 3198 | |
| 3199 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3200 | do_action( 'xmlrpc_call', 'wp.getComment' ); |
| 3201 | |
| 3202 | if ( ! $comment = get_comment( $comment_id ) ) { |
| 3203 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 3204 | } |
| 3205 | |
| 3206 | if ( ! current_user_can( 'edit_comment', $comment_id ) ) { |
| 3207 | return new IXR_Error( 403, __( 'You are not allowed to moderate or edit this comment.' ) ); |
| 3208 | } |
| 3209 | |
| Line | Code |
| 3242 | $username = $args[1]; |
| 3243 | $password = $args[2]; |
| 3244 | $struct = isset( $args[3] ) ? $args[3] : array(); |
| 3245 | |
| 3246 | if ( ! $user = $this->login( $username, $password ) ) { |
| 3247 | return $this->error; |
| 3248 | } |
| 3249 | |
| 3250 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3251 | do_action( 'xmlrpc_call', 'wp.getComments' ); |
| 3252 | |
| 3253 | if ( isset( $struct['status'] ) ) { |
| 3254 | $status = $struct['status']; |
| 3255 | } else { |
| 3256 | $status = ''; |
| 3257 | } |
| 3258 | |
| 3259 | if ( ! current_user_can( 'moderate_comments' ) && 'approve' !== $status ) { |
| 3260 | return new IXR_Error( 401, __( 'Invalid comment status.' ) ); |
| Line | Code |
| 3335 | if ( ! get_comment( $comment_ID ) ) { |
| 3336 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 3337 | } |
| 3338 | |
| 3339 | if ( !current_user_can( 'edit_comment', $comment_ID ) ) { |
| 3340 | return new IXR_Error( 403, __( 'You are not allowed to moderate or edit this comment.' ) ); |
| 3341 | } |
| 3342 | |
| 3343 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3344 | do_action( 'xmlrpc_call', 'wp.deleteComment' ); |
| 3345 | |
| 3346 | $status = wp_delete_comment( $comment_ID ); |
| 3347 | |
| 3348 | if ( $status ) { |
| 3349 | /** |
| 3350 | * Fires after a comment has been successfully deleted via XML-RPC. |
| 3351 | * |
| 3352 | * @since 3.4.0 |
| 3353 | * |
| Line | Code |
| 3402 | if ( ! get_comment( $comment_ID ) ) { |
| 3403 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 3404 | } |
| 3405 | |
| 3406 | if ( ! current_user_can( 'edit_comment', $comment_ID ) ) { |
| 3407 | return new IXR_Error( 403, __( 'You are not allowed to moderate or edit this comment.' ) ); |
| 3408 | } |
| 3409 | |
| 3410 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3411 | do_action( 'xmlrpc_call', 'wp.editComment' ); |
| 3412 | |
| 3413 | if ( isset($content_struct['status']) ) { |
| 3414 | $statuses = get_comment_statuses(); |
| 3415 | $statuses = array_keys($statuses); |
| 3416 | |
| 3417 | if ( ! in_array($content_struct['status'], $statuses) ) |
| 3418 | return new IXR_Error( 401, __( 'Invalid comment status.' ) ); |
| 3419 | $comment_approved = $content_struct['status']; |
| 3420 | } |
| Line | Code |
| 3560 | return new IXR_Error( 403, __( 'A valid email address is required' ) ); |
| 3561 | } |
| 3562 | } |
| 3563 | |
| 3564 | $comment['comment_parent'] = isset($content_struct['comment_parent']) ? absint($content_struct['comment_parent']) : 0; |
| 3565 | |
| 3566 | $comment['comment_content'] = isset($content_struct['content']) ? $content_struct['content'] : null; |
| 3567 | |
| 3568 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3569 | do_action( 'xmlrpc_call', 'wp.newComment' ); |
| 3570 | |
| 3571 | $comment_ID = wp_new_comment( $comment ); |
| 3572 | |
| 3573 | /** |
| 3574 | * Fires after a new comment has been successfully created via XML-RPC. |
| 3575 | * |
| 3576 | * @since 3.4.0 |
| 3577 | * |
| 3578 | * @param int $comment_ID ID of the new comment. |
| Line | Code |
| 3606 | if ( ! $user = $this->login( $username, $password ) ) { |
| 3607 | return $this->error; |
| 3608 | } |
| 3609 | |
| 3610 | if ( ! current_user_can( 'publish_posts' ) ) { |
| 3611 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
| 3612 | } |
| 3613 | |
| 3614 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3615 | do_action( 'xmlrpc_call', 'wp.getCommentStatusList' ); |
| 3616 | |
| 3617 | return get_comment_statuses(); |
| 3618 | } |
| 3619 | |
| 3620 | /** |
| 3621 | * Retrieve comment count. |
| 3622 | * |
| 3623 | * @since 2.5.0 |
| 3624 | * |
| Line | Code |
| 3647 | if ( empty( $post['ID'] ) ) { |
| 3648 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 3649 | } |
| 3650 | |
| 3651 | if ( ! current_user_can( 'edit_post', $post_id ) ) { |
| 3652 | return new IXR_Error( 403, __( 'You are not allowed access to details of this post.' ) ); |
| 3653 | } |
| 3654 | |
| 3655 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3656 | do_action( 'xmlrpc_call', 'wp.getCommentCount' ); |
| 3657 | |
| 3658 | $count = wp_count_comments( $post_id ); |
| 3659 | |
| 3660 | return array( |
| 3661 | 'approved' => $count->approved, |
| 3662 | 'awaiting_moderation' => $count->moderated, |
| 3663 | 'spam' => $count->spam, |
| 3664 | 'total_comments' => $count->total_comments |
| 3665 | ); |
| Line | Code |
| 3686 | $password = $args[2]; |
| 3687 | |
| 3688 | if ( !$user = $this->login($username, $password) ) |
| 3689 | return $this->error; |
| 3690 | |
| 3691 | if ( !current_user_can( 'edit_posts' ) ) |
| 3692 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
| 3693 | |
| 3694 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3695 | do_action( 'xmlrpc_call', 'wp.getPostStatusList' ); |
| 3696 | |
| 3697 | return get_post_statuses(); |
| 3698 | } |
| 3699 | |
| 3700 | /** |
| 3701 | * Retrieve page statuses. |
| 3702 | * |
| 3703 | * @since 2.5.0 |
| 3704 | * |
| Line | Code |
| 3718 | $password = $args[2]; |
| 3719 | |
| 3720 | if ( !$user = $this->login($username, $password) ) |
| 3721 | return $this->error; |
| 3722 | |
| 3723 | if ( !current_user_can( 'edit_pages' ) ) |
| 3724 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
| 3725 | |
| 3726 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3727 | do_action( 'xmlrpc_call', 'wp.getPageStatusList' ); |
| 3728 | |
| 3729 | return get_page_statuses(); |
| 3730 | } |
| 3731 | |
| 3732 | /** |
| 3733 | * Retrieve page templates. |
| 3734 | * |
| 3735 | * @since 2.6.0 |
| 3736 | * |
| Line | Code |
| 3896 | $attachment_id = (int) $args[3]; |
| 3897 | |
| 3898 | if ( !$user = $this->login($username, $password) ) |
| 3899 | return $this->error; |
| 3900 | |
| 3901 | if ( !current_user_can( 'upload_files' ) ) |
| 3902 | return new IXR_Error( 403, __( 'You do not have permission to upload files.' ) ); |
| 3903 | |
| 3904 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3905 | do_action( 'xmlrpc_call', 'wp.getMediaItem' ); |
| 3906 | |
| 3907 | if ( ! $attachment = get_post($attachment_id) ) |
| 3908 | return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); |
| 3909 | |
| 3910 | return $this->_prepare_media_item( $attachment ); |
| 3911 | } |
| 3912 | |
| 3913 | /** |
| 3914 | * Retrieves a collection of media library items (or attachments) |
| Line | Code |
| 3944 | $struct = isset( $args[3] ) ? $args[3] : array() ; |
| 3945 | |
| 3946 | if ( !$user = $this->login($username, $password) ) |
| 3947 | return $this->error; |
| 3948 | |
| 3949 | if ( !current_user_can( 'upload_files' ) ) |
| 3950 | return new IXR_Error( 401, __( 'You do not have permission to upload files.' ) ); |
| 3951 | |
| 3952 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3953 | do_action( 'xmlrpc_call', 'wp.getMediaLibrary' ); |
| 3954 | |
| 3955 | $parent_id = ( isset($struct['parent_id']) ) ? absint($struct['parent_id']) : '' ; |
| 3956 | $mime_type = ( isset($struct['mime_type']) ) ? $struct['mime_type'] : '' ; |
| 3957 | $offset = ( isset($struct['offset']) ) ? absint($struct['offset']) : 0 ; |
| 3958 | $number = ( isset($struct['number']) ) ? absint($struct['number']) : -1 ; |
| 3959 | |
| 3960 | $attachments = get_posts( array('post_type' => 'attachment', 'post_parent' => $parent_id, 'offset' => $offset, 'numberposts' => $number, 'post_mime_type' => $mime_type ) ); |
| 3961 | |
| 3962 | $attachments_struct = array(); |
| Line | Code |
| 3988 | $password = $args[2]; |
| 3989 | |
| 3990 | if ( !$user = $this->login( $username, $password ) ) |
| 3991 | return $this->error; |
| 3992 | |
| 3993 | if ( !current_user_can( 'edit_posts' ) ) |
| 3994 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
| 3995 | |
| 3996 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3997 | do_action( 'xmlrpc_call', 'wp.getPostFormats' ); |
| 3998 | |
| 3999 | $formats = get_post_format_strings(); |
| 4000 | |
| 4001 | // find out if they want a list of currently supports formats |
| 4002 | if ( isset( $args[3] ) && is_array( $args[3] ) ) { |
| 4003 | if ( $args[3]['show-supported'] ) { |
| 4004 | if ( current_theme_supports( 'post-formats' ) ) { |
| 4005 | $supported = get_theme_support( 'post-formats' ); |
| 4006 | |
| Line | Code |
| 4065 | * @param string $method The method name. |
| 4066 | */ |
| 4067 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostType' ); |
| 4068 | } |
| 4069 | |
| 4070 | if ( !$user = $this->login( $username, $password ) ) |
| 4071 | return $this->error; |
| 4072 | |
| 4073 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4074 | do_action( 'xmlrpc_call', 'wp.getPostType' ); |
| 4075 | |
| 4076 | if ( ! post_type_exists( $post_type_name ) ) |
| 4077 | return new IXR_Error( 403, __( 'Invalid post type' ) ); |
| 4078 | |
| 4079 | $post_type = get_post_type_object( $post_type_name ); |
| 4080 | |
| 4081 | if ( ! current_user_can( $post_type->cap->edit_posts ) ) |
| 4082 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post type.' ) ); |
| 4083 | |
| Line | Code |
| 4117 | } else { |
| 4118 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4119 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostTypes' ); |
| 4120 | } |
| 4121 | |
| 4122 | if ( ! $user = $this->login( $username, $password ) ) |
| 4123 | return $this->error; |
| 4124 | |
| 4125 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4126 | do_action( 'xmlrpc_call', 'wp.getPostTypes' ); |
| 4127 | |
| 4128 | $post_types = get_post_types( $filter, 'objects' ); |
| 4129 | |
| 4130 | $struct = array(); |
| 4131 | |
| 4132 | foreach ( $post_types as $post_type ) { |
| 4133 | if ( ! current_user_can( $post_type->cap->edit_posts ) ) |
| 4134 | continue; |
| 4135 | |
| Line | Code |
| 4183 | * @param string $method The method name. |
| 4184 | */ |
| 4185 | $fields = apply_filters( 'xmlrpc_default_revision_fields', array( 'post_date', 'post_date_gmt' ), 'wp.getRevisions' ); |
| 4186 | } |
| 4187 | |
| 4188 | if ( ! $user = $this->login( $username, $password ) ) |
| 4189 | return $this->error; |
| 4190 | |
| 4191 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4192 | do_action( 'xmlrpc_call', 'wp.getRevisions' ); |
| 4193 | |
| 4194 | if ( ! $post = get_post( $post_id ) ) |
| 4195 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4196 | |
| 4197 | if ( ! current_user_can( 'edit_post', $post_id ) ) |
| 4198 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
| 4199 | |
| 4200 | // Check if revisions are enabled. |
| 4201 | if ( ! wp_revisions_enabled( $post ) ) |
| Line | Code |
| 4247 | |
| 4248 | $username = $args[1]; |
| 4249 | $password = $args[2]; |
| 4250 | $revision_id = (int) $args[3]; |
| 4251 | |
| 4252 | if ( ! $user = $this->login( $username, $password ) ) |
| 4253 | return $this->error; |
| 4254 | |
| 4255 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4256 | do_action( 'xmlrpc_call', 'wp.restoreRevision' ); |
| 4257 | |
| 4258 | if ( ! $revision = wp_get_post_revision( $revision_id ) ) |
| 4259 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4260 | |
| 4261 | if ( wp_is_post_autosave( $revision ) ) |
| 4262 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4263 | |
| 4264 | if ( ! $post = get_post( $revision->post_parent ) ) |
| 4265 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| Line | Code |
| 4303 | $this->escape($args); |
| 4304 | |
| 4305 | $username = $args[1]; |
| 4306 | $password = $args[2]; |
| 4307 | |
| 4308 | if ( !$user = $this->login($username, $password) ) |
| 4309 | return $this->error; |
| 4310 | |
| 4311 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4312 | do_action( 'xmlrpc_call', 'blogger.getUsersBlogs' ); |
| 4313 | |
| 4314 | $is_admin = current_user_can('manage_options'); |
| 4315 | |
| 4316 | $struct = array( |
| 4317 | 'isAdmin' => $is_admin, |
| 4318 | 'url' => get_option('home') . '/', |
| 4319 | 'blogid' => '1', |
| 4320 | 'blogName' => get_option('blogname'), |
| 4321 | 'xmlrpc' => site_url( 'xmlrpc.php', 'rpc' ), |
| Line | Code |
| 4378 | $password = $args[2]; |
| 4379 | |
| 4380 | if ( !$user = $this->login($username, $password) ) |
| 4381 | return $this->error; |
| 4382 | |
| 4383 | if ( !current_user_can( 'edit_posts' ) ) |
| 4384 | return new IXR_Error( 401, __( 'Sorry, you do not have access to user data on this site.' ) ); |
| 4385 | |
| 4386 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4387 | do_action( 'xmlrpc_call', 'blogger.getUserInfo' ); |
| 4388 | |
| 4389 | $struct = array( |
| 4390 | 'nickname' => $user->nickname, |
| 4391 | 'userid' => $user->ID, |
| 4392 | 'url' => $user->user_url, |
| 4393 | 'lastname' => $user->last_name, |
| 4394 | 'firstname' => $user->first_name |
| 4395 | ); |
| 4396 | |
| Line | Code |
| 4424 | |
| 4425 | $post_data = get_post($post_ID, ARRAY_A); |
| 4426 | if ( ! $post_data ) |
| 4427 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4428 | |
| 4429 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
| 4430 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); |
| 4431 | |
| 4432 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4433 | do_action( 'xmlrpc_call', 'blogger.getPost' ); |
| 4434 | |
| 4435 | $categories = implode(',', wp_get_post_categories($post_ID)); |
| 4436 | |
| 4437 | $content = '<title>'.wp_unslash($post_data['post_title']).'</title>'; |
| 4438 | $content .= '<category>'.$categories.'</category>'; |
| 4439 | $content .= wp_unslash($post_data['post_content']); |
| 4440 | |
| 4441 | $struct = array( |
| 4442 | 'userid' => $post_data['post_author'], |
| Line | Code |
| 4477 | $query = array(); |
| 4478 | |
| 4479 | if ( !$user = $this->login($username, $password) ) |
| 4480 | return $this->error; |
| 4481 | |
| 4482 | if ( ! current_user_can( 'edit_posts' ) ) |
| 4483 | return new IXR_Error( 401, __( 'Sorry, you cannot edit posts on this site.' ) ); |
| 4484 | |
| 4485 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4486 | do_action( 'xmlrpc_call', 'blogger.getRecentPosts' ); |
| 4487 | |
| 4488 | $posts_list = wp_get_recent_posts( $query ); |
| 4489 | |
| 4490 | if ( !$posts_list ) { |
| 4491 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
| 4492 | return $this->error; |
| 4493 | } |
| 4494 | |
| 4495 | $recent_posts = array(); |
| Line | Code |
| 4560 | $username = $args[2]; |
| 4561 | $password = $args[3]; |
| 4562 | $content = $args[4]; |
| 4563 | $publish = $args[5]; |
| 4564 | |
| 4565 | if ( !$user = $this->login($username, $password) ) |
| 4566 | return $this->error; |
| 4567 | |
| 4568 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4569 | do_action( 'xmlrpc_call', 'blogger.newPost' ); |
| 4570 | |
| 4571 | $cap = ($publish) ? 'publish_posts' : 'edit_posts'; |
| 4572 | if ( ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) || !current_user_can($cap) ) |
| 4573 | return new IXR_Error(401, __('Sorry, you are not allowed to post on this site.')); |
| 4574 | |
| 4575 | $post_status = ($publish) ? 'publish' : 'draft'; |
| 4576 | |
| 4577 | $post_author = $user->ID; |
| 4578 | |
| Line | Code |
| 4633 | $password = $args[3]; |
| 4634 | $content = $args[4]; |
| 4635 | $publish = $args[5]; |
| 4636 | |
| 4637 | if ( ! $user = $this->login( $username, $password ) ) { |
| 4638 | return $this->error; |
| 4639 | } |
| 4640 | |
| 4641 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4642 | do_action( 'xmlrpc_call', 'blogger.editPost' ); |
| 4643 | |
| 4644 | $actual_post = get_post( $post_ID, ARRAY_A ); |
| 4645 | |
| 4646 | if ( ! $actual_post || $actual_post['post_type'] != 'post' ) { |
| 4647 | return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); |
| 4648 | } |
| 4649 | |
| 4650 | $this->escape($actual_post); |
| 4651 | |
| Line | Code |
| 4705 | |
| 4706 | $post_ID = (int) $args[1]; |
| 4707 | $username = $args[2]; |
| 4708 | $password = $args[3]; |
| 4709 | |
| 4710 | if ( !$user = $this->login($username, $password) ) |
| 4711 | return $this->error; |
| 4712 | |
| 4713 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4714 | do_action( 'xmlrpc_call', 'blogger.deletePost' ); |
| 4715 | |
| 4716 | $actual_post = get_post( $post_ID, ARRAY_A ); |
| 4717 | |
| 4718 | if ( ! $actual_post || $actual_post['post_type'] != 'post' ) { |
| 4719 | return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); |
| 4720 | } |
| 4721 | |
| 4722 | if ( ! current_user_can( 'delete_post', $post_ID ) ) { |
| 4723 | return new IXR_Error( 401, __( 'Sorry, you do not have the right to delete this post.' ) ); |
| Line | Code |
| 4790 | $username = $args[1]; |
| 4791 | $password = $args[2]; |
| 4792 | $content_struct = $args[3]; |
| 4793 | $publish = isset( $args[4] ) ? $args[4] : 0; |
| 4794 | |
| 4795 | if ( !$user = $this->login($username, $password) ) |
| 4796 | return $this->error; |
| 4797 | |
| 4798 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4799 | do_action( 'xmlrpc_call', 'metaWeblog.newPost' ); |
| 4800 | |
| 4801 | $page_template = ''; |
| 4802 | if ( !empty( $content_struct['post_type'] ) ) { |
| 4803 | if ( $content_struct['post_type'] == 'page' ) { |
| 4804 | if ( $publish ) |
| 4805 | $cap = 'publish_pages'; |
| 4806 | elseif ( isset( $content_struct['page_status'] ) && 'publish' == $content_struct['page_status'] ) |
| 4807 | $cap = 'publish_pages'; |
| 4808 | else |
| Line | Code |
| 5132 | $username = $args[1]; |
| 5133 | $password = $args[2]; |
| 5134 | $content_struct = $args[3]; |
| 5135 | $publish = isset( $args[4] ) ? $args[4] : 0; |
| 5136 | |
| 5137 | if ( ! $user = $this->login($username, $password) ) |
| 5138 | return $this->error; |
| 5139 | |
| 5140 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5141 | do_action( 'xmlrpc_call', 'metaWeblog.editPost' ); |
| 5142 | |
| 5143 | $postdata = get_post( $post_ID, ARRAY_A ); |
| 5144 | |
| 5145 | /* |
| 5146 | * If there is no post data for the give post id, stop now and return an error. |
| 5147 | * Otherwise a new post will be created (which was the old behavior). |
| 5148 | */ |
| 5149 | if ( ! $postdata || empty( $postdata[ 'ID' ] ) ) |
| 5150 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| Line | Code |
| 5438 | |
| 5439 | $postdata = get_post($post_ID, ARRAY_A); |
| 5440 | if ( ! $postdata ) |
| 5441 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 5442 | |
| 5443 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
| 5444 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); |
| 5445 | |
| 5446 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5447 | do_action( 'xmlrpc_call', 'metaWeblog.getPost' ); |
| 5448 | |
| 5449 | if ($postdata['post_date'] != '') { |
| 5450 | $post_date = $this->_convert_date( $postdata['post_date'] ); |
| 5451 | $post_date_gmt = $this->_convert_date_gmt( $postdata['post_date_gmt'], $postdata['post_date'] ); |
| 5452 | $post_modified = $this->_convert_date( $postdata['post_modified'] ); |
| 5453 | $post_modified_gmt = $this->_convert_date_gmt( $postdata['post_modified_gmt'], $postdata['post_modified'] ); |
| 5454 | |
| 5455 | $categories = array(); |
| 5456 | $catids = wp_get_post_categories($post_ID); |
| Line | Code |
| 5568 | $query = array(); |
| 5569 | |
| 5570 | if ( !$user = $this->login($username, $password) ) |
| 5571 | return $this->error; |
| 5572 | |
| 5573 | if ( ! current_user_can( 'edit_posts' ) ) |
| 5574 | return new IXR_Error( 401, __( 'Sorry, you cannot edit posts on this site.' ) ); |
| 5575 | |
| 5576 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5577 | do_action( 'xmlrpc_call', 'metaWeblog.getRecentPosts' ); |
| 5578 | |
| 5579 | $posts_list = wp_get_recent_posts( $query ); |
| 5580 | |
| 5581 | if ( !$posts_list ) |
| 5582 | return array(); |
| 5583 | |
| 5584 | $recent_posts = array(); |
| 5585 | foreach ($posts_list as $entry) { |
| 5586 | if ( !current_user_can( 'edit_post', $entry['ID'] ) ) |
| Line | Code |
| 5681 | $password = $args[2]; |
| 5682 | |
| 5683 | if ( !$user = $this->login($username, $password) ) |
| 5684 | return $this->error; |
| 5685 | |
| 5686 | if ( !current_user_can( 'edit_posts' ) ) |
| 5687 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
| 5688 | |
| 5689 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5690 | do_action( 'xmlrpc_call', 'metaWeblog.getCategories' ); |
| 5691 | |
| 5692 | $categories_struct = array(); |
| 5693 | |
| 5694 | if ( $cats = get_categories(array('get' => 'all')) ) { |
| 5695 | foreach ( $cats as $cat ) { |
| 5696 | $struct = array(); |
| 5697 | $struct['categoryId'] = $cat->term_id; |
| 5698 | $struct['parentId'] = $cat->parent; |
| 5699 | $struct['description'] = $cat->name; |
| Line | Code |
| 5739 | |
| 5740 | $name = sanitize_file_name( $data['name'] ); |
| 5741 | $type = $data['type']; |
| 5742 | $bits = $data['bits']; |
| 5743 | |
| 5744 | if ( !$user = $this->login($username, $password) ) |
| 5745 | return $this->error; |
| 5746 | |
| 5747 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5748 | do_action( 'xmlrpc_call', 'metaWeblog.newMediaObject' ); |
| 5749 | |
| 5750 | if ( !current_user_can('upload_files') ) { |
| 5751 | $this->error = new IXR_Error( 401, __( 'You do not have permission to upload files.' ) ); |
| 5752 | return $this->error; |
| 5753 | } |
| 5754 | |
| 5755 | if ( is_multisite() && upload_is_user_over_quota( false ) ) { |
| 5756 | $this->error = new IXR_Error( 401, __( 'Sorry, you have used your space allocation.' ) ); |
| 5757 | return $this->error; |
| Line | Code |
| 5844 | if ( isset( $args[3] ) ) |
| 5845 | $query = array( 'numberposts' => absint( $args[3] ) ); |
| 5846 | else |
| 5847 | $query = array(); |
| 5848 | |
| 5849 | if ( !$user = $this->login($username, $password) ) |
| 5850 | return $this->error; |
| 5851 | |
| 5852 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5853 | do_action( 'xmlrpc_call', 'mt.getRecentPostTitles' ); |
| 5854 | |
| 5855 | $posts_list = wp_get_recent_posts( $query ); |
| 5856 | |
| 5857 | if ( !$posts_list ) { |
| 5858 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
| 5859 | return $this->error; |
| 5860 | } |
| 5861 | |
| 5862 | $recent_posts = array(); |
| Line | Code |
| 5902 | $password = $args[2]; |
| 5903 | |
| 5904 | if ( !$user = $this->login($username, $password) ) |
| 5905 | return $this->error; |
| 5906 | |
| 5907 | if ( !current_user_can( 'edit_posts' ) ) |
| 5908 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
| 5909 | |
| 5910 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5911 | do_action( 'xmlrpc_call', 'mt.getCategoryList' ); |
| 5912 | |
| 5913 | $categories_struct = array(); |
| 5914 | |
| 5915 | if ( $cats = get_categories(array('hide_empty' => 0, 'hierarchical' => 0)) ) { |
| 5916 | foreach ( $cats as $cat ) { |
| 5917 | $struct = array(); |
| 5918 | $struct['categoryId'] = $cat->term_id; |
| 5919 | $struct['categoryName'] = $cat->name; |
| 5920 | |
| Line | Code |
| 5950 | return $this->error; |
| 5951 | |
| 5952 | if ( ! get_post( $post_ID ) ) |
| 5953 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 5954 | |
| 5955 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
| 5956 | return new IXR_Error( 401, __( 'Sorry, you can not edit this post.' ) ); |
| 5957 | |
| 5958 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5959 | do_action( 'xmlrpc_call', 'mt.getPostCategories' ); |
| 5960 | |
| 5961 | $categories = array(); |
| 5962 | $catids = wp_get_post_categories(intval($post_ID)); |
| 5963 | // first listed category will be the primary category |
| 5964 | $isPrimary = true; |
| 5965 | foreach ( $catids as $catid ) { |
| 5966 | $categories[] = array( |
| 5967 | 'categoryName' => get_cat_name($catid), |
| 5968 | 'categoryId' => (string) $catid, |
| Line | Code |
| 5995 | $post_ID = (int) $args[0]; |
| 5996 | $username = $args[1]; |
| 5997 | $password = $args[2]; |
| 5998 | $categories = $args[3]; |
| 5999 | |
| 6000 | if ( !$user = $this->login($username, $password) ) |
| 6001 | return $this->error; |
| 6002 | |
| 6003 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6004 | do_action( 'xmlrpc_call', 'mt.setPostCategories' ); |
| 6005 | |
| 6006 | if ( ! get_post( $post_ID ) ) |
| 6007 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 6008 | |
| 6009 | if ( !current_user_can('edit_post', $post_ID) ) |
| 6010 | return new IXR_Error(401, __('Sorry, you cannot edit this post.')); |
| 6011 | |
| 6012 | $catids = array(); |
| 6013 | foreach ( $categories as $cat ) { |
| Line | Code |
| 6022 | /** |
| 6023 | * Retrieve an array of methods supported by this server. |
| 6024 | * |
| 6025 | * @since 1.5.0 |
| 6026 | * |
| 6027 | * @return array |
| 6028 | */ |
| 6029 | public function mt_supportedMethods() { |
| 6030 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6031 | do_action( 'xmlrpc_call', 'mt.supportedMethods' ); |
| 6032 | |
| 6033 | return array_keys( $this->methods ); |
| 6034 | } |
| 6035 | |
| 6036 | /** |
| 6037 | * Retrieve an empty array because we don't support per-post text filters. |
| 6038 | * |
| 6039 | * @since 1.5.0 |
| 6040 | */ |
| 6041 | public function mt_supportedTextFilters() { |
| 6042 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6043 | do_action( 'xmlrpc_call', 'mt.supportedTextFilters' ); |
| 6044 | |
| 6045 | /** |
| 6046 | * Filter the MoveableType text filters list for XML-RPC. |
| 6047 | * |
| 6048 | * @since 2.2.0 |
| 6049 | * |
| 6050 | * @param array $filters An array of text filters. |
| 6051 | */ |
| 6052 | return apply_filters( 'xmlrpc_text_filters', array() ); |
| Line | Code |
| 6060 | * @global wpdb $wpdb WordPress database abstraction object. |
| 6061 | * |
| 6062 | * @param int $post_ID |
| 6063 | * @return array|IXR_Error |
| 6064 | */ |
| 6065 | public function mt_getTrackbackPings( $post_ID ) { |
| 6066 | global $wpdb; |
| 6067 | |
| 6068 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6069 | do_action( 'xmlrpc_call', 'mt.getTrackbackPings' ); |
| 6070 | |
| 6071 | $actual_post = get_post($post_ID, ARRAY_A); |
| 6072 | |
| 6073 | if ( !$actual_post ) |
| 6074 | return new IXR_Error(404, __('Sorry, no such post.')); |
| 6075 | |
| 6076 | $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) ); |
| 6077 | |
| 6078 | if ( !$comments ) |
| Line | Code |
| 6113 | |
| 6114 | $post_ID = (int) $args[0]; |
| 6115 | $username = $args[1]; |
| 6116 | $password = $args[2]; |
| 6117 | |
| 6118 | if ( !$user = $this->login($username, $password) ) |
| 6119 | return $this->error; |
| 6120 | |
| 6121 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6122 | do_action( 'xmlrpc_call', 'mt.publishPost' ); |
| 6123 | |
| 6124 | $postdata = get_post($post_ID, ARRAY_A); |
| 6125 | if ( ! $postdata ) |
| 6126 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 6127 | |
| 6128 | if ( !current_user_can('publish_posts') || !current_user_can('edit_post', $post_ID) ) |
| 6129 | return new IXR_Error(401, __('Sorry, you cannot publish this post.')); |
| 6130 | |
| 6131 | $postdata['post_status'] = 'publish'; |
| Line | Code |
| 6156 | * @type string $pagelinkedfrom |
| 6157 | * @type string $pagelinkedto |
| 6158 | * } |
| 6159 | * @return string|IXR_Error |
| 6160 | */ |
| 6161 | public function pingback_ping( $args ) { |
| 6162 | global $wpdb, $wp_version; |
| 6163 | |
| 6164 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6165 | do_action( 'xmlrpc_call', 'pingback.ping' ); |
| 6166 | |
| 6167 | $this->escape( $args ); |
| 6168 | |
| 6169 | $pagelinkedfrom = str_replace( '&', '&', $args[0] ); |
| 6170 | $pagelinkedto = str_replace( '&', '&', $args[1] ); |
| 6171 | $pagelinkedto = str_replace( '&', '&', $pagelinkedto ); |
| 6172 | |
| 6173 | /** |
| 6174 | * Filter the pingback source URI. |
| Line | Code |
| 6361 | * @global wpdb $wpdb WordPress database abstraction object. |
| 6362 | * |
| 6363 | * @param string $url |
| 6364 | * @return array|IXR_Error |
| 6365 | */ |
| 6366 | public function pingback_extensions_getPingbacks( $url ) { |
| 6367 | global $wpdb; |
| 6368 | |
| 6369 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6370 | do_action( 'xmlrpc_call', 'pingback.extensions.getPingbacks' ); |
| 6371 | |
| 6372 | $url = $this->escape( $url ); |
| 6373 | |
| 6374 | $post_ID = url_to_postid($url); |
| 6375 | if ( !$post_ID ) { |
| 6376 | // We aren't sure that the resource is available and/or pingback enabled |
| 6377 | return $this->pingback_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.' ) ); |
| 6378 | } |
| 6379 | |