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 |
3636 | $password = $args[2]; |
3637 | $struct = isset( $args[3] ) ? $args[3] : array(); |
3638 |
|
3639 | $user = $this->login( $username, $password ); |
3640 | if ( ! $user ) { |
3641 | return $this->error; |
3642 | } |
3643 |
|
3644 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3645 | do_action( 'xmlrpc_call', 'wp.getComments', $args, $this ); |
3646 |
|
3647 | if ( isset( $struct['status'] ) ) { |
3648 | $status = $struct['status']; |
3649 | } else { |
3650 | $status = ''; |
3651 | } |
3652 |
|
3653 | if ( ! current_user_can( 'moderate_comments' ) && 'approve' !== $status ) { |
3654 | return new IXR_Error( 401, __( 'Invalid comment status.' ) ); |
Line | Code |
3731 | if ( ! get_comment( $comment_id ) ) { |
3732 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
3733 | } |
3734 |
|
3735 | if ( ! current_user_can( 'edit_comment', $comment_id ) ) { |
3736 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to delete this comment.' ) ); |
3737 | } |
3738 |
|
3739 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3740 | do_action( 'xmlrpc_call', 'wp.deleteComment', $args, $this ); |
3741 |
|
3742 | $status = wp_delete_comment( $comment_id ); |
3743 |
|
3744 | if ( $status ) { |
3745 | /** |
3746 | * Fires after a comment has been successfully deleted via XML-RPC. |
3747 | * |
3748 | * @since 3.4.0 |
3749 | * |
Line | Code |
3799 | if ( ! get_comment( $comment_id ) ) { |
3800 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
3801 | } |
3802 |
|
3803 | if ( ! current_user_can( 'edit_comment', $comment_id ) ) { |
3804 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) ); |
3805 | } |
3806 |
|
3807 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3808 | do_action( 'xmlrpc_call', 'wp.editComment', $args, $this ); |
3809 | $comment = array( |
3810 | 'comment_ID' => $comment_id, |
3811 | ); |
3812 |
|
3813 | if ( isset( $content_struct['status'] ) ) { |
3814 | $statuses = get_comment_statuses(); |
3815 | $statuses = array_keys( $statuses ); |
3816 |
|
3817 | if ( ! in_array( $content_struct['status'], $statuses, true ) ) { |
Line | Code |
3992 |
|
3993 | /** This filter is documented in wp-includes/comment.php */ |
3994 | $allow_empty = apply_filters( 'allow_empty_comment', false, $comment ); |
3995 |
|
3996 | if ( ! $allow_empty && '' === $comment['comment_content'] ) { |
3997 | return new IXR_Error( 403, __( 'Comment is required.' ) ); |
3998 | } |
3999 |
|
4000 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4001 | do_action( 'xmlrpc_call', 'wp.newComment', $args, $this ); |
4002 |
|
4003 | $comment_id = wp_new_comment( $comment, true ); |
4004 | if ( is_wp_error( $comment_id ) ) { |
4005 | return new IXR_Error( 403, $comment_id->get_error_message() ); |
4006 | } |
4007 |
|
4008 | if ( ! $comment_id ) { |
4009 | return new IXR_Error( 403, __( 'Something went wrong.' ) ); |
4010 | } |
Line | Code |
4046 | if ( ! $user ) { |
4047 | return $this->error; |
4048 | } |
4049 |
|
4050 | if ( ! current_user_can( 'publish_posts' ) ) { |
4051 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) ); |
4052 | } |
4053 |
|
4054 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4055 | do_action( 'xmlrpc_call', 'wp.getCommentStatusList', $args, $this ); |
4056 |
|
4057 | return get_comment_statuses(); |
4058 | } |
4059 |
|
4060 | /** |
4061 | * Retrieves comment counts. |
4062 | * |
4063 | * @since 2.5.0 |
4064 | * |
Line | Code |
4088 | if ( empty( $post['ID'] ) ) { |
4089 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
4090 | } |
4091 |
|
4092 | if ( ! current_user_can( 'edit_post', $post_id ) ) { |
4093 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details of this post.' ) ); |
4094 | } |
4095 |
|
4096 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4097 | do_action( 'xmlrpc_call', 'wp.getCommentCount', $args, $this ); |
4098 |
|
4099 | $count = wp_count_comments( $post_id ); |
4100 |
|
4101 | return array( |
4102 | 'approved' => $count->approved, |
4103 | 'awaiting_moderation' => $count->moderated, |
4104 | 'spam' => $count->spam, |
4105 | 'total_comments' => $count->total_comments, |
4106 | ); |
Line | Code |
4130 | if ( ! $user ) { |
4131 | return $this->error; |
4132 | } |
4133 |
|
4134 | if ( ! current_user_can( 'edit_posts' ) ) { |
4135 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) ); |
4136 | } |
4137 |
|
4138 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4139 | do_action( 'xmlrpc_call', 'wp.getPostStatusList', $args, $this ); |
4140 |
|
4141 | return get_post_statuses(); |
4142 | } |
4143 |
|
4144 | /** |
4145 | * Retrieves page statuses. |
4146 | * |
4147 | * @since 2.5.0 |
4148 | * |
Line | Code |
4165 | if ( ! $user ) { |
4166 | return $this->error; |
4167 | } |
4168 |
|
4169 | if ( ! current_user_can( 'edit_pages' ) ) { |
4170 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) ); |
4171 | } |
4172 |
|
4173 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4174 | do_action( 'xmlrpc_call', 'wp.getPageStatusList', $args, $this ); |
4175 |
|
4176 | return get_page_statuses(); |
4177 | } |
4178 |
|
4179 | /** |
4180 | * Retrieves page templates. |
4181 | * |
4182 | * @since 2.6.0 |
4183 | * |
Line | Code |
4358 | if ( ! $user ) { |
4359 | return $this->error; |
4360 | } |
4361 |
|
4362 | if ( ! current_user_can( 'upload_files' ) ) { |
4363 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to upload files.' ) ); |
4364 | } |
4365 |
|
4366 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4367 | do_action( 'xmlrpc_call', 'wp.getMediaItem', $args, $this ); |
4368 |
|
4369 | $attachment = get_post( $attachment_id ); |
4370 | if ( ! $attachment || 'attachment' !== $attachment->post_type ) { |
4371 | return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); |
4372 | } |
4373 |
|
4374 | return $this->_prepare_media_item( $attachment ); |
4375 | } |
4376 |
|
Line | Code |
4413 | if ( ! $user ) { |
4414 | return $this->error; |
4415 | } |
4416 |
|
4417 | if ( ! current_user_can( 'upload_files' ) ) { |
4418 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to upload files.' ) ); |
4419 | } |
4420 |
|
4421 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4422 | do_action( 'xmlrpc_call', 'wp.getMediaLibrary', $args, $this ); |
4423 |
|
4424 | $parent_id = ( isset( $struct['parent_id'] ) ) ? absint( $struct['parent_id'] ) : ''; |
4425 | $mime_type = ( isset( $struct['mime_type'] ) ) ? $struct['mime_type'] : ''; |
4426 | $offset = ( isset( $struct['offset'] ) ) ? absint( $struct['offset'] ) : 0; |
4427 | $number = ( isset( $struct['number'] ) ) ? absint( $struct['number'] ) : -1; |
4428 |
|
4429 | $attachments = get_posts( |
4430 | array( |
4431 | 'post_type' => 'attachment', |
Line | Code |
4469 | if ( ! $user ) { |
4470 | return $this->error; |
4471 | } |
4472 |
|
4473 | if ( ! current_user_can( 'edit_posts' ) ) { |
4474 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) ); |
4475 | } |
4476 |
|
4477 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4478 | do_action( 'xmlrpc_call', 'wp.getPostFormats', $args, $this ); |
4479 |
|
4480 | $formats = get_post_format_strings(); |
4481 |
|
4482 | // Find out if they want a list of currently supports formats. |
4483 | if ( isset( $args[3] ) && is_array( $args[3] ) ) { |
4484 | if ( $args[3]['show-supported'] ) { |
4485 | if ( current_theme_supports( 'post-formats' ) ) { |
4486 | $supported = get_theme_support( 'post-formats' ); |
4487 |
|
Line | Code |
4549 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostType' ); |
4550 | } |
4551 |
|
4552 | $user = $this->login( $username, $password ); |
4553 | if ( ! $user ) { |
4554 | return $this->error; |
4555 | } |
4556 |
|
4557 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4558 | do_action( 'xmlrpc_call', 'wp.getPostType', $args, $this ); |
4559 |
|
4560 | if ( ! post_type_exists( $post_type_name ) ) { |
4561 | return new IXR_Error( 403, __( 'Invalid post type.' ) ); |
4562 | } |
4563 |
|
4564 | $post_type = get_post_type_object( $post_type_name ); |
4565 |
|
4566 | if ( ! current_user_can( $post_type->cap->edit_posts ) ) { |
4567 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts in this post type.' ) ); |
Line | Code |
4606 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostTypes' ); |
4607 | } |
4608 |
|
4609 | $user = $this->login( $username, $password ); |
4610 | if ( ! $user ) { |
4611 | return $this->error; |
4612 | } |
4613 |
|
4614 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4615 | do_action( 'xmlrpc_call', 'wp.getPostTypes', $args, $this ); |
4616 |
|
4617 | $post_types = get_post_types( $filter, 'objects' ); |
4618 |
|
4619 | $struct = array(); |
4620 |
|
4621 | foreach ( $post_types as $post_type ) { |
4622 | if ( ! current_user_can( $post_type->cap->edit_posts ) ) { |
4623 | continue; |
4624 | } |
Line | Code |
4676 | $fields = apply_filters( 'xmlrpc_default_revision_fields', array( 'post_date', 'post_date_gmt' ), 'wp.getRevisions' ); |
4677 | } |
4678 |
|
4679 | $user = $this->login( $username, $password ); |
4680 | if ( ! $user ) { |
4681 | return $this->error; |
4682 | } |
4683 |
|
4684 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4685 | do_action( 'xmlrpc_call', 'wp.getRevisions', $args, $this ); |
4686 |
|
4687 | $post = get_post( $post_id ); |
4688 | if ( ! $post ) { |
4689 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
4690 | } |
4691 |
|
4692 | if ( ! current_user_can( 'edit_post', $post_id ) ) { |
4693 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
4694 | } |
Line | Code |
4750 | $password = $args[2]; |
4751 | $revision_id = (int) $args[3]; |
4752 |
|
4753 | $user = $this->login( $username, $password ); |
4754 | if ( ! $user ) { |
4755 | return $this->error; |
4756 | } |
4757 |
|
4758 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4759 | do_action( 'xmlrpc_call', 'wp.restoreRevision', $args, $this ); |
4760 |
|
4761 | $revision = wp_get_post_revision( $revision_id ); |
4762 | if ( ! $revision ) { |
4763 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
4764 | } |
4765 |
|
4766 | if ( wp_is_post_autosave( $revision ) ) { |
4767 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
4768 | } |
Line | Code |
4821 | $username = $args[1]; |
4822 | $password = $args[2]; |
4823 |
|
4824 | $user = $this->login( $username, $password ); |
4825 | if ( ! $user ) { |
4826 | return $this->error; |
4827 | } |
4828 |
|
4829 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4830 | do_action( 'xmlrpc_call', 'blogger.getUsersBlogs', $args, $this ); |
4831 |
|
4832 | $is_admin = current_user_can( 'manage_options' ); |
4833 |
|
4834 | $struct = array( |
4835 | 'isAdmin' => $is_admin, |
4836 | 'url' => get_option( 'home' ) . '/', |
4837 | 'blogid' => '1', |
4838 | 'blogName' => get_option( 'blogname' ), |
4839 | 'xmlrpc' => site_url( 'xmlrpc.php', 'rpc' ), |
Line | Code |
4905 | if ( ! $user ) { |
4906 | return $this->error; |
4907 | } |
4908 |
|
4909 | if ( ! current_user_can( 'edit_posts' ) ) { |
4910 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to access user data on this site.' ) ); |
4911 | } |
4912 |
|
4913 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4914 | do_action( 'xmlrpc_call', 'blogger.getUserInfo', $args, $this ); |
4915 |
|
4916 | $struct = array( |
4917 | 'nickname' => $user->nickname, |
4918 | 'userid' => $user->ID, |
4919 | 'url' => $user->user_url, |
4920 | 'lastname' => $user->last_name, |
4921 | 'firstname' => $user->first_name, |
4922 | ); |
4923 |
|
Line | Code |
4955 | if ( ! $post_data ) { |
4956 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
4957 | } |
4958 |
|
4959 | if ( ! current_user_can( 'edit_post', $post_id ) ) { |
4960 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
4961 | } |
4962 |
|
4963 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4964 | do_action( 'xmlrpc_call', 'blogger.getPost', $args, $this ); |
4965 |
|
4966 | $categories = implode( ',', wp_get_post_categories( $post_id ) ); |
4967 |
|
4968 | $content = '<title>' . wp_unslash( $post_data['post_title'] ) . '</title>'; |
4969 | $content .= '<category>' . $categories . '</category>'; |
4970 | $content .= wp_unslash( $post_data['post_content'] ); |
4971 |
|
4972 | $struct = array( |
4973 | 'userid' => $post_data['post_author'], |
Line | Code |
5012 | if ( ! $user ) { |
5013 | return $this->error; |
5014 | } |
5015 |
|
5016 | if ( ! current_user_can( 'edit_posts' ) ) { |
5017 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
5018 | } |
5019 |
|
5020 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5021 | do_action( 'xmlrpc_call', 'blogger.getRecentPosts', $args, $this ); |
5022 |
|
5023 | $posts_list = wp_get_recent_posts( $query ); |
5024 |
|
5025 | if ( ! $posts_list ) { |
5026 | $this->error = new IXR_Error( 500, __( 'Either there are no posts, or something went wrong.' ) ); |
5027 | return $this->error; |
5028 | } |
5029 |
|
5030 | $recent_posts = array(); |
Line | Code |
5102 | $content = $args[4]; |
5103 | $publish = $args[5]; |
5104 |
|
5105 | $user = $this->login( $username, $password ); |
5106 | if ( ! $user ) { |
5107 | return $this->error; |
5108 | } |
5109 |
|
5110 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5111 | do_action( 'xmlrpc_call', 'blogger.newPost', $args, $this ); |
5112 |
|
5113 | $cap = ( $publish ) ? 'publish_posts' : 'edit_posts'; |
5114 | if ( ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) || ! current_user_can( $cap ) ) { |
5115 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to post on this site.' ) ); |
5116 | } |
5117 |
|
5118 | $post_status = ( $publish ) ? 'publish' : 'draft'; |
5119 |
|
5120 | $post_author = $user->ID; |
Line | Code |
5179 | $content = $args[4]; |
5180 | $publish = $args[5]; |
5181 |
|
5182 | $user = $this->login( $username, $password ); |
5183 | if ( ! $user ) { |
5184 | return $this->error; |
5185 | } |
5186 |
|
5187 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5188 | do_action( 'xmlrpc_call', 'blogger.editPost', $args, $this ); |
5189 |
|
5190 | $actual_post = get_post( $post_id, ARRAY_A ); |
5191 |
|
5192 | if ( ! $actual_post || 'post' !== $actual_post['post_type'] ) { |
5193 | return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); |
5194 | } |
5195 |
|
5196 | $this->escape( $actual_post ); |
5197 |
|
Line | Code |
5253 | $username = $args[2]; |
5254 | $password = $args[3]; |
5255 |
|
5256 | $user = $this->login( $username, $password ); |
5257 | if ( ! $user ) { |
5258 | return $this->error; |
5259 | } |
5260 |
|
5261 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5262 | do_action( 'xmlrpc_call', 'blogger.deletePost', $args, $this ); |
5263 |
|
5264 | $actual_post = get_post( $post_id, ARRAY_A ); |
5265 |
|
5266 | if ( ! $actual_post || 'post' !== $actual_post['post_type'] ) { |
5267 | return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); |
5268 | } |
5269 |
|
5270 | if ( ! current_user_can( 'delete_post', $post_id ) ) { |
5271 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) ); |
Line | Code |
5341 | $content_struct = $args[3]; |
5342 | $publish = isset( $args[4] ) ? $args[4] : 0; |
5343 |
|
5344 | $user = $this->login( $username, $password ); |
5345 | if ( ! $user ) { |
5346 | return $this->error; |
5347 | } |
5348 |
|
5349 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5350 | do_action( 'xmlrpc_call', 'metaWeblog.newPost', $args, $this ); |
5351 |
|
5352 | $page_template = ''; |
5353 | if ( ! empty( $content_struct['post_type'] ) ) { |
5354 | if ( 'page' === $content_struct['post_type'] ) { |
5355 | if ( $publish ) { |
5356 | $cap = 'publish_pages'; |
5357 | } elseif ( isset( $content_struct['page_status'] ) && 'publish' === $content_struct['page_status'] ) { |
5358 | $cap = 'publish_pages'; |
5359 | } else { |
Line | Code |
5716 | $content_struct = $args[3]; |
5717 | $publish = isset( $args[4] ) ? $args[4] : 0; |
5718 |
|
5719 | $user = $this->login( $username, $password ); |
5720 | if ( ! $user ) { |
5721 | return $this->error; |
5722 | } |
5723 |
|
5724 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5725 | do_action( 'xmlrpc_call', 'metaWeblog.editPost', $args, $this ); |
5726 |
|
5727 | $postdata = get_post( $post_id, ARRAY_A ); |
5728 |
|
5729 | /* |
5730 | * If there is no post data for the give post ID, stop now and return an error. |
5731 | * Otherwise a new post will be created (which was the old behavior). |
5732 | */ |
5733 | if ( ! $postdata || empty( $postdata['ID'] ) ) { |
5734 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
Line | Code |
6053 | if ( ! $postdata ) { |
6054 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
6055 | } |
6056 |
|
6057 | if ( ! current_user_can( 'edit_post', $post_id ) ) { |
6058 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
6059 | } |
6060 |
|
6061 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6062 | do_action( 'xmlrpc_call', 'metaWeblog.getPost', $args, $this ); |
6063 |
|
6064 | if ( '' !== $postdata['post_date'] ) { |
6065 | $post_date = $this->_convert_date( $postdata['post_date'] ); |
6066 | $post_date_gmt = $this->_convert_date_gmt( $postdata['post_date_gmt'], $postdata['post_date'] ); |
6067 | $post_modified = $this->_convert_date( $postdata['post_modified'] ); |
6068 | $post_modified_gmt = $this->_convert_date_gmt( $postdata['post_modified_gmt'], $postdata['post_modified'] ); |
6069 |
|
6070 | $categories = array(); |
6071 | $catids = wp_get_post_categories( $post_id ); |
Line | Code |
6194 | if ( ! $user ) { |
6195 | return $this->error; |
6196 | } |
6197 |
|
6198 | if ( ! current_user_can( 'edit_posts' ) ) { |
6199 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
6200 | } |
6201 |
|
6202 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6203 | do_action( 'xmlrpc_call', 'metaWeblog.getRecentPosts', $args, $this ); |
6204 |
|
6205 | $posts_list = wp_get_recent_posts( $query ); |
6206 |
|
6207 | if ( ! $posts_list ) { |
6208 | return array(); |
6209 | } |
6210 |
|
6211 | $recent_posts = array(); |
6212 | foreach ( $posts_list as $entry ) { |
Line | Code |
6315 | if ( ! $user ) { |
6316 | return $this->error; |
6317 | } |
6318 |
|
6319 | if ( ! current_user_can( 'edit_posts' ) ) { |
6320 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
6321 | } |
6322 |
|
6323 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6324 | do_action( 'xmlrpc_call', 'metaWeblog.getCategories', $args, $this ); |
6325 |
|
6326 | $categories_struct = array(); |
6327 |
|
6328 | $cats = get_categories( array( 'get' => 'all' ) ); |
6329 | if ( $cats ) { |
6330 | foreach ( $cats as $cat ) { |
6331 | $struct = array(); |
6332 | $struct['categoryId'] = $cat->term_id; |
6333 | $struct['parentId'] = $cat->parent; |
Line | Code |
6376 | $type = $data['type']; |
6377 | $bits = $data['bits']; |
6378 |
|
6379 | $user = $this->login( $username, $password ); |
6380 | if ( ! $user ) { |
6381 | return $this->error; |
6382 | } |
6383 |
|
6384 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6385 | do_action( 'xmlrpc_call', 'metaWeblog.newMediaObject', $args, $this ); |
6386 |
|
6387 | if ( ! current_user_can( 'upload_files' ) ) { |
6388 | $this->error = new IXR_Error( 401, __( 'Sorry, you are not allowed to upload files.' ) ); |
6389 | return $this->error; |
6390 | } |
6391 |
|
6392 | if ( is_multisite() && upload_is_user_over_quota( false ) ) { |
6393 | $this->error = new IXR_Error( |
6394 | 401, |
Line | Code |
6495 | $query = array(); |
6496 | } |
6497 |
|
6498 | $user = $this->login( $username, $password ); |
6499 | if ( ! $user ) { |
6500 | return $this->error; |
6501 | } |
6502 |
|
6503 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6504 | do_action( 'xmlrpc_call', 'mt.getRecentPostTitles', $args, $this ); |
6505 |
|
6506 | $posts_list = wp_get_recent_posts( $query ); |
6507 |
|
6508 | if ( ! $posts_list ) { |
6509 | $this->error = new IXR_Error( 500, __( 'Either there are no posts, or something went wrong.' ) ); |
6510 | return $this->error; |
6511 | } |
6512 |
|
6513 | $recent_posts = array(); |
Line | Code |
6557 | if ( ! $user ) { |
6558 | return $this->error; |
6559 | } |
6560 |
|
6561 | if ( ! current_user_can( 'edit_posts' ) ) { |
6562 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
6563 | } |
6564 |
|
6565 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6566 | do_action( 'xmlrpc_call', 'mt.getCategoryList', $args, $this ); |
6567 |
|
6568 | $categories_struct = array(); |
6569 |
|
6570 | $cats = get_categories( |
6571 | array( |
6572 | 'hide_empty' => 0, |
6573 | 'hierarchical' => 0, |
6574 | ) |
6575 | ); |
Line | Code |
6615 | if ( ! get_post( $post_id ) ) { |
6616 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
6617 | } |
6618 |
|
6619 | if ( ! current_user_can( 'edit_post', $post_id ) ) { |
6620 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
6621 | } |
6622 |
|
6623 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6624 | do_action( 'xmlrpc_call', 'mt.getPostCategories', $args, $this ); |
6625 |
|
6626 | $categories = array(); |
6627 | $catids = wp_get_post_categories( (int) $post_id ); |
6628 | // First listed category will be the primary category. |
6629 | $isPrimary = true; |
6630 | foreach ( $catids as $catid ) { |
6631 | $categories[] = array( |
6632 | 'categoryName' => get_cat_name( $catid ), |
6633 | 'categoryId' => (string) $catid, |
Line | Code |
6662 | $password = $args[2]; |
6663 | $categories = $args[3]; |
6664 |
|
6665 | $user = $this->login( $username, $password ); |
6666 | if ( ! $user ) { |
6667 | return $this->error; |
6668 | } |
6669 |
|
6670 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6671 | do_action( 'xmlrpc_call', 'mt.setPostCategories', $args, $this ); |
6672 |
|
6673 | if ( ! get_post( $post_id ) ) { |
6674 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
6675 | } |
6676 |
|
6677 | if ( ! current_user_can( 'edit_post', $post_id ) ) { |
6678 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
6679 | } |
6680 |
|
Line | Code |
6691 | /** |
6692 | * Retrieves an array of methods supported by this server. |
6693 | * |
6694 | * @since 1.5.0 |
6695 | * |
6696 | * @return array |
6697 | */ |
6698 | public function mt_supportedMethods() { |
6699 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6700 | do_action( 'xmlrpc_call', 'mt.supportedMethods', array(), $this ); |
6701 |
|
6702 | return array_keys( $this->methods ); |
6703 | } |
6704 |
|
6705 | /** |
6706 | * Retrieves an empty array because we don't support per-post text filters. |
6707 | * |
6708 | * @since 1.5.0 |
6709 | */ |
6710 | public function mt_supportedTextFilters() { |
6711 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6712 | do_action( 'xmlrpc_call', 'mt.supportedTextFilters', array(), $this ); |
6713 |
|
6714 | /** |
6715 | * Filters the MoveableType text filters list for XML-RPC. |
6716 | * |
6717 | * @since 2.2.0 |
6718 | * |
6719 | * @param array $filters An array of text filters. |
6720 | */ |
6721 | return apply_filters( 'xmlrpc_text_filters', array() ); |
Line | Code |
6729 | * @global wpdb $wpdb WordPress database abstraction object. |
6730 | * |
6731 | * @param int $post_id |
6732 | * @return array|IXR_Error |
6733 | */ |
6734 | public function mt_getTrackbackPings( $post_id ) { |
6735 | global $wpdb; |
6736 |
|
6737 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6738 | do_action( 'xmlrpc_call', 'mt.getTrackbackPings', $post_id, $this ); |
6739 |
|
6740 | $actual_post = get_post( $post_id, ARRAY_A ); |
6741 |
|
6742 | if ( ! $actual_post ) { |
6743 | return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); |
6744 | } |
6745 |
|
6746 | $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 ) ); |
6747 |
|
Line | Code |
6786 | $username = $args[1]; |
6787 | $password = $args[2]; |
6788 |
|
6789 | $user = $this->login( $username, $password ); |
6790 | if ( ! $user ) { |
6791 | return $this->error; |
6792 | } |
6793 |
|
6794 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6795 | do_action( 'xmlrpc_call', 'mt.publishPost', $args, $this ); |
6796 |
|
6797 | $postdata = get_post( $post_id, ARRAY_A ); |
6798 | if ( ! $postdata ) { |
6799 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
6800 | } |
6801 |
|
6802 | if ( ! current_user_can( 'publish_posts' ) || ! current_user_can( 'edit_post', $post_id ) ) { |
6803 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish this post.' ) ); |
6804 | } |
Line | Code |
6830 | * @type string $0 URL of page linked from. |
6831 | * @type string $1 URL of page linked to. |
6832 | * } |
6833 | * @return string|IXR_Error |
6834 | */ |
6835 | public function pingback_ping( $args ) { |
6836 | global $wpdb; |
6837 |
|
6838 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6839 | do_action( 'xmlrpc_call', 'pingback.ping', $args, $this ); |
6840 |
|
6841 | $this->escape( $args ); |
6842 |
|
6843 | $pagelinkedfrom = str_replace( '&', '&', $args[0] ); |
6844 | $pagelinkedto = str_replace( '&', '&', $args[1] ); |
6845 | $pagelinkedto = str_replace( '&', '&', $pagelinkedto ); |
6846 |
|
6847 | /** |
6848 | * Filters the pingback source URI. |
Line | Code |
7072 | * @global wpdb $wpdb WordPress database abstraction object. |
7073 | * |
7074 | * @param string $url |
7075 | * @return array|IXR_Error |
7076 | */ |
7077 | public function pingback_extensions_getPingbacks( $url ) { |
7078 | global $wpdb; |
7079 |
|
7080 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
7081 | do_action( 'xmlrpc_call', 'pingback.extensions.getPingbacks', $url, $this ); |
7082 |
|
7083 | $url = $this->escape( $url ); |
7084 |
|
7085 | $post_id = url_to_postid( $url ); |
7086 | if ( ! $post_id ) { |
7087 | // We aren't sure that the resource is available and/or pingback enabled. |
7088 | 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.' ) ); |
7089 | } |
7090 |
|