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 |
1217 | if ( isset( $content_struct['post_date_gmt'] ) && ! ( $content_struct['post_date_gmt'] instanceof IXR_Date ) ) { |
1218 | if ( $content_struct['post_date_gmt'] == '0000-00-00 00:00:00' || isset( $content_struct['post_date'] ) ) { |
1219 | unset( $content_struct['post_date_gmt'] ); |
1220 | } else { |
1221 | $content_struct['post_date_gmt'] = $this->_convert_date( $content_struct['post_date_gmt'] ); |
1222 | } |
1223 | } |
1224 |
|
1225 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
1226 | do_action( 'xmlrpc_call', 'wp.newPost' ); |
1227 |
|
1228 | unset( $content_struct['ID'] ); |
1229 |
|
1230 | return $this->_insert_post( $user, $content_struct ); |
1231 | } |
1232 |
|
1233 | /** |
1234 | * Helper method for filtering out elements from an array. |
1235 | * |
Line | Code |
1553 | $username = $args[1]; |
1554 | $password = $args[2]; |
1555 | $post_id = (int) $args[3]; |
1556 | $content_struct = $args[4]; |
1557 |
|
1558 | if ( ! $user = $this->login( $username, $password ) ) |
1559 | return $this->error; |
1560 |
|
1561 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
1562 | do_action( 'xmlrpc_call', 'wp.editPost' ); |
1563 |
|
1564 | $post = get_post( $post_id, ARRAY_A ); |
1565 |
|
1566 | if ( empty( $post['ID'] ) ) |
1567 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
1568 |
|
1569 | if ( isset( $content_struct['if_not_modified_since'] ) ) { |
1570 | // If the post has been modified since the date provided, return an error. |
1571 | if ( mysql2date( 'U', $post['post_modified_gmt'] ) > $content_struct['if_not_modified_since']->getTimestamp() ) { |
Line | Code |
1620 |
|
1621 | $username = $args[1]; |
1622 | $password = $args[2]; |
1623 | $post_id = (int) $args[3]; |
1624 |
|
1625 | if ( ! $user = $this->login( $username, $password ) ) |
1626 | return $this->error; |
1627 |
|
1628 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
1629 | do_action( 'xmlrpc_call', 'wp.deletePost' ); |
1630 |
|
1631 | $post = get_post( $post_id, ARRAY_A ); |
1632 | if ( empty( $post['ID'] ) ) { |
1633 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
1634 | } |
1635 |
|
1636 | if ( ! current_user_can( 'delete_post', $post_id ) ) { |
1637 | return new IXR_Error( 401, __( 'Sorry, you do not have the right to delete this post.' ) ); |
1638 | } |
Line | Code |
1717 | * @param string $method Method name. |
1718 | */ |
1719 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPost' ); |
1720 | } |
1721 |
|
1722 | if ( ! $user = $this->login( $username, $password ) ) |
1723 | return $this->error; |
1724 |
|
1725 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
1726 | do_action( 'xmlrpc_call', 'wp.getPost' ); |
1727 |
|
1728 | $post = get_post( $post_id, ARRAY_A ); |
1729 |
|
1730 | if ( empty( $post['ID'] ) ) |
1731 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
1732 |
|
1733 | if ( ! current_user_can( 'edit_post', $post_id ) ) |
1734 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); |
1735 |
|
Line | Code |
1773 | } else { |
1774 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
1775 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPosts' ); |
1776 | } |
1777 |
|
1778 | if ( ! $user = $this->login( $username, $password ) ) |
1779 | return $this->error; |
1780 |
|
1781 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
1782 | do_action( 'xmlrpc_call', 'wp.getPosts' ); |
1783 |
|
1784 | $query = array(); |
1785 |
|
1786 | if ( isset( $filter['post_type'] ) ) { |
1787 | $post_type = get_post_type_object( $filter['post_type'] ); |
1788 | if ( ! ( (bool) $post_type ) ) |
1789 | return new IXR_Error( 403, __( 'The post type specified is not valid' ) ); |
1790 | } else { |
1791 | $post_type = get_post_type_object( 'post' ); |
Line | Code |
1861 |
|
1862 | $username = $args[1]; |
1863 | $password = $args[2]; |
1864 | $content_struct = $args[3]; |
1865 |
|
1866 | if ( ! $user = $this->login( $username, $password ) ) |
1867 | return $this->error; |
1868 |
|
1869 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
1870 | do_action( 'xmlrpc_call', 'wp.newTerm' ); |
1871 |
|
1872 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) |
1873 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
1874 |
|
1875 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
1876 |
|
1877 | if ( ! current_user_can( $taxonomy->cap->manage_terms ) ) |
1878 | return new IXR_Error( 401, __( 'You are not allowed to create terms in this taxonomy.' ) ); |
1879 |
|
Line | Code |
1948 | $username = $args[1]; |
1949 | $password = $args[2]; |
1950 | $term_id = (int) $args[3]; |
1951 | $content_struct = $args[4]; |
1952 |
|
1953 | if ( ! $user = $this->login( $username, $password ) ) |
1954 | return $this->error; |
1955 |
|
1956 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
1957 | do_action( 'xmlrpc_call', 'wp.editTerm' ); |
1958 |
|
1959 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) |
1960 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
1961 |
|
1962 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
1963 |
|
1964 | if ( ! current_user_can( $taxonomy->cap->edit_terms ) ) |
1965 | return new IXR_Error( 401, __( 'You are not allowed to edit terms in this taxonomy.' ) ); |
1966 |
|
Line | Code |
2044 | $username = $args[1]; |
2045 | $password = $args[2]; |
2046 | $taxonomy = $args[3]; |
2047 | $term_id = (int) $args[4]; |
2048 |
|
2049 | if ( ! $user = $this->login( $username, $password ) ) |
2050 | return $this->error; |
2051 |
|
2052 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2053 | do_action( 'xmlrpc_call', 'wp.deleteTerm' ); |
2054 |
|
2055 | if ( ! taxonomy_exists( $taxonomy ) ) |
2056 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
2057 |
|
2058 | $taxonomy = get_taxonomy( $taxonomy ); |
2059 |
|
2060 | if ( ! current_user_can( $taxonomy->cap->delete_terms ) ) |
2061 | return new IXR_Error( 401, __( 'You are not allowed to delete terms in this taxonomy.' ) ); |
2062 |
|
Line | Code |
2115 | $username = $args[1]; |
2116 | $password = $args[2]; |
2117 | $taxonomy = $args[3]; |
2118 | $term_id = (int) $args[4]; |
2119 |
|
2120 | if ( ! $user = $this->login( $username, $password ) ) |
2121 | return $this->error; |
2122 |
|
2123 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2124 | do_action( 'xmlrpc_call', 'wp.getTerm' ); |
2125 |
|
2126 | if ( ! taxonomy_exists( $taxonomy ) ) |
2127 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
2128 |
|
2129 | $taxonomy = get_taxonomy( $taxonomy ); |
2130 |
|
2131 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
2132 | return new IXR_Error( 401, __( 'You are not allowed to assign terms in this taxonomy.' ) ); |
2133 |
|
Line | Code |
2173 | $username = $args[1]; |
2174 | $password = $args[2]; |
2175 | $taxonomy = $args[3]; |
2176 | $filter = isset( $args[4] ) ? $args[4] : array(); |
2177 |
|
2178 | if ( ! $user = $this->login( $username, $password ) ) |
2179 | return $this->error; |
2180 |
|
2181 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2182 | do_action( 'xmlrpc_call', 'wp.getTerms' ); |
2183 |
|
2184 | if ( ! taxonomy_exists( $taxonomy ) ) |
2185 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
2186 |
|
2187 | $taxonomy = get_taxonomy( $taxonomy ); |
2188 |
|
2189 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
2190 | return new IXR_Error( 401, __( 'You are not allowed to assign terms in this taxonomy.' ) ); |
2191 |
|
Line | Code |
2268 | * @param string $method The method name. |
2269 | */ |
2270 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomy' ); |
2271 | } |
2272 |
|
2273 | if ( ! $user = $this->login( $username, $password ) ) |
2274 | return $this->error; |
2275 |
|
2276 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2277 | do_action( 'xmlrpc_call', 'wp.getTaxonomy' ); |
2278 |
|
2279 | if ( ! taxonomy_exists( $taxonomy ) ) |
2280 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
2281 |
|
2282 | $taxonomy = get_taxonomy( $taxonomy ); |
2283 |
|
2284 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
2285 | return new IXR_Error( 401, __( 'You are not allowed to assign terms in this taxonomy.' ) ); |
2286 |
|
Line | Code |
2321 | } else { |
2322 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2323 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomies' ); |
2324 | } |
2325 |
|
2326 | if ( ! $user = $this->login( $username, $password ) ) |
2327 | return $this->error; |
2328 |
|
2329 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2330 | do_action( 'xmlrpc_call', 'wp.getTaxonomies' ); |
2331 |
|
2332 | $taxonomies = get_taxonomies( $filter, 'objects' ); |
2333 |
|
2334 | // holds all the taxonomy data |
2335 | $struct = array(); |
2336 |
|
2337 | foreach ( $taxonomies as $taxonomy ) { |
2338 | // capability check for post_types |
2339 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
Line | Code |
2403 | * @param string $method The method name. |
2404 | */ |
2405 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUser' ); |
2406 | } |
2407 |
|
2408 | if ( ! $user = $this->login( $username, $password ) ) |
2409 | return $this->error; |
2410 |
|
2411 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2412 | do_action( 'xmlrpc_call', 'wp.getUser' ); |
2413 |
|
2414 | if ( ! current_user_can( 'edit_user', $user_id ) ) |
2415 | return new IXR_Error( 401, __( 'Sorry, you cannot edit users.' ) ); |
2416 |
|
2417 | $user_data = get_userdata( $user_id ); |
2418 |
|
2419 | if ( ! $user_data ) |
2420 | return new IXR_Error( 404, __( 'Invalid user ID.' ) ); |
2421 |
|
Line | Code |
2461 | } else { |
2462 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2463 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUsers' ); |
2464 | } |
2465 |
|
2466 | if ( ! $user = $this->login( $username, $password ) ) |
2467 | return $this->error; |
2468 |
|
2469 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2470 | do_action( 'xmlrpc_call', 'wp.getUsers' ); |
2471 |
|
2472 | if ( ! current_user_can( 'list_users' ) ) |
2473 | return new IXR_Error( 401, __( 'You are not allowed to browse users.' ) ); |
2474 |
|
2475 | $query = array( 'fields' => 'all_with_meta' ); |
2476 |
|
2477 | $query['number'] = ( isset( $filter['number'] ) ) ? absint( $filter['number'] ) : 50; |
2478 | $query['offset'] = ( isset( $filter['offset'] ) ) ? absint( $filter['offset'] ) : 0; |
2479 |
|
Line | Code |
2534 | } else { |
2535 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2536 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getProfile' ); |
2537 | } |
2538 |
|
2539 | if ( ! $user = $this->login( $username, $password ) ) |
2540 | return $this->error; |
2541 |
|
2542 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2543 | do_action( 'xmlrpc_call', 'wp.getProfile' ); |
2544 |
|
2545 | if ( ! current_user_can( 'edit_user', $user->ID ) ) |
2546 | return new IXR_Error( 401, __( 'Sorry, you cannot edit your profile.' ) ); |
2547 |
|
2548 | $user_data = get_userdata( $user->ID ); |
2549 |
|
2550 | return $this->_prepare_user( $user_data, $fields ); |
2551 | } |
2552 |
|
Line | Code |
2580 |
|
2581 | $username = $args[1]; |
2582 | $password = $args[2]; |
2583 | $content_struct = $args[3]; |
2584 |
|
2585 | if ( ! $user = $this->login( $username, $password ) ) |
2586 | return $this->error; |
2587 |
|
2588 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2589 | do_action( 'xmlrpc_call', 'wp.editProfile' ); |
2590 |
|
2591 | if ( ! current_user_can( 'edit_user', $user->ID ) ) |
2592 | return new IXR_Error( 401, __( 'Sorry, you cannot edit your profile.' ) ); |
2593 |
|
2594 | // holds data of the user |
2595 | $user_data = array(); |
2596 | $user_data['ID'] = $user->ID; |
2597 |
|
2598 | // only set the user details if it was given |
Line | Code |
2656 |
|
2657 | $page = get_post($page_id); |
2658 | if ( ! $page ) |
2659 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
2660 |
|
2661 | if ( !current_user_can( 'edit_page', $page_id ) ) |
2662 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this page.' ) ); |
2663 |
|
2664 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2665 | do_action( 'xmlrpc_call', 'wp.getPage' ); |
2666 |
|
2667 | // If we found the page then format the data. |
2668 | if ( $page->ID && ($page->post_type == 'page') ) { |
2669 | return $this->_prepare_page( $page ); |
2670 | } |
2671 | // If the page doesn't exist indicate that. |
2672 | else { |
2673 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
2674 | } |
Line | Code |
2697 | $num_pages = isset($args[3]) ? (int) $args[3] : 10; |
2698 |
|
2699 | if ( !$user = $this->login($username, $password) ) |
2700 | return $this->error; |
2701 |
|
2702 | if ( !current_user_can( 'edit_pages' ) ) |
2703 | return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) ); |
2704 |
|
2705 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2706 | do_action( 'xmlrpc_call', 'wp.getPages' ); |
2707 |
|
2708 | $pages = get_posts( array('post_type' => 'page', 'post_status' => 'any', 'numberposts' => $num_pages) ); |
2709 | $num_pages = count($pages); |
2710 |
|
2711 | // If we have pages, put together their info. |
2712 | if ( $num_pages >= 1 ) { |
2713 | $pages_struct = array(); |
2714 |
|
2715 | foreach ($pages as $page) { |
Line | Code |
2743 | public function wp_newPage( $args ) { |
2744 | // Items not escaped here will be escaped in newPost. |
2745 | $username = $this->escape( $args[1] ); |
2746 | $password = $this->escape( $args[2] ); |
2747 |
|
2748 | if ( !$user = $this->login($username, $password) ) |
2749 | return $this->error; |
2750 |
|
2751 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2752 | do_action( 'xmlrpc_call', 'wp.newPage' ); |
2753 |
|
2754 | // Mark this as content for a page. |
2755 | $args[3]["post_type"] = 'page'; |
2756 |
|
2757 | // Let mw_newPost do all of the heavy lifting. |
2758 | return $this->mw_newPost( $args ); |
2759 | } |
2760 |
|
2761 | /** |
Line | Code |
2778 |
|
2779 | $username = $args[1]; |
2780 | $password = $args[2]; |
2781 | $page_id = (int) $args[3]; |
2782 |
|
2783 | if ( !$user = $this->login($username, $password) ) |
2784 | return $this->error; |
2785 |
|
2786 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2787 | do_action( 'xmlrpc_call', 'wp.deletePage' ); |
2788 |
|
2789 | // Get the current page based on the page_id and |
2790 | // make sure it is a page and not a post. |
2791 | $actual_page = get_post($page_id, ARRAY_A); |
2792 | if ( !$actual_page || ($actual_page['post_type'] != 'page') ) |
2793 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
2794 |
|
2795 | // Make sure the user can delete pages. |
2796 | if ( !current_user_can('delete_page', $page_id) ) |
Line | Code |
2841 |
|
2842 | $escaped_username = $this->escape( $username ); |
2843 | $escaped_password = $this->escape( $password ); |
2844 |
|
2845 | if ( !$user = $this->login( $escaped_username, $escaped_password ) ) { |
2846 | return $this->error; |
2847 | } |
2848 |
|
2849 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2850 | do_action( 'xmlrpc_call', 'wp.editPage' ); |
2851 |
|
2852 | // Get the page data and make sure it is a page. |
2853 | $actual_page = get_post($page_id, ARRAY_A); |
2854 | if ( !$actual_page || ($actual_page['post_type'] != 'page') ) |
2855 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
2856 |
|
2857 | // Make sure the user is allowed to edit pages. |
2858 | if ( !current_user_can('edit_page', $page_id) ) |
2859 | return new IXR_Error( 401, __( 'Sorry, you do not have the right to edit this page.' ) ); |
Line | Code |
2899 | $password = $args[2]; |
2900 |
|
2901 | if ( !$user = $this->login($username, $password) ) |
2902 | return $this->error; |
2903 |
|
2904 | if ( !current_user_can( 'edit_pages' ) ) |
2905 | return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) ); |
2906 |
|
2907 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2908 | do_action( 'xmlrpc_call', 'wp.getPageList' ); |
2909 |
|
2910 | // Get list of pages ids and titles |
2911 | $page_list = $wpdb->get_results(" |
2912 | SELECT ID page_id, |
2913 | post_title page_title, |
2914 | post_parent page_parent_id, |
2915 | post_date_gmt, |
2916 | post_date, |
2917 | post_status |
Line | Code |
2955 | $password = $args[2]; |
2956 |
|
2957 | if ( !$user = $this->login($username, $password) ) |
2958 | return $this->error; |
2959 |
|
2960 | if ( !current_user_can('edit_posts') ) |
2961 | return new IXR_Error( 401, __( 'Sorry, you cannot edit posts on this site.' ) ); |
2962 |
|
2963 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2964 | do_action( 'xmlrpc_call', 'wp.getAuthors' ); |
2965 |
|
2966 | $authors = array(); |
2967 | foreach ( get_users( array( 'fields' => array('ID','user_login','display_name') ) ) as $user ) { |
2968 | $authors[] = array( |
2969 | 'user_id' => $user->ID, |
2970 | 'user_login' => $user->user_login, |
2971 | 'display_name' => $user->display_name |
2972 | ); |
2973 | } |
Line | Code |
2996 | $password = $args[2]; |
2997 |
|
2998 | if ( !$user = $this->login($username, $password) ) |
2999 | return $this->error; |
3000 |
|
3001 | if ( !current_user_can( 'edit_posts' ) ) |
3002 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view tags.' ) ); |
3003 |
|
3004 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3005 | do_action( 'xmlrpc_call', 'wp.getKeywords' ); |
3006 |
|
3007 | $tags = array(); |
3008 |
|
3009 | if ( $all_tags = get_tags() ) { |
3010 | foreach ( (array) $all_tags as $tag ) { |
3011 | $struct = array(); |
3012 | $struct['tag_id'] = $tag->term_id; |
3013 | $struct['name'] = $tag->name; |
3014 | $struct['count'] = $tag->count; |
Line | Code |
3043 |
|
3044 | $username = $args[1]; |
3045 | $password = $args[2]; |
3046 | $category = $args[3]; |
3047 |
|
3048 | if ( !$user = $this->login($username, $password) ) |
3049 | return $this->error; |
3050 |
|
3051 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3052 | do_action( 'xmlrpc_call', 'wp.newCategory' ); |
3053 |
|
3054 | // Make sure the user is allowed to add a category. |
3055 | if ( !current_user_can('manage_categories') ) |
3056 | return new IXR_Error(401, __('Sorry, you do not have the right to add a category.')); |
3057 |
|
3058 | // If no slug was provided make it empty so that |
3059 | // WordPress will generate one. |
3060 | if ( empty($category['slug']) ) |
3061 | $category['slug'] = ''; |
Line | Code |
3119 |
|
3120 | $username = $args[1]; |
3121 | $password = $args[2]; |
3122 | $category_id = (int) $args[3]; |
3123 |
|
3124 | if ( !$user = $this->login($username, $password) ) |
3125 | return $this->error; |
3126 |
|
3127 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3128 | do_action( 'xmlrpc_call', 'wp.deleteCategory' ); |
3129 |
|
3130 | if ( !current_user_can('manage_categories') ) |
3131 | return new IXR_Error( 401, __( 'Sorry, you do not have the right to delete a category.' ) ); |
3132 |
|
3133 | $status = wp_delete_term( $category_id, 'category' ); |
3134 |
|
3135 | if ( true == $status ) { |
3136 | /** |
3137 | * Fires after a category has been successfully deleted via XML-RPC. |
Line | Code |
3172 | $max_results = (int) $args[4]; |
3173 |
|
3174 | if ( !$user = $this->login($username, $password) ) |
3175 | return $this->error; |
3176 |
|
3177 | if ( !current_user_can( 'edit_posts' ) ) |
3178 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
3179 |
|
3180 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3181 | do_action( 'xmlrpc_call', 'wp.suggestCategories' ); |
3182 |
|
3183 | $category_suggestions = array(); |
3184 | $args = array('get' => 'all', 'number' => $max_results, 'name__like' => $category); |
3185 | foreach ( (array) get_categories($args) as $cat ) { |
3186 | $category_suggestions[] = array( |
3187 | 'category_id' => $cat->term_id, |
3188 | 'category_name' => $cat->name |
3189 | ); |
3190 | } |
Line | Code |
3213 | $username = $args[1]; |
3214 | $password = $args[2]; |
3215 | $comment_id = (int) $args[3]; |
3216 |
|
3217 | if ( ! $user = $this->login( $username, $password ) ) { |
3218 | return $this->error; |
3219 | } |
3220 |
|
3221 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3222 | do_action( 'xmlrpc_call', 'wp.getComment' ); |
3223 |
|
3224 | if ( ! $comment = get_comment( $comment_id ) ) { |
3225 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
3226 | } |
3227 |
|
3228 | if ( ! current_user_can( 'edit_comment', $comment_id ) ) { |
3229 | return new IXR_Error( 403, __( 'You are not allowed to moderate or edit this comment.' ) ); |
3230 | } |
3231 |
|
Line | Code |
3264 | $username = $args[1]; |
3265 | $password = $args[2]; |
3266 | $struct = isset( $args[3] ) ? $args[3] : array(); |
3267 |
|
3268 | if ( ! $user = $this->login( $username, $password ) ) { |
3269 | return $this->error; |
3270 | } |
3271 |
|
3272 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3273 | do_action( 'xmlrpc_call', 'wp.getComments' ); |
3274 |
|
3275 | if ( isset( $struct['status'] ) ) { |
3276 | $status = $struct['status']; |
3277 | } else { |
3278 | $status = ''; |
3279 | } |
3280 |
|
3281 | if ( ! current_user_can( 'moderate_comments' ) && 'approve' !== $status ) { |
3282 | return new IXR_Error( 401, __( 'Invalid comment status.' ) ); |
Line | Code |
3357 | if ( ! get_comment( $comment_ID ) ) { |
3358 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
3359 | } |
3360 |
|
3361 | if ( !current_user_can( 'edit_comment', $comment_ID ) ) { |
3362 | return new IXR_Error( 403, __( 'You are not allowed to moderate or edit this comment.' ) ); |
3363 | } |
3364 |
|
3365 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3366 | do_action( 'xmlrpc_call', 'wp.deleteComment' ); |
3367 |
|
3368 | $status = wp_delete_comment( $comment_ID ); |
3369 |
|
3370 | if ( $status ) { |
3371 | /** |
3372 | * Fires after a comment has been successfully deleted via XML-RPC. |
3373 | * |
3374 | * @since 3.4.0 |
3375 | * |
Line | Code |
3424 | if ( ! get_comment( $comment_ID ) ) { |
3425 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
3426 | } |
3427 |
|
3428 | if ( ! current_user_can( 'edit_comment', $comment_ID ) ) { |
3429 | return new IXR_Error( 403, __( 'You are not allowed to moderate or edit this comment.' ) ); |
3430 | } |
3431 |
|
3432 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3433 | do_action( 'xmlrpc_call', 'wp.editComment' ); |
3434 |
|
3435 | if ( isset($content_struct['status']) ) { |
3436 | $statuses = get_comment_statuses(); |
3437 | $statuses = array_keys($statuses); |
3438 |
|
3439 | if ( ! in_array($content_struct['status'], $statuses) ) |
3440 | return new IXR_Error( 401, __( 'Invalid comment status.' ) ); |
3441 | $comment_approved = $content_struct['status']; |
3442 | } |
Line | Code |
3582 | return new IXR_Error( 403, __( 'A valid email address is required' ) ); |
3583 | } |
3584 | } |
3585 |
|
3586 | $comment['comment_parent'] = isset($content_struct['comment_parent']) ? absint($content_struct['comment_parent']) : 0; |
3587 |
|
3588 | $comment['comment_content'] = isset($content_struct['content']) ? $content_struct['content'] : null; |
3589 |
|
3590 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3591 | do_action( 'xmlrpc_call', 'wp.newComment' ); |
3592 |
|
3593 | $comment_ID = wp_new_comment( $comment ); |
3594 |
|
3595 | /** |
3596 | * Fires after a new comment has been successfully created via XML-RPC. |
3597 | * |
3598 | * @since 3.4.0 |
3599 | * |
3600 | * @param int $comment_ID ID of the new comment. |
Line | Code |
3628 | if ( ! $user = $this->login( $username, $password ) ) { |
3629 | return $this->error; |
3630 | } |
3631 |
|
3632 | if ( ! current_user_can( 'publish_posts' ) ) { |
3633 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
3634 | } |
3635 |
|
3636 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3637 | do_action( 'xmlrpc_call', 'wp.getCommentStatusList' ); |
3638 |
|
3639 | return get_comment_statuses(); |
3640 | } |
3641 |
|
3642 | /** |
3643 | * Retrieve comment count. |
3644 | * |
3645 | * @since 2.5.0 |
3646 | * |
Line | Code |
3669 | if ( empty( $post['ID'] ) ) { |
3670 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
3671 | } |
3672 |
|
3673 | if ( ! current_user_can( 'edit_post', $post_id ) ) { |
3674 | return new IXR_Error( 403, __( 'You are not allowed access to details of this post.' ) ); |
3675 | } |
3676 |
|
3677 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3678 | do_action( 'xmlrpc_call', 'wp.getCommentCount' ); |
3679 |
|
3680 | $count = wp_count_comments( $post_id ); |
3681 |
|
3682 | return array( |
3683 | 'approved' => $count->approved, |
3684 | 'awaiting_moderation' => $count->moderated, |
3685 | 'spam' => $count->spam, |
3686 | 'total_comments' => $count->total_comments |
3687 | ); |
Line | Code |
3708 | $password = $args[2]; |
3709 |
|
3710 | if ( !$user = $this->login($username, $password) ) |
3711 | return $this->error; |
3712 |
|
3713 | if ( !current_user_can( 'edit_posts' ) ) |
3714 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
3715 |
|
3716 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3717 | do_action( 'xmlrpc_call', 'wp.getPostStatusList' ); |
3718 |
|
3719 | return get_post_statuses(); |
3720 | } |
3721 |
|
3722 | /** |
3723 | * Retrieve page statuses. |
3724 | * |
3725 | * @since 2.5.0 |
3726 | * |
Line | Code |
3740 | $password = $args[2]; |
3741 |
|
3742 | if ( !$user = $this->login($username, $password) ) |
3743 | return $this->error; |
3744 |
|
3745 | if ( !current_user_can( 'edit_pages' ) ) |
3746 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
3747 |
|
3748 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3749 | do_action( 'xmlrpc_call', 'wp.getPageStatusList' ); |
3750 |
|
3751 | return get_page_statuses(); |
3752 | } |
3753 |
|
3754 | /** |
3755 | * Retrieve page templates. |
3756 | * |
3757 | * @since 2.6.0 |
3758 | * |
Line | Code |
3918 | $attachment_id = (int) $args[3]; |
3919 |
|
3920 | if ( !$user = $this->login($username, $password) ) |
3921 | return $this->error; |
3922 |
|
3923 | if ( !current_user_can( 'upload_files' ) ) |
3924 | return new IXR_Error( 403, __( 'You do not have permission to upload files.' ) ); |
3925 |
|
3926 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3927 | do_action( 'xmlrpc_call', 'wp.getMediaItem' ); |
3928 |
|
3929 | if ( ! $attachment = get_post($attachment_id) ) |
3930 | return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); |
3931 |
|
3932 | return $this->_prepare_media_item( $attachment ); |
3933 | } |
3934 |
|
3935 | /** |
3936 | * Retrieves a collection of media library items (or attachments) |
Line | Code |
3966 | $struct = isset( $args[3] ) ? $args[3] : array() ; |
3967 |
|
3968 | if ( !$user = $this->login($username, $password) ) |
3969 | return $this->error; |
3970 |
|
3971 | if ( !current_user_can( 'upload_files' ) ) |
3972 | return new IXR_Error( 401, __( 'You do not have permission to upload files.' ) ); |
3973 |
|
3974 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3975 | do_action( 'xmlrpc_call', 'wp.getMediaLibrary' ); |
3976 |
|
3977 | $parent_id = ( isset($struct['parent_id']) ) ? absint($struct['parent_id']) : '' ; |
3978 | $mime_type = ( isset($struct['mime_type']) ) ? $struct['mime_type'] : '' ; |
3979 | $offset = ( isset($struct['offset']) ) ? absint($struct['offset']) : 0 ; |
3980 | $number = ( isset($struct['number']) ) ? absint($struct['number']) : -1 ; |
3981 |
|
3982 | $attachments = get_posts( array('post_type' => 'attachment', 'post_parent' => $parent_id, 'offset' => $offset, 'numberposts' => $number, 'post_mime_type' => $mime_type ) ); |
3983 |
|
3984 | $attachments_struct = array(); |
Line | Code |
4010 | $password = $args[2]; |
4011 |
|
4012 | if ( !$user = $this->login( $username, $password ) ) |
4013 | return $this->error; |
4014 |
|
4015 | if ( !current_user_can( 'edit_posts' ) ) |
4016 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
4017 |
|
4018 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4019 | do_action( 'xmlrpc_call', 'wp.getPostFormats' ); |
4020 |
|
4021 | $formats = get_post_format_strings(); |
4022 |
|
4023 | // find out if they want a list of currently supports formats |
4024 | if ( isset( $args[3] ) && is_array( $args[3] ) ) { |
4025 | if ( $args[3]['show-supported'] ) { |
4026 | if ( current_theme_supports( 'post-formats' ) ) { |
4027 | $supported = get_theme_support( 'post-formats' ); |
4028 |
|
Line | Code |
4087 | * @param string $method The method name. |
4088 | */ |
4089 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostType' ); |
4090 | } |
4091 |
|
4092 | if ( !$user = $this->login( $username, $password ) ) |
4093 | return $this->error; |
4094 |
|
4095 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4096 | do_action( 'xmlrpc_call', 'wp.getPostType' ); |
4097 |
|
4098 | if ( ! post_type_exists( $post_type_name ) ) |
4099 | return new IXR_Error( 403, __( 'Invalid post type' ) ); |
4100 |
|
4101 | $post_type = get_post_type_object( $post_type_name ); |
4102 |
|
4103 | if ( ! current_user_can( $post_type->cap->edit_posts ) ) |
4104 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post type.' ) ); |
4105 |
|
Line | Code |
4139 | } else { |
4140 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4141 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostTypes' ); |
4142 | } |
4143 |
|
4144 | if ( ! $user = $this->login( $username, $password ) ) |
4145 | return $this->error; |
4146 |
|
4147 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4148 | do_action( 'xmlrpc_call', 'wp.getPostTypes' ); |
4149 |
|
4150 | $post_types = get_post_types( $filter, 'objects' ); |
4151 |
|
4152 | $struct = array(); |
4153 |
|
4154 | foreach ( $post_types as $post_type ) { |
4155 | if ( ! current_user_can( $post_type->cap->edit_posts ) ) |
4156 | continue; |
4157 |
|
Line | Code |
4205 | * @param string $method The method name. |
4206 | */ |
4207 | $fields = apply_filters( 'xmlrpc_default_revision_fields', array( 'post_date', 'post_date_gmt' ), 'wp.getRevisions' ); |
4208 | } |
4209 |
|
4210 | if ( ! $user = $this->login( $username, $password ) ) |
4211 | return $this->error; |
4212 |
|
4213 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4214 | do_action( 'xmlrpc_call', 'wp.getRevisions' ); |
4215 |
|
4216 | if ( ! $post = get_post( $post_id ) ) |
4217 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
4218 |
|
4219 | if ( ! current_user_can( 'edit_post', $post_id ) ) |
4220 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
4221 |
|
4222 | // Check if revisions are enabled. |
4223 | if ( ! wp_revisions_enabled( $post ) ) |
Line | Code |
4269 |
|
4270 | $username = $args[1]; |
4271 | $password = $args[2]; |
4272 | $revision_id = (int) $args[3]; |
4273 |
|
4274 | if ( ! $user = $this->login( $username, $password ) ) |
4275 | return $this->error; |
4276 |
|
4277 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4278 | do_action( 'xmlrpc_call', 'wp.restoreRevision' ); |
4279 |
|
4280 | if ( ! $revision = wp_get_post_revision( $revision_id ) ) |
4281 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
4282 |
|
4283 | if ( wp_is_post_autosave( $revision ) ) |
4284 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
4285 |
|
4286 | if ( ! $post = get_post( $revision->post_parent ) ) |
4287 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
Line | Code |
4325 | $this->escape($args); |
4326 |
|
4327 | $username = $args[1]; |
4328 | $password = $args[2]; |
4329 |
|
4330 | if ( !$user = $this->login($username, $password) ) |
4331 | return $this->error; |
4332 |
|
4333 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4334 | do_action( 'xmlrpc_call', 'blogger.getUsersBlogs' ); |
4335 |
|
4336 | $is_admin = current_user_can('manage_options'); |
4337 |
|
4338 | $struct = array( |
4339 | 'isAdmin' => $is_admin, |
4340 | 'url' => get_option('home') . '/', |
4341 | 'blogid' => '1', |
4342 | 'blogName' => get_option('blogname'), |
4343 | 'xmlrpc' => site_url( 'xmlrpc.php', 'rpc' ), |
Line | Code |
4407 | $password = $args[2]; |
4408 |
|
4409 | if ( !$user = $this->login($username, $password) ) |
4410 | return $this->error; |
4411 |
|
4412 | if ( !current_user_can( 'edit_posts' ) ) |
4413 | return new IXR_Error( 401, __( 'Sorry, you do not have access to user data on this site.' ) ); |
4414 |
|
4415 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4416 | do_action( 'xmlrpc_call', 'blogger.getUserInfo' ); |
4417 |
|
4418 | $struct = array( |
4419 | 'nickname' => $user->nickname, |
4420 | 'userid' => $user->ID, |
4421 | 'url' => $user->user_url, |
4422 | 'lastname' => $user->last_name, |
4423 | 'firstname' => $user->first_name |
4424 | ); |
4425 |
|
Line | Code |
4453 |
|
4454 | $post_data = get_post($post_ID, ARRAY_A); |
4455 | if ( ! $post_data ) |
4456 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
4457 |
|
4458 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
4459 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); |
4460 |
|
4461 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4462 | do_action( 'xmlrpc_call', 'blogger.getPost' ); |
4463 |
|
4464 | $categories = implode(',', wp_get_post_categories($post_ID)); |
4465 |
|
4466 | $content = '<title>'.wp_unslash($post_data['post_title']).'</title>'; |
4467 | $content .= '<category>'.$categories.'</category>'; |
4468 | $content .= wp_unslash($post_data['post_content']); |
4469 |
|
4470 | $struct = array( |
4471 | 'userid' => $post_data['post_author'], |
Line | Code |
4506 | $query = array(); |
4507 |
|
4508 | if ( !$user = $this->login($username, $password) ) |
4509 | return $this->error; |
4510 |
|
4511 | if ( ! current_user_can( 'edit_posts' ) ) |
4512 | return new IXR_Error( 401, __( 'Sorry, you cannot edit posts on this site.' ) ); |
4513 |
|
4514 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4515 | do_action( 'xmlrpc_call', 'blogger.getRecentPosts' ); |
4516 |
|
4517 | $posts_list = wp_get_recent_posts( $query ); |
4518 |
|
4519 | if ( !$posts_list ) { |
4520 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
4521 | return $this->error; |
4522 | } |
4523 |
|
4524 | $recent_posts = array(); |
Line | Code |
4593 | $username = $args[2]; |
4594 | $password = $args[3]; |
4595 | $content = $args[4]; |
4596 | $publish = $args[5]; |
4597 |
|
4598 | if ( !$user = $this->login($username, $password) ) |
4599 | return $this->error; |
4600 |
|
4601 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4602 | do_action( 'xmlrpc_call', 'blogger.newPost' ); |
4603 |
|
4604 | $cap = ($publish) ? 'publish_posts' : 'edit_posts'; |
4605 | if ( ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) || !current_user_can($cap) ) |
4606 | return new IXR_Error(401, __('Sorry, you are not allowed to post on this site.')); |
4607 |
|
4608 | $post_status = ($publish) ? 'publish' : 'draft'; |
4609 |
|
4610 | $post_author = $user->ID; |
4611 |
|
Line | Code |
4666 | $password = $args[3]; |
4667 | $content = $args[4]; |
4668 | $publish = $args[5]; |
4669 |
|
4670 | if ( ! $user = $this->login( $username, $password ) ) { |
4671 | return $this->error; |
4672 | } |
4673 |
|
4674 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4675 | do_action( 'xmlrpc_call', 'blogger.editPost' ); |
4676 |
|
4677 | $actual_post = get_post( $post_ID, ARRAY_A ); |
4678 |
|
4679 | if ( ! $actual_post || $actual_post['post_type'] != 'post' ) { |
4680 | return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); |
4681 | } |
4682 |
|
4683 | $this->escape($actual_post); |
4684 |
|
Line | Code |
4738 |
|
4739 | $post_ID = (int) $args[1]; |
4740 | $username = $args[2]; |
4741 | $password = $args[3]; |
4742 |
|
4743 | if ( !$user = $this->login($username, $password) ) |
4744 | return $this->error; |
4745 |
|
4746 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4747 | do_action( 'xmlrpc_call', 'blogger.deletePost' ); |
4748 |
|
4749 | $actual_post = get_post( $post_ID, ARRAY_A ); |
4750 |
|
4751 | if ( ! $actual_post || $actual_post['post_type'] != 'post' ) { |
4752 | return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); |
4753 | } |
4754 |
|
4755 | if ( ! current_user_can( 'delete_post', $post_ID ) ) { |
4756 | return new IXR_Error( 401, __( 'Sorry, you do not have the right to delete this post.' ) ); |
Line | Code |
4823 | $username = $args[1]; |
4824 | $password = $args[2]; |
4825 | $content_struct = $args[3]; |
4826 | $publish = isset( $args[4] ) ? $args[4] : 0; |
4827 |
|
4828 | if ( !$user = $this->login($username, $password) ) |
4829 | return $this->error; |
4830 |
|
4831 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4832 | do_action( 'xmlrpc_call', 'metaWeblog.newPost' ); |
4833 |
|
4834 | $page_template = ''; |
4835 | if ( !empty( $content_struct['post_type'] ) ) { |
4836 | if ( $content_struct['post_type'] == 'page' ) { |
4837 | if ( $publish ) |
4838 | $cap = 'publish_pages'; |
4839 | elseif ( isset( $content_struct['page_status'] ) && 'publish' == $content_struct['page_status'] ) |
4840 | $cap = 'publish_pages'; |
4841 | else |
Line | Code |
5169 | $username = $args[1]; |
5170 | $password = $args[2]; |
5171 | $content_struct = $args[3]; |
5172 | $publish = isset( $args[4] ) ? $args[4] : 0; |
5173 |
|
5174 | if ( ! $user = $this->login($username, $password) ) |
5175 | return $this->error; |
5176 |
|
5177 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5178 | do_action( 'xmlrpc_call', 'metaWeblog.editPost' ); |
5179 |
|
5180 | $postdata = get_post( $post_ID, ARRAY_A ); |
5181 |
|
5182 | /* |
5183 | * If there is no post data for the give post id, stop now and return an error. |
5184 | * Otherwise a new post will be created (which was the old behavior). |
5185 | */ |
5186 | if ( ! $postdata || empty( $postdata[ 'ID' ] ) ) |
5187 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
Line | Code |
5481 |
|
5482 | $postdata = get_post($post_ID, ARRAY_A); |
5483 | if ( ! $postdata ) |
5484 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
5485 |
|
5486 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
5487 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); |
5488 |
|
5489 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5490 | do_action( 'xmlrpc_call', 'metaWeblog.getPost' ); |
5491 |
|
5492 | if ($postdata['post_date'] != '') { |
5493 | $post_date = $this->_convert_date( $postdata['post_date'] ); |
5494 | $post_date_gmt = $this->_convert_date_gmt( $postdata['post_date_gmt'], $postdata['post_date'] ); |
5495 | $post_modified = $this->_convert_date( $postdata['post_modified'] ); |
5496 | $post_modified_gmt = $this->_convert_date_gmt( $postdata['post_modified_gmt'], $postdata['post_modified'] ); |
5497 |
|
5498 | $categories = array(); |
5499 | $catids = wp_get_post_categories($post_ID); |
Line | Code |
5611 | $query = array(); |
5612 |
|
5613 | if ( !$user = $this->login($username, $password) ) |
5614 | return $this->error; |
5615 |
|
5616 | if ( ! current_user_can( 'edit_posts' ) ) |
5617 | return new IXR_Error( 401, __( 'Sorry, you cannot edit posts on this site.' ) ); |
5618 |
|
5619 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5620 | do_action( 'xmlrpc_call', 'metaWeblog.getRecentPosts' ); |
5621 |
|
5622 | $posts_list = wp_get_recent_posts( $query ); |
5623 |
|
5624 | if ( !$posts_list ) |
5625 | return array(); |
5626 |
|
5627 | $recent_posts = array(); |
5628 | foreach ($posts_list as $entry) { |
5629 | if ( !current_user_can( 'edit_post', $entry['ID'] ) ) |
Line | Code |
5724 | $password = $args[2]; |
5725 |
|
5726 | if ( !$user = $this->login($username, $password) ) |
5727 | return $this->error; |
5728 |
|
5729 | if ( !current_user_can( 'edit_posts' ) ) |
5730 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
5731 |
|
5732 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5733 | do_action( 'xmlrpc_call', 'metaWeblog.getCategories' ); |
5734 |
|
5735 | $categories_struct = array(); |
5736 |
|
5737 | if ( $cats = get_categories(array('get' => 'all')) ) { |
5738 | foreach ( $cats as $cat ) { |
5739 | $struct = array(); |
5740 | $struct['categoryId'] = $cat->term_id; |
5741 | $struct['parentId'] = $cat->parent; |
5742 | $struct['description'] = $cat->name; |
Line | Code |
5782 |
|
5783 | $name = sanitize_file_name( $data['name'] ); |
5784 | $type = $data['type']; |
5785 | $bits = $data['bits']; |
5786 |
|
5787 | if ( !$user = $this->login($username, $password) ) |
5788 | return $this->error; |
5789 |
|
5790 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5791 | do_action( 'xmlrpc_call', 'metaWeblog.newMediaObject' ); |
5792 |
|
5793 | if ( !current_user_can('upload_files') ) { |
5794 | $this->error = new IXR_Error( 401, __( 'You do not have permission to upload files.' ) ); |
5795 | return $this->error; |
5796 | } |
5797 |
|
5798 | if ( is_multisite() && upload_is_user_over_quota( false ) ) { |
5799 | $this->error = new IXR_Error( 401, __( 'Sorry, you have used your space allocation.' ) ); |
5800 | return $this->error; |
Line | Code |
5887 | if ( isset( $args[3] ) ) |
5888 | $query = array( 'numberposts' => absint( $args[3] ) ); |
5889 | else |
5890 | $query = array(); |
5891 |
|
5892 | if ( !$user = $this->login($username, $password) ) |
5893 | return $this->error; |
5894 |
|
5895 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5896 | do_action( 'xmlrpc_call', 'mt.getRecentPostTitles' ); |
5897 |
|
5898 | $posts_list = wp_get_recent_posts( $query ); |
5899 |
|
5900 | if ( !$posts_list ) { |
5901 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
5902 | return $this->error; |
5903 | } |
5904 |
|
5905 | $recent_posts = array(); |
Line | Code |
5945 | $password = $args[2]; |
5946 |
|
5947 | if ( !$user = $this->login($username, $password) ) |
5948 | return $this->error; |
5949 |
|
5950 | if ( !current_user_can( 'edit_posts' ) ) |
5951 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
5952 |
|
5953 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5954 | do_action( 'xmlrpc_call', 'mt.getCategoryList' ); |
5955 |
|
5956 | $categories_struct = array(); |
5957 |
|
5958 | if ( $cats = get_categories(array('hide_empty' => 0, 'hierarchical' => 0)) ) { |
5959 | foreach ( $cats as $cat ) { |
5960 | $struct = array(); |
5961 | $struct['categoryId'] = $cat->term_id; |
5962 | $struct['categoryName'] = $cat->name; |
5963 |
|
Line | Code |
5993 | return $this->error; |
5994 |
|
5995 | if ( ! get_post( $post_ID ) ) |
5996 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
5997 |
|
5998 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
5999 | return new IXR_Error( 401, __( 'Sorry, you can not edit this post.' ) ); |
6000 |
|
6001 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6002 | do_action( 'xmlrpc_call', 'mt.getPostCategories' ); |
6003 |
|
6004 | $categories = array(); |
6005 | $catids = wp_get_post_categories(intval($post_ID)); |
6006 | // first listed category will be the primary category |
6007 | $isPrimary = true; |
6008 | foreach ( $catids as $catid ) { |
6009 | $categories[] = array( |
6010 | 'categoryName' => get_cat_name($catid), |
6011 | 'categoryId' => (string) $catid, |
Line | Code |
6038 | $post_ID = (int) $args[0]; |
6039 | $username = $args[1]; |
6040 | $password = $args[2]; |
6041 | $categories = $args[3]; |
6042 |
|
6043 | if ( !$user = $this->login($username, $password) ) |
6044 | return $this->error; |
6045 |
|
6046 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6047 | do_action( 'xmlrpc_call', 'mt.setPostCategories' ); |
6048 |
|
6049 | if ( ! get_post( $post_ID ) ) |
6050 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
6051 |
|
6052 | if ( !current_user_can('edit_post', $post_ID) ) |
6053 | return new IXR_Error(401, __('Sorry, you cannot edit this post.')); |
6054 |
|
6055 | $catids = array(); |
6056 | foreach ( $categories as $cat ) { |
Line | Code |
6065 | /** |
6066 | * Retrieve an array of methods supported by this server. |
6067 | * |
6068 | * @since 1.5.0 |
6069 | * |
6070 | * @return array |
6071 | */ |
6072 | public function mt_supportedMethods() { |
6073 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6074 | do_action( 'xmlrpc_call', 'mt.supportedMethods' ); |
6075 |
|
6076 | return array_keys( $this->methods ); |
6077 | } |
6078 |
|
6079 | /** |
6080 | * Retrieve an empty array because we don't support per-post text filters. |
6081 | * |
6082 | * @since 1.5.0 |
6083 | */ |
6084 | public function mt_supportedTextFilters() { |
6085 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6086 | do_action( 'xmlrpc_call', 'mt.supportedTextFilters' ); |
6087 |
|
6088 | /** |
6089 | * Filter the MoveableType text filters list for XML-RPC. |
6090 | * |
6091 | * @since 2.2.0 |
6092 | * |
6093 | * @param array $filters An array of text filters. |
6094 | */ |
6095 | return apply_filters( 'xmlrpc_text_filters', array() ); |
Line | Code |
6103 | * @global wpdb $wpdb WordPress database abstraction object. |
6104 | * |
6105 | * @param int $post_ID |
6106 | * @return array|IXR_Error |
6107 | */ |
6108 | public function mt_getTrackbackPings( $post_ID ) { |
6109 | global $wpdb; |
6110 |
|
6111 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6112 | do_action( 'xmlrpc_call', 'mt.getTrackbackPings' ); |
6113 |
|
6114 | $actual_post = get_post($post_ID, ARRAY_A); |
6115 |
|
6116 | if ( !$actual_post ) |
6117 | return new IXR_Error(404, __('Sorry, no such post.')); |
6118 |
|
6119 | $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) ); |
6120 |
|
6121 | if ( !$comments ) |
Line | Code |
6156 |
|
6157 | $post_ID = (int) $args[0]; |
6158 | $username = $args[1]; |
6159 | $password = $args[2]; |
6160 |
|
6161 | if ( !$user = $this->login($username, $password) ) |
6162 | return $this->error; |
6163 |
|
6164 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6165 | do_action( 'xmlrpc_call', 'mt.publishPost' ); |
6166 |
|
6167 | $postdata = get_post($post_ID, ARRAY_A); |
6168 | if ( ! $postdata ) |
6169 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
6170 |
|
6171 | if ( !current_user_can('publish_posts') || !current_user_can('edit_post', $post_ID) ) |
6172 | return new IXR_Error(401, __('Sorry, you cannot publish this post.')); |
6173 |
|
6174 | $postdata['post_status'] = 'publish'; |
Line | Code |
6199 | * @type string $pagelinkedfrom |
6200 | * @type string $pagelinkedto |
6201 | * } |
6202 | * @return string|IXR_Error |
6203 | */ |
6204 | public function pingback_ping( $args ) { |
6205 | global $wpdb, $wp_version; |
6206 |
|
6207 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6208 | do_action( 'xmlrpc_call', 'pingback.ping' ); |
6209 |
|
6210 | $this->escape( $args ); |
6211 |
|
6212 | $pagelinkedfrom = str_replace( '&', '&', $args[0] ); |
6213 | $pagelinkedto = str_replace( '&', '&', $args[1] ); |
6214 | $pagelinkedto = str_replace( '&', '&', $pagelinkedto ); |
6215 |
|
6216 | /** |
6217 | * Filter the pingback source URI. |
Line | Code |
6409 | * @global wpdb $wpdb WordPress database abstraction object. |
6410 | * |
6411 | * @param string $url |
6412 | * @return array|IXR_Error |
6413 | */ |
6414 | public function pingback_extensions_getPingbacks( $url ) { |
6415 | global $wpdb; |
6416 |
|
6417 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6418 | do_action( 'xmlrpc_call', 'pingback.extensions.getPingbacks' ); |
6419 |
|
6420 | $url = $this->escape( $url ); |
6421 |
|
6422 | $post_ID = url_to_postid($url); |
6423 | if ( !$post_ID ) { |
6424 | // We aren't sure that the resource is available and/or pingback enabled |
6425 | 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.' ) ); |
6426 | } |
6427 |
|