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 |
|---|---|
| 724 | * equal to the method's name, e.g., wp.getUsersBlogs, wp.newPost, etc. |
| 725 | * |
| 726 | * @since 2.5.0 |
| 727 | * @since 5.7.0 Added the `$args` and `$server` parameters. |
| 728 | * |
| 729 | * @param string $name The method name. |
| 730 | * @param array|string $args The escaped arguments passed to the method. |
| 731 | * @param wp_xmlrpc_server $server The XML-RPC server instance. |
| 732 | */ |
| 733 | do_action( 'xmlrpc_call', 'wp.getUsersBlogs', $args, $this ); |
| 734 | |
| 735 | $blogs = (array) get_blogs_of_user( $user->ID ); |
| 736 | $struct = array(); |
| 737 | $primary_blog_id = 0; |
| 738 | $active_blog = get_active_blog_for_user( $user->ID ); |
| 739 | if ( $active_blog ) { |
| 740 | $primary_blog_id = (int) $active_blog->blog_id; |
| 741 | } |
| 742 | |
| Line | Code |
| 1334 | if ( isset( $content_struct['post_date_gmt'] ) && ! ( $content_struct['post_date_gmt'] instanceof IXR_Date ) ) { |
| 1335 | if ( '0000-00-00 00:00:00' === $content_struct['post_date_gmt'] || isset( $content_struct['post_date'] ) ) { |
| 1336 | unset( $content_struct['post_date_gmt'] ); |
| 1337 | } else { |
| 1338 | $content_struct['post_date_gmt'] = $this->_convert_date( $content_struct['post_date_gmt'] ); |
| 1339 | } |
| 1340 | } |
| 1341 | |
| 1342 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1343 | do_action( 'xmlrpc_call', 'wp.newPost', $args, $this ); |
| 1344 | |
| 1345 | unset( $content_struct['ID'] ); |
| 1346 | |
| 1347 | return $this->_insert_post( $user, $content_struct ); |
| 1348 | } |
| 1349 | |
| 1350 | /** |
| 1351 | * Helper method for filtering out elements from an array. |
| 1352 | * |
| Line | Code |
| 1727 | $post_id = (int) $args[3]; |
| 1728 | $content_struct = $args[4]; |
| 1729 | |
| 1730 | $user = $this->login( $username, $password ); |
| 1731 | if ( ! $user ) { |
| 1732 | return $this->error; |
| 1733 | } |
| 1734 | |
| 1735 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1736 | do_action( 'xmlrpc_call', 'wp.editPost', $args, $this ); |
| 1737 | |
| 1738 | $post = get_post( $post_id, ARRAY_A ); |
| 1739 | |
| 1740 | if ( empty( $post['ID'] ) ) { |
| 1741 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 1742 | } |
| 1743 | |
| 1744 | if ( isset( $content_struct['if_not_modified_since'] ) ) { |
| 1745 | // If the post has been modified since the date provided, return an error. |
| Line | Code |
| 1810 | $password = $args[2]; |
| 1811 | $post_id = (int) $args[3]; |
| 1812 | |
| 1813 | $user = $this->login( $username, $password ); |
| 1814 | if ( ! $user ) { |
| 1815 | return $this->error; |
| 1816 | } |
| 1817 | |
| 1818 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1819 | do_action( 'xmlrpc_call', 'wp.deletePost', $args, $this ); |
| 1820 | |
| 1821 | $post = get_post( $post_id, ARRAY_A ); |
| 1822 | if ( empty( $post['ID'] ) ) { |
| 1823 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 1824 | } |
| 1825 | |
| 1826 | if ( ! current_user_can( 'delete_post', $post_id ) ) { |
| 1827 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) ); |
| 1828 | } |
| Line | Code |
| 1910 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPost' ); |
| 1911 | } |
| 1912 | |
| 1913 | $user = $this->login( $username, $password ); |
| 1914 | if ( ! $user ) { |
| 1915 | return $this->error; |
| 1916 | } |
| 1917 | |
| 1918 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1919 | do_action( 'xmlrpc_call', 'wp.getPost', $args, $this ); |
| 1920 | |
| 1921 | $post = get_post( $post_id, ARRAY_A ); |
| 1922 | |
| 1923 | if ( empty( $post['ID'] ) ) { |
| 1924 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 1925 | } |
| 1926 | |
| 1927 | if ( ! current_user_can( 'edit_post', $post_id ) ) { |
| 1928 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
| Line | Code |
| 1971 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPosts' ); |
| 1972 | } |
| 1973 | |
| 1974 | $user = $this->login( $username, $password ); |
| 1975 | if ( ! $user ) { |
| 1976 | return $this->error; |
| 1977 | } |
| 1978 | |
| 1979 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1980 | do_action( 'xmlrpc_call', 'wp.getPosts', $args, $this ); |
| 1981 | |
| 1982 | $query = array(); |
| 1983 | |
| 1984 | if ( isset( $filter['post_type'] ) ) { |
| 1985 | $post_type = get_post_type_object( $filter['post_type'] ); |
| 1986 | if ( ! ( (bool) $post_type ) ) { |
| 1987 | return new IXR_Error( 403, __( 'Invalid post type.' ) ); |
| 1988 | } |
| 1989 | } else { |
| Line | Code |
| 2070 | $password = $args[2]; |
| 2071 | $content_struct = $args[3]; |
| 2072 | |
| 2073 | $user = $this->login( $username, $password ); |
| 2074 | if ( ! $user ) { |
| 2075 | return $this->error; |
| 2076 | } |
| 2077 | |
| 2078 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2079 | do_action( 'xmlrpc_call', 'wp.newTerm', $args, $this ); |
| 2080 | |
| 2081 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) { |
| 2082 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 2083 | } |
| 2084 | |
| 2085 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
| 2086 | |
| 2087 | if ( ! current_user_can( $taxonomy->cap->edit_terms ) ) { |
| 2088 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to create terms in this taxonomy.' ) ); |
| Line | Code |
| 2175 | $term_id = (int) $args[3]; |
| 2176 | $content_struct = $args[4]; |
| 2177 | |
| 2178 | $user = $this->login( $username, $password ); |
| 2179 | if ( ! $user ) { |
| 2180 | return $this->error; |
| 2181 | } |
| 2182 | |
| 2183 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2184 | do_action( 'xmlrpc_call', 'wp.editTerm', $args, $this ); |
| 2185 | |
| 2186 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) { |
| 2187 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 2188 | } |
| 2189 | |
| 2190 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
| 2191 | |
| 2192 | $taxonomy = (array) $taxonomy; |
| 2193 | |
| Line | Code |
| 2291 | $taxonomy = $args[3]; |
| 2292 | $term_id = (int) $args[4]; |
| 2293 | |
| 2294 | $user = $this->login( $username, $password ); |
| 2295 | if ( ! $user ) { |
| 2296 | return $this->error; |
| 2297 | } |
| 2298 | |
| 2299 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2300 | do_action( 'xmlrpc_call', 'wp.deleteTerm', $args, $this ); |
| 2301 | |
| 2302 | if ( ! taxonomy_exists( $taxonomy ) ) { |
| 2303 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 2304 | } |
| 2305 | |
| 2306 | $taxonomy = get_taxonomy( $taxonomy ); |
| 2307 | $term = get_term( $term_id, $taxonomy->name ); |
| 2308 | |
| 2309 | if ( is_wp_error( $term ) ) { |
| Line | Code |
| 2370 | $taxonomy = $args[3]; |
| 2371 | $term_id = (int) $args[4]; |
| 2372 | |
| 2373 | $user = $this->login( $username, $password ); |
| 2374 | if ( ! $user ) { |
| 2375 | return $this->error; |
| 2376 | } |
| 2377 | |
| 2378 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2379 | do_action( 'xmlrpc_call', 'wp.getTerm', $args, $this ); |
| 2380 | |
| 2381 | if ( ! taxonomy_exists( $taxonomy ) ) { |
| 2382 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 2383 | } |
| 2384 | |
| 2385 | $taxonomy = get_taxonomy( $taxonomy ); |
| 2386 | |
| 2387 | $term = get_term( $term_id, $taxonomy->name, ARRAY_A ); |
| 2388 | |
| Line | Code |
| 2435 | $taxonomy = $args[3]; |
| 2436 | $filter = isset( $args[4] ) ? $args[4] : array(); |
| 2437 | |
| 2438 | $user = $this->login( $username, $password ); |
| 2439 | if ( ! $user ) { |
| 2440 | return $this->error; |
| 2441 | } |
| 2442 | |
| 2443 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2444 | do_action( 'xmlrpc_call', 'wp.getTerms', $args, $this ); |
| 2445 | |
| 2446 | if ( ! taxonomy_exists( $taxonomy ) ) { |
| 2447 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 2448 | } |
| 2449 | |
| 2450 | $taxonomy = get_taxonomy( $taxonomy ); |
| 2451 | |
| 2452 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) { |
| 2453 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ) ); |
| Line | Code |
| 2541 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomy' ); |
| 2542 | } |
| 2543 | |
| 2544 | $user = $this->login( $username, $password ); |
| 2545 | if ( ! $user ) { |
| 2546 | return $this->error; |
| 2547 | } |
| 2548 | |
| 2549 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2550 | do_action( 'xmlrpc_call', 'wp.getTaxonomy', $args, $this ); |
| 2551 | |
| 2552 | if ( ! taxonomy_exists( $taxonomy ) ) { |
| 2553 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 2554 | } |
| 2555 | |
| 2556 | $taxonomy = get_taxonomy( $taxonomy ); |
| 2557 | |
| 2558 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) { |
| 2559 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ) ); |
| Line | Code |
| 2599 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomies' ); |
| 2600 | } |
| 2601 | |
| 2602 | $user = $this->login( $username, $password ); |
| 2603 | if ( ! $user ) { |
| 2604 | return $this->error; |
| 2605 | } |
| 2606 | |
| 2607 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2608 | do_action( 'xmlrpc_call', 'wp.getTaxonomies', $args, $this ); |
| 2609 | |
| 2610 | $taxonomies = get_taxonomies( $filter, 'objects' ); |
| 2611 | |
| 2612 | // Holds all the taxonomy data. |
| 2613 | $struct = array(); |
| 2614 | |
| 2615 | foreach ( $taxonomies as $taxonomy ) { |
| 2616 | // Capability check for post types. |
| 2617 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) { |
| Line | Code |
| 2685 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUser' ); |
| 2686 | } |
| 2687 | |
| 2688 | $user = $this->login( $username, $password ); |
| 2689 | if ( ! $user ) { |
| 2690 | return $this->error; |
| 2691 | } |
| 2692 | |
| 2693 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2694 | do_action( 'xmlrpc_call', 'wp.getUser', $args, $this ); |
| 2695 | |
| 2696 | if ( ! current_user_can( 'edit_user', $user_id ) ) { |
| 2697 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this user.' ) ); |
| 2698 | } |
| 2699 | |
| 2700 | $user_data = get_userdata( $user_id ); |
| 2701 | |
| 2702 | if ( ! $user_data ) { |
| 2703 | return new IXR_Error( 404, __( 'Invalid user ID.' ) ); |
| Line | Code |
| 2748 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUsers' ); |
| 2749 | } |
| 2750 | |
| 2751 | $user = $this->login( $username, $password ); |
| 2752 | if ( ! $user ) { |
| 2753 | return $this->error; |
| 2754 | } |
| 2755 | |
| 2756 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2757 | do_action( 'xmlrpc_call', 'wp.getUsers', $args, $this ); |
| 2758 | |
| 2759 | if ( ! current_user_can( 'list_users' ) ) { |
| 2760 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to list users.' ) ); |
| 2761 | } |
| 2762 | |
| 2763 | $query = array( 'fields' => 'all_with_meta' ); |
| 2764 | |
| 2765 | $query['number'] = ( isset( $filter['number'] ) ) ? absint( $filter['number'] ) : 50; |
| 2766 | $query['offset'] = ( isset( $filter['offset'] ) ) ? absint( $filter['offset'] ) : 0; |
| Line | Code |
| 2828 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getProfile' ); |
| 2829 | } |
| 2830 | |
| 2831 | $user = $this->login( $username, $password ); |
| 2832 | if ( ! $user ) { |
| 2833 | return $this->error; |
| 2834 | } |
| 2835 | |
| 2836 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2837 | do_action( 'xmlrpc_call', 'wp.getProfile', $args, $this ); |
| 2838 | |
| 2839 | if ( ! current_user_can( 'edit_user', $user->ID ) ) { |
| 2840 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit your profile.' ) ); |
| 2841 | } |
| 2842 | |
| 2843 | $user_data = get_userdata( $user->ID ); |
| 2844 | |
| 2845 | return $this->_prepare_user( $user_data, $fields ); |
| 2846 | } |
| Line | Code |
| 2878 | $password = $args[2]; |
| 2879 | $content_struct = $args[3]; |
| 2880 | |
| 2881 | $user = $this->login( $username, $password ); |
| 2882 | if ( ! $user ) { |
| 2883 | return $this->error; |
| 2884 | } |
| 2885 | |
| 2886 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2887 | do_action( 'xmlrpc_call', 'wp.editProfile', $args, $this ); |
| 2888 | |
| 2889 | if ( ! current_user_can( 'edit_user', $user->ID ) ) { |
| 2890 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit your profile.' ) ); |
| 2891 | } |
| 2892 | |
| 2893 | // Holds data of the user. |
| 2894 | $user_data = array(); |
| 2895 | $user_data['ID'] = $user->ID; |
| 2896 | |
| Line | Code |
| 2967 | if ( ! $page ) { |
| 2968 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 2969 | } |
| 2970 | |
| 2971 | if ( ! current_user_can( 'edit_page', $page_id ) ) { |
| 2972 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this page.' ) ); |
| 2973 | } |
| 2974 | |
| 2975 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2976 | do_action( 'xmlrpc_call', 'wp.getPage', $args, $this ); |
| 2977 | |
| 2978 | // If we found the page then format the data. |
| 2979 | if ( $page->ID && ( 'page' === $page->post_type ) ) { |
| 2980 | return $this->_prepare_page( $page ); |
| 2981 | } else { |
| 2982 | // If the page doesn't exist, indicate that. |
| 2983 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
| 2984 | } |
| 2985 | } |
| Line | Code |
| 3010 | if ( ! $user ) { |
| 3011 | return $this->error; |
| 3012 | } |
| 3013 | |
| 3014 | if ( ! current_user_can( 'edit_pages' ) ) { |
| 3015 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit pages.' ) ); |
| 3016 | } |
| 3017 | |
| 3018 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3019 | do_action( 'xmlrpc_call', 'wp.getPages', $args, $this ); |
| 3020 | |
| 3021 | $pages = get_posts( |
| 3022 | array( |
| 3023 | 'post_type' => 'page', |
| 3024 | 'post_status' => 'any', |
| 3025 | 'numberposts' => $num_pages, |
| 3026 | ) |
| 3027 | ); |
| 3028 | $num_pages = count( $pages ); |
| Line | Code |
| 3065 | $username = $this->escape( $args[1] ); |
| 3066 | $password = $this->escape( $args[2] ); |
| 3067 | |
| 3068 | $user = $this->login( $username, $password ); |
| 3069 | if ( ! $user ) { |
| 3070 | return $this->error; |
| 3071 | } |
| 3072 | |
| 3073 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3074 | do_action( 'xmlrpc_call', 'wp.newPage', $args, $this ); |
| 3075 | |
| 3076 | // Mark this as content for a page. |
| 3077 | $args[3]['post_type'] = 'page'; |
| 3078 | |
| 3079 | // Let mw_newPost() do all of the heavy lifting. |
| 3080 | return $this->mw_newPost( $args ); |
| 3081 | } |
| 3082 | |
| 3083 | /** |
| Line | Code |
| 3102 | $password = $args[2]; |
| 3103 | $page_id = (int) $args[3]; |
| 3104 | |
| 3105 | $user = $this->login( $username, $password ); |
| 3106 | if ( ! $user ) { |
| 3107 | return $this->error; |
| 3108 | } |
| 3109 | |
| 3110 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3111 | do_action( 'xmlrpc_call', 'wp.deletePage', $args, $this ); |
| 3112 | |
| 3113 | // Get the current page based on the 'page_id' and |
| 3114 | // make sure it is a page and not a post. |
| 3115 | $actual_page = get_post( $page_id, ARRAY_A ); |
| 3116 | if ( ! $actual_page || ( 'page' !== $actual_page['post_type'] ) ) { |
| 3117 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
| 3118 | } |
| 3119 | |
| 3120 | // Make sure the user can delete pages. |
| Line | Code |
| 3169 | $escaped_username = $this->escape( $username ); |
| 3170 | $escaped_password = $this->escape( $password ); |
| 3171 | |
| 3172 | $user = $this->login( $escaped_username, $escaped_password ); |
| 3173 | if ( ! $user ) { |
| 3174 | return $this->error; |
| 3175 | } |
| 3176 | |
| 3177 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3178 | do_action( 'xmlrpc_call', 'wp.editPage', $args, $this ); |
| 3179 | |
| 3180 | // Get the page data and make sure it is a page. |
| 3181 | $actual_page = get_post( $page_id, ARRAY_A ); |
| 3182 | if ( ! $actual_page || ( 'page' !== $actual_page['post_type'] ) ) { |
| 3183 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
| 3184 | } |
| 3185 | |
| 3186 | // Make sure the user is allowed to edit pages. |
| 3187 | if ( ! current_user_can( 'edit_page', $page_id ) ) { |
| Line | Code |
| 3232 | if ( ! $user ) { |
| 3233 | return $this->error; |
| 3234 | } |
| 3235 | |
| 3236 | if ( ! current_user_can( 'edit_pages' ) ) { |
| 3237 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit pages.' ) ); |
| 3238 | } |
| 3239 | |
| 3240 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3241 | do_action( 'xmlrpc_call', 'wp.getPageList', $args, $this ); |
| 3242 | |
| 3243 | // Get list of page IDs and titles. |
| 3244 | $page_list = $wpdb->get_results( |
| 3245 | " |
| 3246 | SELECT ID page_id, |
| 3247 | post_title page_title, |
| 3248 | post_parent page_parent_id, |
| 3249 | post_date_gmt, |
| 3250 | post_date, |
| Line | Code |
| 3293 | if ( ! $user ) { |
| 3294 | return $this->error; |
| 3295 | } |
| 3296 | |
| 3297 | if ( ! current_user_can( 'edit_posts' ) ) { |
| 3298 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
| 3299 | } |
| 3300 | |
| 3301 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3302 | do_action( 'xmlrpc_call', 'wp.getAuthors', $args, $this ); |
| 3303 | |
| 3304 | $authors = array(); |
| 3305 | foreach ( get_users( array( 'fields' => array( 'ID', 'user_login', 'display_name' ) ) ) as $user ) { |
| 3306 | $authors[] = array( |
| 3307 | 'user_id' => $user->ID, |
| 3308 | 'user_login' => $user->user_login, |
| 3309 | 'display_name' => $user->display_name, |
| 3310 | ); |
| 3311 | } |
| Line | Code |
| 3337 | if ( ! $user ) { |
| 3338 | return $this->error; |
| 3339 | } |
| 3340 | |
| 3341 | if ( ! current_user_can( 'edit_posts' ) ) { |
| 3342 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view tags.' ) ); |
| 3343 | } |
| 3344 | |
| 3345 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3346 | do_action( 'xmlrpc_call', 'wp.getKeywords', $args, $this ); |
| 3347 | |
| 3348 | $tags = array(); |
| 3349 | |
| 3350 | $all_tags = get_tags(); |
| 3351 | if ( $all_tags ) { |
| 3352 | foreach ( (array) $all_tags as $tag ) { |
| 3353 | $struct = array(); |
| 3354 | $struct['tag_id'] = $tag->term_id; |
| 3355 | $struct['name'] = $tag->name; |
| Line | Code |
| 3387 | $password = $args[2]; |
| 3388 | $category = $args[3]; |
| 3389 | |
| 3390 | $user = $this->login( $username, $password ); |
| 3391 | if ( ! $user ) { |
| 3392 | return $this->error; |
| 3393 | } |
| 3394 | |
| 3395 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3396 | do_action( 'xmlrpc_call', 'wp.newCategory', $args, $this ); |
| 3397 | |
| 3398 | // Make sure the user is allowed to add a category. |
| 3399 | if ( ! current_user_can( 'manage_categories' ) ) { |
| 3400 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to add a category.' ) ); |
| 3401 | } |
| 3402 | |
| 3403 | // If no slug was provided, make it empty |
| 3404 | // so that WordPress will generate one. |
| 3405 | if ( empty( $category['slug'] ) ) { |
| Line | Code |
| 3470 | $password = $args[2]; |
| 3471 | $category_id = (int) $args[3]; |
| 3472 | |
| 3473 | $user = $this->login( $username, $password ); |
| 3474 | if ( ! $user ) { |
| 3475 | return $this->error; |
| 3476 | } |
| 3477 | |
| 3478 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3479 | do_action( 'xmlrpc_call', 'wp.deleteCategory', $args, $this ); |
| 3480 | |
| 3481 | if ( ! current_user_can( 'delete_term', $category_id ) ) { |
| 3482 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this category.' ) ); |
| 3483 | } |
| 3484 | |
| 3485 | $status = wp_delete_term( $category_id, 'category' ); |
| 3486 | |
| 3487 | if ( true == $status ) { |
| 3488 | /** |
| Line | Code |
| 3527 | if ( ! $user ) { |
| 3528 | return $this->error; |
| 3529 | } |
| 3530 | |
| 3531 | if ( ! current_user_can( 'edit_posts' ) ) { |
| 3532 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
| 3533 | } |
| 3534 | |
| 3535 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3536 | do_action( 'xmlrpc_call', 'wp.suggestCategories', $args, $this ); |
| 3537 | |
| 3538 | $category_suggestions = array(); |
| 3539 | $args = array( |
| 3540 | 'get' => 'all', |
| 3541 | 'number' => $max_results, |
| 3542 | 'name__like' => $category, |
| 3543 | ); |
| 3544 | foreach ( (array) get_categories( $args ) as $cat ) { |
| 3545 | $category_suggestions[] = array( |
| Line | Code |
| 3573 | $password = $args[2]; |
| 3574 | $comment_id = (int) $args[3]; |
| 3575 | |
| 3576 | $user = $this->login( $username, $password ); |
| 3577 | if ( ! $user ) { |
| 3578 | return $this->error; |
| 3579 | } |
| 3580 | |
| 3581 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3582 | do_action( 'xmlrpc_call', 'wp.getComment', $args, $this ); |
| 3583 | |
| 3584 | $comment = get_comment( $comment_id ); |
| 3585 | if ( ! $comment ) { |
| 3586 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 3587 | } |
| 3588 | |
| 3589 | if ( ! current_user_can( 'edit_comment', $comment_id ) ) { |
| 3590 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) ); |
| 3591 | } |
| Line | Code |
| 3626 | $password = $args[2]; |
| 3627 | $struct = isset( $args[3] ) ? $args[3] : array(); |
| 3628 | |
| 3629 | $user = $this->login( $username, $password ); |
| 3630 | if ( ! $user ) { |
| 3631 | return $this->error; |
| 3632 | } |
| 3633 | |
| 3634 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3635 | do_action( 'xmlrpc_call', 'wp.getComments', $args, $this ); |
| 3636 | |
| 3637 | if ( isset( $struct['status'] ) ) { |
| 3638 | $status = $struct['status']; |
| 3639 | } else { |
| 3640 | $status = ''; |
| 3641 | } |
| 3642 | |
| 3643 | if ( ! current_user_can( 'moderate_comments' ) && 'approve' !== $status ) { |
| 3644 | return new IXR_Error( 401, __( 'Invalid comment status.' ) ); |
| Line | Code |
| 3721 | if ( ! get_comment( $comment_ID ) ) { |
| 3722 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 3723 | } |
| 3724 | |
| 3725 | if ( ! current_user_can( 'edit_comment', $comment_ID ) ) { |
| 3726 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to delete this comment.' ) ); |
| 3727 | } |
| 3728 | |
| 3729 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3730 | do_action( 'xmlrpc_call', 'wp.deleteComment', $args, $this ); |
| 3731 | |
| 3732 | $status = wp_delete_comment( $comment_ID ); |
| 3733 | |
| 3734 | if ( $status ) { |
| 3735 | /** |
| 3736 | * Fires after a comment has been successfully deleted via XML-RPC. |
| 3737 | * |
| 3738 | * @since 3.4.0 |
| 3739 | * |
| Line | Code |
| 3789 | if ( ! get_comment( $comment_ID ) ) { |
| 3790 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 3791 | } |
| 3792 | |
| 3793 | if ( ! current_user_can( 'edit_comment', $comment_ID ) ) { |
| 3794 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) ); |
| 3795 | } |
| 3796 | |
| 3797 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3798 | do_action( 'xmlrpc_call', 'wp.editComment', $args, $this ); |
| 3799 | $comment = array( |
| 3800 | 'comment_ID' => $comment_ID, |
| 3801 | ); |
| 3802 | |
| 3803 | if ( isset( $content_struct['status'] ) ) { |
| 3804 | $statuses = get_comment_statuses(); |
| 3805 | $statuses = array_keys( $statuses ); |
| 3806 | |
| 3807 | if ( ! in_array( $content_struct['status'], $statuses, true ) ) { |
| Line | Code |
| 3982 | |
| 3983 | /** This filter is documented in wp-includes/comment.php */ |
| 3984 | $allow_empty = apply_filters( 'allow_empty_comment', false, $comment ); |
| 3985 | |
| 3986 | if ( ! $allow_empty && '' === $comment['comment_content'] ) { |
| 3987 | return new IXR_Error( 403, __( 'Comment is required.' ) ); |
| 3988 | } |
| 3989 | |
| 3990 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3991 | do_action( 'xmlrpc_call', 'wp.newComment', $args, $this ); |
| 3992 | |
| 3993 | $comment_ID = wp_new_comment( $comment, true ); |
| 3994 | if ( is_wp_error( $comment_ID ) ) { |
| 3995 | return new IXR_Error( 403, $comment_ID->get_error_message() ); |
| 3996 | } |
| 3997 | |
| 3998 | if ( ! $comment_ID ) { |
| 3999 | return new IXR_Error( 403, __( 'Something went wrong.' ) ); |
| 4000 | } |
| Line | Code |
| 4036 | if ( ! $user ) { |
| 4037 | return $this->error; |
| 4038 | } |
| 4039 | |
| 4040 | if ( ! current_user_can( 'publish_posts' ) ) { |
| 4041 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) ); |
| 4042 | } |
| 4043 | |
| 4044 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4045 | do_action( 'xmlrpc_call', 'wp.getCommentStatusList', $args, $this ); |
| 4046 | |
| 4047 | return get_comment_statuses(); |
| 4048 | } |
| 4049 | |
| 4050 | /** |
| 4051 | * Retrieve comment count. |
| 4052 | * |
| 4053 | * @since 2.5.0 |
| 4054 | * |
| Line | Code |
| 4078 | if ( empty( $post['ID'] ) ) { |
| 4079 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4080 | } |
| 4081 | |
| 4082 | if ( ! current_user_can( 'edit_post', $post_id ) ) { |
| 4083 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details of this post.' ) ); |
| 4084 | } |
| 4085 | |
| 4086 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4087 | do_action( 'xmlrpc_call', 'wp.getCommentCount', $args, $this ); |
| 4088 | |
| 4089 | $count = wp_count_comments( $post_id ); |
| 4090 | |
| 4091 | return array( |
| 4092 | 'approved' => $count->approved, |
| 4093 | 'awaiting_moderation' => $count->moderated, |
| 4094 | 'spam' => $count->spam, |
| 4095 | 'total_comments' => $count->total_comments, |
| 4096 | ); |
| Line | Code |
| 4120 | if ( ! $user ) { |
| 4121 | return $this->error; |
| 4122 | } |
| 4123 | |
| 4124 | if ( ! current_user_can( 'edit_posts' ) ) { |
| 4125 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) ); |
| 4126 | } |
| 4127 | |
| 4128 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4129 | do_action( 'xmlrpc_call', 'wp.getPostStatusList', $args, $this ); |
| 4130 | |
| 4131 | return get_post_statuses(); |
| 4132 | } |
| 4133 | |
| 4134 | /** |
| 4135 | * Retrieve page statuses. |
| 4136 | * |
| 4137 | * @since 2.5.0 |
| 4138 | * |
| Line | Code |
| 4155 | if ( ! $user ) { |
| 4156 | return $this->error; |
| 4157 | } |
| 4158 | |
| 4159 | if ( ! current_user_can( 'edit_pages' ) ) { |
| 4160 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) ); |
| 4161 | } |
| 4162 | |
| 4163 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4164 | do_action( 'xmlrpc_call', 'wp.getPageStatusList', $args, $this ); |
| 4165 | |
| 4166 | return get_page_statuses(); |
| 4167 | } |
| 4168 | |
| 4169 | /** |
| 4170 | * Retrieve page templates. |
| 4171 | * |
| 4172 | * @since 2.6.0 |
| 4173 | * |
| Line | Code |
| 4348 | if ( ! $user ) { |
| 4349 | return $this->error; |
| 4350 | } |
| 4351 | |
| 4352 | if ( ! current_user_can( 'upload_files' ) ) { |
| 4353 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to upload files.' ) ); |
| 4354 | } |
| 4355 | |
| 4356 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4357 | do_action( 'xmlrpc_call', 'wp.getMediaItem', $args, $this ); |
| 4358 | |
| 4359 | $attachment = get_post( $attachment_id ); |
| 4360 | if ( ! $attachment || 'attachment' !== $attachment->post_type ) { |
| 4361 | return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); |
| 4362 | } |
| 4363 | |
| 4364 | return $this->_prepare_media_item( $attachment ); |
| 4365 | } |
| 4366 | |
| Line | Code |
| 4401 | if ( ! $user ) { |
| 4402 | return $this->error; |
| 4403 | } |
| 4404 | |
| 4405 | if ( ! current_user_can( 'upload_files' ) ) { |
| 4406 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to upload files.' ) ); |
| 4407 | } |
| 4408 | |
| 4409 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4410 | do_action( 'xmlrpc_call', 'wp.getMediaLibrary', $args, $this ); |
| 4411 | |
| 4412 | $parent_id = ( isset( $struct['parent_id'] ) ) ? absint( $struct['parent_id'] ) : ''; |
| 4413 | $mime_type = ( isset( $struct['mime_type'] ) ) ? $struct['mime_type'] : ''; |
| 4414 | $offset = ( isset( $struct['offset'] ) ) ? absint( $struct['offset'] ) : 0; |
| 4415 | $number = ( isset( $struct['number'] ) ) ? absint( $struct['number'] ) : -1; |
| 4416 | |
| 4417 | $attachments = get_posts( |
| 4418 | array( |
| 4419 | 'post_type' => 'attachment', |
| Line | Code |
| 4457 | if ( ! $user ) { |
| 4458 | return $this->error; |
| 4459 | } |
| 4460 | |
| 4461 | if ( ! current_user_can( 'edit_posts' ) ) { |
| 4462 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) ); |
| 4463 | } |
| 4464 | |
| 4465 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4466 | do_action( 'xmlrpc_call', 'wp.getPostFormats', $args, $this ); |
| 4467 | |
| 4468 | $formats = get_post_format_strings(); |
| 4469 | |
| 4470 | // Find out if they want a list of currently supports formats. |
| 4471 | if ( isset( $args[3] ) && is_array( $args[3] ) ) { |
| 4472 | if ( $args[3]['show-supported'] ) { |
| 4473 | if ( current_theme_supports( 'post-formats' ) ) { |
| 4474 | $supported = get_theme_support( 'post-formats' ); |
| 4475 | |
| Line | Code |
| 4537 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostType' ); |
| 4538 | } |
| 4539 | |
| 4540 | $user = $this->login( $username, $password ); |
| 4541 | if ( ! $user ) { |
| 4542 | return $this->error; |
| 4543 | } |
| 4544 | |
| 4545 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4546 | do_action( 'xmlrpc_call', 'wp.getPostType', $args, $this ); |
| 4547 | |
| 4548 | if ( ! post_type_exists( $post_type_name ) ) { |
| 4549 | return new IXR_Error( 403, __( 'Invalid post type.' ) ); |
| 4550 | } |
| 4551 | |
| 4552 | $post_type = get_post_type_object( $post_type_name ); |
| 4553 | |
| 4554 | if ( ! current_user_can( $post_type->cap->edit_posts ) ) { |
| 4555 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts in this post type.' ) ); |
| Line | Code |
| 4594 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostTypes' ); |
| 4595 | } |
| 4596 | |
| 4597 | $user = $this->login( $username, $password ); |
| 4598 | if ( ! $user ) { |
| 4599 | return $this->error; |
| 4600 | } |
| 4601 | |
| 4602 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4603 | do_action( 'xmlrpc_call', 'wp.getPostTypes', $args, $this ); |
| 4604 | |
| 4605 | $post_types = get_post_types( $filter, 'objects' ); |
| 4606 | |
| 4607 | $struct = array(); |
| 4608 | |
| 4609 | foreach ( $post_types as $post_type ) { |
| 4610 | if ( ! current_user_can( $post_type->cap->edit_posts ) ) { |
| 4611 | continue; |
| 4612 | } |
| Line | Code |
| 4664 | $fields = apply_filters( 'xmlrpc_default_revision_fields', array( 'post_date', 'post_date_gmt' ), 'wp.getRevisions' ); |
| 4665 | } |
| 4666 | |
| 4667 | $user = $this->login( $username, $password ); |
| 4668 | if ( ! $user ) { |
| 4669 | return $this->error; |
| 4670 | } |
| 4671 | |
| 4672 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4673 | do_action( 'xmlrpc_call', 'wp.getRevisions', $args, $this ); |
| 4674 | |
| 4675 | $post = get_post( $post_id ); |
| 4676 | if ( ! $post ) { |
| 4677 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4678 | } |
| 4679 | |
| 4680 | if ( ! current_user_can( 'edit_post', $post_id ) ) { |
| 4681 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
| 4682 | } |
| Line | Code |
| 4738 | $password = $args[2]; |
| 4739 | $revision_id = (int) $args[3]; |
| 4740 | |
| 4741 | $user = $this->login( $username, $password ); |
| 4742 | if ( ! $user ) { |
| 4743 | return $this->error; |
| 4744 | } |
| 4745 | |
| 4746 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4747 | do_action( 'xmlrpc_call', 'wp.restoreRevision', $args, $this ); |
| 4748 | |
| 4749 | $revision = wp_get_post_revision( $revision_id ); |
| 4750 | if ( ! $revision ) { |
| 4751 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4752 | } |
| 4753 | |
| 4754 | if ( wp_is_post_autosave( $revision ) ) { |
| 4755 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4756 | } |
| Line | Code |
| 4809 | $username = $args[1]; |
| 4810 | $password = $args[2]; |
| 4811 | |
| 4812 | $user = $this->login( $username, $password ); |
| 4813 | if ( ! $user ) { |
| 4814 | return $this->error; |
| 4815 | } |
| 4816 | |
| 4817 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4818 | do_action( 'xmlrpc_call', 'blogger.getUsersBlogs', $args, $this ); |
| 4819 | |
| 4820 | $is_admin = current_user_can( 'manage_options' ); |
| 4821 | |
| 4822 | $struct = array( |
| 4823 | 'isAdmin' => $is_admin, |
| 4824 | 'url' => get_option( 'home' ) . '/', |
| 4825 | 'blogid' => '1', |
| 4826 | 'blogName' => get_option( 'blogname' ), |
| 4827 | 'xmlrpc' => site_url( 'xmlrpc.php', 'rpc' ), |
| Line | Code |
| 4895 | if ( ! $user ) { |
| 4896 | return $this->error; |
| 4897 | } |
| 4898 | |
| 4899 | if ( ! current_user_can( 'edit_posts' ) ) { |
| 4900 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to access user data on this site.' ) ); |
| 4901 | } |
| 4902 | |
| 4903 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4904 | do_action( 'xmlrpc_call', 'blogger.getUserInfo', $args, $this ); |
| 4905 | |
| 4906 | $struct = array( |
| 4907 | 'nickname' => $user->nickname, |
| 4908 | 'userid' => $user->ID, |
| 4909 | 'url' => $user->user_url, |
| 4910 | 'lastname' => $user->last_name, |
| 4911 | 'firstname' => $user->first_name, |
| 4912 | ); |
| 4913 | |
| Line | Code |
| 4945 | if ( ! $post_data ) { |
| 4946 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4947 | } |
| 4948 | |
| 4949 | if ( ! current_user_can( 'edit_post', $post_ID ) ) { |
| 4950 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
| 4951 | } |
| 4952 | |
| 4953 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4954 | do_action( 'xmlrpc_call', 'blogger.getPost', $args, $this ); |
| 4955 | |
| 4956 | $categories = implode( ',', wp_get_post_categories( $post_ID ) ); |
| 4957 | |
| 4958 | $content = '<title>' . wp_unslash( $post_data['post_title'] ) . '</title>'; |
| 4959 | $content .= '<category>' . $categories . '</category>'; |
| 4960 | $content .= wp_unslash( $post_data['post_content'] ); |
| 4961 | |
| 4962 | $struct = array( |
| 4963 | 'userid' => $post_data['post_author'], |
| Line | Code |
| 5002 | if ( ! $user ) { |
| 5003 | return $this->error; |
| 5004 | } |
| 5005 | |
| 5006 | if ( ! current_user_can( 'edit_posts' ) ) { |
| 5007 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
| 5008 | } |
| 5009 | |
| 5010 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5011 | do_action( 'xmlrpc_call', 'blogger.getRecentPosts', $args, $this ); |
| 5012 | |
| 5013 | $posts_list = wp_get_recent_posts( $query ); |
| 5014 | |
| 5015 | if ( ! $posts_list ) { |
| 5016 | $this->error = new IXR_Error( 500, __( 'Either there are no posts, or something went wrong.' ) ); |
| 5017 | return $this->error; |
| 5018 | } |
| 5019 | |
| 5020 | $recent_posts = array(); |
| Line | Code |
| 5092 | $content = $args[4]; |
| 5093 | $publish = $args[5]; |
| 5094 | |
| 5095 | $user = $this->login( $username, $password ); |
| 5096 | if ( ! $user ) { |
| 5097 | return $this->error; |
| 5098 | } |
| 5099 | |
| 5100 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5101 | do_action( 'xmlrpc_call', 'blogger.newPost', $args, $this ); |
| 5102 | |
| 5103 | $cap = ( $publish ) ? 'publish_posts' : 'edit_posts'; |
| 5104 | if ( ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) || ! current_user_can( $cap ) ) { |
| 5105 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to post on this site.' ) ); |
| 5106 | } |
| 5107 | |
| 5108 | $post_status = ( $publish ) ? 'publish' : 'draft'; |
| 5109 | |
| 5110 | $post_author = $user->ID; |
| Line | Code |
| 5169 | $content = $args[4]; |
| 5170 | $publish = $args[5]; |
| 5171 | |
| 5172 | $user = $this->login( $username, $password ); |
| 5173 | if ( ! $user ) { |
| 5174 | return $this->error; |
| 5175 | } |
| 5176 | |
| 5177 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5178 | do_action( 'xmlrpc_call', 'blogger.editPost', $args, $this ); |
| 5179 | |
| 5180 | $actual_post = get_post( $post_ID, ARRAY_A ); |
| 5181 | |
| 5182 | if ( ! $actual_post || 'post' !== $actual_post['post_type'] ) { |
| 5183 | return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); |
| 5184 | } |
| 5185 | |
| 5186 | $this->escape( $actual_post ); |
| 5187 | |
| Line | Code |
| 5243 | $username = $args[2]; |
| 5244 | $password = $args[3]; |
| 5245 | |
| 5246 | $user = $this->login( $username, $password ); |
| 5247 | if ( ! $user ) { |
| 5248 | return $this->error; |
| 5249 | } |
| 5250 | |
| 5251 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5252 | do_action( 'xmlrpc_call', 'blogger.deletePost', $args, $this ); |
| 5253 | |
| 5254 | $actual_post = get_post( $post_ID, ARRAY_A ); |
| 5255 | |
| 5256 | if ( ! $actual_post || 'post' !== $actual_post['post_type'] ) { |
| 5257 | return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); |
| 5258 | } |
| 5259 | |
| 5260 | if ( ! current_user_can( 'delete_post', $post_ID ) ) { |
| 5261 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) ); |
| Line | Code |
| 5331 | $content_struct = $args[3]; |
| 5332 | $publish = isset( $args[4] ) ? $args[4] : 0; |
| 5333 | |
| 5334 | $user = $this->login( $username, $password ); |
| 5335 | if ( ! $user ) { |
| 5336 | return $this->error; |
| 5337 | } |
| 5338 | |
| 5339 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5340 | do_action( 'xmlrpc_call', 'metaWeblog.newPost', $args, $this ); |
| 5341 | |
| 5342 | $page_template = ''; |
| 5343 | if ( ! empty( $content_struct['post_type'] ) ) { |
| 5344 | if ( 'page' === $content_struct['post_type'] ) { |
| 5345 | if ( $publish ) { |
| 5346 | $cap = 'publish_pages'; |
| 5347 | } elseif ( isset( $content_struct['page_status'] ) && 'publish' === $content_struct['page_status'] ) { |
| 5348 | $cap = 'publish_pages'; |
| 5349 | } else { |
| Line | Code |
| 5710 | $content_struct = $args[3]; |
| 5711 | $publish = isset( $args[4] ) ? $args[4] : 0; |
| 5712 | |
| 5713 | $user = $this->login( $username, $password ); |
| 5714 | if ( ! $user ) { |
| 5715 | return $this->error; |
| 5716 | } |
| 5717 | |
| 5718 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5719 | do_action( 'xmlrpc_call', 'metaWeblog.editPost', $args, $this ); |
| 5720 | |
| 5721 | $postdata = get_post( $post_ID, ARRAY_A ); |
| 5722 | |
| 5723 | /* |
| 5724 | * If there is no post data for the give post ID, stop now and return an error. |
| 5725 | * Otherwise a new post will be created (which was the old behavior). |
| 5726 | */ |
| 5727 | if ( ! $postdata || empty( $postdata['ID'] ) ) { |
| 5728 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| Line | Code |
| 6048 | if ( ! $postdata ) { |
| 6049 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 6050 | } |
| 6051 | |
| 6052 | if ( ! current_user_can( 'edit_post', $post_ID ) ) { |
| 6053 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
| 6054 | } |
| 6055 | |
| 6056 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6057 | do_action( 'xmlrpc_call', 'metaWeblog.getPost', $args, $this ); |
| 6058 | |
| 6059 | if ( '' !== $postdata['post_date'] ) { |
| 6060 | $post_date = $this->_convert_date( $postdata['post_date'] ); |
| 6061 | $post_date_gmt = $this->_convert_date_gmt( $postdata['post_date_gmt'], $postdata['post_date'] ); |
| 6062 | $post_modified = $this->_convert_date( $postdata['post_modified'] ); |
| 6063 | $post_modified_gmt = $this->_convert_date_gmt( $postdata['post_modified_gmt'], $postdata['post_modified'] ); |
| 6064 | |
| 6065 | $categories = array(); |
| 6066 | $catids = wp_get_post_categories( $post_ID ); |
| Line | Code |
| 6189 | if ( ! $user ) { |
| 6190 | return $this->error; |
| 6191 | } |
| 6192 | |
| 6193 | if ( ! current_user_can( 'edit_posts' ) ) { |
| 6194 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
| 6195 | } |
| 6196 | |
| 6197 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6198 | do_action( 'xmlrpc_call', 'metaWeblog.getRecentPosts', $args, $this ); |
| 6199 | |
| 6200 | $posts_list = wp_get_recent_posts( $query ); |
| 6201 | |
| 6202 | if ( ! $posts_list ) { |
| 6203 | return array(); |
| 6204 | } |
| 6205 | |
| 6206 | $recent_posts = array(); |
| 6207 | foreach ( $posts_list as $entry ) { |
| Line | Code |
| 6310 | if ( ! $user ) { |
| 6311 | return $this->error; |
| 6312 | } |
| 6313 | |
| 6314 | if ( ! current_user_can( 'edit_posts' ) ) { |
| 6315 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
| 6316 | } |
| 6317 | |
| 6318 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6319 | do_action( 'xmlrpc_call', 'metaWeblog.getCategories', $args, $this ); |
| 6320 | |
| 6321 | $categories_struct = array(); |
| 6322 | |
| 6323 | $cats = get_categories( array( 'get' => 'all' ) ); |
| 6324 | if ( $cats ) { |
| 6325 | foreach ( $cats as $cat ) { |
| 6326 | $struct = array(); |
| 6327 | $struct['categoryId'] = $cat->term_id; |
| 6328 | $struct['parentId'] = $cat->parent; |
| Line | Code |
| 6371 | $type = $data['type']; |
| 6372 | $bits = $data['bits']; |
| 6373 | |
| 6374 | $user = $this->login( $username, $password ); |
| 6375 | if ( ! $user ) { |
| 6376 | return $this->error; |
| 6377 | } |
| 6378 | |
| 6379 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6380 | do_action( 'xmlrpc_call', 'metaWeblog.newMediaObject', $args, $this ); |
| 6381 | |
| 6382 | if ( ! current_user_can( 'upload_files' ) ) { |
| 6383 | $this->error = new IXR_Error( 401, __( 'Sorry, you are not allowed to upload files.' ) ); |
| 6384 | return $this->error; |
| 6385 | } |
| 6386 | |
| 6387 | if ( is_multisite() && upload_is_user_over_quota( false ) ) { |
| 6388 | $this->error = new IXR_Error( |
| 6389 | 401, |
| Line | Code |
| 6490 | $query = array(); |
| 6491 | } |
| 6492 | |
| 6493 | $user = $this->login( $username, $password ); |
| 6494 | if ( ! $user ) { |
| 6495 | return $this->error; |
| 6496 | } |
| 6497 | |
| 6498 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6499 | do_action( 'xmlrpc_call', 'mt.getRecentPostTitles', $args, $this ); |
| 6500 | |
| 6501 | $posts_list = wp_get_recent_posts( $query ); |
| 6502 | |
| 6503 | if ( ! $posts_list ) { |
| 6504 | $this->error = new IXR_Error( 500, __( 'Either there are no posts, or something went wrong.' ) ); |
| 6505 | return $this->error; |
| 6506 | } |
| 6507 | |
| 6508 | $recent_posts = array(); |
| Line | Code |
| 6552 | if ( ! $user ) { |
| 6553 | return $this->error; |
| 6554 | } |
| 6555 | |
| 6556 | if ( ! current_user_can( 'edit_posts' ) ) { |
| 6557 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
| 6558 | } |
| 6559 | |
| 6560 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6561 | do_action( 'xmlrpc_call', 'mt.getCategoryList', $args, $this ); |
| 6562 | |
| 6563 | $categories_struct = array(); |
| 6564 | |
| 6565 | $cats = get_categories( |
| 6566 | array( |
| 6567 | 'hide_empty' => 0, |
| 6568 | 'hierarchical' => 0, |
| 6569 | ) |
| 6570 | ); |
| Line | Code |
| 6610 | if ( ! get_post( $post_ID ) ) { |
| 6611 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 6612 | } |
| 6613 | |
| 6614 | if ( ! current_user_can( 'edit_post', $post_ID ) ) { |
| 6615 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
| 6616 | } |
| 6617 | |
| 6618 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6619 | do_action( 'xmlrpc_call', 'mt.getPostCategories', $args, $this ); |
| 6620 | |
| 6621 | $categories = array(); |
| 6622 | $catids = wp_get_post_categories( (int) $post_ID ); |
| 6623 | // First listed category will be the primary category. |
| 6624 | $isPrimary = true; |
| 6625 | foreach ( $catids as $catid ) { |
| 6626 | $categories[] = array( |
| 6627 | 'categoryName' => get_cat_name( $catid ), |
| 6628 | 'categoryId' => (string) $catid, |
| Line | Code |
| 6657 | $password = $args[2]; |
| 6658 | $categories = $args[3]; |
| 6659 | |
| 6660 | $user = $this->login( $username, $password ); |
| 6661 | if ( ! $user ) { |
| 6662 | return $this->error; |
| 6663 | } |
| 6664 | |
| 6665 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6666 | do_action( 'xmlrpc_call', 'mt.setPostCategories', $args, $this ); |
| 6667 | |
| 6668 | if ( ! get_post( $post_ID ) ) { |
| 6669 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 6670 | } |
| 6671 | |
| 6672 | if ( ! current_user_can( 'edit_post', $post_ID ) ) { |
| 6673 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
| 6674 | } |
| 6675 | |
| Line | Code |
| 6686 | /** |
| 6687 | * Retrieve an array of methods supported by this server. |
| 6688 | * |
| 6689 | * @since 1.5.0 |
| 6690 | * |
| 6691 | * @return array |
| 6692 | */ |
| 6693 | public function mt_supportedMethods() { |
| 6694 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6695 | do_action( 'xmlrpc_call', 'mt.supportedMethods', array(), $this ); |
| 6696 | |
| 6697 | return array_keys( $this->methods ); |
| 6698 | } |
| 6699 | |
| 6700 | /** |
| 6701 | * Retrieve an empty array because we don't support per-post text filters. |
| 6702 | * |
| 6703 | * @since 1.5.0 |
| 6704 | */ |
| 6705 | public function mt_supportedTextFilters() { |
| 6706 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6707 | do_action( 'xmlrpc_call', 'mt.supportedTextFilters', array(), $this ); |
| 6708 | |
| 6709 | /** |
| 6710 | * Filters the MoveableType text filters list for XML-RPC. |
| 6711 | * |
| 6712 | * @since 2.2.0 |
| 6713 | * |
| 6714 | * @param array $filters An array of text filters. |
| 6715 | */ |
| 6716 | return apply_filters( 'xmlrpc_text_filters', array() ); |
| Line | Code |
| 6724 | * @global wpdb $wpdb WordPress database abstraction object. |
| 6725 | * |
| 6726 | * @param int $post_ID |
| 6727 | * @return array|IXR_Error |
| 6728 | */ |
| 6729 | public function mt_getTrackbackPings( $post_ID ) { |
| 6730 | global $wpdb; |
| 6731 | |
| 6732 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6733 | do_action( 'xmlrpc_call', 'mt.getTrackbackPings', $post_ID, $this ); |
| 6734 | |
| 6735 | $actual_post = get_post( $post_ID, ARRAY_A ); |
| 6736 | |
| 6737 | if ( ! $actual_post ) { |
| 6738 | return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); |
| 6739 | } |
| 6740 | |
| 6741 | $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 ) ); |
| 6742 | |
| Line | Code |
| 6781 | $username = $args[1]; |
| 6782 | $password = $args[2]; |
| 6783 | |
| 6784 | $user = $this->login( $username, $password ); |
| 6785 | if ( ! $user ) { |
| 6786 | return $this->error; |
| 6787 | } |
| 6788 | |
| 6789 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6790 | do_action( 'xmlrpc_call', 'mt.publishPost', $args, $this ); |
| 6791 | |
| 6792 | $postdata = get_post( $post_ID, ARRAY_A ); |
| 6793 | if ( ! $postdata ) { |
| 6794 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 6795 | } |
| 6796 | |
| 6797 | if ( ! current_user_can( 'publish_posts' ) || ! current_user_can( 'edit_post', $post_ID ) ) { |
| 6798 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish this post.' ) ); |
| 6799 | } |
| Line | Code |
| 6823 | * @type string $pagelinkedfrom |
| 6824 | * @type string $pagelinkedto |
| 6825 | * } |
| 6826 | * @return string|IXR_Error |
| 6827 | */ |
| 6828 | public function pingback_ping( $args ) { |
| 6829 | global $wpdb; |
| 6830 | |
| 6831 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6832 | do_action( 'xmlrpc_call', 'pingback.ping', $args, $this ); |
| 6833 | |
| 6834 | $this->escape( $args ); |
| 6835 | |
| 6836 | $pagelinkedfrom = str_replace( '&', '&', $args[0] ); |
| 6837 | $pagelinkedto = str_replace( '&', '&', $args[1] ); |
| 6838 | $pagelinkedto = str_replace( '&', '&', $pagelinkedto ); |
| 6839 | |
| 6840 | /** |
| 6841 | * Filters the pingback source URI. |
| Line | Code |
| 7062 | * @global wpdb $wpdb WordPress database abstraction object. |
| 7063 | * |
| 7064 | * @param string $url |
| 7065 | * @return array|IXR_Error |
| 7066 | */ |
| 7067 | public function pingback_extensions_getPingbacks( $url ) { |
| 7068 | global $wpdb; |
| 7069 | |
| 7070 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 7071 | do_action( 'xmlrpc_call', 'pingback.extensions.getPingbacks', $url, $this ); |
| 7072 | |
| 7073 | $url = $this->escape( $url ); |
| 7074 | |
| 7075 | $post_ID = url_to_postid( $url ); |
| 7076 | if ( ! $post_ID ) { |
| 7077 | // We aren't sure that the resource is available and/or pingback enabled. |
| 7078 | return $this->pingback_error( 33, __( 'The specified target URL cannot be used as a target. It either does not exist, or it is not a pingback-enabled resource.' ) ); |
| 7079 | } |
| 7080 | |