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 |
|---|---|
| 615 | * the method logic begins. |
| 616 | * |
| 617 | * All built-in XML-RPC methods use the action xmlrpc_call, with a parameter |
| 618 | * equal to the method's name, e.g., wp.getUsersBlogs, wp.newPost, etc. |
| 619 | * |
| 620 | * @since 2.5.0 |
| 621 | * |
| 622 | * @param string $name The method name. |
| 623 | */ |
| 624 | do_action( 'xmlrpc_call', 'wp.getUsersBlogs' ); |
| 625 | |
| 626 | $blogs = (array) get_blogs_of_user( $user->ID ); |
| 627 | $struct = array(); |
| 628 | $primary_blog_id = 0; |
| 629 | $active_blog = get_active_blog_for_user( $user->ID ); |
| 630 | if ( $active_blog ) { |
| 631 | $primary_blog_id = (int) $active_blog->blog_id; |
| 632 | } |
| 633 | |
| Line | Code |
| 1225 | if ( isset( $content_struct['post_date_gmt'] ) && ! ( $content_struct['post_date_gmt'] instanceof IXR_Date ) ) { |
| 1226 | if ( $content_struct['post_date_gmt'] == '0000-00-00 00:00:00' || isset( $content_struct['post_date'] ) ) { |
| 1227 | unset( $content_struct['post_date_gmt'] ); |
| 1228 | } else { |
| 1229 | $content_struct['post_date_gmt'] = $this->_convert_date( $content_struct['post_date_gmt'] ); |
| 1230 | } |
| 1231 | } |
| 1232 | |
| 1233 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1234 | do_action( 'xmlrpc_call', 'wp.newPost' ); |
| 1235 | |
| 1236 | unset( $content_struct['ID'] ); |
| 1237 | |
| 1238 | return $this->_insert_post( $user, $content_struct ); |
| 1239 | } |
| 1240 | |
| 1241 | /** |
| 1242 | * Helper method for filtering out elements from an array. |
| 1243 | * |
| Line | Code |
| 1579 | $username = $args[1]; |
| 1580 | $password = $args[2]; |
| 1581 | $post_id = (int) $args[3]; |
| 1582 | $content_struct = $args[4]; |
| 1583 | |
| 1584 | if ( ! $user = $this->login( $username, $password ) ) |
| 1585 | return $this->error; |
| 1586 | |
| 1587 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1588 | do_action( 'xmlrpc_call', 'wp.editPost' ); |
| 1589 | |
| 1590 | $post = get_post( $post_id, ARRAY_A ); |
| 1591 | |
| 1592 | if ( empty( $post['ID'] ) ) |
| 1593 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 1594 | |
| 1595 | if ( isset( $content_struct['if_not_modified_since'] ) ) { |
| 1596 | // If the post has been modified since the date provided, return an error. |
| 1597 | if ( mysql2date( 'U', $post['post_modified_gmt'] ) > $content_struct['if_not_modified_since']->getTimestamp() ) { |
| Line | Code |
| 1646 | |
| 1647 | $username = $args[1]; |
| 1648 | $password = $args[2]; |
| 1649 | $post_id = (int) $args[3]; |
| 1650 | |
| 1651 | if ( ! $user = $this->login( $username, $password ) ) |
| 1652 | return $this->error; |
| 1653 | |
| 1654 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1655 | do_action( 'xmlrpc_call', 'wp.deletePost' ); |
| 1656 | |
| 1657 | $post = get_post( $post_id, ARRAY_A ); |
| 1658 | if ( empty( $post['ID'] ) ) { |
| 1659 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 1660 | } |
| 1661 | |
| 1662 | if ( ! current_user_can( 'delete_post', $post_id ) ) { |
| 1663 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) ); |
| 1664 | } |
| Line | Code |
| 1743 | * @param string $method Method name. |
| 1744 | */ |
| 1745 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPost' ); |
| 1746 | } |
| 1747 | |
| 1748 | if ( ! $user = $this->login( $username, $password ) ) |
| 1749 | return $this->error; |
| 1750 | |
| 1751 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1752 | do_action( 'xmlrpc_call', 'wp.getPost' ); |
| 1753 | |
| 1754 | $post = get_post( $post_id, ARRAY_A ); |
| 1755 | |
| 1756 | if ( empty( $post['ID'] ) ) |
| 1757 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 1758 | |
| 1759 | if ( ! current_user_can( 'edit_post', $post_id ) ) |
| 1760 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
| 1761 | |
| Line | Code |
| 1799 | } else { |
| 1800 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1801 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPosts' ); |
| 1802 | } |
| 1803 | |
| 1804 | if ( ! $user = $this->login( $username, $password ) ) |
| 1805 | return $this->error; |
| 1806 | |
| 1807 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1808 | do_action( 'xmlrpc_call', 'wp.getPosts' ); |
| 1809 | |
| 1810 | $query = array(); |
| 1811 | |
| 1812 | if ( isset( $filter['post_type'] ) ) { |
| 1813 | $post_type = get_post_type_object( $filter['post_type'] ); |
| 1814 | if ( ! ( (bool) $post_type ) ) |
| 1815 | return new IXR_Error( 403, __( 'Invalid post type.' ) ); |
| 1816 | } else { |
| 1817 | $post_type = get_post_type_object( 'post' ); |
| Line | Code |
| 1887 | |
| 1888 | $username = $args[1]; |
| 1889 | $password = $args[2]; |
| 1890 | $content_struct = $args[3]; |
| 1891 | |
| 1892 | if ( ! $user = $this->login( $username, $password ) ) |
| 1893 | return $this->error; |
| 1894 | |
| 1895 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1896 | do_action( 'xmlrpc_call', 'wp.newTerm' ); |
| 1897 | |
| 1898 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) |
| 1899 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 1900 | |
| 1901 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
| 1902 | |
| 1903 | if ( ! current_user_can( $taxonomy->cap->edit_terms ) ) { |
| 1904 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to create terms in this taxonomy.' ) ); |
| 1905 | } |
| Line | Code |
| 1975 | $username = $args[1]; |
| 1976 | $password = $args[2]; |
| 1977 | $term_id = (int) $args[3]; |
| 1978 | $content_struct = $args[4]; |
| 1979 | |
| 1980 | if ( ! $user = $this->login( $username, $password ) ) |
| 1981 | return $this->error; |
| 1982 | |
| 1983 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1984 | do_action( 'xmlrpc_call', 'wp.editTerm' ); |
| 1985 | |
| 1986 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) |
| 1987 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 1988 | |
| 1989 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
| 1990 | |
| 1991 | $taxonomy = (array) $taxonomy; |
| 1992 | |
| 1993 | // hold the data of the term |
| Line | Code |
| 2072 | $username = $args[1]; |
| 2073 | $password = $args[2]; |
| 2074 | $taxonomy = $args[3]; |
| 2075 | $term_id = (int) $args[4]; |
| 2076 | |
| 2077 | if ( ! $user = $this->login( $username, $password ) ) |
| 2078 | return $this->error; |
| 2079 | |
| 2080 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2081 | do_action( 'xmlrpc_call', 'wp.deleteTerm' ); |
| 2082 | |
| 2083 | if ( ! taxonomy_exists( $taxonomy ) ) |
| 2084 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 2085 | |
| 2086 | $taxonomy = get_taxonomy( $taxonomy ); |
| 2087 | $term = get_term( $term_id, $taxonomy->name ); |
| 2088 | |
| 2089 | if ( is_wp_error( $term ) ) |
| 2090 | return new IXR_Error( 500, $term->get_error_message() ); |
| Line | Code |
| 2143 | $username = $args[1]; |
| 2144 | $password = $args[2]; |
| 2145 | $taxonomy = $args[3]; |
| 2146 | $term_id = (int) $args[4]; |
| 2147 | |
| 2148 | if ( ! $user = $this->login( $username, $password ) ) |
| 2149 | return $this->error; |
| 2150 | |
| 2151 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2152 | do_action( 'xmlrpc_call', 'wp.getTerm' ); |
| 2153 | |
| 2154 | if ( ! taxonomy_exists( $taxonomy ) ) |
| 2155 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 2156 | |
| 2157 | $taxonomy = get_taxonomy( $taxonomy ); |
| 2158 | |
| 2159 | $term = get_term( $term_id , $taxonomy->name, ARRAY_A ); |
| 2160 | |
| 2161 | if ( is_wp_error( $term ) ) |
| Line | Code |
| 2202 | $username = $args[1]; |
| 2203 | $password = $args[2]; |
| 2204 | $taxonomy = $args[3]; |
| 2205 | $filter = isset( $args[4] ) ? $args[4] : array(); |
| 2206 | |
| 2207 | if ( ! $user = $this->login( $username, $password ) ) |
| 2208 | return $this->error; |
| 2209 | |
| 2210 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2211 | do_action( 'xmlrpc_call', 'wp.getTerms' ); |
| 2212 | |
| 2213 | if ( ! taxonomy_exists( $taxonomy ) ) |
| 2214 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 2215 | |
| 2216 | $taxonomy = get_taxonomy( $taxonomy ); |
| 2217 | |
| 2218 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
| 2219 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ) ); |
| 2220 | |
| Line | Code |
| 2297 | * @param string $method The method name. |
| 2298 | */ |
| 2299 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomy' ); |
| 2300 | } |
| 2301 | |
| 2302 | if ( ! $user = $this->login( $username, $password ) ) |
| 2303 | return $this->error; |
| 2304 | |
| 2305 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2306 | do_action( 'xmlrpc_call', 'wp.getTaxonomy' ); |
| 2307 | |
| 2308 | if ( ! taxonomy_exists( $taxonomy ) ) |
| 2309 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 2310 | |
| 2311 | $taxonomy = get_taxonomy( $taxonomy ); |
| 2312 | |
| 2313 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
| 2314 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ) ); |
| 2315 | |
| Line | Code |
| 2350 | } else { |
| 2351 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2352 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomies' ); |
| 2353 | } |
| 2354 | |
| 2355 | if ( ! $user = $this->login( $username, $password ) ) |
| 2356 | return $this->error; |
| 2357 | |
| 2358 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2359 | do_action( 'xmlrpc_call', 'wp.getTaxonomies' ); |
| 2360 | |
| 2361 | $taxonomies = get_taxonomies( $filter, 'objects' ); |
| 2362 | |
| 2363 | // holds all the taxonomy data |
| 2364 | $struct = array(); |
| 2365 | |
| 2366 | foreach ( $taxonomies as $taxonomy ) { |
| 2367 | // capability check for post_types |
| 2368 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
| Line | Code |
| 2432 | * @param string $method The method name. |
| 2433 | */ |
| 2434 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUser' ); |
| 2435 | } |
| 2436 | |
| 2437 | if ( ! $user = $this->login( $username, $password ) ) |
| 2438 | return $this->error; |
| 2439 | |
| 2440 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2441 | do_action( 'xmlrpc_call', 'wp.getUser' ); |
| 2442 | |
| 2443 | if ( ! current_user_can( 'edit_user', $user_id ) ) |
| 2444 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this user.' ) ); |
| 2445 | |
| 2446 | $user_data = get_userdata( $user_id ); |
| 2447 | |
| 2448 | if ( ! $user_data ) |
| 2449 | return new IXR_Error( 404, __( 'Invalid user ID.' ) ); |
| 2450 | |
| Line | Code |
| 2490 | } else { |
| 2491 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2492 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUsers' ); |
| 2493 | } |
| 2494 | |
| 2495 | if ( ! $user = $this->login( $username, $password ) ) |
| 2496 | return $this->error; |
| 2497 | |
| 2498 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2499 | do_action( 'xmlrpc_call', 'wp.getUsers' ); |
| 2500 | |
| 2501 | if ( ! current_user_can( 'list_users' ) ) |
| 2502 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to list users.' ) ); |
| 2503 | |
| 2504 | $query = array( 'fields' => 'all_with_meta' ); |
| 2505 | |
| 2506 | $query['number'] = ( isset( $filter['number'] ) ) ? absint( $filter['number'] ) : 50; |
| 2507 | $query['offset'] = ( isset( $filter['offset'] ) ) ? absint( $filter['offset'] ) : 0; |
| 2508 | |
| Line | Code |
| 2563 | } else { |
| 2564 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2565 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getProfile' ); |
| 2566 | } |
| 2567 | |
| 2568 | if ( ! $user = $this->login( $username, $password ) ) |
| 2569 | return $this->error; |
| 2570 | |
| 2571 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2572 | do_action( 'xmlrpc_call', 'wp.getProfile' ); |
| 2573 | |
| 2574 | if ( ! current_user_can( 'edit_user', $user->ID ) ) |
| 2575 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit your profile.' ) ); |
| 2576 | |
| 2577 | $user_data = get_userdata( $user->ID ); |
| 2578 | |
| 2579 | return $this->_prepare_user( $user_data, $fields ); |
| 2580 | } |
| 2581 | |
| Line | Code |
| 2609 | |
| 2610 | $username = $args[1]; |
| 2611 | $password = $args[2]; |
| 2612 | $content_struct = $args[3]; |
| 2613 | |
| 2614 | if ( ! $user = $this->login( $username, $password ) ) |
| 2615 | return $this->error; |
| 2616 | |
| 2617 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2618 | do_action( 'xmlrpc_call', 'wp.editProfile' ); |
| 2619 | |
| 2620 | if ( ! current_user_can( 'edit_user', $user->ID ) ) |
| 2621 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit your profile.' ) ); |
| 2622 | |
| 2623 | // holds data of the user |
| 2624 | $user_data = array(); |
| 2625 | $user_data['ID'] = $user->ID; |
| 2626 | |
| 2627 | // only set the user details if it was given |
| Line | Code |
| 2685 | |
| 2686 | $page = get_post($page_id); |
| 2687 | if ( ! $page ) |
| 2688 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 2689 | |
| 2690 | if ( !current_user_can( 'edit_page', $page_id ) ) |
| 2691 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this page.' ) ); |
| 2692 | |
| 2693 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2694 | do_action( 'xmlrpc_call', 'wp.getPage' ); |
| 2695 | |
| 2696 | // If we found the page then format the data. |
| 2697 | if ( $page->ID && ($page->post_type == 'page') ) { |
| 2698 | return $this->_prepare_page( $page ); |
| 2699 | } |
| 2700 | // If the page doesn't exist indicate that. |
| 2701 | else { |
| 2702 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
| 2703 | } |
| Line | Code |
| 2726 | $num_pages = isset($args[3]) ? (int) $args[3] : 10; |
| 2727 | |
| 2728 | if ( !$user = $this->login($username, $password) ) |
| 2729 | return $this->error; |
| 2730 | |
| 2731 | if ( !current_user_can( 'edit_pages' ) ) |
| 2732 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit pages.' ) ); |
| 2733 | |
| 2734 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2735 | do_action( 'xmlrpc_call', 'wp.getPages' ); |
| 2736 | |
| 2737 | $pages = get_posts( array('post_type' => 'page', 'post_status' => 'any', 'numberposts' => $num_pages) ); |
| 2738 | $num_pages = count($pages); |
| 2739 | |
| 2740 | // If we have pages, put together their info. |
| 2741 | if ( $num_pages >= 1 ) { |
| 2742 | $pages_struct = array(); |
| 2743 | |
| 2744 | foreach ($pages as $page) { |
| Line | Code |
| 2772 | public function wp_newPage( $args ) { |
| 2773 | // Items not escaped here will be escaped in newPost. |
| 2774 | $username = $this->escape( $args[1] ); |
| 2775 | $password = $this->escape( $args[2] ); |
| 2776 | |
| 2777 | if ( !$user = $this->login($username, $password) ) |
| 2778 | return $this->error; |
| 2779 | |
| 2780 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2781 | do_action( 'xmlrpc_call', 'wp.newPage' ); |
| 2782 | |
| 2783 | // Mark this as content for a page. |
| 2784 | $args[3]["post_type"] = 'page'; |
| 2785 | |
| 2786 | // Let mw_newPost do all of the heavy lifting. |
| 2787 | return $this->mw_newPost( $args ); |
| 2788 | } |
| 2789 | |
| 2790 | /** |
| Line | Code |
| 2807 | |
| 2808 | $username = $args[1]; |
| 2809 | $password = $args[2]; |
| 2810 | $page_id = (int) $args[3]; |
| 2811 | |
| 2812 | if ( !$user = $this->login($username, $password) ) |
| 2813 | return $this->error; |
| 2814 | |
| 2815 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2816 | do_action( 'xmlrpc_call', 'wp.deletePage' ); |
| 2817 | |
| 2818 | // Get the current page based on the page_id and |
| 2819 | // make sure it is a page and not a post. |
| 2820 | $actual_page = get_post($page_id, ARRAY_A); |
| 2821 | if ( !$actual_page || ($actual_page['post_type'] != 'page') ) |
| 2822 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
| 2823 | |
| 2824 | // Make sure the user can delete pages. |
| 2825 | if ( !current_user_can('delete_page', $page_id) ) |
| Line | Code |
| 2870 | |
| 2871 | $escaped_username = $this->escape( $username ); |
| 2872 | $escaped_password = $this->escape( $password ); |
| 2873 | |
| 2874 | if ( !$user = $this->login( $escaped_username, $escaped_password ) ) { |
| 2875 | return $this->error; |
| 2876 | } |
| 2877 | |
| 2878 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2879 | do_action( 'xmlrpc_call', 'wp.editPage' ); |
| 2880 | |
| 2881 | // Get the page data and make sure it is a page. |
| 2882 | $actual_page = get_post($page_id, ARRAY_A); |
| 2883 | if ( !$actual_page || ($actual_page['post_type'] != 'page') ) |
| 2884 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
| 2885 | |
| 2886 | // Make sure the user is allowed to edit pages. |
| 2887 | if ( !current_user_can('edit_page', $page_id) ) |
| 2888 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this page.' ) ); |
| Line | Code |
| 2928 | $password = $args[2]; |
| 2929 | |
| 2930 | if ( !$user = $this->login($username, $password) ) |
| 2931 | return $this->error; |
| 2932 | |
| 2933 | if ( !current_user_can( 'edit_pages' ) ) |
| 2934 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit pages.' ) ); |
| 2935 | |
| 2936 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2937 | do_action( 'xmlrpc_call', 'wp.getPageList' ); |
| 2938 | |
| 2939 | // Get list of pages ids and titles |
| 2940 | $page_list = $wpdb->get_results(" |
| 2941 | SELECT ID page_id, |
| 2942 | post_title page_title, |
| 2943 | post_parent page_parent_id, |
| 2944 | post_date_gmt, |
| 2945 | post_date, |
| 2946 | post_status |
| 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_posts') ) |
| 2990 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
| 2991 | |
| 2992 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2993 | do_action( 'xmlrpc_call', 'wp.getAuthors' ); |
| 2994 | |
| 2995 | $authors = array(); |
| 2996 | foreach ( get_users( array( 'fields' => array('ID','user_login','display_name') ) ) as $user ) { |
| 2997 | $authors[] = array( |
| 2998 | 'user_id' => $user->ID, |
| 2999 | 'user_login' => $user->user_login, |
| 3000 | 'display_name' => $user->display_name |
| 3001 | ); |
| 3002 | } |
| Line | Code |
| 3025 | $password = $args[2]; |
| 3026 | |
| 3027 | if ( !$user = $this->login($username, $password) ) |
| 3028 | return $this->error; |
| 3029 | |
| 3030 | if ( !current_user_can( 'edit_posts' ) ) |
| 3031 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view tags.' ) ); |
| 3032 | |
| 3033 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3034 | do_action( 'xmlrpc_call', 'wp.getKeywords' ); |
| 3035 | |
| 3036 | $tags = array(); |
| 3037 | |
| 3038 | if ( $all_tags = get_tags() ) { |
| 3039 | foreach ( (array) $all_tags as $tag ) { |
| 3040 | $struct = array(); |
| 3041 | $struct['tag_id'] = $tag->term_id; |
| 3042 | $struct['name'] = $tag->name; |
| 3043 | $struct['count'] = $tag->count; |
| Line | Code |
| 3072 | |
| 3073 | $username = $args[1]; |
| 3074 | $password = $args[2]; |
| 3075 | $category = $args[3]; |
| 3076 | |
| 3077 | if ( !$user = $this->login($username, $password) ) |
| 3078 | return $this->error; |
| 3079 | |
| 3080 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3081 | do_action( 'xmlrpc_call', 'wp.newCategory' ); |
| 3082 | |
| 3083 | // Make sure the user is allowed to add a category. |
| 3084 | if ( !current_user_can('manage_categories') ) |
| 3085 | return new IXR_Error(401, __('Sorry, you are not allowed to add a category.')); |
| 3086 | |
| 3087 | // If no slug was provided make it empty so that |
| 3088 | // WordPress will generate one. |
| 3089 | if ( empty($category['slug']) ) |
| 3090 | $category['slug'] = ''; |
| Line | Code |
| 3148 | |
| 3149 | $username = $args[1]; |
| 3150 | $password = $args[2]; |
| 3151 | $category_id = (int) $args[3]; |
| 3152 | |
| 3153 | if ( !$user = $this->login($username, $password) ) |
| 3154 | return $this->error; |
| 3155 | |
| 3156 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3157 | do_action( 'xmlrpc_call', 'wp.deleteCategory' ); |
| 3158 | |
| 3159 | if ( !current_user_can('manage_categories') ) |
| 3160 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete a category.' ) ); |
| 3161 | |
| 3162 | $status = wp_delete_term( $category_id, 'category' ); |
| 3163 | |
| 3164 | if ( true == $status ) { |
| 3165 | /** |
| 3166 | * Fires after a category has been successfully deleted via XML-RPC. |
| Line | Code |
| 3201 | $max_results = (int) $args[4]; |
| 3202 | |
| 3203 | if ( !$user = $this->login($username, $password) ) |
| 3204 | return $this->error; |
| 3205 | |
| 3206 | if ( !current_user_can( 'edit_posts' ) ) |
| 3207 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
| 3208 | |
| 3209 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3210 | do_action( 'xmlrpc_call', 'wp.suggestCategories' ); |
| 3211 | |
| 3212 | $category_suggestions = array(); |
| 3213 | $args = array('get' => 'all', 'number' => $max_results, 'name__like' => $category); |
| 3214 | foreach ( (array) get_categories($args) as $cat ) { |
| 3215 | $category_suggestions[] = array( |
| 3216 | 'category_id' => $cat->term_id, |
| 3217 | 'category_name' => $cat->name |
| 3218 | ); |
| 3219 | } |
| Line | Code |
| 3242 | $username = $args[1]; |
| 3243 | $password = $args[2]; |
| 3244 | $comment_id = (int) $args[3]; |
| 3245 | |
| 3246 | if ( ! $user = $this->login( $username, $password ) ) { |
| 3247 | return $this->error; |
| 3248 | } |
| 3249 | |
| 3250 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3251 | do_action( 'xmlrpc_call', 'wp.getComment' ); |
| 3252 | |
| 3253 | if ( ! $comment = get_comment( $comment_id ) ) { |
| 3254 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 3255 | } |
| 3256 | |
| 3257 | if ( ! current_user_can( 'edit_comment', $comment_id ) ) { |
| 3258 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) ); |
| 3259 | } |
| 3260 | |
| Line | Code |
| 3293 | $username = $args[1]; |
| 3294 | $password = $args[2]; |
| 3295 | $struct = isset( $args[3] ) ? $args[3] : array(); |
| 3296 | |
| 3297 | if ( ! $user = $this->login( $username, $password ) ) { |
| 3298 | return $this->error; |
| 3299 | } |
| 3300 | |
| 3301 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3302 | do_action( 'xmlrpc_call', 'wp.getComments' ); |
| 3303 | |
| 3304 | if ( isset( $struct['status'] ) ) { |
| 3305 | $status = $struct['status']; |
| 3306 | } else { |
| 3307 | $status = ''; |
| 3308 | } |
| 3309 | |
| 3310 | if ( ! current_user_can( 'moderate_comments' ) && 'approve' !== $status ) { |
| 3311 | return new IXR_Error( 401, __( 'Invalid comment status.' ) ); |
| Line | Code |
| 3385 | if ( ! get_comment( $comment_ID ) ) { |
| 3386 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 3387 | } |
| 3388 | |
| 3389 | if ( !current_user_can( 'edit_comment', $comment_ID ) ) { |
| 3390 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) ); |
| 3391 | } |
| 3392 | |
| 3393 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3394 | do_action( 'xmlrpc_call', 'wp.deleteComment' ); |
| 3395 | |
| 3396 | $status = wp_delete_comment( $comment_ID ); |
| 3397 | |
| 3398 | if ( $status ) { |
| 3399 | /** |
| 3400 | * Fires after a comment has been successfully deleted via XML-RPC. |
| 3401 | * |
| 3402 | * @since 3.4.0 |
| 3403 | * |
| Line | Code |
| 3452 | if ( ! get_comment( $comment_ID ) ) { |
| 3453 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 3454 | } |
| 3455 | |
| 3456 | if ( ! current_user_can( 'edit_comment', $comment_ID ) ) { |
| 3457 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) ); |
| 3458 | } |
| 3459 | |
| 3460 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3461 | do_action( 'xmlrpc_call', 'wp.editComment' ); |
| 3462 | |
| 3463 | if ( isset($content_struct['status']) ) { |
| 3464 | $statuses = get_comment_statuses(); |
| 3465 | $statuses = array_keys($statuses); |
| 3466 | |
| 3467 | if ( ! in_array($content_struct['status'], $statuses) ) |
| 3468 | return new IXR_Error( 401, __( 'Invalid comment status.' ) ); |
| 3469 | $comment_approved = $content_struct['status']; |
| 3470 | } |
| Line | Code |
| 3614 | return new IXR_Error( 403, __( 'Comment author name and email are required.' ) ); |
| 3615 | elseif ( !is_email($comment['comment_author_email']) ) |
| 3616 | return new IXR_Error( 403, __( 'A valid email address is required.' ) ); |
| 3617 | } |
| 3618 | } |
| 3619 | |
| 3620 | $comment['comment_parent'] = isset($content_struct['comment_parent']) ? absint($content_struct['comment_parent']) : 0; |
| 3621 | |
| 3622 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3623 | do_action( 'xmlrpc_call', 'wp.newComment' ); |
| 3624 | |
| 3625 | $comment_ID = wp_new_comment( $comment, true ); |
| 3626 | if ( is_wp_error( $comment_ID ) ) { |
| 3627 | return new IXR_Error( 403, $comment_ID->get_error_message() ); |
| 3628 | } |
| 3629 | |
| 3630 | if ( ! $comment_ID ) { |
| 3631 | return new IXR_Error( 403, __( 'An unknown error occurred' ) ); |
| 3632 | } |
| Line | Code |
| 3667 | if ( ! $user = $this->login( $username, $password ) ) { |
| 3668 | return $this->error; |
| 3669 | } |
| 3670 | |
| 3671 | if ( ! current_user_can( 'publish_posts' ) ) { |
| 3672 | return new IXR_Error( 403, __( 'Sorry, you are not allowed access to details about this site.' ) ); |
| 3673 | } |
| 3674 | |
| 3675 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3676 | do_action( 'xmlrpc_call', 'wp.getCommentStatusList' ); |
| 3677 | |
| 3678 | return get_comment_statuses(); |
| 3679 | } |
| 3680 | |
| 3681 | /** |
| 3682 | * Retrieve comment count. |
| 3683 | * |
| 3684 | * @since 2.5.0 |
| 3685 | * |
| Line | Code |
| 3708 | if ( empty( $post['ID'] ) ) { |
| 3709 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 3710 | } |
| 3711 | |
| 3712 | if ( ! current_user_can( 'edit_post', $post_id ) ) { |
| 3713 | return new IXR_Error( 403, __( 'Sorry, you are not allowed access to details of this post.' ) ); |
| 3714 | } |
| 3715 | |
| 3716 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3717 | do_action( 'xmlrpc_call', 'wp.getCommentCount' ); |
| 3718 | |
| 3719 | $count = wp_count_comments( $post_id ); |
| 3720 | |
| 3721 | return array( |
| 3722 | 'approved' => $count->approved, |
| 3723 | 'awaiting_moderation' => $count->moderated, |
| 3724 | 'spam' => $count->spam, |
| 3725 | 'total_comments' => $count->total_comments |
| 3726 | ); |
| Line | Code |
| 3747 | $password = $args[2]; |
| 3748 | |
| 3749 | if ( !$user = $this->login($username, $password) ) |
| 3750 | return $this->error; |
| 3751 | |
| 3752 | if ( !current_user_can( 'edit_posts' ) ) |
| 3753 | return new IXR_Error( 403, __( 'Sorry, you are not allowed access to details about this site.' ) ); |
| 3754 | |
| 3755 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3756 | do_action( 'xmlrpc_call', 'wp.getPostStatusList' ); |
| 3757 | |
| 3758 | return get_post_statuses(); |
| 3759 | } |
| 3760 | |
| 3761 | /** |
| 3762 | * Retrieve page statuses. |
| 3763 | * |
| 3764 | * @since 2.5.0 |
| 3765 | * |
| Line | Code |
| 3779 | $password = $args[2]; |
| 3780 | |
| 3781 | if ( !$user = $this->login($username, $password) ) |
| 3782 | return $this->error; |
| 3783 | |
| 3784 | if ( !current_user_can( 'edit_pages' ) ) |
| 3785 | return new IXR_Error( 403, __( 'Sorry, you are not allowed access to details about this site.' ) ); |
| 3786 | |
| 3787 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3788 | do_action( 'xmlrpc_call', 'wp.getPageStatusList' ); |
| 3789 | |
| 3790 | return get_page_statuses(); |
| 3791 | } |
| 3792 | |
| 3793 | /** |
| 3794 | * Retrieve page templates. |
| 3795 | * |
| 3796 | * @since 2.6.0 |
| 3797 | * |
| Line | Code |
| 3957 | $attachment_id = (int) $args[3]; |
| 3958 | |
| 3959 | if ( !$user = $this->login($username, $password) ) |
| 3960 | return $this->error; |
| 3961 | |
| 3962 | if ( !current_user_can( 'upload_files' ) ) |
| 3963 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to upload files.' ) ); |
| 3964 | |
| 3965 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3966 | do_action( 'xmlrpc_call', 'wp.getMediaItem' ); |
| 3967 | |
| 3968 | if ( ! $attachment = get_post($attachment_id) ) |
| 3969 | return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); |
| 3970 | |
| 3971 | return $this->_prepare_media_item( $attachment ); |
| 3972 | } |
| 3973 | |
| 3974 | /** |
| 3975 | * Retrieves a collection of media library items (or attachments) |
| Line | Code |
| 4005 | $struct = isset( $args[3] ) ? $args[3] : array() ; |
| 4006 | |
| 4007 | if ( !$user = $this->login($username, $password) ) |
| 4008 | return $this->error; |
| 4009 | |
| 4010 | if ( !current_user_can( 'upload_files' ) ) |
| 4011 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to upload files.' ) ); |
| 4012 | |
| 4013 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4014 | do_action( 'xmlrpc_call', 'wp.getMediaLibrary' ); |
| 4015 | |
| 4016 | $parent_id = ( isset($struct['parent_id']) ) ? absint($struct['parent_id']) : '' ; |
| 4017 | $mime_type = ( isset($struct['mime_type']) ) ? $struct['mime_type'] : '' ; |
| 4018 | $offset = ( isset($struct['offset']) ) ? absint($struct['offset']) : 0 ; |
| 4019 | $number = ( isset($struct['number']) ) ? absint($struct['number']) : -1 ; |
| 4020 | |
| 4021 | $attachments = get_posts( array('post_type' => 'attachment', 'post_parent' => $parent_id, 'offset' => $offset, 'numberposts' => $number, 'post_mime_type' => $mime_type ) ); |
| 4022 | |
| 4023 | $attachments_struct = array(); |
| Line | Code |
| 4049 | $password = $args[2]; |
| 4050 | |
| 4051 | if ( !$user = $this->login( $username, $password ) ) |
| 4052 | return $this->error; |
| 4053 | |
| 4054 | if ( !current_user_can( 'edit_posts' ) ) |
| 4055 | return new IXR_Error( 403, __( 'Sorry, you are not allowed access to details about this site.' ) ); |
| 4056 | |
| 4057 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4058 | do_action( 'xmlrpc_call', 'wp.getPostFormats' ); |
| 4059 | |
| 4060 | $formats = get_post_format_strings(); |
| 4061 | |
| 4062 | // find out if they want a list of currently supports formats |
| 4063 | if ( isset( $args[3] ) && is_array( $args[3] ) ) { |
| 4064 | if ( $args[3]['show-supported'] ) { |
| 4065 | if ( current_theme_supports( 'post-formats' ) ) { |
| 4066 | $supported = get_theme_support( 'post-formats' ); |
| 4067 | |
| Line | Code |
| 4126 | * @param string $method The method name. |
| 4127 | */ |
| 4128 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostType' ); |
| 4129 | } |
| 4130 | |
| 4131 | if ( !$user = $this->login( $username, $password ) ) |
| 4132 | return $this->error; |
| 4133 | |
| 4134 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4135 | do_action( 'xmlrpc_call', 'wp.getPostType' ); |
| 4136 | |
| 4137 | if ( ! post_type_exists( $post_type_name ) ) |
| 4138 | return new IXR_Error( 403, __( 'Invalid post type.' ) ); |
| 4139 | |
| 4140 | $post_type = get_post_type_object( $post_type_name ); |
| 4141 | |
| 4142 | if ( ! current_user_can( $post_type->cap->edit_posts ) ) |
| 4143 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts in this post type.' ) ); |
| 4144 | |
| Line | Code |
| 4178 | } else { |
| 4179 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4180 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostTypes' ); |
| 4181 | } |
| 4182 | |
| 4183 | if ( ! $user = $this->login( $username, $password ) ) |
| 4184 | return $this->error; |
| 4185 | |
| 4186 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4187 | do_action( 'xmlrpc_call', 'wp.getPostTypes' ); |
| 4188 | |
| 4189 | $post_types = get_post_types( $filter, 'objects' ); |
| 4190 | |
| 4191 | $struct = array(); |
| 4192 | |
| 4193 | foreach ( $post_types as $post_type ) { |
| 4194 | if ( ! current_user_can( $post_type->cap->edit_posts ) ) |
| 4195 | continue; |
| 4196 | |
| Line | Code |
| 4244 | * @param string $method The method name. |
| 4245 | */ |
| 4246 | $fields = apply_filters( 'xmlrpc_default_revision_fields', array( 'post_date', 'post_date_gmt' ), 'wp.getRevisions' ); |
| 4247 | } |
| 4248 | |
| 4249 | if ( ! $user = $this->login( $username, $password ) ) |
| 4250 | return $this->error; |
| 4251 | |
| 4252 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4253 | do_action( 'xmlrpc_call', 'wp.getRevisions' ); |
| 4254 | |
| 4255 | if ( ! $post = get_post( $post_id ) ) |
| 4256 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4257 | |
| 4258 | if ( ! current_user_can( 'edit_post', $post_id ) ) |
| 4259 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
| 4260 | |
| 4261 | // Check if revisions are enabled. |
| 4262 | if ( ! wp_revisions_enabled( $post ) ) |
| Line | Code |
| 4308 | |
| 4309 | $username = $args[1]; |
| 4310 | $password = $args[2]; |
| 4311 | $revision_id = (int) $args[3]; |
| 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.restoreRevision' ); |
| 4318 | |
| 4319 | if ( ! $revision = wp_get_post_revision( $revision_id ) ) |
| 4320 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4321 | |
| 4322 | if ( wp_is_post_autosave( $revision ) ) |
| 4323 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4324 | |
| 4325 | if ( ! $post = get_post( $revision->post_parent ) ) |
| 4326 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| Line | Code |
| 4369 | $this->escape($args); |
| 4370 | |
| 4371 | $username = $args[1]; |
| 4372 | $password = $args[2]; |
| 4373 | |
| 4374 | if ( !$user = $this->login($username, $password) ) |
| 4375 | return $this->error; |
| 4376 | |
| 4377 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4378 | do_action( 'xmlrpc_call', 'blogger.getUsersBlogs' ); |
| 4379 | |
| 4380 | $is_admin = current_user_can('manage_options'); |
| 4381 | |
| 4382 | $struct = array( |
| 4383 | 'isAdmin' => $is_admin, |
| 4384 | 'url' => get_option('home') . '/', |
| 4385 | 'blogid' => '1', |
| 4386 | 'blogName' => get_option('blogname'), |
| 4387 | 'xmlrpc' => site_url( 'xmlrpc.php', 'rpc' ), |
| Line | Code |
| 4451 | $password = $args[2]; |
| 4452 | |
| 4453 | if ( !$user = $this->login($username, $password) ) |
| 4454 | return $this->error; |
| 4455 | |
| 4456 | if ( !current_user_can( 'edit_posts' ) ) |
| 4457 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to access user data on this site.' ) ); |
| 4458 | |
| 4459 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4460 | do_action( 'xmlrpc_call', 'blogger.getUserInfo' ); |
| 4461 | |
| 4462 | $struct = array( |
| 4463 | 'nickname' => $user->nickname, |
| 4464 | 'userid' => $user->ID, |
| 4465 | 'url' => $user->user_url, |
| 4466 | 'lastname' => $user->last_name, |
| 4467 | 'firstname' => $user->first_name |
| 4468 | ); |
| 4469 | |
| Line | Code |
| 4497 | |
| 4498 | $post_data = get_post($post_ID, ARRAY_A); |
| 4499 | if ( ! $post_data ) |
| 4500 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4501 | |
| 4502 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
| 4503 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
| 4504 | |
| 4505 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4506 | do_action( 'xmlrpc_call', 'blogger.getPost' ); |
| 4507 | |
| 4508 | $categories = implode(',', wp_get_post_categories($post_ID)); |
| 4509 | |
| 4510 | $content = '<title>'.wp_unslash($post_data['post_title']).'</title>'; |
| 4511 | $content .= '<category>'.$categories.'</category>'; |
| 4512 | $content .= wp_unslash($post_data['post_content']); |
| 4513 | |
| 4514 | $struct = array( |
| 4515 | 'userid' => $post_data['post_author'], |
| Line | Code |
| 4550 | $query = array(); |
| 4551 | |
| 4552 | if ( !$user = $this->login($username, $password) ) |
| 4553 | return $this->error; |
| 4554 | |
| 4555 | if ( ! current_user_can( 'edit_posts' ) ) |
| 4556 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
| 4557 | |
| 4558 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4559 | do_action( 'xmlrpc_call', 'blogger.getRecentPosts' ); |
| 4560 | |
| 4561 | $posts_list = wp_get_recent_posts( $query ); |
| 4562 | |
| 4563 | if ( !$posts_list ) { |
| 4564 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
| 4565 | return $this->error; |
| 4566 | } |
| 4567 | |
| 4568 | $recent_posts = array(); |
| Line | Code |
| 4637 | $username = $args[2]; |
| 4638 | $password = $args[3]; |
| 4639 | $content = $args[4]; |
| 4640 | $publish = $args[5]; |
| 4641 | |
| 4642 | if ( !$user = $this->login($username, $password) ) |
| 4643 | return $this->error; |
| 4644 | |
| 4645 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4646 | do_action( 'xmlrpc_call', 'blogger.newPost' ); |
| 4647 | |
| 4648 | $cap = ($publish) ? 'publish_posts' : 'edit_posts'; |
| 4649 | if ( ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) || !current_user_can($cap) ) |
| 4650 | return new IXR_Error(401, __('Sorry, you are not allowed to post on this site.')); |
| 4651 | |
| 4652 | $post_status = ($publish) ? 'publish' : 'draft'; |
| 4653 | |
| 4654 | $post_author = $user->ID; |
| 4655 | |
| Line | Code |
| 4710 | $password = $args[3]; |
| 4711 | $content = $args[4]; |
| 4712 | $publish = $args[5]; |
| 4713 | |
| 4714 | if ( ! $user = $this->login( $username, $password ) ) { |
| 4715 | return $this->error; |
| 4716 | } |
| 4717 | |
| 4718 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4719 | do_action( 'xmlrpc_call', 'blogger.editPost' ); |
| 4720 | |
| 4721 | $actual_post = get_post( $post_ID, ARRAY_A ); |
| 4722 | |
| 4723 | if ( ! $actual_post || $actual_post['post_type'] != 'post' ) { |
| 4724 | return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); |
| 4725 | } |
| 4726 | |
| 4727 | $this->escape($actual_post); |
| 4728 | |
| Line | Code |
| 4782 | |
| 4783 | $post_ID = (int) $args[1]; |
| 4784 | $username = $args[2]; |
| 4785 | $password = $args[3]; |
| 4786 | |
| 4787 | if ( !$user = $this->login($username, $password) ) |
| 4788 | return $this->error; |
| 4789 | |
| 4790 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4791 | do_action( 'xmlrpc_call', 'blogger.deletePost' ); |
| 4792 | |
| 4793 | $actual_post = get_post( $post_ID, ARRAY_A ); |
| 4794 | |
| 4795 | if ( ! $actual_post || $actual_post['post_type'] != 'post' ) { |
| 4796 | return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); |
| 4797 | } |
| 4798 | |
| 4799 | if ( ! current_user_can( 'delete_post', $post_ID ) ) { |
| 4800 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) ); |
| Line | Code |
| 4867 | $username = $args[1]; |
| 4868 | $password = $args[2]; |
| 4869 | $content_struct = $args[3]; |
| 4870 | $publish = isset( $args[4] ) ? $args[4] : 0; |
| 4871 | |
| 4872 | if ( !$user = $this->login($username, $password) ) |
| 4873 | return $this->error; |
| 4874 | |
| 4875 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4876 | do_action( 'xmlrpc_call', 'metaWeblog.newPost' ); |
| 4877 | |
| 4878 | $page_template = ''; |
| 4879 | if ( !empty( $content_struct['post_type'] ) ) { |
| 4880 | if ( $content_struct['post_type'] == 'page' ) { |
| 4881 | if ( $publish ) |
| 4882 | $cap = 'publish_pages'; |
| 4883 | elseif ( isset( $content_struct['page_status'] ) && 'publish' == $content_struct['page_status'] ) |
| 4884 | $cap = 'publish_pages'; |
| 4885 | else |
| Line | Code |
| 5213 | $username = $args[1]; |
| 5214 | $password = $args[2]; |
| 5215 | $content_struct = $args[3]; |
| 5216 | $publish = isset( $args[4] ) ? $args[4] : 0; |
| 5217 | |
| 5218 | if ( ! $user = $this->login($username, $password) ) |
| 5219 | return $this->error; |
| 5220 | |
| 5221 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5222 | do_action( 'xmlrpc_call', 'metaWeblog.editPost' ); |
| 5223 | |
| 5224 | $postdata = get_post( $post_ID, ARRAY_A ); |
| 5225 | |
| 5226 | /* |
| 5227 | * If there is no post data for the give post id, stop now and return an error. |
| 5228 | * Otherwise a new post will be created (which was the old behavior). |
| 5229 | */ |
| 5230 | if ( ! $postdata || empty( $postdata[ 'ID' ] ) ) |
| 5231 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| Line | Code |
| 5525 | |
| 5526 | $postdata = get_post($post_ID, ARRAY_A); |
| 5527 | if ( ! $postdata ) |
| 5528 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 5529 | |
| 5530 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
| 5531 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
| 5532 | |
| 5533 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5534 | do_action( 'xmlrpc_call', 'metaWeblog.getPost' ); |
| 5535 | |
| 5536 | if ($postdata['post_date'] != '') { |
| 5537 | $post_date = $this->_convert_date( $postdata['post_date'] ); |
| 5538 | $post_date_gmt = $this->_convert_date_gmt( $postdata['post_date_gmt'], $postdata['post_date'] ); |
| 5539 | $post_modified = $this->_convert_date( $postdata['post_modified'] ); |
| 5540 | $post_modified_gmt = $this->_convert_date_gmt( $postdata['post_modified_gmt'], $postdata['post_modified'] ); |
| 5541 | |
| 5542 | $categories = array(); |
| 5543 | $catids = wp_get_post_categories($post_ID); |
| Line | Code |
| 5655 | $query = array(); |
| 5656 | |
| 5657 | if ( !$user = $this->login($username, $password) ) |
| 5658 | return $this->error; |
| 5659 | |
| 5660 | if ( ! current_user_can( 'edit_posts' ) ) |
| 5661 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
| 5662 | |
| 5663 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5664 | do_action( 'xmlrpc_call', 'metaWeblog.getRecentPosts' ); |
| 5665 | |
| 5666 | $posts_list = wp_get_recent_posts( $query ); |
| 5667 | |
| 5668 | if ( !$posts_list ) |
| 5669 | return array(); |
| 5670 | |
| 5671 | $recent_posts = array(); |
| 5672 | foreach ($posts_list as $entry) { |
| 5673 | if ( !current_user_can( 'edit_post', $entry['ID'] ) ) |
| Line | Code |
| 5768 | $password = $args[2]; |
| 5769 | |
| 5770 | if ( !$user = $this->login($username, $password) ) |
| 5771 | return $this->error; |
| 5772 | |
| 5773 | if ( !current_user_can( 'edit_posts' ) ) |
| 5774 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
| 5775 | |
| 5776 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5777 | do_action( 'xmlrpc_call', 'metaWeblog.getCategories' ); |
| 5778 | |
| 5779 | $categories_struct = array(); |
| 5780 | |
| 5781 | if ( $cats = get_categories(array('get' => 'all')) ) { |
| 5782 | foreach ( $cats as $cat ) { |
| 5783 | $struct = array(); |
| 5784 | $struct['categoryId'] = $cat->term_id; |
| 5785 | $struct['parentId'] = $cat->parent; |
| 5786 | $struct['description'] = $cat->name; |
| Line | Code |
| 5826 | |
| 5827 | $name = sanitize_file_name( $data['name'] ); |
| 5828 | $type = $data['type']; |
| 5829 | $bits = $data['bits']; |
| 5830 | |
| 5831 | if ( !$user = $this->login($username, $password) ) |
| 5832 | return $this->error; |
| 5833 | |
| 5834 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5835 | do_action( 'xmlrpc_call', 'metaWeblog.newMediaObject' ); |
| 5836 | |
| 5837 | if ( !current_user_can('upload_files') ) { |
| 5838 | $this->error = new IXR_Error( 401, __( 'Sorry, you are not allowed to upload files.' ) ); |
| 5839 | return $this->error; |
| 5840 | } |
| 5841 | |
| 5842 | if ( is_multisite() && upload_is_user_over_quota( false ) ) { |
| 5843 | $this->error = new IXR_Error( 401, __( 'Sorry, you have used your space allocation.' ) ); |
| 5844 | return $this->error; |
| Line | Code |
| 5932 | if ( isset( $args[3] ) ) |
| 5933 | $query = array( 'numberposts' => absint( $args[3] ) ); |
| 5934 | else |
| 5935 | $query = array(); |
| 5936 | |
| 5937 | if ( !$user = $this->login($username, $password) ) |
| 5938 | return $this->error; |
| 5939 | |
| 5940 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5941 | do_action( 'xmlrpc_call', 'mt.getRecentPostTitles' ); |
| 5942 | |
| 5943 | $posts_list = wp_get_recent_posts( $query ); |
| 5944 | |
| 5945 | if ( !$posts_list ) { |
| 5946 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
| 5947 | return $this->error; |
| 5948 | } |
| 5949 | |
| 5950 | $recent_posts = array(); |
| Line | Code |
| 5990 | $password = $args[2]; |
| 5991 | |
| 5992 | if ( !$user = $this->login($username, $password) ) |
| 5993 | return $this->error; |
| 5994 | |
| 5995 | if ( !current_user_can( 'edit_posts' ) ) |
| 5996 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
| 5997 | |
| 5998 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5999 | do_action( 'xmlrpc_call', 'mt.getCategoryList' ); |
| 6000 | |
| 6001 | $categories_struct = array(); |
| 6002 | |
| 6003 | if ( $cats = get_categories(array('hide_empty' => 0, 'hierarchical' => 0)) ) { |
| 6004 | foreach ( $cats as $cat ) { |
| 6005 | $struct = array(); |
| 6006 | $struct['categoryId'] = $cat->term_id; |
| 6007 | $struct['categoryName'] = $cat->name; |
| 6008 | |
| Line | Code |
| 6038 | return $this->error; |
| 6039 | |
| 6040 | if ( ! get_post( $post_ID ) ) |
| 6041 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 6042 | |
| 6043 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
| 6044 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
| 6045 | |
| 6046 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6047 | do_action( 'xmlrpc_call', 'mt.getPostCategories' ); |
| 6048 | |
| 6049 | $categories = array(); |
| 6050 | $catids = wp_get_post_categories(intval($post_ID)); |
| 6051 | // first listed category will be the primary category |
| 6052 | $isPrimary = true; |
| 6053 | foreach ( $catids as $catid ) { |
| 6054 | $categories[] = array( |
| 6055 | 'categoryName' => get_cat_name($catid), |
| 6056 | 'categoryId' => (string) $catid, |
| Line | Code |
| 6083 | $post_ID = (int) $args[0]; |
| 6084 | $username = $args[1]; |
| 6085 | $password = $args[2]; |
| 6086 | $categories = $args[3]; |
| 6087 | |
| 6088 | if ( !$user = $this->login($username, $password) ) |
| 6089 | return $this->error; |
| 6090 | |
| 6091 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6092 | do_action( 'xmlrpc_call', 'mt.setPostCategories' ); |
| 6093 | |
| 6094 | if ( ! get_post( $post_ID ) ) |
| 6095 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 6096 | |
| 6097 | if ( !current_user_can('edit_post', $post_ID) ) |
| 6098 | return new IXR_Error(401, __('Sorry, you are not allowed to edit this post.')); |
| 6099 | |
| 6100 | $catids = array(); |
| 6101 | foreach ( $categories as $cat ) { |
| Line | Code |
| 6110 | /** |
| 6111 | * Retrieve an array of methods supported by this server. |
| 6112 | * |
| 6113 | * @since 1.5.0 |
| 6114 | * |
| 6115 | * @return array |
| 6116 | */ |
| 6117 | public function mt_supportedMethods() { |
| 6118 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6119 | do_action( 'xmlrpc_call', 'mt.supportedMethods' ); |
| 6120 | |
| 6121 | return array_keys( $this->methods ); |
| 6122 | } |
| 6123 | |
| 6124 | /** |
| 6125 | * Retrieve an empty array because we don't support per-post text filters. |
| 6126 | * |
| 6127 | * @since 1.5.0 |
| 6128 | */ |
| 6129 | public function mt_supportedTextFilters() { |
| 6130 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6131 | do_action( 'xmlrpc_call', 'mt.supportedTextFilters' ); |
| 6132 | |
| 6133 | /** |
| 6134 | * Filters the MoveableType text filters list for XML-RPC. |
| 6135 | * |
| 6136 | * @since 2.2.0 |
| 6137 | * |
| 6138 | * @param array $filters An array of text filters. |
| 6139 | */ |
| 6140 | return apply_filters( 'xmlrpc_text_filters', array() ); |
| Line | Code |
| 6148 | * @global wpdb $wpdb WordPress database abstraction object. |
| 6149 | * |
| 6150 | * @param int $post_ID |
| 6151 | * @return array|IXR_Error |
| 6152 | */ |
| 6153 | public function mt_getTrackbackPings( $post_ID ) { |
| 6154 | global $wpdb; |
| 6155 | |
| 6156 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6157 | do_action( 'xmlrpc_call', 'mt.getTrackbackPings' ); |
| 6158 | |
| 6159 | $actual_post = get_post($post_ID, ARRAY_A); |
| 6160 | |
| 6161 | if ( !$actual_post ) |
| 6162 | return new IXR_Error(404, __('Sorry, no such post.')); |
| 6163 | |
| 6164 | $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) ); |
| 6165 | |
| 6166 | if ( !$comments ) |
| Line | Code |
| 6201 | |
| 6202 | $post_ID = (int) $args[0]; |
| 6203 | $username = $args[1]; |
| 6204 | $password = $args[2]; |
| 6205 | |
| 6206 | if ( !$user = $this->login($username, $password) ) |
| 6207 | return $this->error; |
| 6208 | |
| 6209 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6210 | do_action( 'xmlrpc_call', 'mt.publishPost' ); |
| 6211 | |
| 6212 | $postdata = get_post($post_ID, ARRAY_A); |
| 6213 | if ( ! $postdata ) |
| 6214 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 6215 | |
| 6216 | if ( !current_user_can('publish_posts') || !current_user_can('edit_post', $post_ID) ) |
| 6217 | return new IXR_Error(401, __('Sorry, you are not allowed to publish this post.')); |
| 6218 | |
| 6219 | $postdata['post_status'] = 'publish'; |
| Line | Code |
| 6241 | * @type string $pagelinkedfrom |
| 6242 | * @type string $pagelinkedto |
| 6243 | * } |
| 6244 | * @return string|IXR_Error |
| 6245 | */ |
| 6246 | public function pingback_ping( $args ) { |
| 6247 | global $wpdb; |
| 6248 | |
| 6249 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6250 | do_action( 'xmlrpc_call', 'pingback.ping' ); |
| 6251 | |
| 6252 | $this->escape( $args ); |
| 6253 | |
| 6254 | $pagelinkedfrom = str_replace( '&', '&', $args[0] ); |
| 6255 | $pagelinkedto = str_replace( '&', '&', $args[1] ); |
| 6256 | $pagelinkedto = str_replace( '&', '&', $pagelinkedto ); |
| 6257 | |
| 6258 | /** |
| 6259 | * Filters the pingback source URI. |
| Line | Code |
| 6453 | * @global wpdb $wpdb WordPress database abstraction object. |
| 6454 | * |
| 6455 | * @param string $url |
| 6456 | * @return array|IXR_Error |
| 6457 | */ |
| 6458 | public function pingback_extensions_getPingbacks( $url ) { |
| 6459 | global $wpdb; |
| 6460 | |
| 6461 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6462 | do_action( 'xmlrpc_call', 'pingback.extensions.getPingbacks' ); |
| 6463 | |
| 6464 | $url = $this->escape( $url ); |
| 6465 | |
| 6466 | $post_ID = url_to_postid($url); |
| 6467 | if ( !$post_ID ) { |
| 6468 | // We aren't sure that the resource is available and/or pingback enabled |
| 6469 | 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.' ) ); |
| 6470 | } |
| 6471 | |