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 |
---|---|
681 | * equal to the method's name, e.g., wp.getUsersBlogs, wp.newPost, etc. |
682 | * |
683 | * @since 2.5.0 |
684 | * @since 5.7.0 Added the `$args` and `$server` parameters. |
685 | * |
686 | * @param string $name The method name. |
687 | * @param array|string $args The escaped arguments passed to the method. |
688 | * @param wp_xmlrpc_server $server The XML-RPC server instance. |
689 | */ |
690 | do_action( 'xmlrpc_call', 'wp.getUsersBlogs', $args, $this ); |
691 |
|
692 | $blogs = (array) get_blogs_of_user( $user->ID ); |
693 | $struct = array(); |
694 | $primary_blog_id = 0; |
695 | $active_blog = get_active_blog_for_user( $user->ID ); |
696 | if ( $active_blog ) { |
697 | $primary_blog_id = (int) $active_blog->blog_id; |
698 | } |
699 |
|
Line | Code |
1291 | if ( isset( $content_struct['post_date_gmt'] ) && ! ( $content_struct['post_date_gmt'] instanceof IXR_Date ) ) { |
1292 | if ( '0000-00-00 00:00:00' === $content_struct['post_date_gmt'] || isset( $content_struct['post_date'] ) ) { |
1293 | unset( $content_struct['post_date_gmt'] ); |
1294 | } else { |
1295 | $content_struct['post_date_gmt'] = $this->_convert_date( $content_struct['post_date_gmt'] ); |
1296 | } |
1297 | } |
1298 |
|
1299 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
1300 | do_action( 'xmlrpc_call', 'wp.newPost', $args, $this ); |
1301 |
|
1302 | unset( $content_struct['ID'] ); |
1303 |
|
1304 | return $this->_insert_post( $user, $content_struct ); |
1305 | } |
1306 |
|
1307 | /** |
1308 | * Helper method for filtering out elements from an array. |
1309 | * |
Line | Code |
1684 | $post_id = (int) $args[3]; |
1685 | $content_struct = $args[4]; |
1686 |
|
1687 | $user = $this->login( $username, $password ); |
1688 | if ( ! $user ) { |
1689 | return $this->error; |
1690 | } |
1691 |
|
1692 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
1693 | do_action( 'xmlrpc_call', 'wp.editPost', $args, $this ); |
1694 |
|
1695 | $post = get_post( $post_id, ARRAY_A ); |
1696 |
|
1697 | if ( empty( $post['ID'] ) ) { |
1698 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
1699 | } |
1700 |
|
1701 | if ( isset( $content_struct['if_not_modified_since'] ) ) { |
1702 | // If the post has been modified since the date provided, return an error. |
Line | Code |
1767 | $password = $args[2]; |
1768 | $post_id = (int) $args[3]; |
1769 |
|
1770 | $user = $this->login( $username, $password ); |
1771 | if ( ! $user ) { |
1772 | return $this->error; |
1773 | } |
1774 |
|
1775 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
1776 | do_action( 'xmlrpc_call', 'wp.deletePost', $args, $this ); |
1777 |
|
1778 | $post = get_post( $post_id, ARRAY_A ); |
1779 | if ( empty( $post['ID'] ) ) { |
1780 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
1781 | } |
1782 |
|
1783 | if ( ! current_user_can( 'delete_post', $post_id ) ) { |
1784 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) ); |
1785 | } |
Line | Code |
1867 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPost' ); |
1868 | } |
1869 |
|
1870 | $user = $this->login( $username, $password ); |
1871 | if ( ! $user ) { |
1872 | return $this->error; |
1873 | } |
1874 |
|
1875 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
1876 | do_action( 'xmlrpc_call', 'wp.getPost', $args, $this ); |
1877 |
|
1878 | $post = get_post( $post_id, ARRAY_A ); |
1879 |
|
1880 | if ( empty( $post['ID'] ) ) { |
1881 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
1882 | } |
1883 |
|
1884 | if ( ! current_user_can( 'edit_post', $post_id ) ) { |
1885 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
Line | Code |
1928 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPosts' ); |
1929 | } |
1930 |
|
1931 | $user = $this->login( $username, $password ); |
1932 | if ( ! $user ) { |
1933 | return $this->error; |
1934 | } |
1935 |
|
1936 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
1937 | do_action( 'xmlrpc_call', 'wp.getPosts', $args, $this ); |
1938 |
|
1939 | $query = array(); |
1940 |
|
1941 | if ( isset( $filter['post_type'] ) ) { |
1942 | $post_type = get_post_type_object( $filter['post_type'] ); |
1943 | if ( ! ( (bool) $post_type ) ) { |
1944 | return new IXR_Error( 403, __( 'Invalid post type.' ) ); |
1945 | } |
1946 | } else { |
Line | Code |
2027 | $password = $args[2]; |
2028 | $content_struct = $args[3]; |
2029 |
|
2030 | $user = $this->login( $username, $password ); |
2031 | if ( ! $user ) { |
2032 | return $this->error; |
2033 | } |
2034 |
|
2035 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2036 | do_action( 'xmlrpc_call', 'wp.newTerm', $args, $this ); |
2037 |
|
2038 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) { |
2039 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
2040 | } |
2041 |
|
2042 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
2043 |
|
2044 | if ( ! current_user_can( $taxonomy->cap->edit_terms ) ) { |
2045 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to create terms in this taxonomy.' ) ); |
Line | Code |
2132 | $term_id = (int) $args[3]; |
2133 | $content_struct = $args[4]; |
2134 |
|
2135 | $user = $this->login( $username, $password ); |
2136 | if ( ! $user ) { |
2137 | return $this->error; |
2138 | } |
2139 |
|
2140 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2141 | do_action( 'xmlrpc_call', 'wp.editTerm', $args, $this ); |
2142 |
|
2143 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) { |
2144 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
2145 | } |
2146 |
|
2147 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
2148 |
|
2149 | $taxonomy = (array) $taxonomy; |
2150 |
|
Line | Code |
2248 | $taxonomy = $args[3]; |
2249 | $term_id = (int) $args[4]; |
2250 |
|
2251 | $user = $this->login( $username, $password ); |
2252 | if ( ! $user ) { |
2253 | return $this->error; |
2254 | } |
2255 |
|
2256 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2257 | do_action( 'xmlrpc_call', 'wp.deleteTerm', $args, $this ); |
2258 |
|
2259 | if ( ! taxonomy_exists( $taxonomy ) ) { |
2260 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
2261 | } |
2262 |
|
2263 | $taxonomy = get_taxonomy( $taxonomy ); |
2264 | $term = get_term( $term_id, $taxonomy->name ); |
2265 |
|
2266 | if ( is_wp_error( $term ) ) { |
Line | Code |
2327 | $taxonomy = $args[3]; |
2328 | $term_id = (int) $args[4]; |
2329 |
|
2330 | $user = $this->login( $username, $password ); |
2331 | if ( ! $user ) { |
2332 | return $this->error; |
2333 | } |
2334 |
|
2335 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2336 | do_action( 'xmlrpc_call', 'wp.getTerm', $args, $this ); |
2337 |
|
2338 | if ( ! taxonomy_exists( $taxonomy ) ) { |
2339 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
2340 | } |
2341 |
|
2342 | $taxonomy = get_taxonomy( $taxonomy ); |
2343 |
|
2344 | $term = get_term( $term_id, $taxonomy->name, ARRAY_A ); |
2345 |
|
Line | Code |
2392 | $taxonomy = $args[3]; |
2393 | $filter = isset( $args[4] ) ? $args[4] : array(); |
2394 |
|
2395 | $user = $this->login( $username, $password ); |
2396 | if ( ! $user ) { |
2397 | return $this->error; |
2398 | } |
2399 |
|
2400 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2401 | do_action( 'xmlrpc_call', 'wp.getTerms', $args, $this ); |
2402 |
|
2403 | if ( ! taxonomy_exists( $taxonomy ) ) { |
2404 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
2405 | } |
2406 |
|
2407 | $taxonomy = get_taxonomy( $taxonomy ); |
2408 |
|
2409 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) { |
2410 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ) ); |
Line | Code |
2498 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomy' ); |
2499 | } |
2500 |
|
2501 | $user = $this->login( $username, $password ); |
2502 | if ( ! $user ) { |
2503 | return $this->error; |
2504 | } |
2505 |
|
2506 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2507 | do_action( 'xmlrpc_call', 'wp.getTaxonomy', $args, $this ); |
2508 |
|
2509 | if ( ! taxonomy_exists( $taxonomy ) ) { |
2510 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
2511 | } |
2512 |
|
2513 | $taxonomy = get_taxonomy( $taxonomy ); |
2514 |
|
2515 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) { |
2516 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ) ); |
Line | Code |
2556 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomies' ); |
2557 | } |
2558 |
|
2559 | $user = $this->login( $username, $password ); |
2560 | if ( ! $user ) { |
2561 | return $this->error; |
2562 | } |
2563 |
|
2564 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2565 | do_action( 'xmlrpc_call', 'wp.getTaxonomies', $args, $this ); |
2566 |
|
2567 | $taxonomies = get_taxonomies( $filter, 'objects' ); |
2568 |
|
2569 | // Holds all the taxonomy data. |
2570 | $struct = array(); |
2571 |
|
2572 | foreach ( $taxonomies as $taxonomy ) { |
2573 | // Capability check for post types. |
2574 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) { |
Line | Code |
2642 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUser' ); |
2643 | } |
2644 |
|
2645 | $user = $this->login( $username, $password ); |
2646 | if ( ! $user ) { |
2647 | return $this->error; |
2648 | } |
2649 |
|
2650 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2651 | do_action( 'xmlrpc_call', 'wp.getUser', $args, $this ); |
2652 |
|
2653 | if ( ! current_user_can( 'edit_user', $user_id ) ) { |
2654 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this user.' ) ); |
2655 | } |
2656 |
|
2657 | $user_data = get_userdata( $user_id ); |
2658 |
|
2659 | if ( ! $user_data ) { |
2660 | return new IXR_Error( 404, __( 'Invalid user ID.' ) ); |
Line | Code |
2705 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUsers' ); |
2706 | } |
2707 |
|
2708 | $user = $this->login( $username, $password ); |
2709 | if ( ! $user ) { |
2710 | return $this->error; |
2711 | } |
2712 |
|
2713 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2714 | do_action( 'xmlrpc_call', 'wp.getUsers', $args, $this ); |
2715 |
|
2716 | if ( ! current_user_can( 'list_users' ) ) { |
2717 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to list users.' ) ); |
2718 | } |
2719 |
|
2720 | $query = array( 'fields' => 'all_with_meta' ); |
2721 |
|
2722 | $query['number'] = ( isset( $filter['number'] ) ) ? absint( $filter['number'] ) : 50; |
2723 | $query['offset'] = ( isset( $filter['offset'] ) ) ? absint( $filter['offset'] ) : 0; |
Line | Code |
2785 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getProfile' ); |
2786 | } |
2787 |
|
2788 | $user = $this->login( $username, $password ); |
2789 | if ( ! $user ) { |
2790 | return $this->error; |
2791 | } |
2792 |
|
2793 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2794 | do_action( 'xmlrpc_call', 'wp.getProfile', $args, $this ); |
2795 |
|
2796 | if ( ! current_user_can( 'edit_user', $user->ID ) ) { |
2797 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit your profile.' ) ); |
2798 | } |
2799 |
|
2800 | $user_data = get_userdata( $user->ID ); |
2801 |
|
2802 | return $this->_prepare_user( $user_data, $fields ); |
2803 | } |
Line | Code |
2835 | $password = $args[2]; |
2836 | $content_struct = $args[3]; |
2837 |
|
2838 | $user = $this->login( $username, $password ); |
2839 | if ( ! $user ) { |
2840 | return $this->error; |
2841 | } |
2842 |
|
2843 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2844 | do_action( 'xmlrpc_call', 'wp.editProfile', $args, $this ); |
2845 |
|
2846 | if ( ! current_user_can( 'edit_user', $user->ID ) ) { |
2847 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit your profile.' ) ); |
2848 | } |
2849 |
|
2850 | // Holds data of the user. |
2851 | $user_data = array(); |
2852 | $user_data['ID'] = $user->ID; |
2853 |
|
Line | Code |
2924 | if ( ! $page ) { |
2925 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
2926 | } |
2927 |
|
2928 | if ( ! current_user_can( 'edit_page', $page_id ) ) { |
2929 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this page.' ) ); |
2930 | } |
2931 |
|
2932 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2933 | do_action( 'xmlrpc_call', 'wp.getPage', $args, $this ); |
2934 |
|
2935 | // If we found the page then format the data. |
2936 | if ( $page->ID && ( 'page' === $page->post_type ) ) { |
2937 | return $this->_prepare_page( $page ); |
2938 | } else { |
2939 | // If the page doesn't exist, indicate that. |
2940 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
2941 | } |
2942 | } |
Line | Code |
2967 | if ( ! $user ) { |
2968 | return $this->error; |
2969 | } |
2970 |
|
2971 | if ( ! current_user_can( 'edit_pages' ) ) { |
2972 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit pages.' ) ); |
2973 | } |
2974 |
|
2975 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2976 | do_action( 'xmlrpc_call', 'wp.getPages', $args, $this ); |
2977 |
|
2978 | $pages = get_posts( |
2979 | array( |
2980 | 'post_type' => 'page', |
2981 | 'post_status' => 'any', |
2982 | 'numberposts' => $num_pages, |
2983 | ) |
2984 | ); |
2985 | $num_pages = count( $pages ); |
Line | Code |
3022 | $username = $this->escape( $args[1] ); |
3023 | $password = $this->escape( $args[2] ); |
3024 |
|
3025 | $user = $this->login( $username, $password ); |
3026 | if ( ! $user ) { |
3027 | return $this->error; |
3028 | } |
3029 |
|
3030 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3031 | do_action( 'xmlrpc_call', 'wp.newPage', $args, $this ); |
3032 |
|
3033 | // Mark this as content for a page. |
3034 | $args[3]['post_type'] = 'page'; |
3035 |
|
3036 | // Let mw_newPost() do all of the heavy lifting. |
3037 | return $this->mw_newPost( $args ); |
3038 | } |
3039 |
|
3040 | /** |
Line | Code |
3059 | $password = $args[2]; |
3060 | $page_id = (int) $args[3]; |
3061 |
|
3062 | $user = $this->login( $username, $password ); |
3063 | if ( ! $user ) { |
3064 | return $this->error; |
3065 | } |
3066 |
|
3067 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3068 | do_action( 'xmlrpc_call', 'wp.deletePage', $args, $this ); |
3069 |
|
3070 | // Get the current page based on the 'page_id' and |
3071 | // make sure it is a page and not a post. |
3072 | $actual_page = get_post( $page_id, ARRAY_A ); |
3073 | if ( ! $actual_page || ( 'page' !== $actual_page['post_type'] ) ) { |
3074 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
3075 | } |
3076 |
|
3077 | // Make sure the user can delete pages. |
Line | Code |
3126 | $escaped_username = $this->escape( $username ); |
3127 | $escaped_password = $this->escape( $password ); |
3128 |
|
3129 | $user = $this->login( $escaped_username, $escaped_password ); |
3130 | if ( ! $user ) { |
3131 | return $this->error; |
3132 | } |
3133 |
|
3134 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3135 | do_action( 'xmlrpc_call', 'wp.editPage', $args, $this ); |
3136 |
|
3137 | // Get the page data and make sure it is a page. |
3138 | $actual_page = get_post( $page_id, ARRAY_A ); |
3139 | if ( ! $actual_page || ( 'page' !== $actual_page['post_type'] ) ) { |
3140 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
3141 | } |
3142 |
|
3143 | // Make sure the user is allowed to edit pages. |
3144 | if ( ! current_user_can( 'edit_page', $page_id ) ) { |
Line | Code |
3189 | if ( ! $user ) { |
3190 | return $this->error; |
3191 | } |
3192 |
|
3193 | if ( ! current_user_can( 'edit_pages' ) ) { |
3194 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit pages.' ) ); |
3195 | } |
3196 |
|
3197 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3198 | do_action( 'xmlrpc_call', 'wp.getPageList', $args, $this ); |
3199 |
|
3200 | // Get list of page IDs and titles. |
3201 | $page_list = $wpdb->get_results( |
3202 | " |
3203 | SELECT ID page_id, |
3204 | post_title page_title, |
3205 | post_parent page_parent_id, |
3206 | post_date_gmt, |
3207 | post_date, |
Line | Code |
3250 | if ( ! $user ) { |
3251 | return $this->error; |
3252 | } |
3253 |
|
3254 | if ( ! current_user_can( 'edit_posts' ) ) { |
3255 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
3256 | } |
3257 |
|
3258 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3259 | do_action( 'xmlrpc_call', 'wp.getAuthors', $args, $this ); |
3260 |
|
3261 | $authors = array(); |
3262 | foreach ( get_users( array( 'fields' => array( 'ID', 'user_login', 'display_name' ) ) ) as $user ) { |
3263 | $authors[] = array( |
3264 | 'user_id' => $user->ID, |
3265 | 'user_login' => $user->user_login, |
3266 | 'display_name' => $user->display_name, |
3267 | ); |
3268 | } |
Line | Code |
3294 | if ( ! $user ) { |
3295 | return $this->error; |
3296 | } |
3297 |
|
3298 | if ( ! current_user_can( 'edit_posts' ) ) { |
3299 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view tags.' ) ); |
3300 | } |
3301 |
|
3302 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3303 | do_action( 'xmlrpc_call', 'wp.getKeywords', $args, $this ); |
3304 |
|
3305 | $tags = array(); |
3306 |
|
3307 | $all_tags = get_tags(); |
3308 | if ( $all_tags ) { |
3309 | foreach ( (array) $all_tags as $tag ) { |
3310 | $struct = array(); |
3311 | $struct['tag_id'] = $tag->term_id; |
3312 | $struct['name'] = $tag->name; |
Line | Code |
3344 | $password = $args[2]; |
3345 | $category = $args[3]; |
3346 |
|
3347 | $user = $this->login( $username, $password ); |
3348 | if ( ! $user ) { |
3349 | return $this->error; |
3350 | } |
3351 |
|
3352 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3353 | do_action( 'xmlrpc_call', 'wp.newCategory', $args, $this ); |
3354 |
|
3355 | // Make sure the user is allowed to add a category. |
3356 | if ( ! current_user_can( 'manage_categories' ) ) { |
3357 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to add a category.' ) ); |
3358 | } |
3359 |
|
3360 | // If no slug was provided, make it empty |
3361 | // so that WordPress will generate one. |
3362 | if ( empty( $category['slug'] ) ) { |
Line | Code |
3427 | $password = $args[2]; |
3428 | $category_id = (int) $args[3]; |
3429 |
|
3430 | $user = $this->login( $username, $password ); |
3431 | if ( ! $user ) { |
3432 | return $this->error; |
3433 | } |
3434 |
|
3435 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3436 | do_action( 'xmlrpc_call', 'wp.deleteCategory', $args, $this ); |
3437 |
|
3438 | if ( ! current_user_can( 'delete_term', $category_id ) ) { |
3439 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this category.' ) ); |
3440 | } |
3441 |
|
3442 | $status = wp_delete_term( $category_id, 'category' ); |
3443 |
|
3444 | if ( true == $status ) { |
3445 | /** |
Line | Code |
3484 | if ( ! $user ) { |
3485 | return $this->error; |
3486 | } |
3487 |
|
3488 | if ( ! current_user_can( 'edit_posts' ) ) { |
3489 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
3490 | } |
3491 |
|
3492 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3493 | do_action( 'xmlrpc_call', 'wp.suggestCategories', $args, $this ); |
3494 |
|
3495 | $category_suggestions = array(); |
3496 | $args = array( |
3497 | 'get' => 'all', |
3498 | 'number' => $max_results, |
3499 | 'name__like' => $category, |
3500 | ); |
3501 | foreach ( (array) get_categories( $args ) as $cat ) { |
3502 | $category_suggestions[] = array( |
Line | Code |
3530 | $password = $args[2]; |
3531 | $comment_id = (int) $args[3]; |
3532 |
|
3533 | $user = $this->login( $username, $password ); |
3534 | if ( ! $user ) { |
3535 | return $this->error; |
3536 | } |
3537 |
|
3538 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3539 | do_action( 'xmlrpc_call', 'wp.getComment', $args, $this ); |
3540 |
|
3541 | $comment = get_comment( $comment_id ); |
3542 | if ( ! $comment ) { |
3543 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
3544 | } |
3545 |
|
3546 | if ( ! current_user_can( 'edit_comment', $comment_id ) ) { |
3547 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) ); |
3548 | } |
Line | Code |
3583 | $password = $args[2]; |
3584 | $struct = isset( $args[3] ) ? $args[3] : array(); |
3585 |
|
3586 | $user = $this->login( $username, $password ); |
3587 | if ( ! $user ) { |
3588 | return $this->error; |
3589 | } |
3590 |
|
3591 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3592 | do_action( 'xmlrpc_call', 'wp.getComments', $args, $this ); |
3593 |
|
3594 | if ( isset( $struct['status'] ) ) { |
3595 | $status = $struct['status']; |
3596 | } else { |
3597 | $status = ''; |
3598 | } |
3599 |
|
3600 | if ( ! current_user_can( 'moderate_comments' ) && 'approve' !== $status ) { |
3601 | return new IXR_Error( 401, __( 'Invalid comment status.' ) ); |
Line | Code |
3678 | if ( ! get_comment( $comment_ID ) ) { |
3679 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
3680 | } |
3681 |
|
3682 | if ( ! current_user_can( 'edit_comment', $comment_ID ) ) { |
3683 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to delete this comment.' ) ); |
3684 | } |
3685 |
|
3686 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3687 | do_action( 'xmlrpc_call', 'wp.deleteComment', $args, $this ); |
3688 |
|
3689 | $status = wp_delete_comment( $comment_ID ); |
3690 |
|
3691 | if ( $status ) { |
3692 | /** |
3693 | * Fires after a comment has been successfully deleted via XML-RPC. |
3694 | * |
3695 | * @since 3.4.0 |
3696 | * |
Line | Code |
3746 | if ( ! get_comment( $comment_ID ) ) { |
3747 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
3748 | } |
3749 |
|
3750 | if ( ! current_user_can( 'edit_comment', $comment_ID ) ) { |
3751 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) ); |
3752 | } |
3753 |
|
3754 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3755 | do_action( 'xmlrpc_call', 'wp.editComment', $args, $this ); |
3756 | $comment = array( |
3757 | 'comment_ID' => $comment_ID, |
3758 | ); |
3759 |
|
3760 | if ( isset( $content_struct['status'] ) ) { |
3761 | $statuses = get_comment_statuses(); |
3762 | $statuses = array_keys( $statuses ); |
3763 |
|
3764 | if ( ! in_array( $content_struct['status'], $statuses, true ) ) { |
Line | Code |
3939 |
|
3940 | /** This filter is documented in wp-includes/comment.php */ |
3941 | $allow_empty = apply_filters( 'allow_empty_comment', false, $comment ); |
3942 |
|
3943 | if ( ! $allow_empty && '' === $comment['comment_content'] ) { |
3944 | return new IXR_Error( 403, __( 'Comment is required.' ) ); |
3945 | } |
3946 |
|
3947 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3948 | do_action( 'xmlrpc_call', 'wp.newComment', $args, $this ); |
3949 |
|
3950 | $comment_ID = wp_new_comment( $comment, true ); |
3951 | if ( is_wp_error( $comment_ID ) ) { |
3952 | return new IXR_Error( 403, $comment_ID->get_error_message() ); |
3953 | } |
3954 |
|
3955 | if ( ! $comment_ID ) { |
3956 | return new IXR_Error( 403, __( 'Something went wrong.' ) ); |
3957 | } |
Line | Code |
3993 | if ( ! $user ) { |
3994 | return $this->error; |
3995 | } |
3996 |
|
3997 | if ( ! current_user_can( 'publish_posts' ) ) { |
3998 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) ); |
3999 | } |
4000 |
|
4001 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4002 | do_action( 'xmlrpc_call', 'wp.getCommentStatusList', $args, $this ); |
4003 |
|
4004 | return get_comment_statuses(); |
4005 | } |
4006 |
|
4007 | /** |
4008 | * Retrieve comment count. |
4009 | * |
4010 | * @since 2.5.0 |
4011 | * |
Line | Code |
4035 | if ( empty( $post['ID'] ) ) { |
4036 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
4037 | } |
4038 |
|
4039 | if ( ! current_user_can( 'edit_post', $post_id ) ) { |
4040 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details of this post.' ) ); |
4041 | } |
4042 |
|
4043 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4044 | do_action( 'xmlrpc_call', 'wp.getCommentCount', $args, $this ); |
4045 |
|
4046 | $count = wp_count_comments( $post_id ); |
4047 |
|
4048 | return array( |
4049 | 'approved' => $count->approved, |
4050 | 'awaiting_moderation' => $count->moderated, |
4051 | 'spam' => $count->spam, |
4052 | 'total_comments' => $count->total_comments, |
4053 | ); |
Line | Code |
4077 | if ( ! $user ) { |
4078 | return $this->error; |
4079 | } |
4080 |
|
4081 | if ( ! current_user_can( 'edit_posts' ) ) { |
4082 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) ); |
4083 | } |
4084 |
|
4085 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4086 | do_action( 'xmlrpc_call', 'wp.getPostStatusList', $args, $this ); |
4087 |
|
4088 | return get_post_statuses(); |
4089 | } |
4090 |
|
4091 | /** |
4092 | * Retrieve page statuses. |
4093 | * |
4094 | * @since 2.5.0 |
4095 | * |
Line | Code |
4112 | if ( ! $user ) { |
4113 | return $this->error; |
4114 | } |
4115 |
|
4116 | if ( ! current_user_can( 'edit_pages' ) ) { |
4117 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) ); |
4118 | } |
4119 |
|
4120 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4121 | do_action( 'xmlrpc_call', 'wp.getPageStatusList', $args, $this ); |
4122 |
|
4123 | return get_page_statuses(); |
4124 | } |
4125 |
|
4126 | /** |
4127 | * Retrieve page templates. |
4128 | * |
4129 | * @since 2.6.0 |
4130 | * |
Line | Code |
4305 | if ( ! $user ) { |
4306 | return $this->error; |
4307 | } |
4308 |
|
4309 | if ( ! current_user_can( 'upload_files' ) ) { |
4310 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to upload files.' ) ); |
4311 | } |
4312 |
|
4313 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4314 | do_action( 'xmlrpc_call', 'wp.getMediaItem', $args, $this ); |
4315 |
|
4316 | $attachment = get_post( $attachment_id ); |
4317 | if ( ! $attachment || 'attachment' !== $attachment->post_type ) { |
4318 | return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); |
4319 | } |
4320 |
|
4321 | return $this->_prepare_media_item( $attachment ); |
4322 | } |
4323 |
|
Line | Code |
4358 | if ( ! $user ) { |
4359 | return $this->error; |
4360 | } |
4361 |
|
4362 | if ( ! current_user_can( 'upload_files' ) ) { |
4363 | return new IXR_Error( 401, __( '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.getMediaLibrary', $args, $this ); |
4368 |
|
4369 | $parent_id = ( isset( $struct['parent_id'] ) ) ? absint( $struct['parent_id'] ) : ''; |
4370 | $mime_type = ( isset( $struct['mime_type'] ) ) ? $struct['mime_type'] : ''; |
4371 | $offset = ( isset( $struct['offset'] ) ) ? absint( $struct['offset'] ) : 0; |
4372 | $number = ( isset( $struct['number'] ) ) ? absint( $struct['number'] ) : -1; |
4373 |
|
4374 | $attachments = get_posts( |
4375 | array( |
4376 | 'post_type' => 'attachment', |
Line | Code |
4414 | if ( ! $user ) { |
4415 | return $this->error; |
4416 | } |
4417 |
|
4418 | if ( ! current_user_can( 'edit_posts' ) ) { |
4419 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) ); |
4420 | } |
4421 |
|
4422 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4423 | do_action( 'xmlrpc_call', 'wp.getPostFormats', $args, $this ); |
4424 |
|
4425 | $formats = get_post_format_strings(); |
4426 |
|
4427 | // Find out if they want a list of currently supports formats. |
4428 | if ( isset( $args[3] ) && is_array( $args[3] ) ) { |
4429 | if ( $args[3]['show-supported'] ) { |
4430 | if ( current_theme_supports( 'post-formats' ) ) { |
4431 | $supported = get_theme_support( 'post-formats' ); |
4432 |
|
Line | Code |
4494 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostType' ); |
4495 | } |
4496 |
|
4497 | $user = $this->login( $username, $password ); |
4498 | if ( ! $user ) { |
4499 | return $this->error; |
4500 | } |
4501 |
|
4502 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4503 | do_action( 'xmlrpc_call', 'wp.getPostType', $args, $this ); |
4504 |
|
4505 | if ( ! post_type_exists( $post_type_name ) ) { |
4506 | return new IXR_Error( 403, __( 'Invalid post type.' ) ); |
4507 | } |
4508 |
|
4509 | $post_type = get_post_type_object( $post_type_name ); |
4510 |
|
4511 | if ( ! current_user_can( $post_type->cap->edit_posts ) ) { |
4512 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts in this post type.' ) ); |
Line | Code |
4551 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostTypes' ); |
4552 | } |
4553 |
|
4554 | $user = $this->login( $username, $password ); |
4555 | if ( ! $user ) { |
4556 | return $this->error; |
4557 | } |
4558 |
|
4559 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4560 | do_action( 'xmlrpc_call', 'wp.getPostTypes', $args, $this ); |
4561 |
|
4562 | $post_types = get_post_types( $filter, 'objects' ); |
4563 |
|
4564 | $struct = array(); |
4565 |
|
4566 | foreach ( $post_types as $post_type ) { |
4567 | if ( ! current_user_can( $post_type->cap->edit_posts ) ) { |
4568 | continue; |
4569 | } |
Line | Code |
4621 | $fields = apply_filters( 'xmlrpc_default_revision_fields', array( 'post_date', 'post_date_gmt' ), 'wp.getRevisions' ); |
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.getRevisions', $args, $this ); |
4631 |
|
4632 | $post = get_post( $post_id ); |
4633 | if ( ! $post ) { |
4634 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
4635 | } |
4636 |
|
4637 | if ( ! current_user_can( 'edit_post', $post_id ) ) { |
4638 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
4639 | } |
Line | Code |
4695 | $password = $args[2]; |
4696 | $revision_id = (int) $args[3]; |
4697 |
|
4698 | $user = $this->login( $username, $password ); |
4699 | if ( ! $user ) { |
4700 | return $this->error; |
4701 | } |
4702 |
|
4703 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4704 | do_action( 'xmlrpc_call', 'wp.restoreRevision', $args, $this ); |
4705 |
|
4706 | $revision = wp_get_post_revision( $revision_id ); |
4707 | if ( ! $revision ) { |
4708 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
4709 | } |
4710 |
|
4711 | if ( wp_is_post_autosave( $revision ) ) { |
4712 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
4713 | } |
Line | Code |
4766 | $username = $args[1]; |
4767 | $password = $args[2]; |
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', 'blogger.getUsersBlogs', $args, $this ); |
4776 |
|
4777 | $is_admin = current_user_can( 'manage_options' ); |
4778 |
|
4779 | $struct = array( |
4780 | 'isAdmin' => $is_admin, |
4781 | 'url' => get_option( 'home' ) . '/', |
4782 | 'blogid' => '1', |
4783 | 'blogName' => get_option( 'blogname' ), |
4784 | 'xmlrpc' => site_url( 'xmlrpc.php', 'rpc' ), |
Line | Code |
4852 | if ( ! $user ) { |
4853 | return $this->error; |
4854 | } |
4855 |
|
4856 | if ( ! current_user_can( 'edit_posts' ) ) { |
4857 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to access user data on this site.' ) ); |
4858 | } |
4859 |
|
4860 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4861 | do_action( 'xmlrpc_call', 'blogger.getUserInfo', $args, $this ); |
4862 |
|
4863 | $struct = array( |
4864 | 'nickname' => $user->nickname, |
4865 | 'userid' => $user->ID, |
4866 | 'url' => $user->user_url, |
4867 | 'lastname' => $user->last_name, |
4868 | 'firstname' => $user->first_name, |
4869 | ); |
4870 |
|
Line | Code |
4902 | if ( ! $post_data ) { |
4903 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
4904 | } |
4905 |
|
4906 | if ( ! current_user_can( 'edit_post', $post_ID ) ) { |
4907 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
4908 | } |
4909 |
|
4910 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4911 | do_action( 'xmlrpc_call', 'blogger.getPost', $args, $this ); |
4912 |
|
4913 | $categories = implode( ',', wp_get_post_categories( $post_ID ) ); |
4914 |
|
4915 | $content = '<title>' . wp_unslash( $post_data['post_title'] ) . '</title>'; |
4916 | $content .= '<category>' . $categories . '</category>'; |
4917 | $content .= wp_unslash( $post_data['post_content'] ); |
4918 |
|
4919 | $struct = array( |
4920 | 'userid' => $post_data['post_author'], |
Line | Code |
4959 | if ( ! $user ) { |
4960 | return $this->error; |
4961 | } |
4962 |
|
4963 | if ( ! current_user_can( 'edit_posts' ) ) { |
4964 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
4965 | } |
4966 |
|
4967 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4968 | do_action( 'xmlrpc_call', 'blogger.getRecentPosts', $args, $this ); |
4969 |
|
4970 | $posts_list = wp_get_recent_posts( $query ); |
4971 |
|
4972 | if ( ! $posts_list ) { |
4973 | $this->error = new IXR_Error( 500, __( 'Either there are no posts, or something went wrong.' ) ); |
4974 | return $this->error; |
4975 | } |
4976 |
|
4977 | $recent_posts = array(); |
Line | Code |
5049 | $content = $args[4]; |
5050 | $publish = $args[5]; |
5051 |
|
5052 | $user = $this->login( $username, $password ); |
5053 | if ( ! $user ) { |
5054 | return $this->error; |
5055 | } |
5056 |
|
5057 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5058 | do_action( 'xmlrpc_call', 'blogger.newPost', $args, $this ); |
5059 |
|
5060 | $cap = ( $publish ) ? 'publish_posts' : 'edit_posts'; |
5061 | if ( ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) || ! current_user_can( $cap ) ) { |
5062 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to post on this site.' ) ); |
5063 | } |
5064 |
|
5065 | $post_status = ( $publish ) ? 'publish' : 'draft'; |
5066 |
|
5067 | $post_author = $user->ID; |
Line | Code |
5126 | $content = $args[4]; |
5127 | $publish = $args[5]; |
5128 |
|
5129 | $user = $this->login( $username, $password ); |
5130 | if ( ! $user ) { |
5131 | return $this->error; |
5132 | } |
5133 |
|
5134 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5135 | do_action( 'xmlrpc_call', 'blogger.editPost', $args, $this ); |
5136 |
|
5137 | $actual_post = get_post( $post_ID, ARRAY_A ); |
5138 |
|
5139 | if ( ! $actual_post || 'post' !== $actual_post['post_type'] ) { |
5140 | return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); |
5141 | } |
5142 |
|
5143 | $this->escape( $actual_post ); |
5144 |
|
Line | Code |
5200 | $username = $args[2]; |
5201 | $password = $args[3]; |
5202 |
|
5203 | $user = $this->login( $username, $password ); |
5204 | if ( ! $user ) { |
5205 | return $this->error; |
5206 | } |
5207 |
|
5208 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5209 | do_action( 'xmlrpc_call', 'blogger.deletePost', $args, $this ); |
5210 |
|
5211 | $actual_post = get_post( $post_ID, ARRAY_A ); |
5212 |
|
5213 | if ( ! $actual_post || 'post' !== $actual_post['post_type'] ) { |
5214 | return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); |
5215 | } |
5216 |
|
5217 | if ( ! current_user_can( 'delete_post', $post_ID ) ) { |
5218 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) ); |
Line | Code |
5288 | $content_struct = $args[3]; |
5289 | $publish = isset( $args[4] ) ? $args[4] : 0; |
5290 |
|
5291 | $user = $this->login( $username, $password ); |
5292 | if ( ! $user ) { |
5293 | return $this->error; |
5294 | } |
5295 |
|
5296 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5297 | do_action( 'xmlrpc_call', 'metaWeblog.newPost', $args, $this ); |
5298 |
|
5299 | $page_template = ''; |
5300 | if ( ! empty( $content_struct['post_type'] ) ) { |
5301 | if ( 'page' === $content_struct['post_type'] ) { |
5302 | if ( $publish ) { |
5303 | $cap = 'publish_pages'; |
5304 | } elseif ( isset( $content_struct['page_status'] ) && 'publish' === $content_struct['page_status'] ) { |
5305 | $cap = 'publish_pages'; |
5306 | } else { |
Line | Code |
5667 | $content_struct = $args[3]; |
5668 | $publish = isset( $args[4] ) ? $args[4] : 0; |
5669 |
|
5670 | $user = $this->login( $username, $password ); |
5671 | if ( ! $user ) { |
5672 | return $this->error; |
5673 | } |
5674 |
|
5675 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5676 | do_action( 'xmlrpc_call', 'metaWeblog.editPost', $args, $this ); |
5677 |
|
5678 | $postdata = get_post( $post_ID, ARRAY_A ); |
5679 |
|
5680 | /* |
5681 | * If there is no post data for the give post ID, stop now and return an error. |
5682 | * Otherwise a new post will be created (which was the old behavior). |
5683 | */ |
5684 | if ( ! $postdata || empty( $postdata['ID'] ) ) { |
5685 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
Line | Code |
6005 | if ( ! $postdata ) { |
6006 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
6007 | } |
6008 |
|
6009 | if ( ! current_user_can( 'edit_post', $post_ID ) ) { |
6010 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
6011 | } |
6012 |
|
6013 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6014 | do_action( 'xmlrpc_call', 'metaWeblog.getPost', $args, $this ); |
6015 |
|
6016 | if ( '' !== $postdata['post_date'] ) { |
6017 | $post_date = $this->_convert_date( $postdata['post_date'] ); |
6018 | $post_date_gmt = $this->_convert_date_gmt( $postdata['post_date_gmt'], $postdata['post_date'] ); |
6019 | $post_modified = $this->_convert_date( $postdata['post_modified'] ); |
6020 | $post_modified_gmt = $this->_convert_date_gmt( $postdata['post_modified_gmt'], $postdata['post_modified'] ); |
6021 |
|
6022 | $categories = array(); |
6023 | $catids = wp_get_post_categories( $post_ID ); |
Line | Code |
6146 | if ( ! $user ) { |
6147 | return $this->error; |
6148 | } |
6149 |
|
6150 | if ( ! current_user_can( 'edit_posts' ) ) { |
6151 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
6152 | } |
6153 |
|
6154 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6155 | do_action( 'xmlrpc_call', 'metaWeblog.getRecentPosts', $args, $this ); |
6156 |
|
6157 | $posts_list = wp_get_recent_posts( $query ); |
6158 |
|
6159 | if ( ! $posts_list ) { |
6160 | return array(); |
6161 | } |
6162 |
|
6163 | $recent_posts = array(); |
6164 | foreach ( $posts_list as $entry ) { |
Line | Code |
6267 | if ( ! $user ) { |
6268 | return $this->error; |
6269 | } |
6270 |
|
6271 | if ( ! current_user_can( 'edit_posts' ) ) { |
6272 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
6273 | } |
6274 |
|
6275 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6276 | do_action( 'xmlrpc_call', 'metaWeblog.getCategories', $args, $this ); |
6277 |
|
6278 | $categories_struct = array(); |
6279 |
|
6280 | $cats = get_categories( array( 'get' => 'all' ) ); |
6281 | if ( $cats ) { |
6282 | foreach ( $cats as $cat ) { |
6283 | $struct = array(); |
6284 | $struct['categoryId'] = $cat->term_id; |
6285 | $struct['parentId'] = $cat->parent; |
Line | Code |
6328 | $type = $data['type']; |
6329 | $bits = $data['bits']; |
6330 |
|
6331 | $user = $this->login( $username, $password ); |
6332 | if ( ! $user ) { |
6333 | return $this->error; |
6334 | } |
6335 |
|
6336 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6337 | do_action( 'xmlrpc_call', 'metaWeblog.newMediaObject', $args, $this ); |
6338 |
|
6339 | if ( ! current_user_can( 'upload_files' ) ) { |
6340 | $this->error = new IXR_Error( 401, __( 'Sorry, you are not allowed to upload files.' ) ); |
6341 | return $this->error; |
6342 | } |
6343 |
|
6344 | if ( is_multisite() && upload_is_user_over_quota( false ) ) { |
6345 | $this->error = new IXR_Error( |
6346 | 401, |
Line | Code |
6447 | $query = array(); |
6448 | } |
6449 |
|
6450 | $user = $this->login( $username, $password ); |
6451 | if ( ! $user ) { |
6452 | return $this->error; |
6453 | } |
6454 |
|
6455 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6456 | do_action( 'xmlrpc_call', 'mt.getRecentPostTitles', $args, $this ); |
6457 |
|
6458 | $posts_list = wp_get_recent_posts( $query ); |
6459 |
|
6460 | if ( ! $posts_list ) { |
6461 | $this->error = new IXR_Error( 500, __( 'Either there are no posts, or something went wrong.' ) ); |
6462 | return $this->error; |
6463 | } |
6464 |
|
6465 | $recent_posts = array(); |
Line | Code |
6509 | if ( ! $user ) { |
6510 | return $this->error; |
6511 | } |
6512 |
|
6513 | if ( ! current_user_can( 'edit_posts' ) ) { |
6514 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
6515 | } |
6516 |
|
6517 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6518 | do_action( 'xmlrpc_call', 'mt.getCategoryList', $args, $this ); |
6519 |
|
6520 | $categories_struct = array(); |
6521 |
|
6522 | $cats = get_categories( |
6523 | array( |
6524 | 'hide_empty' => 0, |
6525 | 'hierarchical' => 0, |
6526 | ) |
6527 | ); |
Line | Code |
6567 | if ( ! get_post( $post_ID ) ) { |
6568 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
6569 | } |
6570 |
|
6571 | if ( ! current_user_can( 'edit_post', $post_ID ) ) { |
6572 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
6573 | } |
6574 |
|
6575 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6576 | do_action( 'xmlrpc_call', 'mt.getPostCategories', $args, $this ); |
6577 |
|
6578 | $categories = array(); |
6579 | $catids = wp_get_post_categories( (int) $post_ID ); |
6580 | // First listed category will be the primary category. |
6581 | $isPrimary = true; |
6582 | foreach ( $catids as $catid ) { |
6583 | $categories[] = array( |
6584 | 'categoryName' => get_cat_name( $catid ), |
6585 | 'categoryId' => (string) $catid, |
Line | Code |
6614 | $password = $args[2]; |
6615 | $categories = $args[3]; |
6616 |
|
6617 | $user = $this->login( $username, $password ); |
6618 | if ( ! $user ) { |
6619 | return $this->error; |
6620 | } |
6621 |
|
6622 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6623 | do_action( 'xmlrpc_call', 'mt.setPostCategories', $args, $this ); |
6624 |
|
6625 | if ( ! get_post( $post_ID ) ) { |
6626 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
6627 | } |
6628 |
|
6629 | if ( ! current_user_can( 'edit_post', $post_ID ) ) { |
6630 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
6631 | } |
6632 |
|
Line | Code |
6643 | /** |
6644 | * Retrieve an array of methods supported by this server. |
6645 | * |
6646 | * @since 1.5.0 |
6647 | * |
6648 | * @return array |
6649 | */ |
6650 | public function mt_supportedMethods() { |
6651 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6652 | do_action( 'xmlrpc_call', 'mt.supportedMethods', array(), $this ); |
6653 |
|
6654 | return array_keys( $this->methods ); |
6655 | } |
6656 |
|
6657 | /** |
6658 | * Retrieve an empty array because we don't support per-post text filters. |
6659 | * |
6660 | * @since 1.5.0 |
6661 | */ |
6662 | public function mt_supportedTextFilters() { |
6663 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6664 | do_action( 'xmlrpc_call', 'mt.supportedTextFilters', array(), $this ); |
6665 |
|
6666 | /** |
6667 | * Filters the MoveableType text filters list for XML-RPC. |
6668 | * |
6669 | * @since 2.2.0 |
6670 | * |
6671 | * @param array $filters An array of text filters. |
6672 | */ |
6673 | return apply_filters( 'xmlrpc_text_filters', array() ); |
Line | Code |
6681 | * @global wpdb $wpdb WordPress database abstraction object. |
6682 | * |
6683 | * @param int $post_ID |
6684 | * @return array|IXR_Error |
6685 | */ |
6686 | public function mt_getTrackbackPings( $post_ID ) { |
6687 | global $wpdb; |
6688 |
|
6689 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6690 | do_action( 'xmlrpc_call', 'mt.getTrackbackPings', $post_ID, $this ); |
6691 |
|
6692 | $actual_post = get_post( $post_ID, ARRAY_A ); |
6693 |
|
6694 | if ( ! $actual_post ) { |
6695 | return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); |
6696 | } |
6697 |
|
6698 | $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 ) ); |
6699 |
|
Line | Code |
6738 | $username = $args[1]; |
6739 | $password = $args[2]; |
6740 |
|
6741 | $user = $this->login( $username, $password ); |
6742 | if ( ! $user ) { |
6743 | return $this->error; |
6744 | } |
6745 |
|
6746 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6747 | do_action( 'xmlrpc_call', 'mt.publishPost', $args, $this ); |
6748 |
|
6749 | $postdata = get_post( $post_ID, ARRAY_A ); |
6750 | if ( ! $postdata ) { |
6751 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
6752 | } |
6753 |
|
6754 | if ( ! current_user_can( 'publish_posts' ) || ! current_user_can( 'edit_post', $post_ID ) ) { |
6755 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish this post.' ) ); |
6756 | } |
Line | Code |
6780 | * @type string $pagelinkedfrom |
6781 | * @type string $pagelinkedto |
6782 | * } |
6783 | * @return string|IXR_Error |
6784 | */ |
6785 | public function pingback_ping( $args ) { |
6786 | global $wpdb; |
6787 |
|
6788 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6789 | do_action( 'xmlrpc_call', 'pingback.ping', $args, $this ); |
6790 |
|
6791 | $this->escape( $args ); |
6792 |
|
6793 | $pagelinkedfrom = str_replace( '&', '&', $args[0] ); |
6794 | $pagelinkedto = str_replace( '&', '&', $args[1] ); |
6795 | $pagelinkedto = str_replace( '&', '&', $pagelinkedto ); |
6796 |
|
6797 | /** |
6798 | * Filters the pingback source URI. |
Line | Code |
7019 | * @global wpdb $wpdb WordPress database abstraction object. |
7020 | * |
7021 | * @param string $url |
7022 | * @return array|IXR_Error |
7023 | */ |
7024 | public function pingback_extensions_getPingbacks( $url ) { |
7025 | global $wpdb; |
7026 |
|
7027 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
7028 | do_action( 'xmlrpc_call', 'pingback.extensions.getPingbacks', $url, $this ); |
7029 |
|
7030 | $url = $this->escape( $url ); |
7031 |
|
7032 | $post_ID = url_to_postid( $url ); |
7033 | if ( ! $post_ID ) { |
7034 | // We aren't sure that the resource is available and/or pingback enabled. |
7035 | return $this->pingback_error( 33, __( 'The specified target URL cannot be used as a target. It either doesn’t exist, or it is not a pingback-enabled resource.' ) ); |
7036 | } |
7037 |
|