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 |
|---|---|
| 671 | * the method logic begins. |
| 672 | * |
| 673 | * All built-in XML-RPC methods use the action xmlrpc_call, with a parameter |
| 674 | * equal to the method's name, e.g., wp.getUsersBlogs, wp.newPost, etc. |
| 675 | * |
| 676 | * @since 2.5.0 |
| 677 | * |
| 678 | * @param string $name The method name. |
| 679 | */ |
| 680 | do_action( 'xmlrpc_call', 'wp.getUsersBlogs' ); |
| 681 | |
| 682 | $blogs = (array) get_blogs_of_user( $user->ID ); |
| 683 | $struct = array(); |
| 684 | $primary_blog_id = 0; |
| 685 | $active_blog = get_active_blog_for_user( $user->ID ); |
| 686 | if ( $active_blog ) { |
| 687 | $primary_blog_id = (int) $active_blog->blog_id; |
| 688 | } |
| 689 | |
| Line | Code |
| 1273 | if ( isset( $content_struct['post_date_gmt'] ) && ! ( $content_struct['post_date_gmt'] instanceof IXR_Date ) ) { |
| 1274 | if ( $content_struct['post_date_gmt'] == '0000-00-00 00:00:00' || isset( $content_struct['post_date'] ) ) { |
| 1275 | unset( $content_struct['post_date_gmt'] ); |
| 1276 | } else { |
| 1277 | $content_struct['post_date_gmt'] = $this->_convert_date( $content_struct['post_date_gmt'] ); |
| 1278 | } |
| 1279 | } |
| 1280 | |
| 1281 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1282 | do_action( 'xmlrpc_call', 'wp.newPost' ); |
| 1283 | |
| 1284 | unset( $content_struct['ID'] ); |
| 1285 | |
| 1286 | return $this->_insert_post( $user, $content_struct ); |
| 1287 | } |
| 1288 | |
| 1289 | /** |
| 1290 | * Helper method for filtering out elements from an array. |
| 1291 | * |
| Line | Code |
| 1625 | $username = $args[1]; |
| 1626 | $password = $args[2]; |
| 1627 | $post_id = (int) $args[3]; |
| 1628 | $content_struct = $args[4]; |
| 1629 | |
| 1630 | if ( ! $user = $this->login( $username, $password ) ) |
| 1631 | return $this->error; |
| 1632 | |
| 1633 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1634 | do_action( 'xmlrpc_call', 'wp.editPost' ); |
| 1635 | |
| 1636 | $post = get_post( $post_id, ARRAY_A ); |
| 1637 | |
| 1638 | if ( empty( $post['ID'] ) ) |
| 1639 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 1640 | |
| 1641 | if ( isset( $content_struct['if_not_modified_since'] ) ) { |
| 1642 | // If the post has been modified since the date provided, return an error. |
| 1643 | if ( mysql2date( 'U', $post['post_modified_gmt'] ) > $content_struct['if_not_modified_since']->getTimestamp() ) { |
| Line | Code |
| 1692 | |
| 1693 | $username = $args[1]; |
| 1694 | $password = $args[2]; |
| 1695 | $post_id = (int) $args[3]; |
| 1696 | |
| 1697 | if ( ! $user = $this->login( $username, $password ) ) |
| 1698 | return $this->error; |
| 1699 | |
| 1700 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1701 | do_action( 'xmlrpc_call', 'wp.deletePost' ); |
| 1702 | |
| 1703 | $post = get_post( $post_id, ARRAY_A ); |
| 1704 | if ( empty( $post['ID'] ) ) { |
| 1705 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 1706 | } |
| 1707 | |
| 1708 | if ( ! current_user_can( 'delete_post', $post_id ) ) { |
| 1709 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) ); |
| 1710 | } |
| Line | Code |
| 1789 | * @param string $method Method name. |
| 1790 | */ |
| 1791 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPost' ); |
| 1792 | } |
| 1793 | |
| 1794 | if ( ! $user = $this->login( $username, $password ) ) |
| 1795 | return $this->error; |
| 1796 | |
| 1797 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1798 | do_action( 'xmlrpc_call', 'wp.getPost' ); |
| 1799 | |
| 1800 | $post = get_post( $post_id, ARRAY_A ); |
| 1801 | |
| 1802 | if ( empty( $post['ID'] ) ) |
| 1803 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 1804 | |
| 1805 | if ( ! current_user_can( 'edit_post', $post_id ) ) |
| 1806 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
| 1807 | |
| Line | Code |
| 1845 | } else { |
| 1846 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1847 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPosts' ); |
| 1848 | } |
| 1849 | |
| 1850 | if ( ! $user = $this->login( $username, $password ) ) |
| 1851 | return $this->error; |
| 1852 | |
| 1853 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1854 | do_action( 'xmlrpc_call', 'wp.getPosts' ); |
| 1855 | |
| 1856 | $query = array(); |
| 1857 | |
| 1858 | if ( isset( $filter['post_type'] ) ) { |
| 1859 | $post_type = get_post_type_object( $filter['post_type'] ); |
| 1860 | if ( ! ( (bool) $post_type ) ) |
| 1861 | return new IXR_Error( 403, __( 'Invalid post type.' ) ); |
| 1862 | } else { |
| 1863 | $post_type = get_post_type_object( 'post' ); |
| Line | Code |
| 1933 | |
| 1934 | $username = $args[1]; |
| 1935 | $password = $args[2]; |
| 1936 | $content_struct = $args[3]; |
| 1937 | |
| 1938 | if ( ! $user = $this->login( $username, $password ) ) |
| 1939 | return $this->error; |
| 1940 | |
| 1941 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1942 | do_action( 'xmlrpc_call', 'wp.newTerm' ); |
| 1943 | |
| 1944 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) |
| 1945 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 1946 | |
| 1947 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
| 1948 | |
| 1949 | if ( ! current_user_can( $taxonomy->cap->edit_terms ) ) { |
| 1950 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to create terms in this taxonomy.' ) ); |
| 1951 | } |
| Line | Code |
| 2026 | $username = $args[1]; |
| 2027 | $password = $args[2]; |
| 2028 | $term_id = (int) $args[3]; |
| 2029 | $content_struct = $args[4]; |
| 2030 | |
| 2031 | if ( ! $user = $this->login( $username, $password ) ) |
| 2032 | return $this->error; |
| 2033 | |
| 2034 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2035 | do_action( 'xmlrpc_call', 'wp.editTerm' ); |
| 2036 | |
| 2037 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) |
| 2038 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 2039 | |
| 2040 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
| 2041 | |
| 2042 | $taxonomy = (array) $taxonomy; |
| 2043 | |
| 2044 | // hold the data of the term |
| Line | Code |
| 2128 | $username = $args[1]; |
| 2129 | $password = $args[2]; |
| 2130 | $taxonomy = $args[3]; |
| 2131 | $term_id = (int) $args[4]; |
| 2132 | |
| 2133 | if ( ! $user = $this->login( $username, $password ) ) |
| 2134 | return $this->error; |
| 2135 | |
| 2136 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2137 | do_action( 'xmlrpc_call', 'wp.deleteTerm' ); |
| 2138 | |
| 2139 | if ( ! taxonomy_exists( $taxonomy ) ) |
| 2140 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 2141 | |
| 2142 | $taxonomy = get_taxonomy( $taxonomy ); |
| 2143 | $term = get_term( $term_id, $taxonomy->name ); |
| 2144 | |
| 2145 | if ( is_wp_error( $term ) ) |
| 2146 | return new IXR_Error( 500, $term->get_error_message() ); |
| Line | Code |
| 2199 | $username = $args[1]; |
| 2200 | $password = $args[2]; |
| 2201 | $taxonomy = $args[3]; |
| 2202 | $term_id = (int) $args[4]; |
| 2203 | |
| 2204 | if ( ! $user = $this->login( $username, $password ) ) |
| 2205 | return $this->error; |
| 2206 | |
| 2207 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2208 | do_action( 'xmlrpc_call', 'wp.getTerm' ); |
| 2209 | |
| 2210 | if ( ! taxonomy_exists( $taxonomy ) ) |
| 2211 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 2212 | |
| 2213 | $taxonomy = get_taxonomy( $taxonomy ); |
| 2214 | |
| 2215 | $term = get_term( $term_id , $taxonomy->name, ARRAY_A ); |
| 2216 | |
| 2217 | if ( is_wp_error( $term ) ) |
| Line | Code |
| 2258 | $username = $args[1]; |
| 2259 | $password = $args[2]; |
| 2260 | $taxonomy = $args[3]; |
| 2261 | $filter = isset( $args[4] ) ? $args[4] : array(); |
| 2262 | |
| 2263 | if ( ! $user = $this->login( $username, $password ) ) |
| 2264 | return $this->error; |
| 2265 | |
| 2266 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2267 | do_action( 'xmlrpc_call', 'wp.getTerms' ); |
| 2268 | |
| 2269 | if ( ! taxonomy_exists( $taxonomy ) ) |
| 2270 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 2271 | |
| 2272 | $taxonomy = get_taxonomy( $taxonomy ); |
| 2273 | |
| 2274 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
| 2275 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ) ); |
| 2276 | |
| Line | Code |
| 2353 | * @param string $method The method name. |
| 2354 | */ |
| 2355 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomy' ); |
| 2356 | } |
| 2357 | |
| 2358 | if ( ! $user = $this->login( $username, $password ) ) |
| 2359 | return $this->error; |
| 2360 | |
| 2361 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2362 | do_action( 'xmlrpc_call', 'wp.getTaxonomy' ); |
| 2363 | |
| 2364 | if ( ! taxonomy_exists( $taxonomy ) ) |
| 2365 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 2366 | |
| 2367 | $taxonomy = get_taxonomy( $taxonomy ); |
| 2368 | |
| 2369 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
| 2370 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ) ); |
| 2371 | |
| Line | Code |
| 2406 | } else { |
| 2407 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2408 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomies' ); |
| 2409 | } |
| 2410 | |
| 2411 | if ( ! $user = $this->login( $username, $password ) ) |
| 2412 | return $this->error; |
| 2413 | |
| 2414 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2415 | do_action( 'xmlrpc_call', 'wp.getTaxonomies' ); |
| 2416 | |
| 2417 | $taxonomies = get_taxonomies( $filter, 'objects' ); |
| 2418 | |
| 2419 | // holds all the taxonomy data |
| 2420 | $struct = array(); |
| 2421 | |
| 2422 | foreach ( $taxonomies as $taxonomy ) { |
| 2423 | // capability check for post_types |
| 2424 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
| Line | Code |
| 2488 | * @param string $method The method name. |
| 2489 | */ |
| 2490 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUser' ); |
| 2491 | } |
| 2492 | |
| 2493 | if ( ! $user = $this->login( $username, $password ) ) |
| 2494 | return $this->error; |
| 2495 | |
| 2496 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2497 | do_action( 'xmlrpc_call', 'wp.getUser' ); |
| 2498 | |
| 2499 | if ( ! current_user_can( 'edit_user', $user_id ) ) |
| 2500 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this user.' ) ); |
| 2501 | |
| 2502 | $user_data = get_userdata( $user_id ); |
| 2503 | |
| 2504 | if ( ! $user_data ) |
| 2505 | return new IXR_Error( 404, __( 'Invalid user ID.' ) ); |
| 2506 | |
| Line | Code |
| 2546 | } else { |
| 2547 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2548 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUsers' ); |
| 2549 | } |
| 2550 | |
| 2551 | if ( ! $user = $this->login( $username, $password ) ) |
| 2552 | return $this->error; |
| 2553 | |
| 2554 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2555 | do_action( 'xmlrpc_call', 'wp.getUsers' ); |
| 2556 | |
| 2557 | if ( ! current_user_can( 'list_users' ) ) |
| 2558 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to list users.' ) ); |
| 2559 | |
| 2560 | $query = array( 'fields' => 'all_with_meta' ); |
| 2561 | |
| 2562 | $query['number'] = ( isset( $filter['number'] ) ) ? absint( $filter['number'] ) : 50; |
| 2563 | $query['offset'] = ( isset( $filter['offset'] ) ) ? absint( $filter['offset'] ) : 0; |
| 2564 | |
| Line | Code |
| 2619 | } else { |
| 2620 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2621 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getProfile' ); |
| 2622 | } |
| 2623 | |
| 2624 | if ( ! $user = $this->login( $username, $password ) ) |
| 2625 | return $this->error; |
| 2626 | |
| 2627 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2628 | do_action( 'xmlrpc_call', 'wp.getProfile' ); |
| 2629 | |
| 2630 | if ( ! current_user_can( 'edit_user', $user->ID ) ) |
| 2631 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit your profile.' ) ); |
| 2632 | |
| 2633 | $user_data = get_userdata( $user->ID ); |
| 2634 | |
| 2635 | return $this->_prepare_user( $user_data, $fields ); |
| 2636 | } |
| 2637 | |
| Line | Code |
| 2665 | |
| 2666 | $username = $args[1]; |
| 2667 | $password = $args[2]; |
| 2668 | $content_struct = $args[3]; |
| 2669 | |
| 2670 | if ( ! $user = $this->login( $username, $password ) ) |
| 2671 | return $this->error; |
| 2672 | |
| 2673 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2674 | do_action( 'xmlrpc_call', 'wp.editProfile' ); |
| 2675 | |
| 2676 | if ( ! current_user_can( 'edit_user', $user->ID ) ) |
| 2677 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit your profile.' ) ); |
| 2678 | |
| 2679 | // holds data of the user |
| 2680 | $user_data = array(); |
| 2681 | $user_data['ID'] = $user->ID; |
| 2682 | |
| 2683 | // only set the user details if it was given |
| Line | Code |
| 2741 | |
| 2742 | $page = get_post($page_id); |
| 2743 | if ( ! $page ) |
| 2744 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 2745 | |
| 2746 | if ( !current_user_can( 'edit_page', $page_id ) ) |
| 2747 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this page.' ) ); |
| 2748 | |
| 2749 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2750 | do_action( 'xmlrpc_call', 'wp.getPage' ); |
| 2751 | |
| 2752 | // If we found the page then format the data. |
| 2753 | if ( $page->ID && ($page->post_type == 'page') ) { |
| 2754 | return $this->_prepare_page( $page ); |
| 2755 | } |
| 2756 | // If the page doesn't exist indicate that. |
| 2757 | else { |
| 2758 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
| 2759 | } |
| Line | Code |
| 2782 | $num_pages = isset($args[3]) ? (int) $args[3] : 10; |
| 2783 | |
| 2784 | if ( !$user = $this->login($username, $password) ) |
| 2785 | return $this->error; |
| 2786 | |
| 2787 | if ( !current_user_can( 'edit_pages' ) ) |
| 2788 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit pages.' ) ); |
| 2789 | |
| 2790 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2791 | do_action( 'xmlrpc_call', 'wp.getPages' ); |
| 2792 | |
| 2793 | $pages = get_posts( array('post_type' => 'page', 'post_status' => 'any', 'numberposts' => $num_pages) ); |
| 2794 | $num_pages = count($pages); |
| 2795 | |
| 2796 | // If we have pages, put together their info. |
| 2797 | if ( $num_pages >= 1 ) { |
| 2798 | $pages_struct = array(); |
| 2799 | |
| 2800 | foreach ($pages as $page) { |
| Line | Code |
| 2828 | public function wp_newPage( $args ) { |
| 2829 | // Items not escaped here will be escaped in newPost. |
| 2830 | $username = $this->escape( $args[1] ); |
| 2831 | $password = $this->escape( $args[2] ); |
| 2832 | |
| 2833 | if ( !$user = $this->login($username, $password) ) |
| 2834 | return $this->error; |
| 2835 | |
| 2836 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2837 | do_action( 'xmlrpc_call', 'wp.newPage' ); |
| 2838 | |
| 2839 | // Mark this as content for a page. |
| 2840 | $args[3]["post_type"] = 'page'; |
| 2841 | |
| 2842 | // Let mw_newPost do all of the heavy lifting. |
| 2843 | return $this->mw_newPost( $args ); |
| 2844 | } |
| 2845 | |
| 2846 | /** |
| Line | Code |
| 2863 | |
| 2864 | $username = $args[1]; |
| 2865 | $password = $args[2]; |
| 2866 | $page_id = (int) $args[3]; |
| 2867 | |
| 2868 | if ( !$user = $this->login($username, $password) ) |
| 2869 | return $this->error; |
| 2870 | |
| 2871 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2872 | do_action( 'xmlrpc_call', 'wp.deletePage' ); |
| 2873 | |
| 2874 | // Get the current page based on the page_id and |
| 2875 | // make sure it is a page and not a post. |
| 2876 | $actual_page = get_post($page_id, ARRAY_A); |
| 2877 | if ( !$actual_page || ($actual_page['post_type'] != 'page') ) |
| 2878 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
| 2879 | |
| 2880 | // Make sure the user can delete pages. |
| 2881 | if ( !current_user_can('delete_page', $page_id) ) |
| Line | Code |
| 2926 | |
| 2927 | $escaped_username = $this->escape( $username ); |
| 2928 | $escaped_password = $this->escape( $password ); |
| 2929 | |
| 2930 | if ( !$user = $this->login( $escaped_username, $escaped_password ) ) { |
| 2931 | return $this->error; |
| 2932 | } |
| 2933 | |
| 2934 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2935 | do_action( 'xmlrpc_call', 'wp.editPage' ); |
| 2936 | |
| 2937 | // Get the page data and make sure it is a page. |
| 2938 | $actual_page = get_post($page_id, ARRAY_A); |
| 2939 | if ( !$actual_page || ($actual_page['post_type'] != 'page') ) |
| 2940 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
| 2941 | |
| 2942 | // Make sure the user is allowed to edit pages. |
| 2943 | if ( !current_user_can('edit_page', $page_id) ) |
| 2944 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this page.' ) ); |
| Line | Code |
| 2984 | $password = $args[2]; |
| 2985 | |
| 2986 | if ( !$user = $this->login($username, $password) ) |
| 2987 | return $this->error; |
| 2988 | |
| 2989 | if ( !current_user_can( 'edit_pages' ) ) |
| 2990 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit pages.' ) ); |
| 2991 | |
| 2992 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2993 | do_action( 'xmlrpc_call', 'wp.getPageList' ); |
| 2994 | |
| 2995 | // Get list of pages ids and titles |
| 2996 | $page_list = $wpdb->get_results(" |
| 2997 | SELECT ID page_id, |
| 2998 | post_title page_title, |
| 2999 | post_parent page_parent_id, |
| 3000 | post_date_gmt, |
| 3001 | post_date, |
| 3002 | post_status |
| Line | Code |
| 3040 | $password = $args[2]; |
| 3041 | |
| 3042 | if ( !$user = $this->login($username, $password) ) |
| 3043 | return $this->error; |
| 3044 | |
| 3045 | if ( !current_user_can('edit_posts') ) |
| 3046 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
| 3047 | |
| 3048 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3049 | do_action( 'xmlrpc_call', 'wp.getAuthors' ); |
| 3050 | |
| 3051 | $authors = array(); |
| 3052 | foreach ( get_users( array( 'fields' => array('ID','user_login','display_name') ) ) as $user ) { |
| 3053 | $authors[] = array( |
| 3054 | 'user_id' => $user->ID, |
| 3055 | 'user_login' => $user->user_login, |
| 3056 | 'display_name' => $user->display_name |
| 3057 | ); |
| 3058 | } |
| Line | Code |
| 3081 | $password = $args[2]; |
| 3082 | |
| 3083 | if ( !$user = $this->login($username, $password) ) |
| 3084 | return $this->error; |
| 3085 | |
| 3086 | if ( !current_user_can( 'edit_posts' ) ) |
| 3087 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view tags.' ) ); |
| 3088 | |
| 3089 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3090 | do_action( 'xmlrpc_call', 'wp.getKeywords' ); |
| 3091 | |
| 3092 | $tags = array(); |
| 3093 | |
| 3094 | if ( $all_tags = get_tags() ) { |
| 3095 | foreach ( (array) $all_tags as $tag ) { |
| 3096 | $struct = array(); |
| 3097 | $struct['tag_id'] = $tag->term_id; |
| 3098 | $struct['name'] = $tag->name; |
| 3099 | $struct['count'] = $tag->count; |
| Line | Code |
| 3128 | |
| 3129 | $username = $args[1]; |
| 3130 | $password = $args[2]; |
| 3131 | $category = $args[3]; |
| 3132 | |
| 3133 | if ( !$user = $this->login($username, $password) ) |
| 3134 | return $this->error; |
| 3135 | |
| 3136 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3137 | do_action( 'xmlrpc_call', 'wp.newCategory' ); |
| 3138 | |
| 3139 | // Make sure the user is allowed to add a category. |
| 3140 | if ( ! current_user_can( 'manage_categories' ) ) { |
| 3141 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to add a category.' ) ); |
| 3142 | } |
| 3143 | |
| 3144 | // If no slug was provided make it empty so that |
| 3145 | // WordPress will generate one. |
| 3146 | if ( empty($category['slug']) ) |
| Line | Code |
| 3205 | |
| 3206 | $username = $args[1]; |
| 3207 | $password = $args[2]; |
| 3208 | $category_id = (int) $args[3]; |
| 3209 | |
| 3210 | if ( !$user = $this->login($username, $password) ) |
| 3211 | return $this->error; |
| 3212 | |
| 3213 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3214 | do_action( 'xmlrpc_call', 'wp.deleteCategory' ); |
| 3215 | |
| 3216 | if ( ! current_user_can( 'delete_term', $category_id ) ) { |
| 3217 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this category.' ) ); |
| 3218 | } |
| 3219 | |
| 3220 | $status = wp_delete_term( $category_id, 'category' ); |
| 3221 | |
| 3222 | if ( true == $status ) { |
| 3223 | /** |
| Line | Code |
| 3259 | $max_results = (int) $args[4]; |
| 3260 | |
| 3261 | if ( !$user = $this->login($username, $password) ) |
| 3262 | return $this->error; |
| 3263 | |
| 3264 | if ( !current_user_can( 'edit_posts' ) ) |
| 3265 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
| 3266 | |
| 3267 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3268 | do_action( 'xmlrpc_call', 'wp.suggestCategories' ); |
| 3269 | |
| 3270 | $category_suggestions = array(); |
| 3271 | $args = array('get' => 'all', 'number' => $max_results, 'name__like' => $category); |
| 3272 | foreach ( (array) get_categories($args) as $cat ) { |
| 3273 | $category_suggestions[] = array( |
| 3274 | 'category_id' => $cat->term_id, |
| 3275 | 'category_name' => $cat->name |
| 3276 | ); |
| 3277 | } |
| Line | Code |
| 3300 | $username = $args[1]; |
| 3301 | $password = $args[2]; |
| 3302 | $comment_id = (int) $args[3]; |
| 3303 | |
| 3304 | if ( ! $user = $this->login( $username, $password ) ) { |
| 3305 | return $this->error; |
| 3306 | } |
| 3307 | |
| 3308 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3309 | do_action( 'xmlrpc_call', 'wp.getComment' ); |
| 3310 | |
| 3311 | if ( ! $comment = get_comment( $comment_id ) ) { |
| 3312 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 3313 | } |
| 3314 | |
| 3315 | if ( ! current_user_can( 'edit_comment', $comment_id ) ) { |
| 3316 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) ); |
| 3317 | } |
| 3318 | |
| Line | Code |
| 3351 | $username = $args[1]; |
| 3352 | $password = $args[2]; |
| 3353 | $struct = isset( $args[3] ) ? $args[3] : array(); |
| 3354 | |
| 3355 | if ( ! $user = $this->login( $username, $password ) ) { |
| 3356 | return $this->error; |
| 3357 | } |
| 3358 | |
| 3359 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3360 | do_action( 'xmlrpc_call', 'wp.getComments' ); |
| 3361 | |
| 3362 | if ( isset( $struct['status'] ) ) { |
| 3363 | $status = $struct['status']; |
| 3364 | } else { |
| 3365 | $status = ''; |
| 3366 | } |
| 3367 | |
| 3368 | if ( ! current_user_can( 'moderate_comments' ) && 'approve' !== $status ) { |
| 3369 | return new IXR_Error( 401, __( 'Invalid comment status.' ) ); |
| Line | Code |
| 3443 | if ( ! get_comment( $comment_ID ) ) { |
| 3444 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 3445 | } |
| 3446 | |
| 3447 | if ( ! current_user_can( 'edit_comment', $comment_ID ) ) { |
| 3448 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to delete this comment.' ) ); |
| 3449 | } |
| 3450 | |
| 3451 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3452 | do_action( 'xmlrpc_call', 'wp.deleteComment' ); |
| 3453 | |
| 3454 | $status = wp_delete_comment( $comment_ID ); |
| 3455 | |
| 3456 | if ( $status ) { |
| 3457 | /** |
| 3458 | * Fires after a comment has been successfully deleted via XML-RPC. |
| 3459 | * |
| 3460 | * @since 3.4.0 |
| 3461 | * |
| Line | Code |
| 3510 | if ( ! get_comment( $comment_ID ) ) { |
| 3511 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 3512 | } |
| 3513 | |
| 3514 | if ( ! current_user_can( 'edit_comment', $comment_ID ) ) { |
| 3515 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) ); |
| 3516 | } |
| 3517 | |
| 3518 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3519 | do_action( 'xmlrpc_call', 'wp.editComment' ); |
| 3520 | $comment = array( |
| 3521 | 'comment_ID' => $comment_ID, |
| 3522 | ); |
| 3523 | |
| 3524 | |
| 3525 | if ( isset($content_struct['status']) ) { |
| 3526 | $statuses = get_comment_statuses(); |
| 3527 | $statuses = array_keys($statuses); |
| 3528 | |
| Line | Code |
| 3678 | return new IXR_Error( 403, __( 'Comment author name and email are required.' ) ); |
| 3679 | elseif ( !is_email($comment['comment_author_email']) ) |
| 3680 | return new IXR_Error( 403, __( 'A valid email address is required.' ) ); |
| 3681 | } |
| 3682 | } |
| 3683 | |
| 3684 | $comment['comment_parent'] = isset($content_struct['comment_parent']) ? absint($content_struct['comment_parent']) : 0; |
| 3685 | |
| 3686 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3687 | do_action( 'xmlrpc_call', 'wp.newComment' ); |
| 3688 | |
| 3689 | $comment_ID = wp_new_comment( $comment, true ); |
| 3690 | if ( is_wp_error( $comment_ID ) ) { |
| 3691 | return new IXR_Error( 403, $comment_ID->get_error_message() ); |
| 3692 | } |
| 3693 | |
| 3694 | if ( ! $comment_ID ) { |
| 3695 | return new IXR_Error( 403, __( 'Something went wrong.' ) ); |
| 3696 | } |
| Line | Code |
| 3731 | if ( ! $user = $this->login( $username, $password ) ) { |
| 3732 | return $this->error; |
| 3733 | } |
| 3734 | |
| 3735 | if ( ! current_user_can( 'publish_posts' ) ) { |
| 3736 | return new IXR_Error( 403, __( 'Sorry, you are not allowed access to details about this site.' ) ); |
| 3737 | } |
| 3738 | |
| 3739 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3740 | do_action( 'xmlrpc_call', 'wp.getCommentStatusList' ); |
| 3741 | |
| 3742 | return get_comment_statuses(); |
| 3743 | } |
| 3744 | |
| 3745 | /** |
| 3746 | * Retrieve comment count. |
| 3747 | * |
| 3748 | * @since 2.5.0 |
| 3749 | * |
| Line | Code |
| 3772 | if ( empty( $post['ID'] ) ) { |
| 3773 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 3774 | } |
| 3775 | |
| 3776 | if ( ! current_user_can( 'edit_post', $post_id ) ) { |
| 3777 | return new IXR_Error( 403, __( 'Sorry, you are not allowed access to details of this post.' ) ); |
| 3778 | } |
| 3779 | |
| 3780 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3781 | do_action( 'xmlrpc_call', 'wp.getCommentCount' ); |
| 3782 | |
| 3783 | $count = wp_count_comments( $post_id ); |
| 3784 | |
| 3785 | return array( |
| 3786 | 'approved' => $count->approved, |
| 3787 | 'awaiting_moderation' => $count->moderated, |
| 3788 | 'spam' => $count->spam, |
| 3789 | 'total_comments' => $count->total_comments |
| 3790 | ); |
| Line | Code |
| 3811 | $password = $args[2]; |
| 3812 | |
| 3813 | if ( !$user = $this->login($username, $password) ) |
| 3814 | return $this->error; |
| 3815 | |
| 3816 | if ( !current_user_can( 'edit_posts' ) ) |
| 3817 | return new IXR_Error( 403, __( 'Sorry, you are not allowed access to details about this site.' ) ); |
| 3818 | |
| 3819 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3820 | do_action( 'xmlrpc_call', 'wp.getPostStatusList' ); |
| 3821 | |
| 3822 | return get_post_statuses(); |
| 3823 | } |
| 3824 | |
| 3825 | /** |
| 3826 | * Retrieve page statuses. |
| 3827 | * |
| 3828 | * @since 2.5.0 |
| 3829 | * |
| Line | Code |
| 3843 | $password = $args[2]; |
| 3844 | |
| 3845 | if ( !$user = $this->login($username, $password) ) |
| 3846 | return $this->error; |
| 3847 | |
| 3848 | if ( !current_user_can( 'edit_pages' ) ) |
| 3849 | return new IXR_Error( 403, __( 'Sorry, you are not allowed access to details about this site.' ) ); |
| 3850 | |
| 3851 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3852 | do_action( 'xmlrpc_call', 'wp.getPageStatusList' ); |
| 3853 | |
| 3854 | return get_page_statuses(); |
| 3855 | } |
| 3856 | |
| 3857 | /** |
| 3858 | * Retrieve page templates. |
| 3859 | * |
| 3860 | * @since 2.6.0 |
| 3861 | * |
| Line | Code |
| 4021 | $attachment_id = (int) $args[3]; |
| 4022 | |
| 4023 | if ( !$user = $this->login($username, $password) ) |
| 4024 | return $this->error; |
| 4025 | |
| 4026 | if ( !current_user_can( 'upload_files' ) ) |
| 4027 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to upload files.' ) ); |
| 4028 | |
| 4029 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4030 | do_action( 'xmlrpc_call', 'wp.getMediaItem' ); |
| 4031 | |
| 4032 | if ( ! $attachment = get_post($attachment_id) ) |
| 4033 | return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); |
| 4034 | |
| 4035 | return $this->_prepare_media_item( $attachment ); |
| 4036 | } |
| 4037 | |
| 4038 | /** |
| 4039 | * Retrieves a collection of media library items (or attachments) |
| Line | Code |
| 4069 | $struct = isset( $args[3] ) ? $args[3] : array() ; |
| 4070 | |
| 4071 | if ( !$user = $this->login($username, $password) ) |
| 4072 | return $this->error; |
| 4073 | |
| 4074 | if ( !current_user_can( 'upload_files' ) ) |
| 4075 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to upload files.' ) ); |
| 4076 | |
| 4077 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4078 | do_action( 'xmlrpc_call', 'wp.getMediaLibrary' ); |
| 4079 | |
| 4080 | $parent_id = ( isset($struct['parent_id']) ) ? absint($struct['parent_id']) : '' ; |
| 4081 | $mime_type = ( isset($struct['mime_type']) ) ? $struct['mime_type'] : '' ; |
| 4082 | $offset = ( isset($struct['offset']) ) ? absint($struct['offset']) : 0 ; |
| 4083 | $number = ( isset($struct['number']) ) ? absint($struct['number']) : -1 ; |
| 4084 | |
| 4085 | $attachments = get_posts( array('post_type' => 'attachment', 'post_parent' => $parent_id, 'offset' => $offset, 'numberposts' => $number, 'post_mime_type' => $mime_type ) ); |
| 4086 | |
| 4087 | $attachments_struct = array(); |
| Line | Code |
| 4113 | $password = $args[2]; |
| 4114 | |
| 4115 | if ( !$user = $this->login( $username, $password ) ) |
| 4116 | return $this->error; |
| 4117 | |
| 4118 | if ( !current_user_can( 'edit_posts' ) ) |
| 4119 | return new IXR_Error( 403, __( 'Sorry, you are not allowed access to details about this site.' ) ); |
| 4120 | |
| 4121 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4122 | do_action( 'xmlrpc_call', 'wp.getPostFormats' ); |
| 4123 | |
| 4124 | $formats = get_post_format_strings(); |
| 4125 | |
| 4126 | // find out if they want a list of currently supports formats |
| 4127 | if ( isset( $args[3] ) && is_array( $args[3] ) ) { |
| 4128 | if ( $args[3]['show-supported'] ) { |
| 4129 | if ( current_theme_supports( 'post-formats' ) ) { |
| 4130 | $supported = get_theme_support( 'post-formats' ); |
| 4131 | |
| Line | Code |
| 4190 | * @param string $method The method name. |
| 4191 | */ |
| 4192 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostType' ); |
| 4193 | } |
| 4194 | |
| 4195 | if ( !$user = $this->login( $username, $password ) ) |
| 4196 | return $this->error; |
| 4197 | |
| 4198 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4199 | do_action( 'xmlrpc_call', 'wp.getPostType' ); |
| 4200 | |
| 4201 | if ( ! post_type_exists( $post_type_name ) ) |
| 4202 | return new IXR_Error( 403, __( 'Invalid post type.' ) ); |
| 4203 | |
| 4204 | $post_type = get_post_type_object( $post_type_name ); |
| 4205 | |
| 4206 | if ( ! current_user_can( $post_type->cap->edit_posts ) ) |
| 4207 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts in this post type.' ) ); |
| 4208 | |
| Line | Code |
| 4242 | } else { |
| 4243 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4244 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostTypes' ); |
| 4245 | } |
| 4246 | |
| 4247 | if ( ! $user = $this->login( $username, $password ) ) |
| 4248 | return $this->error; |
| 4249 | |
| 4250 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4251 | do_action( 'xmlrpc_call', 'wp.getPostTypes' ); |
| 4252 | |
| 4253 | $post_types = get_post_types( $filter, 'objects' ); |
| 4254 | |
| 4255 | $struct = array(); |
| 4256 | |
| 4257 | foreach ( $post_types as $post_type ) { |
| 4258 | if ( ! current_user_can( $post_type->cap->edit_posts ) ) |
| 4259 | continue; |
| 4260 | |
| Line | Code |
| 4308 | * @param string $method The method name. |
| 4309 | */ |
| 4310 | $fields = apply_filters( 'xmlrpc_default_revision_fields', array( 'post_date', 'post_date_gmt' ), 'wp.getRevisions' ); |
| 4311 | } |
| 4312 | |
| 4313 | if ( ! $user = $this->login( $username, $password ) ) |
| 4314 | return $this->error; |
| 4315 | |
| 4316 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4317 | do_action( 'xmlrpc_call', 'wp.getRevisions' ); |
| 4318 | |
| 4319 | if ( ! $post = get_post( $post_id ) ) |
| 4320 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4321 | |
| 4322 | if ( ! current_user_can( 'edit_post', $post_id ) ) |
| 4323 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
| 4324 | |
| 4325 | // Check if revisions are enabled. |
| 4326 | if ( ! wp_revisions_enabled( $post ) ) |
| Line | Code |
| 4372 | |
| 4373 | $username = $args[1]; |
| 4374 | $password = $args[2]; |
| 4375 | $revision_id = (int) $args[3]; |
| 4376 | |
| 4377 | if ( ! $user = $this->login( $username, $password ) ) |
| 4378 | return $this->error; |
| 4379 | |
| 4380 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4381 | do_action( 'xmlrpc_call', 'wp.restoreRevision' ); |
| 4382 | |
| 4383 | if ( ! $revision = wp_get_post_revision( $revision_id ) ) |
| 4384 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4385 | |
| 4386 | if ( wp_is_post_autosave( $revision ) ) |
| 4387 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4388 | |
| 4389 | if ( ! $post = get_post( $revision->post_parent ) ) |
| 4390 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| Line | Code |
| 4433 | $this->escape($args); |
| 4434 | |
| 4435 | $username = $args[1]; |
| 4436 | $password = $args[2]; |
| 4437 | |
| 4438 | if ( !$user = $this->login($username, $password) ) |
| 4439 | return $this->error; |
| 4440 | |
| 4441 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4442 | do_action( 'xmlrpc_call', 'blogger.getUsersBlogs' ); |
| 4443 | |
| 4444 | $is_admin = current_user_can('manage_options'); |
| 4445 | |
| 4446 | $struct = array( |
| 4447 | 'isAdmin' => $is_admin, |
| 4448 | 'url' => get_option('home') . '/', |
| 4449 | 'blogid' => '1', |
| 4450 | 'blogName' => get_option('blogname'), |
| 4451 | 'xmlrpc' => site_url( 'xmlrpc.php', 'rpc' ), |
| Line | Code |
| 4514 | $password = $args[2]; |
| 4515 | |
| 4516 | if ( !$user = $this->login($username, $password) ) |
| 4517 | return $this->error; |
| 4518 | |
| 4519 | if ( !current_user_can( 'edit_posts' ) ) |
| 4520 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to access user data on this site.' ) ); |
| 4521 | |
| 4522 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4523 | do_action( 'xmlrpc_call', 'blogger.getUserInfo' ); |
| 4524 | |
| 4525 | $struct = array( |
| 4526 | 'nickname' => $user->nickname, |
| 4527 | 'userid' => $user->ID, |
| 4528 | 'url' => $user->user_url, |
| 4529 | 'lastname' => $user->last_name, |
| 4530 | 'firstname' => $user->first_name |
| 4531 | ); |
| 4532 | |
| Line | Code |
| 4560 | |
| 4561 | $post_data = get_post($post_ID, ARRAY_A); |
| 4562 | if ( ! $post_data ) |
| 4563 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4564 | |
| 4565 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
| 4566 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
| 4567 | |
| 4568 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4569 | do_action( 'xmlrpc_call', 'blogger.getPost' ); |
| 4570 | |
| 4571 | $categories = implode(',', wp_get_post_categories($post_ID)); |
| 4572 | |
| 4573 | $content = '<title>'.wp_unslash($post_data['post_title']).'</title>'; |
| 4574 | $content .= '<category>'.$categories.'</category>'; |
| 4575 | $content .= wp_unslash($post_data['post_content']); |
| 4576 | |
| 4577 | $struct = array( |
| 4578 | 'userid' => $post_data['post_author'], |
| Line | Code |
| 4613 | $query = array(); |
| 4614 | |
| 4615 | if ( !$user = $this->login($username, $password) ) |
| 4616 | return $this->error; |
| 4617 | |
| 4618 | if ( ! current_user_can( 'edit_posts' ) ) |
| 4619 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
| 4620 | |
| 4621 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4622 | do_action( 'xmlrpc_call', 'blogger.getRecentPosts' ); |
| 4623 | |
| 4624 | $posts_list = wp_get_recent_posts( $query ); |
| 4625 | |
| 4626 | if ( !$posts_list ) { |
| 4627 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
| 4628 | return $this->error; |
| 4629 | } |
| 4630 | |
| 4631 | $recent_posts = array(); |
| Line | Code |
| 4700 | $username = $args[2]; |
| 4701 | $password = $args[3]; |
| 4702 | $content = $args[4]; |
| 4703 | $publish = $args[5]; |
| 4704 | |
| 4705 | if ( !$user = $this->login($username, $password) ) |
| 4706 | return $this->error; |
| 4707 | |
| 4708 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4709 | do_action( 'xmlrpc_call', 'blogger.newPost' ); |
| 4710 | |
| 4711 | $cap = ($publish) ? 'publish_posts' : 'edit_posts'; |
| 4712 | if ( ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) || !current_user_can($cap) ) |
| 4713 | return new IXR_Error(401, __('Sorry, you are not allowed to post on this site.')); |
| 4714 | |
| 4715 | $post_status = ($publish) ? 'publish' : 'draft'; |
| 4716 | |
| 4717 | $post_author = $user->ID; |
| 4718 | |
| Line | Code |
| 4773 | $password = $args[3]; |
| 4774 | $content = $args[4]; |
| 4775 | $publish = $args[5]; |
| 4776 | |
| 4777 | if ( ! $user = $this->login( $username, $password ) ) { |
| 4778 | return $this->error; |
| 4779 | } |
| 4780 | |
| 4781 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4782 | do_action( 'xmlrpc_call', 'blogger.editPost' ); |
| 4783 | |
| 4784 | $actual_post = get_post( $post_ID, ARRAY_A ); |
| 4785 | |
| 4786 | if ( ! $actual_post || $actual_post['post_type'] != 'post' ) { |
| 4787 | return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); |
| 4788 | } |
| 4789 | |
| 4790 | $this->escape($actual_post); |
| 4791 | |
| Line | Code |
| 4845 | |
| 4846 | $post_ID = (int) $args[1]; |
| 4847 | $username = $args[2]; |
| 4848 | $password = $args[3]; |
| 4849 | |
| 4850 | if ( !$user = $this->login($username, $password) ) |
| 4851 | return $this->error; |
| 4852 | |
| 4853 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4854 | do_action( 'xmlrpc_call', 'blogger.deletePost' ); |
| 4855 | |
| 4856 | $actual_post = get_post( $post_ID, ARRAY_A ); |
| 4857 | |
| 4858 | if ( ! $actual_post || $actual_post['post_type'] != 'post' ) { |
| 4859 | return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); |
| 4860 | } |
| 4861 | |
| 4862 | if ( ! current_user_can( 'delete_post', $post_ID ) ) { |
| 4863 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) ); |
| Line | Code |
| 4930 | $username = $args[1]; |
| 4931 | $password = $args[2]; |
| 4932 | $content_struct = $args[3]; |
| 4933 | $publish = isset( $args[4] ) ? $args[4] : 0; |
| 4934 | |
| 4935 | if ( !$user = $this->login($username, $password) ) |
| 4936 | return $this->error; |
| 4937 | |
| 4938 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4939 | do_action( 'xmlrpc_call', 'metaWeblog.newPost' ); |
| 4940 | |
| 4941 | $page_template = ''; |
| 4942 | if ( !empty( $content_struct['post_type'] ) ) { |
| 4943 | if ( $content_struct['post_type'] == 'page' ) { |
| 4944 | if ( $publish ) |
| 4945 | $cap = 'publish_pages'; |
| 4946 | elseif ( isset( $content_struct['page_status'] ) && 'publish' == $content_struct['page_status'] ) |
| 4947 | $cap = 'publish_pages'; |
| 4948 | else |
| Line | Code |
| 5285 | $username = $args[1]; |
| 5286 | $password = $args[2]; |
| 5287 | $content_struct = $args[3]; |
| 5288 | $publish = isset( $args[4] ) ? $args[4] : 0; |
| 5289 | |
| 5290 | if ( ! $user = $this->login($username, $password) ) |
| 5291 | return $this->error; |
| 5292 | |
| 5293 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5294 | do_action( 'xmlrpc_call', 'metaWeblog.editPost' ); |
| 5295 | |
| 5296 | $postdata = get_post( $post_ID, ARRAY_A ); |
| 5297 | |
| 5298 | /* |
| 5299 | * If there is no post data for the give post id, stop now and return an error. |
| 5300 | * Otherwise a new post will be created (which was the old behavior). |
| 5301 | */ |
| 5302 | if ( ! $postdata || empty( $postdata[ 'ID' ] ) ) |
| 5303 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| Line | Code |
| 5599 | |
| 5600 | $postdata = get_post($post_ID, ARRAY_A); |
| 5601 | if ( ! $postdata ) |
| 5602 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 5603 | |
| 5604 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
| 5605 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
| 5606 | |
| 5607 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5608 | do_action( 'xmlrpc_call', 'metaWeblog.getPost' ); |
| 5609 | |
| 5610 | if ($postdata['post_date'] != '') { |
| 5611 | $post_date = $this->_convert_date( $postdata['post_date'] ); |
| 5612 | $post_date_gmt = $this->_convert_date_gmt( $postdata['post_date_gmt'], $postdata['post_date'] ); |
| 5613 | $post_modified = $this->_convert_date( $postdata['post_modified'] ); |
| 5614 | $post_modified_gmt = $this->_convert_date_gmt( $postdata['post_modified_gmt'], $postdata['post_modified'] ); |
| 5615 | |
| 5616 | $categories = array(); |
| 5617 | $catids = wp_get_post_categories($post_ID); |
| Line | Code |
| 5729 | $query = array(); |
| 5730 | |
| 5731 | if ( !$user = $this->login($username, $password) ) |
| 5732 | return $this->error; |
| 5733 | |
| 5734 | if ( ! current_user_can( 'edit_posts' ) ) |
| 5735 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
| 5736 | |
| 5737 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5738 | do_action( 'xmlrpc_call', 'metaWeblog.getRecentPosts' ); |
| 5739 | |
| 5740 | $posts_list = wp_get_recent_posts( $query ); |
| 5741 | |
| 5742 | if ( !$posts_list ) |
| 5743 | return array(); |
| 5744 | |
| 5745 | $recent_posts = array(); |
| 5746 | foreach ($posts_list as $entry) { |
| 5747 | if ( !current_user_can( 'edit_post', $entry['ID'] ) ) |
| Line | Code |
| 5842 | $password = $args[2]; |
| 5843 | |
| 5844 | if ( !$user = $this->login($username, $password) ) |
| 5845 | return $this->error; |
| 5846 | |
| 5847 | if ( !current_user_can( 'edit_posts' ) ) |
| 5848 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
| 5849 | |
| 5850 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5851 | do_action( 'xmlrpc_call', 'metaWeblog.getCategories' ); |
| 5852 | |
| 5853 | $categories_struct = array(); |
| 5854 | |
| 5855 | if ( $cats = get_categories(array('get' => 'all')) ) { |
| 5856 | foreach ( $cats as $cat ) { |
| 5857 | $struct = array(); |
| 5858 | $struct['categoryId'] = $cat->term_id; |
| 5859 | $struct['parentId'] = $cat->parent; |
| 5860 | $struct['description'] = $cat->name; |
| Line | Code |
| 5900 | |
| 5901 | $name = sanitize_file_name( $data['name'] ); |
| 5902 | $type = $data['type']; |
| 5903 | $bits = $data['bits']; |
| 5904 | |
| 5905 | if ( !$user = $this->login($username, $password) ) |
| 5906 | return $this->error; |
| 5907 | |
| 5908 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5909 | do_action( 'xmlrpc_call', 'metaWeblog.newMediaObject' ); |
| 5910 | |
| 5911 | if ( !current_user_can('upload_files') ) { |
| 5912 | $this->error = new IXR_Error( 401, __( 'Sorry, you are not allowed to upload files.' ) ); |
| 5913 | return $this->error; |
| 5914 | } |
| 5915 | |
| 5916 | if ( is_multisite() && upload_is_user_over_quota( false ) ) { |
| 5917 | $this->error = new IXR_Error( 401, __( 'Sorry, you have used your space allocation.' ) ); |
| 5918 | return $this->error; |
| Line | Code |
| 6006 | if ( isset( $args[3] ) ) |
| 6007 | $query = array( 'numberposts' => absint( $args[3] ) ); |
| 6008 | else |
| 6009 | $query = array(); |
| 6010 | |
| 6011 | if ( !$user = $this->login($username, $password) ) |
| 6012 | return $this->error; |
| 6013 | |
| 6014 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6015 | do_action( 'xmlrpc_call', 'mt.getRecentPostTitles' ); |
| 6016 | |
| 6017 | $posts_list = wp_get_recent_posts( $query ); |
| 6018 | |
| 6019 | if ( !$posts_list ) { |
| 6020 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
| 6021 | return $this->error; |
| 6022 | } |
| 6023 | |
| 6024 | $recent_posts = array(); |
| Line | Code |
| 6064 | $password = $args[2]; |
| 6065 | |
| 6066 | if ( !$user = $this->login($username, $password) ) |
| 6067 | return $this->error; |
| 6068 | |
| 6069 | if ( !current_user_can( 'edit_posts' ) ) |
| 6070 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
| 6071 | |
| 6072 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6073 | do_action( 'xmlrpc_call', 'mt.getCategoryList' ); |
| 6074 | |
| 6075 | $categories_struct = array(); |
| 6076 | |
| 6077 | if ( $cats = get_categories(array('hide_empty' => 0, 'hierarchical' => 0)) ) { |
| 6078 | foreach ( $cats as $cat ) { |
| 6079 | $struct = array(); |
| 6080 | $struct['categoryId'] = $cat->term_id; |
| 6081 | $struct['categoryName'] = $cat->name; |
| 6082 | |
| Line | Code |
| 6112 | return $this->error; |
| 6113 | |
| 6114 | if ( ! get_post( $post_ID ) ) |
| 6115 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 6116 | |
| 6117 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
| 6118 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
| 6119 | |
| 6120 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6121 | do_action( 'xmlrpc_call', 'mt.getPostCategories' ); |
| 6122 | |
| 6123 | $categories = array(); |
| 6124 | $catids = wp_get_post_categories(intval($post_ID)); |
| 6125 | // first listed category will be the primary category |
| 6126 | $isPrimary = true; |
| 6127 | foreach ( $catids as $catid ) { |
| 6128 | $categories[] = array( |
| 6129 | 'categoryName' => get_cat_name($catid), |
| 6130 | 'categoryId' => (string) $catid, |
| Line | Code |
| 6157 | $post_ID = (int) $args[0]; |
| 6158 | $username = $args[1]; |
| 6159 | $password = $args[2]; |
| 6160 | $categories = $args[3]; |
| 6161 | |
| 6162 | if ( !$user = $this->login($username, $password) ) |
| 6163 | return $this->error; |
| 6164 | |
| 6165 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6166 | do_action( 'xmlrpc_call', 'mt.setPostCategories' ); |
| 6167 | |
| 6168 | if ( ! get_post( $post_ID ) ) |
| 6169 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 6170 | |
| 6171 | if ( !current_user_can('edit_post', $post_ID) ) |
| 6172 | return new IXR_Error(401, __('Sorry, you are not allowed to edit this post.')); |
| 6173 | |
| 6174 | $catids = array(); |
| 6175 | foreach ( $categories as $cat ) { |
| Line | Code |
| 6184 | /** |
| 6185 | * Retrieve an array of methods supported by this server. |
| 6186 | * |
| 6187 | * @since 1.5.0 |
| 6188 | * |
| 6189 | * @return array |
| 6190 | */ |
| 6191 | public function mt_supportedMethods() { |
| 6192 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6193 | do_action( 'xmlrpc_call', 'mt.supportedMethods' ); |
| 6194 | |
| 6195 | return array_keys( $this->methods ); |
| 6196 | } |
| 6197 | |
| 6198 | /** |
| 6199 | * Retrieve an empty array because we don't support per-post text filters. |
| 6200 | * |
| 6201 | * @since 1.5.0 |
| 6202 | */ |
| 6203 | public function mt_supportedTextFilters() { |
| 6204 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6205 | do_action( 'xmlrpc_call', 'mt.supportedTextFilters' ); |
| 6206 | |
| 6207 | /** |
| 6208 | * Filters the MoveableType text filters list for XML-RPC. |
| 6209 | * |
| 6210 | * @since 2.2.0 |
| 6211 | * |
| 6212 | * @param array $filters An array of text filters. |
| 6213 | */ |
| 6214 | return apply_filters( 'xmlrpc_text_filters', array() ); |
| Line | Code |
| 6222 | * @global wpdb $wpdb WordPress database abstraction object. |
| 6223 | * |
| 6224 | * @param int $post_ID |
| 6225 | * @return array|IXR_Error |
| 6226 | */ |
| 6227 | public function mt_getTrackbackPings( $post_ID ) { |
| 6228 | global $wpdb; |
| 6229 | |
| 6230 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6231 | do_action( 'xmlrpc_call', 'mt.getTrackbackPings' ); |
| 6232 | |
| 6233 | $actual_post = get_post($post_ID, ARRAY_A); |
| 6234 | |
| 6235 | if ( !$actual_post ) |
| 6236 | return new IXR_Error(404, __('Sorry, no such post.')); |
| 6237 | |
| 6238 | $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) ); |
| 6239 | |
| 6240 | if ( !$comments ) |
| Line | Code |
| 6275 | |
| 6276 | $post_ID = (int) $args[0]; |
| 6277 | $username = $args[1]; |
| 6278 | $password = $args[2]; |
| 6279 | |
| 6280 | if ( !$user = $this->login($username, $password) ) |
| 6281 | return $this->error; |
| 6282 | |
| 6283 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6284 | do_action( 'xmlrpc_call', 'mt.publishPost' ); |
| 6285 | |
| 6286 | $postdata = get_post($post_ID, ARRAY_A); |
| 6287 | if ( ! $postdata ) |
| 6288 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 6289 | |
| 6290 | if ( !current_user_can('publish_posts') || !current_user_can('edit_post', $post_ID) ) |
| 6291 | return new IXR_Error(401, __('Sorry, you are not allowed to publish this post.')); |
| 6292 | |
| 6293 | $postdata['post_status'] = 'publish'; |
| Line | Code |
| 6315 | * @type string $pagelinkedfrom |
| 6316 | * @type string $pagelinkedto |
| 6317 | * } |
| 6318 | * @return string|IXR_Error |
| 6319 | */ |
| 6320 | public function pingback_ping( $args ) { |
| 6321 | global $wpdb; |
| 6322 | |
| 6323 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6324 | do_action( 'xmlrpc_call', 'pingback.ping' ); |
| 6325 | |
| 6326 | $this->escape( $args ); |
| 6327 | |
| 6328 | $pagelinkedfrom = str_replace( '&', '&', $args[0] ); |
| 6329 | $pagelinkedto = str_replace( '&', '&', $args[1] ); |
| 6330 | $pagelinkedto = str_replace( '&', '&', $pagelinkedto ); |
| 6331 | |
| 6332 | /** |
| 6333 | * Filters the pingback source URI. |
| Line | Code |
| 6531 | * @global wpdb $wpdb WordPress database abstraction object. |
| 6532 | * |
| 6533 | * @param string $url |
| 6534 | * @return array|IXR_Error |
| 6535 | */ |
| 6536 | public function pingback_extensions_getPingbacks( $url ) { |
| 6537 | global $wpdb; |
| 6538 | |
| 6539 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6540 | do_action( 'xmlrpc_call', 'pingback.extensions.getPingbacks' ); |
| 6541 | |
| 6542 | $url = $this->escape( $url ); |
| 6543 | |
| 6544 | $post_ID = url_to_postid($url); |
| 6545 | if ( !$post_ID ) { |
| 6546 | // We aren't sure that the resource is available and/or pingback enabled |
| 6547 | 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.' ) ); |
| 6548 | } |
| 6549 | |