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 |
---|---|
727 | * equal to the method's name, e.g., wp.getUsersBlogs, wp.newPost, etc. |
728 | * |
729 | * @since 2.5.0 |
730 | * @since 5.7.0 Added the `$args` and `$server` parameters. |
731 | * |
732 | * @param string $name The method name. |
733 | * @param array|string $args The escaped arguments passed to the method. |
734 | * @param wp_xmlrpc_server $server The XML-RPC server instance. |
735 | */ |
736 | do_action( 'xmlrpc_call', 'wp.getUsersBlogs', $args, $this ); |
737 |
|
738 | $blogs = (array) get_blogs_of_user( $user->ID ); |
739 | $struct = array(); |
740 | $primary_blog_id = 0; |
741 | $active_blog = get_active_blog_for_user( $user->ID ); |
742 | if ( $active_blog ) { |
743 | $primary_blog_id = (int) $active_blog->blog_id; |
744 | } |
745 |
|
Line | Code |
1338 | if ( isset( $content_struct['post_date_gmt'] ) && ! ( $content_struct['post_date_gmt'] instanceof IXR_Date ) ) { |
1339 | if ( '0000-00-00 00:00:00' === $content_struct['post_date_gmt'] || isset( $content_struct['post_date'] ) ) { |
1340 | unset( $content_struct['post_date_gmt'] ); |
1341 | } else { |
1342 | $content_struct['post_date_gmt'] = $this->_convert_date( $content_struct['post_date_gmt'] ); |
1343 | } |
1344 | } |
1345 |
|
1346 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
1347 | do_action( 'xmlrpc_call', 'wp.newPost', $args, $this ); |
1348 |
|
1349 | unset( $content_struct['ID'] ); |
1350 |
|
1351 | return $this->_insert_post( $user, $content_struct ); |
1352 | } |
1353 |
|
1354 | /** |
1355 | * Helper method for filtering out elements from an array. |
1356 | * |
Line | Code |
1739 | $post_id = (int) $args[3]; |
1740 | $content_struct = $args[4]; |
1741 |
|
1742 | $user = $this->login( $username, $password ); |
1743 | if ( ! $user ) { |
1744 | return $this->error; |
1745 | } |
1746 |
|
1747 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
1748 | do_action( 'xmlrpc_call', 'wp.editPost', $args, $this ); |
1749 |
|
1750 | $post = get_post( $post_id, ARRAY_A ); |
1751 |
|
1752 | if ( empty( $post['ID'] ) ) { |
1753 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
1754 | } |
1755 |
|
1756 | if ( isset( $content_struct['if_not_modified_since'] ) ) { |
1757 | // If the post has been modified since the date provided, return an error. |
Line | Code |
1822 | $password = $args[2]; |
1823 | $post_id = (int) $args[3]; |
1824 |
|
1825 | $user = $this->login( $username, $password ); |
1826 | if ( ! $user ) { |
1827 | return $this->error; |
1828 | } |
1829 |
|
1830 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
1831 | do_action( 'xmlrpc_call', 'wp.deletePost', $args, $this ); |
1832 |
|
1833 | $post = get_post( $post_id, ARRAY_A ); |
1834 | if ( empty( $post['ID'] ) ) { |
1835 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
1836 | } |
1837 |
|
1838 | if ( ! current_user_can( 'delete_post', $post_id ) ) { |
1839 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) ); |
1840 | } |
Line | Code |
1923 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPost' ); |
1924 | } |
1925 |
|
1926 | $user = $this->login( $username, $password ); |
1927 | if ( ! $user ) { |
1928 | return $this->error; |
1929 | } |
1930 |
|
1931 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
1932 | do_action( 'xmlrpc_call', 'wp.getPost', $args, $this ); |
1933 |
|
1934 | $post = get_post( $post_id, ARRAY_A ); |
1935 |
|
1936 | if ( empty( $post['ID'] ) ) { |
1937 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
1938 | } |
1939 |
|
1940 | if ( ! current_user_can( 'edit_post', $post_id ) ) { |
1941 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
Line | Code |
1984 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPosts' ); |
1985 | } |
1986 |
|
1987 | $user = $this->login( $username, $password ); |
1988 | if ( ! $user ) { |
1989 | return $this->error; |
1990 | } |
1991 |
|
1992 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
1993 | do_action( 'xmlrpc_call', 'wp.getPosts', $args, $this ); |
1994 |
|
1995 | $query = array(); |
1996 |
|
1997 | if ( isset( $filter['post_type'] ) ) { |
1998 | $post_type = get_post_type_object( $filter['post_type'] ); |
1999 | if ( ! ( (bool) $post_type ) ) { |
2000 | return new IXR_Error( 403, __( 'Invalid post type.' ) ); |
2001 | } |
2002 | } else { |
Line | Code |
2083 | $password = $args[2]; |
2084 | $content_struct = $args[3]; |
2085 |
|
2086 | $user = $this->login( $username, $password ); |
2087 | if ( ! $user ) { |
2088 | return $this->error; |
2089 | } |
2090 |
|
2091 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2092 | do_action( 'xmlrpc_call', 'wp.newTerm', $args, $this ); |
2093 |
|
2094 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) { |
2095 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
2096 | } |
2097 |
|
2098 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
2099 |
|
2100 | if ( ! current_user_can( $taxonomy->cap->edit_terms ) ) { |
2101 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to create terms in this taxonomy.' ) ); |
Line | Code |
2188 | $term_id = (int) $args[3]; |
2189 | $content_struct = $args[4]; |
2190 |
|
2191 | $user = $this->login( $username, $password ); |
2192 | if ( ! $user ) { |
2193 | return $this->error; |
2194 | } |
2195 |
|
2196 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2197 | do_action( 'xmlrpc_call', 'wp.editTerm', $args, $this ); |
2198 |
|
2199 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) { |
2200 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
2201 | } |
2202 |
|
2203 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
2204 |
|
2205 | $taxonomy = (array) $taxonomy; |
2206 |
|
Line | Code |
2304 | $taxonomy = $args[3]; |
2305 | $term_id = (int) $args[4]; |
2306 |
|
2307 | $user = $this->login( $username, $password ); |
2308 | if ( ! $user ) { |
2309 | return $this->error; |
2310 | } |
2311 |
|
2312 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2313 | do_action( 'xmlrpc_call', 'wp.deleteTerm', $args, $this ); |
2314 |
|
2315 | if ( ! taxonomy_exists( $taxonomy ) ) { |
2316 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
2317 | } |
2318 |
|
2319 | $taxonomy = get_taxonomy( $taxonomy ); |
2320 | $term = get_term( $term_id, $taxonomy->name ); |
2321 |
|
2322 | if ( is_wp_error( $term ) ) { |
Line | Code |
2383 | $taxonomy = $args[3]; |
2384 | $term_id = (int) $args[4]; |
2385 |
|
2386 | $user = $this->login( $username, $password ); |
2387 | if ( ! $user ) { |
2388 | return $this->error; |
2389 | } |
2390 |
|
2391 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2392 | do_action( 'xmlrpc_call', 'wp.getTerm', $args, $this ); |
2393 |
|
2394 | if ( ! taxonomy_exists( $taxonomy ) ) { |
2395 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
2396 | } |
2397 |
|
2398 | $taxonomy = get_taxonomy( $taxonomy ); |
2399 |
|
2400 | $term = get_term( $term_id, $taxonomy->name, ARRAY_A ); |
2401 |
|
Line | Code |
2448 | $taxonomy = $args[3]; |
2449 | $filter = isset( $args[4] ) ? $args[4] : array(); |
2450 |
|
2451 | $user = $this->login( $username, $password ); |
2452 | if ( ! $user ) { |
2453 | return $this->error; |
2454 | } |
2455 |
|
2456 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2457 | do_action( 'xmlrpc_call', 'wp.getTerms', $args, $this ); |
2458 |
|
2459 | if ( ! taxonomy_exists( $taxonomy ) ) { |
2460 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
2461 | } |
2462 |
|
2463 | $taxonomy = get_taxonomy( $taxonomy ); |
2464 |
|
2465 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) { |
2466 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ) ); |
Line | Code |
2555 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomy' ); |
2556 | } |
2557 |
|
2558 | $user = $this->login( $username, $password ); |
2559 | if ( ! $user ) { |
2560 | return $this->error; |
2561 | } |
2562 |
|
2563 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2564 | do_action( 'xmlrpc_call', 'wp.getTaxonomy', $args, $this ); |
2565 |
|
2566 | if ( ! taxonomy_exists( $taxonomy ) ) { |
2567 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
2568 | } |
2569 |
|
2570 | $taxonomy = get_taxonomy( $taxonomy ); |
2571 |
|
2572 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) { |
2573 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ) ); |
Line | Code |
2613 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomies' ); |
2614 | } |
2615 |
|
2616 | $user = $this->login( $username, $password ); |
2617 | if ( ! $user ) { |
2618 | return $this->error; |
2619 | } |
2620 |
|
2621 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2622 | do_action( 'xmlrpc_call', 'wp.getTaxonomies', $args, $this ); |
2623 |
|
2624 | $taxonomies = get_taxonomies( $filter, 'objects' ); |
2625 |
|
2626 | // Holds all the taxonomy data. |
2627 | $struct = array(); |
2628 |
|
2629 | foreach ( $taxonomies as $taxonomy ) { |
2630 | // Capability check for post types. |
2631 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) { |
Line | Code |
2699 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUser' ); |
2700 | } |
2701 |
|
2702 | $user = $this->login( $username, $password ); |
2703 | if ( ! $user ) { |
2704 | return $this->error; |
2705 | } |
2706 |
|
2707 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2708 | do_action( 'xmlrpc_call', 'wp.getUser', $args, $this ); |
2709 |
|
2710 | if ( ! current_user_can( 'edit_user', $user_id ) ) { |
2711 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this user.' ) ); |
2712 | } |
2713 |
|
2714 | $user_data = get_userdata( $user_id ); |
2715 |
|
2716 | if ( ! $user_data ) { |
2717 | return new IXR_Error( 404, __( 'Invalid user ID.' ) ); |
Line | Code |
2762 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUsers' ); |
2763 | } |
2764 |
|
2765 | $user = $this->login( $username, $password ); |
2766 | if ( ! $user ) { |
2767 | return $this->error; |
2768 | } |
2769 |
|
2770 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2771 | do_action( 'xmlrpc_call', 'wp.getUsers', $args, $this ); |
2772 |
|
2773 | if ( ! current_user_can( 'list_users' ) ) { |
2774 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to list users.' ) ); |
2775 | } |
2776 |
|
2777 | $query = array( 'fields' => 'all_with_meta' ); |
2778 |
|
2779 | $query['number'] = ( isset( $filter['number'] ) ) ? absint( $filter['number'] ) : 50; |
2780 | $query['offset'] = ( isset( $filter['offset'] ) ) ? absint( $filter['offset'] ) : 0; |
Line | Code |
2842 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getProfile' ); |
2843 | } |
2844 |
|
2845 | $user = $this->login( $username, $password ); |
2846 | if ( ! $user ) { |
2847 | return $this->error; |
2848 | } |
2849 |
|
2850 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2851 | do_action( 'xmlrpc_call', 'wp.getProfile', $args, $this ); |
2852 |
|
2853 | if ( ! current_user_can( 'edit_user', $user->ID ) ) { |
2854 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit your profile.' ) ); |
2855 | } |
2856 |
|
2857 | $user_data = get_userdata( $user->ID ); |
2858 |
|
2859 | return $this->_prepare_user( $user_data, $fields ); |
2860 | } |
Line | Code |
2892 | $password = $args[2]; |
2893 | $content_struct = $args[3]; |
2894 |
|
2895 | $user = $this->login( $username, $password ); |
2896 | if ( ! $user ) { |
2897 | return $this->error; |
2898 | } |
2899 |
|
2900 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2901 | do_action( 'xmlrpc_call', 'wp.editProfile', $args, $this ); |
2902 |
|
2903 | if ( ! current_user_can( 'edit_user', $user->ID ) ) { |
2904 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit your profile.' ) ); |
2905 | } |
2906 |
|
2907 | // Holds data of the user. |
2908 | $user_data = array(); |
2909 | $user_data['ID'] = $user->ID; |
2910 |
|
Line | Code |
2981 | if ( ! $page ) { |
2982 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
2983 | } |
2984 |
|
2985 | if ( ! current_user_can( 'edit_page', $page_id ) ) { |
2986 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this page.' ) ); |
2987 | } |
2988 |
|
2989 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2990 | do_action( 'xmlrpc_call', 'wp.getPage', $args, $this ); |
2991 |
|
2992 | // If we found the page then format the data. |
2993 | if ( $page->ID && ( 'page' === $page->post_type ) ) { |
2994 | return $this->_prepare_page( $page ); |
2995 | } else { |
2996 | // If the page doesn't exist, indicate that. |
2997 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
2998 | } |
2999 | } |
Line | Code |
3024 | if ( ! $user ) { |
3025 | return $this->error; |
3026 | } |
3027 |
|
3028 | if ( ! current_user_can( 'edit_pages' ) ) { |
3029 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit pages.' ) ); |
3030 | } |
3031 |
|
3032 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3033 | do_action( 'xmlrpc_call', 'wp.getPages', $args, $this ); |
3034 |
|
3035 | $pages = get_posts( |
3036 | array( |
3037 | 'post_type' => 'page', |
3038 | 'post_status' => 'any', |
3039 | 'numberposts' => $num_pages, |
3040 | ) |
3041 | ); |
3042 | $num_pages = count( $pages ); |
Line | Code |
3079 | $username = $this->escape( $args[1] ); |
3080 | $password = $this->escape( $args[2] ); |
3081 |
|
3082 | $user = $this->login( $username, $password ); |
3083 | if ( ! $user ) { |
3084 | return $this->error; |
3085 | } |
3086 |
|
3087 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3088 | do_action( 'xmlrpc_call', 'wp.newPage', $args, $this ); |
3089 |
|
3090 | // Mark this as content for a page. |
3091 | $args[3]['post_type'] = 'page'; |
3092 |
|
3093 | // Let mw_newPost() do all of the heavy lifting. |
3094 | return $this->mw_newPost( $args ); |
3095 | } |
3096 |
|
3097 | /** |
Line | Code |
3116 | $password = $args[2]; |
3117 | $page_id = (int) $args[3]; |
3118 |
|
3119 | $user = $this->login( $username, $password ); |
3120 | if ( ! $user ) { |
3121 | return $this->error; |
3122 | } |
3123 |
|
3124 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3125 | do_action( 'xmlrpc_call', 'wp.deletePage', $args, $this ); |
3126 |
|
3127 | /* |
3128 | * Get the current page based on the 'page_id' and |
3129 | * make sure it is a page and not a post. |
3130 | */ |
3131 | $actual_page = get_post( $page_id, ARRAY_A ); |
3132 | if ( ! $actual_page || ( 'page' !== $actual_page['post_type'] ) ) { |
3133 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
3134 | } |
Line | Code |
3185 | $escaped_username = $this->escape( $username ); |
3186 | $escaped_password = $this->escape( $password ); |
3187 |
|
3188 | $user = $this->login( $escaped_username, $escaped_password ); |
3189 | if ( ! $user ) { |
3190 | return $this->error; |
3191 | } |
3192 |
|
3193 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3194 | do_action( 'xmlrpc_call', 'wp.editPage', $args, $this ); |
3195 |
|
3196 | // Get the page data and make sure it is a page. |
3197 | $actual_page = get_post( $page_id, ARRAY_A ); |
3198 | if ( ! $actual_page || ( 'page' !== $actual_page['post_type'] ) ) { |
3199 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
3200 | } |
3201 |
|
3202 | // Make sure the user is allowed to edit pages. |
3203 | if ( ! current_user_can( 'edit_page', $page_id ) ) { |
Line | Code |
3248 | if ( ! $user ) { |
3249 | return $this->error; |
3250 | } |
3251 |
|
3252 | if ( ! current_user_can( 'edit_pages' ) ) { |
3253 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit pages.' ) ); |
3254 | } |
3255 |
|
3256 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3257 | do_action( 'xmlrpc_call', 'wp.getPageList', $args, $this ); |
3258 |
|
3259 | // Get list of page IDs and titles. |
3260 | $page_list = $wpdb->get_results( |
3261 | " |
3262 | SELECT ID page_id, |
3263 | post_title page_title, |
3264 | post_parent page_parent_id, |
3265 | post_date_gmt, |
3266 | post_date, |
Line | Code |
3309 | if ( ! $user ) { |
3310 | return $this->error; |
3311 | } |
3312 |
|
3313 | if ( ! current_user_can( 'edit_posts' ) ) { |
3314 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
3315 | } |
3316 |
|
3317 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3318 | do_action( 'xmlrpc_call', 'wp.getAuthors', $args, $this ); |
3319 |
|
3320 | $authors = array(); |
3321 | foreach ( get_users( array( 'fields' => array( 'ID', 'user_login', 'display_name' ) ) ) as $user ) { |
3322 | $authors[] = array( |
3323 | 'user_id' => $user->ID, |
3324 | 'user_login' => $user->user_login, |
3325 | 'display_name' => $user->display_name, |
3326 | ); |
3327 | } |
Line | Code |
3353 | if ( ! $user ) { |
3354 | return $this->error; |
3355 | } |
3356 |
|
3357 | if ( ! current_user_can( 'edit_posts' ) ) { |
3358 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view tags.' ) ); |
3359 | } |
3360 |
|
3361 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3362 | do_action( 'xmlrpc_call', 'wp.getKeywords', $args, $this ); |
3363 |
|
3364 | $tags = array(); |
3365 |
|
3366 | $all_tags = get_tags(); |
3367 | if ( $all_tags ) { |
3368 | foreach ( (array) $all_tags as $tag ) { |
3369 | $struct = array(); |
3370 | $struct['tag_id'] = $tag->term_id; |
3371 | $struct['name'] = $tag->name; |
Line | Code |
3403 | $password = $args[2]; |
3404 | $category = $args[3]; |
3405 |
|
3406 | $user = $this->login( $username, $password ); |
3407 | if ( ! $user ) { |
3408 | return $this->error; |
3409 | } |
3410 |
|
3411 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3412 | do_action( 'xmlrpc_call', 'wp.newCategory', $args, $this ); |
3413 |
|
3414 | // Make sure the user is allowed to add a category. |
3415 | if ( ! current_user_can( 'manage_categories' ) ) { |
3416 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to add a category.' ) ); |
3417 | } |
3418 |
|
3419 | /* |
3420 | * If no slug was provided, make it empty |
3421 | * so that WordPress will generate one. |
Line | Code |
3490 | $password = $args[2]; |
3491 | $category_id = (int) $args[3]; |
3492 |
|
3493 | $user = $this->login( $username, $password ); |
3494 | if ( ! $user ) { |
3495 | return $this->error; |
3496 | } |
3497 |
|
3498 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3499 | do_action( 'xmlrpc_call', 'wp.deleteCategory', $args, $this ); |
3500 |
|
3501 | if ( ! current_user_can( 'delete_term', $category_id ) ) { |
3502 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this category.' ) ); |
3503 | } |
3504 |
|
3505 | $status = wp_delete_term( $category_id, 'category' ); |
3506 |
|
3507 | if ( true == $status ) { |
3508 | /** |
Line | Code |
3547 | if ( ! $user ) { |
3548 | return $this->error; |
3549 | } |
3550 |
|
3551 | if ( ! current_user_can( 'edit_posts' ) ) { |
3552 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
3553 | } |
3554 |
|
3555 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3556 | do_action( 'xmlrpc_call', 'wp.suggestCategories', $args, $this ); |
3557 |
|
3558 | $category_suggestions = array(); |
3559 | $args = array( |
3560 | 'get' => 'all', |
3561 | 'number' => $max_results, |
3562 | 'name__like' => $category, |
3563 | ); |
3564 | foreach ( (array) get_categories( $args ) as $cat ) { |
3565 | $category_suggestions[] = array( |
Line | Code |
3593 | $password = $args[2]; |
3594 | $comment_id = (int) $args[3]; |
3595 |
|
3596 | $user = $this->login( $username, $password ); |
3597 | if ( ! $user ) { |
3598 | return $this->error; |
3599 | } |
3600 |
|
3601 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3602 | do_action( 'xmlrpc_call', 'wp.getComment', $args, $this ); |
3603 |
|
3604 | $comment = get_comment( $comment_id ); |
3605 | if ( ! $comment ) { |
3606 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
3607 | } |
3608 |
|
3609 | if ( ! current_user_can( 'edit_comment', $comment_id ) ) { |
3610 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) ); |
3611 | } |
Line | Code |
3649 | $password = $args[2]; |
3650 | $struct = isset( $args[3] ) ? $args[3] : array(); |
3651 |
|
3652 | $user = $this->login( $username, $password ); |
3653 | if ( ! $user ) { |
3654 | return $this->error; |
3655 | } |
3656 |
|
3657 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3658 | do_action( 'xmlrpc_call', 'wp.getComments', $args, $this ); |
3659 |
|
3660 | if ( isset( $struct['status'] ) ) { |
3661 | $status = $struct['status']; |
3662 | } else { |
3663 | $status = ''; |
3664 | } |
3665 |
|
3666 | if ( ! current_user_can( 'moderate_comments' ) && 'approve' !== $status ) { |
3667 | return new IXR_Error( 401, __( 'Invalid comment status.' ) ); |
Line | Code |
3744 | if ( ! get_comment( $comment_id ) ) { |
3745 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
3746 | } |
3747 |
|
3748 | if ( ! current_user_can( 'edit_comment', $comment_id ) ) { |
3749 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to delete this comment.' ) ); |
3750 | } |
3751 |
|
3752 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3753 | do_action( 'xmlrpc_call', 'wp.deleteComment', $args, $this ); |
3754 |
|
3755 | $status = wp_delete_comment( $comment_id ); |
3756 |
|
3757 | if ( $status ) { |
3758 | /** |
3759 | * Fires after a comment has been successfully deleted via XML-RPC. |
3760 | * |
3761 | * @since 3.4.0 |
3762 | * |
Line | Code |
3812 | if ( ! get_comment( $comment_id ) ) { |
3813 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
3814 | } |
3815 |
|
3816 | if ( ! current_user_can( 'edit_comment', $comment_id ) ) { |
3817 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) ); |
3818 | } |
3819 |
|
3820 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3821 | do_action( 'xmlrpc_call', 'wp.editComment', $args, $this ); |
3822 | $comment = array( |
3823 | 'comment_ID' => $comment_id, |
3824 | ); |
3825 |
|
3826 | if ( isset( $content_struct['status'] ) ) { |
3827 | $statuses = get_comment_statuses(); |
3828 | $statuses = array_keys( $statuses ); |
3829 |
|
3830 | if ( ! in_array( $content_struct['status'], $statuses, true ) ) { |
Line | Code |
4005 |
|
4006 | /** This filter is documented in wp-includes/comment.php */ |
4007 | $allow_empty = apply_filters( 'allow_empty_comment', false, $comment ); |
4008 |
|
4009 | if ( ! $allow_empty && '' === $comment['comment_content'] ) { |
4010 | return new IXR_Error( 403, __( 'Comment is required.' ) ); |
4011 | } |
4012 |
|
4013 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4014 | do_action( 'xmlrpc_call', 'wp.newComment', $args, $this ); |
4015 |
|
4016 | $comment_id = wp_new_comment( $comment, true ); |
4017 | if ( is_wp_error( $comment_id ) ) { |
4018 | return new IXR_Error( 403, $comment_id->get_error_message() ); |
4019 | } |
4020 |
|
4021 | if ( ! $comment_id ) { |
4022 | return new IXR_Error( 403, __( 'Something went wrong.' ) ); |
4023 | } |
Line | Code |
4059 | if ( ! $user ) { |
4060 | return $this->error; |
4061 | } |
4062 |
|
4063 | if ( ! current_user_can( 'publish_posts' ) ) { |
4064 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) ); |
4065 | } |
4066 |
|
4067 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4068 | do_action( 'xmlrpc_call', 'wp.getCommentStatusList', $args, $this ); |
4069 |
|
4070 | return get_comment_statuses(); |
4071 | } |
4072 |
|
4073 | /** |
4074 | * Retrieves comment counts. |
4075 | * |
4076 | * @since 2.5.0 |
4077 | * |
Line | Code |
4101 | if ( empty( $post['ID'] ) ) { |
4102 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
4103 | } |
4104 |
|
4105 | if ( ! current_user_can( 'edit_post', $post_id ) ) { |
4106 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details of this post.' ) ); |
4107 | } |
4108 |
|
4109 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4110 | do_action( 'xmlrpc_call', 'wp.getCommentCount', $args, $this ); |
4111 |
|
4112 | $count = wp_count_comments( $post_id ); |
4113 |
|
4114 | return array( |
4115 | 'approved' => $count->approved, |
4116 | 'awaiting_moderation' => $count->moderated, |
4117 | 'spam' => $count->spam, |
4118 | 'total_comments' => $count->total_comments, |
4119 | ); |
Line | Code |
4143 | if ( ! $user ) { |
4144 | return $this->error; |
4145 | } |
4146 |
|
4147 | if ( ! current_user_can( 'edit_posts' ) ) { |
4148 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) ); |
4149 | } |
4150 |
|
4151 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4152 | do_action( 'xmlrpc_call', 'wp.getPostStatusList', $args, $this ); |
4153 |
|
4154 | return get_post_statuses(); |
4155 | } |
4156 |
|
4157 | /** |
4158 | * Retrieves page statuses. |
4159 | * |
4160 | * @since 2.5.0 |
4161 | * |
Line | Code |
4178 | if ( ! $user ) { |
4179 | return $this->error; |
4180 | } |
4181 |
|
4182 | if ( ! current_user_can( 'edit_pages' ) ) { |
4183 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) ); |
4184 | } |
4185 |
|
4186 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4187 | do_action( 'xmlrpc_call', 'wp.getPageStatusList', $args, $this ); |
4188 |
|
4189 | return get_page_statuses(); |
4190 | } |
4191 |
|
4192 | /** |
4193 | * Retrieves page templates. |
4194 | * |
4195 | * @since 2.6.0 |
4196 | * |
Line | Code |
4371 | if ( ! $user ) { |
4372 | return $this->error; |
4373 | } |
4374 |
|
4375 | if ( ! current_user_can( 'upload_files' ) ) { |
4376 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to upload files.' ) ); |
4377 | } |
4378 |
|
4379 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4380 | do_action( 'xmlrpc_call', 'wp.getMediaItem', $args, $this ); |
4381 |
|
4382 | $attachment = get_post( $attachment_id ); |
4383 | if ( ! $attachment || 'attachment' !== $attachment->post_type ) { |
4384 | return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); |
4385 | } |
4386 |
|
4387 | return $this->_prepare_media_item( $attachment ); |
4388 | } |
4389 |
|
Line | Code |
4427 | if ( ! $user ) { |
4428 | return $this->error; |
4429 | } |
4430 |
|
4431 | if ( ! current_user_can( 'upload_files' ) ) { |
4432 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to upload files.' ) ); |
4433 | } |
4434 |
|
4435 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4436 | do_action( 'xmlrpc_call', 'wp.getMediaLibrary', $args, $this ); |
4437 |
|
4438 | $parent_id = ( isset( $struct['parent_id'] ) ) ? absint( $struct['parent_id'] ) : ''; |
4439 | $mime_type = ( isset( $struct['mime_type'] ) ) ? $struct['mime_type'] : ''; |
4440 | $offset = ( isset( $struct['offset'] ) ) ? absint( $struct['offset'] ) : 0; |
4441 | $number = ( isset( $struct['number'] ) ) ? absint( $struct['number'] ) : -1; |
4442 |
|
4443 | $attachments = get_posts( |
4444 | array( |
4445 | 'post_type' => 'attachment', |
Line | Code |
4483 | if ( ! $user ) { |
4484 | return $this->error; |
4485 | } |
4486 |
|
4487 | if ( ! current_user_can( 'edit_posts' ) ) { |
4488 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) ); |
4489 | } |
4490 |
|
4491 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4492 | do_action( 'xmlrpc_call', 'wp.getPostFormats', $args, $this ); |
4493 |
|
4494 | $formats = get_post_format_strings(); |
4495 |
|
4496 | // Find out if they want a list of currently supports formats. |
4497 | if ( isset( $args[3] ) && is_array( $args[3] ) ) { |
4498 | if ( $args[3]['show-supported'] ) { |
4499 | if ( current_theme_supports( 'post-formats' ) ) { |
4500 | $supported = get_theme_support( 'post-formats' ); |
4501 |
|
Line | Code |
4564 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostType' ); |
4565 | } |
4566 |
|
4567 | $user = $this->login( $username, $password ); |
4568 | if ( ! $user ) { |
4569 | return $this->error; |
4570 | } |
4571 |
|
4572 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4573 | do_action( 'xmlrpc_call', 'wp.getPostType', $args, $this ); |
4574 |
|
4575 | if ( ! post_type_exists( $post_type_name ) ) { |
4576 | return new IXR_Error( 403, __( 'Invalid post type.' ) ); |
4577 | } |
4578 |
|
4579 | $post_type = get_post_type_object( $post_type_name ); |
4580 |
|
4581 | if ( ! current_user_can( $post_type->cap->edit_posts ) ) { |
4582 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts in this post type.' ) ); |
Line | Code |
4621 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostTypes' ); |
4622 | } |
4623 |
|
4624 | $user = $this->login( $username, $password ); |
4625 | if ( ! $user ) { |
4626 | return $this->error; |
4627 | } |
4628 |
|
4629 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4630 | do_action( 'xmlrpc_call', 'wp.getPostTypes', $args, $this ); |
4631 |
|
4632 | $post_types = get_post_types( $filter, 'objects' ); |
4633 |
|
4634 | $struct = array(); |
4635 |
|
4636 | foreach ( $post_types as $post_type ) { |
4637 | if ( ! current_user_can( $post_type->cap->edit_posts ) ) { |
4638 | continue; |
4639 | } |
Line | Code |
4692 | $fields = apply_filters( 'xmlrpc_default_revision_fields', array( 'post_date', 'post_date_gmt' ), 'wp.getRevisions' ); |
4693 | } |
4694 |
|
4695 | $user = $this->login( $username, $password ); |
4696 | if ( ! $user ) { |
4697 | return $this->error; |
4698 | } |
4699 |
|
4700 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4701 | do_action( 'xmlrpc_call', 'wp.getRevisions', $args, $this ); |
4702 |
|
4703 | $post = get_post( $post_id ); |
4704 | if ( ! $post ) { |
4705 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
4706 | } |
4707 |
|
4708 | if ( ! current_user_can( 'edit_post', $post_id ) ) { |
4709 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
4710 | } |
Line | Code |
4766 | $password = $args[2]; |
4767 | $revision_id = (int) $args[3]; |
4768 |
|
4769 | $user = $this->login( $username, $password ); |
4770 | if ( ! $user ) { |
4771 | return $this->error; |
4772 | } |
4773 |
|
4774 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4775 | do_action( 'xmlrpc_call', 'wp.restoreRevision', $args, $this ); |
4776 |
|
4777 | $revision = wp_get_post_revision( $revision_id ); |
4778 | if ( ! $revision ) { |
4779 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
4780 | } |
4781 |
|
4782 | if ( wp_is_post_autosave( $revision ) ) { |
4783 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
4784 | } |
Line | Code |
4837 | $username = $args[1]; |
4838 | $password = $args[2]; |
4839 |
|
4840 | $user = $this->login( $username, $password ); |
4841 | if ( ! $user ) { |
4842 | return $this->error; |
4843 | } |
4844 |
|
4845 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4846 | do_action( 'xmlrpc_call', 'blogger.getUsersBlogs', $args, $this ); |
4847 |
|
4848 | $is_admin = current_user_can( 'manage_options' ); |
4849 |
|
4850 | $struct = array( |
4851 | 'isAdmin' => $is_admin, |
4852 | 'url' => get_option( 'home' ) . '/', |
4853 | 'blogid' => '1', |
4854 | 'blogName' => get_option( 'blogname' ), |
4855 | 'xmlrpc' => site_url( 'xmlrpc.php', 'rpc' ), |
Line | Code |
4921 | if ( ! $user ) { |
4922 | return $this->error; |
4923 | } |
4924 |
|
4925 | if ( ! current_user_can( 'edit_posts' ) ) { |
4926 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to access user data on this site.' ) ); |
4927 | } |
4928 |
|
4929 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4930 | do_action( 'xmlrpc_call', 'blogger.getUserInfo', $args, $this ); |
4931 |
|
4932 | $struct = array( |
4933 | 'nickname' => $user->nickname, |
4934 | 'userid' => $user->ID, |
4935 | 'url' => $user->user_url, |
4936 | 'lastname' => $user->last_name, |
4937 | 'firstname' => $user->first_name, |
4938 | ); |
4939 |
|
Line | Code |
4971 | if ( ! $post_data ) { |
4972 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
4973 | } |
4974 |
|
4975 | if ( ! current_user_can( 'edit_post', $post_id ) ) { |
4976 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
4977 | } |
4978 |
|
4979 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4980 | do_action( 'xmlrpc_call', 'blogger.getPost', $args, $this ); |
4981 |
|
4982 | $categories = implode( ',', wp_get_post_categories( $post_id ) ); |
4983 |
|
4984 | $content = '<title>' . wp_unslash( $post_data['post_title'] ) . '</title>'; |
4985 | $content .= '<category>' . $categories . '</category>'; |
4986 | $content .= wp_unslash( $post_data['post_content'] ); |
4987 |
|
4988 | $struct = array( |
4989 | 'userid' => $post_data['post_author'], |
Line | Code |
5028 | if ( ! $user ) { |
5029 | return $this->error; |
5030 | } |
5031 |
|
5032 | if ( ! current_user_can( 'edit_posts' ) ) { |
5033 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
5034 | } |
5035 |
|
5036 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5037 | do_action( 'xmlrpc_call', 'blogger.getRecentPosts', $args, $this ); |
5038 |
|
5039 | $posts_list = wp_get_recent_posts( $query ); |
5040 |
|
5041 | if ( ! $posts_list ) { |
5042 | $this->error = new IXR_Error( 500, __( 'Either there are no posts, or something went wrong.' ) ); |
5043 | return $this->error; |
5044 | } |
5045 |
|
5046 | $recent_posts = array(); |
Line | Code |
5118 | $content = $args[4]; |
5119 | $publish = $args[5]; |
5120 |
|
5121 | $user = $this->login( $username, $password ); |
5122 | if ( ! $user ) { |
5123 | return $this->error; |
5124 | } |
5125 |
|
5126 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5127 | do_action( 'xmlrpc_call', 'blogger.newPost', $args, $this ); |
5128 |
|
5129 | $cap = ( $publish ) ? 'publish_posts' : 'edit_posts'; |
5130 | if ( ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) || ! current_user_can( $cap ) ) { |
5131 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to post on this site.' ) ); |
5132 | } |
5133 |
|
5134 | $post_status = ( $publish ) ? 'publish' : 'draft'; |
5135 |
|
5136 | $post_author = $user->ID; |
Line | Code |
5195 | $content = $args[4]; |
5196 | $publish = $args[5]; |
5197 |
|
5198 | $user = $this->login( $username, $password ); |
5199 | if ( ! $user ) { |
5200 | return $this->error; |
5201 | } |
5202 |
|
5203 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5204 | do_action( 'xmlrpc_call', 'blogger.editPost', $args, $this ); |
5205 |
|
5206 | $actual_post = get_post( $post_id, ARRAY_A ); |
5207 |
|
5208 | if ( ! $actual_post || 'post' !== $actual_post['post_type'] ) { |
5209 | return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); |
5210 | } |
5211 |
|
5212 | $this->escape( $actual_post ); |
5213 |
|
Line | Code |
5269 | $username = $args[2]; |
5270 | $password = $args[3]; |
5271 |
|
5272 | $user = $this->login( $username, $password ); |
5273 | if ( ! $user ) { |
5274 | return $this->error; |
5275 | } |
5276 |
|
5277 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5278 | do_action( 'xmlrpc_call', 'blogger.deletePost', $args, $this ); |
5279 |
|
5280 | $actual_post = get_post( $post_id, ARRAY_A ); |
5281 |
|
5282 | if ( ! $actual_post || 'post' !== $actual_post['post_type'] ) { |
5283 | return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); |
5284 | } |
5285 |
|
5286 | if ( ! current_user_can( 'delete_post', $post_id ) ) { |
5287 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) ); |
Line | Code |
5357 | $content_struct = $args[3]; |
5358 | $publish = isset( $args[4] ) ? $args[4] : 0; |
5359 |
|
5360 | $user = $this->login( $username, $password ); |
5361 | if ( ! $user ) { |
5362 | return $this->error; |
5363 | } |
5364 |
|
5365 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5366 | do_action( 'xmlrpc_call', 'metaWeblog.newPost', $args, $this ); |
5367 |
|
5368 | $page_template = ''; |
5369 | if ( ! empty( $content_struct['post_type'] ) ) { |
5370 | if ( 'page' === $content_struct['post_type'] ) { |
5371 | if ( $publish ) { |
5372 | $cap = 'publish_pages'; |
5373 | } elseif ( isset( $content_struct['page_status'] ) && 'publish' === $content_struct['page_status'] ) { |
5374 | $cap = 'publish_pages'; |
5375 | } else { |
Line | Code |
5734 | $content_struct = $args[3]; |
5735 | $publish = isset( $args[4] ) ? $args[4] : 0; |
5736 |
|
5737 | $user = $this->login( $username, $password ); |
5738 | if ( ! $user ) { |
5739 | return $this->error; |
5740 | } |
5741 |
|
5742 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5743 | do_action( 'xmlrpc_call', 'metaWeblog.editPost', $args, $this ); |
5744 |
|
5745 | $postdata = get_post( $post_id, ARRAY_A ); |
5746 |
|
5747 | /* |
5748 | * If there is no post data for the give post ID, stop now and return an error. |
5749 | * Otherwise a new post will be created (which was the old behavior). |
5750 | */ |
5751 | if ( ! $postdata || empty( $postdata['ID'] ) ) { |
5752 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
Line | Code |
6071 | if ( ! $postdata ) { |
6072 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
6073 | } |
6074 |
|
6075 | if ( ! current_user_can( 'edit_post', $post_id ) ) { |
6076 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
6077 | } |
6078 |
|
6079 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6080 | do_action( 'xmlrpc_call', 'metaWeblog.getPost', $args, $this ); |
6081 |
|
6082 | if ( '' !== $postdata['post_date'] ) { |
6083 | $post_date = $this->_convert_date( $postdata['post_date'] ); |
6084 | $post_date_gmt = $this->_convert_date_gmt( $postdata['post_date_gmt'], $postdata['post_date'] ); |
6085 | $post_modified = $this->_convert_date( $postdata['post_modified'] ); |
6086 | $post_modified_gmt = $this->_convert_date_gmt( $postdata['post_modified_gmt'], $postdata['post_modified'] ); |
6087 |
|
6088 | $categories = array(); |
6089 | $catids = wp_get_post_categories( $post_id ); |
Line | Code |
6212 | if ( ! $user ) { |
6213 | return $this->error; |
6214 | } |
6215 |
|
6216 | if ( ! current_user_can( 'edit_posts' ) ) { |
6217 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
6218 | } |
6219 |
|
6220 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6221 | do_action( 'xmlrpc_call', 'metaWeblog.getRecentPosts', $args, $this ); |
6222 |
|
6223 | $posts_list = wp_get_recent_posts( $query ); |
6224 |
|
6225 | if ( ! $posts_list ) { |
6226 | return array(); |
6227 | } |
6228 |
|
6229 | $recent_posts = array(); |
6230 | foreach ( $posts_list as $entry ) { |
Line | Code |
6333 | if ( ! $user ) { |
6334 | return $this->error; |
6335 | } |
6336 |
|
6337 | if ( ! current_user_can( 'edit_posts' ) ) { |
6338 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
6339 | } |
6340 |
|
6341 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6342 | do_action( 'xmlrpc_call', 'metaWeblog.getCategories', $args, $this ); |
6343 |
|
6344 | $categories_struct = array(); |
6345 |
|
6346 | $cats = get_categories( array( 'get' => 'all' ) ); |
6347 | if ( $cats ) { |
6348 | foreach ( $cats as $cat ) { |
6349 | $struct = array(); |
6350 | $struct['categoryId'] = $cat->term_id; |
6351 | $struct['parentId'] = $cat->parent; |
Line | Code |
6390 | $type = $data['type']; |
6391 | $bits = $data['bits']; |
6392 |
|
6393 | $user = $this->login( $username, $password ); |
6394 | if ( ! $user ) { |
6395 | return $this->error; |
6396 | } |
6397 |
|
6398 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6399 | do_action( 'xmlrpc_call', 'metaWeblog.newMediaObject', $args, $this ); |
6400 |
|
6401 | if ( ! current_user_can( 'upload_files' ) ) { |
6402 | $this->error = new IXR_Error( 401, __( 'Sorry, you are not allowed to upload files.' ) ); |
6403 | return $this->error; |
6404 | } |
6405 |
|
6406 | if ( is_multisite() && upload_is_user_over_quota( false ) ) { |
6407 | $this->error = new IXR_Error( |
6408 | 401, |
Line | Code |
6509 | $query = array(); |
6510 | } |
6511 |
|
6512 | $user = $this->login( $username, $password ); |
6513 | if ( ! $user ) { |
6514 | return $this->error; |
6515 | } |
6516 |
|
6517 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6518 | do_action( 'xmlrpc_call', 'mt.getRecentPostTitles', $args, $this ); |
6519 |
|
6520 | $posts_list = wp_get_recent_posts( $query ); |
6521 |
|
6522 | if ( ! $posts_list ) { |
6523 | $this->error = new IXR_Error( 500, __( 'Either there are no posts, or something went wrong.' ) ); |
6524 | return $this->error; |
6525 | } |
6526 |
|
6527 | $recent_posts = array(); |
Line | Code |
6571 | if ( ! $user ) { |
6572 | return $this->error; |
6573 | } |
6574 |
|
6575 | if ( ! current_user_can( 'edit_posts' ) ) { |
6576 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
6577 | } |
6578 |
|
6579 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6580 | do_action( 'xmlrpc_call', 'mt.getCategoryList', $args, $this ); |
6581 |
|
6582 | $categories_struct = array(); |
6583 |
|
6584 | $cats = get_categories( |
6585 | array( |
6586 | 'hide_empty' => 0, |
6587 | 'hierarchical' => 0, |
6588 | ) |
6589 | ); |
Line | Code |
6629 | if ( ! get_post( $post_id ) ) { |
6630 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
6631 | } |
6632 |
|
6633 | if ( ! current_user_can( 'edit_post', $post_id ) ) { |
6634 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
6635 | } |
6636 |
|
6637 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6638 | do_action( 'xmlrpc_call', 'mt.getPostCategories', $args, $this ); |
6639 |
|
6640 | $categories = array(); |
6641 | $catids = wp_get_post_categories( (int) $post_id ); |
6642 | // First listed category will be the primary category. |
6643 | $isPrimary = true; |
6644 | foreach ( $catids as $catid ) { |
6645 | $categories[] = array( |
6646 | 'categoryName' => get_cat_name( $catid ), |
6647 | 'categoryId' => (string) $catid, |
Line | Code |
6676 | $password = $args[2]; |
6677 | $categories = $args[3]; |
6678 |
|
6679 | $user = $this->login( $username, $password ); |
6680 | if ( ! $user ) { |
6681 | return $this->error; |
6682 | } |
6683 |
|
6684 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6685 | do_action( 'xmlrpc_call', 'mt.setPostCategories', $args, $this ); |
6686 |
|
6687 | if ( ! get_post( $post_id ) ) { |
6688 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
6689 | } |
6690 |
|
6691 | if ( ! current_user_can( 'edit_post', $post_id ) ) { |
6692 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
6693 | } |
6694 |
|
Line | Code |
6705 | /** |
6706 | * Retrieves an array of methods supported by this server. |
6707 | * |
6708 | * @since 1.5.0 |
6709 | * |
6710 | * @return array |
6711 | */ |
6712 | public function mt_supportedMethods() { |
6713 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6714 | do_action( 'xmlrpc_call', 'mt.supportedMethods', array(), $this ); |
6715 |
|
6716 | return array_keys( $this->methods ); |
6717 | } |
6718 |
|
6719 | /** |
6720 | * Retrieves an empty array because we don't support per-post text filters. |
6721 | * |
6722 | * @since 1.5.0 |
6723 | */ |
6724 | public function mt_supportedTextFilters() { |
6725 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6726 | do_action( 'xmlrpc_call', 'mt.supportedTextFilters', array(), $this ); |
6727 |
|
6728 | /** |
6729 | * Filters the MoveableType text filters list for XML-RPC. |
6730 | * |
6731 | * @since 2.2.0 |
6732 | * |
6733 | * @param array $filters An array of text filters. |
6734 | */ |
6735 | return apply_filters( 'xmlrpc_text_filters', array() ); |
Line | Code |
6743 | * @global wpdb $wpdb WordPress database abstraction object. |
6744 | * |
6745 | * @param int $post_id |
6746 | * @return array|IXR_Error |
6747 | */ |
6748 | public function mt_getTrackbackPings( $post_id ) { |
6749 | global $wpdb; |
6750 |
|
6751 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6752 | do_action( 'xmlrpc_call', 'mt.getTrackbackPings', $post_id, $this ); |
6753 |
|
6754 | $actual_post = get_post( $post_id, ARRAY_A ); |
6755 |
|
6756 | if ( ! $actual_post ) { |
6757 | return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); |
6758 | } |
6759 |
|
6760 | $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 ) ); |
6761 |
|
Line | Code |
6800 | $username = $args[1]; |
6801 | $password = $args[2]; |
6802 |
|
6803 | $user = $this->login( $username, $password ); |
6804 | if ( ! $user ) { |
6805 | return $this->error; |
6806 | } |
6807 |
|
6808 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6809 | do_action( 'xmlrpc_call', 'mt.publishPost', $args, $this ); |
6810 |
|
6811 | $postdata = get_post( $post_id, ARRAY_A ); |
6812 | if ( ! $postdata ) { |
6813 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
6814 | } |
6815 |
|
6816 | if ( ! current_user_can( 'publish_posts' ) || ! current_user_can( 'edit_post', $post_id ) ) { |
6817 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish this post.' ) ); |
6818 | } |
Line | Code |
6844 | * @type string $0 URL of page linked from. |
6845 | * @type string $1 URL of page linked to. |
6846 | * } |
6847 | * @return string|IXR_Error |
6848 | */ |
6849 | public function pingback_ping( $args ) { |
6850 | global $wpdb; |
6851 |
|
6852 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6853 | do_action( 'xmlrpc_call', 'pingback.ping', $args, $this ); |
6854 |
|
6855 | $this->escape( $args ); |
6856 |
|
6857 | $pagelinkedfrom = str_replace( '&', '&', $args[0] ); |
6858 | $pagelinkedto = str_replace( '&', '&', $args[1] ); |
6859 | $pagelinkedto = str_replace( '&', '&', $pagelinkedto ); |
6860 |
|
6861 | /** |
6862 | * Filters the pingback source URI. |
Line | Code |
7100 | * @global wpdb $wpdb WordPress database abstraction object. |
7101 | * |
7102 | * @param string $url |
7103 | * @return array|IXR_Error |
7104 | */ |
7105 | public function pingback_extensions_getPingbacks( $url ) { |
7106 | global $wpdb; |
7107 |
|
7108 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
7109 | do_action( 'xmlrpc_call', 'pingback.extensions.getPingbacks', $url, $this ); |
7110 |
|
7111 | $url = $this->escape( $url ); |
7112 |
|
7113 | $post_id = url_to_postid( $url ); |
7114 | if ( ! $post_id ) { |
7115 | // We aren't sure that the resource is available and/or pingback enabled. |
7116 | 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.' ) ); |
7117 | } |
7118 |
|