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 |
|---|---|
| 677 | * the method logic begins. |
| 678 | * |
| 679 | * All built-in XML-RPC methods use the action xmlrpc_call, with a parameter |
| 680 | * equal to the method's name, e.g., wp.getUsersBlogs, wp.newPost, etc. |
| 681 | * |
| 682 | * @since 2.5.0 |
| 683 | * |
| 684 | * @param string $name The method name. |
| 685 | */ |
| 686 | do_action( 'xmlrpc_call', 'wp.getUsersBlogs' ); |
| 687 | |
| 688 | $blogs = (array) get_blogs_of_user( $user->ID ); |
| 689 | $struct = array(); |
| 690 | $primary_blog_id = 0; |
| 691 | $active_blog = get_active_blog_for_user( $user->ID ); |
| 692 | if ( $active_blog ) { |
| 693 | $primary_blog_id = (int) $active_blog->blog_id; |
| 694 | } |
| 695 | |
| Line | Code |
| 1284 | if ( isset( $content_struct['post_date_gmt'] ) && ! ( $content_struct['post_date_gmt'] instanceof IXR_Date ) ) { |
| 1285 | if ( $content_struct['post_date_gmt'] == '0000-00-00 00:00:00' || isset( $content_struct['post_date'] ) ) { |
| 1286 | unset( $content_struct['post_date_gmt'] ); |
| 1287 | } else { |
| 1288 | $content_struct['post_date_gmt'] = $this->_convert_date( $content_struct['post_date_gmt'] ); |
| 1289 | } |
| 1290 | } |
| 1291 | |
| 1292 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1293 | do_action( 'xmlrpc_call', 'wp.newPost' ); |
| 1294 | |
| 1295 | unset( $content_struct['ID'] ); |
| 1296 | |
| 1297 | return $this->_insert_post( $user, $content_struct ); |
| 1298 | } |
| 1299 | |
| 1300 | /** |
| 1301 | * Helper method for filtering out elements from an array. |
| 1302 | * |
| Line | Code |
| 1671 | $password = $args[2]; |
| 1672 | $post_id = (int) $args[3]; |
| 1673 | $content_struct = $args[4]; |
| 1674 | |
| 1675 | if ( ! $user = $this->login( $username, $password ) ) { |
| 1676 | return $this->error; |
| 1677 | } |
| 1678 | |
| 1679 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1680 | do_action( 'xmlrpc_call', 'wp.editPost' ); |
| 1681 | |
| 1682 | $post = get_post( $post_id, ARRAY_A ); |
| 1683 | |
| 1684 | if ( empty( $post['ID'] ) ) { |
| 1685 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 1686 | } |
| 1687 | |
| 1688 | if ( isset( $content_struct['if_not_modified_since'] ) ) { |
| 1689 | // If the post has been modified since the date provided, return an error. |
| Line | Code |
| 1743 | $username = $args[1]; |
| 1744 | $password = $args[2]; |
| 1745 | $post_id = (int) $args[3]; |
| 1746 | |
| 1747 | if ( ! $user = $this->login( $username, $password ) ) { |
| 1748 | return $this->error; |
| 1749 | } |
| 1750 | |
| 1751 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1752 | do_action( 'xmlrpc_call', 'wp.deletePost' ); |
| 1753 | |
| 1754 | $post = get_post( $post_id, ARRAY_A ); |
| 1755 | if ( empty( $post['ID'] ) ) { |
| 1756 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 1757 | } |
| 1758 | |
| 1759 | if ( ! current_user_can( 'delete_post', $post_id ) ) { |
| 1760 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) ); |
| 1761 | } |
| Line | Code |
| 1842 | */ |
| 1843 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPost' ); |
| 1844 | } |
| 1845 | |
| 1846 | if ( ! $user = $this->login( $username, $password ) ) { |
| 1847 | return $this->error; |
| 1848 | } |
| 1849 | |
| 1850 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1851 | do_action( 'xmlrpc_call', 'wp.getPost' ); |
| 1852 | |
| 1853 | $post = get_post( $post_id, ARRAY_A ); |
| 1854 | |
| 1855 | if ( empty( $post['ID'] ) ) { |
| 1856 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 1857 | } |
| 1858 | |
| 1859 | if ( ! current_user_can( 'edit_post', $post_id ) ) { |
| 1860 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
| Line | Code |
| 1902 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1903 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPosts' ); |
| 1904 | } |
| 1905 | |
| 1906 | if ( ! $user = $this->login( $username, $password ) ) { |
| 1907 | return $this->error; |
| 1908 | } |
| 1909 | |
| 1910 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1911 | do_action( 'xmlrpc_call', 'wp.getPosts' ); |
| 1912 | |
| 1913 | $query = array(); |
| 1914 | |
| 1915 | if ( isset( $filter['post_type'] ) ) { |
| 1916 | $post_type = get_post_type_object( $filter['post_type'] ); |
| 1917 | if ( ! ( (bool) $post_type ) ) { |
| 1918 | return new IXR_Error( 403, __( 'Invalid post type.' ) ); |
| 1919 | } |
| 1920 | } else { |
| Line | Code |
| 2000 | $username = $args[1]; |
| 2001 | $password = $args[2]; |
| 2002 | $content_struct = $args[3]; |
| 2003 | |
| 2004 | if ( ! $user = $this->login( $username, $password ) ) { |
| 2005 | return $this->error; |
| 2006 | } |
| 2007 | |
| 2008 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2009 | do_action( 'xmlrpc_call', 'wp.newTerm' ); |
| 2010 | |
| 2011 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) { |
| 2012 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 2013 | } |
| 2014 | |
| 2015 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
| 2016 | |
| 2017 | if ( ! current_user_can( $taxonomy->cap->edit_terms ) ) { |
| 2018 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to create terms in this taxonomy.' ) ); |
| Line | Code |
| 2104 | $password = $args[2]; |
| 2105 | $term_id = (int) $args[3]; |
| 2106 | $content_struct = $args[4]; |
| 2107 | |
| 2108 | if ( ! $user = $this->login( $username, $password ) ) { |
| 2109 | return $this->error; |
| 2110 | } |
| 2111 | |
| 2112 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2113 | do_action( 'xmlrpc_call', 'wp.editTerm' ); |
| 2114 | |
| 2115 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) { |
| 2116 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 2117 | } |
| 2118 | |
| 2119 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
| 2120 | |
| 2121 | $taxonomy = (array) $taxonomy; |
| 2122 | |
| Line | Code |
| 2219 | $password = $args[2]; |
| 2220 | $taxonomy = $args[3]; |
| 2221 | $term_id = (int) $args[4]; |
| 2222 | |
| 2223 | if ( ! $user = $this->login( $username, $password ) ) { |
| 2224 | return $this->error; |
| 2225 | } |
| 2226 | |
| 2227 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2228 | do_action( 'xmlrpc_call', 'wp.deleteTerm' ); |
| 2229 | |
| 2230 | if ( ! taxonomy_exists( $taxonomy ) ) { |
| 2231 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 2232 | } |
| 2233 | |
| 2234 | $taxonomy = get_taxonomy( $taxonomy ); |
| 2235 | $term = get_term( $term_id, $taxonomy->name ); |
| 2236 | |
| 2237 | if ( is_wp_error( $term ) ) { |
| Line | Code |
| 2297 | $password = $args[2]; |
| 2298 | $taxonomy = $args[3]; |
| 2299 | $term_id = (int) $args[4]; |
| 2300 | |
| 2301 | if ( ! $user = $this->login( $username, $password ) ) { |
| 2302 | return $this->error; |
| 2303 | } |
| 2304 | |
| 2305 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2306 | do_action( 'xmlrpc_call', 'wp.getTerm' ); |
| 2307 | |
| 2308 | if ( ! taxonomy_exists( $taxonomy ) ) { |
| 2309 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 2310 | } |
| 2311 | |
| 2312 | $taxonomy = get_taxonomy( $taxonomy ); |
| 2313 | |
| 2314 | $term = get_term( $term_id, $taxonomy->name, ARRAY_A ); |
| 2315 | |
| Line | Code |
| 2361 | $password = $args[2]; |
| 2362 | $taxonomy = $args[3]; |
| 2363 | $filter = isset( $args[4] ) ? $args[4] : array(); |
| 2364 | |
| 2365 | if ( ! $user = $this->login( $username, $password ) ) { |
| 2366 | return $this->error; |
| 2367 | } |
| 2368 | |
| 2369 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2370 | do_action( 'xmlrpc_call', 'wp.getTerms' ); |
| 2371 | |
| 2372 | if ( ! taxonomy_exists( $taxonomy ) ) { |
| 2373 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 2374 | } |
| 2375 | |
| 2376 | $taxonomy = get_taxonomy( $taxonomy ); |
| 2377 | |
| 2378 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) { |
| 2379 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ) ); |
| Line | Code |
| 2466 | */ |
| 2467 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomy' ); |
| 2468 | } |
| 2469 | |
| 2470 | if ( ! $user = $this->login( $username, $password ) ) { |
| 2471 | return $this->error; |
| 2472 | } |
| 2473 | |
| 2474 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2475 | do_action( 'xmlrpc_call', 'wp.getTaxonomy' ); |
| 2476 | |
| 2477 | if ( ! taxonomy_exists( $taxonomy ) ) { |
| 2478 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 2479 | } |
| 2480 | |
| 2481 | $taxonomy = get_taxonomy( $taxonomy ); |
| 2482 | |
| 2483 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) { |
| 2484 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ) ); |
| Line | Code |
| 2523 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2524 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomies' ); |
| 2525 | } |
| 2526 | |
| 2527 | if ( ! $user = $this->login( $username, $password ) ) { |
| 2528 | return $this->error; |
| 2529 | } |
| 2530 | |
| 2531 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2532 | do_action( 'xmlrpc_call', 'wp.getTaxonomies' ); |
| 2533 | |
| 2534 | $taxonomies = get_taxonomies( $filter, 'objects' ); |
| 2535 | |
| 2536 | // holds all the taxonomy data |
| 2537 | $struct = array(); |
| 2538 | |
| 2539 | foreach ( $taxonomies as $taxonomy ) { |
| 2540 | // capability check for post_types |
| 2541 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) { |
| Line | Code |
| 2608 | */ |
| 2609 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUser' ); |
| 2610 | } |
| 2611 | |
| 2612 | if ( ! $user = $this->login( $username, $password ) ) { |
| 2613 | return $this->error; |
| 2614 | } |
| 2615 | |
| 2616 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2617 | do_action( 'xmlrpc_call', 'wp.getUser' ); |
| 2618 | |
| 2619 | if ( ! current_user_can( 'edit_user', $user_id ) ) { |
| 2620 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this user.' ) ); |
| 2621 | } |
| 2622 | |
| 2623 | $user_data = get_userdata( $user_id ); |
| 2624 | |
| 2625 | if ( ! $user_data ) { |
| 2626 | return new IXR_Error( 404, __( 'Invalid user ID.' ) ); |
| Line | Code |
| 2670 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2671 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUsers' ); |
| 2672 | } |
| 2673 | |
| 2674 | if ( ! $user = $this->login( $username, $password ) ) { |
| 2675 | return $this->error; |
| 2676 | } |
| 2677 | |
| 2678 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2679 | do_action( 'xmlrpc_call', 'wp.getUsers' ); |
| 2680 | |
| 2681 | if ( ! current_user_can( 'list_users' ) ) { |
| 2682 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to list users.' ) ); |
| 2683 | } |
| 2684 | |
| 2685 | $query = array( 'fields' => 'all_with_meta' ); |
| 2686 | |
| 2687 | $query['number'] = ( isset( $filter['number'] ) ) ? absint( $filter['number'] ) : 50; |
| 2688 | $query['offset'] = ( isset( $filter['offset'] ) ) ? absint( $filter['offset'] ) : 0; |
| Line | Code |
| 2749 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2750 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getProfile' ); |
| 2751 | } |
| 2752 | |
| 2753 | if ( ! $user = $this->login( $username, $password ) ) { |
| 2754 | return $this->error; |
| 2755 | } |
| 2756 | |
| 2757 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2758 | do_action( 'xmlrpc_call', 'wp.getProfile' ); |
| 2759 | |
| 2760 | if ( ! current_user_can( 'edit_user', $user->ID ) ) { |
| 2761 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit your profile.' ) ); |
| 2762 | } |
| 2763 | |
| 2764 | $user_data = get_userdata( $user->ID ); |
| 2765 | |
| 2766 | return $this->_prepare_user( $user_data, $fields ); |
| 2767 | } |
| Line | Code |
| 2798 | $username = $args[1]; |
| 2799 | $password = $args[2]; |
| 2800 | $content_struct = $args[3]; |
| 2801 | |
| 2802 | if ( ! $user = $this->login( $username, $password ) ) { |
| 2803 | return $this->error; |
| 2804 | } |
| 2805 | |
| 2806 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2807 | do_action( 'xmlrpc_call', 'wp.editProfile' ); |
| 2808 | |
| 2809 | if ( ! current_user_can( 'edit_user', $user->ID ) ) { |
| 2810 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit your profile.' ) ); |
| 2811 | } |
| 2812 | |
| 2813 | // holds data of the user |
| 2814 | $user_data = array(); |
| 2815 | $user_data['ID'] = $user->ID; |
| 2816 | |
| Line | Code |
| 2886 | if ( ! $page ) { |
| 2887 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 2888 | } |
| 2889 | |
| 2890 | if ( ! current_user_can( 'edit_page', $page_id ) ) { |
| 2891 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this page.' ) ); |
| 2892 | } |
| 2893 | |
| 2894 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2895 | do_action( 'xmlrpc_call', 'wp.getPage' ); |
| 2896 | |
| 2897 | // If we found the page then format the data. |
| 2898 | if ( $page->ID && ( $page->post_type == 'page' ) ) { |
| 2899 | return $this->_prepare_page( $page ); |
| 2900 | } else { |
| 2901 | // If the page doesn't exist indicate that. |
| 2902 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
| 2903 | } |
| 2904 | } |
| Line | Code |
| 2928 | if ( ! $user = $this->login( $username, $password ) ) { |
| 2929 | return $this->error; |
| 2930 | } |
| 2931 | |
| 2932 | if ( ! current_user_can( 'edit_pages' ) ) { |
| 2933 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit pages.' ) ); |
| 2934 | } |
| 2935 | |
| 2936 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2937 | do_action( 'xmlrpc_call', 'wp.getPages' ); |
| 2938 | |
| 2939 | $pages = get_posts( |
| 2940 | array( |
| 2941 | 'post_type' => 'page', |
| 2942 | 'post_status' => 'any', |
| 2943 | 'numberposts' => $num_pages, |
| 2944 | ) |
| 2945 | ); |
| 2946 | $num_pages = count( $pages ); |
| Line | Code |
| 2982 | // Items not escaped here will be escaped in newPost. |
| 2983 | $username = $this->escape( $args[1] ); |
| 2984 | $password = $this->escape( $args[2] ); |
| 2985 | |
| 2986 | if ( ! $user = $this->login( $username, $password ) ) { |
| 2987 | return $this->error; |
| 2988 | } |
| 2989 | |
| 2990 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2991 | do_action( 'xmlrpc_call', 'wp.newPage' ); |
| 2992 | |
| 2993 | // Mark this as content for a page. |
| 2994 | $args[3]['post_type'] = 'page'; |
| 2995 | |
| 2996 | // Let mw_newPost do all of the heavy lifting. |
| 2997 | return $this->mw_newPost( $args ); |
| 2998 | } |
| 2999 | |
| 3000 | /** |
| Line | Code |
| 3018 | $username = $args[1]; |
| 3019 | $password = $args[2]; |
| 3020 | $page_id = (int) $args[3]; |
| 3021 | |
| 3022 | if ( ! $user = $this->login( $username, $password ) ) { |
| 3023 | return $this->error; |
| 3024 | } |
| 3025 | |
| 3026 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3027 | do_action( 'xmlrpc_call', 'wp.deletePage' ); |
| 3028 | |
| 3029 | // Get the current page based on the page_id and |
| 3030 | // make sure it is a page and not a post. |
| 3031 | $actual_page = get_post( $page_id, ARRAY_A ); |
| 3032 | if ( ! $actual_page || ( $actual_page['post_type'] != 'page' ) ) { |
| 3033 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
| 3034 | } |
| 3035 | |
| 3036 | // Make sure the user can delete pages. |
| Line | Code |
| 3084 | |
| 3085 | $escaped_username = $this->escape( $username ); |
| 3086 | $escaped_password = $this->escape( $password ); |
| 3087 | |
| 3088 | if ( ! $user = $this->login( $escaped_username, $escaped_password ) ) { |
| 3089 | return $this->error; |
| 3090 | } |
| 3091 | |
| 3092 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3093 | do_action( 'xmlrpc_call', 'wp.editPage' ); |
| 3094 | |
| 3095 | // Get the page data and make sure it is a page. |
| 3096 | $actual_page = get_post( $page_id, ARRAY_A ); |
| 3097 | if ( ! $actual_page || ( $actual_page['post_type'] != 'page' ) ) { |
| 3098 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
| 3099 | } |
| 3100 | |
| 3101 | // Make sure the user is allowed to edit pages. |
| 3102 | if ( ! current_user_can( 'edit_page', $page_id ) ) { |
| Line | Code |
| 3146 | if ( ! $user = $this->login( $username, $password ) ) { |
| 3147 | return $this->error; |
| 3148 | } |
| 3149 | |
| 3150 | if ( ! current_user_can( 'edit_pages' ) ) { |
| 3151 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit pages.' ) ); |
| 3152 | } |
| 3153 | |
| 3154 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3155 | do_action( 'xmlrpc_call', 'wp.getPageList' ); |
| 3156 | |
| 3157 | // Get list of pages ids and titles |
| 3158 | $page_list = $wpdb->get_results( |
| 3159 | " |
| 3160 | SELECT ID page_id, |
| 3161 | post_title page_title, |
| 3162 | post_parent page_parent_id, |
| 3163 | post_date_gmt, |
| 3164 | post_date, |
| Line | Code |
| 3206 | if ( ! $user = $this->login( $username, $password ) ) { |
| 3207 | return $this->error; |
| 3208 | } |
| 3209 | |
| 3210 | if ( ! current_user_can( 'edit_posts' ) ) { |
| 3211 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
| 3212 | } |
| 3213 | |
| 3214 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3215 | do_action( 'xmlrpc_call', 'wp.getAuthors' ); |
| 3216 | |
| 3217 | $authors = array(); |
| 3218 | foreach ( get_users( array( 'fields' => array( 'ID', 'user_login', 'display_name' ) ) ) as $user ) { |
| 3219 | $authors[] = array( |
| 3220 | 'user_id' => $user->ID, |
| 3221 | 'user_login' => $user->user_login, |
| 3222 | 'display_name' => $user->display_name, |
| 3223 | ); |
| 3224 | } |
| Line | Code |
| 3249 | if ( ! $user = $this->login( $username, $password ) ) { |
| 3250 | return $this->error; |
| 3251 | } |
| 3252 | |
| 3253 | if ( ! current_user_can( 'edit_posts' ) ) { |
| 3254 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view tags.' ) ); |
| 3255 | } |
| 3256 | |
| 3257 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3258 | do_action( 'xmlrpc_call', 'wp.getKeywords' ); |
| 3259 | |
| 3260 | $tags = array(); |
| 3261 | |
| 3262 | if ( $all_tags = get_tags() ) { |
| 3263 | foreach ( (array) $all_tags as $tag ) { |
| 3264 | $struct = array(); |
| 3265 | $struct['tag_id'] = $tag->term_id; |
| 3266 | $struct['name'] = $tag->name; |
| 3267 | $struct['count'] = $tag->count; |
| Line | Code |
| 3297 | $username = $args[1]; |
| 3298 | $password = $args[2]; |
| 3299 | $category = $args[3]; |
| 3300 | |
| 3301 | if ( ! $user = $this->login( $username, $password ) ) { |
| 3302 | return $this->error; |
| 3303 | } |
| 3304 | |
| 3305 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3306 | do_action( 'xmlrpc_call', 'wp.newCategory' ); |
| 3307 | |
| 3308 | // Make sure the user is allowed to add a category. |
| 3309 | if ( ! current_user_can( 'manage_categories' ) ) { |
| 3310 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to add a category.' ) ); |
| 3311 | } |
| 3312 | |
| 3313 | // If no slug was provided make it empty so that |
| 3314 | // WordPress will generate one. |
| 3315 | if ( empty( $category['slug'] ) ) { |
| Line | Code |
| 3379 | $username = $args[1]; |
| 3380 | $password = $args[2]; |
| 3381 | $category_id = (int) $args[3]; |
| 3382 | |
| 3383 | if ( ! $user = $this->login( $username, $password ) ) { |
| 3384 | return $this->error; |
| 3385 | } |
| 3386 | |
| 3387 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3388 | do_action( 'xmlrpc_call', 'wp.deleteCategory' ); |
| 3389 | |
| 3390 | if ( ! current_user_can( 'delete_term', $category_id ) ) { |
| 3391 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this category.' ) ); |
| 3392 | } |
| 3393 | |
| 3394 | $status = wp_delete_term( $category_id, 'category' ); |
| 3395 | |
| 3396 | if ( true == $status ) { |
| 3397 | /** |
| Line | Code |
| 3435 | if ( ! $user = $this->login( $username, $password ) ) { |
| 3436 | return $this->error; |
| 3437 | } |
| 3438 | |
| 3439 | if ( ! current_user_can( 'edit_posts' ) ) { |
| 3440 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
| 3441 | } |
| 3442 | |
| 3443 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3444 | do_action( 'xmlrpc_call', 'wp.suggestCategories' ); |
| 3445 | |
| 3446 | $category_suggestions = array(); |
| 3447 | $args = array( |
| 3448 | 'get' => 'all', |
| 3449 | 'number' => $max_results, |
| 3450 | 'name__like' => $category, |
| 3451 | ); |
| 3452 | foreach ( (array) get_categories( $args ) as $cat ) { |
| 3453 | $category_suggestions[] = array( |
| Line | Code |
| 3480 | $username = $args[1]; |
| 3481 | $password = $args[2]; |
| 3482 | $comment_id = (int) $args[3]; |
| 3483 | |
| 3484 | if ( ! $user = $this->login( $username, $password ) ) { |
| 3485 | return $this->error; |
| 3486 | } |
| 3487 | |
| 3488 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3489 | do_action( 'xmlrpc_call', 'wp.getComment' ); |
| 3490 | |
| 3491 | if ( ! $comment = get_comment( $comment_id ) ) { |
| 3492 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 3493 | } |
| 3494 | |
| 3495 | if ( ! current_user_can( 'edit_comment', $comment_id ) ) { |
| 3496 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) ); |
| 3497 | } |
| 3498 | |
| Line | Code |
| 3531 | $username = $args[1]; |
| 3532 | $password = $args[2]; |
| 3533 | $struct = isset( $args[3] ) ? $args[3] : array(); |
| 3534 | |
| 3535 | if ( ! $user = $this->login( $username, $password ) ) { |
| 3536 | return $this->error; |
| 3537 | } |
| 3538 | |
| 3539 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3540 | do_action( 'xmlrpc_call', 'wp.getComments' ); |
| 3541 | |
| 3542 | if ( isset( $struct['status'] ) ) { |
| 3543 | $status = $struct['status']; |
| 3544 | } else { |
| 3545 | $status = ''; |
| 3546 | } |
| 3547 | |
| 3548 | if ( ! current_user_can( 'moderate_comments' ) && 'approve' !== $status ) { |
| 3549 | return new IXR_Error( 401, __( 'Invalid comment status.' ) ); |
| Line | Code |
| 3625 | if ( ! get_comment( $comment_ID ) ) { |
| 3626 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 3627 | } |
| 3628 | |
| 3629 | if ( ! current_user_can( 'edit_comment', $comment_ID ) ) { |
| 3630 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to delete this comment.' ) ); |
| 3631 | } |
| 3632 | |
| 3633 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3634 | do_action( 'xmlrpc_call', 'wp.deleteComment' ); |
| 3635 | |
| 3636 | $status = wp_delete_comment( $comment_ID ); |
| 3637 | |
| 3638 | if ( $status ) { |
| 3639 | /** |
| 3640 | * Fires after a comment has been successfully deleted via XML-RPC. |
| 3641 | * |
| 3642 | * @since 3.4.0 |
| 3643 | * |
| Line | Code |
| 3692 | if ( ! get_comment( $comment_ID ) ) { |
| 3693 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 3694 | } |
| 3695 | |
| 3696 | if ( ! current_user_can( 'edit_comment', $comment_ID ) ) { |
| 3697 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) ); |
| 3698 | } |
| 3699 | |
| 3700 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3701 | do_action( 'xmlrpc_call', 'wp.editComment' ); |
| 3702 | $comment = array( |
| 3703 | 'comment_ID' => $comment_ID, |
| 3704 | ); |
| 3705 | |
| 3706 | if ( isset( $content_struct['status'] ) ) { |
| 3707 | $statuses = get_comment_statuses(); |
| 3708 | $statuses = array_keys( $statuses ); |
| 3709 | |
| 3710 | if ( ! in_array( $content_struct['status'], $statuses ) ) { |
| Line | Code |
| 3867 | } elseif ( ! is_email( $comment['comment_author_email'] ) ) { |
| 3868 | return new IXR_Error( 403, __( 'A valid email address is required.' ) ); |
| 3869 | } |
| 3870 | } |
| 3871 | } |
| 3872 | |
| 3873 | $comment['comment_parent'] = isset( $content_struct['comment_parent'] ) ? absint( $content_struct['comment_parent'] ) : 0; |
| 3874 | |
| 3875 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3876 | do_action( 'xmlrpc_call', 'wp.newComment' ); |
| 3877 | |
| 3878 | $comment_ID = wp_new_comment( $comment, true ); |
| 3879 | if ( is_wp_error( $comment_ID ) ) { |
| 3880 | return new IXR_Error( 403, $comment_ID->get_error_message() ); |
| 3881 | } |
| 3882 | |
| 3883 | if ( ! $comment_ID ) { |
| 3884 | return new IXR_Error( 403, __( 'Something went wrong.' ) ); |
| 3885 | } |
| Line | Code |
| 3920 | if ( ! $user = $this->login( $username, $password ) ) { |
| 3921 | return $this->error; |
| 3922 | } |
| 3923 | |
| 3924 | if ( ! current_user_can( 'publish_posts' ) ) { |
| 3925 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) ); |
| 3926 | } |
| 3927 | |
| 3928 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3929 | do_action( 'xmlrpc_call', 'wp.getCommentStatusList' ); |
| 3930 | |
| 3931 | return get_comment_statuses(); |
| 3932 | } |
| 3933 | |
| 3934 | /** |
| 3935 | * Retrieve comment count. |
| 3936 | * |
| 3937 | * @since 2.5.0 |
| 3938 | * |
| Line | Code |
| 3961 | if ( empty( $post['ID'] ) ) { |
| 3962 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 3963 | } |
| 3964 | |
| 3965 | if ( ! current_user_can( 'edit_post', $post_id ) ) { |
| 3966 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details of this post.' ) ); |
| 3967 | } |
| 3968 | |
| 3969 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3970 | do_action( 'xmlrpc_call', 'wp.getCommentCount' ); |
| 3971 | |
| 3972 | $count = wp_count_comments( $post_id ); |
| 3973 | |
| 3974 | return array( |
| 3975 | 'approved' => $count->approved, |
| 3976 | 'awaiting_moderation' => $count->moderated, |
| 3977 | 'spam' => $count->spam, |
| 3978 | 'total_comments' => $count->total_comments, |
| 3979 | ); |
| Line | Code |
| 4002 | if ( ! $user = $this->login( $username, $password ) ) { |
| 4003 | return $this->error; |
| 4004 | } |
| 4005 | |
| 4006 | if ( ! current_user_can( 'edit_posts' ) ) { |
| 4007 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) ); |
| 4008 | } |
| 4009 | |
| 4010 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4011 | do_action( 'xmlrpc_call', 'wp.getPostStatusList' ); |
| 4012 | |
| 4013 | return get_post_statuses(); |
| 4014 | } |
| 4015 | |
| 4016 | /** |
| 4017 | * Retrieve page statuses. |
| 4018 | * |
| 4019 | * @since 2.5.0 |
| 4020 | * |
| Line | Code |
| 4036 | if ( ! $user = $this->login( $username, $password ) ) { |
| 4037 | return $this->error; |
| 4038 | } |
| 4039 | |
| 4040 | if ( ! current_user_can( 'edit_pages' ) ) { |
| 4041 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) ); |
| 4042 | } |
| 4043 | |
| 4044 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4045 | do_action( 'xmlrpc_call', 'wp.getPageStatusList' ); |
| 4046 | |
| 4047 | return get_page_statuses(); |
| 4048 | } |
| 4049 | |
| 4050 | /** |
| 4051 | * Retrieve page templates. |
| 4052 | * |
| 4053 | * @since 2.6.0 |
| 4054 | * |
| Line | Code |
| 4225 | if ( ! $user = $this->login( $username, $password ) ) { |
| 4226 | return $this->error; |
| 4227 | } |
| 4228 | |
| 4229 | if ( ! current_user_can( 'upload_files' ) ) { |
| 4230 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to upload files.' ) ); |
| 4231 | } |
| 4232 | |
| 4233 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4234 | do_action( 'xmlrpc_call', 'wp.getMediaItem' ); |
| 4235 | |
| 4236 | if ( ! $attachment = get_post( $attachment_id ) ) { |
| 4237 | return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); |
| 4238 | } |
| 4239 | |
| 4240 | return $this->_prepare_media_item( $attachment ); |
| 4241 | } |
| 4242 | |
| 4243 | /** |
| Line | Code |
| 4276 | if ( ! $user = $this->login( $username, $password ) ) { |
| 4277 | return $this->error; |
| 4278 | } |
| 4279 | |
| 4280 | if ( ! current_user_can( 'upload_files' ) ) { |
| 4281 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to upload files.' ) ); |
| 4282 | } |
| 4283 | |
| 4284 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4285 | do_action( 'xmlrpc_call', 'wp.getMediaLibrary' ); |
| 4286 | |
| 4287 | $parent_id = ( isset( $struct['parent_id'] ) ) ? absint( $struct['parent_id'] ) : ''; |
| 4288 | $mime_type = ( isset( $struct['mime_type'] ) ) ? $struct['mime_type'] : ''; |
| 4289 | $offset = ( isset( $struct['offset'] ) ) ? absint( $struct['offset'] ) : 0; |
| 4290 | $number = ( isset( $struct['number'] ) ) ? absint( $struct['number'] ) : -1; |
| 4291 | |
| 4292 | $attachments = get_posts( |
| 4293 | array( |
| 4294 | 'post_type' => 'attachment', |
| Line | Code |
| 4331 | if ( ! $user = $this->login( $username, $password ) ) { |
| 4332 | return $this->error; |
| 4333 | } |
| 4334 | |
| 4335 | if ( ! current_user_can( 'edit_posts' ) ) { |
| 4336 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) ); |
| 4337 | } |
| 4338 | |
| 4339 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4340 | do_action( 'xmlrpc_call', 'wp.getPostFormats' ); |
| 4341 | |
| 4342 | $formats = get_post_format_strings(); |
| 4343 | |
| 4344 | // find out if they want a list of currently supports formats |
| 4345 | if ( isset( $args[3] ) && is_array( $args[3] ) ) { |
| 4346 | if ( $args[3]['show-supported'] ) { |
| 4347 | if ( current_theme_supports( 'post-formats' ) ) { |
| 4348 | $supported = get_theme_support( 'post-formats' ); |
| 4349 | |
| Line | Code |
| 4410 | */ |
| 4411 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostType' ); |
| 4412 | } |
| 4413 | |
| 4414 | if ( ! $user = $this->login( $username, $password ) ) { |
| 4415 | return $this->error; |
| 4416 | } |
| 4417 | |
| 4418 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4419 | do_action( 'xmlrpc_call', 'wp.getPostType' ); |
| 4420 | |
| 4421 | if ( ! post_type_exists( $post_type_name ) ) { |
| 4422 | return new IXR_Error( 403, __( 'Invalid post type.' ) ); |
| 4423 | } |
| 4424 | |
| 4425 | $post_type = get_post_type_object( $post_type_name ); |
| 4426 | |
| 4427 | if ( ! current_user_can( $post_type->cap->edit_posts ) ) { |
| 4428 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts in this post type.' ) ); |
| Line | Code |
| 4466 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4467 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostTypes' ); |
| 4468 | } |
| 4469 | |
| 4470 | if ( ! $user = $this->login( $username, $password ) ) { |
| 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.getPostTypes' ); |
| 4476 | |
| 4477 | $post_types = get_post_types( $filter, 'objects' ); |
| 4478 | |
| 4479 | $struct = array(); |
| 4480 | |
| 4481 | foreach ( $post_types as $post_type ) { |
| 4482 | if ( ! current_user_can( $post_type->cap->edit_posts ) ) { |
| 4483 | continue; |
| 4484 | } |
| Line | Code |
| 4535 | */ |
| 4536 | $fields = apply_filters( 'xmlrpc_default_revision_fields', array( 'post_date', 'post_date_gmt' ), 'wp.getRevisions' ); |
| 4537 | } |
| 4538 | |
| 4539 | if ( ! $user = $this->login( $username, $password ) ) { |
| 4540 | return $this->error; |
| 4541 | } |
| 4542 | |
| 4543 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4544 | do_action( 'xmlrpc_call', 'wp.getRevisions' ); |
| 4545 | |
| 4546 | if ( ! $post = get_post( $post_id ) ) { |
| 4547 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4548 | } |
| 4549 | |
| 4550 | if ( ! current_user_can( 'edit_post', $post_id ) ) { |
| 4551 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
| 4552 | } |
| 4553 | |
| Line | Code |
| 4607 | $username = $args[1]; |
| 4608 | $password = $args[2]; |
| 4609 | $revision_id = (int) $args[3]; |
| 4610 | |
| 4611 | if ( ! $user = $this->login( $username, $password ) ) { |
| 4612 | return $this->error; |
| 4613 | } |
| 4614 | |
| 4615 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4616 | do_action( 'xmlrpc_call', 'wp.restoreRevision' ); |
| 4617 | |
| 4618 | if ( ! $revision = wp_get_post_revision( $revision_id ) ) { |
| 4619 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4620 | } |
| 4621 | |
| 4622 | if ( wp_is_post_autosave( $revision ) ) { |
| 4623 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4624 | } |
| 4625 | |
| Line | Code |
| 4674 | |
| 4675 | $username = $args[1]; |
| 4676 | $password = $args[2]; |
| 4677 | |
| 4678 | if ( ! $user = $this->login( $username, $password ) ) { |
| 4679 | return $this->error; |
| 4680 | } |
| 4681 | |
| 4682 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4683 | do_action( 'xmlrpc_call', 'blogger.getUsersBlogs' ); |
| 4684 | |
| 4685 | $is_admin = current_user_can( 'manage_options' ); |
| 4686 | |
| 4687 | $struct = array( |
| 4688 | 'isAdmin' => $is_admin, |
| 4689 | 'url' => get_option( 'home' ) . '/', |
| 4690 | 'blogid' => '1', |
| 4691 | 'blogName' => get_option( 'blogname' ), |
| 4692 | 'xmlrpc' => site_url( 'xmlrpc.php', 'rpc' ), |
| Line | Code |
| 4759 | if ( ! $user = $this->login( $username, $password ) ) { |
| 4760 | return $this->error; |
| 4761 | } |
| 4762 | |
| 4763 | if ( ! current_user_can( 'edit_posts' ) ) { |
| 4764 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to access user data on this site.' ) ); |
| 4765 | } |
| 4766 | |
| 4767 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4768 | do_action( 'xmlrpc_call', 'blogger.getUserInfo' ); |
| 4769 | |
| 4770 | $struct = array( |
| 4771 | 'nickname' => $user->nickname, |
| 4772 | 'userid' => $user->ID, |
| 4773 | 'url' => $user->user_url, |
| 4774 | 'lastname' => $user->last_name, |
| 4775 | 'firstname' => $user->first_name, |
| 4776 | ); |
| 4777 | |
| Line | Code |
| 4808 | if ( ! $post_data ) { |
| 4809 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4810 | } |
| 4811 | |
| 4812 | if ( ! current_user_can( 'edit_post', $post_ID ) ) { |
| 4813 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
| 4814 | } |
| 4815 | |
| 4816 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4817 | do_action( 'xmlrpc_call', 'blogger.getPost' ); |
| 4818 | |
| 4819 | $categories = implode( ',', wp_get_post_categories( $post_ID ) ); |
| 4820 | |
| 4821 | $content = '<title>' . wp_unslash( $post_data['post_title'] ) . '</title>'; |
| 4822 | $content .= '<category>' . $categories . '</category>'; |
| 4823 | $content .= wp_unslash( $post_data['post_content'] ); |
| 4824 | |
| 4825 | $struct = array( |
| 4826 | 'userid' => $post_data['post_author'], |
| Line | Code |
| 4864 | if ( ! $user = $this->login( $username, $password ) ) { |
| 4865 | return $this->error; |
| 4866 | } |
| 4867 | |
| 4868 | if ( ! current_user_can( 'edit_posts' ) ) { |
| 4869 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
| 4870 | } |
| 4871 | |
| 4872 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4873 | do_action( 'xmlrpc_call', 'blogger.getRecentPosts' ); |
| 4874 | |
| 4875 | $posts_list = wp_get_recent_posts( $query ); |
| 4876 | |
| 4877 | if ( ! $posts_list ) { |
| 4878 | $this->error = new IXR_Error( 500, __( 'Either there are no posts, or something went wrong.' ) ); |
| 4879 | return $this->error; |
| 4880 | } |
| 4881 | |
| 4882 | $recent_posts = array(); |
| Line | Code |
| 4953 | $password = $args[3]; |
| 4954 | $content = $args[4]; |
| 4955 | $publish = $args[5]; |
| 4956 | |
| 4957 | if ( ! $user = $this->login( $username, $password ) ) { |
| 4958 | return $this->error; |
| 4959 | } |
| 4960 | |
| 4961 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4962 | do_action( 'xmlrpc_call', 'blogger.newPost' ); |
| 4963 | |
| 4964 | $cap = ( $publish ) ? 'publish_posts' : 'edit_posts'; |
| 4965 | if ( ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) || ! current_user_can( $cap ) ) { |
| 4966 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to post on this site.' ) ); |
| 4967 | } |
| 4968 | |
| 4969 | $post_status = ( $publish ) ? 'publish' : 'draft'; |
| 4970 | |
| 4971 | $post_author = $user->ID; |
| Line | Code |
| 5029 | $password = $args[3]; |
| 5030 | $content = $args[4]; |
| 5031 | $publish = $args[5]; |
| 5032 | |
| 5033 | if ( ! $user = $this->login( $username, $password ) ) { |
| 5034 | return $this->error; |
| 5035 | } |
| 5036 | |
| 5037 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5038 | do_action( 'xmlrpc_call', 'blogger.editPost' ); |
| 5039 | |
| 5040 | $actual_post = get_post( $post_ID, ARRAY_A ); |
| 5041 | |
| 5042 | if ( ! $actual_post || $actual_post['post_type'] != 'post' ) { |
| 5043 | return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); |
| 5044 | } |
| 5045 | |
| 5046 | $this->escape( $actual_post ); |
| 5047 | |
| Line | Code |
| 5102 | $post_ID = (int) $args[1]; |
| 5103 | $username = $args[2]; |
| 5104 | $password = $args[3]; |
| 5105 | |
| 5106 | if ( ! $user = $this->login( $username, $password ) ) { |
| 5107 | return $this->error; |
| 5108 | } |
| 5109 | |
| 5110 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5111 | do_action( 'xmlrpc_call', 'blogger.deletePost' ); |
| 5112 | |
| 5113 | $actual_post = get_post( $post_ID, ARRAY_A ); |
| 5114 | |
| 5115 | if ( ! $actual_post || $actual_post['post_type'] != 'post' ) { |
| 5116 | return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); |
| 5117 | } |
| 5118 | |
| 5119 | if ( ! current_user_can( 'delete_post', $post_ID ) ) { |
| 5120 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) ); |
| Line | Code |
| 5188 | $password = $args[2]; |
| 5189 | $content_struct = $args[3]; |
| 5190 | $publish = isset( $args[4] ) ? $args[4] : 0; |
| 5191 | |
| 5192 | if ( ! $user = $this->login( $username, $password ) ) { |
| 5193 | return $this->error; |
| 5194 | } |
| 5195 | |
| 5196 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5197 | do_action( 'xmlrpc_call', 'metaWeblog.newPost' ); |
| 5198 | |
| 5199 | $page_template = ''; |
| 5200 | if ( ! empty( $content_struct['post_type'] ) ) { |
| 5201 | if ( $content_struct['post_type'] == 'page' ) { |
| 5202 | if ( $publish ) { |
| 5203 | $cap = 'publish_pages'; |
| 5204 | } elseif ( isset( $content_struct['page_status'] ) && 'publish' == $content_struct['page_status'] ) { |
| 5205 | $cap = 'publish_pages'; |
| 5206 | } else { |
| Line | Code |
| 5564 | $password = $args[2]; |
| 5565 | $content_struct = $args[3]; |
| 5566 | $publish = isset( $args[4] ) ? $args[4] : 0; |
| 5567 | |
| 5568 | if ( ! $user = $this->login( $username, $password ) ) { |
| 5569 | return $this->error; |
| 5570 | } |
| 5571 | |
| 5572 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5573 | do_action( 'xmlrpc_call', 'metaWeblog.editPost' ); |
| 5574 | |
| 5575 | $postdata = get_post( $post_ID, ARRAY_A ); |
| 5576 | |
| 5577 | /* |
| 5578 | * If there is no post data for the give post id, stop now and return an error. |
| 5579 | * Otherwise a new post will be created (which was the old behavior). |
| 5580 | */ |
| 5581 | if ( ! $postdata || empty( $postdata['ID'] ) ) { |
| 5582 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| Line | Code |
| 5901 | if ( ! $postdata ) { |
| 5902 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 5903 | } |
| 5904 | |
| 5905 | if ( ! current_user_can( 'edit_post', $post_ID ) ) { |
| 5906 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
| 5907 | } |
| 5908 | |
| 5909 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5910 | do_action( 'xmlrpc_call', 'metaWeblog.getPost' ); |
| 5911 | |
| 5912 | if ( $postdata['post_date'] != '' ) { |
| 5913 | $post_date = $this->_convert_date( $postdata['post_date'] ); |
| 5914 | $post_date_gmt = $this->_convert_date_gmt( $postdata['post_date_gmt'], $postdata['post_date'] ); |
| 5915 | $post_modified = $this->_convert_date( $postdata['post_modified'] ); |
| 5916 | $post_modified_gmt = $this->_convert_date_gmt( $postdata['post_modified_gmt'], $postdata['post_modified'] ); |
| 5917 | |
| 5918 | $categories = array(); |
| 5919 | $catids = wp_get_post_categories( $post_ID ); |
| Line | Code |
| 6041 | if ( ! $user = $this->login( $username, $password ) ) { |
| 6042 | return $this->error; |
| 6043 | } |
| 6044 | |
| 6045 | if ( ! current_user_can( 'edit_posts' ) ) { |
| 6046 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
| 6047 | } |
| 6048 | |
| 6049 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6050 | do_action( 'xmlrpc_call', 'metaWeblog.getRecentPosts' ); |
| 6051 | |
| 6052 | $posts_list = wp_get_recent_posts( $query ); |
| 6053 | |
| 6054 | if ( ! $posts_list ) { |
| 6055 | return array(); |
| 6056 | } |
| 6057 | |
| 6058 | $recent_posts = array(); |
| 6059 | foreach ( $posts_list as $entry ) { |
| Line | Code |
| 6161 | if ( ! $user = $this->login( $username, $password ) ) { |
| 6162 | return $this->error; |
| 6163 | } |
| 6164 | |
| 6165 | if ( ! current_user_can( 'edit_posts' ) ) { |
| 6166 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
| 6167 | } |
| 6168 | |
| 6169 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6170 | do_action( 'xmlrpc_call', 'metaWeblog.getCategories' ); |
| 6171 | |
| 6172 | $categories_struct = array(); |
| 6173 | |
| 6174 | if ( $cats = get_categories( array( 'get' => 'all' ) ) ) { |
| 6175 | foreach ( $cats as $cat ) { |
| 6176 | $struct = array(); |
| 6177 | $struct['categoryId'] = $cat->term_id; |
| 6178 | $struct['parentId'] = $cat->parent; |
| 6179 | $struct['description'] = $cat->name; |
| Line | Code |
| 6220 | $name = sanitize_file_name( $data['name'] ); |
| 6221 | $type = $data['type']; |
| 6222 | $bits = $data['bits']; |
| 6223 | |
| 6224 | if ( ! $user = $this->login( $username, $password ) ) { |
| 6225 | return $this->error; |
| 6226 | } |
| 6227 | |
| 6228 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6229 | do_action( 'xmlrpc_call', 'metaWeblog.newMediaObject' ); |
| 6230 | |
| 6231 | if ( ! current_user_can( 'upload_files' ) ) { |
| 6232 | $this->error = new IXR_Error( 401, __( 'Sorry, you are not allowed to upload files.' ) ); |
| 6233 | return $this->error; |
| 6234 | } |
| 6235 | |
| 6236 | if ( is_multisite() && upload_is_user_over_quota( false ) ) { |
| 6237 | $this->error = new IXR_Error( |
| 6238 | 401, |
| Line | Code |
| 6336 | } else { |
| 6337 | $query = array(); |
| 6338 | } |
| 6339 | |
| 6340 | if ( ! $user = $this->login( $username, $password ) ) { |
| 6341 | return $this->error; |
| 6342 | } |
| 6343 | |
| 6344 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6345 | do_action( 'xmlrpc_call', 'mt.getRecentPostTitles' ); |
| 6346 | |
| 6347 | $posts_list = wp_get_recent_posts( $query ); |
| 6348 | |
| 6349 | if ( ! $posts_list ) { |
| 6350 | $this->error = new IXR_Error( 500, __( 'Either there are no posts, or something went wrong.' ) ); |
| 6351 | return $this->error; |
| 6352 | } |
| 6353 | |
| 6354 | $recent_posts = array(); |
| Line | Code |
| 6397 | if ( ! $user = $this->login( $username, $password ) ) { |
| 6398 | return $this->error; |
| 6399 | } |
| 6400 | |
| 6401 | if ( ! current_user_can( 'edit_posts' ) ) { |
| 6402 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
| 6403 | } |
| 6404 | |
| 6405 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6406 | do_action( 'xmlrpc_call', 'mt.getCategoryList' ); |
| 6407 | |
| 6408 | $categories_struct = array(); |
| 6409 | |
| 6410 | if ( $cats = get_categories( |
| 6411 | array( |
| 6412 | 'hide_empty' => 0, |
| 6413 | 'hierarchical' => 0, |
| 6414 | ) |
| 6415 | ) ) { |
| Line | Code |
| 6453 | if ( ! get_post( $post_ID ) ) { |
| 6454 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 6455 | } |
| 6456 | |
| 6457 | if ( ! current_user_can( 'edit_post', $post_ID ) ) { |
| 6458 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
| 6459 | } |
| 6460 | |
| 6461 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6462 | do_action( 'xmlrpc_call', 'mt.getPostCategories' ); |
| 6463 | |
| 6464 | $categories = array(); |
| 6465 | $catids = wp_get_post_categories( intval( $post_ID ) ); |
| 6466 | // first listed category will be the primary category |
| 6467 | $isPrimary = true; |
| 6468 | foreach ( $catids as $catid ) { |
| 6469 | $categories[] = array( |
| 6470 | 'categoryName' => get_cat_name( $catid ), |
| 6471 | 'categoryId' => (string) $catid, |
| Line | Code |
| 6499 | $username = $args[1]; |
| 6500 | $password = $args[2]; |
| 6501 | $categories = $args[3]; |
| 6502 | |
| 6503 | if ( ! $user = $this->login( $username, $password ) ) { |
| 6504 | return $this->error; |
| 6505 | } |
| 6506 | |
| 6507 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6508 | do_action( 'xmlrpc_call', 'mt.setPostCategories' ); |
| 6509 | |
| 6510 | if ( ! get_post( $post_ID ) ) { |
| 6511 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 6512 | } |
| 6513 | |
| 6514 | if ( ! current_user_can( 'edit_post', $post_ID ) ) { |
| 6515 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
| 6516 | } |
| 6517 | |
| Line | Code |
| 6528 | /** |
| 6529 | * Retrieve an array of methods supported by this server. |
| 6530 | * |
| 6531 | * @since 1.5.0 |
| 6532 | * |
| 6533 | * @return array |
| 6534 | */ |
| 6535 | public function mt_supportedMethods() { |
| 6536 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6537 | do_action( 'xmlrpc_call', 'mt.supportedMethods' ); |
| 6538 | |
| 6539 | return array_keys( $this->methods ); |
| 6540 | } |
| 6541 | |
| 6542 | /** |
| 6543 | * Retrieve an empty array because we don't support per-post text filters. |
| 6544 | * |
| 6545 | * @since 1.5.0 |
| 6546 | */ |
| 6547 | public function mt_supportedTextFilters() { |
| 6548 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6549 | do_action( 'xmlrpc_call', 'mt.supportedTextFilters' ); |
| 6550 | |
| 6551 | /** |
| 6552 | * Filters the MoveableType text filters list for XML-RPC. |
| 6553 | * |
| 6554 | * @since 2.2.0 |
| 6555 | * |
| 6556 | * @param array $filters An array of text filters. |
| 6557 | */ |
| 6558 | return apply_filters( 'xmlrpc_text_filters', array() ); |
| Line | Code |
| 6566 | * @global wpdb $wpdb WordPress database abstraction object. |
| 6567 | * |
| 6568 | * @param int $post_ID |
| 6569 | * @return array|IXR_Error |
| 6570 | */ |
| 6571 | public function mt_getTrackbackPings( $post_ID ) { |
| 6572 | global $wpdb; |
| 6573 | |
| 6574 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6575 | do_action( 'xmlrpc_call', 'mt.getTrackbackPings' ); |
| 6576 | |
| 6577 | $actual_post = get_post( $post_ID, ARRAY_A ); |
| 6578 | |
| 6579 | if ( ! $actual_post ) { |
| 6580 | return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); |
| 6581 | } |
| 6582 | |
| 6583 | $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 ) ); |
| 6584 | |
| Line | Code |
| 6622 | $post_ID = (int) $args[0]; |
| 6623 | $username = $args[1]; |
| 6624 | $password = $args[2]; |
| 6625 | |
| 6626 | if ( ! $user = $this->login( $username, $password ) ) { |
| 6627 | return $this->error; |
| 6628 | } |
| 6629 | |
| 6630 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6631 | do_action( 'xmlrpc_call', 'mt.publishPost' ); |
| 6632 | |
| 6633 | $postdata = get_post( $post_ID, ARRAY_A ); |
| 6634 | if ( ! $postdata ) { |
| 6635 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 6636 | } |
| 6637 | |
| 6638 | if ( ! current_user_can( 'publish_posts' ) || ! current_user_can( 'edit_post', $post_ID ) ) { |
| 6639 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish this post.' ) ); |
| 6640 | } |
| Line | Code |
| 6664 | * @type string $pagelinkedfrom |
| 6665 | * @type string $pagelinkedto |
| 6666 | * } |
| 6667 | * @return string|IXR_Error |
| 6668 | */ |
| 6669 | public function pingback_ping( $args ) { |
| 6670 | global $wpdb; |
| 6671 | |
| 6672 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6673 | do_action( 'xmlrpc_call', 'pingback.ping' ); |
| 6674 | |
| 6675 | $this->escape( $args ); |
| 6676 | |
| 6677 | $pagelinkedfrom = str_replace( '&', '&', $args[0] ); |
| 6678 | $pagelinkedto = str_replace( '&', '&', $args[1] ); |
| 6679 | $pagelinkedto = str_replace( '&', '&', $pagelinkedto ); |
| 6680 | |
| 6681 | /** |
| 6682 | * Filters the pingback source URI. |
| Line | Code |
| 6895 | * @global wpdb $wpdb WordPress database abstraction object. |
| 6896 | * |
| 6897 | * @param string $url |
| 6898 | * @return array|IXR_Error |
| 6899 | */ |
| 6900 | public function pingback_extensions_getPingbacks( $url ) { |
| 6901 | global $wpdb; |
| 6902 | |
| 6903 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6904 | do_action( 'xmlrpc_call', 'pingback.extensions.getPingbacks' ); |
| 6905 | |
| 6906 | $url = $this->escape( $url ); |
| 6907 | |
| 6908 | $post_ID = url_to_postid( $url ); |
| 6909 | if ( ! $post_ID ) { |
| 6910 | // We aren't sure that the resource is available and/or pingback enabled |
| 6911 | 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.' ) ); |
| 6912 | } |
| 6913 | |