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 |
|---|---|
| 678 | * the method logic begins. |
| 679 | * |
| 680 | * All built-in XML-RPC methods use the action xmlrpc_call, with a parameter |
| 681 | * equal to the method's name, e.g., wp.getUsersBlogs, wp.newPost, etc. |
| 682 | * |
| 683 | * @since 2.5.0 |
| 684 | * |
| 685 | * @param string $name The method name. |
| 686 | */ |
| 687 | do_action( 'xmlrpc_call', 'wp.getUsersBlogs' ); |
| 688 | |
| 689 | $blogs = (array) get_blogs_of_user( $user->ID ); |
| 690 | $struct = array(); |
| 691 | $primary_blog_id = 0; |
| 692 | $active_blog = get_active_blog_for_user( $user->ID ); |
| 693 | if ( $active_blog ) { |
| 694 | $primary_blog_id = (int) $active_blog->blog_id; |
| 695 | } |
| 696 | |
| Line | Code |
| 1288 | if ( isset( $content_struct['post_date_gmt'] ) && ! ( $content_struct['post_date_gmt'] instanceof IXR_Date ) ) { |
| 1289 | if ( '0000-00-00 00:00:00' === $content_struct['post_date_gmt'] || isset( $content_struct['post_date'] ) ) { |
| 1290 | unset( $content_struct['post_date_gmt'] ); |
| 1291 | } else { |
| 1292 | $content_struct['post_date_gmt'] = $this->_convert_date( $content_struct['post_date_gmt'] ); |
| 1293 | } |
| 1294 | } |
| 1295 | |
| 1296 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1297 | do_action( 'xmlrpc_call', 'wp.newPost' ); |
| 1298 | |
| 1299 | unset( $content_struct['ID'] ); |
| 1300 | |
| 1301 | return $this->_insert_post( $user, $content_struct ); |
| 1302 | } |
| 1303 | |
| 1304 | /** |
| 1305 | * Helper method for filtering out elements from an array. |
| 1306 | * |
| Line | Code |
| 1681 | $post_id = (int) $args[3]; |
| 1682 | $content_struct = $args[4]; |
| 1683 | |
| 1684 | $user = $this->login( $username, $password ); |
| 1685 | if ( ! $user ) { |
| 1686 | return $this->error; |
| 1687 | } |
| 1688 | |
| 1689 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1690 | do_action( 'xmlrpc_call', 'wp.editPost' ); |
| 1691 | |
| 1692 | $post = get_post( $post_id, ARRAY_A ); |
| 1693 | |
| 1694 | if ( empty( $post['ID'] ) ) { |
| 1695 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 1696 | } |
| 1697 | |
| 1698 | if ( isset( $content_struct['if_not_modified_since'] ) ) { |
| 1699 | // If the post has been modified since the date provided, return an error. |
| Line | Code |
| 1764 | $password = $args[2]; |
| 1765 | $post_id = (int) $args[3]; |
| 1766 | |
| 1767 | $user = $this->login( $username, $password ); |
| 1768 | if ( ! $user ) { |
| 1769 | return $this->error; |
| 1770 | } |
| 1771 | |
| 1772 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1773 | do_action( 'xmlrpc_call', 'wp.deletePost' ); |
| 1774 | |
| 1775 | $post = get_post( $post_id, ARRAY_A ); |
| 1776 | if ( empty( $post['ID'] ) ) { |
| 1777 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 1778 | } |
| 1779 | |
| 1780 | if ( ! current_user_can( 'delete_post', $post_id ) ) { |
| 1781 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) ); |
| 1782 | } |
| Line | Code |
| 1864 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPost' ); |
| 1865 | } |
| 1866 | |
| 1867 | $user = $this->login( $username, $password ); |
| 1868 | if ( ! $user ) { |
| 1869 | return $this->error; |
| 1870 | } |
| 1871 | |
| 1872 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1873 | do_action( 'xmlrpc_call', 'wp.getPost' ); |
| 1874 | |
| 1875 | $post = get_post( $post_id, ARRAY_A ); |
| 1876 | |
| 1877 | if ( empty( $post['ID'] ) ) { |
| 1878 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 1879 | } |
| 1880 | |
| 1881 | if ( ! current_user_can( 'edit_post', $post_id ) ) { |
| 1882 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
| Line | Code |
| 1925 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPosts' ); |
| 1926 | } |
| 1927 | |
| 1928 | $user = $this->login( $username, $password ); |
| 1929 | if ( ! $user ) { |
| 1930 | return $this->error; |
| 1931 | } |
| 1932 | |
| 1933 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1934 | do_action( 'xmlrpc_call', 'wp.getPosts' ); |
| 1935 | |
| 1936 | $query = array(); |
| 1937 | |
| 1938 | if ( isset( $filter['post_type'] ) ) { |
| 1939 | $post_type = get_post_type_object( $filter['post_type'] ); |
| 1940 | if ( ! ( (bool) $post_type ) ) { |
| 1941 | return new IXR_Error( 403, __( 'Invalid post type.' ) ); |
| 1942 | } |
| 1943 | } else { |
| Line | Code |
| 2024 | $password = $args[2]; |
| 2025 | $content_struct = $args[3]; |
| 2026 | |
| 2027 | $user = $this->login( $username, $password ); |
| 2028 | if ( ! $user ) { |
| 2029 | return $this->error; |
| 2030 | } |
| 2031 | |
| 2032 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2033 | do_action( 'xmlrpc_call', 'wp.newTerm' ); |
| 2034 | |
| 2035 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) { |
| 2036 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 2037 | } |
| 2038 | |
| 2039 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
| 2040 | |
| 2041 | if ( ! current_user_can( $taxonomy->cap->edit_terms ) ) { |
| 2042 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to create terms in this taxonomy.' ) ); |
| Line | Code |
| 2129 | $term_id = (int) $args[3]; |
| 2130 | $content_struct = $args[4]; |
| 2131 | |
| 2132 | $user = $this->login( $username, $password ); |
| 2133 | if ( ! $user ) { |
| 2134 | return $this->error; |
| 2135 | } |
| 2136 | |
| 2137 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2138 | do_action( 'xmlrpc_call', 'wp.editTerm' ); |
| 2139 | |
| 2140 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) { |
| 2141 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 2142 | } |
| 2143 | |
| 2144 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
| 2145 | |
| 2146 | $taxonomy = (array) $taxonomy; |
| 2147 | |
| Line | Code |
| 2245 | $taxonomy = $args[3]; |
| 2246 | $term_id = (int) $args[4]; |
| 2247 | |
| 2248 | $user = $this->login( $username, $password ); |
| 2249 | if ( ! $user ) { |
| 2250 | return $this->error; |
| 2251 | } |
| 2252 | |
| 2253 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2254 | do_action( 'xmlrpc_call', 'wp.deleteTerm' ); |
| 2255 | |
| 2256 | if ( ! taxonomy_exists( $taxonomy ) ) { |
| 2257 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 2258 | } |
| 2259 | |
| 2260 | $taxonomy = get_taxonomy( $taxonomy ); |
| 2261 | $term = get_term( $term_id, $taxonomy->name ); |
| 2262 | |
| 2263 | if ( is_wp_error( $term ) ) { |
| Line | Code |
| 2324 | $taxonomy = $args[3]; |
| 2325 | $term_id = (int) $args[4]; |
| 2326 | |
| 2327 | $user = $this->login( $username, $password ); |
| 2328 | if ( ! $user ) { |
| 2329 | return $this->error; |
| 2330 | } |
| 2331 | |
| 2332 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2333 | do_action( 'xmlrpc_call', 'wp.getTerm' ); |
| 2334 | |
| 2335 | if ( ! taxonomy_exists( $taxonomy ) ) { |
| 2336 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 2337 | } |
| 2338 | |
| 2339 | $taxonomy = get_taxonomy( $taxonomy ); |
| 2340 | |
| 2341 | $term = get_term( $term_id, $taxonomy->name, ARRAY_A ); |
| 2342 | |
| Line | Code |
| 2389 | $taxonomy = $args[3]; |
| 2390 | $filter = isset( $args[4] ) ? $args[4] : array(); |
| 2391 | |
| 2392 | $user = $this->login( $username, $password ); |
| 2393 | if ( ! $user ) { |
| 2394 | return $this->error; |
| 2395 | } |
| 2396 | |
| 2397 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2398 | do_action( 'xmlrpc_call', 'wp.getTerms' ); |
| 2399 | |
| 2400 | if ( ! taxonomy_exists( $taxonomy ) ) { |
| 2401 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 2402 | } |
| 2403 | |
| 2404 | $taxonomy = get_taxonomy( $taxonomy ); |
| 2405 | |
| 2406 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) { |
| 2407 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ) ); |
| Line | Code |
| 2495 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomy' ); |
| 2496 | } |
| 2497 | |
| 2498 | $user = $this->login( $username, $password ); |
| 2499 | if ( ! $user ) { |
| 2500 | return $this->error; |
| 2501 | } |
| 2502 | |
| 2503 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2504 | do_action( 'xmlrpc_call', 'wp.getTaxonomy' ); |
| 2505 | |
| 2506 | if ( ! taxonomy_exists( $taxonomy ) ) { |
| 2507 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 2508 | } |
| 2509 | |
| 2510 | $taxonomy = get_taxonomy( $taxonomy ); |
| 2511 | |
| 2512 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) { |
| 2513 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ) ); |
| Line | Code |
| 2553 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomies' ); |
| 2554 | } |
| 2555 | |
| 2556 | $user = $this->login( $username, $password ); |
| 2557 | if ( ! $user ) { |
| 2558 | return $this->error; |
| 2559 | } |
| 2560 | |
| 2561 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2562 | do_action( 'xmlrpc_call', 'wp.getTaxonomies' ); |
| 2563 | |
| 2564 | $taxonomies = get_taxonomies( $filter, 'objects' ); |
| 2565 | |
| 2566 | // Holds all the taxonomy data. |
| 2567 | $struct = array(); |
| 2568 | |
| 2569 | foreach ( $taxonomies as $taxonomy ) { |
| 2570 | // Capability check for post types. |
| 2571 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) { |
| Line | Code |
| 2639 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUser' ); |
| 2640 | } |
| 2641 | |
| 2642 | $user = $this->login( $username, $password ); |
| 2643 | if ( ! $user ) { |
| 2644 | return $this->error; |
| 2645 | } |
| 2646 | |
| 2647 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2648 | do_action( 'xmlrpc_call', 'wp.getUser' ); |
| 2649 | |
| 2650 | if ( ! current_user_can( 'edit_user', $user_id ) ) { |
| 2651 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this user.' ) ); |
| 2652 | } |
| 2653 | |
| 2654 | $user_data = get_userdata( $user_id ); |
| 2655 | |
| 2656 | if ( ! $user_data ) { |
| 2657 | return new IXR_Error( 404, __( 'Invalid user ID.' ) ); |
| Line | Code |
| 2702 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUsers' ); |
| 2703 | } |
| 2704 | |
| 2705 | $user = $this->login( $username, $password ); |
| 2706 | if ( ! $user ) { |
| 2707 | return $this->error; |
| 2708 | } |
| 2709 | |
| 2710 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2711 | do_action( 'xmlrpc_call', 'wp.getUsers' ); |
| 2712 | |
| 2713 | if ( ! current_user_can( 'list_users' ) ) { |
| 2714 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to list users.' ) ); |
| 2715 | } |
| 2716 | |
| 2717 | $query = array( 'fields' => 'all_with_meta' ); |
| 2718 | |
| 2719 | $query['number'] = ( isset( $filter['number'] ) ) ? absint( $filter['number'] ) : 50; |
| 2720 | $query['offset'] = ( isset( $filter['offset'] ) ) ? absint( $filter['offset'] ) : 0; |
| Line | Code |
| 2782 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getProfile' ); |
| 2783 | } |
| 2784 | |
| 2785 | $user = $this->login( $username, $password ); |
| 2786 | if ( ! $user ) { |
| 2787 | return $this->error; |
| 2788 | } |
| 2789 | |
| 2790 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2791 | do_action( 'xmlrpc_call', 'wp.getProfile' ); |
| 2792 | |
| 2793 | if ( ! current_user_can( 'edit_user', $user->ID ) ) { |
| 2794 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit your profile.' ) ); |
| 2795 | } |
| 2796 | |
| 2797 | $user_data = get_userdata( $user->ID ); |
| 2798 | |
| 2799 | return $this->_prepare_user( $user_data, $fields ); |
| 2800 | } |
| Line | Code |
| 2832 | $password = $args[2]; |
| 2833 | $content_struct = $args[3]; |
| 2834 | |
| 2835 | $user = $this->login( $username, $password ); |
| 2836 | if ( ! $user ) { |
| 2837 | return $this->error; |
| 2838 | } |
| 2839 | |
| 2840 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2841 | do_action( 'xmlrpc_call', 'wp.editProfile' ); |
| 2842 | |
| 2843 | if ( ! current_user_can( 'edit_user', $user->ID ) ) { |
| 2844 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit your profile.' ) ); |
| 2845 | } |
| 2846 | |
| 2847 | // Holds data of the user. |
| 2848 | $user_data = array(); |
| 2849 | $user_data['ID'] = $user->ID; |
| 2850 | |
| Line | Code |
| 2921 | if ( ! $page ) { |
| 2922 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 2923 | } |
| 2924 | |
| 2925 | if ( ! current_user_can( 'edit_page', $page_id ) ) { |
| 2926 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this page.' ) ); |
| 2927 | } |
| 2928 | |
| 2929 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2930 | do_action( 'xmlrpc_call', 'wp.getPage' ); |
| 2931 | |
| 2932 | // If we found the page then format the data. |
| 2933 | if ( $page->ID && ( 'page' === $page->post_type ) ) { |
| 2934 | return $this->_prepare_page( $page ); |
| 2935 | } else { |
| 2936 | // If the page doesn't exist, indicate that. |
| 2937 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
| 2938 | } |
| 2939 | } |
| Line | Code |
| 2964 | if ( ! $user ) { |
| 2965 | return $this->error; |
| 2966 | } |
| 2967 | |
| 2968 | if ( ! current_user_can( 'edit_pages' ) ) { |
| 2969 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit pages.' ) ); |
| 2970 | } |
| 2971 | |
| 2972 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2973 | do_action( 'xmlrpc_call', 'wp.getPages' ); |
| 2974 | |
| 2975 | $pages = get_posts( |
| 2976 | array( |
| 2977 | 'post_type' => 'page', |
| 2978 | 'post_status' => 'any', |
| 2979 | 'numberposts' => $num_pages, |
| 2980 | ) |
| 2981 | ); |
| 2982 | $num_pages = count( $pages ); |
| Line | Code |
| 3019 | $username = $this->escape( $args[1] ); |
| 3020 | $password = $this->escape( $args[2] ); |
| 3021 | |
| 3022 | $user = $this->login( $username, $password ); |
| 3023 | if ( ! $user ) { |
| 3024 | return $this->error; |
| 3025 | } |
| 3026 | |
| 3027 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3028 | do_action( 'xmlrpc_call', 'wp.newPage' ); |
| 3029 | |
| 3030 | // Mark this as content for a page. |
| 3031 | $args[3]['post_type'] = 'page'; |
| 3032 | |
| 3033 | // Let mw_newPost() do all of the heavy lifting. |
| 3034 | return $this->mw_newPost( $args ); |
| 3035 | } |
| 3036 | |
| 3037 | /** |
| Line | Code |
| 3056 | $password = $args[2]; |
| 3057 | $page_id = (int) $args[3]; |
| 3058 | |
| 3059 | $user = $this->login( $username, $password ); |
| 3060 | if ( ! $user ) { |
| 3061 | return $this->error; |
| 3062 | } |
| 3063 | |
| 3064 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3065 | do_action( 'xmlrpc_call', 'wp.deletePage' ); |
| 3066 | |
| 3067 | // Get the current page based on the 'page_id' and |
| 3068 | // make sure it is a page and not a post. |
| 3069 | $actual_page = get_post( $page_id, ARRAY_A ); |
| 3070 | if ( ! $actual_page || ( 'page' !== $actual_page['post_type'] ) ) { |
| 3071 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
| 3072 | } |
| 3073 | |
| 3074 | // Make sure the user can delete pages. |
| Line | Code |
| 3123 | $escaped_username = $this->escape( $username ); |
| 3124 | $escaped_password = $this->escape( $password ); |
| 3125 | |
| 3126 | $user = $this->login( $escaped_username, $escaped_password ); |
| 3127 | if ( ! $user ) { |
| 3128 | return $this->error; |
| 3129 | } |
| 3130 | |
| 3131 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3132 | do_action( 'xmlrpc_call', 'wp.editPage' ); |
| 3133 | |
| 3134 | // Get the page data and make sure it is a page. |
| 3135 | $actual_page = get_post( $page_id, ARRAY_A ); |
| 3136 | if ( ! $actual_page || ( 'page' !== $actual_page['post_type'] ) ) { |
| 3137 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
| 3138 | } |
| 3139 | |
| 3140 | // Make sure the user is allowed to edit pages. |
| 3141 | if ( ! current_user_can( 'edit_page', $page_id ) ) { |
| Line | Code |
| 3186 | if ( ! $user ) { |
| 3187 | return $this->error; |
| 3188 | } |
| 3189 | |
| 3190 | if ( ! current_user_can( 'edit_pages' ) ) { |
| 3191 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit pages.' ) ); |
| 3192 | } |
| 3193 | |
| 3194 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3195 | do_action( 'xmlrpc_call', 'wp.getPageList' ); |
| 3196 | |
| 3197 | // Get list of page IDs and titles. |
| 3198 | $page_list = $wpdb->get_results( |
| 3199 | " |
| 3200 | SELECT ID page_id, |
| 3201 | post_title page_title, |
| 3202 | post_parent page_parent_id, |
| 3203 | post_date_gmt, |
| 3204 | post_date, |
| Line | Code |
| 3247 | if ( ! $user ) { |
| 3248 | return $this->error; |
| 3249 | } |
| 3250 | |
| 3251 | if ( ! current_user_can( 'edit_posts' ) ) { |
| 3252 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
| 3253 | } |
| 3254 | |
| 3255 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3256 | do_action( 'xmlrpc_call', 'wp.getAuthors' ); |
| 3257 | |
| 3258 | $authors = array(); |
| 3259 | foreach ( get_users( array( 'fields' => array( 'ID', 'user_login', 'display_name' ) ) ) as $user ) { |
| 3260 | $authors[] = array( |
| 3261 | 'user_id' => $user->ID, |
| 3262 | 'user_login' => $user->user_login, |
| 3263 | 'display_name' => $user->display_name, |
| 3264 | ); |
| 3265 | } |
| Line | Code |
| 3291 | if ( ! $user ) { |
| 3292 | return $this->error; |
| 3293 | } |
| 3294 | |
| 3295 | if ( ! current_user_can( 'edit_posts' ) ) { |
| 3296 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view tags.' ) ); |
| 3297 | } |
| 3298 | |
| 3299 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3300 | do_action( 'xmlrpc_call', 'wp.getKeywords' ); |
| 3301 | |
| 3302 | $tags = array(); |
| 3303 | |
| 3304 | $all_tags = get_tags(); |
| 3305 | if ( $all_tags ) { |
| 3306 | foreach ( (array) $all_tags as $tag ) { |
| 3307 | $struct = array(); |
| 3308 | $struct['tag_id'] = $tag->term_id; |
| 3309 | $struct['name'] = $tag->name; |
| Line | Code |
| 3341 | $password = $args[2]; |
| 3342 | $category = $args[3]; |
| 3343 | |
| 3344 | $user = $this->login( $username, $password ); |
| 3345 | if ( ! $user ) { |
| 3346 | return $this->error; |
| 3347 | } |
| 3348 | |
| 3349 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3350 | do_action( 'xmlrpc_call', 'wp.newCategory' ); |
| 3351 | |
| 3352 | // Make sure the user is allowed to add a category. |
| 3353 | if ( ! current_user_can( 'manage_categories' ) ) { |
| 3354 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to add a category.' ) ); |
| 3355 | } |
| 3356 | |
| 3357 | // If no slug was provided, make it empty |
| 3358 | // so that WordPress will generate one. |
| 3359 | if ( empty( $category['slug'] ) ) { |
| Line | Code |
| 3424 | $password = $args[2]; |
| 3425 | $category_id = (int) $args[3]; |
| 3426 | |
| 3427 | $user = $this->login( $username, $password ); |
| 3428 | if ( ! $user ) { |
| 3429 | return $this->error; |
| 3430 | } |
| 3431 | |
| 3432 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3433 | do_action( 'xmlrpc_call', 'wp.deleteCategory' ); |
| 3434 | |
| 3435 | if ( ! current_user_can( 'delete_term', $category_id ) ) { |
| 3436 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this category.' ) ); |
| 3437 | } |
| 3438 | |
| 3439 | $status = wp_delete_term( $category_id, 'category' ); |
| 3440 | |
| 3441 | if ( true == $status ) { |
| 3442 | /** |
| Line | Code |
| 3481 | if ( ! $user ) { |
| 3482 | return $this->error; |
| 3483 | } |
| 3484 | |
| 3485 | if ( ! current_user_can( 'edit_posts' ) ) { |
| 3486 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
| 3487 | } |
| 3488 | |
| 3489 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3490 | do_action( 'xmlrpc_call', 'wp.suggestCategories' ); |
| 3491 | |
| 3492 | $category_suggestions = array(); |
| 3493 | $args = array( |
| 3494 | 'get' => 'all', |
| 3495 | 'number' => $max_results, |
| 3496 | 'name__like' => $category, |
| 3497 | ); |
| 3498 | foreach ( (array) get_categories( $args ) as $cat ) { |
| 3499 | $category_suggestions[] = array( |
| Line | Code |
| 3527 | $password = $args[2]; |
| 3528 | $comment_id = (int) $args[3]; |
| 3529 | |
| 3530 | $user = $this->login( $username, $password ); |
| 3531 | if ( ! $user ) { |
| 3532 | return $this->error; |
| 3533 | } |
| 3534 | |
| 3535 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3536 | do_action( 'xmlrpc_call', 'wp.getComment' ); |
| 3537 | |
| 3538 | $comment = get_comment( $comment_id ); |
| 3539 | if ( ! $comment ) { |
| 3540 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 3541 | } |
| 3542 | |
| 3543 | if ( ! current_user_can( 'edit_comment', $comment_id ) ) { |
| 3544 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) ); |
| 3545 | } |
| Line | Code |
| 3580 | $password = $args[2]; |
| 3581 | $struct = isset( $args[3] ) ? $args[3] : array(); |
| 3582 | |
| 3583 | $user = $this->login( $username, $password ); |
| 3584 | if ( ! $user ) { |
| 3585 | return $this->error; |
| 3586 | } |
| 3587 | |
| 3588 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3589 | do_action( 'xmlrpc_call', 'wp.getComments' ); |
| 3590 | |
| 3591 | if ( isset( $struct['status'] ) ) { |
| 3592 | $status = $struct['status']; |
| 3593 | } else { |
| 3594 | $status = ''; |
| 3595 | } |
| 3596 | |
| 3597 | if ( ! current_user_can( 'moderate_comments' ) && 'approve' !== $status ) { |
| 3598 | return new IXR_Error( 401, __( 'Invalid comment status.' ) ); |
| Line | Code |
| 3675 | if ( ! get_comment( $comment_ID ) ) { |
| 3676 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 3677 | } |
| 3678 | |
| 3679 | if ( ! current_user_can( 'edit_comment', $comment_ID ) ) { |
| 3680 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to delete this comment.' ) ); |
| 3681 | } |
| 3682 | |
| 3683 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3684 | do_action( 'xmlrpc_call', 'wp.deleteComment' ); |
| 3685 | |
| 3686 | $status = wp_delete_comment( $comment_ID ); |
| 3687 | |
| 3688 | if ( $status ) { |
| 3689 | /** |
| 3690 | * Fires after a comment has been successfully deleted via XML-RPC. |
| 3691 | * |
| 3692 | * @since 3.4.0 |
| 3693 | * |
| Line | Code |
| 3743 | if ( ! get_comment( $comment_ID ) ) { |
| 3744 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 3745 | } |
| 3746 | |
| 3747 | if ( ! current_user_can( 'edit_comment', $comment_ID ) ) { |
| 3748 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) ); |
| 3749 | } |
| 3750 | |
| 3751 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3752 | do_action( 'xmlrpc_call', 'wp.editComment' ); |
| 3753 | $comment = array( |
| 3754 | 'comment_ID' => $comment_ID, |
| 3755 | ); |
| 3756 | |
| 3757 | if ( isset( $content_struct['status'] ) ) { |
| 3758 | $statuses = get_comment_statuses(); |
| 3759 | $statuses = array_keys( $statuses ); |
| 3760 | |
| 3761 | if ( ! in_array( $content_struct['status'], $statuses, true ) ) { |
| Line | Code |
| 3936 | |
| 3937 | /** This filter is documented in wp-includes/comment.php */ |
| 3938 | $allow_empty = apply_filters( 'allow_empty_comment', false, $comment ); |
| 3939 | |
| 3940 | if ( ! $allow_empty && '' === $comment['comment_content'] ) { |
| 3941 | return new IXR_Error( 403, __( 'Comment is required.' ) ); |
| 3942 | } |
| 3943 | |
| 3944 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3945 | do_action( 'xmlrpc_call', 'wp.newComment' ); |
| 3946 | |
| 3947 | $comment_ID = wp_new_comment( $comment, true ); |
| 3948 | if ( is_wp_error( $comment_ID ) ) { |
| 3949 | return new IXR_Error( 403, $comment_ID->get_error_message() ); |
| 3950 | } |
| 3951 | |
| 3952 | if ( ! $comment_ID ) { |
| 3953 | return new IXR_Error( 403, __( 'Something went wrong.' ) ); |
| 3954 | } |
| Line | Code |
| 3990 | if ( ! $user ) { |
| 3991 | return $this->error; |
| 3992 | } |
| 3993 | |
| 3994 | if ( ! current_user_can( 'publish_posts' ) ) { |
| 3995 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) ); |
| 3996 | } |
| 3997 | |
| 3998 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3999 | do_action( 'xmlrpc_call', 'wp.getCommentStatusList' ); |
| 4000 | |
| 4001 | return get_comment_statuses(); |
| 4002 | } |
| 4003 | |
| 4004 | /** |
| 4005 | * Retrieve comment count. |
| 4006 | * |
| 4007 | * @since 2.5.0 |
| 4008 | * |
| Line | Code |
| 4032 | if ( empty( $post['ID'] ) ) { |
| 4033 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4034 | } |
| 4035 | |
| 4036 | if ( ! current_user_can( 'edit_post', $post_id ) ) { |
| 4037 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details of this post.' ) ); |
| 4038 | } |
| 4039 | |
| 4040 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4041 | do_action( 'xmlrpc_call', 'wp.getCommentCount' ); |
| 4042 | |
| 4043 | $count = wp_count_comments( $post_id ); |
| 4044 | |
| 4045 | return array( |
| 4046 | 'approved' => $count->approved, |
| 4047 | 'awaiting_moderation' => $count->moderated, |
| 4048 | 'spam' => $count->spam, |
| 4049 | 'total_comments' => $count->total_comments, |
| 4050 | ); |
| Line | Code |
| 4074 | if ( ! $user ) { |
| 4075 | return $this->error; |
| 4076 | } |
| 4077 | |
| 4078 | if ( ! current_user_can( 'edit_posts' ) ) { |
| 4079 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) ); |
| 4080 | } |
| 4081 | |
| 4082 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4083 | do_action( 'xmlrpc_call', 'wp.getPostStatusList' ); |
| 4084 | |
| 4085 | return get_post_statuses(); |
| 4086 | } |
| 4087 | |
| 4088 | /** |
| 4089 | * Retrieve page statuses. |
| 4090 | * |
| 4091 | * @since 2.5.0 |
| 4092 | * |
| Line | Code |
| 4109 | if ( ! $user ) { |
| 4110 | return $this->error; |
| 4111 | } |
| 4112 | |
| 4113 | if ( ! current_user_can( 'edit_pages' ) ) { |
| 4114 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) ); |
| 4115 | } |
| 4116 | |
| 4117 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4118 | do_action( 'xmlrpc_call', 'wp.getPageStatusList' ); |
| 4119 | |
| 4120 | return get_page_statuses(); |
| 4121 | } |
| 4122 | |
| 4123 | /** |
| 4124 | * Retrieve page templates. |
| 4125 | * |
| 4126 | * @since 2.6.0 |
| 4127 | * |
| Line | Code |
| 4302 | if ( ! $user ) { |
| 4303 | return $this->error; |
| 4304 | } |
| 4305 | |
| 4306 | if ( ! current_user_can( 'upload_files' ) ) { |
| 4307 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to upload files.' ) ); |
| 4308 | } |
| 4309 | |
| 4310 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4311 | do_action( 'xmlrpc_call', 'wp.getMediaItem' ); |
| 4312 | |
| 4313 | $attachment = get_post( $attachment_id ); |
| 4314 | if ( ! $attachment || 'attachment' !== $attachment->post_type ) { |
| 4315 | return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); |
| 4316 | } |
| 4317 | |
| 4318 | return $this->_prepare_media_item( $attachment ); |
| 4319 | } |
| 4320 | |
| Line | Code |
| 4355 | if ( ! $user ) { |
| 4356 | return $this->error; |
| 4357 | } |
| 4358 | |
| 4359 | if ( ! current_user_can( 'upload_files' ) ) { |
| 4360 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to upload files.' ) ); |
| 4361 | } |
| 4362 | |
| 4363 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4364 | do_action( 'xmlrpc_call', 'wp.getMediaLibrary' ); |
| 4365 | |
| 4366 | $parent_id = ( isset( $struct['parent_id'] ) ) ? absint( $struct['parent_id'] ) : ''; |
| 4367 | $mime_type = ( isset( $struct['mime_type'] ) ) ? $struct['mime_type'] : ''; |
| 4368 | $offset = ( isset( $struct['offset'] ) ) ? absint( $struct['offset'] ) : 0; |
| 4369 | $number = ( isset( $struct['number'] ) ) ? absint( $struct['number'] ) : -1; |
| 4370 | |
| 4371 | $attachments = get_posts( |
| 4372 | array( |
| 4373 | 'post_type' => 'attachment', |
| Line | Code |
| 4411 | if ( ! $user ) { |
| 4412 | return $this->error; |
| 4413 | } |
| 4414 | |
| 4415 | if ( ! current_user_can( 'edit_posts' ) ) { |
| 4416 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) ); |
| 4417 | } |
| 4418 | |
| 4419 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4420 | do_action( 'xmlrpc_call', 'wp.getPostFormats' ); |
| 4421 | |
| 4422 | $formats = get_post_format_strings(); |
| 4423 | |
| 4424 | // Find out if they want a list of currently supports formats. |
| 4425 | if ( isset( $args[3] ) && is_array( $args[3] ) ) { |
| 4426 | if ( $args[3]['show-supported'] ) { |
| 4427 | if ( current_theme_supports( 'post-formats' ) ) { |
| 4428 | $supported = get_theme_support( 'post-formats' ); |
| 4429 | |
| Line | Code |
| 4491 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostType' ); |
| 4492 | } |
| 4493 | |
| 4494 | $user = $this->login( $username, $password ); |
| 4495 | if ( ! $user ) { |
| 4496 | return $this->error; |
| 4497 | } |
| 4498 | |
| 4499 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4500 | do_action( 'xmlrpc_call', 'wp.getPostType' ); |
| 4501 | |
| 4502 | if ( ! post_type_exists( $post_type_name ) ) { |
| 4503 | return new IXR_Error( 403, __( 'Invalid post type.' ) ); |
| 4504 | } |
| 4505 | |
| 4506 | $post_type = get_post_type_object( $post_type_name ); |
| 4507 | |
| 4508 | if ( ! current_user_can( $post_type->cap->edit_posts ) ) { |
| 4509 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts in this post type.' ) ); |
| Line | Code |
| 4548 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostTypes' ); |
| 4549 | } |
| 4550 | |
| 4551 | $user = $this->login( $username, $password ); |
| 4552 | if ( ! $user ) { |
| 4553 | return $this->error; |
| 4554 | } |
| 4555 | |
| 4556 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4557 | do_action( 'xmlrpc_call', 'wp.getPostTypes' ); |
| 4558 | |
| 4559 | $post_types = get_post_types( $filter, 'objects' ); |
| 4560 | |
| 4561 | $struct = array(); |
| 4562 | |
| 4563 | foreach ( $post_types as $post_type ) { |
| 4564 | if ( ! current_user_can( $post_type->cap->edit_posts ) ) { |
| 4565 | continue; |
| 4566 | } |
| Line | Code |
| 4618 | $fields = apply_filters( 'xmlrpc_default_revision_fields', array( 'post_date', 'post_date_gmt' ), 'wp.getRevisions' ); |
| 4619 | } |
| 4620 | |
| 4621 | $user = $this->login( $username, $password ); |
| 4622 | if ( ! $user ) { |
| 4623 | return $this->error; |
| 4624 | } |
| 4625 | |
| 4626 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4627 | do_action( 'xmlrpc_call', 'wp.getRevisions' ); |
| 4628 | |
| 4629 | $post = get_post( $post_id ); |
| 4630 | if ( ! $post ) { |
| 4631 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4632 | } |
| 4633 | |
| 4634 | if ( ! current_user_can( 'edit_post', $post_id ) ) { |
| 4635 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
| 4636 | } |
| Line | Code |
| 4692 | $password = $args[2]; |
| 4693 | $revision_id = (int) $args[3]; |
| 4694 | |
| 4695 | $user = $this->login( $username, $password ); |
| 4696 | if ( ! $user ) { |
| 4697 | return $this->error; |
| 4698 | } |
| 4699 | |
| 4700 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4701 | do_action( 'xmlrpc_call', 'wp.restoreRevision' ); |
| 4702 | |
| 4703 | $revision = wp_get_post_revision( $revision_id ); |
| 4704 | if ( ! $revision ) { |
| 4705 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4706 | } |
| 4707 | |
| 4708 | if ( wp_is_post_autosave( $revision ) ) { |
| 4709 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4710 | } |
| Line | Code |
| 4763 | $username = $args[1]; |
| 4764 | $password = $args[2]; |
| 4765 | |
| 4766 | $user = $this->login( $username, $password ); |
| 4767 | if ( ! $user ) { |
| 4768 | return $this->error; |
| 4769 | } |
| 4770 | |
| 4771 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4772 | do_action( 'xmlrpc_call', 'blogger.getUsersBlogs' ); |
| 4773 | |
| 4774 | $is_admin = current_user_can( 'manage_options' ); |
| 4775 | |
| 4776 | $struct = array( |
| 4777 | 'isAdmin' => $is_admin, |
| 4778 | 'url' => get_option( 'home' ) . '/', |
| 4779 | 'blogid' => '1', |
| 4780 | 'blogName' => get_option( 'blogname' ), |
| 4781 | 'xmlrpc' => site_url( 'xmlrpc.php', 'rpc' ), |
| Line | Code |
| 4849 | if ( ! $user ) { |
| 4850 | return $this->error; |
| 4851 | } |
| 4852 | |
| 4853 | if ( ! current_user_can( 'edit_posts' ) ) { |
| 4854 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to access user data on this site.' ) ); |
| 4855 | } |
| 4856 | |
| 4857 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4858 | do_action( 'xmlrpc_call', 'blogger.getUserInfo' ); |
| 4859 | |
| 4860 | $struct = array( |
| 4861 | 'nickname' => $user->nickname, |
| 4862 | 'userid' => $user->ID, |
| 4863 | 'url' => $user->user_url, |
| 4864 | 'lastname' => $user->last_name, |
| 4865 | 'firstname' => $user->first_name, |
| 4866 | ); |
| 4867 | |
| Line | Code |
| 4899 | if ( ! $post_data ) { |
| 4900 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4901 | } |
| 4902 | |
| 4903 | if ( ! current_user_can( 'edit_post', $post_ID ) ) { |
| 4904 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
| 4905 | } |
| 4906 | |
| 4907 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4908 | do_action( 'xmlrpc_call', 'blogger.getPost' ); |
| 4909 | |
| 4910 | $categories = implode( ',', wp_get_post_categories( $post_ID ) ); |
| 4911 | |
| 4912 | $content = '<title>' . wp_unslash( $post_data['post_title'] ) . '</title>'; |
| 4913 | $content .= '<category>' . $categories . '</category>'; |
| 4914 | $content .= wp_unslash( $post_data['post_content'] ); |
| 4915 | |
| 4916 | $struct = array( |
| 4917 | 'userid' => $post_data['post_author'], |
| Line | Code |
| 4956 | if ( ! $user ) { |
| 4957 | return $this->error; |
| 4958 | } |
| 4959 | |
| 4960 | if ( ! current_user_can( 'edit_posts' ) ) { |
| 4961 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
| 4962 | } |
| 4963 | |
| 4964 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4965 | do_action( 'xmlrpc_call', 'blogger.getRecentPosts' ); |
| 4966 | |
| 4967 | $posts_list = wp_get_recent_posts( $query ); |
| 4968 | |
| 4969 | if ( ! $posts_list ) { |
| 4970 | $this->error = new IXR_Error( 500, __( 'Either there are no posts, or something went wrong.' ) ); |
| 4971 | return $this->error; |
| 4972 | } |
| 4973 | |
| 4974 | $recent_posts = array(); |
| Line | Code |
| 5046 | $content = $args[4]; |
| 5047 | $publish = $args[5]; |
| 5048 | |
| 5049 | $user = $this->login( $username, $password ); |
| 5050 | if ( ! $user ) { |
| 5051 | return $this->error; |
| 5052 | } |
| 5053 | |
| 5054 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5055 | do_action( 'xmlrpc_call', 'blogger.newPost' ); |
| 5056 | |
| 5057 | $cap = ( $publish ) ? 'publish_posts' : 'edit_posts'; |
| 5058 | if ( ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) || ! current_user_can( $cap ) ) { |
| 5059 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to post on this site.' ) ); |
| 5060 | } |
| 5061 | |
| 5062 | $post_status = ( $publish ) ? 'publish' : 'draft'; |
| 5063 | |
| 5064 | $post_author = $user->ID; |
| Line | Code |
| 5123 | $content = $args[4]; |
| 5124 | $publish = $args[5]; |
| 5125 | |
| 5126 | $user = $this->login( $username, $password ); |
| 5127 | if ( ! $user ) { |
| 5128 | return $this->error; |
| 5129 | } |
| 5130 | |
| 5131 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5132 | do_action( 'xmlrpc_call', 'blogger.editPost' ); |
| 5133 | |
| 5134 | $actual_post = get_post( $post_ID, ARRAY_A ); |
| 5135 | |
| 5136 | if ( ! $actual_post || 'post' !== $actual_post['post_type'] ) { |
| 5137 | return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); |
| 5138 | } |
| 5139 | |
| 5140 | $this->escape( $actual_post ); |
| 5141 | |
| Line | Code |
| 5197 | $username = $args[2]; |
| 5198 | $password = $args[3]; |
| 5199 | |
| 5200 | $user = $this->login( $username, $password ); |
| 5201 | if ( ! $user ) { |
| 5202 | return $this->error; |
| 5203 | } |
| 5204 | |
| 5205 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5206 | do_action( 'xmlrpc_call', 'blogger.deletePost' ); |
| 5207 | |
| 5208 | $actual_post = get_post( $post_ID, ARRAY_A ); |
| 5209 | |
| 5210 | if ( ! $actual_post || 'post' !== $actual_post['post_type'] ) { |
| 5211 | return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); |
| 5212 | } |
| 5213 | |
| 5214 | if ( ! current_user_can( 'delete_post', $post_ID ) ) { |
| 5215 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) ); |
| Line | Code |
| 5285 | $content_struct = $args[3]; |
| 5286 | $publish = isset( $args[4] ) ? $args[4] : 0; |
| 5287 | |
| 5288 | $user = $this->login( $username, $password ); |
| 5289 | if ( ! $user ) { |
| 5290 | return $this->error; |
| 5291 | } |
| 5292 | |
| 5293 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5294 | do_action( 'xmlrpc_call', 'metaWeblog.newPost' ); |
| 5295 | |
| 5296 | $page_template = ''; |
| 5297 | if ( ! empty( $content_struct['post_type'] ) ) { |
| 5298 | if ( 'page' === $content_struct['post_type'] ) { |
| 5299 | if ( $publish ) { |
| 5300 | $cap = 'publish_pages'; |
| 5301 | } elseif ( isset( $content_struct['page_status'] ) && 'publish' === $content_struct['page_status'] ) { |
| 5302 | $cap = 'publish_pages'; |
| 5303 | } else { |
| Line | Code |
| 5664 | $content_struct = $args[3]; |
| 5665 | $publish = isset( $args[4] ) ? $args[4] : 0; |
| 5666 | |
| 5667 | $user = $this->login( $username, $password ); |
| 5668 | if ( ! $user ) { |
| 5669 | return $this->error; |
| 5670 | } |
| 5671 | |
| 5672 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5673 | do_action( 'xmlrpc_call', 'metaWeblog.editPost' ); |
| 5674 | |
| 5675 | $postdata = get_post( $post_ID, ARRAY_A ); |
| 5676 | |
| 5677 | /* |
| 5678 | * If there is no post data for the give post ID, stop now and return an error. |
| 5679 | * Otherwise a new post will be created (which was the old behavior). |
| 5680 | */ |
| 5681 | if ( ! $postdata || empty( $postdata['ID'] ) ) { |
| 5682 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| Line | Code |
| 6002 | if ( ! $postdata ) { |
| 6003 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 6004 | } |
| 6005 | |
| 6006 | if ( ! current_user_can( 'edit_post', $post_ID ) ) { |
| 6007 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
| 6008 | } |
| 6009 | |
| 6010 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6011 | do_action( 'xmlrpc_call', 'metaWeblog.getPost' ); |
| 6012 | |
| 6013 | if ( '' !== $postdata['post_date'] ) { |
| 6014 | $post_date = $this->_convert_date( $postdata['post_date'] ); |
| 6015 | $post_date_gmt = $this->_convert_date_gmt( $postdata['post_date_gmt'], $postdata['post_date'] ); |
| 6016 | $post_modified = $this->_convert_date( $postdata['post_modified'] ); |
| 6017 | $post_modified_gmt = $this->_convert_date_gmt( $postdata['post_modified_gmt'], $postdata['post_modified'] ); |
| 6018 | |
| 6019 | $categories = array(); |
| 6020 | $catids = wp_get_post_categories( $post_ID ); |
| Line | Code |
| 6143 | if ( ! $user ) { |
| 6144 | return $this->error; |
| 6145 | } |
| 6146 | |
| 6147 | if ( ! current_user_can( 'edit_posts' ) ) { |
| 6148 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
| 6149 | } |
| 6150 | |
| 6151 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6152 | do_action( 'xmlrpc_call', 'metaWeblog.getRecentPosts' ); |
| 6153 | |
| 6154 | $posts_list = wp_get_recent_posts( $query ); |
| 6155 | |
| 6156 | if ( ! $posts_list ) { |
| 6157 | return array(); |
| 6158 | } |
| 6159 | |
| 6160 | $recent_posts = array(); |
| 6161 | foreach ( $posts_list as $entry ) { |
| Line | Code |
| 6264 | if ( ! $user ) { |
| 6265 | return $this->error; |
| 6266 | } |
| 6267 | |
| 6268 | if ( ! current_user_can( 'edit_posts' ) ) { |
| 6269 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
| 6270 | } |
| 6271 | |
| 6272 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6273 | do_action( 'xmlrpc_call', 'metaWeblog.getCategories' ); |
| 6274 | |
| 6275 | $categories_struct = array(); |
| 6276 | |
| 6277 | $cats = get_categories( array( 'get' => 'all' ) ); |
| 6278 | if ( $cats ) { |
| 6279 | foreach ( $cats as $cat ) { |
| 6280 | $struct = array(); |
| 6281 | $struct['categoryId'] = $cat->term_id; |
| 6282 | $struct['parentId'] = $cat->parent; |
| Line | Code |
| 6325 | $type = $data['type']; |
| 6326 | $bits = $data['bits']; |
| 6327 | |
| 6328 | $user = $this->login( $username, $password ); |
| 6329 | if ( ! $user ) { |
| 6330 | return $this->error; |
| 6331 | } |
| 6332 | |
| 6333 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6334 | do_action( 'xmlrpc_call', 'metaWeblog.newMediaObject' ); |
| 6335 | |
| 6336 | if ( ! current_user_can( 'upload_files' ) ) { |
| 6337 | $this->error = new IXR_Error( 401, __( 'Sorry, you are not allowed to upload files.' ) ); |
| 6338 | return $this->error; |
| 6339 | } |
| 6340 | |
| 6341 | if ( is_multisite() && upload_is_user_over_quota( false ) ) { |
| 6342 | $this->error = new IXR_Error( |
| 6343 | 401, |
| Line | Code |
| 6444 | $query = array(); |
| 6445 | } |
| 6446 | |
| 6447 | $user = $this->login( $username, $password ); |
| 6448 | if ( ! $user ) { |
| 6449 | return $this->error; |
| 6450 | } |
| 6451 | |
| 6452 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6453 | do_action( 'xmlrpc_call', 'mt.getRecentPostTitles' ); |
| 6454 | |
| 6455 | $posts_list = wp_get_recent_posts( $query ); |
| 6456 | |
| 6457 | if ( ! $posts_list ) { |
| 6458 | $this->error = new IXR_Error( 500, __( 'Either there are no posts, or something went wrong.' ) ); |
| 6459 | return $this->error; |
| 6460 | } |
| 6461 | |
| 6462 | $recent_posts = array(); |
| Line | Code |
| 6506 | if ( ! $user ) { |
| 6507 | return $this->error; |
| 6508 | } |
| 6509 | |
| 6510 | if ( ! current_user_can( 'edit_posts' ) ) { |
| 6511 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
| 6512 | } |
| 6513 | |
| 6514 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6515 | do_action( 'xmlrpc_call', 'mt.getCategoryList' ); |
| 6516 | |
| 6517 | $categories_struct = array(); |
| 6518 | |
| 6519 | $cats = get_categories( |
| 6520 | array( |
| 6521 | 'hide_empty' => 0, |
| 6522 | 'hierarchical' => 0, |
| 6523 | ) |
| 6524 | ); |
| Line | Code |
| 6564 | if ( ! get_post( $post_ID ) ) { |
| 6565 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 6566 | } |
| 6567 | |
| 6568 | if ( ! current_user_can( 'edit_post', $post_ID ) ) { |
| 6569 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
| 6570 | } |
| 6571 | |
| 6572 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6573 | do_action( 'xmlrpc_call', 'mt.getPostCategories' ); |
| 6574 | |
| 6575 | $categories = array(); |
| 6576 | $catids = wp_get_post_categories( (int) $post_ID ); |
| 6577 | // First listed category will be the primary category. |
| 6578 | $isPrimary = true; |
| 6579 | foreach ( $catids as $catid ) { |
| 6580 | $categories[] = array( |
| 6581 | 'categoryName' => get_cat_name( $catid ), |
| 6582 | 'categoryId' => (string) $catid, |
| Line | Code |
| 6611 | $password = $args[2]; |
| 6612 | $categories = $args[3]; |
| 6613 | |
| 6614 | $user = $this->login( $username, $password ); |
| 6615 | if ( ! $user ) { |
| 6616 | return $this->error; |
| 6617 | } |
| 6618 | |
| 6619 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6620 | do_action( 'xmlrpc_call', 'mt.setPostCategories' ); |
| 6621 | |
| 6622 | if ( ! get_post( $post_ID ) ) { |
| 6623 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 6624 | } |
| 6625 | |
| 6626 | if ( ! current_user_can( 'edit_post', $post_ID ) ) { |
| 6627 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
| 6628 | } |
| 6629 | |
| Line | Code |
| 6640 | /** |
| 6641 | * Retrieve an array of methods supported by this server. |
| 6642 | * |
| 6643 | * @since 1.5.0 |
| 6644 | * |
| 6645 | * @return array |
| 6646 | */ |
| 6647 | public function mt_supportedMethods() { |
| 6648 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6649 | do_action( 'xmlrpc_call', 'mt.supportedMethods' ); |
| 6650 | |
| 6651 | return array_keys( $this->methods ); |
| 6652 | } |
| 6653 | |
| 6654 | /** |
| 6655 | * Retrieve an empty array because we don't support per-post text filters. |
| 6656 | * |
| 6657 | * @since 1.5.0 |
| 6658 | */ |
| 6659 | public function mt_supportedTextFilters() { |
| 6660 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6661 | do_action( 'xmlrpc_call', 'mt.supportedTextFilters' ); |
| 6662 | |
| 6663 | /** |
| 6664 | * Filters the MoveableType text filters list for XML-RPC. |
| 6665 | * |
| 6666 | * @since 2.2.0 |
| 6667 | * |
| 6668 | * @param array $filters An array of text filters. |
| 6669 | */ |
| 6670 | return apply_filters( 'xmlrpc_text_filters', array() ); |
| Line | Code |
| 6678 | * @global wpdb $wpdb WordPress database abstraction object. |
| 6679 | * |
| 6680 | * @param int $post_ID |
| 6681 | * @return array|IXR_Error |
| 6682 | */ |
| 6683 | public function mt_getTrackbackPings( $post_ID ) { |
| 6684 | global $wpdb; |
| 6685 | |
| 6686 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6687 | do_action( 'xmlrpc_call', 'mt.getTrackbackPings' ); |
| 6688 | |
| 6689 | $actual_post = get_post( $post_ID, ARRAY_A ); |
| 6690 | |
| 6691 | if ( ! $actual_post ) { |
| 6692 | return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); |
| 6693 | } |
| 6694 | |
| 6695 | $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 ) ); |
| 6696 | |
| Line | Code |
| 6735 | $username = $args[1]; |
| 6736 | $password = $args[2]; |
| 6737 | |
| 6738 | $user = $this->login( $username, $password ); |
| 6739 | if ( ! $user ) { |
| 6740 | return $this->error; |
| 6741 | } |
| 6742 | |
| 6743 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6744 | do_action( 'xmlrpc_call', 'mt.publishPost' ); |
| 6745 | |
| 6746 | $postdata = get_post( $post_ID, ARRAY_A ); |
| 6747 | if ( ! $postdata ) { |
| 6748 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 6749 | } |
| 6750 | |
| 6751 | if ( ! current_user_can( 'publish_posts' ) || ! current_user_can( 'edit_post', $post_ID ) ) { |
| 6752 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish this post.' ) ); |
| 6753 | } |
| Line | Code |
| 6777 | * @type string $pagelinkedfrom |
| 6778 | * @type string $pagelinkedto |
| 6779 | * } |
| 6780 | * @return string|IXR_Error |
| 6781 | */ |
| 6782 | public function pingback_ping( $args ) { |
| 6783 | global $wpdb; |
| 6784 | |
| 6785 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6786 | do_action( 'xmlrpc_call', 'pingback.ping' ); |
| 6787 | |
| 6788 | $this->escape( $args ); |
| 6789 | |
| 6790 | $pagelinkedfrom = str_replace( '&', '&', $args[0] ); |
| 6791 | $pagelinkedto = str_replace( '&', '&', $args[1] ); |
| 6792 | $pagelinkedto = str_replace( '&', '&', $pagelinkedto ); |
| 6793 | |
| 6794 | /** |
| 6795 | * Filters the pingback source URI. |
| Line | Code |
| 7016 | * @global wpdb $wpdb WordPress database abstraction object. |
| 7017 | * |
| 7018 | * @param string $url |
| 7019 | * @return array|IXR_Error |
| 7020 | */ |
| 7021 | public function pingback_extensions_getPingbacks( $url ) { |
| 7022 | global $wpdb; |
| 7023 | |
| 7024 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 7025 | do_action( 'xmlrpc_call', 'pingback.extensions.getPingbacks' ); |
| 7026 | |
| 7027 | $url = $this->escape( $url ); |
| 7028 | |
| 7029 | $post_ID = url_to_postid( $url ); |
| 7030 | if ( ! $post_ID ) { |
| 7031 | // We aren't sure that the resource is available and/or pingback enabled. |
| 7032 | 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.' ) ); |
| 7033 | } |
| 7034 | |