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 |
|---|---|
| 610 | * the method logic begins. |
| 611 | * |
| 612 | * All built-in XML-RPC methods use the action xmlrpc_call, with a parameter |
| 613 | * equal to the method's name, e.g., wp.getUsersBlogs, wp.newPost, etc. |
| 614 | * |
| 615 | * @since 2.5.0 |
| 616 | * |
| 617 | * @param string $name The method name. |
| 618 | */ |
| 619 | do_action( 'xmlrpc_call', 'wp.getUsersBlogs' ); |
| 620 | |
| 621 | $blogs = (array) get_blogs_of_user( $user->ID ); |
| 622 | $struct = array(); |
| 623 | $primary_blog_id = 0; |
| 624 | $active_blog = get_active_blog_for_user( $user->ID ); |
| 625 | if ( $active_blog ) { |
| 626 | $primary_blog_id = (int) $active_blog->blog_id; |
| 627 | } |
| 628 | |
| Line | Code |
| 1220 | if ( isset( $content_struct['post_date_gmt'] ) && ! ( $content_struct['post_date_gmt'] instanceof IXR_Date ) ) { |
| 1221 | if ( $content_struct['post_date_gmt'] == '0000-00-00 00:00:00' || isset( $content_struct['post_date'] ) ) { |
| 1222 | unset( $content_struct['post_date_gmt'] ); |
| 1223 | } else { |
| 1224 | $content_struct['post_date_gmt'] = $this->_convert_date( $content_struct['post_date_gmt'] ); |
| 1225 | } |
| 1226 | } |
| 1227 | |
| 1228 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1229 | do_action( 'xmlrpc_call', 'wp.newPost' ); |
| 1230 | |
| 1231 | unset( $content_struct['ID'] ); |
| 1232 | |
| 1233 | return $this->_insert_post( $user, $content_struct ); |
| 1234 | } |
| 1235 | |
| 1236 | /** |
| 1237 | * Helper method for filtering out elements from an array. |
| 1238 | * |
| Line | Code |
| 1556 | $username = $args[1]; |
| 1557 | $password = $args[2]; |
| 1558 | $post_id = (int) $args[3]; |
| 1559 | $content_struct = $args[4]; |
| 1560 | |
| 1561 | if ( ! $user = $this->login( $username, $password ) ) |
| 1562 | return $this->error; |
| 1563 | |
| 1564 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1565 | do_action( 'xmlrpc_call', 'wp.editPost' ); |
| 1566 | |
| 1567 | $post = get_post( $post_id, ARRAY_A ); |
| 1568 | |
| 1569 | if ( empty( $post['ID'] ) ) |
| 1570 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 1571 | |
| 1572 | if ( isset( $content_struct['if_not_modified_since'] ) ) { |
| 1573 | // If the post has been modified since the date provided, return an error. |
| 1574 | if ( mysql2date( 'U', $post['post_modified_gmt'] ) > $content_struct['if_not_modified_since']->getTimestamp() ) { |
| Line | Code |
| 1623 | |
| 1624 | $username = $args[1]; |
| 1625 | $password = $args[2]; |
| 1626 | $post_id = (int) $args[3]; |
| 1627 | |
| 1628 | if ( ! $user = $this->login( $username, $password ) ) |
| 1629 | return $this->error; |
| 1630 | |
| 1631 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1632 | do_action( 'xmlrpc_call', 'wp.deletePost' ); |
| 1633 | |
| 1634 | $post = get_post( $post_id, ARRAY_A ); |
| 1635 | if ( empty( $post['ID'] ) ) { |
| 1636 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 1637 | } |
| 1638 | |
| 1639 | if ( ! current_user_can( 'delete_post', $post_id ) ) { |
| 1640 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) ); |
| 1641 | } |
| Line | Code |
| 1720 | * @param string $method Method name. |
| 1721 | */ |
| 1722 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPost' ); |
| 1723 | } |
| 1724 | |
| 1725 | if ( ! $user = $this->login( $username, $password ) ) |
| 1726 | return $this->error; |
| 1727 | |
| 1728 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1729 | do_action( 'xmlrpc_call', 'wp.getPost' ); |
| 1730 | |
| 1731 | $post = get_post( $post_id, ARRAY_A ); |
| 1732 | |
| 1733 | if ( empty( $post['ID'] ) ) |
| 1734 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 1735 | |
| 1736 | if ( ! current_user_can( 'edit_post', $post_id ) ) |
| 1737 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
| 1738 | |
| Line | Code |
| 1776 | } else { |
| 1777 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1778 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPosts' ); |
| 1779 | } |
| 1780 | |
| 1781 | if ( ! $user = $this->login( $username, $password ) ) |
| 1782 | return $this->error; |
| 1783 | |
| 1784 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1785 | do_action( 'xmlrpc_call', 'wp.getPosts' ); |
| 1786 | |
| 1787 | $query = array(); |
| 1788 | |
| 1789 | if ( isset( $filter['post_type'] ) ) { |
| 1790 | $post_type = get_post_type_object( $filter['post_type'] ); |
| 1791 | if ( ! ( (bool) $post_type ) ) |
| 1792 | return new IXR_Error( 403, __( 'Invalid post type.' ) ); |
| 1793 | } else { |
| 1794 | $post_type = get_post_type_object( 'post' ); |
| Line | Code |
| 1864 | |
| 1865 | $username = $args[1]; |
| 1866 | $password = $args[2]; |
| 1867 | $content_struct = $args[3]; |
| 1868 | |
| 1869 | if ( ! $user = $this->login( $username, $password ) ) |
| 1870 | return $this->error; |
| 1871 | |
| 1872 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1873 | do_action( 'xmlrpc_call', 'wp.newTerm' ); |
| 1874 | |
| 1875 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) |
| 1876 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 1877 | |
| 1878 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
| 1879 | |
| 1880 | if ( ! current_user_can( $taxonomy->cap->edit_terms ) ) { |
| 1881 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to create terms in this taxonomy.' ) ); |
| 1882 | } |
| Line | Code |
| 1952 | $username = $args[1]; |
| 1953 | $password = $args[2]; |
| 1954 | $term_id = (int) $args[3]; |
| 1955 | $content_struct = $args[4]; |
| 1956 | |
| 1957 | if ( ! $user = $this->login( $username, $password ) ) |
| 1958 | return $this->error; |
| 1959 | |
| 1960 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1961 | do_action( 'xmlrpc_call', 'wp.editTerm' ); |
| 1962 | |
| 1963 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) |
| 1964 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 1965 | |
| 1966 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
| 1967 | |
| 1968 | $taxonomy = (array) $taxonomy; |
| 1969 | |
| 1970 | // hold the data of the term |
| Line | Code |
| 2049 | $username = $args[1]; |
| 2050 | $password = $args[2]; |
| 2051 | $taxonomy = $args[3]; |
| 2052 | $term_id = (int) $args[4]; |
| 2053 | |
| 2054 | if ( ! $user = $this->login( $username, $password ) ) |
| 2055 | return $this->error; |
| 2056 | |
| 2057 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2058 | do_action( 'xmlrpc_call', 'wp.deleteTerm' ); |
| 2059 | |
| 2060 | if ( ! taxonomy_exists( $taxonomy ) ) |
| 2061 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 2062 | |
| 2063 | $taxonomy = get_taxonomy( $taxonomy ); |
| 2064 | $term = get_term( $term_id, $taxonomy->name ); |
| 2065 | |
| 2066 | if ( is_wp_error( $term ) ) |
| 2067 | return new IXR_Error( 500, $term->get_error_message() ); |
| Line | Code |
| 2120 | $username = $args[1]; |
| 2121 | $password = $args[2]; |
| 2122 | $taxonomy = $args[3]; |
| 2123 | $term_id = (int) $args[4]; |
| 2124 | |
| 2125 | if ( ! $user = $this->login( $username, $password ) ) |
| 2126 | return $this->error; |
| 2127 | |
| 2128 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2129 | do_action( 'xmlrpc_call', 'wp.getTerm' ); |
| 2130 | |
| 2131 | if ( ! taxonomy_exists( $taxonomy ) ) |
| 2132 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 2133 | |
| 2134 | $taxonomy = get_taxonomy( $taxonomy ); |
| 2135 | |
| 2136 | $term = get_term( $term_id , $taxonomy->name, ARRAY_A ); |
| 2137 | |
| 2138 | if ( is_wp_error( $term ) ) |
| Line | Code |
| 2179 | $username = $args[1]; |
| 2180 | $password = $args[2]; |
| 2181 | $taxonomy = $args[3]; |
| 2182 | $filter = isset( $args[4] ) ? $args[4] : array(); |
| 2183 | |
| 2184 | if ( ! $user = $this->login( $username, $password ) ) |
| 2185 | return $this->error; |
| 2186 | |
| 2187 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2188 | do_action( 'xmlrpc_call', 'wp.getTerms' ); |
| 2189 | |
| 2190 | if ( ! taxonomy_exists( $taxonomy ) ) |
| 2191 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 2192 | |
| 2193 | $taxonomy = get_taxonomy( $taxonomy ); |
| 2194 | |
| 2195 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
| 2196 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ) ); |
| 2197 | |
| Line | Code |
| 2274 | * @param string $method The method name. |
| 2275 | */ |
| 2276 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomy' ); |
| 2277 | } |
| 2278 | |
| 2279 | if ( ! $user = $this->login( $username, $password ) ) |
| 2280 | return $this->error; |
| 2281 | |
| 2282 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2283 | do_action( 'xmlrpc_call', 'wp.getTaxonomy' ); |
| 2284 | |
| 2285 | if ( ! taxonomy_exists( $taxonomy ) ) |
| 2286 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
| 2287 | |
| 2288 | $taxonomy = get_taxonomy( $taxonomy ); |
| 2289 | |
| 2290 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
| 2291 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ) ); |
| 2292 | |
| Line | Code |
| 2327 | } else { |
| 2328 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2329 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomies' ); |
| 2330 | } |
| 2331 | |
| 2332 | if ( ! $user = $this->login( $username, $password ) ) |
| 2333 | return $this->error; |
| 2334 | |
| 2335 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2336 | do_action( 'xmlrpc_call', 'wp.getTaxonomies' ); |
| 2337 | |
| 2338 | $taxonomies = get_taxonomies( $filter, 'objects' ); |
| 2339 | |
| 2340 | // holds all the taxonomy data |
| 2341 | $struct = array(); |
| 2342 | |
| 2343 | foreach ( $taxonomies as $taxonomy ) { |
| 2344 | // capability check for post_types |
| 2345 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
| Line | Code |
| 2409 | * @param string $method The method name. |
| 2410 | */ |
| 2411 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUser' ); |
| 2412 | } |
| 2413 | |
| 2414 | if ( ! $user = $this->login( $username, $password ) ) |
| 2415 | return $this->error; |
| 2416 | |
| 2417 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2418 | do_action( 'xmlrpc_call', 'wp.getUser' ); |
| 2419 | |
| 2420 | if ( ! current_user_can( 'edit_user', $user_id ) ) |
| 2421 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this user.' ) ); |
| 2422 | |
| 2423 | $user_data = get_userdata( $user_id ); |
| 2424 | |
| 2425 | if ( ! $user_data ) |
| 2426 | return new IXR_Error( 404, __( 'Invalid user ID.' ) ); |
| 2427 | |
| Line | Code |
| 2467 | } else { |
| 2468 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2469 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUsers' ); |
| 2470 | } |
| 2471 | |
| 2472 | if ( ! $user = $this->login( $username, $password ) ) |
| 2473 | return $this->error; |
| 2474 | |
| 2475 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2476 | do_action( 'xmlrpc_call', 'wp.getUsers' ); |
| 2477 | |
| 2478 | if ( ! current_user_can( 'list_users' ) ) |
| 2479 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to list users.' ) ); |
| 2480 | |
| 2481 | $query = array( 'fields' => 'all_with_meta' ); |
| 2482 | |
| 2483 | $query['number'] = ( isset( $filter['number'] ) ) ? absint( $filter['number'] ) : 50; |
| 2484 | $query['offset'] = ( isset( $filter['offset'] ) ) ? absint( $filter['offset'] ) : 0; |
| 2485 | |
| Line | Code |
| 2540 | } else { |
| 2541 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2542 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getProfile' ); |
| 2543 | } |
| 2544 | |
| 2545 | if ( ! $user = $this->login( $username, $password ) ) |
| 2546 | return $this->error; |
| 2547 | |
| 2548 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2549 | do_action( 'xmlrpc_call', 'wp.getProfile' ); |
| 2550 | |
| 2551 | if ( ! current_user_can( 'edit_user', $user->ID ) ) |
| 2552 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit your profile.' ) ); |
| 2553 | |
| 2554 | $user_data = get_userdata( $user->ID ); |
| 2555 | |
| 2556 | return $this->_prepare_user( $user_data, $fields ); |
| 2557 | } |
| 2558 | |
| Line | Code |
| 2586 | |
| 2587 | $username = $args[1]; |
| 2588 | $password = $args[2]; |
| 2589 | $content_struct = $args[3]; |
| 2590 | |
| 2591 | if ( ! $user = $this->login( $username, $password ) ) |
| 2592 | return $this->error; |
| 2593 | |
| 2594 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2595 | do_action( 'xmlrpc_call', 'wp.editProfile' ); |
| 2596 | |
| 2597 | if ( ! current_user_can( 'edit_user', $user->ID ) ) |
| 2598 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit your profile.' ) ); |
| 2599 | |
| 2600 | // holds data of the user |
| 2601 | $user_data = array(); |
| 2602 | $user_data['ID'] = $user->ID; |
| 2603 | |
| 2604 | // only set the user details if it was given |
| Line | Code |
| 2662 | |
| 2663 | $page = get_post($page_id); |
| 2664 | if ( ! $page ) |
| 2665 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 2666 | |
| 2667 | if ( !current_user_can( 'edit_page', $page_id ) ) |
| 2668 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this page.' ) ); |
| 2669 | |
| 2670 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2671 | do_action( 'xmlrpc_call', 'wp.getPage' ); |
| 2672 | |
| 2673 | // If we found the page then format the data. |
| 2674 | if ( $page->ID && ($page->post_type == 'page') ) { |
| 2675 | return $this->_prepare_page( $page ); |
| 2676 | } |
| 2677 | // If the page doesn't exist indicate that. |
| 2678 | else { |
| 2679 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
| 2680 | } |
| Line | Code |
| 2703 | $num_pages = isset($args[3]) ? (int) $args[3] : 10; |
| 2704 | |
| 2705 | if ( !$user = $this->login($username, $password) ) |
| 2706 | return $this->error; |
| 2707 | |
| 2708 | if ( !current_user_can( 'edit_pages' ) ) |
| 2709 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit pages.' ) ); |
| 2710 | |
| 2711 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2712 | do_action( 'xmlrpc_call', 'wp.getPages' ); |
| 2713 | |
| 2714 | $pages = get_posts( array('post_type' => 'page', 'post_status' => 'any', 'numberposts' => $num_pages) ); |
| 2715 | $num_pages = count($pages); |
| 2716 | |
| 2717 | // If we have pages, put together their info. |
| 2718 | if ( $num_pages >= 1 ) { |
| 2719 | $pages_struct = array(); |
| 2720 | |
| 2721 | foreach ($pages as $page) { |
| Line | Code |
| 2749 | public function wp_newPage( $args ) { |
| 2750 | // Items not escaped here will be escaped in newPost. |
| 2751 | $username = $this->escape( $args[1] ); |
| 2752 | $password = $this->escape( $args[2] ); |
| 2753 | |
| 2754 | if ( !$user = $this->login($username, $password) ) |
| 2755 | return $this->error; |
| 2756 | |
| 2757 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2758 | do_action( 'xmlrpc_call', 'wp.newPage' ); |
| 2759 | |
| 2760 | // Mark this as content for a page. |
| 2761 | $args[3]["post_type"] = 'page'; |
| 2762 | |
| 2763 | // Let mw_newPost do all of the heavy lifting. |
| 2764 | return $this->mw_newPost( $args ); |
| 2765 | } |
| 2766 | |
| 2767 | /** |
| Line | Code |
| 2784 | |
| 2785 | $username = $args[1]; |
| 2786 | $password = $args[2]; |
| 2787 | $page_id = (int) $args[3]; |
| 2788 | |
| 2789 | if ( !$user = $this->login($username, $password) ) |
| 2790 | return $this->error; |
| 2791 | |
| 2792 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2793 | do_action( 'xmlrpc_call', 'wp.deletePage' ); |
| 2794 | |
| 2795 | // Get the current page based on the page_id and |
| 2796 | // make sure it is a page and not a post. |
| 2797 | $actual_page = get_post($page_id, ARRAY_A); |
| 2798 | if ( !$actual_page || ($actual_page['post_type'] != 'page') ) |
| 2799 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
| 2800 | |
| 2801 | // Make sure the user can delete pages. |
| 2802 | if ( !current_user_can('delete_page', $page_id) ) |
| Line | Code |
| 2847 | |
| 2848 | $escaped_username = $this->escape( $username ); |
| 2849 | $escaped_password = $this->escape( $password ); |
| 2850 | |
| 2851 | if ( !$user = $this->login( $escaped_username, $escaped_password ) ) { |
| 2852 | return $this->error; |
| 2853 | } |
| 2854 | |
| 2855 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2856 | do_action( 'xmlrpc_call', 'wp.editPage' ); |
| 2857 | |
| 2858 | // Get the page data and make sure it is a page. |
| 2859 | $actual_page = get_post($page_id, ARRAY_A); |
| 2860 | if ( !$actual_page || ($actual_page['post_type'] != 'page') ) |
| 2861 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
| 2862 | |
| 2863 | // Make sure the user is allowed to edit pages. |
| 2864 | if ( !current_user_can('edit_page', $page_id) ) |
| 2865 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this page.' ) ); |
| Line | Code |
| 2905 | $password = $args[2]; |
| 2906 | |
| 2907 | if ( !$user = $this->login($username, $password) ) |
| 2908 | return $this->error; |
| 2909 | |
| 2910 | if ( !current_user_can( 'edit_pages' ) ) |
| 2911 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit pages.' ) ); |
| 2912 | |
| 2913 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2914 | do_action( 'xmlrpc_call', 'wp.getPageList' ); |
| 2915 | |
| 2916 | // Get list of pages ids and titles |
| 2917 | $page_list = $wpdb->get_results(" |
| 2918 | SELECT ID page_id, |
| 2919 | post_title page_title, |
| 2920 | post_parent page_parent_id, |
| 2921 | post_date_gmt, |
| 2922 | post_date, |
| 2923 | post_status |
| Line | Code |
| 2961 | $password = $args[2]; |
| 2962 | |
| 2963 | if ( !$user = $this->login($username, $password) ) |
| 2964 | return $this->error; |
| 2965 | |
| 2966 | if ( !current_user_can('edit_posts') ) |
| 2967 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
| 2968 | |
| 2969 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2970 | do_action( 'xmlrpc_call', 'wp.getAuthors' ); |
| 2971 | |
| 2972 | $authors = array(); |
| 2973 | foreach ( get_users( array( 'fields' => array('ID','user_login','display_name') ) ) as $user ) { |
| 2974 | $authors[] = array( |
| 2975 | 'user_id' => $user->ID, |
| 2976 | 'user_login' => $user->user_login, |
| 2977 | 'display_name' => $user->display_name |
| 2978 | ); |
| 2979 | } |
| Line | Code |
| 3002 | $password = $args[2]; |
| 3003 | |
| 3004 | if ( !$user = $this->login($username, $password) ) |
| 3005 | return $this->error; |
| 3006 | |
| 3007 | if ( !current_user_can( 'edit_posts' ) ) |
| 3008 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view tags.' ) ); |
| 3009 | |
| 3010 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3011 | do_action( 'xmlrpc_call', 'wp.getKeywords' ); |
| 3012 | |
| 3013 | $tags = array(); |
| 3014 | |
| 3015 | if ( $all_tags = get_tags() ) { |
| 3016 | foreach ( (array) $all_tags as $tag ) { |
| 3017 | $struct = array(); |
| 3018 | $struct['tag_id'] = $tag->term_id; |
| 3019 | $struct['name'] = $tag->name; |
| 3020 | $struct['count'] = $tag->count; |
| Line | Code |
| 3049 | |
| 3050 | $username = $args[1]; |
| 3051 | $password = $args[2]; |
| 3052 | $category = $args[3]; |
| 3053 | |
| 3054 | if ( !$user = $this->login($username, $password) ) |
| 3055 | return $this->error; |
| 3056 | |
| 3057 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3058 | do_action( 'xmlrpc_call', 'wp.newCategory' ); |
| 3059 | |
| 3060 | // Make sure the user is allowed to add a category. |
| 3061 | if ( !current_user_can('manage_categories') ) |
| 3062 | return new IXR_Error(401, __('Sorry, you are not allowed to add a category.')); |
| 3063 | |
| 3064 | // If no slug was provided make it empty so that |
| 3065 | // WordPress will generate one. |
| 3066 | if ( empty($category['slug']) ) |
| 3067 | $category['slug'] = ''; |
| Line | Code |
| 3125 | |
| 3126 | $username = $args[1]; |
| 3127 | $password = $args[2]; |
| 3128 | $category_id = (int) $args[3]; |
| 3129 | |
| 3130 | if ( !$user = $this->login($username, $password) ) |
| 3131 | return $this->error; |
| 3132 | |
| 3133 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3134 | do_action( 'xmlrpc_call', 'wp.deleteCategory' ); |
| 3135 | |
| 3136 | if ( !current_user_can('manage_categories') ) |
| 3137 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete a category.' ) ); |
| 3138 | |
| 3139 | $status = wp_delete_term( $category_id, 'category' ); |
| 3140 | |
| 3141 | if ( true == $status ) { |
| 3142 | /** |
| 3143 | * Fires after a category has been successfully deleted via XML-RPC. |
| Line | Code |
| 3178 | $max_results = (int) $args[4]; |
| 3179 | |
| 3180 | if ( !$user = $this->login($username, $password) ) |
| 3181 | return $this->error; |
| 3182 | |
| 3183 | if ( !current_user_can( 'edit_posts' ) ) |
| 3184 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
| 3185 | |
| 3186 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3187 | do_action( 'xmlrpc_call', 'wp.suggestCategories' ); |
| 3188 | |
| 3189 | $category_suggestions = array(); |
| 3190 | $args = array('get' => 'all', 'number' => $max_results, 'name__like' => $category); |
| 3191 | foreach ( (array) get_categories($args) as $cat ) { |
| 3192 | $category_suggestions[] = array( |
| 3193 | 'category_id' => $cat->term_id, |
| 3194 | 'category_name' => $cat->name |
| 3195 | ); |
| 3196 | } |
| Line | Code |
| 3219 | $username = $args[1]; |
| 3220 | $password = $args[2]; |
| 3221 | $comment_id = (int) $args[3]; |
| 3222 | |
| 3223 | if ( ! $user = $this->login( $username, $password ) ) { |
| 3224 | return $this->error; |
| 3225 | } |
| 3226 | |
| 3227 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3228 | do_action( 'xmlrpc_call', 'wp.getComment' ); |
| 3229 | |
| 3230 | if ( ! $comment = get_comment( $comment_id ) ) { |
| 3231 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 3232 | } |
| 3233 | |
| 3234 | if ( ! current_user_can( 'edit_comment', $comment_id ) ) { |
| 3235 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) ); |
| 3236 | } |
| 3237 | |
| Line | Code |
| 3270 | $username = $args[1]; |
| 3271 | $password = $args[2]; |
| 3272 | $struct = isset( $args[3] ) ? $args[3] : array(); |
| 3273 | |
| 3274 | if ( ! $user = $this->login( $username, $password ) ) { |
| 3275 | return $this->error; |
| 3276 | } |
| 3277 | |
| 3278 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3279 | do_action( 'xmlrpc_call', 'wp.getComments' ); |
| 3280 | |
| 3281 | if ( isset( $struct['status'] ) ) { |
| 3282 | $status = $struct['status']; |
| 3283 | } else { |
| 3284 | $status = ''; |
| 3285 | } |
| 3286 | |
| 3287 | if ( ! current_user_can( 'moderate_comments' ) && 'approve' !== $status ) { |
| 3288 | return new IXR_Error( 401, __( 'Invalid comment status.' ) ); |
| Line | Code |
| 3362 | if ( ! get_comment( $comment_ID ) ) { |
| 3363 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 3364 | } |
| 3365 | |
| 3366 | if ( !current_user_can( 'edit_comment', $comment_ID ) ) { |
| 3367 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) ); |
| 3368 | } |
| 3369 | |
| 3370 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3371 | do_action( 'xmlrpc_call', 'wp.deleteComment' ); |
| 3372 | |
| 3373 | $status = wp_delete_comment( $comment_ID ); |
| 3374 | |
| 3375 | if ( $status ) { |
| 3376 | /** |
| 3377 | * Fires after a comment has been successfully deleted via XML-RPC. |
| 3378 | * |
| 3379 | * @since 3.4.0 |
| 3380 | * |
| Line | Code |
| 3429 | if ( ! get_comment( $comment_ID ) ) { |
| 3430 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 3431 | } |
| 3432 | |
| 3433 | if ( ! current_user_can( 'edit_comment', $comment_ID ) ) { |
| 3434 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) ); |
| 3435 | } |
| 3436 | |
| 3437 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3438 | do_action( 'xmlrpc_call', 'wp.editComment' ); |
| 3439 | |
| 3440 | if ( isset($content_struct['status']) ) { |
| 3441 | $statuses = get_comment_statuses(); |
| 3442 | $statuses = array_keys($statuses); |
| 3443 | |
| 3444 | if ( ! in_array($content_struct['status'], $statuses) ) |
| 3445 | return new IXR_Error( 401, __( 'Invalid comment status.' ) ); |
| 3446 | $comment_approved = $content_struct['status']; |
| 3447 | } |
| Line | Code |
| 3591 | return new IXR_Error( 403, __( 'Comment author name and email are required.' ) ); |
| 3592 | elseif ( !is_email($comment['comment_author_email']) ) |
| 3593 | return new IXR_Error( 403, __( 'A valid email address is required.' ) ); |
| 3594 | } |
| 3595 | } |
| 3596 | |
| 3597 | $comment['comment_parent'] = isset($content_struct['comment_parent']) ? absint($content_struct['comment_parent']) : 0; |
| 3598 | |
| 3599 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3600 | do_action( 'xmlrpc_call', 'wp.newComment' ); |
| 3601 | |
| 3602 | $comment_ID = wp_new_comment( $comment, true ); |
| 3603 | if ( is_wp_error( $comment_ID ) ) { |
| 3604 | return new IXR_Error( 403, $comment_ID->get_error_message() ); |
| 3605 | } |
| 3606 | |
| 3607 | if ( ! $comment_ID ) { |
| 3608 | return new IXR_Error( 403, __( 'An unknown error occurred' ) ); |
| 3609 | } |
| Line | Code |
| 3644 | if ( ! $user = $this->login( $username, $password ) ) { |
| 3645 | return $this->error; |
| 3646 | } |
| 3647 | |
| 3648 | if ( ! current_user_can( 'publish_posts' ) ) { |
| 3649 | return new IXR_Error( 403, __( 'Sorry, you are not allowed access to details about this site.' ) ); |
| 3650 | } |
| 3651 | |
| 3652 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3653 | do_action( 'xmlrpc_call', 'wp.getCommentStatusList' ); |
| 3654 | |
| 3655 | return get_comment_statuses(); |
| 3656 | } |
| 3657 | |
| 3658 | /** |
| 3659 | * Retrieve comment count. |
| 3660 | * |
| 3661 | * @since 2.5.0 |
| 3662 | * |
| Line | Code |
| 3685 | if ( empty( $post['ID'] ) ) { |
| 3686 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 3687 | } |
| 3688 | |
| 3689 | if ( ! current_user_can( 'edit_post', $post_id ) ) { |
| 3690 | return new IXR_Error( 403, __( 'Sorry, you are not allowed access to details of this post.' ) ); |
| 3691 | } |
| 3692 | |
| 3693 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3694 | do_action( 'xmlrpc_call', 'wp.getCommentCount' ); |
| 3695 | |
| 3696 | $count = wp_count_comments( $post_id ); |
| 3697 | |
| 3698 | return array( |
| 3699 | 'approved' => $count->approved, |
| 3700 | 'awaiting_moderation' => $count->moderated, |
| 3701 | 'spam' => $count->spam, |
| 3702 | 'total_comments' => $count->total_comments |
| 3703 | ); |
| Line | Code |
| 3724 | $password = $args[2]; |
| 3725 | |
| 3726 | if ( !$user = $this->login($username, $password) ) |
| 3727 | return $this->error; |
| 3728 | |
| 3729 | if ( !current_user_can( 'edit_posts' ) ) |
| 3730 | return new IXR_Error( 403, __( 'Sorry, you are not allowed access to details about this site.' ) ); |
| 3731 | |
| 3732 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3733 | do_action( 'xmlrpc_call', 'wp.getPostStatusList' ); |
| 3734 | |
| 3735 | return get_post_statuses(); |
| 3736 | } |
| 3737 | |
| 3738 | /** |
| 3739 | * Retrieve page statuses. |
| 3740 | * |
| 3741 | * @since 2.5.0 |
| 3742 | * |
| Line | Code |
| 3756 | $password = $args[2]; |
| 3757 | |
| 3758 | if ( !$user = $this->login($username, $password) ) |
| 3759 | return $this->error; |
| 3760 | |
| 3761 | if ( !current_user_can( 'edit_pages' ) ) |
| 3762 | return new IXR_Error( 403, __( 'Sorry, you are not allowed access to details about this site.' ) ); |
| 3763 | |
| 3764 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3765 | do_action( 'xmlrpc_call', 'wp.getPageStatusList' ); |
| 3766 | |
| 3767 | return get_page_statuses(); |
| 3768 | } |
| 3769 | |
| 3770 | /** |
| 3771 | * Retrieve page templates. |
| 3772 | * |
| 3773 | * @since 2.6.0 |
| 3774 | * |
| Line | Code |
| 3934 | $attachment_id = (int) $args[3]; |
| 3935 | |
| 3936 | if ( !$user = $this->login($username, $password) ) |
| 3937 | return $this->error; |
| 3938 | |
| 3939 | if ( !current_user_can( 'upload_files' ) ) |
| 3940 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to upload files.' ) ); |
| 3941 | |
| 3942 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3943 | do_action( 'xmlrpc_call', 'wp.getMediaItem' ); |
| 3944 | |
| 3945 | if ( ! $attachment = get_post($attachment_id) ) |
| 3946 | return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); |
| 3947 | |
| 3948 | return $this->_prepare_media_item( $attachment ); |
| 3949 | } |
| 3950 | |
| 3951 | /** |
| 3952 | * Retrieves a collection of media library items (or attachments) |
| Line | Code |
| 3982 | $struct = isset( $args[3] ) ? $args[3] : array() ; |
| 3983 | |
| 3984 | if ( !$user = $this->login($username, $password) ) |
| 3985 | return $this->error; |
| 3986 | |
| 3987 | if ( !current_user_can( 'upload_files' ) ) |
| 3988 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to upload files.' ) ); |
| 3989 | |
| 3990 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3991 | do_action( 'xmlrpc_call', 'wp.getMediaLibrary' ); |
| 3992 | |
| 3993 | $parent_id = ( isset($struct['parent_id']) ) ? absint($struct['parent_id']) : '' ; |
| 3994 | $mime_type = ( isset($struct['mime_type']) ) ? $struct['mime_type'] : '' ; |
| 3995 | $offset = ( isset($struct['offset']) ) ? absint($struct['offset']) : 0 ; |
| 3996 | $number = ( isset($struct['number']) ) ? absint($struct['number']) : -1 ; |
| 3997 | |
| 3998 | $attachments = get_posts( array('post_type' => 'attachment', 'post_parent' => $parent_id, 'offset' => $offset, 'numberposts' => $number, 'post_mime_type' => $mime_type ) ); |
| 3999 | |
| 4000 | $attachments_struct = array(); |
| Line | Code |
| 4026 | $password = $args[2]; |
| 4027 | |
| 4028 | if ( !$user = $this->login( $username, $password ) ) |
| 4029 | return $this->error; |
| 4030 | |
| 4031 | if ( !current_user_can( 'edit_posts' ) ) |
| 4032 | return new IXR_Error( 403, __( 'Sorry, you are not allowed access to details about this site.' ) ); |
| 4033 | |
| 4034 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4035 | do_action( 'xmlrpc_call', 'wp.getPostFormats' ); |
| 4036 | |
| 4037 | $formats = get_post_format_strings(); |
| 4038 | |
| 4039 | // find out if they want a list of currently supports formats |
| 4040 | if ( isset( $args[3] ) && is_array( $args[3] ) ) { |
| 4041 | if ( $args[3]['show-supported'] ) { |
| 4042 | if ( current_theme_supports( 'post-formats' ) ) { |
| 4043 | $supported = get_theme_support( 'post-formats' ); |
| 4044 | |
| Line | Code |
| 4103 | * @param string $method The method name. |
| 4104 | */ |
| 4105 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostType' ); |
| 4106 | } |
| 4107 | |
| 4108 | if ( !$user = $this->login( $username, $password ) ) |
| 4109 | return $this->error; |
| 4110 | |
| 4111 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4112 | do_action( 'xmlrpc_call', 'wp.getPostType' ); |
| 4113 | |
| 4114 | if ( ! post_type_exists( $post_type_name ) ) |
| 4115 | return new IXR_Error( 403, __( 'Invalid post type.' ) ); |
| 4116 | |
| 4117 | $post_type = get_post_type_object( $post_type_name ); |
| 4118 | |
| 4119 | if ( ! current_user_can( $post_type->cap->edit_posts ) ) |
| 4120 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts in this post type.' ) ); |
| 4121 | |
| Line | Code |
| 4155 | } else { |
| 4156 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4157 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostTypes' ); |
| 4158 | } |
| 4159 | |
| 4160 | if ( ! $user = $this->login( $username, $password ) ) |
| 4161 | return $this->error; |
| 4162 | |
| 4163 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4164 | do_action( 'xmlrpc_call', 'wp.getPostTypes' ); |
| 4165 | |
| 4166 | $post_types = get_post_types( $filter, 'objects' ); |
| 4167 | |
| 4168 | $struct = array(); |
| 4169 | |
| 4170 | foreach ( $post_types as $post_type ) { |
| 4171 | if ( ! current_user_can( $post_type->cap->edit_posts ) ) |
| 4172 | continue; |
| 4173 | |
| Line | Code |
| 4221 | * @param string $method The method name. |
| 4222 | */ |
| 4223 | $fields = apply_filters( 'xmlrpc_default_revision_fields', array( 'post_date', 'post_date_gmt' ), 'wp.getRevisions' ); |
| 4224 | } |
| 4225 | |
| 4226 | if ( ! $user = $this->login( $username, $password ) ) |
| 4227 | return $this->error; |
| 4228 | |
| 4229 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4230 | do_action( 'xmlrpc_call', 'wp.getRevisions' ); |
| 4231 | |
| 4232 | if ( ! $post = get_post( $post_id ) ) |
| 4233 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4234 | |
| 4235 | if ( ! current_user_can( 'edit_post', $post_id ) ) |
| 4236 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
| 4237 | |
| 4238 | // Check if revisions are enabled. |
| 4239 | if ( ! wp_revisions_enabled( $post ) ) |
| Line | Code |
| 4285 | |
| 4286 | $username = $args[1]; |
| 4287 | $password = $args[2]; |
| 4288 | $revision_id = (int) $args[3]; |
| 4289 | |
| 4290 | if ( ! $user = $this->login( $username, $password ) ) |
| 4291 | return $this->error; |
| 4292 | |
| 4293 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4294 | do_action( 'xmlrpc_call', 'wp.restoreRevision' ); |
| 4295 | |
| 4296 | if ( ! $revision = wp_get_post_revision( $revision_id ) ) |
| 4297 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4298 | |
| 4299 | if ( wp_is_post_autosave( $revision ) ) |
| 4300 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4301 | |
| 4302 | if ( ! $post = get_post( $revision->post_parent ) ) |
| 4303 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| Line | Code |
| 4346 | $this->escape($args); |
| 4347 | |
| 4348 | $username = $args[1]; |
| 4349 | $password = $args[2]; |
| 4350 | |
| 4351 | if ( !$user = $this->login($username, $password) ) |
| 4352 | return $this->error; |
| 4353 | |
| 4354 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4355 | do_action( 'xmlrpc_call', 'blogger.getUsersBlogs' ); |
| 4356 | |
| 4357 | $is_admin = current_user_can('manage_options'); |
| 4358 | |
| 4359 | $struct = array( |
| 4360 | 'isAdmin' => $is_admin, |
| 4361 | 'url' => get_option('home') . '/', |
| 4362 | 'blogid' => '1', |
| 4363 | 'blogName' => get_option('blogname'), |
| 4364 | 'xmlrpc' => site_url( 'xmlrpc.php', 'rpc' ), |
| Line | Code |
| 4428 | $password = $args[2]; |
| 4429 | |
| 4430 | if ( !$user = $this->login($username, $password) ) |
| 4431 | return $this->error; |
| 4432 | |
| 4433 | if ( !current_user_can( 'edit_posts' ) ) |
| 4434 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to access user data on this site.' ) ); |
| 4435 | |
| 4436 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4437 | do_action( 'xmlrpc_call', 'blogger.getUserInfo' ); |
| 4438 | |
| 4439 | $struct = array( |
| 4440 | 'nickname' => $user->nickname, |
| 4441 | 'userid' => $user->ID, |
| 4442 | 'url' => $user->user_url, |
| 4443 | 'lastname' => $user->last_name, |
| 4444 | 'firstname' => $user->first_name |
| 4445 | ); |
| 4446 | |
| Line | Code |
| 4474 | |
| 4475 | $post_data = get_post($post_ID, ARRAY_A); |
| 4476 | if ( ! $post_data ) |
| 4477 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4478 | |
| 4479 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
| 4480 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
| 4481 | |
| 4482 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4483 | do_action( 'xmlrpc_call', 'blogger.getPost' ); |
| 4484 | |
| 4485 | $categories = implode(',', wp_get_post_categories($post_ID)); |
| 4486 | |
| 4487 | $content = '<title>'.wp_unslash($post_data['post_title']).'</title>'; |
| 4488 | $content .= '<category>'.$categories.'</category>'; |
| 4489 | $content .= wp_unslash($post_data['post_content']); |
| 4490 | |
| 4491 | $struct = array( |
| 4492 | 'userid' => $post_data['post_author'], |
| Line | Code |
| 4527 | $query = array(); |
| 4528 | |
| 4529 | if ( !$user = $this->login($username, $password) ) |
| 4530 | return $this->error; |
| 4531 | |
| 4532 | if ( ! current_user_can( 'edit_posts' ) ) |
| 4533 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
| 4534 | |
| 4535 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4536 | do_action( 'xmlrpc_call', 'blogger.getRecentPosts' ); |
| 4537 | |
| 4538 | $posts_list = wp_get_recent_posts( $query ); |
| 4539 | |
| 4540 | if ( !$posts_list ) { |
| 4541 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
| 4542 | return $this->error; |
| 4543 | } |
| 4544 | |
| 4545 | $recent_posts = array(); |
| Line | Code |
| 4614 | $username = $args[2]; |
| 4615 | $password = $args[3]; |
| 4616 | $content = $args[4]; |
| 4617 | $publish = $args[5]; |
| 4618 | |
| 4619 | if ( !$user = $this->login($username, $password) ) |
| 4620 | return $this->error; |
| 4621 | |
| 4622 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4623 | do_action( 'xmlrpc_call', 'blogger.newPost' ); |
| 4624 | |
| 4625 | $cap = ($publish) ? 'publish_posts' : 'edit_posts'; |
| 4626 | if ( ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) || !current_user_can($cap) ) |
| 4627 | return new IXR_Error(401, __('Sorry, you are not allowed to post on this site.')); |
| 4628 | |
| 4629 | $post_status = ($publish) ? 'publish' : 'draft'; |
| 4630 | |
| 4631 | $post_author = $user->ID; |
| 4632 | |
| Line | Code |
| 4687 | $password = $args[3]; |
| 4688 | $content = $args[4]; |
| 4689 | $publish = $args[5]; |
| 4690 | |
| 4691 | if ( ! $user = $this->login( $username, $password ) ) { |
| 4692 | return $this->error; |
| 4693 | } |
| 4694 | |
| 4695 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4696 | do_action( 'xmlrpc_call', 'blogger.editPost' ); |
| 4697 | |
| 4698 | $actual_post = get_post( $post_ID, ARRAY_A ); |
| 4699 | |
| 4700 | if ( ! $actual_post || $actual_post['post_type'] != 'post' ) { |
| 4701 | return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); |
| 4702 | } |
| 4703 | |
| 4704 | $this->escape($actual_post); |
| 4705 | |
| Line | Code |
| 4759 | |
| 4760 | $post_ID = (int) $args[1]; |
| 4761 | $username = $args[2]; |
| 4762 | $password = $args[3]; |
| 4763 | |
| 4764 | if ( !$user = $this->login($username, $password) ) |
| 4765 | return $this->error; |
| 4766 | |
| 4767 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4768 | do_action( 'xmlrpc_call', 'blogger.deletePost' ); |
| 4769 | |
| 4770 | $actual_post = get_post( $post_ID, ARRAY_A ); |
| 4771 | |
| 4772 | if ( ! $actual_post || $actual_post['post_type'] != 'post' ) { |
| 4773 | return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); |
| 4774 | } |
| 4775 | |
| 4776 | if ( ! current_user_can( 'delete_post', $post_ID ) ) { |
| 4777 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) ); |
| Line | Code |
| 4844 | $username = $args[1]; |
| 4845 | $password = $args[2]; |
| 4846 | $content_struct = $args[3]; |
| 4847 | $publish = isset( $args[4] ) ? $args[4] : 0; |
| 4848 | |
| 4849 | if ( !$user = $this->login($username, $password) ) |
| 4850 | return $this->error; |
| 4851 | |
| 4852 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4853 | do_action( 'xmlrpc_call', 'metaWeblog.newPost' ); |
| 4854 | |
| 4855 | $page_template = ''; |
| 4856 | if ( !empty( $content_struct['post_type'] ) ) { |
| 4857 | if ( $content_struct['post_type'] == 'page' ) { |
| 4858 | if ( $publish ) |
| 4859 | $cap = 'publish_pages'; |
| 4860 | elseif ( isset( $content_struct['page_status'] ) && 'publish' == $content_struct['page_status'] ) |
| 4861 | $cap = 'publish_pages'; |
| 4862 | else |
| Line | Code |
| 5190 | $username = $args[1]; |
| 5191 | $password = $args[2]; |
| 5192 | $content_struct = $args[3]; |
| 5193 | $publish = isset( $args[4] ) ? $args[4] : 0; |
| 5194 | |
| 5195 | if ( ! $user = $this->login($username, $password) ) |
| 5196 | return $this->error; |
| 5197 | |
| 5198 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5199 | do_action( 'xmlrpc_call', 'metaWeblog.editPost' ); |
| 5200 | |
| 5201 | $postdata = get_post( $post_ID, ARRAY_A ); |
| 5202 | |
| 5203 | /* |
| 5204 | * If there is no post data for the give post id, stop now and return an error. |
| 5205 | * Otherwise a new post will be created (which was the old behavior). |
| 5206 | */ |
| 5207 | if ( ! $postdata || empty( $postdata[ 'ID' ] ) ) |
| 5208 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| Line | Code |
| 5502 | |
| 5503 | $postdata = get_post($post_ID, ARRAY_A); |
| 5504 | if ( ! $postdata ) |
| 5505 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 5506 | |
| 5507 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
| 5508 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
| 5509 | |
| 5510 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5511 | do_action( 'xmlrpc_call', 'metaWeblog.getPost' ); |
| 5512 | |
| 5513 | if ($postdata['post_date'] != '') { |
| 5514 | $post_date = $this->_convert_date( $postdata['post_date'] ); |
| 5515 | $post_date_gmt = $this->_convert_date_gmt( $postdata['post_date_gmt'], $postdata['post_date'] ); |
| 5516 | $post_modified = $this->_convert_date( $postdata['post_modified'] ); |
| 5517 | $post_modified_gmt = $this->_convert_date_gmt( $postdata['post_modified_gmt'], $postdata['post_modified'] ); |
| 5518 | |
| 5519 | $categories = array(); |
| 5520 | $catids = wp_get_post_categories($post_ID); |
| Line | Code |
| 5632 | $query = array(); |
| 5633 | |
| 5634 | if ( !$user = $this->login($username, $password) ) |
| 5635 | return $this->error; |
| 5636 | |
| 5637 | if ( ! current_user_can( 'edit_posts' ) ) |
| 5638 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
| 5639 | |
| 5640 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5641 | do_action( 'xmlrpc_call', 'metaWeblog.getRecentPosts' ); |
| 5642 | |
| 5643 | $posts_list = wp_get_recent_posts( $query ); |
| 5644 | |
| 5645 | if ( !$posts_list ) |
| 5646 | return array(); |
| 5647 | |
| 5648 | $recent_posts = array(); |
| 5649 | foreach ($posts_list as $entry) { |
| 5650 | if ( !current_user_can( 'edit_post', $entry['ID'] ) ) |
| Line | Code |
| 5745 | $password = $args[2]; |
| 5746 | |
| 5747 | if ( !$user = $this->login($username, $password) ) |
| 5748 | return $this->error; |
| 5749 | |
| 5750 | if ( !current_user_can( 'edit_posts' ) ) |
| 5751 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
| 5752 | |
| 5753 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5754 | do_action( 'xmlrpc_call', 'metaWeblog.getCategories' ); |
| 5755 | |
| 5756 | $categories_struct = array(); |
| 5757 | |
| 5758 | if ( $cats = get_categories(array('get' => 'all')) ) { |
| 5759 | foreach ( $cats as $cat ) { |
| 5760 | $struct = array(); |
| 5761 | $struct['categoryId'] = $cat->term_id; |
| 5762 | $struct['parentId'] = $cat->parent; |
| 5763 | $struct['description'] = $cat->name; |
| Line | Code |
| 5803 | |
| 5804 | $name = sanitize_file_name( $data['name'] ); |
| 5805 | $type = $data['type']; |
| 5806 | $bits = $data['bits']; |
| 5807 | |
| 5808 | if ( !$user = $this->login($username, $password) ) |
| 5809 | return $this->error; |
| 5810 | |
| 5811 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5812 | do_action( 'xmlrpc_call', 'metaWeblog.newMediaObject' ); |
| 5813 | |
| 5814 | if ( !current_user_can('upload_files') ) { |
| 5815 | $this->error = new IXR_Error( 401, __( 'Sorry, you are not allowed to upload files.' ) ); |
| 5816 | return $this->error; |
| 5817 | } |
| 5818 | |
| 5819 | if ( is_multisite() && upload_is_user_over_quota( false ) ) { |
| 5820 | $this->error = new IXR_Error( 401, __( 'Sorry, you have used your space allocation.' ) ); |
| 5821 | return $this->error; |
| Line | Code |
| 5909 | if ( isset( $args[3] ) ) |
| 5910 | $query = array( 'numberposts' => absint( $args[3] ) ); |
| 5911 | else |
| 5912 | $query = array(); |
| 5913 | |
| 5914 | if ( !$user = $this->login($username, $password) ) |
| 5915 | return $this->error; |
| 5916 | |
| 5917 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5918 | do_action( 'xmlrpc_call', 'mt.getRecentPostTitles' ); |
| 5919 | |
| 5920 | $posts_list = wp_get_recent_posts( $query ); |
| 5921 | |
| 5922 | if ( !$posts_list ) { |
| 5923 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
| 5924 | return $this->error; |
| 5925 | } |
| 5926 | |
| 5927 | $recent_posts = array(); |
| Line | Code |
| 5967 | $password = $args[2]; |
| 5968 | |
| 5969 | if ( !$user = $this->login($username, $password) ) |
| 5970 | return $this->error; |
| 5971 | |
| 5972 | if ( !current_user_can( 'edit_posts' ) ) |
| 5973 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
| 5974 | |
| 5975 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5976 | do_action( 'xmlrpc_call', 'mt.getCategoryList' ); |
| 5977 | |
| 5978 | $categories_struct = array(); |
| 5979 | |
| 5980 | if ( $cats = get_categories(array('hide_empty' => 0, 'hierarchical' => 0)) ) { |
| 5981 | foreach ( $cats as $cat ) { |
| 5982 | $struct = array(); |
| 5983 | $struct['categoryId'] = $cat->term_id; |
| 5984 | $struct['categoryName'] = $cat->name; |
| 5985 | |
| Line | Code |
| 6015 | return $this->error; |
| 6016 | |
| 6017 | if ( ! get_post( $post_ID ) ) |
| 6018 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 6019 | |
| 6020 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
| 6021 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
| 6022 | |
| 6023 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6024 | do_action( 'xmlrpc_call', 'mt.getPostCategories' ); |
| 6025 | |
| 6026 | $categories = array(); |
| 6027 | $catids = wp_get_post_categories(intval($post_ID)); |
| 6028 | // first listed category will be the primary category |
| 6029 | $isPrimary = true; |
| 6030 | foreach ( $catids as $catid ) { |
| 6031 | $categories[] = array( |
| 6032 | 'categoryName' => get_cat_name($catid), |
| 6033 | 'categoryId' => (string) $catid, |
| Line | Code |
| 6060 | $post_ID = (int) $args[0]; |
| 6061 | $username = $args[1]; |
| 6062 | $password = $args[2]; |
| 6063 | $categories = $args[3]; |
| 6064 | |
| 6065 | if ( !$user = $this->login($username, $password) ) |
| 6066 | return $this->error; |
| 6067 | |
| 6068 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6069 | do_action( 'xmlrpc_call', 'mt.setPostCategories' ); |
| 6070 | |
| 6071 | if ( ! get_post( $post_ID ) ) |
| 6072 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 6073 | |
| 6074 | if ( !current_user_can('edit_post', $post_ID) ) |
| 6075 | return new IXR_Error(401, __('Sorry, you are not allowed to edit this post.')); |
| 6076 | |
| 6077 | $catids = array(); |
| 6078 | foreach ( $categories as $cat ) { |
| Line | Code |
| 6087 | /** |
| 6088 | * Retrieve an array of methods supported by this server. |
| 6089 | * |
| 6090 | * @since 1.5.0 |
| 6091 | * |
| 6092 | * @return array |
| 6093 | */ |
| 6094 | public function mt_supportedMethods() { |
| 6095 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6096 | do_action( 'xmlrpc_call', 'mt.supportedMethods' ); |
| 6097 | |
| 6098 | return array_keys( $this->methods ); |
| 6099 | } |
| 6100 | |
| 6101 | /** |
| 6102 | * Retrieve an empty array because we don't support per-post text filters. |
| 6103 | * |
| 6104 | * @since 1.5.0 |
| 6105 | */ |
| 6106 | public function mt_supportedTextFilters() { |
| 6107 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6108 | do_action( 'xmlrpc_call', 'mt.supportedTextFilters' ); |
| 6109 | |
| 6110 | /** |
| 6111 | * Filters the MoveableType text filters list for XML-RPC. |
| 6112 | * |
| 6113 | * @since 2.2.0 |
| 6114 | * |
| 6115 | * @param array $filters An array of text filters. |
| 6116 | */ |
| 6117 | return apply_filters( 'xmlrpc_text_filters', array() ); |
| Line | Code |
| 6125 | * @global wpdb $wpdb WordPress database abstraction object. |
| 6126 | * |
| 6127 | * @param int $post_ID |
| 6128 | * @return array|IXR_Error |
| 6129 | */ |
| 6130 | public function mt_getTrackbackPings( $post_ID ) { |
| 6131 | global $wpdb; |
| 6132 | |
| 6133 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6134 | do_action( 'xmlrpc_call', 'mt.getTrackbackPings' ); |
| 6135 | |
| 6136 | $actual_post = get_post($post_ID, ARRAY_A); |
| 6137 | |
| 6138 | if ( !$actual_post ) |
| 6139 | return new IXR_Error(404, __('Sorry, no such post.')); |
| 6140 | |
| 6141 | $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) ); |
| 6142 | |
| 6143 | if ( !$comments ) |
| Line | Code |
| 6178 | |
| 6179 | $post_ID = (int) $args[0]; |
| 6180 | $username = $args[1]; |
| 6181 | $password = $args[2]; |
| 6182 | |
| 6183 | if ( !$user = $this->login($username, $password) ) |
| 6184 | return $this->error; |
| 6185 | |
| 6186 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6187 | do_action( 'xmlrpc_call', 'mt.publishPost' ); |
| 6188 | |
| 6189 | $postdata = get_post($post_ID, ARRAY_A); |
| 6190 | if ( ! $postdata ) |
| 6191 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 6192 | |
| 6193 | if ( !current_user_can('publish_posts') || !current_user_can('edit_post', $post_ID) ) |
| 6194 | return new IXR_Error(401, __('Sorry, you are not allowed to publish this post.')); |
| 6195 | |
| 6196 | $postdata['post_status'] = 'publish'; |
| Line | Code |
| 6218 | * @type string $pagelinkedfrom |
| 6219 | * @type string $pagelinkedto |
| 6220 | * } |
| 6221 | * @return string|IXR_Error |
| 6222 | */ |
| 6223 | public function pingback_ping( $args ) { |
| 6224 | global $wpdb; |
| 6225 | |
| 6226 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6227 | do_action( 'xmlrpc_call', 'pingback.ping' ); |
| 6228 | |
| 6229 | $this->escape( $args ); |
| 6230 | |
| 6231 | $pagelinkedfrom = str_replace( '&', '&', $args[0] ); |
| 6232 | $pagelinkedto = str_replace( '&', '&', $args[1] ); |
| 6233 | $pagelinkedto = str_replace( '&', '&', $pagelinkedto ); |
| 6234 | |
| 6235 | /** |
| 6236 | * Filters the pingback source URI. |
| Line | Code |
| 6430 | * @global wpdb $wpdb WordPress database abstraction object. |
| 6431 | * |
| 6432 | * @param string $url |
| 6433 | * @return array|IXR_Error |
| 6434 | */ |
| 6435 | public function pingback_extensions_getPingbacks( $url ) { |
| 6436 | global $wpdb; |
| 6437 | |
| 6438 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6439 | do_action( 'xmlrpc_call', 'pingback.extensions.getPingbacks' ); |
| 6440 | |
| 6441 | $url = $this->escape( $url ); |
| 6442 | |
| 6443 | $post_ID = url_to_postid($url); |
| 6444 | if ( !$post_ID ) { |
| 6445 | // We aren't sure that the resource is available and/or pingback enabled |
| 6446 | 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.' ) ); |
| 6447 | } |
| 6448 | |