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 |
---|---|
678 | * the method logic begins. |
679 | * |
680 | * All built-in XML-RPC methods use the action xmlrpc_call, with a parameter |
681 | * equal to the method's name, e.g., wp.getUsersBlogs, wp.newPost, etc. |
682 | * |
683 | * @since 2.5.0 |
684 | * |
685 | * @param string $name The method name. |
686 | */ |
687 | do_action( 'xmlrpc_call', 'wp.getUsersBlogs' ); |
688 |
|
689 | $blogs = (array) get_blogs_of_user( $user->ID ); |
690 | $struct = array(); |
691 | $primary_blog_id = 0; |
692 | $active_blog = get_active_blog_for_user( $user->ID ); |
693 | if ( $active_blog ) { |
694 | $primary_blog_id = (int) $active_blog->blog_id; |
695 | } |
696 |
|
Line | Code |
1286 | if ( isset( $content_struct['post_date_gmt'] ) && ! ( $content_struct['post_date_gmt'] instanceof IXR_Date ) ) { |
1287 | if ( $content_struct['post_date_gmt'] == '0000-00-00 00:00:00' || isset( $content_struct['post_date'] ) ) { |
1288 | unset( $content_struct['post_date_gmt'] ); |
1289 | } else { |
1290 | $content_struct['post_date_gmt'] = $this->_convert_date( $content_struct['post_date_gmt'] ); |
1291 | } |
1292 | } |
1293 |
|
1294 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
1295 | do_action( 'xmlrpc_call', 'wp.newPost' ); |
1296 |
|
1297 | unset( $content_struct['ID'] ); |
1298 |
|
1299 | return $this->_insert_post( $user, $content_struct ); |
1300 | } |
1301 |
|
1302 | /** |
1303 | * Helper method for filtering out elements from an array. |
1304 | * |
Line | Code |
1674 | $post_id = (int) $args[3]; |
1675 | $content_struct = $args[4]; |
1676 |
|
1677 | $user = $this->login( $username, $password ); |
1678 | if ( ! $user ) { |
1679 | return $this->error; |
1680 | } |
1681 |
|
1682 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
1683 | do_action( 'xmlrpc_call', 'wp.editPost' ); |
1684 |
|
1685 | $post = get_post( $post_id, ARRAY_A ); |
1686 |
|
1687 | if ( empty( $post['ID'] ) ) { |
1688 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
1689 | } |
1690 |
|
1691 | if ( isset( $content_struct['if_not_modified_since'] ) ) { |
1692 | // If the post has been modified since the date provided, return an error. |
Line | Code |
1757 | $password = $args[2]; |
1758 | $post_id = (int) $args[3]; |
1759 |
|
1760 | $user = $this->login( $username, $password ); |
1761 | if ( ! $user ) { |
1762 | return $this->error; |
1763 | } |
1764 |
|
1765 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
1766 | do_action( 'xmlrpc_call', 'wp.deletePost' ); |
1767 |
|
1768 | $post = get_post( $post_id, ARRAY_A ); |
1769 | if ( empty( $post['ID'] ) ) { |
1770 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
1771 | } |
1772 |
|
1773 | if ( ! current_user_can( 'delete_post', $post_id ) ) { |
1774 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) ); |
1775 | } |
Line | Code |
1857 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPost' ); |
1858 | } |
1859 |
|
1860 | $user = $this->login( $username, $password ); |
1861 | if ( ! $user ) { |
1862 | return $this->error; |
1863 | } |
1864 |
|
1865 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
1866 | do_action( 'xmlrpc_call', 'wp.getPost' ); |
1867 |
|
1868 | $post = get_post( $post_id, ARRAY_A ); |
1869 |
|
1870 | if ( empty( $post['ID'] ) ) { |
1871 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
1872 | } |
1873 |
|
1874 | if ( ! current_user_can( 'edit_post', $post_id ) ) { |
1875 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
Line | Code |
1918 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPosts' ); |
1919 | } |
1920 |
|
1921 | $user = $this->login( $username, $password ); |
1922 | if ( ! $user ) { |
1923 | return $this->error; |
1924 | } |
1925 |
|
1926 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
1927 | do_action( 'xmlrpc_call', 'wp.getPosts' ); |
1928 |
|
1929 | $query = array(); |
1930 |
|
1931 | if ( isset( $filter['post_type'] ) ) { |
1932 | $post_type = get_post_type_object( $filter['post_type'] ); |
1933 | if ( ! ( (bool) $post_type ) ) { |
1934 | return new IXR_Error( 403, __( 'Invalid post type.' ) ); |
1935 | } |
1936 | } else { |
Line | Code |
2017 | $password = $args[2]; |
2018 | $content_struct = $args[3]; |
2019 |
|
2020 | $user = $this->login( $username, $password ); |
2021 | if ( ! $user ) { |
2022 | return $this->error; |
2023 | } |
2024 |
|
2025 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2026 | do_action( 'xmlrpc_call', 'wp.newTerm' ); |
2027 |
|
2028 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) { |
2029 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
2030 | } |
2031 |
|
2032 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
2033 |
|
2034 | if ( ! current_user_can( $taxonomy->cap->edit_terms ) ) { |
2035 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to create terms in this taxonomy.' ) ); |
Line | Code |
2122 | $term_id = (int) $args[3]; |
2123 | $content_struct = $args[4]; |
2124 |
|
2125 | $user = $this->login( $username, $password ); |
2126 | if ( ! $user ) { |
2127 | return $this->error; |
2128 | } |
2129 |
|
2130 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2131 | do_action( 'xmlrpc_call', 'wp.editTerm' ); |
2132 |
|
2133 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) { |
2134 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
2135 | } |
2136 |
|
2137 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
2138 |
|
2139 | $taxonomy = (array) $taxonomy; |
2140 |
|
Line | Code |
2238 | $taxonomy = $args[3]; |
2239 | $term_id = (int) $args[4]; |
2240 |
|
2241 | $user = $this->login( $username, $password ); |
2242 | if ( ! $user ) { |
2243 | return $this->error; |
2244 | } |
2245 |
|
2246 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2247 | do_action( 'xmlrpc_call', 'wp.deleteTerm' ); |
2248 |
|
2249 | if ( ! taxonomy_exists( $taxonomy ) ) { |
2250 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
2251 | } |
2252 |
|
2253 | $taxonomy = get_taxonomy( $taxonomy ); |
2254 | $term = get_term( $term_id, $taxonomy->name ); |
2255 |
|
2256 | if ( is_wp_error( $term ) ) { |
Line | Code |
2317 | $taxonomy = $args[3]; |
2318 | $term_id = (int) $args[4]; |
2319 |
|
2320 | $user = $this->login( $username, $password ); |
2321 | if ( ! $user ) { |
2322 | return $this->error; |
2323 | } |
2324 |
|
2325 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2326 | do_action( 'xmlrpc_call', 'wp.getTerm' ); |
2327 |
|
2328 | if ( ! taxonomy_exists( $taxonomy ) ) { |
2329 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
2330 | } |
2331 |
|
2332 | $taxonomy = get_taxonomy( $taxonomy ); |
2333 |
|
2334 | $term = get_term( $term_id, $taxonomy->name, ARRAY_A ); |
2335 |
|
Line | Code |
2382 | $taxonomy = $args[3]; |
2383 | $filter = isset( $args[4] ) ? $args[4] : array(); |
2384 |
|
2385 | $user = $this->login( $username, $password ); |
2386 | if ( ! $user ) { |
2387 | return $this->error; |
2388 | } |
2389 |
|
2390 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2391 | do_action( 'xmlrpc_call', 'wp.getTerms' ); |
2392 |
|
2393 | if ( ! taxonomy_exists( $taxonomy ) ) { |
2394 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
2395 | } |
2396 |
|
2397 | $taxonomy = get_taxonomy( $taxonomy ); |
2398 |
|
2399 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) { |
2400 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ) ); |
Line | Code |
2488 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomy' ); |
2489 | } |
2490 |
|
2491 | $user = $this->login( $username, $password ); |
2492 | if ( ! $user ) { |
2493 | return $this->error; |
2494 | } |
2495 |
|
2496 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2497 | do_action( 'xmlrpc_call', 'wp.getTaxonomy' ); |
2498 |
|
2499 | if ( ! taxonomy_exists( $taxonomy ) ) { |
2500 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
2501 | } |
2502 |
|
2503 | $taxonomy = get_taxonomy( $taxonomy ); |
2504 |
|
2505 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) { |
2506 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ) ); |
Line | Code |
2546 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomies' ); |
2547 | } |
2548 |
|
2549 | $user = $this->login( $username, $password ); |
2550 | if ( ! $user ) { |
2551 | return $this->error; |
2552 | } |
2553 |
|
2554 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2555 | do_action( 'xmlrpc_call', 'wp.getTaxonomies' ); |
2556 |
|
2557 | $taxonomies = get_taxonomies( $filter, 'objects' ); |
2558 |
|
2559 | // holds all the taxonomy data |
2560 | $struct = array(); |
2561 |
|
2562 | foreach ( $taxonomies as $taxonomy ) { |
2563 | // capability check for post_types |
2564 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) { |
Line | Code |
2632 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUser' ); |
2633 | } |
2634 |
|
2635 | $user = $this->login( $username, $password ); |
2636 | if ( ! $user ) { |
2637 | return $this->error; |
2638 | } |
2639 |
|
2640 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2641 | do_action( 'xmlrpc_call', 'wp.getUser' ); |
2642 |
|
2643 | if ( ! current_user_can( 'edit_user', $user_id ) ) { |
2644 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this user.' ) ); |
2645 | } |
2646 |
|
2647 | $user_data = get_userdata( $user_id ); |
2648 |
|
2649 | if ( ! $user_data ) { |
2650 | return new IXR_Error( 404, __( 'Invalid user ID.' ) ); |
Line | Code |
2695 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUsers' ); |
2696 | } |
2697 |
|
2698 | $user = $this->login( $username, $password ); |
2699 | if ( ! $user ) { |
2700 | return $this->error; |
2701 | } |
2702 |
|
2703 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2704 | do_action( 'xmlrpc_call', 'wp.getUsers' ); |
2705 |
|
2706 | if ( ! current_user_can( 'list_users' ) ) { |
2707 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to list users.' ) ); |
2708 | } |
2709 |
|
2710 | $query = array( 'fields' => 'all_with_meta' ); |
2711 |
|
2712 | $query['number'] = ( isset( $filter['number'] ) ) ? absint( $filter['number'] ) : 50; |
2713 | $query['offset'] = ( isset( $filter['offset'] ) ) ? absint( $filter['offset'] ) : 0; |
Line | Code |
2775 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getProfile' ); |
2776 | } |
2777 |
|
2778 | $user = $this->login( $username, $password ); |
2779 | if ( ! $user ) { |
2780 | return $this->error; |
2781 | } |
2782 |
|
2783 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2784 | do_action( 'xmlrpc_call', 'wp.getProfile' ); |
2785 |
|
2786 | if ( ! current_user_can( 'edit_user', $user->ID ) ) { |
2787 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit your profile.' ) ); |
2788 | } |
2789 |
|
2790 | $user_data = get_userdata( $user->ID ); |
2791 |
|
2792 | return $this->_prepare_user( $user_data, $fields ); |
2793 | } |
Line | Code |
2825 | $password = $args[2]; |
2826 | $content_struct = $args[3]; |
2827 |
|
2828 | $user = $this->login( $username, $password ); |
2829 | if ( ! $user ) { |
2830 | return $this->error; |
2831 | } |
2832 |
|
2833 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2834 | do_action( 'xmlrpc_call', 'wp.editProfile' ); |
2835 |
|
2836 | if ( ! current_user_can( 'edit_user', $user->ID ) ) { |
2837 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit your profile.' ) ); |
2838 | } |
2839 |
|
2840 | // holds data of the user |
2841 | $user_data = array(); |
2842 | $user_data['ID'] = $user->ID; |
2843 |
|
Line | Code |
2914 | if ( ! $page ) { |
2915 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
2916 | } |
2917 |
|
2918 | if ( ! current_user_can( 'edit_page', $page_id ) ) { |
2919 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this page.' ) ); |
2920 | } |
2921 |
|
2922 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2923 | do_action( 'xmlrpc_call', 'wp.getPage' ); |
2924 |
|
2925 | // If we found the page then format the data. |
2926 | if ( $page->ID && ( $page->post_type == 'page' ) ) { |
2927 | return $this->_prepare_page( $page ); |
2928 | } else { |
2929 | // If the page doesn't exist indicate that. |
2930 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
2931 | } |
2932 | } |
Line | Code |
2957 | if ( ! $user ) { |
2958 | return $this->error; |
2959 | } |
2960 |
|
2961 | if ( ! current_user_can( 'edit_pages' ) ) { |
2962 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit pages.' ) ); |
2963 | } |
2964 |
|
2965 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2966 | do_action( 'xmlrpc_call', 'wp.getPages' ); |
2967 |
|
2968 | $pages = get_posts( |
2969 | array( |
2970 | 'post_type' => 'page', |
2971 | 'post_status' => 'any', |
2972 | 'numberposts' => $num_pages, |
2973 | ) |
2974 | ); |
2975 | $num_pages = count( $pages ); |
Line | Code |
3012 | $username = $this->escape( $args[1] ); |
3013 | $password = $this->escape( $args[2] ); |
3014 |
|
3015 | $user = $this->login( $username, $password ); |
3016 | if ( ! $user ) { |
3017 | return $this->error; |
3018 | } |
3019 |
|
3020 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3021 | do_action( 'xmlrpc_call', 'wp.newPage' ); |
3022 |
|
3023 | // Mark this as content for a page. |
3024 | $args[3]['post_type'] = 'page'; |
3025 |
|
3026 | // Let mw_newPost do all of the heavy lifting. |
3027 | return $this->mw_newPost( $args ); |
3028 | } |
3029 |
|
3030 | /** |
Line | Code |
3049 | $password = $args[2]; |
3050 | $page_id = (int) $args[3]; |
3051 |
|
3052 | $user = $this->login( $username, $password ); |
3053 | if ( ! $user ) { |
3054 | return $this->error; |
3055 | } |
3056 |
|
3057 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3058 | do_action( 'xmlrpc_call', 'wp.deletePage' ); |
3059 |
|
3060 | // Get the current page based on the page_id and |
3061 | // make sure it is a page and not a post. |
3062 | $actual_page = get_post( $page_id, ARRAY_A ); |
3063 | if ( ! $actual_page || ( $actual_page['post_type'] != 'page' ) ) { |
3064 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
3065 | } |
3066 |
|
3067 | // Make sure the user can delete pages. |
Line | Code |
3116 | $escaped_username = $this->escape( $username ); |
3117 | $escaped_password = $this->escape( $password ); |
3118 |
|
3119 | $user = $this->login( $escaped_username, $escaped_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.editPage' ); |
3126 |
|
3127 | // Get the page data and make sure it is a page. |
3128 | $actual_page = get_post( $page_id, ARRAY_A ); |
3129 | if ( ! $actual_page || ( $actual_page['post_type'] != 'page' ) ) { |
3130 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
3131 | } |
3132 |
|
3133 | // Make sure the user is allowed to edit pages. |
3134 | if ( ! current_user_can( 'edit_page', $page_id ) ) { |
Line | Code |
3179 | if ( ! $user ) { |
3180 | return $this->error; |
3181 | } |
3182 |
|
3183 | if ( ! current_user_can( 'edit_pages' ) ) { |
3184 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit pages.' ) ); |
3185 | } |
3186 |
|
3187 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3188 | do_action( 'xmlrpc_call', 'wp.getPageList' ); |
3189 |
|
3190 | // Get list of pages ids and titles |
3191 | $page_list = $wpdb->get_results( |
3192 | " |
3193 | SELECT ID page_id, |
3194 | post_title page_title, |
3195 | post_parent page_parent_id, |
3196 | post_date_gmt, |
3197 | post_date, |
Line | Code |
3240 | if ( ! $user ) { |
3241 | return $this->error; |
3242 | } |
3243 |
|
3244 | if ( ! current_user_can( 'edit_posts' ) ) { |
3245 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
3246 | } |
3247 |
|
3248 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3249 | do_action( 'xmlrpc_call', 'wp.getAuthors' ); |
3250 |
|
3251 | $authors = array(); |
3252 | foreach ( get_users( array( 'fields' => array( 'ID', 'user_login', 'display_name' ) ) ) as $user ) { |
3253 | $authors[] = array( |
3254 | 'user_id' => $user->ID, |
3255 | 'user_login' => $user->user_login, |
3256 | 'display_name' => $user->display_name, |
3257 | ); |
3258 | } |
Line | Code |
3284 | if ( ! $user ) { |
3285 | return $this->error; |
3286 | } |
3287 |
|
3288 | if ( ! current_user_can( 'edit_posts' ) ) { |
3289 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view tags.' ) ); |
3290 | } |
3291 |
|
3292 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3293 | do_action( 'xmlrpc_call', 'wp.getKeywords' ); |
3294 |
|
3295 | $tags = array(); |
3296 |
|
3297 | $all_tags = get_tags(); |
3298 | if ( $all_tags ) { |
3299 | foreach ( (array) $all_tags as $tag ) { |
3300 | $struct = array(); |
3301 | $struct['tag_id'] = $tag->term_id; |
3302 | $struct['name'] = $tag->name; |
Line | Code |
3334 | $password = $args[2]; |
3335 | $category = $args[3]; |
3336 |
|
3337 | $user = $this->login( $username, $password ); |
3338 | if ( ! $user ) { |
3339 | return $this->error; |
3340 | } |
3341 |
|
3342 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3343 | do_action( 'xmlrpc_call', 'wp.newCategory' ); |
3344 |
|
3345 | // Make sure the user is allowed to add a category. |
3346 | if ( ! current_user_can( 'manage_categories' ) ) { |
3347 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to add a category.' ) ); |
3348 | } |
3349 |
|
3350 | // If no slug was provided make it empty so that |
3351 | // WordPress will generate one. |
3352 | if ( empty( $category['slug'] ) ) { |
Line | Code |
3417 | $password = $args[2]; |
3418 | $category_id = (int) $args[3]; |
3419 |
|
3420 | $user = $this->login( $username, $password ); |
3421 | if ( ! $user ) { |
3422 | return $this->error; |
3423 | } |
3424 |
|
3425 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3426 | do_action( 'xmlrpc_call', 'wp.deleteCategory' ); |
3427 |
|
3428 | if ( ! current_user_can( 'delete_term', $category_id ) ) { |
3429 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this category.' ) ); |
3430 | } |
3431 |
|
3432 | $status = wp_delete_term( $category_id, 'category' ); |
3433 |
|
3434 | if ( true == $status ) { |
3435 | /** |
Line | Code |
3474 | if ( ! $user ) { |
3475 | return $this->error; |
3476 | } |
3477 |
|
3478 | if ( ! current_user_can( 'edit_posts' ) ) { |
3479 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
3480 | } |
3481 |
|
3482 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3483 | do_action( 'xmlrpc_call', 'wp.suggestCategories' ); |
3484 |
|
3485 | $category_suggestions = array(); |
3486 | $args = array( |
3487 | 'get' => 'all', |
3488 | 'number' => $max_results, |
3489 | 'name__like' => $category, |
3490 | ); |
3491 | foreach ( (array) get_categories( $args ) as $cat ) { |
3492 | $category_suggestions[] = array( |
Line | Code |
3520 | $password = $args[2]; |
3521 | $comment_id = (int) $args[3]; |
3522 |
|
3523 | $user = $this->login( $username, $password ); |
3524 | if ( ! $user ) { |
3525 | return $this->error; |
3526 | } |
3527 |
|
3528 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3529 | do_action( 'xmlrpc_call', 'wp.getComment' ); |
3530 |
|
3531 | $comment = get_comment( $comment_id ); |
3532 | if ( ! $comment ) { |
3533 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
3534 | } |
3535 |
|
3536 | if ( ! current_user_can( 'edit_comment', $comment_id ) ) { |
3537 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) ); |
3538 | } |
Line | Code |
3573 | $password = $args[2]; |
3574 | $struct = isset( $args[3] ) ? $args[3] : array(); |
3575 |
|
3576 | $user = $this->login( $username, $password ); |
3577 | if ( ! $user ) { |
3578 | return $this->error; |
3579 | } |
3580 |
|
3581 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3582 | do_action( 'xmlrpc_call', 'wp.getComments' ); |
3583 |
|
3584 | if ( isset( $struct['status'] ) ) { |
3585 | $status = $struct['status']; |
3586 | } else { |
3587 | $status = ''; |
3588 | } |
3589 |
|
3590 | if ( ! current_user_can( 'moderate_comments' ) && 'approve' !== $status ) { |
3591 | return new IXR_Error( 401, __( 'Invalid comment status.' ) ); |
Line | Code |
3668 | if ( ! get_comment( $comment_ID ) ) { |
3669 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
3670 | } |
3671 |
|
3672 | if ( ! current_user_can( 'edit_comment', $comment_ID ) ) { |
3673 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to delete this comment.' ) ); |
3674 | } |
3675 |
|
3676 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3677 | do_action( 'xmlrpc_call', 'wp.deleteComment' ); |
3678 |
|
3679 | $status = wp_delete_comment( $comment_ID ); |
3680 |
|
3681 | if ( $status ) { |
3682 | /** |
3683 | * Fires after a comment has been successfully deleted via XML-RPC. |
3684 | * |
3685 | * @since 3.4.0 |
3686 | * |
Line | Code |
3736 | if ( ! get_comment( $comment_ID ) ) { |
3737 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
3738 | } |
3739 |
|
3740 | if ( ! current_user_can( 'edit_comment', $comment_ID ) ) { |
3741 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) ); |
3742 | } |
3743 |
|
3744 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3745 | do_action( 'xmlrpc_call', 'wp.editComment' ); |
3746 | $comment = array( |
3747 | 'comment_ID' => $comment_ID, |
3748 | ); |
3749 |
|
3750 | if ( isset( $content_struct['status'] ) ) { |
3751 | $statuses = get_comment_statuses(); |
3752 | $statuses = array_keys( $statuses ); |
3753 |
|
3754 | if ( ! in_array( $content_struct['status'], $statuses ) ) { |
Line | Code |
3911 | } elseif ( ! is_email( $comment['comment_author_email'] ) ) { |
3912 | return new IXR_Error( 403, __( 'A valid email address is required.' ) ); |
3913 | } |
3914 | } |
3915 | } |
3916 |
|
3917 | $comment['comment_parent'] = isset( $content_struct['comment_parent'] ) ? absint( $content_struct['comment_parent'] ) : 0; |
3918 |
|
3919 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3920 | do_action( 'xmlrpc_call', 'wp.newComment' ); |
3921 |
|
3922 | $comment_ID = wp_new_comment( $comment, true ); |
3923 | if ( is_wp_error( $comment_ID ) ) { |
3924 | return new IXR_Error( 403, $comment_ID->get_error_message() ); |
3925 | } |
3926 |
|
3927 | if ( ! $comment_ID ) { |
3928 | return new IXR_Error( 403, __( 'Something went wrong.' ) ); |
3929 | } |
Line | Code |
3965 | if ( ! $user ) { |
3966 | return $this->error; |
3967 | } |
3968 |
|
3969 | if ( ! current_user_can( 'publish_posts' ) ) { |
3970 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) ); |
3971 | } |
3972 |
|
3973 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3974 | do_action( 'xmlrpc_call', 'wp.getCommentStatusList' ); |
3975 |
|
3976 | return get_comment_statuses(); |
3977 | } |
3978 |
|
3979 | /** |
3980 | * Retrieve comment count. |
3981 | * |
3982 | * @since 2.5.0 |
3983 | * |
Line | Code |
4007 | if ( empty( $post['ID'] ) ) { |
4008 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
4009 | } |
4010 |
|
4011 | if ( ! current_user_can( 'edit_post', $post_id ) ) { |
4012 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details of this post.' ) ); |
4013 | } |
4014 |
|
4015 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4016 | do_action( 'xmlrpc_call', 'wp.getCommentCount' ); |
4017 |
|
4018 | $count = wp_count_comments( $post_id ); |
4019 |
|
4020 | return array( |
4021 | 'approved' => $count->approved, |
4022 | 'awaiting_moderation' => $count->moderated, |
4023 | 'spam' => $count->spam, |
4024 | 'total_comments' => $count->total_comments, |
4025 | ); |
Line | Code |
4049 | if ( ! $user ) { |
4050 | return $this->error; |
4051 | } |
4052 |
|
4053 | if ( ! current_user_can( 'edit_posts' ) ) { |
4054 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) ); |
4055 | } |
4056 |
|
4057 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4058 | do_action( 'xmlrpc_call', 'wp.getPostStatusList' ); |
4059 |
|
4060 | return get_post_statuses(); |
4061 | } |
4062 |
|
4063 | /** |
4064 | * Retrieve page statuses. |
4065 | * |
4066 | * @since 2.5.0 |
4067 | * |
Line | Code |
4084 | if ( ! $user ) { |
4085 | return $this->error; |
4086 | } |
4087 |
|
4088 | if ( ! current_user_can( 'edit_pages' ) ) { |
4089 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) ); |
4090 | } |
4091 |
|
4092 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4093 | do_action( 'xmlrpc_call', 'wp.getPageStatusList' ); |
4094 |
|
4095 | return get_page_statuses(); |
4096 | } |
4097 |
|
4098 | /** |
4099 | * Retrieve page templates. |
4100 | * |
4101 | * @since 2.6.0 |
4102 | * |
Line | Code |
4277 | if ( ! $user ) { |
4278 | return $this->error; |
4279 | } |
4280 |
|
4281 | if ( ! current_user_can( 'upload_files' ) ) { |
4282 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to upload files.' ) ); |
4283 | } |
4284 |
|
4285 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4286 | do_action( 'xmlrpc_call', 'wp.getMediaItem' ); |
4287 |
|
4288 | $attachment = get_post( $attachment_id ); |
4289 | if ( ! $attachment ) { |
4290 | return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); |
4291 | } |
4292 |
|
4293 | return $this->_prepare_media_item( $attachment ); |
4294 | } |
4295 |
|
Line | Code |
4330 | if ( ! $user ) { |
4331 | return $this->error; |
4332 | } |
4333 |
|
4334 | if ( ! current_user_can( 'upload_files' ) ) { |
4335 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to upload files.' ) ); |
4336 | } |
4337 |
|
4338 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4339 | do_action( 'xmlrpc_call', 'wp.getMediaLibrary' ); |
4340 |
|
4341 | $parent_id = ( isset( $struct['parent_id'] ) ) ? absint( $struct['parent_id'] ) : ''; |
4342 | $mime_type = ( isset( $struct['mime_type'] ) ) ? $struct['mime_type'] : ''; |
4343 | $offset = ( isset( $struct['offset'] ) ) ? absint( $struct['offset'] ) : 0; |
4344 | $number = ( isset( $struct['number'] ) ) ? absint( $struct['number'] ) : -1; |
4345 |
|
4346 | $attachments = get_posts( |
4347 | array( |
4348 | 'post_type' => 'attachment', |
Line | Code |
4386 | if ( ! $user ) { |
4387 | return $this->error; |
4388 | } |
4389 |
|
4390 | if ( ! current_user_can( 'edit_posts' ) ) { |
4391 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) ); |
4392 | } |
4393 |
|
4394 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4395 | do_action( 'xmlrpc_call', 'wp.getPostFormats' ); |
4396 |
|
4397 | $formats = get_post_format_strings(); |
4398 |
|
4399 | // find out if they want a list of currently supports formats |
4400 | if ( isset( $args[3] ) && is_array( $args[3] ) ) { |
4401 | if ( $args[3]['show-supported'] ) { |
4402 | if ( current_theme_supports( 'post-formats' ) ) { |
4403 | $supported = get_theme_support( 'post-formats' ); |
4404 |
|
Line | Code |
4466 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostType' ); |
4467 | } |
4468 |
|
4469 | $user = $this->login( $username, $password ); |
4470 | if ( ! $user ) { |
4471 | return $this->error; |
4472 | } |
4473 |
|
4474 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4475 | do_action( 'xmlrpc_call', 'wp.getPostType' ); |
4476 |
|
4477 | if ( ! post_type_exists( $post_type_name ) ) { |
4478 | return new IXR_Error( 403, __( 'Invalid post type.' ) ); |
4479 | } |
4480 |
|
4481 | $post_type = get_post_type_object( $post_type_name ); |
4482 |
|
4483 | if ( ! current_user_can( $post_type->cap->edit_posts ) ) { |
4484 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts in this post type.' ) ); |
Line | Code |
4523 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostTypes' ); |
4524 | } |
4525 |
|
4526 | $user = $this->login( $username, $password ); |
4527 | if ( ! $user ) { |
4528 | return $this->error; |
4529 | } |
4530 |
|
4531 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4532 | do_action( 'xmlrpc_call', 'wp.getPostTypes' ); |
4533 |
|
4534 | $post_types = get_post_types( $filter, 'objects' ); |
4535 |
|
4536 | $struct = array(); |
4537 |
|
4538 | foreach ( $post_types as $post_type ) { |
4539 | if ( ! current_user_can( $post_type->cap->edit_posts ) ) { |
4540 | continue; |
4541 | } |
Line | Code |
4593 | $fields = apply_filters( 'xmlrpc_default_revision_fields', array( 'post_date', 'post_date_gmt' ), 'wp.getRevisions' ); |
4594 | } |
4595 |
|
4596 | $user = $this->login( $username, $password ); |
4597 | if ( ! $user ) { |
4598 | return $this->error; |
4599 | } |
4600 |
|
4601 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4602 | do_action( 'xmlrpc_call', 'wp.getRevisions' ); |
4603 |
|
4604 | $post = get_post( $post_id ); |
4605 | if ( ! $post ) { |
4606 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
4607 | } |
4608 |
|
4609 | if ( ! current_user_can( 'edit_post', $post_id ) ) { |
4610 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
4611 | } |
Line | Code |
4667 | $password = $args[2]; |
4668 | $revision_id = (int) $args[3]; |
4669 |
|
4670 | $user = $this->login( $username, $password ); |
4671 | if ( ! $user ) { |
4672 | return $this->error; |
4673 | } |
4674 |
|
4675 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4676 | do_action( 'xmlrpc_call', 'wp.restoreRevision' ); |
4677 |
|
4678 | $revision = wp_get_post_revision( $revision_id ); |
4679 | if ( ! $revision ) { |
4680 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
4681 | } |
4682 |
|
4683 | if ( wp_is_post_autosave( $revision ) ) { |
4684 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
4685 | } |
Line | Code |
4737 | $username = $args[1]; |
4738 | $password = $args[2]; |
4739 |
|
4740 | $user = $this->login( $username, $password ); |
4741 | if ( ! $user ) { |
4742 | return $this->error; |
4743 | } |
4744 |
|
4745 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4746 | do_action( 'xmlrpc_call', 'blogger.getUsersBlogs' ); |
4747 |
|
4748 | $is_admin = current_user_can( 'manage_options' ); |
4749 |
|
4750 | $struct = array( |
4751 | 'isAdmin' => $is_admin, |
4752 | 'url' => get_option( 'home' ) . '/', |
4753 | 'blogid' => '1', |
4754 | 'blogName' => get_option( 'blogname' ), |
4755 | 'xmlrpc' => site_url( 'xmlrpc.php', 'rpc' ), |
Line | Code |
4823 | if ( ! $user ) { |
4824 | return $this->error; |
4825 | } |
4826 |
|
4827 | if ( ! current_user_can( 'edit_posts' ) ) { |
4828 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to access user data on this site.' ) ); |
4829 | } |
4830 |
|
4831 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4832 | do_action( 'xmlrpc_call', 'blogger.getUserInfo' ); |
4833 |
|
4834 | $struct = array( |
4835 | 'nickname' => $user->nickname, |
4836 | 'userid' => $user->ID, |
4837 | 'url' => $user->user_url, |
4838 | 'lastname' => $user->last_name, |
4839 | 'firstname' => $user->first_name, |
4840 | ); |
4841 |
|
Line | Code |
4873 | if ( ! $post_data ) { |
4874 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
4875 | } |
4876 |
|
4877 | if ( ! current_user_can( 'edit_post', $post_ID ) ) { |
4878 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
4879 | } |
4880 |
|
4881 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4882 | do_action( 'xmlrpc_call', 'blogger.getPost' ); |
4883 |
|
4884 | $categories = implode( ',', wp_get_post_categories( $post_ID ) ); |
4885 |
|
4886 | $content = '<title>' . wp_unslash( $post_data['post_title'] ) . '</title>'; |
4887 | $content .= '<category>' . $categories . '</category>'; |
4888 | $content .= wp_unslash( $post_data['post_content'] ); |
4889 |
|
4890 | $struct = array( |
4891 | 'userid' => $post_data['post_author'], |
Line | Code |
4930 | if ( ! $user ) { |
4931 | return $this->error; |
4932 | } |
4933 |
|
4934 | if ( ! current_user_can( 'edit_posts' ) ) { |
4935 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
4936 | } |
4937 |
|
4938 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4939 | do_action( 'xmlrpc_call', 'blogger.getRecentPosts' ); |
4940 |
|
4941 | $posts_list = wp_get_recent_posts( $query ); |
4942 |
|
4943 | if ( ! $posts_list ) { |
4944 | $this->error = new IXR_Error( 500, __( 'Either there are no posts, or something went wrong.' ) ); |
4945 | return $this->error; |
4946 | } |
4947 |
|
4948 | $recent_posts = array(); |
Line | Code |
5020 | $content = $args[4]; |
5021 | $publish = $args[5]; |
5022 |
|
5023 | $user = $this->login( $username, $password ); |
5024 | if ( ! $user ) { |
5025 | return $this->error; |
5026 | } |
5027 |
|
5028 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5029 | do_action( 'xmlrpc_call', 'blogger.newPost' ); |
5030 |
|
5031 | $cap = ( $publish ) ? 'publish_posts' : 'edit_posts'; |
5032 | if ( ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) || ! current_user_can( $cap ) ) { |
5033 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to post on this site.' ) ); |
5034 | } |
5035 |
|
5036 | $post_status = ( $publish ) ? 'publish' : 'draft'; |
5037 |
|
5038 | $post_author = $user->ID; |
Line | Code |
5097 | $content = $args[4]; |
5098 | $publish = $args[5]; |
5099 |
|
5100 | $user = $this->login( $username, $password ); |
5101 | if ( ! $user ) { |
5102 | return $this->error; |
5103 | } |
5104 |
|
5105 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5106 | do_action( 'xmlrpc_call', 'blogger.editPost' ); |
5107 |
|
5108 | $actual_post = get_post( $post_ID, ARRAY_A ); |
5109 |
|
5110 | if ( ! $actual_post || $actual_post['post_type'] != 'post' ) { |
5111 | return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); |
5112 | } |
5113 |
|
5114 | $this->escape( $actual_post ); |
5115 |
|
Line | Code |
5171 | $username = $args[2]; |
5172 | $password = $args[3]; |
5173 |
|
5174 | $user = $this->login( $username, $password ); |
5175 | if ( ! $user ) { |
5176 | return $this->error; |
5177 | } |
5178 |
|
5179 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5180 | do_action( 'xmlrpc_call', 'blogger.deletePost' ); |
5181 |
|
5182 | $actual_post = get_post( $post_ID, ARRAY_A ); |
5183 |
|
5184 | if ( ! $actual_post || $actual_post['post_type'] != 'post' ) { |
5185 | return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); |
5186 | } |
5187 |
|
5188 | if ( ! current_user_can( 'delete_post', $post_ID ) ) { |
5189 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) ); |
Line | Code |
5258 | $content_struct = $args[3]; |
5259 | $publish = isset( $args[4] ) ? $args[4] : 0; |
5260 |
|
5261 | $user = $this->login( $username, $password ); |
5262 | if ( ! $user ) { |
5263 | return $this->error; |
5264 | } |
5265 |
|
5266 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5267 | do_action( 'xmlrpc_call', 'metaWeblog.newPost' ); |
5268 |
|
5269 | $page_template = ''; |
5270 | if ( ! empty( $content_struct['post_type'] ) ) { |
5271 | if ( $content_struct['post_type'] == 'page' ) { |
5272 | if ( $publish ) { |
5273 | $cap = 'publish_pages'; |
5274 | } elseif ( isset( $content_struct['page_status'] ) && 'publish' == $content_struct['page_status'] ) { |
5275 | $cap = 'publish_pages'; |
5276 | } else { |
Line | Code |
5637 | $content_struct = $args[3]; |
5638 | $publish = isset( $args[4] ) ? $args[4] : 0; |
5639 |
|
5640 | $user = $this->login( $username, $password ); |
5641 | if ( ! $user ) { |
5642 | return $this->error; |
5643 | } |
5644 |
|
5645 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5646 | do_action( 'xmlrpc_call', 'metaWeblog.editPost' ); |
5647 |
|
5648 | $postdata = get_post( $post_ID, ARRAY_A ); |
5649 |
|
5650 | /* |
5651 | * If there is no post data for the give post id, stop now and return an error. |
5652 | * Otherwise a new post will be created (which was the old behavior). |
5653 | */ |
5654 | if ( ! $postdata || empty( $postdata['ID'] ) ) { |
5655 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
Line | Code |
5975 | if ( ! $postdata ) { |
5976 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
5977 | } |
5978 |
|
5979 | if ( ! current_user_can( 'edit_post', $post_ID ) ) { |
5980 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
5981 | } |
5982 |
|
5983 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5984 | do_action( 'xmlrpc_call', 'metaWeblog.getPost' ); |
5985 |
|
5986 | if ( $postdata['post_date'] != '' ) { |
5987 | $post_date = $this->_convert_date( $postdata['post_date'] ); |
5988 | $post_date_gmt = $this->_convert_date_gmt( $postdata['post_date_gmt'], $postdata['post_date'] ); |
5989 | $post_modified = $this->_convert_date( $postdata['post_modified'] ); |
5990 | $post_modified_gmt = $this->_convert_date_gmt( $postdata['post_modified_gmt'], $postdata['post_modified'] ); |
5991 |
|
5992 | $categories = array(); |
5993 | $catids = wp_get_post_categories( $post_ID ); |
Line | Code |
6116 | if ( ! $user ) { |
6117 | return $this->error; |
6118 | } |
6119 |
|
6120 | if ( ! current_user_can( 'edit_posts' ) ) { |
6121 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
6122 | } |
6123 |
|
6124 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6125 | do_action( 'xmlrpc_call', 'metaWeblog.getRecentPosts' ); |
6126 |
|
6127 | $posts_list = wp_get_recent_posts( $query ); |
6128 |
|
6129 | if ( ! $posts_list ) { |
6130 | return array(); |
6131 | } |
6132 |
|
6133 | $recent_posts = array(); |
6134 | foreach ( $posts_list as $entry ) { |
Line | Code |
6237 | if ( ! $user ) { |
6238 | return $this->error; |
6239 | } |
6240 |
|
6241 | if ( ! current_user_can( 'edit_posts' ) ) { |
6242 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
6243 | } |
6244 |
|
6245 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6246 | do_action( 'xmlrpc_call', 'metaWeblog.getCategories' ); |
6247 |
|
6248 | $categories_struct = array(); |
6249 |
|
6250 | $cats = get_categories( array( 'get' => 'all' ) ); |
6251 | if ( $cats ) { |
6252 | foreach ( $cats as $cat ) { |
6253 | $struct = array(); |
6254 | $struct['categoryId'] = $cat->term_id; |
6255 | $struct['parentId'] = $cat->parent; |
Line | Code |
6298 | $type = $data['type']; |
6299 | $bits = $data['bits']; |
6300 |
|
6301 | $user = $this->login( $username, $password ); |
6302 | if ( ! $user ) { |
6303 | return $this->error; |
6304 | } |
6305 |
|
6306 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6307 | do_action( 'xmlrpc_call', 'metaWeblog.newMediaObject' ); |
6308 |
|
6309 | if ( ! current_user_can( 'upload_files' ) ) { |
6310 | $this->error = new IXR_Error( 401, __( 'Sorry, you are not allowed to upload files.' ) ); |
6311 | return $this->error; |
6312 | } |
6313 |
|
6314 | if ( is_multisite() && upload_is_user_over_quota( false ) ) { |
6315 | $this->error = new IXR_Error( |
6316 | 401, |
Line | Code |
6416 | $query = array(); |
6417 | } |
6418 |
|
6419 | $user = $this->login( $username, $password ); |
6420 | if ( ! $user ) { |
6421 | return $this->error; |
6422 | } |
6423 |
|
6424 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6425 | do_action( 'xmlrpc_call', 'mt.getRecentPostTitles' ); |
6426 |
|
6427 | $posts_list = wp_get_recent_posts( $query ); |
6428 |
|
6429 | if ( ! $posts_list ) { |
6430 | $this->error = new IXR_Error( 500, __( 'Either there are no posts, or something went wrong.' ) ); |
6431 | return $this->error; |
6432 | } |
6433 |
|
6434 | $recent_posts = array(); |
Line | Code |
6478 | if ( ! $user ) { |
6479 | return $this->error; |
6480 | } |
6481 |
|
6482 | if ( ! current_user_can( 'edit_posts' ) ) { |
6483 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
6484 | } |
6485 |
|
6486 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6487 | do_action( 'xmlrpc_call', 'mt.getCategoryList' ); |
6488 |
|
6489 | $categories_struct = array(); |
6490 |
|
6491 | $cats = get_categories( |
6492 | array( |
6493 | 'hide_empty' => 0, |
6494 | 'hierarchical' => 0, |
6495 | ) |
6496 | ); |
Line | Code |
6536 | if ( ! get_post( $post_ID ) ) { |
6537 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
6538 | } |
6539 |
|
6540 | if ( ! current_user_can( 'edit_post', $post_ID ) ) { |
6541 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
6542 | } |
6543 |
|
6544 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6545 | do_action( 'xmlrpc_call', 'mt.getPostCategories' ); |
6546 |
|
6547 | $categories = array(); |
6548 | $catids = wp_get_post_categories( intval( $post_ID ) ); |
6549 | // first listed category will be the primary category |
6550 | $isPrimary = true; |
6551 | foreach ( $catids as $catid ) { |
6552 | $categories[] = array( |
6553 | 'categoryName' => get_cat_name( $catid ), |
6554 | 'categoryId' => (string) $catid, |
Line | Code |
6583 | $password = $args[2]; |
6584 | $categories = $args[3]; |
6585 |
|
6586 | $user = $this->login( $username, $password ); |
6587 | if ( ! $user ) { |
6588 | return $this->error; |
6589 | } |
6590 |
|
6591 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6592 | do_action( 'xmlrpc_call', 'mt.setPostCategories' ); |
6593 |
|
6594 | if ( ! get_post( $post_ID ) ) { |
6595 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
6596 | } |
6597 |
|
6598 | if ( ! current_user_can( 'edit_post', $post_ID ) ) { |
6599 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
6600 | } |
6601 |
|
Line | Code |
6612 | /** |
6613 | * Retrieve an array of methods supported by this server. |
6614 | * |
6615 | * @since 1.5.0 |
6616 | * |
6617 | * @return array |
6618 | */ |
6619 | public function mt_supportedMethods() { |
6620 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6621 | do_action( 'xmlrpc_call', 'mt.supportedMethods' ); |
6622 |
|
6623 | return array_keys( $this->methods ); |
6624 | } |
6625 |
|
6626 | /** |
6627 | * Retrieve an empty array because we don't support per-post text filters. |
6628 | * |
6629 | * @since 1.5.0 |
6630 | */ |
6631 | public function mt_supportedTextFilters() { |
6632 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6633 | do_action( 'xmlrpc_call', 'mt.supportedTextFilters' ); |
6634 |
|
6635 | /** |
6636 | * Filters the MoveableType text filters list for XML-RPC. |
6637 | * |
6638 | * @since 2.2.0 |
6639 | * |
6640 | * @param array $filters An array of text filters. |
6641 | */ |
6642 | return apply_filters( 'xmlrpc_text_filters', array() ); |
Line | Code |
6650 | * @global wpdb $wpdb WordPress database abstraction object. |
6651 | * |
6652 | * @param int $post_ID |
6653 | * @return array|IXR_Error |
6654 | */ |
6655 | public function mt_getTrackbackPings( $post_ID ) { |
6656 | global $wpdb; |
6657 |
|
6658 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6659 | do_action( 'xmlrpc_call', 'mt.getTrackbackPings' ); |
6660 |
|
6661 | $actual_post = get_post( $post_ID, ARRAY_A ); |
6662 |
|
6663 | if ( ! $actual_post ) { |
6664 | return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); |
6665 | } |
6666 |
|
6667 | $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 ) ); |
6668 |
|
Line | Code |
6707 | $username = $args[1]; |
6708 | $password = $args[2]; |
6709 |
|
6710 | $user = $this->login( $username, $password ); |
6711 | if ( ! $user ) { |
6712 | return $this->error; |
6713 | } |
6714 |
|
6715 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6716 | do_action( 'xmlrpc_call', 'mt.publishPost' ); |
6717 |
|
6718 | $postdata = get_post( $post_ID, ARRAY_A ); |
6719 | if ( ! $postdata ) { |
6720 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
6721 | } |
6722 |
|
6723 | if ( ! current_user_can( 'publish_posts' ) || ! current_user_can( 'edit_post', $post_ID ) ) { |
6724 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish this post.' ) ); |
6725 | } |
Line | Code |
6749 | * @type string $pagelinkedfrom |
6750 | * @type string $pagelinkedto |
6751 | * } |
6752 | * @return string|IXR_Error |
6753 | */ |
6754 | public function pingback_ping( $args ) { |
6755 | global $wpdb; |
6756 |
|
6757 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6758 | do_action( 'xmlrpc_call', 'pingback.ping' ); |
6759 |
|
6760 | $this->escape( $args ); |
6761 |
|
6762 | $pagelinkedfrom = str_replace( '&', '&', $args[0] ); |
6763 | $pagelinkedto = str_replace( '&', '&', $args[1] ); |
6764 | $pagelinkedto = str_replace( '&', '&', $pagelinkedto ); |
6765 |
|
6766 | /** |
6767 | * Filters the pingback source URI. |
Line | Code |
6986 | * @global wpdb $wpdb WordPress database abstraction object. |
6987 | * |
6988 | * @param string $url |
6989 | * @return array|IXR_Error |
6990 | */ |
6991 | public function pingback_extensions_getPingbacks( $url ) { |
6992 | global $wpdb; |
6993 |
|
6994 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6995 | do_action( 'xmlrpc_call', 'pingback.extensions.getPingbacks' ); |
6996 |
|
6997 | $url = $this->escape( $url ); |
6998 |
|
6999 | $post_ID = url_to_postid( $url ); |
7000 | if ( ! $post_ID ) { |
7001 | // We aren't sure that the resource is available and/or pingback enabled |
7002 | 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.' ) ); |
7003 | } |
7004 |
|