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 |
---|---|
725 | * equal to the method's name, e.g., wp.getUsersBlogs, wp.newPost, etc. |
726 | * |
727 | * @since 2.5.0 |
728 | * @since 5.7.0 Added the `$args` and `$server` parameters. |
729 | * |
730 | * @param string $name The method name. |
731 | * @param array|string $args The escaped arguments passed to the method. |
732 | * @param wp_xmlrpc_server $server The XML-RPC server instance. |
733 | */ |
734 | do_action( 'xmlrpc_call', 'wp.getUsersBlogs', $args, $this ); |
735 |
|
736 | $blogs = (array) get_blogs_of_user( $user->ID ); |
737 | $struct = array(); |
738 | $primary_blog_id = 0; |
739 | $active_blog = get_active_blog_for_user( $user->ID ); |
740 | if ( $active_blog ) { |
741 | $primary_blog_id = (int) $active_blog->blog_id; |
742 | } |
743 |
|
Line | Code |
1335 | if ( isset( $content_struct['post_date_gmt'] ) && ! ( $content_struct['post_date_gmt'] instanceof IXR_Date ) ) { |
1336 | if ( '0000-00-00 00:00:00' === $content_struct['post_date_gmt'] || isset( $content_struct['post_date'] ) ) { |
1337 | unset( $content_struct['post_date_gmt'] ); |
1338 | } else { |
1339 | $content_struct['post_date_gmt'] = $this->_convert_date( $content_struct['post_date_gmt'] ); |
1340 | } |
1341 | } |
1342 |
|
1343 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
1344 | do_action( 'xmlrpc_call', 'wp.newPost', $args, $this ); |
1345 |
|
1346 | unset( $content_struct['ID'] ); |
1347 |
|
1348 | return $this->_insert_post( $user, $content_struct ); |
1349 | } |
1350 |
|
1351 | /** |
1352 | * Helper method for filtering out elements from an array. |
1353 | * |
Line | Code |
1736 | $post_id = (int) $args[3]; |
1737 | $content_struct = $args[4]; |
1738 |
|
1739 | $user = $this->login( $username, $password ); |
1740 | if ( ! $user ) { |
1741 | return $this->error; |
1742 | } |
1743 |
|
1744 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
1745 | do_action( 'xmlrpc_call', 'wp.editPost', $args, $this ); |
1746 |
|
1747 | $post = get_post( $post_id, ARRAY_A ); |
1748 |
|
1749 | if ( empty( $post['ID'] ) ) { |
1750 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
1751 | } |
1752 |
|
1753 | if ( isset( $content_struct['if_not_modified_since'] ) ) { |
1754 | // If the post has been modified since the date provided, return an error. |
Line | Code |
1819 | $password = $args[2]; |
1820 | $post_id = (int) $args[3]; |
1821 |
|
1822 | $user = $this->login( $username, $password ); |
1823 | if ( ! $user ) { |
1824 | return $this->error; |
1825 | } |
1826 |
|
1827 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
1828 | do_action( 'xmlrpc_call', 'wp.deletePost', $args, $this ); |
1829 |
|
1830 | $post = get_post( $post_id, ARRAY_A ); |
1831 | if ( empty( $post['ID'] ) ) { |
1832 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
1833 | } |
1834 |
|
1835 | if ( ! current_user_can( 'delete_post', $post_id ) ) { |
1836 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) ); |
1837 | } |
Line | Code |
1919 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPost' ); |
1920 | } |
1921 |
|
1922 | $user = $this->login( $username, $password ); |
1923 | if ( ! $user ) { |
1924 | return $this->error; |
1925 | } |
1926 |
|
1927 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
1928 | do_action( 'xmlrpc_call', 'wp.getPost', $args, $this ); |
1929 |
|
1930 | $post = get_post( $post_id, ARRAY_A ); |
1931 |
|
1932 | if ( empty( $post['ID'] ) ) { |
1933 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
1934 | } |
1935 |
|
1936 | if ( ! current_user_can( 'edit_post', $post_id ) ) { |
1937 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
Line | Code |
1980 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPosts' ); |
1981 | } |
1982 |
|
1983 | $user = $this->login( $username, $password ); |
1984 | if ( ! $user ) { |
1985 | return $this->error; |
1986 | } |
1987 |
|
1988 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
1989 | do_action( 'xmlrpc_call', 'wp.getPosts', $args, $this ); |
1990 |
|
1991 | $query = array(); |
1992 |
|
1993 | if ( isset( $filter['post_type'] ) ) { |
1994 | $post_type = get_post_type_object( $filter['post_type'] ); |
1995 | if ( ! ( (bool) $post_type ) ) { |
1996 | return new IXR_Error( 403, __( 'Invalid post type.' ) ); |
1997 | } |
1998 | } else { |
Line | Code |
2079 | $password = $args[2]; |
2080 | $content_struct = $args[3]; |
2081 |
|
2082 | $user = $this->login( $username, $password ); |
2083 | if ( ! $user ) { |
2084 | return $this->error; |
2085 | } |
2086 |
|
2087 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2088 | do_action( 'xmlrpc_call', 'wp.newTerm', $args, $this ); |
2089 |
|
2090 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) { |
2091 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
2092 | } |
2093 |
|
2094 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
2095 |
|
2096 | if ( ! current_user_can( $taxonomy->cap->edit_terms ) ) { |
2097 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to create terms in this taxonomy.' ) ); |
Line | Code |
2184 | $term_id = (int) $args[3]; |
2185 | $content_struct = $args[4]; |
2186 |
|
2187 | $user = $this->login( $username, $password ); |
2188 | if ( ! $user ) { |
2189 | return $this->error; |
2190 | } |
2191 |
|
2192 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2193 | do_action( 'xmlrpc_call', 'wp.editTerm', $args, $this ); |
2194 |
|
2195 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) { |
2196 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
2197 | } |
2198 |
|
2199 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
2200 |
|
2201 | $taxonomy = (array) $taxonomy; |
2202 |
|
Line | Code |
2300 | $taxonomy = $args[3]; |
2301 | $term_id = (int) $args[4]; |
2302 |
|
2303 | $user = $this->login( $username, $password ); |
2304 | if ( ! $user ) { |
2305 | return $this->error; |
2306 | } |
2307 |
|
2308 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2309 | do_action( 'xmlrpc_call', 'wp.deleteTerm', $args, $this ); |
2310 |
|
2311 | if ( ! taxonomy_exists( $taxonomy ) ) { |
2312 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
2313 | } |
2314 |
|
2315 | $taxonomy = get_taxonomy( $taxonomy ); |
2316 | $term = get_term( $term_id, $taxonomy->name ); |
2317 |
|
2318 | if ( is_wp_error( $term ) ) { |
Line | Code |
2379 | $taxonomy = $args[3]; |
2380 | $term_id = (int) $args[4]; |
2381 |
|
2382 | $user = $this->login( $username, $password ); |
2383 | if ( ! $user ) { |
2384 | return $this->error; |
2385 | } |
2386 |
|
2387 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2388 | do_action( 'xmlrpc_call', 'wp.getTerm', $args, $this ); |
2389 |
|
2390 | if ( ! taxonomy_exists( $taxonomy ) ) { |
2391 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
2392 | } |
2393 |
|
2394 | $taxonomy = get_taxonomy( $taxonomy ); |
2395 |
|
2396 | $term = get_term( $term_id, $taxonomy->name, ARRAY_A ); |
2397 |
|
Line | Code |
2444 | $taxonomy = $args[3]; |
2445 | $filter = isset( $args[4] ) ? $args[4] : array(); |
2446 |
|
2447 | $user = $this->login( $username, $password ); |
2448 | if ( ! $user ) { |
2449 | return $this->error; |
2450 | } |
2451 |
|
2452 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2453 | do_action( 'xmlrpc_call', 'wp.getTerms', $args, $this ); |
2454 |
|
2455 | if ( ! taxonomy_exists( $taxonomy ) ) { |
2456 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
2457 | } |
2458 |
|
2459 | $taxonomy = get_taxonomy( $taxonomy ); |
2460 |
|
2461 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) { |
2462 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ) ); |
Line | Code |
2550 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomy' ); |
2551 | } |
2552 |
|
2553 | $user = $this->login( $username, $password ); |
2554 | if ( ! $user ) { |
2555 | return $this->error; |
2556 | } |
2557 |
|
2558 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2559 | do_action( 'xmlrpc_call', 'wp.getTaxonomy', $args, $this ); |
2560 |
|
2561 | if ( ! taxonomy_exists( $taxonomy ) ) { |
2562 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
2563 | } |
2564 |
|
2565 | $taxonomy = get_taxonomy( $taxonomy ); |
2566 |
|
2567 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) { |
2568 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ) ); |
Line | Code |
2608 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomies' ); |
2609 | } |
2610 |
|
2611 | $user = $this->login( $username, $password ); |
2612 | if ( ! $user ) { |
2613 | return $this->error; |
2614 | } |
2615 |
|
2616 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2617 | do_action( 'xmlrpc_call', 'wp.getTaxonomies', $args, $this ); |
2618 |
|
2619 | $taxonomies = get_taxonomies( $filter, 'objects' ); |
2620 |
|
2621 | // Holds all the taxonomy data. |
2622 | $struct = array(); |
2623 |
|
2624 | foreach ( $taxonomies as $taxonomy ) { |
2625 | // Capability check for post types. |
2626 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) { |
Line | Code |
2694 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUser' ); |
2695 | } |
2696 |
|
2697 | $user = $this->login( $username, $password ); |
2698 | if ( ! $user ) { |
2699 | return $this->error; |
2700 | } |
2701 |
|
2702 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2703 | do_action( 'xmlrpc_call', 'wp.getUser', $args, $this ); |
2704 |
|
2705 | if ( ! current_user_can( 'edit_user', $user_id ) ) { |
2706 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this user.' ) ); |
2707 | } |
2708 |
|
2709 | $user_data = get_userdata( $user_id ); |
2710 |
|
2711 | if ( ! $user_data ) { |
2712 | return new IXR_Error( 404, __( 'Invalid user ID.' ) ); |
Line | Code |
2757 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUsers' ); |
2758 | } |
2759 |
|
2760 | $user = $this->login( $username, $password ); |
2761 | if ( ! $user ) { |
2762 | return $this->error; |
2763 | } |
2764 |
|
2765 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2766 | do_action( 'xmlrpc_call', 'wp.getUsers', $args, $this ); |
2767 |
|
2768 | if ( ! current_user_can( 'list_users' ) ) { |
2769 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to list users.' ) ); |
2770 | } |
2771 |
|
2772 | $query = array( 'fields' => 'all_with_meta' ); |
2773 |
|
2774 | $query['number'] = ( isset( $filter['number'] ) ) ? absint( $filter['number'] ) : 50; |
2775 | $query['offset'] = ( isset( $filter['offset'] ) ) ? absint( $filter['offset'] ) : 0; |
Line | Code |
2837 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getProfile' ); |
2838 | } |
2839 |
|
2840 | $user = $this->login( $username, $password ); |
2841 | if ( ! $user ) { |
2842 | return $this->error; |
2843 | } |
2844 |
|
2845 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2846 | do_action( 'xmlrpc_call', 'wp.getProfile', $args, $this ); |
2847 |
|
2848 | if ( ! current_user_can( 'edit_user', $user->ID ) ) { |
2849 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit your profile.' ) ); |
2850 | } |
2851 |
|
2852 | $user_data = get_userdata( $user->ID ); |
2853 |
|
2854 | return $this->_prepare_user( $user_data, $fields ); |
2855 | } |
Line | Code |
2887 | $password = $args[2]; |
2888 | $content_struct = $args[3]; |
2889 |
|
2890 | $user = $this->login( $username, $password ); |
2891 | if ( ! $user ) { |
2892 | return $this->error; |
2893 | } |
2894 |
|
2895 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2896 | do_action( 'xmlrpc_call', 'wp.editProfile', $args, $this ); |
2897 |
|
2898 | if ( ! current_user_can( 'edit_user', $user->ID ) ) { |
2899 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit your profile.' ) ); |
2900 | } |
2901 |
|
2902 | // Holds data of the user. |
2903 | $user_data = array(); |
2904 | $user_data['ID'] = $user->ID; |
2905 |
|
Line | Code |
2976 | if ( ! $page ) { |
2977 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
2978 | } |
2979 |
|
2980 | if ( ! current_user_can( 'edit_page', $page_id ) ) { |
2981 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this page.' ) ); |
2982 | } |
2983 |
|
2984 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2985 | do_action( 'xmlrpc_call', 'wp.getPage', $args, $this ); |
2986 |
|
2987 | // If we found the page then format the data. |
2988 | if ( $page->ID && ( 'page' === $page->post_type ) ) { |
2989 | return $this->_prepare_page( $page ); |
2990 | } else { |
2991 | // If the page doesn't exist, indicate that. |
2992 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
2993 | } |
2994 | } |
Line | Code |
3019 | if ( ! $user ) { |
3020 | return $this->error; |
3021 | } |
3022 |
|
3023 | if ( ! current_user_can( 'edit_pages' ) ) { |
3024 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit pages.' ) ); |
3025 | } |
3026 |
|
3027 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3028 | do_action( 'xmlrpc_call', 'wp.getPages', $args, $this ); |
3029 |
|
3030 | $pages = get_posts( |
3031 | array( |
3032 | 'post_type' => 'page', |
3033 | 'post_status' => 'any', |
3034 | 'numberposts' => $num_pages, |
3035 | ) |
3036 | ); |
3037 | $num_pages = count( $pages ); |
Line | Code |
3074 | $username = $this->escape( $args[1] ); |
3075 | $password = $this->escape( $args[2] ); |
3076 |
|
3077 | $user = $this->login( $username, $password ); |
3078 | if ( ! $user ) { |
3079 | return $this->error; |
3080 | } |
3081 |
|
3082 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3083 | do_action( 'xmlrpc_call', 'wp.newPage', $args, $this ); |
3084 |
|
3085 | // Mark this as content for a page. |
3086 | $args[3]['post_type'] = 'page'; |
3087 |
|
3088 | // Let mw_newPost() do all of the heavy lifting. |
3089 | return $this->mw_newPost( $args ); |
3090 | } |
3091 |
|
3092 | /** |
Line | Code |
3111 | $password = $args[2]; |
3112 | $page_id = (int) $args[3]; |
3113 |
|
3114 | $user = $this->login( $username, $password ); |
3115 | if ( ! $user ) { |
3116 | return $this->error; |
3117 | } |
3118 |
|
3119 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3120 | do_action( 'xmlrpc_call', 'wp.deletePage', $args, $this ); |
3121 |
|
3122 | // Get the current page based on the 'page_id' and |
3123 | // make sure it is a page and not a post. |
3124 | $actual_page = get_post( $page_id, ARRAY_A ); |
3125 | if ( ! $actual_page || ( 'page' !== $actual_page['post_type'] ) ) { |
3126 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
3127 | } |
3128 |
|
3129 | // Make sure the user can delete pages. |
Line | Code |
3178 | $escaped_username = $this->escape( $username ); |
3179 | $escaped_password = $this->escape( $password ); |
3180 |
|
3181 | $user = $this->login( $escaped_username, $escaped_password ); |
3182 | if ( ! $user ) { |
3183 | return $this->error; |
3184 | } |
3185 |
|
3186 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3187 | do_action( 'xmlrpc_call', 'wp.editPage', $args, $this ); |
3188 |
|
3189 | // Get the page data and make sure it is a page. |
3190 | $actual_page = get_post( $page_id, ARRAY_A ); |
3191 | if ( ! $actual_page || ( 'page' !== $actual_page['post_type'] ) ) { |
3192 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
3193 | } |
3194 |
|
3195 | // Make sure the user is allowed to edit pages. |
3196 | if ( ! current_user_can( 'edit_page', $page_id ) ) { |
Line | Code |
3241 | if ( ! $user ) { |
3242 | return $this->error; |
3243 | } |
3244 |
|
3245 | if ( ! current_user_can( 'edit_pages' ) ) { |
3246 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit pages.' ) ); |
3247 | } |
3248 |
|
3249 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3250 | do_action( 'xmlrpc_call', 'wp.getPageList', $args, $this ); |
3251 |
|
3252 | // Get list of page IDs and titles. |
3253 | $page_list = $wpdb->get_results( |
3254 | " |
3255 | SELECT ID page_id, |
3256 | post_title page_title, |
3257 | post_parent page_parent_id, |
3258 | post_date_gmt, |
3259 | post_date, |
Line | Code |
3302 | if ( ! $user ) { |
3303 | return $this->error; |
3304 | } |
3305 |
|
3306 | if ( ! current_user_can( 'edit_posts' ) ) { |
3307 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
3308 | } |
3309 |
|
3310 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3311 | do_action( 'xmlrpc_call', 'wp.getAuthors', $args, $this ); |
3312 |
|
3313 | $authors = array(); |
3314 | foreach ( get_users( array( 'fields' => array( 'ID', 'user_login', 'display_name' ) ) ) as $user ) { |
3315 | $authors[] = array( |
3316 | 'user_id' => $user->ID, |
3317 | 'user_login' => $user->user_login, |
3318 | 'display_name' => $user->display_name, |
3319 | ); |
3320 | } |
Line | Code |
3346 | if ( ! $user ) { |
3347 | return $this->error; |
3348 | } |
3349 |
|
3350 | if ( ! current_user_can( 'edit_posts' ) ) { |
3351 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view tags.' ) ); |
3352 | } |
3353 |
|
3354 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3355 | do_action( 'xmlrpc_call', 'wp.getKeywords', $args, $this ); |
3356 |
|
3357 | $tags = array(); |
3358 |
|
3359 | $all_tags = get_tags(); |
3360 | if ( $all_tags ) { |
3361 | foreach ( (array) $all_tags as $tag ) { |
3362 | $struct = array(); |
3363 | $struct['tag_id'] = $tag->term_id; |
3364 | $struct['name'] = $tag->name; |
Line | Code |
3396 | $password = $args[2]; |
3397 | $category = $args[3]; |
3398 |
|
3399 | $user = $this->login( $username, $password ); |
3400 | if ( ! $user ) { |
3401 | return $this->error; |
3402 | } |
3403 |
|
3404 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3405 | do_action( 'xmlrpc_call', 'wp.newCategory', $args, $this ); |
3406 |
|
3407 | // Make sure the user is allowed to add a category. |
3408 | if ( ! current_user_can( 'manage_categories' ) ) { |
3409 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to add a category.' ) ); |
3410 | } |
3411 |
|
3412 | // If no slug was provided, make it empty |
3413 | // so that WordPress will generate one. |
3414 | if ( empty( $category['slug'] ) ) { |
Line | Code |
3479 | $password = $args[2]; |
3480 | $category_id = (int) $args[3]; |
3481 |
|
3482 | $user = $this->login( $username, $password ); |
3483 | if ( ! $user ) { |
3484 | return $this->error; |
3485 | } |
3486 |
|
3487 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3488 | do_action( 'xmlrpc_call', 'wp.deleteCategory', $args, $this ); |
3489 |
|
3490 | if ( ! current_user_can( 'delete_term', $category_id ) ) { |
3491 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this category.' ) ); |
3492 | } |
3493 |
|
3494 | $status = wp_delete_term( $category_id, 'category' ); |
3495 |
|
3496 | if ( true == $status ) { |
3497 | /** |
Line | Code |
3536 | if ( ! $user ) { |
3537 | return $this->error; |
3538 | } |
3539 |
|
3540 | if ( ! current_user_can( 'edit_posts' ) ) { |
3541 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
3542 | } |
3543 |
|
3544 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3545 | do_action( 'xmlrpc_call', 'wp.suggestCategories', $args, $this ); |
3546 |
|
3547 | $category_suggestions = array(); |
3548 | $args = array( |
3549 | 'get' => 'all', |
3550 | 'number' => $max_results, |
3551 | 'name__like' => $category, |
3552 | ); |
3553 | foreach ( (array) get_categories( $args ) as $cat ) { |
3554 | $category_suggestions[] = array( |
Line | Code |
3582 | $password = $args[2]; |
3583 | $comment_id = (int) $args[3]; |
3584 |
|
3585 | $user = $this->login( $username, $password ); |
3586 | if ( ! $user ) { |
3587 | return $this->error; |
3588 | } |
3589 |
|
3590 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3591 | do_action( 'xmlrpc_call', 'wp.getComment', $args, $this ); |
3592 |
|
3593 | $comment = get_comment( $comment_id ); |
3594 | if ( ! $comment ) { |
3595 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
3596 | } |
3597 |
|
3598 | if ( ! current_user_can( 'edit_comment', $comment_id ) ) { |
3599 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) ); |
3600 | } |
Line | Code |
3635 | $password = $args[2]; |
3636 | $struct = isset( $args[3] ) ? $args[3] : array(); |
3637 |
|
3638 | $user = $this->login( $username, $password ); |
3639 | if ( ! $user ) { |
3640 | return $this->error; |
3641 | } |
3642 |
|
3643 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3644 | do_action( 'xmlrpc_call', 'wp.getComments', $args, $this ); |
3645 |
|
3646 | if ( isset( $struct['status'] ) ) { |
3647 | $status = $struct['status']; |
3648 | } else { |
3649 | $status = ''; |
3650 | } |
3651 |
|
3652 | if ( ! current_user_can( 'moderate_comments' ) && 'approve' !== $status ) { |
3653 | return new IXR_Error( 401, __( 'Invalid comment status.' ) ); |
Line | Code |
3730 | if ( ! get_comment( $comment_ID ) ) { |
3731 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
3732 | } |
3733 |
|
3734 | if ( ! current_user_can( 'edit_comment', $comment_ID ) ) { |
3735 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to delete this comment.' ) ); |
3736 | } |
3737 |
|
3738 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3739 | do_action( 'xmlrpc_call', 'wp.deleteComment', $args, $this ); |
3740 |
|
3741 | $status = wp_delete_comment( $comment_ID ); |
3742 |
|
3743 | if ( $status ) { |
3744 | /** |
3745 | * Fires after a comment has been successfully deleted via XML-RPC. |
3746 | * |
3747 | * @since 3.4.0 |
3748 | * |
Line | Code |
3798 | if ( ! get_comment( $comment_ID ) ) { |
3799 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
3800 | } |
3801 |
|
3802 | if ( ! current_user_can( 'edit_comment', $comment_ID ) ) { |
3803 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) ); |
3804 | } |
3805 |
|
3806 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3807 | do_action( 'xmlrpc_call', 'wp.editComment', $args, $this ); |
3808 | $comment = array( |
3809 | 'comment_ID' => $comment_ID, |
3810 | ); |
3811 |
|
3812 | if ( isset( $content_struct['status'] ) ) { |
3813 | $statuses = get_comment_statuses(); |
3814 | $statuses = array_keys( $statuses ); |
3815 |
|
3816 | if ( ! in_array( $content_struct['status'], $statuses, true ) ) { |
Line | Code |
3991 |
|
3992 | /** This filter is documented in wp-includes/comment.php */ |
3993 | $allow_empty = apply_filters( 'allow_empty_comment', false, $comment ); |
3994 |
|
3995 | if ( ! $allow_empty && '' === $comment['comment_content'] ) { |
3996 | return new IXR_Error( 403, __( 'Comment is required.' ) ); |
3997 | } |
3998 |
|
3999 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4000 | do_action( 'xmlrpc_call', 'wp.newComment', $args, $this ); |
4001 |
|
4002 | $comment_ID = wp_new_comment( $comment, true ); |
4003 | if ( is_wp_error( $comment_ID ) ) { |
4004 | return new IXR_Error( 403, $comment_ID->get_error_message() ); |
4005 | } |
4006 |
|
4007 | if ( ! $comment_ID ) { |
4008 | return new IXR_Error( 403, __( 'Something went wrong.' ) ); |
4009 | } |
Line | Code |
4045 | if ( ! $user ) { |
4046 | return $this->error; |
4047 | } |
4048 |
|
4049 | if ( ! current_user_can( 'publish_posts' ) ) { |
4050 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) ); |
4051 | } |
4052 |
|
4053 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4054 | do_action( 'xmlrpc_call', 'wp.getCommentStatusList', $args, $this ); |
4055 |
|
4056 | return get_comment_statuses(); |
4057 | } |
4058 |
|
4059 | /** |
4060 | * Retrieve comment count. |
4061 | * |
4062 | * @since 2.5.0 |
4063 | * |
Line | Code |
4087 | if ( empty( $post['ID'] ) ) { |
4088 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
4089 | } |
4090 |
|
4091 | if ( ! current_user_can( 'edit_post', $post_id ) ) { |
4092 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details of this post.' ) ); |
4093 | } |
4094 |
|
4095 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4096 | do_action( 'xmlrpc_call', 'wp.getCommentCount', $args, $this ); |
4097 |
|
4098 | $count = wp_count_comments( $post_id ); |
4099 |
|
4100 | return array( |
4101 | 'approved' => $count->approved, |
4102 | 'awaiting_moderation' => $count->moderated, |
4103 | 'spam' => $count->spam, |
4104 | 'total_comments' => $count->total_comments, |
4105 | ); |
Line | Code |
4129 | if ( ! $user ) { |
4130 | return $this->error; |
4131 | } |
4132 |
|
4133 | if ( ! current_user_can( 'edit_posts' ) ) { |
4134 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) ); |
4135 | } |
4136 |
|
4137 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4138 | do_action( 'xmlrpc_call', 'wp.getPostStatusList', $args, $this ); |
4139 |
|
4140 | return get_post_statuses(); |
4141 | } |
4142 |
|
4143 | /** |
4144 | * Retrieve page statuses. |
4145 | * |
4146 | * @since 2.5.0 |
4147 | * |
Line | Code |
4164 | if ( ! $user ) { |
4165 | return $this->error; |
4166 | } |
4167 |
|
4168 | if ( ! current_user_can( 'edit_pages' ) ) { |
4169 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) ); |
4170 | } |
4171 |
|
4172 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4173 | do_action( 'xmlrpc_call', 'wp.getPageStatusList', $args, $this ); |
4174 |
|
4175 | return get_page_statuses(); |
4176 | } |
4177 |
|
4178 | /** |
4179 | * Retrieve page templates. |
4180 | * |
4181 | * @since 2.6.0 |
4182 | * |
Line | Code |
4357 | if ( ! $user ) { |
4358 | return $this->error; |
4359 | } |
4360 |
|
4361 | if ( ! current_user_can( 'upload_files' ) ) { |
4362 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to upload files.' ) ); |
4363 | } |
4364 |
|
4365 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4366 | do_action( 'xmlrpc_call', 'wp.getMediaItem', $args, $this ); |
4367 |
|
4368 | $attachment = get_post( $attachment_id ); |
4369 | if ( ! $attachment || 'attachment' !== $attachment->post_type ) { |
4370 | return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); |
4371 | } |
4372 |
|
4373 | return $this->_prepare_media_item( $attachment ); |
4374 | } |
4375 |
|
Line | Code |
4410 | if ( ! $user ) { |
4411 | return $this->error; |
4412 | } |
4413 |
|
4414 | if ( ! current_user_can( 'upload_files' ) ) { |
4415 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to upload files.' ) ); |
4416 | } |
4417 |
|
4418 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4419 | do_action( 'xmlrpc_call', 'wp.getMediaLibrary', $args, $this ); |
4420 |
|
4421 | $parent_id = ( isset( $struct['parent_id'] ) ) ? absint( $struct['parent_id'] ) : ''; |
4422 | $mime_type = ( isset( $struct['mime_type'] ) ) ? $struct['mime_type'] : ''; |
4423 | $offset = ( isset( $struct['offset'] ) ) ? absint( $struct['offset'] ) : 0; |
4424 | $number = ( isset( $struct['number'] ) ) ? absint( $struct['number'] ) : -1; |
4425 |
|
4426 | $attachments = get_posts( |
4427 | array( |
4428 | 'post_type' => 'attachment', |
Line | Code |
4466 | if ( ! $user ) { |
4467 | return $this->error; |
4468 | } |
4469 |
|
4470 | if ( ! current_user_can( 'edit_posts' ) ) { |
4471 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) ); |
4472 | } |
4473 |
|
4474 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4475 | do_action( 'xmlrpc_call', 'wp.getPostFormats', $args, $this ); |
4476 |
|
4477 | $formats = get_post_format_strings(); |
4478 |
|
4479 | // Find out if they want a list of currently supports formats. |
4480 | if ( isset( $args[3] ) && is_array( $args[3] ) ) { |
4481 | if ( $args[3]['show-supported'] ) { |
4482 | if ( current_theme_supports( 'post-formats' ) ) { |
4483 | $supported = get_theme_support( 'post-formats' ); |
4484 |
|
Line | Code |
4546 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostType' ); |
4547 | } |
4548 |
|
4549 | $user = $this->login( $username, $password ); |
4550 | if ( ! $user ) { |
4551 | return $this->error; |
4552 | } |
4553 |
|
4554 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4555 | do_action( 'xmlrpc_call', 'wp.getPostType', $args, $this ); |
4556 |
|
4557 | if ( ! post_type_exists( $post_type_name ) ) { |
4558 | return new IXR_Error( 403, __( 'Invalid post type.' ) ); |
4559 | } |
4560 |
|
4561 | $post_type = get_post_type_object( $post_type_name ); |
4562 |
|
4563 | if ( ! current_user_can( $post_type->cap->edit_posts ) ) { |
4564 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts in this post type.' ) ); |
Line | Code |
4603 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostTypes' ); |
4604 | } |
4605 |
|
4606 | $user = $this->login( $username, $password ); |
4607 | if ( ! $user ) { |
4608 | return $this->error; |
4609 | } |
4610 |
|
4611 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4612 | do_action( 'xmlrpc_call', 'wp.getPostTypes', $args, $this ); |
4613 |
|
4614 | $post_types = get_post_types( $filter, 'objects' ); |
4615 |
|
4616 | $struct = array(); |
4617 |
|
4618 | foreach ( $post_types as $post_type ) { |
4619 | if ( ! current_user_can( $post_type->cap->edit_posts ) ) { |
4620 | continue; |
4621 | } |
Line | Code |
4673 | $fields = apply_filters( 'xmlrpc_default_revision_fields', array( 'post_date', 'post_date_gmt' ), 'wp.getRevisions' ); |
4674 | } |
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.getRevisions', $args, $this ); |
4683 |
|
4684 | $post = get_post( $post_id ); |
4685 | if ( ! $post ) { |
4686 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
4687 | } |
4688 |
|
4689 | if ( ! current_user_can( 'edit_post', $post_id ) ) { |
4690 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
4691 | } |
Line | Code |
4747 | $password = $args[2]; |
4748 | $revision_id = (int) $args[3]; |
4749 |
|
4750 | $user = $this->login( $username, $password ); |
4751 | if ( ! $user ) { |
4752 | return $this->error; |
4753 | } |
4754 |
|
4755 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4756 | do_action( 'xmlrpc_call', 'wp.restoreRevision', $args, $this ); |
4757 |
|
4758 | $revision = wp_get_post_revision( $revision_id ); |
4759 | if ( ! $revision ) { |
4760 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
4761 | } |
4762 |
|
4763 | if ( wp_is_post_autosave( $revision ) ) { |
4764 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
4765 | } |
Line | Code |
4818 | $username = $args[1]; |
4819 | $password = $args[2]; |
4820 |
|
4821 | $user = $this->login( $username, $password ); |
4822 | if ( ! $user ) { |
4823 | return $this->error; |
4824 | } |
4825 |
|
4826 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4827 | do_action( 'xmlrpc_call', 'blogger.getUsersBlogs', $args, $this ); |
4828 |
|
4829 | $is_admin = current_user_can( 'manage_options' ); |
4830 |
|
4831 | $struct = array( |
4832 | 'isAdmin' => $is_admin, |
4833 | 'url' => get_option( 'home' ) . '/', |
4834 | 'blogid' => '1', |
4835 | 'blogName' => get_option( 'blogname' ), |
4836 | 'xmlrpc' => site_url( 'xmlrpc.php', 'rpc' ), |
Line | Code |
4902 | if ( ! $user ) { |
4903 | return $this->error; |
4904 | } |
4905 |
|
4906 | if ( ! current_user_can( 'edit_posts' ) ) { |
4907 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to access user data on this site.' ) ); |
4908 | } |
4909 |
|
4910 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4911 | do_action( 'xmlrpc_call', 'blogger.getUserInfo', $args, $this ); |
4912 |
|
4913 | $struct = array( |
4914 | 'nickname' => $user->nickname, |
4915 | 'userid' => $user->ID, |
4916 | 'url' => $user->user_url, |
4917 | 'lastname' => $user->last_name, |
4918 | 'firstname' => $user->first_name, |
4919 | ); |
4920 |
|
Line | Code |
4952 | if ( ! $post_data ) { |
4953 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
4954 | } |
4955 |
|
4956 | if ( ! current_user_can( 'edit_post', $post_ID ) ) { |
4957 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
4958 | } |
4959 |
|
4960 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4961 | do_action( 'xmlrpc_call', 'blogger.getPost', $args, $this ); |
4962 |
|
4963 | $categories = implode( ',', wp_get_post_categories( $post_ID ) ); |
4964 |
|
4965 | $content = '<title>' . wp_unslash( $post_data['post_title'] ) . '</title>'; |
4966 | $content .= '<category>' . $categories . '</category>'; |
4967 | $content .= wp_unslash( $post_data['post_content'] ); |
4968 |
|
4969 | $struct = array( |
4970 | 'userid' => $post_data['post_author'], |
Line | Code |
5009 | if ( ! $user ) { |
5010 | return $this->error; |
5011 | } |
5012 |
|
5013 | if ( ! current_user_can( 'edit_posts' ) ) { |
5014 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
5015 | } |
5016 |
|
5017 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5018 | do_action( 'xmlrpc_call', 'blogger.getRecentPosts', $args, $this ); |
5019 |
|
5020 | $posts_list = wp_get_recent_posts( $query ); |
5021 |
|
5022 | if ( ! $posts_list ) { |
5023 | $this->error = new IXR_Error( 500, __( 'Either there are no posts, or something went wrong.' ) ); |
5024 | return $this->error; |
5025 | } |
5026 |
|
5027 | $recent_posts = array(); |
Line | Code |
5099 | $content = $args[4]; |
5100 | $publish = $args[5]; |
5101 |
|
5102 | $user = $this->login( $username, $password ); |
5103 | if ( ! $user ) { |
5104 | return $this->error; |
5105 | } |
5106 |
|
5107 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5108 | do_action( 'xmlrpc_call', 'blogger.newPost', $args, $this ); |
5109 |
|
5110 | $cap = ( $publish ) ? 'publish_posts' : 'edit_posts'; |
5111 | if ( ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) || ! current_user_can( $cap ) ) { |
5112 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to post on this site.' ) ); |
5113 | } |
5114 |
|
5115 | $post_status = ( $publish ) ? 'publish' : 'draft'; |
5116 |
|
5117 | $post_author = $user->ID; |
Line | Code |
5176 | $content = $args[4]; |
5177 | $publish = $args[5]; |
5178 |
|
5179 | $user = $this->login( $username, $password ); |
5180 | if ( ! $user ) { |
5181 | return $this->error; |
5182 | } |
5183 |
|
5184 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5185 | do_action( 'xmlrpc_call', 'blogger.editPost', $args, $this ); |
5186 |
|
5187 | $actual_post = get_post( $post_ID, ARRAY_A ); |
5188 |
|
5189 | if ( ! $actual_post || 'post' !== $actual_post['post_type'] ) { |
5190 | return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); |
5191 | } |
5192 |
|
5193 | $this->escape( $actual_post ); |
5194 |
|
Line | Code |
5250 | $username = $args[2]; |
5251 | $password = $args[3]; |
5252 |
|
5253 | $user = $this->login( $username, $password ); |
5254 | if ( ! $user ) { |
5255 | return $this->error; |
5256 | } |
5257 |
|
5258 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5259 | do_action( 'xmlrpc_call', 'blogger.deletePost', $args, $this ); |
5260 |
|
5261 | $actual_post = get_post( $post_ID, ARRAY_A ); |
5262 |
|
5263 | if ( ! $actual_post || 'post' !== $actual_post['post_type'] ) { |
5264 | return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); |
5265 | } |
5266 |
|
5267 | if ( ! current_user_can( 'delete_post', $post_ID ) ) { |
5268 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) ); |
Line | Code |
5338 | $content_struct = $args[3]; |
5339 | $publish = isset( $args[4] ) ? $args[4] : 0; |
5340 |
|
5341 | $user = $this->login( $username, $password ); |
5342 | if ( ! $user ) { |
5343 | return $this->error; |
5344 | } |
5345 |
|
5346 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5347 | do_action( 'xmlrpc_call', 'metaWeblog.newPost', $args, $this ); |
5348 |
|
5349 | $page_template = ''; |
5350 | if ( ! empty( $content_struct['post_type'] ) ) { |
5351 | if ( 'page' === $content_struct['post_type'] ) { |
5352 | if ( $publish ) { |
5353 | $cap = 'publish_pages'; |
5354 | } elseif ( isset( $content_struct['page_status'] ) && 'publish' === $content_struct['page_status'] ) { |
5355 | $cap = 'publish_pages'; |
5356 | } else { |
Line | Code |
5713 | $content_struct = $args[3]; |
5714 | $publish = isset( $args[4] ) ? $args[4] : 0; |
5715 |
|
5716 | $user = $this->login( $username, $password ); |
5717 | if ( ! $user ) { |
5718 | return $this->error; |
5719 | } |
5720 |
|
5721 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5722 | do_action( 'xmlrpc_call', 'metaWeblog.editPost', $args, $this ); |
5723 |
|
5724 | $postdata = get_post( $post_ID, ARRAY_A ); |
5725 |
|
5726 | /* |
5727 | * If there is no post data for the give post ID, stop now and return an error. |
5728 | * Otherwise a new post will be created (which was the old behavior). |
5729 | */ |
5730 | if ( ! $postdata || empty( $postdata['ID'] ) ) { |
5731 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
Line | Code |
6050 | if ( ! $postdata ) { |
6051 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
6052 | } |
6053 |
|
6054 | if ( ! current_user_can( 'edit_post', $post_ID ) ) { |
6055 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
6056 | } |
6057 |
|
6058 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6059 | do_action( 'xmlrpc_call', 'metaWeblog.getPost', $args, $this ); |
6060 |
|
6061 | if ( '' !== $postdata['post_date'] ) { |
6062 | $post_date = $this->_convert_date( $postdata['post_date'] ); |
6063 | $post_date_gmt = $this->_convert_date_gmt( $postdata['post_date_gmt'], $postdata['post_date'] ); |
6064 | $post_modified = $this->_convert_date( $postdata['post_modified'] ); |
6065 | $post_modified_gmt = $this->_convert_date_gmt( $postdata['post_modified_gmt'], $postdata['post_modified'] ); |
6066 |
|
6067 | $categories = array(); |
6068 | $catids = wp_get_post_categories( $post_ID ); |
Line | Code |
6191 | if ( ! $user ) { |
6192 | return $this->error; |
6193 | } |
6194 |
|
6195 | if ( ! current_user_can( 'edit_posts' ) ) { |
6196 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
6197 | } |
6198 |
|
6199 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6200 | do_action( 'xmlrpc_call', 'metaWeblog.getRecentPosts', $args, $this ); |
6201 |
|
6202 | $posts_list = wp_get_recent_posts( $query ); |
6203 |
|
6204 | if ( ! $posts_list ) { |
6205 | return array(); |
6206 | } |
6207 |
|
6208 | $recent_posts = array(); |
6209 | foreach ( $posts_list as $entry ) { |
Line | Code |
6312 | if ( ! $user ) { |
6313 | return $this->error; |
6314 | } |
6315 |
|
6316 | if ( ! current_user_can( 'edit_posts' ) ) { |
6317 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
6318 | } |
6319 |
|
6320 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6321 | do_action( 'xmlrpc_call', 'metaWeblog.getCategories', $args, $this ); |
6322 |
|
6323 | $categories_struct = array(); |
6324 |
|
6325 | $cats = get_categories( array( 'get' => 'all' ) ); |
6326 | if ( $cats ) { |
6327 | foreach ( $cats as $cat ) { |
6328 | $struct = array(); |
6329 | $struct['categoryId'] = $cat->term_id; |
6330 | $struct['parentId'] = $cat->parent; |
Line | Code |
6373 | $type = $data['type']; |
6374 | $bits = $data['bits']; |
6375 |
|
6376 | $user = $this->login( $username, $password ); |
6377 | if ( ! $user ) { |
6378 | return $this->error; |
6379 | } |
6380 |
|
6381 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6382 | do_action( 'xmlrpc_call', 'metaWeblog.newMediaObject', $args, $this ); |
6383 |
|
6384 | if ( ! current_user_can( 'upload_files' ) ) { |
6385 | $this->error = new IXR_Error( 401, __( 'Sorry, you are not allowed to upload files.' ) ); |
6386 | return $this->error; |
6387 | } |
6388 |
|
6389 | if ( is_multisite() && upload_is_user_over_quota( false ) ) { |
6390 | $this->error = new IXR_Error( |
6391 | 401, |
Line | Code |
6492 | $query = array(); |
6493 | } |
6494 |
|
6495 | $user = $this->login( $username, $password ); |
6496 | if ( ! $user ) { |
6497 | return $this->error; |
6498 | } |
6499 |
|
6500 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6501 | do_action( 'xmlrpc_call', 'mt.getRecentPostTitles', $args, $this ); |
6502 |
|
6503 | $posts_list = wp_get_recent_posts( $query ); |
6504 |
|
6505 | if ( ! $posts_list ) { |
6506 | $this->error = new IXR_Error( 500, __( 'Either there are no posts, or something went wrong.' ) ); |
6507 | return $this->error; |
6508 | } |
6509 |
|
6510 | $recent_posts = array(); |
Line | Code |
6554 | if ( ! $user ) { |
6555 | return $this->error; |
6556 | } |
6557 |
|
6558 | if ( ! current_user_can( 'edit_posts' ) ) { |
6559 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
6560 | } |
6561 |
|
6562 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6563 | do_action( 'xmlrpc_call', 'mt.getCategoryList', $args, $this ); |
6564 |
|
6565 | $categories_struct = array(); |
6566 |
|
6567 | $cats = get_categories( |
6568 | array( |
6569 | 'hide_empty' => 0, |
6570 | 'hierarchical' => 0, |
6571 | ) |
6572 | ); |
Line | Code |
6612 | if ( ! get_post( $post_ID ) ) { |
6613 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
6614 | } |
6615 |
|
6616 | if ( ! current_user_can( 'edit_post', $post_ID ) ) { |
6617 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
6618 | } |
6619 |
|
6620 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6621 | do_action( 'xmlrpc_call', 'mt.getPostCategories', $args, $this ); |
6622 |
|
6623 | $categories = array(); |
6624 | $catids = wp_get_post_categories( (int) $post_ID ); |
6625 | // First listed category will be the primary category. |
6626 | $isPrimary = true; |
6627 | foreach ( $catids as $catid ) { |
6628 | $categories[] = array( |
6629 | 'categoryName' => get_cat_name( $catid ), |
6630 | 'categoryId' => (string) $catid, |
Line | Code |
6659 | $password = $args[2]; |
6660 | $categories = $args[3]; |
6661 |
|
6662 | $user = $this->login( $username, $password ); |
6663 | if ( ! $user ) { |
6664 | return $this->error; |
6665 | } |
6666 |
|
6667 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6668 | do_action( 'xmlrpc_call', 'mt.setPostCategories', $args, $this ); |
6669 |
|
6670 | if ( ! get_post( $post_ID ) ) { |
6671 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
6672 | } |
6673 |
|
6674 | if ( ! current_user_can( 'edit_post', $post_ID ) ) { |
6675 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
6676 | } |
6677 |
|
Line | Code |
6688 | /** |
6689 | * Retrieve an array of methods supported by this server. |
6690 | * |
6691 | * @since 1.5.0 |
6692 | * |
6693 | * @return array |
6694 | */ |
6695 | public function mt_supportedMethods() { |
6696 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6697 | do_action( 'xmlrpc_call', 'mt.supportedMethods', array(), $this ); |
6698 |
|
6699 | return array_keys( $this->methods ); |
6700 | } |
6701 |
|
6702 | /** |
6703 | * Retrieve an empty array because we don't support per-post text filters. |
6704 | * |
6705 | * @since 1.5.0 |
6706 | */ |
6707 | public function mt_supportedTextFilters() { |
6708 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6709 | do_action( 'xmlrpc_call', 'mt.supportedTextFilters', array(), $this ); |
6710 |
|
6711 | /** |
6712 | * Filters the MoveableType text filters list for XML-RPC. |
6713 | * |
6714 | * @since 2.2.0 |
6715 | * |
6716 | * @param array $filters An array of text filters. |
6717 | */ |
6718 | return apply_filters( 'xmlrpc_text_filters', array() ); |
Line | Code |
6726 | * @global wpdb $wpdb WordPress database abstraction object. |
6727 | * |
6728 | * @param int $post_ID |
6729 | * @return array|IXR_Error |
6730 | */ |
6731 | public function mt_getTrackbackPings( $post_ID ) { |
6732 | global $wpdb; |
6733 |
|
6734 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6735 | do_action( 'xmlrpc_call', 'mt.getTrackbackPings', $post_ID, $this ); |
6736 |
|
6737 | $actual_post = get_post( $post_ID, ARRAY_A ); |
6738 |
|
6739 | if ( ! $actual_post ) { |
6740 | return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); |
6741 | } |
6742 |
|
6743 | $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 ) ); |
6744 |
|
Line | Code |
6783 | $username = $args[1]; |
6784 | $password = $args[2]; |
6785 |
|
6786 | $user = $this->login( $username, $password ); |
6787 | if ( ! $user ) { |
6788 | return $this->error; |
6789 | } |
6790 |
|
6791 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6792 | do_action( 'xmlrpc_call', 'mt.publishPost', $args, $this ); |
6793 |
|
6794 | $postdata = get_post( $post_ID, ARRAY_A ); |
6795 | if ( ! $postdata ) { |
6796 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
6797 | } |
6798 |
|
6799 | if ( ! current_user_can( 'publish_posts' ) || ! current_user_can( 'edit_post', $post_ID ) ) { |
6800 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish this post.' ) ); |
6801 | } |
Line | Code |
6825 | * @type string $0 URL of page linked from. |
6826 | * @type string $1 URL of page linked to. |
6827 | * } |
6828 | * @return string|IXR_Error |
6829 | */ |
6830 | public function pingback_ping( $args ) { |
6831 | global $wpdb; |
6832 |
|
6833 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6834 | do_action( 'xmlrpc_call', 'pingback.ping', $args, $this ); |
6835 |
|
6836 | $this->escape( $args ); |
6837 |
|
6838 | $pagelinkedfrom = str_replace( '&', '&', $args[0] ); |
6839 | $pagelinkedto = str_replace( '&', '&', $args[1] ); |
6840 | $pagelinkedto = str_replace( '&', '&', $pagelinkedto ); |
6841 |
|
6842 | /** |
6843 | * Filters the pingback source URI. |
Line | Code |
7067 | * @global wpdb $wpdb WordPress database abstraction object. |
7068 | * |
7069 | * @param string $url |
7070 | * @return array|IXR_Error |
7071 | */ |
7072 | public function pingback_extensions_getPingbacks( $url ) { |
7073 | global $wpdb; |
7074 |
|
7075 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
7076 | do_action( 'xmlrpc_call', 'pingback.extensions.getPingbacks', $url, $this ); |
7077 |
|
7078 | $url = $this->escape( $url ); |
7079 |
|
7080 | $post_ID = url_to_postid( $url ); |
7081 | if ( ! $post_ID ) { |
7082 | // We aren't sure that the resource is available and/or pingback enabled. |
7083 | 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.' ) ); |
7084 | } |
7085 |
|