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 |
| 1680 | $post_id = (int) $args[3]; |
| 1681 | $content_struct = $args[4]; |
| 1682 | |
| 1683 | $user = $this->login( $username, $password ); |
| 1684 | if ( ! $user ) { |
| 1685 | return $this->error; |
| 1686 | } |
| 1687 | |
| 1688 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1689 | do_action( 'xmlrpc_call', 'wp.editPost' ); |
| 1690 | |
| 1691 | $post = get_post( $post_id, ARRAY_A ); |
| 1692 | |
| 1693 | if ( empty( $post['ID'] ) ) { |
| 1694 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 1695 | } |
| 1696 | |
| 1697 | if ( isset( $content_struct['if_not_modified_since'] ) ) { |
| 1698 | // If the post has been modified since the date provided, return an error. |
| Line | Code |
| 1763 | $password = $args[2]; |
| 1764 | $post_id = (int) $args[3]; |
| 1765 | |
| 1766 | $user = $this->login( $username, $password ); |
| 1767 | if ( ! $user ) { |
| 1768 | return $this->error; |
| 1769 | } |
| 1770 | |
| 1771 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1772 | do_action( 'xmlrpc_call', 'wp.deletePost' ); |
| 1773 | |
| 1774 | $post = get_post( $post_id, ARRAY_A ); |
| 1775 | if ( empty( $post['ID'] ) ) { |
| 1776 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 1777 | } |
| 1778 | |
| 1779 | if ( ! current_user_can( 'delete_post', $post_id ) ) { |
| 1780 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) ); |
| 1781 | } |
| Line | Code |
| 1863 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPost' ); |
| 1864 | } |
| 1865 | |
| 1866 | $user = $this->login( $username, $password ); |
| 1867 | if ( ! $user ) { |
| 1868 | return $this->error; |
| 1869 | } |
| 1870 | |
| 1871 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1872 | do_action( 'xmlrpc_call', 'wp.getPost' ); |
| 1873 | |
| 1874 | $post = get_post( $post_id, ARRAY_A ); |
| 1875 | |
| 1876 | if ( empty( $post['ID'] ) ) { |
| 1877 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 1878 | } |
| 1879 | |
| 1880 | if ( ! current_user_can( 'edit_post', $post_id ) ) { |
| 1881 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
| Line | Code |
| 1924 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPosts' ); |
| 1925 | } |
| 1926 | |
| 1927 | $user = $this->login( $username, $password ); |
| 1928 | if ( ! $user ) { |
| 1929 | return $this->error; |
| 1930 | } |
| 1931 | |
| 1932 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1933 | do_action( 'xmlrpc_call', 'wp.getPosts' ); |
| 1934 | |
| 1935 | $query = array(); |
| 1936 | |
| 1937 | if ( isset( $filter['post_type'] ) ) { |
| 1938 | $post_type = get_post_type_object( $filter['post_type'] ); |
| 1939 | if ( ! ( (bool) $post_type ) ) { |
| 1940 | return new IXR_Error( 403, __( 'Invalid post type.' ) ); |
| 1941 | } |
| 1942 | } else { |
| Line | Code |
| 2023 | $password = $args[2]; |
| 2024 | $content_struct = $args[3]; |
| 2025 | |
| 2026 | $user = $this->login( $username, $password ); |
| 2027 | if ( ! $user ) { |
| 2028 | return $this->error; |
| 2029 | } |
| 2030 | |
| 2031 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2032 | do_action( 'xmlrpc_call', 'wp.newTerm' ); |
| 2033 | |
| 2034 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) { |
| 2035 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 2036 | } |
| 2037 | |
| 2038 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
| 2039 | |
| 2040 | if ( ! current_user_can( $taxonomy->cap->edit_terms ) ) { |
| 2041 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to create terms in this taxonomy.' ) ); |
| Line | Code |
| 2128 | $term_id = (int) $args[3]; |
| 2129 | $content_struct = $args[4]; |
| 2130 | |
| 2131 | $user = $this->login( $username, $password ); |
| 2132 | if ( ! $user ) { |
| 2133 | return $this->error; |
| 2134 | } |
| 2135 | |
| 2136 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2137 | do_action( 'xmlrpc_call', 'wp.editTerm' ); |
| 2138 | |
| 2139 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) { |
| 2140 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 2141 | } |
| 2142 | |
| 2143 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
| 2144 | |
| 2145 | $taxonomy = (array) $taxonomy; |
| 2146 | |
| Line | Code |
| 2244 | $taxonomy = $args[3]; |
| 2245 | $term_id = (int) $args[4]; |
| 2246 | |
| 2247 | $user = $this->login( $username, $password ); |
| 2248 | if ( ! $user ) { |
| 2249 | return $this->error; |
| 2250 | } |
| 2251 | |
| 2252 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2253 | do_action( 'xmlrpc_call', 'wp.deleteTerm' ); |
| 2254 | |
| 2255 | if ( ! taxonomy_exists( $taxonomy ) ) { |
| 2256 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 2257 | } |
| 2258 | |
| 2259 | $taxonomy = get_taxonomy( $taxonomy ); |
| 2260 | $term = get_term( $term_id, $taxonomy->name ); |
| 2261 | |
| 2262 | if ( is_wp_error( $term ) ) { |
| Line | Code |
| 2323 | $taxonomy = $args[3]; |
| 2324 | $term_id = (int) $args[4]; |
| 2325 | |
| 2326 | $user = $this->login( $username, $password ); |
| 2327 | if ( ! $user ) { |
| 2328 | return $this->error; |
| 2329 | } |
| 2330 | |
| 2331 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2332 | do_action( 'xmlrpc_call', 'wp.getTerm' ); |
| 2333 | |
| 2334 | if ( ! taxonomy_exists( $taxonomy ) ) { |
| 2335 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 2336 | } |
| 2337 | |
| 2338 | $taxonomy = get_taxonomy( $taxonomy ); |
| 2339 | |
| 2340 | $term = get_term( $term_id, $taxonomy->name, ARRAY_A ); |
| 2341 | |
| Line | Code |
| 2388 | $taxonomy = $args[3]; |
| 2389 | $filter = isset( $args[4] ) ? $args[4] : array(); |
| 2390 | |
| 2391 | $user = $this->login( $username, $password ); |
| 2392 | if ( ! $user ) { |
| 2393 | return $this->error; |
| 2394 | } |
| 2395 | |
| 2396 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2397 | do_action( 'xmlrpc_call', 'wp.getTerms' ); |
| 2398 | |
| 2399 | if ( ! taxonomy_exists( $taxonomy ) ) { |
| 2400 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 2401 | } |
| 2402 | |
| 2403 | $taxonomy = get_taxonomy( $taxonomy ); |
| 2404 | |
| 2405 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) { |
| 2406 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ) ); |
| Line | Code |
| 2494 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomy' ); |
| 2495 | } |
| 2496 | |
| 2497 | $user = $this->login( $username, $password ); |
| 2498 | if ( ! $user ) { |
| 2499 | return $this->error; |
| 2500 | } |
| 2501 | |
| 2502 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2503 | do_action( 'xmlrpc_call', 'wp.getTaxonomy' ); |
| 2504 | |
| 2505 | if ( ! taxonomy_exists( $taxonomy ) ) { |
| 2506 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 2507 | } |
| 2508 | |
| 2509 | $taxonomy = get_taxonomy( $taxonomy ); |
| 2510 | |
| 2511 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) { |
| 2512 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ) ); |
| Line | Code |
| 2552 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomies' ); |
| 2553 | } |
| 2554 | |
| 2555 | $user = $this->login( $username, $password ); |
| 2556 | if ( ! $user ) { |
| 2557 | return $this->error; |
| 2558 | } |
| 2559 | |
| 2560 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2561 | do_action( 'xmlrpc_call', 'wp.getTaxonomies' ); |
| 2562 | |
| 2563 | $taxonomies = get_taxonomies( $filter, 'objects' ); |
| 2564 | |
| 2565 | // Holds all the taxonomy data. |
| 2566 | $struct = array(); |
| 2567 | |
| 2568 | foreach ( $taxonomies as $taxonomy ) { |
| 2569 | // Capability check for post types. |
| 2570 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) { |
| Line | Code |
| 2638 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUser' ); |
| 2639 | } |
| 2640 | |
| 2641 | $user = $this->login( $username, $password ); |
| 2642 | if ( ! $user ) { |
| 2643 | return $this->error; |
| 2644 | } |
| 2645 | |
| 2646 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2647 | do_action( 'xmlrpc_call', 'wp.getUser' ); |
| 2648 | |
| 2649 | if ( ! current_user_can( 'edit_user', $user_id ) ) { |
| 2650 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this user.' ) ); |
| 2651 | } |
| 2652 | |
| 2653 | $user_data = get_userdata( $user_id ); |
| 2654 | |
| 2655 | if ( ! $user_data ) { |
| 2656 | return new IXR_Error( 404, __( 'Invalid user ID.' ) ); |
| Line | Code |
| 2701 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUsers' ); |
| 2702 | } |
| 2703 | |
| 2704 | $user = $this->login( $username, $password ); |
| 2705 | if ( ! $user ) { |
| 2706 | return $this->error; |
| 2707 | } |
| 2708 | |
| 2709 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2710 | do_action( 'xmlrpc_call', 'wp.getUsers' ); |
| 2711 | |
| 2712 | if ( ! current_user_can( 'list_users' ) ) { |
| 2713 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to list users.' ) ); |
| 2714 | } |
| 2715 | |
| 2716 | $query = array( 'fields' => 'all_with_meta' ); |
| 2717 | |
| 2718 | $query['number'] = ( isset( $filter['number'] ) ) ? absint( $filter['number'] ) : 50; |
| 2719 | $query['offset'] = ( isset( $filter['offset'] ) ) ? absint( $filter['offset'] ) : 0; |
| Line | Code |
| 2781 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getProfile' ); |
| 2782 | } |
| 2783 | |
| 2784 | $user = $this->login( $username, $password ); |
| 2785 | if ( ! $user ) { |
| 2786 | return $this->error; |
| 2787 | } |
| 2788 | |
| 2789 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2790 | do_action( 'xmlrpc_call', 'wp.getProfile' ); |
| 2791 | |
| 2792 | if ( ! current_user_can( 'edit_user', $user->ID ) ) { |
| 2793 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit your profile.' ) ); |
| 2794 | } |
| 2795 | |
| 2796 | $user_data = get_userdata( $user->ID ); |
| 2797 | |
| 2798 | return $this->_prepare_user( $user_data, $fields ); |
| 2799 | } |
| Line | Code |
| 2831 | $password = $args[2]; |
| 2832 | $content_struct = $args[3]; |
| 2833 | |
| 2834 | $user = $this->login( $username, $password ); |
| 2835 | if ( ! $user ) { |
| 2836 | return $this->error; |
| 2837 | } |
| 2838 | |
| 2839 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2840 | do_action( 'xmlrpc_call', 'wp.editProfile' ); |
| 2841 | |
| 2842 | if ( ! current_user_can( 'edit_user', $user->ID ) ) { |
| 2843 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit your profile.' ) ); |
| 2844 | } |
| 2845 | |
| 2846 | // Holds data of the user. |
| 2847 | $user_data = array(); |
| 2848 | $user_data['ID'] = $user->ID; |
| 2849 | |
| Line | Code |
| 2920 | if ( ! $page ) { |
| 2921 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 2922 | } |
| 2923 | |
| 2924 | if ( ! current_user_can( 'edit_page', $page_id ) ) { |
| 2925 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this page.' ) ); |
| 2926 | } |
| 2927 | |
| 2928 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2929 | do_action( 'xmlrpc_call', 'wp.getPage' ); |
| 2930 | |
| 2931 | // If we found the page then format the data. |
| 2932 | if ( $page->ID && ( 'page' === $page->post_type ) ) { |
| 2933 | return $this->_prepare_page( $page ); |
| 2934 | } else { |
| 2935 | // If the page doesn't exist, indicate that. |
| 2936 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
| 2937 | } |
| 2938 | } |
| Line | Code |
| 2963 | if ( ! $user ) { |
| 2964 | return $this->error; |
| 2965 | } |
| 2966 | |
| 2967 | if ( ! current_user_can( 'edit_pages' ) ) { |
| 2968 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit pages.' ) ); |
| 2969 | } |
| 2970 | |
| 2971 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2972 | do_action( 'xmlrpc_call', 'wp.getPages' ); |
| 2973 | |
| 2974 | $pages = get_posts( |
| 2975 | array( |
| 2976 | 'post_type' => 'page', |
| 2977 | 'post_status' => 'any', |
| 2978 | 'numberposts' => $num_pages, |
| 2979 | ) |
| 2980 | ); |
| 2981 | $num_pages = count( $pages ); |
| Line | Code |
| 3018 | $username = $this->escape( $args[1] ); |
| 3019 | $password = $this->escape( $args[2] ); |
| 3020 | |
| 3021 | $user = $this->login( $username, $password ); |
| 3022 | if ( ! $user ) { |
| 3023 | return $this->error; |
| 3024 | } |
| 3025 | |
| 3026 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3027 | do_action( 'xmlrpc_call', 'wp.newPage' ); |
| 3028 | |
| 3029 | // Mark this as content for a page. |
| 3030 | $args[3]['post_type'] = 'page'; |
| 3031 | |
| 3032 | // Let mw_newPost() do all of the heavy lifting. |
| 3033 | return $this->mw_newPost( $args ); |
| 3034 | } |
| 3035 | |
| 3036 | /** |
| Line | Code |
| 3055 | $password = $args[2]; |
| 3056 | $page_id = (int) $args[3]; |
| 3057 | |
| 3058 | $user = $this->login( $username, $password ); |
| 3059 | if ( ! $user ) { |
| 3060 | return $this->error; |
| 3061 | } |
| 3062 | |
| 3063 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3064 | do_action( 'xmlrpc_call', 'wp.deletePage' ); |
| 3065 | |
| 3066 | // Get the current page based on the 'page_id' and |
| 3067 | // make sure it is a page and not a post. |
| 3068 | $actual_page = get_post( $page_id, ARRAY_A ); |
| 3069 | if ( ! $actual_page || ( 'page' !== $actual_page['post_type'] ) ) { |
| 3070 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
| 3071 | } |
| 3072 | |
| 3073 | // Make sure the user can delete pages. |
| Line | Code |
| 3122 | $escaped_username = $this->escape( $username ); |
| 3123 | $escaped_password = $this->escape( $password ); |
| 3124 | |
| 3125 | $user = $this->login( $escaped_username, $escaped_password ); |
| 3126 | if ( ! $user ) { |
| 3127 | return $this->error; |
| 3128 | } |
| 3129 | |
| 3130 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3131 | do_action( 'xmlrpc_call', 'wp.editPage' ); |
| 3132 | |
| 3133 | // Get the page data and make sure it is a page. |
| 3134 | $actual_page = get_post( $page_id, ARRAY_A ); |
| 3135 | if ( ! $actual_page || ( 'page' !== $actual_page['post_type'] ) ) { |
| 3136 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
| 3137 | } |
| 3138 | |
| 3139 | // Make sure the user is allowed to edit pages. |
| 3140 | if ( ! current_user_can( 'edit_page', $page_id ) ) { |
| Line | Code |
| 3185 | if ( ! $user ) { |
| 3186 | return $this->error; |
| 3187 | } |
| 3188 | |
| 3189 | if ( ! current_user_can( 'edit_pages' ) ) { |
| 3190 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit pages.' ) ); |
| 3191 | } |
| 3192 | |
| 3193 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3194 | do_action( 'xmlrpc_call', 'wp.getPageList' ); |
| 3195 | |
| 3196 | // Get list of page IDs and titles. |
| 3197 | $page_list = $wpdb->get_results( |
| 3198 | " |
| 3199 | SELECT ID page_id, |
| 3200 | post_title page_title, |
| 3201 | post_parent page_parent_id, |
| 3202 | post_date_gmt, |
| 3203 | post_date, |
| Line | Code |
| 3246 | if ( ! $user ) { |
| 3247 | return $this->error; |
| 3248 | } |
| 3249 | |
| 3250 | if ( ! current_user_can( 'edit_posts' ) ) { |
| 3251 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
| 3252 | } |
| 3253 | |
| 3254 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3255 | do_action( 'xmlrpc_call', 'wp.getAuthors' ); |
| 3256 | |
| 3257 | $authors = array(); |
| 3258 | foreach ( get_users( array( 'fields' => array( 'ID', 'user_login', 'display_name' ) ) ) as $user ) { |
| 3259 | $authors[] = array( |
| 3260 | 'user_id' => $user->ID, |
| 3261 | 'user_login' => $user->user_login, |
| 3262 | 'display_name' => $user->display_name, |
| 3263 | ); |
| 3264 | } |
| Line | Code |
| 3290 | if ( ! $user ) { |
| 3291 | return $this->error; |
| 3292 | } |
| 3293 | |
| 3294 | if ( ! current_user_can( 'edit_posts' ) ) { |
| 3295 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view tags.' ) ); |
| 3296 | } |
| 3297 | |
| 3298 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3299 | do_action( 'xmlrpc_call', 'wp.getKeywords' ); |
| 3300 | |
| 3301 | $tags = array(); |
| 3302 | |
| 3303 | $all_tags = get_tags(); |
| 3304 | if ( $all_tags ) { |
| 3305 | foreach ( (array) $all_tags as $tag ) { |
| 3306 | $struct = array(); |
| 3307 | $struct['tag_id'] = $tag->term_id; |
| 3308 | $struct['name'] = $tag->name; |
| Line | Code |
| 3340 | $password = $args[2]; |
| 3341 | $category = $args[3]; |
| 3342 | |
| 3343 | $user = $this->login( $username, $password ); |
| 3344 | if ( ! $user ) { |
| 3345 | return $this->error; |
| 3346 | } |
| 3347 | |
| 3348 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3349 | do_action( 'xmlrpc_call', 'wp.newCategory' ); |
| 3350 | |
| 3351 | // Make sure the user is allowed to add a category. |
| 3352 | if ( ! current_user_can( 'manage_categories' ) ) { |
| 3353 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to add a category.' ) ); |
| 3354 | } |
| 3355 | |
| 3356 | // If no slug was provided, make it empty |
| 3357 | // so that WordPress will generate one. |
| 3358 | if ( empty( $category['slug'] ) ) { |
| Line | Code |
| 3423 | $password = $args[2]; |
| 3424 | $category_id = (int) $args[3]; |
| 3425 | |
| 3426 | $user = $this->login( $username, $password ); |
| 3427 | if ( ! $user ) { |
| 3428 | return $this->error; |
| 3429 | } |
| 3430 | |
| 3431 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3432 | do_action( 'xmlrpc_call', 'wp.deleteCategory' ); |
| 3433 | |
| 3434 | if ( ! current_user_can( 'delete_term', $category_id ) ) { |
| 3435 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this category.' ) ); |
| 3436 | } |
| 3437 | |
| 3438 | $status = wp_delete_term( $category_id, 'category' ); |
| 3439 | |
| 3440 | if ( true == $status ) { |
| 3441 | /** |
| Line | Code |
| 3480 | if ( ! $user ) { |
| 3481 | return $this->error; |
| 3482 | } |
| 3483 | |
| 3484 | if ( ! current_user_can( 'edit_posts' ) ) { |
| 3485 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
| 3486 | } |
| 3487 | |
| 3488 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3489 | do_action( 'xmlrpc_call', 'wp.suggestCategories' ); |
| 3490 | |
| 3491 | $category_suggestions = array(); |
| 3492 | $args = array( |
| 3493 | 'get' => 'all', |
| 3494 | 'number' => $max_results, |
| 3495 | 'name__like' => $category, |
| 3496 | ); |
| 3497 | foreach ( (array) get_categories( $args ) as $cat ) { |
| 3498 | $category_suggestions[] = array( |
| Line | Code |
| 3526 | $password = $args[2]; |
| 3527 | $comment_id = (int) $args[3]; |
| 3528 | |
| 3529 | $user = $this->login( $username, $password ); |
| 3530 | if ( ! $user ) { |
| 3531 | return $this->error; |
| 3532 | } |
| 3533 | |
| 3534 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3535 | do_action( 'xmlrpc_call', 'wp.getComment' ); |
| 3536 | |
| 3537 | $comment = get_comment( $comment_id ); |
| 3538 | if ( ! $comment ) { |
| 3539 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 3540 | } |
| 3541 | |
| 3542 | if ( ! current_user_can( 'edit_comment', $comment_id ) ) { |
| 3543 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) ); |
| 3544 | } |
| Line | Code |
| 3579 | $password = $args[2]; |
| 3580 | $struct = isset( $args[3] ) ? $args[3] : array(); |
| 3581 | |
| 3582 | $user = $this->login( $username, $password ); |
| 3583 | if ( ! $user ) { |
| 3584 | return $this->error; |
| 3585 | } |
| 3586 | |
| 3587 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3588 | do_action( 'xmlrpc_call', 'wp.getComments' ); |
| 3589 | |
| 3590 | if ( isset( $struct['status'] ) ) { |
| 3591 | $status = $struct['status']; |
| 3592 | } else { |
| 3593 | $status = ''; |
| 3594 | } |
| 3595 | |
| 3596 | if ( ! current_user_can( 'moderate_comments' ) && 'approve' !== $status ) { |
| 3597 | return new IXR_Error( 401, __( 'Invalid comment status.' ) ); |
| Line | Code |
| 3674 | if ( ! get_comment( $comment_ID ) ) { |
| 3675 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 3676 | } |
| 3677 | |
| 3678 | if ( ! current_user_can( 'edit_comment', $comment_ID ) ) { |
| 3679 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to delete this comment.' ) ); |
| 3680 | } |
| 3681 | |
| 3682 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3683 | do_action( 'xmlrpc_call', 'wp.deleteComment' ); |
| 3684 | |
| 3685 | $status = wp_delete_comment( $comment_ID ); |
| 3686 | |
| 3687 | if ( $status ) { |
| 3688 | /** |
| 3689 | * Fires after a comment has been successfully deleted via XML-RPC. |
| 3690 | * |
| 3691 | * @since 3.4.0 |
| 3692 | * |
| Line | Code |
| 3742 | if ( ! get_comment( $comment_ID ) ) { |
| 3743 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 3744 | } |
| 3745 | |
| 3746 | if ( ! current_user_can( 'edit_comment', $comment_ID ) ) { |
| 3747 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) ); |
| 3748 | } |
| 3749 | |
| 3750 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3751 | do_action( 'xmlrpc_call', 'wp.editComment' ); |
| 3752 | $comment = array( |
| 3753 | 'comment_ID' => $comment_ID, |
| 3754 | ); |
| 3755 | |
| 3756 | if ( isset( $content_struct['status'] ) ) { |
| 3757 | $statuses = get_comment_statuses(); |
| 3758 | $statuses = array_keys( $statuses ); |
| 3759 | |
| 3760 | if ( ! in_array( $content_struct['status'], $statuses, true ) ) { |
| Line | Code |
| 3917 | } elseif ( ! is_email( $comment['comment_author_email'] ) ) { |
| 3918 | return new IXR_Error( 403, __( 'A valid email address is required.' ) ); |
| 3919 | } |
| 3920 | } |
| 3921 | } |
| 3922 | |
| 3923 | $comment['comment_parent'] = isset( $content_struct['comment_parent'] ) ? absint( $content_struct['comment_parent'] ) : 0; |
| 3924 | |
| 3925 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3926 | do_action( 'xmlrpc_call', 'wp.newComment' ); |
| 3927 | |
| 3928 | $comment_ID = wp_new_comment( $comment, true ); |
| 3929 | if ( is_wp_error( $comment_ID ) ) { |
| 3930 | return new IXR_Error( 403, $comment_ID->get_error_message() ); |
| 3931 | } |
| 3932 | |
| 3933 | if ( ! $comment_ID ) { |
| 3934 | return new IXR_Error( 403, __( 'Something went wrong.' ) ); |
| 3935 | } |
| Line | Code |
| 3971 | if ( ! $user ) { |
| 3972 | return $this->error; |
| 3973 | } |
| 3974 | |
| 3975 | if ( ! current_user_can( 'publish_posts' ) ) { |
| 3976 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) ); |
| 3977 | } |
| 3978 | |
| 3979 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3980 | do_action( 'xmlrpc_call', 'wp.getCommentStatusList' ); |
| 3981 | |
| 3982 | return get_comment_statuses(); |
| 3983 | } |
| 3984 | |
| 3985 | /** |
| 3986 | * Retrieve comment count. |
| 3987 | * |
| 3988 | * @since 2.5.0 |
| 3989 | * |
| Line | Code |
| 4013 | if ( empty( $post['ID'] ) ) { |
| 4014 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4015 | } |
| 4016 | |
| 4017 | if ( ! current_user_can( 'edit_post', $post_id ) ) { |
| 4018 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details of this post.' ) ); |
| 4019 | } |
| 4020 | |
| 4021 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4022 | do_action( 'xmlrpc_call', 'wp.getCommentCount' ); |
| 4023 | |
| 4024 | $count = wp_count_comments( $post_id ); |
| 4025 | |
| 4026 | return array( |
| 4027 | 'approved' => $count->approved, |
| 4028 | 'awaiting_moderation' => $count->moderated, |
| 4029 | 'spam' => $count->spam, |
| 4030 | 'total_comments' => $count->total_comments, |
| 4031 | ); |
| Line | Code |
| 4055 | if ( ! $user ) { |
| 4056 | return $this->error; |
| 4057 | } |
| 4058 | |
| 4059 | if ( ! current_user_can( 'edit_posts' ) ) { |
| 4060 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) ); |
| 4061 | } |
| 4062 | |
| 4063 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4064 | do_action( 'xmlrpc_call', 'wp.getPostStatusList' ); |
| 4065 | |
| 4066 | return get_post_statuses(); |
| 4067 | } |
| 4068 | |
| 4069 | /** |
| 4070 | * Retrieve page statuses. |
| 4071 | * |
| 4072 | * @since 2.5.0 |
| 4073 | * |
| Line | Code |
| 4090 | if ( ! $user ) { |
| 4091 | return $this->error; |
| 4092 | } |
| 4093 | |
| 4094 | if ( ! current_user_can( 'edit_pages' ) ) { |
| 4095 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) ); |
| 4096 | } |
| 4097 | |
| 4098 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4099 | do_action( 'xmlrpc_call', 'wp.getPageStatusList' ); |
| 4100 | |
| 4101 | return get_page_statuses(); |
| 4102 | } |
| 4103 | |
| 4104 | /** |
| 4105 | * Retrieve page templates. |
| 4106 | * |
| 4107 | * @since 2.6.0 |
| 4108 | * |
| Line | Code |
| 4283 | if ( ! $user ) { |
| 4284 | return $this->error; |
| 4285 | } |
| 4286 | |
| 4287 | if ( ! current_user_can( 'upload_files' ) ) { |
| 4288 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to upload files.' ) ); |
| 4289 | } |
| 4290 | |
| 4291 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4292 | do_action( 'xmlrpc_call', 'wp.getMediaItem' ); |
| 4293 | |
| 4294 | $attachment = get_post( $attachment_id ); |
| 4295 | if ( ! $attachment ) { |
| 4296 | return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); |
| 4297 | } |
| 4298 | |
| 4299 | return $this->_prepare_media_item( $attachment ); |
| 4300 | } |
| 4301 | |
| Line | Code |
| 4336 | if ( ! $user ) { |
| 4337 | return $this->error; |
| 4338 | } |
| 4339 | |
| 4340 | if ( ! current_user_can( 'upload_files' ) ) { |
| 4341 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to upload files.' ) ); |
| 4342 | } |
| 4343 | |
| 4344 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4345 | do_action( 'xmlrpc_call', 'wp.getMediaLibrary' ); |
| 4346 | |
| 4347 | $parent_id = ( isset( $struct['parent_id'] ) ) ? absint( $struct['parent_id'] ) : ''; |
| 4348 | $mime_type = ( isset( $struct['mime_type'] ) ) ? $struct['mime_type'] : ''; |
| 4349 | $offset = ( isset( $struct['offset'] ) ) ? absint( $struct['offset'] ) : 0; |
| 4350 | $number = ( isset( $struct['number'] ) ) ? absint( $struct['number'] ) : -1; |
| 4351 | |
| 4352 | $attachments = get_posts( |
| 4353 | array( |
| 4354 | 'post_type' => 'attachment', |
| Line | Code |
| 4392 | if ( ! $user ) { |
| 4393 | return $this->error; |
| 4394 | } |
| 4395 | |
| 4396 | if ( ! current_user_can( 'edit_posts' ) ) { |
| 4397 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) ); |
| 4398 | } |
| 4399 | |
| 4400 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4401 | do_action( 'xmlrpc_call', 'wp.getPostFormats' ); |
| 4402 | |
| 4403 | $formats = get_post_format_strings(); |
| 4404 | |
| 4405 | // Find out if they want a list of currently supports formats. |
| 4406 | if ( isset( $args[3] ) && is_array( $args[3] ) ) { |
| 4407 | if ( $args[3]['show-supported'] ) { |
| 4408 | if ( current_theme_supports( 'post-formats' ) ) { |
| 4409 | $supported = get_theme_support( 'post-formats' ); |
| 4410 | |
| Line | Code |
| 4472 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostType' ); |
| 4473 | } |
| 4474 | |
| 4475 | $user = $this->login( $username, $password ); |
| 4476 | if ( ! $user ) { |
| 4477 | return $this->error; |
| 4478 | } |
| 4479 | |
| 4480 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4481 | do_action( 'xmlrpc_call', 'wp.getPostType' ); |
| 4482 | |
| 4483 | if ( ! post_type_exists( $post_type_name ) ) { |
| 4484 | return new IXR_Error( 403, __( 'Invalid post type.' ) ); |
| 4485 | } |
| 4486 | |
| 4487 | $post_type = get_post_type_object( $post_type_name ); |
| 4488 | |
| 4489 | if ( ! current_user_can( $post_type->cap->edit_posts ) ) { |
| 4490 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts in this post type.' ) ); |
| Line | Code |
| 4529 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostTypes' ); |
| 4530 | } |
| 4531 | |
| 4532 | $user = $this->login( $username, $password ); |
| 4533 | if ( ! $user ) { |
| 4534 | return $this->error; |
| 4535 | } |
| 4536 | |
| 4537 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4538 | do_action( 'xmlrpc_call', 'wp.getPostTypes' ); |
| 4539 | |
| 4540 | $post_types = get_post_types( $filter, 'objects' ); |
| 4541 | |
| 4542 | $struct = array(); |
| 4543 | |
| 4544 | foreach ( $post_types as $post_type ) { |
| 4545 | if ( ! current_user_can( $post_type->cap->edit_posts ) ) { |
| 4546 | continue; |
| 4547 | } |
| Line | Code |
| 4599 | $fields = apply_filters( 'xmlrpc_default_revision_fields', array( 'post_date', 'post_date_gmt' ), 'wp.getRevisions' ); |
| 4600 | } |
| 4601 | |
| 4602 | $user = $this->login( $username, $password ); |
| 4603 | if ( ! $user ) { |
| 4604 | return $this->error; |
| 4605 | } |
| 4606 | |
| 4607 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4608 | do_action( 'xmlrpc_call', 'wp.getRevisions' ); |
| 4609 | |
| 4610 | $post = get_post( $post_id ); |
| 4611 | if ( ! $post ) { |
| 4612 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4613 | } |
| 4614 | |
| 4615 | if ( ! current_user_can( 'edit_post', $post_id ) ) { |
| 4616 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
| 4617 | } |
| Line | Code |
| 4673 | $password = $args[2]; |
| 4674 | $revision_id = (int) $args[3]; |
| 4675 | |
| 4676 | $user = $this->login( $username, $password ); |
| 4677 | if ( ! $user ) { |
| 4678 | return $this->error; |
| 4679 | } |
| 4680 | |
| 4681 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4682 | do_action( 'xmlrpc_call', 'wp.restoreRevision' ); |
| 4683 | |
| 4684 | $revision = wp_get_post_revision( $revision_id ); |
| 4685 | if ( ! $revision ) { |
| 4686 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4687 | } |
| 4688 | |
| 4689 | if ( wp_is_post_autosave( $revision ) ) { |
| 4690 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4691 | } |
| Line | Code |
| 4744 | $username = $args[1]; |
| 4745 | $password = $args[2]; |
| 4746 | |
| 4747 | $user = $this->login( $username, $password ); |
| 4748 | if ( ! $user ) { |
| 4749 | return $this->error; |
| 4750 | } |
| 4751 | |
| 4752 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4753 | do_action( 'xmlrpc_call', 'blogger.getUsersBlogs' ); |
| 4754 | |
| 4755 | $is_admin = current_user_can( 'manage_options' ); |
| 4756 | |
| 4757 | $struct = array( |
| 4758 | 'isAdmin' => $is_admin, |
| 4759 | 'url' => get_option( 'home' ) . '/', |
| 4760 | 'blogid' => '1', |
| 4761 | 'blogName' => get_option( 'blogname' ), |
| 4762 | 'xmlrpc' => site_url( 'xmlrpc.php', 'rpc' ), |
| Line | Code |
| 4830 | if ( ! $user ) { |
| 4831 | return $this->error; |
| 4832 | } |
| 4833 | |
| 4834 | if ( ! current_user_can( 'edit_posts' ) ) { |
| 4835 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to access user data on this site.' ) ); |
| 4836 | } |
| 4837 | |
| 4838 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4839 | do_action( 'xmlrpc_call', 'blogger.getUserInfo' ); |
| 4840 | |
| 4841 | $struct = array( |
| 4842 | 'nickname' => $user->nickname, |
| 4843 | 'userid' => $user->ID, |
| 4844 | 'url' => $user->user_url, |
| 4845 | 'lastname' => $user->last_name, |
| 4846 | 'firstname' => $user->first_name, |
| 4847 | ); |
| 4848 | |
| Line | Code |
| 4880 | if ( ! $post_data ) { |
| 4881 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4882 | } |
| 4883 | |
| 4884 | if ( ! current_user_can( 'edit_post', $post_ID ) ) { |
| 4885 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
| 4886 | } |
| 4887 | |
| 4888 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4889 | do_action( 'xmlrpc_call', 'blogger.getPost' ); |
| 4890 | |
| 4891 | $categories = implode( ',', wp_get_post_categories( $post_ID ) ); |
| 4892 | |
| 4893 | $content = '<title>' . wp_unslash( $post_data['post_title'] ) . '</title>'; |
| 4894 | $content .= '<category>' . $categories . '</category>'; |
| 4895 | $content .= wp_unslash( $post_data['post_content'] ); |
| 4896 | |
| 4897 | $struct = array( |
| 4898 | 'userid' => $post_data['post_author'], |
| Line | Code |
| 4937 | if ( ! $user ) { |
| 4938 | return $this->error; |
| 4939 | } |
| 4940 | |
| 4941 | if ( ! current_user_can( 'edit_posts' ) ) { |
| 4942 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
| 4943 | } |
| 4944 | |
| 4945 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4946 | do_action( 'xmlrpc_call', 'blogger.getRecentPosts' ); |
| 4947 | |
| 4948 | $posts_list = wp_get_recent_posts( $query ); |
| 4949 | |
| 4950 | if ( ! $posts_list ) { |
| 4951 | $this->error = new IXR_Error( 500, __( 'Either there are no posts, or something went wrong.' ) ); |
| 4952 | return $this->error; |
| 4953 | } |
| 4954 | |
| 4955 | $recent_posts = array(); |
| Line | Code |
| 5027 | $content = $args[4]; |
| 5028 | $publish = $args[5]; |
| 5029 | |
| 5030 | $user = $this->login( $username, $password ); |
| 5031 | if ( ! $user ) { |
| 5032 | return $this->error; |
| 5033 | } |
| 5034 | |
| 5035 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5036 | do_action( 'xmlrpc_call', 'blogger.newPost' ); |
| 5037 | |
| 5038 | $cap = ( $publish ) ? 'publish_posts' : 'edit_posts'; |
| 5039 | if ( ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) || ! current_user_can( $cap ) ) { |
| 5040 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to post on this site.' ) ); |
| 5041 | } |
| 5042 | |
| 5043 | $post_status = ( $publish ) ? 'publish' : 'draft'; |
| 5044 | |
| 5045 | $post_author = $user->ID; |
| Line | Code |
| 5104 | $content = $args[4]; |
| 5105 | $publish = $args[5]; |
| 5106 | |
| 5107 | $user = $this->login( $username, $password ); |
| 5108 | if ( ! $user ) { |
| 5109 | return $this->error; |
| 5110 | } |
| 5111 | |
| 5112 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5113 | do_action( 'xmlrpc_call', 'blogger.editPost' ); |
| 5114 | |
| 5115 | $actual_post = get_post( $post_ID, ARRAY_A ); |
| 5116 | |
| 5117 | if ( ! $actual_post || 'post' !== $actual_post['post_type'] ) { |
| 5118 | return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); |
| 5119 | } |
| 5120 | |
| 5121 | $this->escape( $actual_post ); |
| 5122 | |
| Line | Code |
| 5178 | $username = $args[2]; |
| 5179 | $password = $args[3]; |
| 5180 | |
| 5181 | $user = $this->login( $username, $password ); |
| 5182 | if ( ! $user ) { |
| 5183 | return $this->error; |
| 5184 | } |
| 5185 | |
| 5186 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5187 | do_action( 'xmlrpc_call', 'blogger.deletePost' ); |
| 5188 | |
| 5189 | $actual_post = get_post( $post_ID, ARRAY_A ); |
| 5190 | |
| 5191 | if ( ! $actual_post || 'post' !== $actual_post['post_type'] ) { |
| 5192 | return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); |
| 5193 | } |
| 5194 | |
| 5195 | if ( ! current_user_can( 'delete_post', $post_ID ) ) { |
| 5196 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) ); |
| Line | Code |
| 5266 | $content_struct = $args[3]; |
| 5267 | $publish = isset( $args[4] ) ? $args[4] : 0; |
| 5268 | |
| 5269 | $user = $this->login( $username, $password ); |
| 5270 | if ( ! $user ) { |
| 5271 | return $this->error; |
| 5272 | } |
| 5273 | |
| 5274 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5275 | do_action( 'xmlrpc_call', 'metaWeblog.newPost' ); |
| 5276 | |
| 5277 | $page_template = ''; |
| 5278 | if ( ! empty( $content_struct['post_type'] ) ) { |
| 5279 | if ( 'page' === $content_struct['post_type'] ) { |
| 5280 | if ( $publish ) { |
| 5281 | $cap = 'publish_pages'; |
| 5282 | } elseif ( isset( $content_struct['page_status'] ) && 'publish' === $content_struct['page_status'] ) { |
| 5283 | $cap = 'publish_pages'; |
| 5284 | } else { |
| Line | Code |
| 5645 | $content_struct = $args[3]; |
| 5646 | $publish = isset( $args[4] ) ? $args[4] : 0; |
| 5647 | |
| 5648 | $user = $this->login( $username, $password ); |
| 5649 | if ( ! $user ) { |
| 5650 | return $this->error; |
| 5651 | } |
| 5652 | |
| 5653 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5654 | do_action( 'xmlrpc_call', 'metaWeblog.editPost' ); |
| 5655 | |
| 5656 | $postdata = get_post( $post_ID, ARRAY_A ); |
| 5657 | |
| 5658 | /* |
| 5659 | * If there is no post data for the give post ID, stop now and return an error. |
| 5660 | * Otherwise a new post will be created (which was the old behavior). |
| 5661 | */ |
| 5662 | if ( ! $postdata || empty( $postdata['ID'] ) ) { |
| 5663 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| Line | Code |
| 5983 | if ( ! $postdata ) { |
| 5984 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 5985 | } |
| 5986 | |
| 5987 | if ( ! current_user_can( 'edit_post', $post_ID ) ) { |
| 5988 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
| 5989 | } |
| 5990 | |
| 5991 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5992 | do_action( 'xmlrpc_call', 'metaWeblog.getPost' ); |
| 5993 | |
| 5994 | if ( '' !== $postdata['post_date'] ) { |
| 5995 | $post_date = $this->_convert_date( $postdata['post_date'] ); |
| 5996 | $post_date_gmt = $this->_convert_date_gmt( $postdata['post_date_gmt'], $postdata['post_date'] ); |
| 5997 | $post_modified = $this->_convert_date( $postdata['post_modified'] ); |
| 5998 | $post_modified_gmt = $this->_convert_date_gmt( $postdata['post_modified_gmt'], $postdata['post_modified'] ); |
| 5999 | |
| 6000 | $categories = array(); |
| 6001 | $catids = wp_get_post_categories( $post_ID ); |
| Line | Code |
| 6124 | if ( ! $user ) { |
| 6125 | return $this->error; |
| 6126 | } |
| 6127 | |
| 6128 | if ( ! current_user_can( 'edit_posts' ) ) { |
| 6129 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
| 6130 | } |
| 6131 | |
| 6132 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6133 | do_action( 'xmlrpc_call', 'metaWeblog.getRecentPosts' ); |
| 6134 | |
| 6135 | $posts_list = wp_get_recent_posts( $query ); |
| 6136 | |
| 6137 | if ( ! $posts_list ) { |
| 6138 | return array(); |
| 6139 | } |
| 6140 | |
| 6141 | $recent_posts = array(); |
| 6142 | foreach ( $posts_list as $entry ) { |
| Line | Code |
| 6245 | if ( ! $user ) { |
| 6246 | return $this->error; |
| 6247 | } |
| 6248 | |
| 6249 | if ( ! current_user_can( 'edit_posts' ) ) { |
| 6250 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
| 6251 | } |
| 6252 | |
| 6253 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6254 | do_action( 'xmlrpc_call', 'metaWeblog.getCategories' ); |
| 6255 | |
| 6256 | $categories_struct = array(); |
| 6257 | |
| 6258 | $cats = get_categories( array( 'get' => 'all' ) ); |
| 6259 | if ( $cats ) { |
| 6260 | foreach ( $cats as $cat ) { |
| 6261 | $struct = array(); |
| 6262 | $struct['categoryId'] = $cat->term_id; |
| 6263 | $struct['parentId'] = $cat->parent; |
| Line | Code |
| 6306 | $type = $data['type']; |
| 6307 | $bits = $data['bits']; |
| 6308 | |
| 6309 | $user = $this->login( $username, $password ); |
| 6310 | if ( ! $user ) { |
| 6311 | return $this->error; |
| 6312 | } |
| 6313 | |
| 6314 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6315 | do_action( 'xmlrpc_call', 'metaWeblog.newMediaObject' ); |
| 6316 | |
| 6317 | if ( ! current_user_can( 'upload_files' ) ) { |
| 6318 | $this->error = new IXR_Error( 401, __( 'Sorry, you are not allowed to upload files.' ) ); |
| 6319 | return $this->error; |
| 6320 | } |
| 6321 | |
| 6322 | if ( is_multisite() && upload_is_user_over_quota( false ) ) { |
| 6323 | $this->error = new IXR_Error( |
| 6324 | 401, |
| Line | Code |
| 6425 | $query = array(); |
| 6426 | } |
| 6427 | |
| 6428 | $user = $this->login( $username, $password ); |
| 6429 | if ( ! $user ) { |
| 6430 | return $this->error; |
| 6431 | } |
| 6432 | |
| 6433 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6434 | do_action( 'xmlrpc_call', 'mt.getRecentPostTitles' ); |
| 6435 | |
| 6436 | $posts_list = wp_get_recent_posts( $query ); |
| 6437 | |
| 6438 | if ( ! $posts_list ) { |
| 6439 | $this->error = new IXR_Error( 500, __( 'Either there are no posts, or something went wrong.' ) ); |
| 6440 | return $this->error; |
| 6441 | } |
| 6442 | |
| 6443 | $recent_posts = array(); |
| Line | Code |
| 6487 | if ( ! $user ) { |
| 6488 | return $this->error; |
| 6489 | } |
| 6490 | |
| 6491 | if ( ! current_user_can( 'edit_posts' ) ) { |
| 6492 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
| 6493 | } |
| 6494 | |
| 6495 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6496 | do_action( 'xmlrpc_call', 'mt.getCategoryList' ); |
| 6497 | |
| 6498 | $categories_struct = array(); |
| 6499 | |
| 6500 | $cats = get_categories( |
| 6501 | array( |
| 6502 | 'hide_empty' => 0, |
| 6503 | 'hierarchical' => 0, |
| 6504 | ) |
| 6505 | ); |
| Line | Code |
| 6545 | if ( ! get_post( $post_ID ) ) { |
| 6546 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 6547 | } |
| 6548 | |
| 6549 | if ( ! current_user_can( 'edit_post', $post_ID ) ) { |
| 6550 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
| 6551 | } |
| 6552 | |
| 6553 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6554 | do_action( 'xmlrpc_call', 'mt.getPostCategories' ); |
| 6555 | |
| 6556 | $categories = array(); |
| 6557 | $catids = wp_get_post_categories( intval( $post_ID ) ); |
| 6558 | // First listed category will be the primary category. |
| 6559 | $isPrimary = true; |
| 6560 | foreach ( $catids as $catid ) { |
| 6561 | $categories[] = array( |
| 6562 | 'categoryName' => get_cat_name( $catid ), |
| 6563 | 'categoryId' => (string) $catid, |
| Line | Code |
| 6592 | $password = $args[2]; |
| 6593 | $categories = $args[3]; |
| 6594 | |
| 6595 | $user = $this->login( $username, $password ); |
| 6596 | if ( ! $user ) { |
| 6597 | return $this->error; |
| 6598 | } |
| 6599 | |
| 6600 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6601 | do_action( 'xmlrpc_call', 'mt.setPostCategories' ); |
| 6602 | |
| 6603 | if ( ! get_post( $post_ID ) ) { |
| 6604 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 6605 | } |
| 6606 | |
| 6607 | if ( ! current_user_can( 'edit_post', $post_ID ) ) { |
| 6608 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
| 6609 | } |
| 6610 | |
| Line | Code |
| 6621 | /** |
| 6622 | * Retrieve an array of methods supported by this server. |
| 6623 | * |
| 6624 | * @since 1.5.0 |
| 6625 | * |
| 6626 | * @return array |
| 6627 | */ |
| 6628 | public function mt_supportedMethods() { |
| 6629 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6630 | do_action( 'xmlrpc_call', 'mt.supportedMethods' ); |
| 6631 | |
| 6632 | return array_keys( $this->methods ); |
| 6633 | } |
| 6634 | |
| 6635 | /** |
| 6636 | * Retrieve an empty array because we don't support per-post text filters. |
| 6637 | * |
| 6638 | * @since 1.5.0 |
| 6639 | */ |
| 6640 | public function mt_supportedTextFilters() { |
| 6641 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6642 | do_action( 'xmlrpc_call', 'mt.supportedTextFilters' ); |
| 6643 | |
| 6644 | /** |
| 6645 | * Filters the MoveableType text filters list for XML-RPC. |
| 6646 | * |
| 6647 | * @since 2.2.0 |
| 6648 | * |
| 6649 | * @param array $filters An array of text filters. |
| 6650 | */ |
| 6651 | return apply_filters( 'xmlrpc_text_filters', array() ); |
| Line | Code |
| 6659 | * @global wpdb $wpdb WordPress database abstraction object. |
| 6660 | * |
| 6661 | * @param int $post_ID |
| 6662 | * @return array|IXR_Error |
| 6663 | */ |
| 6664 | public function mt_getTrackbackPings( $post_ID ) { |
| 6665 | global $wpdb; |
| 6666 | |
| 6667 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6668 | do_action( 'xmlrpc_call', 'mt.getTrackbackPings' ); |
| 6669 | |
| 6670 | $actual_post = get_post( $post_ID, ARRAY_A ); |
| 6671 | |
| 6672 | if ( ! $actual_post ) { |
| 6673 | return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); |
| 6674 | } |
| 6675 | |
| 6676 | $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 ) ); |
| 6677 | |
| Line | Code |
| 6716 | $username = $args[1]; |
| 6717 | $password = $args[2]; |
| 6718 | |
| 6719 | $user = $this->login( $username, $password ); |
| 6720 | if ( ! $user ) { |
| 6721 | return $this->error; |
| 6722 | } |
| 6723 | |
| 6724 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6725 | do_action( 'xmlrpc_call', 'mt.publishPost' ); |
| 6726 | |
| 6727 | $postdata = get_post( $post_ID, ARRAY_A ); |
| 6728 | if ( ! $postdata ) { |
| 6729 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 6730 | } |
| 6731 | |
| 6732 | if ( ! current_user_can( 'publish_posts' ) || ! current_user_can( 'edit_post', $post_ID ) ) { |
| 6733 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish this post.' ) ); |
| 6734 | } |
| Line | Code |
| 6758 | * @type string $pagelinkedfrom |
| 6759 | * @type string $pagelinkedto |
| 6760 | * } |
| 6761 | * @return string|IXR_Error |
| 6762 | */ |
| 6763 | public function pingback_ping( $args ) { |
| 6764 | global $wpdb; |
| 6765 | |
| 6766 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6767 | do_action( 'xmlrpc_call', 'pingback.ping' ); |
| 6768 | |
| 6769 | $this->escape( $args ); |
| 6770 | |
| 6771 | $pagelinkedfrom = str_replace( '&', '&', $args[0] ); |
| 6772 | $pagelinkedto = str_replace( '&', '&', $args[1] ); |
| 6773 | $pagelinkedto = str_replace( '&', '&', $pagelinkedto ); |
| 6774 | |
| 6775 | /** |
| 6776 | * Filters the pingback source URI. |
| Line | Code |
| 6997 | * @global wpdb $wpdb WordPress database abstraction object. |
| 6998 | * |
| 6999 | * @param string $url |
| 7000 | * @return array|IXR_Error |
| 7001 | */ |
| 7002 | public function pingback_extensions_getPingbacks( $url ) { |
| 7003 | global $wpdb; |
| 7004 | |
| 7005 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 7006 | do_action( 'xmlrpc_call', 'pingback.extensions.getPingbacks' ); |
| 7007 | |
| 7008 | $url = $this->escape( $url ); |
| 7009 | |
| 7010 | $post_ID = url_to_postid( $url ); |
| 7011 | if ( ! $post_ID ) { |
| 7012 | // We aren't sure that the resource is available and/or pingback enabled. |
| 7013 | 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.' ) ); |
| 7014 | } |
| 7015 | |