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 |
|---|---|
| 671 | * the method logic begins. |
| 672 | * |
| 673 | * All built-in XML-RPC methods use the action xmlrpc_call, with a parameter |
| 674 | * equal to the method's name, e.g., wp.getUsersBlogs, wp.newPost, etc. |
| 675 | * |
| 676 | * @since 2.5.0 |
| 677 | * |
| 678 | * @param string $name The method name. |
| 679 | */ |
| 680 | do_action( 'xmlrpc_call', 'wp.getUsersBlogs' ); |
| 681 | |
| 682 | $blogs = (array) get_blogs_of_user( $user->ID ); |
| 683 | $struct = array(); |
| 684 | $primary_blog_id = 0; |
| 685 | $active_blog = get_active_blog_for_user( $user->ID ); |
| 686 | if ( $active_blog ) { |
| 687 | $primary_blog_id = (int) $active_blog->blog_id; |
| 688 | } |
| 689 | |
| Line | Code |
| 1273 | if ( isset( $content_struct['post_date_gmt'] ) && ! ( $content_struct['post_date_gmt'] instanceof IXR_Date ) ) { |
| 1274 | if ( $content_struct['post_date_gmt'] == '0000-00-00 00:00:00' || isset( $content_struct['post_date'] ) ) { |
| 1275 | unset( $content_struct['post_date_gmt'] ); |
| 1276 | } else { |
| 1277 | $content_struct['post_date_gmt'] = $this->_convert_date( $content_struct['post_date_gmt'] ); |
| 1278 | } |
| 1279 | } |
| 1280 | |
| 1281 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1282 | do_action( 'xmlrpc_call', 'wp.newPost' ); |
| 1283 | |
| 1284 | unset( $content_struct['ID'] ); |
| 1285 | |
| 1286 | return $this->_insert_post( $user, $content_struct ); |
| 1287 | } |
| 1288 | |
| 1289 | /** |
| 1290 | * Helper method for filtering out elements from an array. |
| 1291 | * |
| Line | Code |
| 1625 | $username = $args[1]; |
| 1626 | $password = $args[2]; |
| 1627 | $post_id = (int) $args[3]; |
| 1628 | $content_struct = $args[4]; |
| 1629 | |
| 1630 | if ( ! $user = $this->login( $username, $password ) ) |
| 1631 | return $this->error; |
| 1632 | |
| 1633 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1634 | do_action( 'xmlrpc_call', 'wp.editPost' ); |
| 1635 | |
| 1636 | $post = get_post( $post_id, ARRAY_A ); |
| 1637 | |
| 1638 | if ( empty( $post['ID'] ) ) |
| 1639 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 1640 | |
| 1641 | if ( isset( $content_struct['if_not_modified_since'] ) ) { |
| 1642 | // If the post has been modified since the date provided, return an error. |
| 1643 | if ( mysql2date( 'U', $post['post_modified_gmt'] ) > $content_struct['if_not_modified_since']->getTimestamp() ) { |
| Line | Code |
| 1692 | |
| 1693 | $username = $args[1]; |
| 1694 | $password = $args[2]; |
| 1695 | $post_id = (int) $args[3]; |
| 1696 | |
| 1697 | if ( ! $user = $this->login( $username, $password ) ) |
| 1698 | return $this->error; |
| 1699 | |
| 1700 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1701 | do_action( 'xmlrpc_call', 'wp.deletePost' ); |
| 1702 | |
| 1703 | $post = get_post( $post_id, ARRAY_A ); |
| 1704 | if ( empty( $post['ID'] ) ) { |
| 1705 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 1706 | } |
| 1707 | |
| 1708 | if ( ! current_user_can( 'delete_post', $post_id ) ) { |
| 1709 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) ); |
| 1710 | } |
| Line | Code |
| 1789 | * @param string $method Method name. |
| 1790 | */ |
| 1791 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPost' ); |
| 1792 | } |
| 1793 | |
| 1794 | if ( ! $user = $this->login( $username, $password ) ) |
| 1795 | return $this->error; |
| 1796 | |
| 1797 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1798 | do_action( 'xmlrpc_call', 'wp.getPost' ); |
| 1799 | |
| 1800 | $post = get_post( $post_id, ARRAY_A ); |
| 1801 | |
| 1802 | if ( empty( $post['ID'] ) ) |
| 1803 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 1804 | |
| 1805 | if ( ! current_user_can( 'edit_post', $post_id ) ) |
| 1806 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
| 1807 | |
| Line | Code |
| 1845 | } else { |
| 1846 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1847 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPosts' ); |
| 1848 | } |
| 1849 | |
| 1850 | if ( ! $user = $this->login( $username, $password ) ) |
| 1851 | return $this->error; |
| 1852 | |
| 1853 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1854 | do_action( 'xmlrpc_call', 'wp.getPosts' ); |
| 1855 | |
| 1856 | $query = array(); |
| 1857 | |
| 1858 | if ( isset( $filter['post_type'] ) ) { |
| 1859 | $post_type = get_post_type_object( $filter['post_type'] ); |
| 1860 | if ( ! ( (bool) $post_type ) ) |
| 1861 | return new IXR_Error( 403, __( 'Invalid post type.' ) ); |
| 1862 | } else { |
| 1863 | $post_type = get_post_type_object( 'post' ); |
| Line | Code |
| 1933 | |
| 1934 | $username = $args[1]; |
| 1935 | $password = $args[2]; |
| 1936 | $content_struct = $args[3]; |
| 1937 | |
| 1938 | if ( ! $user = $this->login( $username, $password ) ) |
| 1939 | return $this->error; |
| 1940 | |
| 1941 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1942 | do_action( 'xmlrpc_call', 'wp.newTerm' ); |
| 1943 | |
| 1944 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) |
| 1945 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 1946 | |
| 1947 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
| 1948 | |
| 1949 | if ( ! current_user_can( $taxonomy->cap->edit_terms ) ) { |
| 1950 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to create terms in this taxonomy.' ) ); |
| 1951 | } |
| Line | Code |
| 2026 | $username = $args[1]; |
| 2027 | $password = $args[2]; |
| 2028 | $term_id = (int) $args[3]; |
| 2029 | $content_struct = $args[4]; |
| 2030 | |
| 2031 | if ( ! $user = $this->login( $username, $password ) ) |
| 2032 | return $this->error; |
| 2033 | |
| 2034 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2035 | do_action( 'xmlrpc_call', 'wp.editTerm' ); |
| 2036 | |
| 2037 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) |
| 2038 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 2039 | |
| 2040 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
| 2041 | |
| 2042 | $taxonomy = (array) $taxonomy; |
| 2043 | |
| 2044 | // hold the data of the term |
| Line | Code |
| 2128 | $username = $args[1]; |
| 2129 | $password = $args[2]; |
| 2130 | $taxonomy = $args[3]; |
| 2131 | $term_id = (int) $args[4]; |
| 2132 | |
| 2133 | if ( ! $user = $this->login( $username, $password ) ) |
| 2134 | return $this->error; |
| 2135 | |
| 2136 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2137 | do_action( 'xmlrpc_call', 'wp.deleteTerm' ); |
| 2138 | |
| 2139 | if ( ! taxonomy_exists( $taxonomy ) ) |
| 2140 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 2141 | |
| 2142 | $taxonomy = get_taxonomy( $taxonomy ); |
| 2143 | $term = get_term( $term_id, $taxonomy->name ); |
| 2144 | |
| 2145 | if ( is_wp_error( $term ) ) |
| 2146 | return new IXR_Error( 500, $term->get_error_message() ); |
| Line | Code |
| 2199 | $username = $args[1]; |
| 2200 | $password = $args[2]; |
| 2201 | $taxonomy = $args[3]; |
| 2202 | $term_id = (int) $args[4]; |
| 2203 | |
| 2204 | if ( ! $user = $this->login( $username, $password ) ) |
| 2205 | return $this->error; |
| 2206 | |
| 2207 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2208 | do_action( 'xmlrpc_call', 'wp.getTerm' ); |
| 2209 | |
| 2210 | if ( ! taxonomy_exists( $taxonomy ) ) |
| 2211 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 2212 | |
| 2213 | $taxonomy = get_taxonomy( $taxonomy ); |
| 2214 | |
| 2215 | $term = get_term( $term_id , $taxonomy->name, ARRAY_A ); |
| 2216 | |
| 2217 | if ( is_wp_error( $term ) ) |
| Line | Code |
| 2258 | $username = $args[1]; |
| 2259 | $password = $args[2]; |
| 2260 | $taxonomy = $args[3]; |
| 2261 | $filter = isset( $args[4] ) ? $args[4] : array(); |
| 2262 | |
| 2263 | if ( ! $user = $this->login( $username, $password ) ) |
| 2264 | return $this->error; |
| 2265 | |
| 2266 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2267 | do_action( 'xmlrpc_call', 'wp.getTerms' ); |
| 2268 | |
| 2269 | if ( ! taxonomy_exists( $taxonomy ) ) |
| 2270 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 2271 | |
| 2272 | $taxonomy = get_taxonomy( $taxonomy ); |
| 2273 | |
| 2274 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
| 2275 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ) ); |
| 2276 | |
| Line | Code |
| 2353 | * @param string $method The method name. |
| 2354 | */ |
| 2355 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomy' ); |
| 2356 | } |
| 2357 | |
| 2358 | if ( ! $user = $this->login( $username, $password ) ) |
| 2359 | return $this->error; |
| 2360 | |
| 2361 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2362 | do_action( 'xmlrpc_call', 'wp.getTaxonomy' ); |
| 2363 | |
| 2364 | if ( ! taxonomy_exists( $taxonomy ) ) |
| 2365 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 2366 | |
| 2367 | $taxonomy = get_taxonomy( $taxonomy ); |
| 2368 | |
| 2369 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
| 2370 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ) ); |
| 2371 | |
| Line | Code |
| 2406 | } else { |
| 2407 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2408 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomies' ); |
| 2409 | } |
| 2410 | |
| 2411 | if ( ! $user = $this->login( $username, $password ) ) |
| 2412 | return $this->error; |
| 2413 | |
| 2414 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2415 | do_action( 'xmlrpc_call', 'wp.getTaxonomies' ); |
| 2416 | |
| 2417 | $taxonomies = get_taxonomies( $filter, 'objects' ); |
| 2418 | |
| 2419 | // holds all the taxonomy data |
| 2420 | $struct = array(); |
| 2421 | |
| 2422 | foreach ( $taxonomies as $taxonomy ) { |
| 2423 | // capability check for post_types |
| 2424 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
| Line | Code |
| 2488 | * @param string $method The method name. |
| 2489 | */ |
| 2490 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUser' ); |
| 2491 | } |
| 2492 | |
| 2493 | if ( ! $user = $this->login( $username, $password ) ) |
| 2494 | return $this->error; |
| 2495 | |
| 2496 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2497 | do_action( 'xmlrpc_call', 'wp.getUser' ); |
| 2498 | |
| 2499 | if ( ! current_user_can( 'edit_user', $user_id ) ) |
| 2500 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this user.' ) ); |
| 2501 | |
| 2502 | $user_data = get_userdata( $user_id ); |
| 2503 | |
| 2504 | if ( ! $user_data ) |
| 2505 | return new IXR_Error( 404, __( 'Invalid user ID.' ) ); |
| 2506 | |
| Line | Code |
| 2546 | } else { |
| 2547 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2548 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUsers' ); |
| 2549 | } |
| 2550 | |
| 2551 | if ( ! $user = $this->login( $username, $password ) ) |
| 2552 | return $this->error; |
| 2553 | |
| 2554 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2555 | do_action( 'xmlrpc_call', 'wp.getUsers' ); |
| 2556 | |
| 2557 | if ( ! current_user_can( 'list_users' ) ) |
| 2558 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to list users.' ) ); |
| 2559 | |
| 2560 | $query = array( 'fields' => 'all_with_meta' ); |
| 2561 | |
| 2562 | $query['number'] = ( isset( $filter['number'] ) ) ? absint( $filter['number'] ) : 50; |
| 2563 | $query['offset'] = ( isset( $filter['offset'] ) ) ? absint( $filter['offset'] ) : 0; |
| 2564 | |
| Line | Code |
| 2619 | } else { |
| 2620 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2621 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getProfile' ); |
| 2622 | } |
| 2623 | |
| 2624 | if ( ! $user = $this->login( $username, $password ) ) |
| 2625 | return $this->error; |
| 2626 | |
| 2627 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2628 | do_action( 'xmlrpc_call', 'wp.getProfile' ); |
| 2629 | |
| 2630 | if ( ! current_user_can( 'edit_user', $user->ID ) ) |
| 2631 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit your profile.' ) ); |
| 2632 | |
| 2633 | $user_data = get_userdata( $user->ID ); |
| 2634 | |
| 2635 | return $this->_prepare_user( $user_data, $fields ); |
| 2636 | } |
| 2637 | |
| Line | Code |
| 2665 | |
| 2666 | $username = $args[1]; |
| 2667 | $password = $args[2]; |
| 2668 | $content_struct = $args[3]; |
| 2669 | |
| 2670 | if ( ! $user = $this->login( $username, $password ) ) |
| 2671 | return $this->error; |
| 2672 | |
| 2673 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2674 | do_action( 'xmlrpc_call', 'wp.editProfile' ); |
| 2675 | |
| 2676 | if ( ! current_user_can( 'edit_user', $user->ID ) ) |
| 2677 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit your profile.' ) ); |
| 2678 | |
| 2679 | // holds data of the user |
| 2680 | $user_data = array(); |
| 2681 | $user_data['ID'] = $user->ID; |
| 2682 | |
| 2683 | // only set the user details if it was given |
| Line | Code |
| 2741 | |
| 2742 | $page = get_post($page_id); |
| 2743 | if ( ! $page ) |
| 2744 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 2745 | |
| 2746 | if ( !current_user_can( 'edit_page', $page_id ) ) |
| 2747 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this page.' ) ); |
| 2748 | |
| 2749 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2750 | do_action( 'xmlrpc_call', 'wp.getPage' ); |
| 2751 | |
| 2752 | // If we found the page then format the data. |
| 2753 | if ( $page->ID && ($page->post_type == 'page') ) { |
| 2754 | return $this->_prepare_page( $page ); |
| 2755 | } |
| 2756 | // If the page doesn't exist indicate that. |
| 2757 | else { |
| 2758 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
| 2759 | } |
| Line | Code |
| 2782 | $num_pages = isset($args[3]) ? (int) $args[3] : 10; |
| 2783 | |
| 2784 | if ( !$user = $this->login($username, $password) ) |
| 2785 | return $this->error; |
| 2786 | |
| 2787 | if ( !current_user_can( 'edit_pages' ) ) |
| 2788 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit pages.' ) ); |
| 2789 | |
| 2790 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2791 | do_action( 'xmlrpc_call', 'wp.getPages' ); |
| 2792 | |
| 2793 | $pages = get_posts( array('post_type' => 'page', 'post_status' => 'any', 'numberposts' => $num_pages) ); |
| 2794 | $num_pages = count($pages); |
| 2795 | |
| 2796 | // If we have pages, put together their info. |
| 2797 | if ( $num_pages >= 1 ) { |
| 2798 | $pages_struct = array(); |
| 2799 | |
| 2800 | foreach ($pages as $page) { |
| Line | Code |
| 2828 | public function wp_newPage( $args ) { |
| 2829 | // Items not escaped here will be escaped in newPost. |
| 2830 | $username = $this->escape( $args[1] ); |
| 2831 | $password = $this->escape( $args[2] ); |
| 2832 | |
| 2833 | if ( !$user = $this->login($username, $password) ) |
| 2834 | return $this->error; |
| 2835 | |
| 2836 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2837 | do_action( 'xmlrpc_call', 'wp.newPage' ); |
| 2838 | |
| 2839 | // Mark this as content for a page. |
| 2840 | $args[3]["post_type"] = 'page'; |
| 2841 | |
| 2842 | // Let mw_newPost do all of the heavy lifting. |
| 2843 | return $this->mw_newPost( $args ); |
| 2844 | } |
| 2845 | |
| 2846 | /** |
| Line | Code |
| 2863 | |
| 2864 | $username = $args[1]; |
| 2865 | $password = $args[2]; |
| 2866 | $page_id = (int) $args[3]; |
| 2867 | |
| 2868 | if ( !$user = $this->login($username, $password) ) |
| 2869 | return $this->error; |
| 2870 | |
| 2871 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2872 | do_action( 'xmlrpc_call', 'wp.deletePage' ); |
| 2873 | |
| 2874 | // Get the current page based on the page_id and |
| 2875 | // make sure it is a page and not a post. |
| 2876 | $actual_page = get_post($page_id, ARRAY_A); |
| 2877 | if ( !$actual_page || ($actual_page['post_type'] != 'page') ) |
| 2878 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
| 2879 | |
| 2880 | // Make sure the user can delete pages. |
| 2881 | if ( !current_user_can('delete_page', $page_id) ) |
| Line | Code |
| 2926 | |
| 2927 | $escaped_username = $this->escape( $username ); |
| 2928 | $escaped_password = $this->escape( $password ); |
| 2929 | |
| 2930 | if ( !$user = $this->login( $escaped_username, $escaped_password ) ) { |
| 2931 | return $this->error; |
| 2932 | } |
| 2933 | |
| 2934 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2935 | do_action( 'xmlrpc_call', 'wp.editPage' ); |
| 2936 | |
| 2937 | // Get the page data and make sure it is a page. |
| 2938 | $actual_page = get_post($page_id, ARRAY_A); |
| 2939 | if ( !$actual_page || ($actual_page['post_type'] != 'page') ) |
| 2940 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
| 2941 | |
| 2942 | // Make sure the user is allowed to edit pages. |
| 2943 | if ( !current_user_can('edit_page', $page_id) ) |
| 2944 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this page.' ) ); |
| Line | Code |
| 2984 | $password = $args[2]; |
| 2985 | |
| 2986 | if ( !$user = $this->login($username, $password) ) |
| 2987 | return $this->error; |
| 2988 | |
| 2989 | if ( !current_user_can( 'edit_pages' ) ) |
| 2990 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit pages.' ) ); |
| 2991 | |
| 2992 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2993 | do_action( 'xmlrpc_call', 'wp.getPageList' ); |
| 2994 | |
| 2995 | // Get list of pages ids and titles |
| 2996 | $page_list = $wpdb->get_results(" |
| 2997 | SELECT ID page_id, |
| 2998 | post_title page_title, |
| 2999 | post_parent page_parent_id, |
| 3000 | post_date_gmt, |
| 3001 | post_date, |
| 3002 | post_status |
| Line | Code |
| 3040 | $password = $args[2]; |
| 3041 | |
| 3042 | if ( !$user = $this->login($username, $password) ) |
| 3043 | return $this->error; |
| 3044 | |
| 3045 | if ( !current_user_can('edit_posts') ) |
| 3046 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
| 3047 | |
| 3048 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3049 | do_action( 'xmlrpc_call', 'wp.getAuthors' ); |
| 3050 | |
| 3051 | $authors = array(); |
| 3052 | foreach ( get_users( array( 'fields' => array('ID','user_login','display_name') ) ) as $user ) { |
| 3053 | $authors[] = array( |
| 3054 | 'user_id' => $user->ID, |
| 3055 | 'user_login' => $user->user_login, |
| 3056 | 'display_name' => $user->display_name |
| 3057 | ); |
| 3058 | } |
| Line | Code |
| 3081 | $password = $args[2]; |
| 3082 | |
| 3083 | if ( !$user = $this->login($username, $password) ) |
| 3084 | return $this->error; |
| 3085 | |
| 3086 | if ( !current_user_can( 'edit_posts' ) ) |
| 3087 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view tags.' ) ); |
| 3088 | |
| 3089 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3090 | do_action( 'xmlrpc_call', 'wp.getKeywords' ); |
| 3091 | |
| 3092 | $tags = array(); |
| 3093 | |
| 3094 | if ( $all_tags = get_tags() ) { |
| 3095 | foreach ( (array) $all_tags as $tag ) { |
| 3096 | $struct = array(); |
| 3097 | $struct['tag_id'] = $tag->term_id; |
| 3098 | $struct['name'] = $tag->name; |
| 3099 | $struct['count'] = $tag->count; |
| Line | Code |
| 3128 | |
| 3129 | $username = $args[1]; |
| 3130 | $password = $args[2]; |
| 3131 | $category = $args[3]; |
| 3132 | |
| 3133 | if ( !$user = $this->login($username, $password) ) |
| 3134 | return $this->error; |
| 3135 | |
| 3136 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3137 | do_action( 'xmlrpc_call', 'wp.newCategory' ); |
| 3138 | |
| 3139 | // Make sure the user is allowed to add a category. |
| 3140 | if ( ! current_user_can( 'manage_categories' ) ) { |
| 3141 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to add a category.' ) ); |
| 3142 | } |
| 3143 | |
| 3144 | // If no slug was provided make it empty so that |
| 3145 | // WordPress will generate one. |
| 3146 | if ( empty($category['slug']) ) |
| Line | Code |
| 3205 | |
| 3206 | $username = $args[1]; |
| 3207 | $password = $args[2]; |
| 3208 | $category_id = (int) $args[3]; |
| 3209 | |
| 3210 | if ( !$user = $this->login($username, $password) ) |
| 3211 | return $this->error; |
| 3212 | |
| 3213 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3214 | do_action( 'xmlrpc_call', 'wp.deleteCategory' ); |
| 3215 | |
| 3216 | if ( ! current_user_can( 'delete_term', $category_id ) ) { |
| 3217 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this category.' ) ); |
| 3218 | } |
| 3219 | |
| 3220 | $status = wp_delete_term( $category_id, 'category' ); |
| 3221 | |
| 3222 | if ( true == $status ) { |
| 3223 | /** |
| Line | Code |
| 3259 | $max_results = (int) $args[4]; |
| 3260 | |
| 3261 | if ( !$user = $this->login($username, $password) ) |
| 3262 | return $this->error; |
| 3263 | |
| 3264 | if ( !current_user_can( 'edit_posts' ) ) |
| 3265 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
| 3266 | |
| 3267 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3268 | do_action( 'xmlrpc_call', 'wp.suggestCategories' ); |
| 3269 | |
| 3270 | $category_suggestions = array(); |
| 3271 | $args = array('get' => 'all', 'number' => $max_results, 'name__like' => $category); |
| 3272 | foreach ( (array) get_categories($args) as $cat ) { |
| 3273 | $category_suggestions[] = array( |
| 3274 | 'category_id' => $cat->term_id, |
| 3275 | 'category_name' => $cat->name |
| 3276 | ); |
| 3277 | } |
| Line | Code |
| 3300 | $username = $args[1]; |
| 3301 | $password = $args[2]; |
| 3302 | $comment_id = (int) $args[3]; |
| 3303 | |
| 3304 | if ( ! $user = $this->login( $username, $password ) ) { |
| 3305 | return $this->error; |
| 3306 | } |
| 3307 | |
| 3308 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3309 | do_action( 'xmlrpc_call', 'wp.getComment' ); |
| 3310 | |
| 3311 | if ( ! $comment = get_comment( $comment_id ) ) { |
| 3312 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 3313 | } |
| 3314 | |
| 3315 | if ( ! current_user_can( 'edit_comment', $comment_id ) ) { |
| 3316 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) ); |
| 3317 | } |
| 3318 | |
| Line | Code |
| 3351 | $username = $args[1]; |
| 3352 | $password = $args[2]; |
| 3353 | $struct = isset( $args[3] ) ? $args[3] : array(); |
| 3354 | |
| 3355 | if ( ! $user = $this->login( $username, $password ) ) { |
| 3356 | return $this->error; |
| 3357 | } |
| 3358 | |
| 3359 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3360 | do_action( 'xmlrpc_call', 'wp.getComments' ); |
| 3361 | |
| 3362 | if ( isset( $struct['status'] ) ) { |
| 3363 | $status = $struct['status']; |
| 3364 | } else { |
| 3365 | $status = ''; |
| 3366 | } |
| 3367 | |
| 3368 | if ( ! current_user_can( 'moderate_comments' ) && 'approve' !== $status ) { |
| 3369 | return new IXR_Error( 401, __( 'Invalid comment status.' ) ); |
| Line | Code |
| 3443 | if ( ! get_comment( $comment_ID ) ) { |
| 3444 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 3445 | } |
| 3446 | |
| 3447 | if ( ! current_user_can( 'edit_comment', $comment_ID ) ) { |
| 3448 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to delete this comment.' ) ); |
| 3449 | } |
| 3450 | |
| 3451 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3452 | do_action( 'xmlrpc_call', 'wp.deleteComment' ); |
| 3453 | |
| 3454 | $status = wp_delete_comment( $comment_ID ); |
| 3455 | |
| 3456 | if ( $status ) { |
| 3457 | /** |
| 3458 | * Fires after a comment has been successfully deleted via XML-RPC. |
| 3459 | * |
| 3460 | * @since 3.4.0 |
| 3461 | * |
| Line | Code |
| 3510 | if ( ! get_comment( $comment_ID ) ) { |
| 3511 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 3512 | } |
| 3513 | |
| 3514 | if ( ! current_user_can( 'edit_comment', $comment_ID ) ) { |
| 3515 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) ); |
| 3516 | } |
| 3517 | |
| 3518 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3519 | do_action( 'xmlrpc_call', 'wp.editComment' ); |
| 3520 | |
| 3521 | if ( isset($content_struct['status']) ) { |
| 3522 | $statuses = get_comment_statuses(); |
| 3523 | $statuses = array_keys($statuses); |
| 3524 | |
| 3525 | if ( ! in_array($content_struct['status'], $statuses) ) |
| 3526 | return new IXR_Error( 401, __( 'Invalid comment status.' ) ); |
| 3527 | $comment_approved = $content_struct['status']; |
| 3528 | } |
| Line | Code |
| 3672 | return new IXR_Error( 403, __( 'Comment author name and email are required.' ) ); |
| 3673 | elseif ( !is_email($comment['comment_author_email']) ) |
| 3674 | return new IXR_Error( 403, __( 'A valid email address is required.' ) ); |
| 3675 | } |
| 3676 | } |
| 3677 | |
| 3678 | $comment['comment_parent'] = isset($content_struct['comment_parent']) ? absint($content_struct['comment_parent']) : 0; |
| 3679 | |
| 3680 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3681 | do_action( 'xmlrpc_call', 'wp.newComment' ); |
| 3682 | |
| 3683 | $comment_ID = wp_new_comment( $comment, true ); |
| 3684 | if ( is_wp_error( $comment_ID ) ) { |
| 3685 | return new IXR_Error( 403, $comment_ID->get_error_message() ); |
| 3686 | } |
| 3687 | |
| 3688 | if ( ! $comment_ID ) { |
| 3689 | return new IXR_Error( 403, __( 'An unidentified error has occurred.' ) ); |
| 3690 | } |
| Line | Code |
| 3725 | if ( ! $user = $this->login( $username, $password ) ) { |
| 3726 | return $this->error; |
| 3727 | } |
| 3728 | |
| 3729 | if ( ! current_user_can( 'publish_posts' ) ) { |
| 3730 | return new IXR_Error( 403, __( 'Sorry, you are not allowed access to details about this site.' ) ); |
| 3731 | } |
| 3732 | |
| 3733 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3734 | do_action( 'xmlrpc_call', 'wp.getCommentStatusList' ); |
| 3735 | |
| 3736 | return get_comment_statuses(); |
| 3737 | } |
| 3738 | |
| 3739 | /** |
| 3740 | * Retrieve comment count. |
| 3741 | * |
| 3742 | * @since 2.5.0 |
| 3743 | * |
| Line | Code |
| 3766 | if ( empty( $post['ID'] ) ) { |
| 3767 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 3768 | } |
| 3769 | |
| 3770 | if ( ! current_user_can( 'edit_post', $post_id ) ) { |
| 3771 | return new IXR_Error( 403, __( 'Sorry, you are not allowed access to details of this post.' ) ); |
| 3772 | } |
| 3773 | |
| 3774 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3775 | do_action( 'xmlrpc_call', 'wp.getCommentCount' ); |
| 3776 | |
| 3777 | $count = wp_count_comments( $post_id ); |
| 3778 | |
| 3779 | return array( |
| 3780 | 'approved' => $count->approved, |
| 3781 | 'awaiting_moderation' => $count->moderated, |
| 3782 | 'spam' => $count->spam, |
| 3783 | 'total_comments' => $count->total_comments |
| 3784 | ); |
| Line | Code |
| 3805 | $password = $args[2]; |
| 3806 | |
| 3807 | if ( !$user = $this->login($username, $password) ) |
| 3808 | return $this->error; |
| 3809 | |
| 3810 | if ( !current_user_can( 'edit_posts' ) ) |
| 3811 | return new IXR_Error( 403, __( 'Sorry, you are not allowed access to details about this site.' ) ); |
| 3812 | |
| 3813 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3814 | do_action( 'xmlrpc_call', 'wp.getPostStatusList' ); |
| 3815 | |
| 3816 | return get_post_statuses(); |
| 3817 | } |
| 3818 | |
| 3819 | /** |
| 3820 | * Retrieve page statuses. |
| 3821 | * |
| 3822 | * @since 2.5.0 |
| 3823 | * |
| Line | Code |
| 3837 | $password = $args[2]; |
| 3838 | |
| 3839 | if ( !$user = $this->login($username, $password) ) |
| 3840 | return $this->error; |
| 3841 | |
| 3842 | if ( !current_user_can( 'edit_pages' ) ) |
| 3843 | return new IXR_Error( 403, __( 'Sorry, you are not allowed access to details about this site.' ) ); |
| 3844 | |
| 3845 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3846 | do_action( 'xmlrpc_call', 'wp.getPageStatusList' ); |
| 3847 | |
| 3848 | return get_page_statuses(); |
| 3849 | } |
| 3850 | |
| 3851 | /** |
| 3852 | * Retrieve page templates. |
| 3853 | * |
| 3854 | * @since 2.6.0 |
| 3855 | * |
| Line | Code |
| 4015 | $attachment_id = (int) $args[3]; |
| 4016 | |
| 4017 | if ( !$user = $this->login($username, $password) ) |
| 4018 | return $this->error; |
| 4019 | |
| 4020 | if ( !current_user_can( 'upload_files' ) ) |
| 4021 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to upload files.' ) ); |
| 4022 | |
| 4023 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4024 | do_action( 'xmlrpc_call', 'wp.getMediaItem' ); |
| 4025 | |
| 4026 | if ( ! $attachment = get_post($attachment_id) ) |
| 4027 | return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); |
| 4028 | |
| 4029 | return $this->_prepare_media_item( $attachment ); |
| 4030 | } |
| 4031 | |
| 4032 | /** |
| 4033 | * Retrieves a collection of media library items (or attachments) |
| Line | Code |
| 4063 | $struct = isset( $args[3] ) ? $args[3] : array() ; |
| 4064 | |
| 4065 | if ( !$user = $this->login($username, $password) ) |
| 4066 | return $this->error; |
| 4067 | |
| 4068 | if ( !current_user_can( 'upload_files' ) ) |
| 4069 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to upload files.' ) ); |
| 4070 | |
| 4071 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4072 | do_action( 'xmlrpc_call', 'wp.getMediaLibrary' ); |
| 4073 | |
| 4074 | $parent_id = ( isset($struct['parent_id']) ) ? absint($struct['parent_id']) : '' ; |
| 4075 | $mime_type = ( isset($struct['mime_type']) ) ? $struct['mime_type'] : '' ; |
| 4076 | $offset = ( isset($struct['offset']) ) ? absint($struct['offset']) : 0 ; |
| 4077 | $number = ( isset($struct['number']) ) ? absint($struct['number']) : -1 ; |
| 4078 | |
| 4079 | $attachments = get_posts( array('post_type' => 'attachment', 'post_parent' => $parent_id, 'offset' => $offset, 'numberposts' => $number, 'post_mime_type' => $mime_type ) ); |
| 4080 | |
| 4081 | $attachments_struct = array(); |
| Line | Code |
| 4107 | $password = $args[2]; |
| 4108 | |
| 4109 | if ( !$user = $this->login( $username, $password ) ) |
| 4110 | return $this->error; |
| 4111 | |
| 4112 | if ( !current_user_can( 'edit_posts' ) ) |
| 4113 | return new IXR_Error( 403, __( 'Sorry, you are not allowed access to details about this site.' ) ); |
| 4114 | |
| 4115 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4116 | do_action( 'xmlrpc_call', 'wp.getPostFormats' ); |
| 4117 | |
| 4118 | $formats = get_post_format_strings(); |
| 4119 | |
| 4120 | // find out if they want a list of currently supports formats |
| 4121 | if ( isset( $args[3] ) && is_array( $args[3] ) ) { |
| 4122 | if ( $args[3]['show-supported'] ) { |
| 4123 | if ( current_theme_supports( 'post-formats' ) ) { |
| 4124 | $supported = get_theme_support( 'post-formats' ); |
| 4125 | |
| Line | Code |
| 4184 | * @param string $method The method name. |
| 4185 | */ |
| 4186 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostType' ); |
| 4187 | } |
| 4188 | |
| 4189 | if ( !$user = $this->login( $username, $password ) ) |
| 4190 | return $this->error; |
| 4191 | |
| 4192 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4193 | do_action( 'xmlrpc_call', 'wp.getPostType' ); |
| 4194 | |
| 4195 | if ( ! post_type_exists( $post_type_name ) ) |
| 4196 | return new IXR_Error( 403, __( 'Invalid post type.' ) ); |
| 4197 | |
| 4198 | $post_type = get_post_type_object( $post_type_name ); |
| 4199 | |
| 4200 | if ( ! current_user_can( $post_type->cap->edit_posts ) ) |
| 4201 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts in this post type.' ) ); |
| 4202 | |
| Line | Code |
| 4236 | } else { |
| 4237 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4238 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostTypes' ); |
| 4239 | } |
| 4240 | |
| 4241 | if ( ! $user = $this->login( $username, $password ) ) |
| 4242 | return $this->error; |
| 4243 | |
| 4244 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4245 | do_action( 'xmlrpc_call', 'wp.getPostTypes' ); |
| 4246 | |
| 4247 | $post_types = get_post_types( $filter, 'objects' ); |
| 4248 | |
| 4249 | $struct = array(); |
| 4250 | |
| 4251 | foreach ( $post_types as $post_type ) { |
| 4252 | if ( ! current_user_can( $post_type->cap->edit_posts ) ) |
| 4253 | continue; |
| 4254 | |
| Line | Code |
| 4302 | * @param string $method The method name. |
| 4303 | */ |
| 4304 | $fields = apply_filters( 'xmlrpc_default_revision_fields', array( 'post_date', 'post_date_gmt' ), 'wp.getRevisions' ); |
| 4305 | } |
| 4306 | |
| 4307 | if ( ! $user = $this->login( $username, $password ) ) |
| 4308 | return $this->error; |
| 4309 | |
| 4310 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4311 | do_action( 'xmlrpc_call', 'wp.getRevisions' ); |
| 4312 | |
| 4313 | if ( ! $post = get_post( $post_id ) ) |
| 4314 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4315 | |
| 4316 | if ( ! current_user_can( 'edit_post', $post_id ) ) |
| 4317 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
| 4318 | |
| 4319 | // Check if revisions are enabled. |
| 4320 | if ( ! wp_revisions_enabled( $post ) ) |
| Line | Code |
| 4366 | |
| 4367 | $username = $args[1]; |
| 4368 | $password = $args[2]; |
| 4369 | $revision_id = (int) $args[3]; |
| 4370 | |
| 4371 | if ( ! $user = $this->login( $username, $password ) ) |
| 4372 | return $this->error; |
| 4373 | |
| 4374 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4375 | do_action( 'xmlrpc_call', 'wp.restoreRevision' ); |
| 4376 | |
| 4377 | if ( ! $revision = wp_get_post_revision( $revision_id ) ) |
| 4378 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4379 | |
| 4380 | if ( wp_is_post_autosave( $revision ) ) |
| 4381 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4382 | |
| 4383 | if ( ! $post = get_post( $revision->post_parent ) ) |
| 4384 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| Line | Code |
| 4427 | $this->escape($args); |
| 4428 | |
| 4429 | $username = $args[1]; |
| 4430 | $password = $args[2]; |
| 4431 | |
| 4432 | if ( !$user = $this->login($username, $password) ) |
| 4433 | return $this->error; |
| 4434 | |
| 4435 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4436 | do_action( 'xmlrpc_call', 'blogger.getUsersBlogs' ); |
| 4437 | |
| 4438 | $is_admin = current_user_can('manage_options'); |
| 4439 | |
| 4440 | $struct = array( |
| 4441 | 'isAdmin' => $is_admin, |
| 4442 | 'url' => get_option('home') . '/', |
| 4443 | 'blogid' => '1', |
| 4444 | 'blogName' => get_option('blogname'), |
| 4445 | 'xmlrpc' => site_url( 'xmlrpc.php', 'rpc' ), |
| Line | Code |
| 4508 | $password = $args[2]; |
| 4509 | |
| 4510 | if ( !$user = $this->login($username, $password) ) |
| 4511 | return $this->error; |
| 4512 | |
| 4513 | if ( !current_user_can( 'edit_posts' ) ) |
| 4514 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to access user data on this site.' ) ); |
| 4515 | |
| 4516 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4517 | do_action( 'xmlrpc_call', 'blogger.getUserInfo' ); |
| 4518 | |
| 4519 | $struct = array( |
| 4520 | 'nickname' => $user->nickname, |
| 4521 | 'userid' => $user->ID, |
| 4522 | 'url' => $user->user_url, |
| 4523 | 'lastname' => $user->last_name, |
| 4524 | 'firstname' => $user->first_name |
| 4525 | ); |
| 4526 | |
| Line | Code |
| 4554 | |
| 4555 | $post_data = get_post($post_ID, ARRAY_A); |
| 4556 | if ( ! $post_data ) |
| 4557 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4558 | |
| 4559 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
| 4560 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
| 4561 | |
| 4562 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4563 | do_action( 'xmlrpc_call', 'blogger.getPost' ); |
| 4564 | |
| 4565 | $categories = implode(',', wp_get_post_categories($post_ID)); |
| 4566 | |
| 4567 | $content = '<title>'.wp_unslash($post_data['post_title']).'</title>'; |
| 4568 | $content .= '<category>'.$categories.'</category>'; |
| 4569 | $content .= wp_unslash($post_data['post_content']); |
| 4570 | |
| 4571 | $struct = array( |
| 4572 | 'userid' => $post_data['post_author'], |
| Line | Code |
| 4607 | $query = array(); |
| 4608 | |
| 4609 | if ( !$user = $this->login($username, $password) ) |
| 4610 | return $this->error; |
| 4611 | |
| 4612 | if ( ! current_user_can( 'edit_posts' ) ) |
| 4613 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
| 4614 | |
| 4615 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4616 | do_action( 'xmlrpc_call', 'blogger.getRecentPosts' ); |
| 4617 | |
| 4618 | $posts_list = wp_get_recent_posts( $query ); |
| 4619 | |
| 4620 | if ( !$posts_list ) { |
| 4621 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
| 4622 | return $this->error; |
| 4623 | } |
| 4624 | |
| 4625 | $recent_posts = array(); |
| Line | Code |
| 4694 | $username = $args[2]; |
| 4695 | $password = $args[3]; |
| 4696 | $content = $args[4]; |
| 4697 | $publish = $args[5]; |
| 4698 | |
| 4699 | if ( !$user = $this->login($username, $password) ) |
| 4700 | return $this->error; |
| 4701 | |
| 4702 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4703 | do_action( 'xmlrpc_call', 'blogger.newPost' ); |
| 4704 | |
| 4705 | $cap = ($publish) ? 'publish_posts' : 'edit_posts'; |
| 4706 | if ( ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) || !current_user_can($cap) ) |
| 4707 | return new IXR_Error(401, __('Sorry, you are not allowed to post on this site.')); |
| 4708 | |
| 4709 | $post_status = ($publish) ? 'publish' : 'draft'; |
| 4710 | |
| 4711 | $post_author = $user->ID; |
| 4712 | |
| Line | Code |
| 4767 | $password = $args[3]; |
| 4768 | $content = $args[4]; |
| 4769 | $publish = $args[5]; |
| 4770 | |
| 4771 | if ( ! $user = $this->login( $username, $password ) ) { |
| 4772 | return $this->error; |
| 4773 | } |
| 4774 | |
| 4775 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4776 | do_action( 'xmlrpc_call', 'blogger.editPost' ); |
| 4777 | |
| 4778 | $actual_post = get_post( $post_ID, ARRAY_A ); |
| 4779 | |
| 4780 | if ( ! $actual_post || $actual_post['post_type'] != 'post' ) { |
| 4781 | return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); |
| 4782 | } |
| 4783 | |
| 4784 | $this->escape($actual_post); |
| 4785 | |
| Line | Code |
| 4839 | |
| 4840 | $post_ID = (int) $args[1]; |
| 4841 | $username = $args[2]; |
| 4842 | $password = $args[3]; |
| 4843 | |
| 4844 | if ( !$user = $this->login($username, $password) ) |
| 4845 | return $this->error; |
| 4846 | |
| 4847 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4848 | do_action( 'xmlrpc_call', 'blogger.deletePost' ); |
| 4849 | |
| 4850 | $actual_post = get_post( $post_ID, ARRAY_A ); |
| 4851 | |
| 4852 | if ( ! $actual_post || $actual_post['post_type'] != 'post' ) { |
| 4853 | return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); |
| 4854 | } |
| 4855 | |
| 4856 | if ( ! current_user_can( 'delete_post', $post_ID ) ) { |
| 4857 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) ); |
| Line | Code |
| 4924 | $username = $args[1]; |
| 4925 | $password = $args[2]; |
| 4926 | $content_struct = $args[3]; |
| 4927 | $publish = isset( $args[4] ) ? $args[4] : 0; |
| 4928 | |
| 4929 | if ( !$user = $this->login($username, $password) ) |
| 4930 | return $this->error; |
| 4931 | |
| 4932 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4933 | do_action( 'xmlrpc_call', 'metaWeblog.newPost' ); |
| 4934 | |
| 4935 | $page_template = ''; |
| 4936 | if ( !empty( $content_struct['post_type'] ) ) { |
| 4937 | if ( $content_struct['post_type'] == 'page' ) { |
| 4938 | if ( $publish ) |
| 4939 | $cap = 'publish_pages'; |
| 4940 | elseif ( isset( $content_struct['page_status'] ) && 'publish' == $content_struct['page_status'] ) |
| 4941 | $cap = 'publish_pages'; |
| 4942 | else |
| Line | Code |
| 5270 | $username = $args[1]; |
| 5271 | $password = $args[2]; |
| 5272 | $content_struct = $args[3]; |
| 5273 | $publish = isset( $args[4] ) ? $args[4] : 0; |
| 5274 | |
| 5275 | if ( ! $user = $this->login($username, $password) ) |
| 5276 | return $this->error; |
| 5277 | |
| 5278 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5279 | do_action( 'xmlrpc_call', 'metaWeblog.editPost' ); |
| 5280 | |
| 5281 | $postdata = get_post( $post_ID, ARRAY_A ); |
| 5282 | |
| 5283 | /* |
| 5284 | * If there is no post data for the give post id, stop now and return an error. |
| 5285 | * Otherwise a new post will be created (which was the old behavior). |
| 5286 | */ |
| 5287 | if ( ! $postdata || empty( $postdata[ 'ID' ] ) ) |
| 5288 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| Line | Code |
| 5582 | |
| 5583 | $postdata = get_post($post_ID, ARRAY_A); |
| 5584 | if ( ! $postdata ) |
| 5585 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 5586 | |
| 5587 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
| 5588 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
| 5589 | |
| 5590 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5591 | do_action( 'xmlrpc_call', 'metaWeblog.getPost' ); |
| 5592 | |
| 5593 | if ($postdata['post_date'] != '') { |
| 5594 | $post_date = $this->_convert_date( $postdata['post_date'] ); |
| 5595 | $post_date_gmt = $this->_convert_date_gmt( $postdata['post_date_gmt'], $postdata['post_date'] ); |
| 5596 | $post_modified = $this->_convert_date( $postdata['post_modified'] ); |
| 5597 | $post_modified_gmt = $this->_convert_date_gmt( $postdata['post_modified_gmt'], $postdata['post_modified'] ); |
| 5598 | |
| 5599 | $categories = array(); |
| 5600 | $catids = wp_get_post_categories($post_ID); |
| Line | Code |
| 5712 | $query = array(); |
| 5713 | |
| 5714 | if ( !$user = $this->login($username, $password) ) |
| 5715 | return $this->error; |
| 5716 | |
| 5717 | if ( ! current_user_can( 'edit_posts' ) ) |
| 5718 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
| 5719 | |
| 5720 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5721 | do_action( 'xmlrpc_call', 'metaWeblog.getRecentPosts' ); |
| 5722 | |
| 5723 | $posts_list = wp_get_recent_posts( $query ); |
| 5724 | |
| 5725 | if ( !$posts_list ) |
| 5726 | return array(); |
| 5727 | |
| 5728 | $recent_posts = array(); |
| 5729 | foreach ($posts_list as $entry) { |
| 5730 | if ( !current_user_can( 'edit_post', $entry['ID'] ) ) |
| Line | Code |
| 5825 | $password = $args[2]; |
| 5826 | |
| 5827 | if ( !$user = $this->login($username, $password) ) |
| 5828 | return $this->error; |
| 5829 | |
| 5830 | if ( !current_user_can( 'edit_posts' ) ) |
| 5831 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
| 5832 | |
| 5833 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5834 | do_action( 'xmlrpc_call', 'metaWeblog.getCategories' ); |
| 5835 | |
| 5836 | $categories_struct = array(); |
| 5837 | |
| 5838 | if ( $cats = get_categories(array('get' => 'all')) ) { |
| 5839 | foreach ( $cats as $cat ) { |
| 5840 | $struct = array(); |
| 5841 | $struct['categoryId'] = $cat->term_id; |
| 5842 | $struct['parentId'] = $cat->parent; |
| 5843 | $struct['description'] = $cat->name; |
| Line | Code |
| 5883 | |
| 5884 | $name = sanitize_file_name( $data['name'] ); |
| 5885 | $type = $data['type']; |
| 5886 | $bits = $data['bits']; |
| 5887 | |
| 5888 | if ( !$user = $this->login($username, $password) ) |
| 5889 | return $this->error; |
| 5890 | |
| 5891 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5892 | do_action( 'xmlrpc_call', 'metaWeblog.newMediaObject' ); |
| 5893 | |
| 5894 | if ( !current_user_can('upload_files') ) { |
| 5895 | $this->error = new IXR_Error( 401, __( 'Sorry, you are not allowed to upload files.' ) ); |
| 5896 | return $this->error; |
| 5897 | } |
| 5898 | |
| 5899 | if ( is_multisite() && upload_is_user_over_quota( false ) ) { |
| 5900 | $this->error = new IXR_Error( 401, __( 'Sorry, you have used your space allocation.' ) ); |
| 5901 | return $this->error; |
| Line | Code |
| 5989 | if ( isset( $args[3] ) ) |
| 5990 | $query = array( 'numberposts' => absint( $args[3] ) ); |
| 5991 | else |
| 5992 | $query = array(); |
| 5993 | |
| 5994 | if ( !$user = $this->login($username, $password) ) |
| 5995 | return $this->error; |
| 5996 | |
| 5997 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5998 | do_action( 'xmlrpc_call', 'mt.getRecentPostTitles' ); |
| 5999 | |
| 6000 | $posts_list = wp_get_recent_posts( $query ); |
| 6001 | |
| 6002 | if ( !$posts_list ) { |
| 6003 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
| 6004 | return $this->error; |
| 6005 | } |
| 6006 | |
| 6007 | $recent_posts = array(); |
| Line | Code |
| 6047 | $password = $args[2]; |
| 6048 | |
| 6049 | if ( !$user = $this->login($username, $password) ) |
| 6050 | return $this->error; |
| 6051 | |
| 6052 | if ( !current_user_can( 'edit_posts' ) ) |
| 6053 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
| 6054 | |
| 6055 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6056 | do_action( 'xmlrpc_call', 'mt.getCategoryList' ); |
| 6057 | |
| 6058 | $categories_struct = array(); |
| 6059 | |
| 6060 | if ( $cats = get_categories(array('hide_empty' => 0, 'hierarchical' => 0)) ) { |
| 6061 | foreach ( $cats as $cat ) { |
| 6062 | $struct = array(); |
| 6063 | $struct['categoryId'] = $cat->term_id; |
| 6064 | $struct['categoryName'] = $cat->name; |
| 6065 | |
| Line | Code |
| 6095 | return $this->error; |
| 6096 | |
| 6097 | if ( ! get_post( $post_ID ) ) |
| 6098 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 6099 | |
| 6100 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
| 6101 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
| 6102 | |
| 6103 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6104 | do_action( 'xmlrpc_call', 'mt.getPostCategories' ); |
| 6105 | |
| 6106 | $categories = array(); |
| 6107 | $catids = wp_get_post_categories(intval($post_ID)); |
| 6108 | // first listed category will be the primary category |
| 6109 | $isPrimary = true; |
| 6110 | foreach ( $catids as $catid ) { |
| 6111 | $categories[] = array( |
| 6112 | 'categoryName' => get_cat_name($catid), |
| 6113 | 'categoryId' => (string) $catid, |
| Line | Code |
| 6140 | $post_ID = (int) $args[0]; |
| 6141 | $username = $args[1]; |
| 6142 | $password = $args[2]; |
| 6143 | $categories = $args[3]; |
| 6144 | |
| 6145 | if ( !$user = $this->login($username, $password) ) |
| 6146 | return $this->error; |
| 6147 | |
| 6148 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6149 | do_action( 'xmlrpc_call', 'mt.setPostCategories' ); |
| 6150 | |
| 6151 | if ( ! get_post( $post_ID ) ) |
| 6152 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 6153 | |
| 6154 | if ( !current_user_can('edit_post', $post_ID) ) |
| 6155 | return new IXR_Error(401, __('Sorry, you are not allowed to edit this post.')); |
| 6156 | |
| 6157 | $catids = array(); |
| 6158 | foreach ( $categories as $cat ) { |
| Line | Code |
| 6167 | /** |
| 6168 | * Retrieve an array of methods supported by this server. |
| 6169 | * |
| 6170 | * @since 1.5.0 |
| 6171 | * |
| 6172 | * @return array |
| 6173 | */ |
| 6174 | public function mt_supportedMethods() { |
| 6175 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6176 | do_action( 'xmlrpc_call', 'mt.supportedMethods' ); |
| 6177 | |
| 6178 | return array_keys( $this->methods ); |
| 6179 | } |
| 6180 | |
| 6181 | /** |
| 6182 | * Retrieve an empty array because we don't support per-post text filters. |
| 6183 | * |
| 6184 | * @since 1.5.0 |
| 6185 | */ |
| 6186 | public function mt_supportedTextFilters() { |
| 6187 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6188 | do_action( 'xmlrpc_call', 'mt.supportedTextFilters' ); |
| 6189 | |
| 6190 | /** |
| 6191 | * Filters the MoveableType text filters list for XML-RPC. |
| 6192 | * |
| 6193 | * @since 2.2.0 |
| 6194 | * |
| 6195 | * @param array $filters An array of text filters. |
| 6196 | */ |
| 6197 | return apply_filters( 'xmlrpc_text_filters', array() ); |
| Line | Code |
| 6205 | * @global wpdb $wpdb WordPress database abstraction object. |
| 6206 | * |
| 6207 | * @param int $post_ID |
| 6208 | * @return array|IXR_Error |
| 6209 | */ |
| 6210 | public function mt_getTrackbackPings( $post_ID ) { |
| 6211 | global $wpdb; |
| 6212 | |
| 6213 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6214 | do_action( 'xmlrpc_call', 'mt.getTrackbackPings' ); |
| 6215 | |
| 6216 | $actual_post = get_post($post_ID, ARRAY_A); |
| 6217 | |
| 6218 | if ( !$actual_post ) |
| 6219 | return new IXR_Error(404, __('Sorry, no such post.')); |
| 6220 | |
| 6221 | $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) ); |
| 6222 | |
| 6223 | if ( !$comments ) |
| Line | Code |
| 6258 | |
| 6259 | $post_ID = (int) $args[0]; |
| 6260 | $username = $args[1]; |
| 6261 | $password = $args[2]; |
| 6262 | |
| 6263 | if ( !$user = $this->login($username, $password) ) |
| 6264 | return $this->error; |
| 6265 | |
| 6266 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6267 | do_action( 'xmlrpc_call', 'mt.publishPost' ); |
| 6268 | |
| 6269 | $postdata = get_post($post_ID, ARRAY_A); |
| 6270 | if ( ! $postdata ) |
| 6271 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 6272 | |
| 6273 | if ( !current_user_can('publish_posts') || !current_user_can('edit_post', $post_ID) ) |
| 6274 | return new IXR_Error(401, __('Sorry, you are not allowed to publish this post.')); |
| 6275 | |
| 6276 | $postdata['post_status'] = 'publish'; |
| Line | Code |
| 6298 | * @type string $pagelinkedfrom |
| 6299 | * @type string $pagelinkedto |
| 6300 | * } |
| 6301 | * @return string|IXR_Error |
| 6302 | */ |
| 6303 | public function pingback_ping( $args ) { |
| 6304 | global $wpdb; |
| 6305 | |
| 6306 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6307 | do_action( 'xmlrpc_call', 'pingback.ping' ); |
| 6308 | |
| 6309 | $this->escape( $args ); |
| 6310 | |
| 6311 | $pagelinkedfrom = str_replace( '&', '&', $args[0] ); |
| 6312 | $pagelinkedto = str_replace( '&', '&', $args[1] ); |
| 6313 | $pagelinkedto = str_replace( '&', '&', $pagelinkedto ); |
| 6314 | |
| 6315 | /** |
| 6316 | * Filters the pingback source URI. |
| Line | Code |
| 6514 | * @global wpdb $wpdb WordPress database abstraction object. |
| 6515 | * |
| 6516 | * @param string $url |
| 6517 | * @return array|IXR_Error |
| 6518 | */ |
| 6519 | public function pingback_extensions_getPingbacks( $url ) { |
| 6520 | global $wpdb; |
| 6521 | |
| 6522 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6523 | do_action( 'xmlrpc_call', 'pingback.extensions.getPingbacks' ); |
| 6524 | |
| 6525 | $url = $this->escape( $url ); |
| 6526 | |
| 6527 | $post_ID = url_to_postid($url); |
| 6528 | if ( !$post_ID ) { |
| 6529 | // We aren't sure that the resource is available and/or pingback enabled |
| 6530 | 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.' ) ); |
| 6531 | } |
| 6532 | |