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, __( 'The post type specified is not valid' ) ); |
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->manage_terms ) ) |
1881 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to create terms in this taxonomy.' ) ); |
1882 |
|
Line | Code |
1951 | $username = $args[1]; |
1952 | $password = $args[2]; |
1953 | $term_id = (int) $args[3]; |
1954 | $content_struct = $args[4]; |
1955 |
|
1956 | if ( ! $user = $this->login( $username, $password ) ) |
1957 | return $this->error; |
1958 |
|
1959 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
1960 | do_action( 'xmlrpc_call', 'wp.editTerm' ); |
1961 |
|
1962 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) |
1963 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
1964 |
|
1965 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
1966 |
|
1967 | if ( ! current_user_can( $taxonomy->cap->edit_terms ) ) |
1968 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit terms in this taxonomy.' ) ); |
1969 |
|
Line | Code |
2047 | $username = $args[1]; |
2048 | $password = $args[2]; |
2049 | $taxonomy = $args[3]; |
2050 | $term_id = (int) $args[4]; |
2051 |
|
2052 | if ( ! $user = $this->login( $username, $password ) ) |
2053 | return $this->error; |
2054 |
|
2055 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2056 | do_action( 'xmlrpc_call', 'wp.deleteTerm' ); |
2057 |
|
2058 | if ( ! taxonomy_exists( $taxonomy ) ) |
2059 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
2060 |
|
2061 | $taxonomy = get_taxonomy( $taxonomy ); |
2062 |
|
2063 | if ( ! current_user_can( $taxonomy->cap->delete_terms ) ) |
2064 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete terms in this taxonomy.' ) ); |
2065 |
|
Line | Code |
2118 | $username = $args[1]; |
2119 | $password = $args[2]; |
2120 | $taxonomy = $args[3]; |
2121 | $term_id = (int) $args[4]; |
2122 |
|
2123 | if ( ! $user = $this->login( $username, $password ) ) |
2124 | return $this->error; |
2125 |
|
2126 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2127 | do_action( 'xmlrpc_call', 'wp.getTerm' ); |
2128 |
|
2129 | if ( ! taxonomy_exists( $taxonomy ) ) |
2130 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
2131 |
|
2132 | $taxonomy = get_taxonomy( $taxonomy ); |
2133 |
|
2134 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
2135 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ) ); |
2136 |
|
Line | Code |
2176 | $username = $args[1]; |
2177 | $password = $args[2]; |
2178 | $taxonomy = $args[3]; |
2179 | $filter = isset( $args[4] ) ? $args[4] : array(); |
2180 |
|
2181 | if ( ! $user = $this->login( $username, $password ) ) |
2182 | return $this->error; |
2183 |
|
2184 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2185 | do_action( 'xmlrpc_call', 'wp.getTerms' ); |
2186 |
|
2187 | if ( ! taxonomy_exists( $taxonomy ) ) |
2188 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
2189 |
|
2190 | $taxonomy = get_taxonomy( $taxonomy ); |
2191 |
|
2192 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
2193 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ) ); |
2194 |
|
Line | Code |
2271 | * @param string $method The method name. |
2272 | */ |
2273 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomy' ); |
2274 | } |
2275 |
|
2276 | if ( ! $user = $this->login( $username, $password ) ) |
2277 | return $this->error; |
2278 |
|
2279 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2280 | do_action( 'xmlrpc_call', 'wp.getTaxonomy' ); |
2281 |
|
2282 | if ( ! taxonomy_exists( $taxonomy ) ) |
2283 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
2284 |
|
2285 | $taxonomy = get_taxonomy( $taxonomy ); |
2286 |
|
2287 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
2288 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ) ); |
2289 |
|
Line | Code |
2324 | } else { |
2325 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2326 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomies' ); |
2327 | } |
2328 |
|
2329 | if ( ! $user = $this->login( $username, $password ) ) |
2330 | return $this->error; |
2331 |
|
2332 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2333 | do_action( 'xmlrpc_call', 'wp.getTaxonomies' ); |
2334 |
|
2335 | $taxonomies = get_taxonomies( $filter, 'objects' ); |
2336 |
|
2337 | // holds all the taxonomy data |
2338 | $struct = array(); |
2339 |
|
2340 | foreach ( $taxonomies as $taxonomy ) { |
2341 | // capability check for post_types |
2342 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
Line | Code |
2406 | * @param string $method The method name. |
2407 | */ |
2408 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUser' ); |
2409 | } |
2410 |
|
2411 | if ( ! $user = $this->login( $username, $password ) ) |
2412 | return $this->error; |
2413 |
|
2414 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2415 | do_action( 'xmlrpc_call', 'wp.getUser' ); |
2416 |
|
2417 | if ( ! current_user_can( 'edit_user', $user_id ) ) |
2418 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this user.' ) ); |
2419 |
|
2420 | $user_data = get_userdata( $user_id ); |
2421 |
|
2422 | if ( ! $user_data ) |
2423 | return new IXR_Error( 404, __( 'Invalid user ID.' ) ); |
2424 |
|
Line | Code |
2464 | } else { |
2465 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2466 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUsers' ); |
2467 | } |
2468 |
|
2469 | if ( ! $user = $this->login( $username, $password ) ) |
2470 | return $this->error; |
2471 |
|
2472 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2473 | do_action( 'xmlrpc_call', 'wp.getUsers' ); |
2474 |
|
2475 | if ( ! current_user_can( 'list_users' ) ) |
2476 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to browse users.' ) ); |
2477 |
|
2478 | $query = array( 'fields' => 'all_with_meta' ); |
2479 |
|
2480 | $query['number'] = ( isset( $filter['number'] ) ) ? absint( $filter['number'] ) : 50; |
2481 | $query['offset'] = ( isset( $filter['offset'] ) ) ? absint( $filter['offset'] ) : 0; |
2482 |
|
Line | Code |
2537 | } else { |
2538 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2539 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getProfile' ); |
2540 | } |
2541 |
|
2542 | if ( ! $user = $this->login( $username, $password ) ) |
2543 | return $this->error; |
2544 |
|
2545 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2546 | do_action( 'xmlrpc_call', 'wp.getProfile' ); |
2547 |
|
2548 | if ( ! current_user_can( 'edit_user', $user->ID ) ) |
2549 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit your profile.' ) ); |
2550 |
|
2551 | $user_data = get_userdata( $user->ID ); |
2552 |
|
2553 | return $this->_prepare_user( $user_data, $fields ); |
2554 | } |
2555 |
|
Line | Code |
2583 |
|
2584 | $username = $args[1]; |
2585 | $password = $args[2]; |
2586 | $content_struct = $args[3]; |
2587 |
|
2588 | if ( ! $user = $this->login( $username, $password ) ) |
2589 | return $this->error; |
2590 |
|
2591 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2592 | do_action( 'xmlrpc_call', 'wp.editProfile' ); |
2593 |
|
2594 | if ( ! current_user_can( 'edit_user', $user->ID ) ) |
2595 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit your profile.' ) ); |
2596 |
|
2597 | // holds data of the user |
2598 | $user_data = array(); |
2599 | $user_data['ID'] = $user->ID; |
2600 |
|
2601 | // only set the user details if it was given |
Line | Code |
2659 |
|
2660 | $page = get_post($page_id); |
2661 | if ( ! $page ) |
2662 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
2663 |
|
2664 | if ( !current_user_can( 'edit_page', $page_id ) ) |
2665 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this page.' ) ); |
2666 |
|
2667 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2668 | do_action( 'xmlrpc_call', 'wp.getPage' ); |
2669 |
|
2670 | // If we found the page then format the data. |
2671 | if ( $page->ID && ($page->post_type == 'page') ) { |
2672 | return $this->_prepare_page( $page ); |
2673 | } |
2674 | // If the page doesn't exist indicate that. |
2675 | else { |
2676 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
2677 | } |
Line | Code |
2700 | $num_pages = isset($args[3]) ? (int) $args[3] : 10; |
2701 |
|
2702 | if ( !$user = $this->login($username, $password) ) |
2703 | return $this->error; |
2704 |
|
2705 | if ( !current_user_can( 'edit_pages' ) ) |
2706 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit pages.' ) ); |
2707 |
|
2708 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2709 | do_action( 'xmlrpc_call', 'wp.getPages' ); |
2710 |
|
2711 | $pages = get_posts( array('post_type' => 'page', 'post_status' => 'any', 'numberposts' => $num_pages) ); |
2712 | $num_pages = count($pages); |
2713 |
|
2714 | // If we have pages, put together their info. |
2715 | if ( $num_pages >= 1 ) { |
2716 | $pages_struct = array(); |
2717 |
|
2718 | foreach ($pages as $page) { |
Line | Code |
2746 | public function wp_newPage( $args ) { |
2747 | // Items not escaped here will be escaped in newPost. |
2748 | $username = $this->escape( $args[1] ); |
2749 | $password = $this->escape( $args[2] ); |
2750 |
|
2751 | if ( !$user = $this->login($username, $password) ) |
2752 | return $this->error; |
2753 |
|
2754 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2755 | do_action( 'xmlrpc_call', 'wp.newPage' ); |
2756 |
|
2757 | // Mark this as content for a page. |
2758 | $args[3]["post_type"] = 'page'; |
2759 |
|
2760 | // Let mw_newPost do all of the heavy lifting. |
2761 | return $this->mw_newPost( $args ); |
2762 | } |
2763 |
|
2764 | /** |
Line | Code |
2781 |
|
2782 | $username = $args[1]; |
2783 | $password = $args[2]; |
2784 | $page_id = (int) $args[3]; |
2785 |
|
2786 | if ( !$user = $this->login($username, $password) ) |
2787 | return $this->error; |
2788 |
|
2789 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2790 | do_action( 'xmlrpc_call', 'wp.deletePage' ); |
2791 |
|
2792 | // Get the current page based on the page_id and |
2793 | // make sure it is a page and not a post. |
2794 | $actual_page = get_post($page_id, ARRAY_A); |
2795 | if ( !$actual_page || ($actual_page['post_type'] != 'page') ) |
2796 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
2797 |
|
2798 | // Make sure the user can delete pages. |
2799 | if ( !current_user_can('delete_page', $page_id) ) |
Line | Code |
2844 |
|
2845 | $escaped_username = $this->escape( $username ); |
2846 | $escaped_password = $this->escape( $password ); |
2847 |
|
2848 | if ( !$user = $this->login( $escaped_username, $escaped_password ) ) { |
2849 | return $this->error; |
2850 | } |
2851 |
|
2852 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2853 | do_action( 'xmlrpc_call', 'wp.editPage' ); |
2854 |
|
2855 | // Get the page data and make sure it is a page. |
2856 | $actual_page = get_post($page_id, ARRAY_A); |
2857 | if ( !$actual_page || ($actual_page['post_type'] != 'page') ) |
2858 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
2859 |
|
2860 | // Make sure the user is allowed to edit pages. |
2861 | if ( !current_user_can('edit_page', $page_id) ) |
2862 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this page.' ) ); |
Line | Code |
2902 | $password = $args[2]; |
2903 |
|
2904 | if ( !$user = $this->login($username, $password) ) |
2905 | return $this->error; |
2906 |
|
2907 | if ( !current_user_can( 'edit_pages' ) ) |
2908 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit pages.' ) ); |
2909 |
|
2910 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2911 | do_action( 'xmlrpc_call', 'wp.getPageList' ); |
2912 |
|
2913 | // Get list of pages ids and titles |
2914 | $page_list = $wpdb->get_results(" |
2915 | SELECT ID page_id, |
2916 | post_title page_title, |
2917 | post_parent page_parent_id, |
2918 | post_date_gmt, |
2919 | post_date, |
2920 | post_status |
Line | Code |
2958 | $password = $args[2]; |
2959 |
|
2960 | if ( !$user = $this->login($username, $password) ) |
2961 | return $this->error; |
2962 |
|
2963 | if ( !current_user_can('edit_posts') ) |
2964 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
2965 |
|
2966 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2967 | do_action( 'xmlrpc_call', 'wp.getAuthors' ); |
2968 |
|
2969 | $authors = array(); |
2970 | foreach ( get_users( array( 'fields' => array('ID','user_login','display_name') ) ) as $user ) { |
2971 | $authors[] = array( |
2972 | 'user_id' => $user->ID, |
2973 | 'user_login' => $user->user_login, |
2974 | 'display_name' => $user->display_name |
2975 | ); |
2976 | } |
Line | Code |
2999 | $password = $args[2]; |
3000 |
|
3001 | if ( !$user = $this->login($username, $password) ) |
3002 | return $this->error; |
3003 |
|
3004 | if ( !current_user_can( 'edit_posts' ) ) |
3005 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view tags.' ) ); |
3006 |
|
3007 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3008 | do_action( 'xmlrpc_call', 'wp.getKeywords' ); |
3009 |
|
3010 | $tags = array(); |
3011 |
|
3012 | if ( $all_tags = get_tags() ) { |
3013 | foreach ( (array) $all_tags as $tag ) { |
3014 | $struct = array(); |
3015 | $struct['tag_id'] = $tag->term_id; |
3016 | $struct['name'] = $tag->name; |
3017 | $struct['count'] = $tag->count; |
Line | Code |
3046 |
|
3047 | $username = $args[1]; |
3048 | $password = $args[2]; |
3049 | $category = $args[3]; |
3050 |
|
3051 | if ( !$user = $this->login($username, $password) ) |
3052 | return $this->error; |
3053 |
|
3054 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3055 | do_action( 'xmlrpc_call', 'wp.newCategory' ); |
3056 |
|
3057 | // Make sure the user is allowed to add a category. |
3058 | if ( !current_user_can('manage_categories') ) |
3059 | return new IXR_Error(401, __('Sorry, you are not allowed to add a category.')); |
3060 |
|
3061 | // If no slug was provided make it empty so that |
3062 | // WordPress will generate one. |
3063 | if ( empty($category['slug']) ) |
3064 | $category['slug'] = ''; |
Line | Code |
3122 |
|
3123 | $username = $args[1]; |
3124 | $password = $args[2]; |
3125 | $category_id = (int) $args[3]; |
3126 |
|
3127 | if ( !$user = $this->login($username, $password) ) |
3128 | return $this->error; |
3129 |
|
3130 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3131 | do_action( 'xmlrpc_call', 'wp.deleteCategory' ); |
3132 |
|
3133 | if ( !current_user_can('manage_categories') ) |
3134 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete a category.' ) ); |
3135 |
|
3136 | $status = wp_delete_term( $category_id, 'category' ); |
3137 |
|
3138 | if ( true == $status ) { |
3139 | /** |
3140 | * Fires after a category has been successfully deleted via XML-RPC. |
Line | Code |
3175 | $max_results = (int) $args[4]; |
3176 |
|
3177 | if ( !$user = $this->login($username, $password) ) |
3178 | return $this->error; |
3179 |
|
3180 | if ( !current_user_can( 'edit_posts' ) ) |
3181 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
3182 |
|
3183 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3184 | do_action( 'xmlrpc_call', 'wp.suggestCategories' ); |
3185 |
|
3186 | $category_suggestions = array(); |
3187 | $args = array('get' => 'all', 'number' => $max_results, 'name__like' => $category); |
3188 | foreach ( (array) get_categories($args) as $cat ) { |
3189 | $category_suggestions[] = array( |
3190 | 'category_id' => $cat->term_id, |
3191 | 'category_name' => $cat->name |
3192 | ); |
3193 | } |
Line | Code |
3216 | $username = $args[1]; |
3217 | $password = $args[2]; |
3218 | $comment_id = (int) $args[3]; |
3219 |
|
3220 | if ( ! $user = $this->login( $username, $password ) ) { |
3221 | return $this->error; |
3222 | } |
3223 |
|
3224 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3225 | do_action( 'xmlrpc_call', 'wp.getComment' ); |
3226 |
|
3227 | if ( ! $comment = get_comment( $comment_id ) ) { |
3228 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
3229 | } |
3230 |
|
3231 | if ( ! current_user_can( 'edit_comment', $comment_id ) ) { |
3232 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) ); |
3233 | } |
3234 |
|
Line | Code |
3267 | $username = $args[1]; |
3268 | $password = $args[2]; |
3269 | $struct = isset( $args[3] ) ? $args[3] : array(); |
3270 |
|
3271 | if ( ! $user = $this->login( $username, $password ) ) { |
3272 | return $this->error; |
3273 | } |
3274 |
|
3275 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3276 | do_action( 'xmlrpc_call', 'wp.getComments' ); |
3277 |
|
3278 | if ( isset( $struct['status'] ) ) { |
3279 | $status = $struct['status']; |
3280 | } else { |
3281 | $status = ''; |
3282 | } |
3283 |
|
3284 | if ( ! current_user_can( 'moderate_comments' ) && 'approve' !== $status ) { |
3285 | return new IXR_Error( 401, __( 'Invalid comment status.' ) ); |
Line | Code |
3359 | if ( ! get_comment( $comment_ID ) ) { |
3360 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
3361 | } |
3362 |
|
3363 | if ( !current_user_can( 'edit_comment', $comment_ID ) ) { |
3364 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) ); |
3365 | } |
3366 |
|
3367 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3368 | do_action( 'xmlrpc_call', 'wp.deleteComment' ); |
3369 |
|
3370 | $status = wp_delete_comment( $comment_ID ); |
3371 |
|
3372 | if ( $status ) { |
3373 | /** |
3374 | * Fires after a comment has been successfully deleted via XML-RPC. |
3375 | * |
3376 | * @since 3.4.0 |
3377 | * |
Line | Code |
3426 | if ( ! get_comment( $comment_ID ) ) { |
3427 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
3428 | } |
3429 |
|
3430 | if ( ! current_user_can( 'edit_comment', $comment_ID ) ) { |
3431 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) ); |
3432 | } |
3433 |
|
3434 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3435 | do_action( 'xmlrpc_call', 'wp.editComment' ); |
3436 |
|
3437 | if ( isset($content_struct['status']) ) { |
3438 | $statuses = get_comment_statuses(); |
3439 | $statuses = array_keys($statuses); |
3440 |
|
3441 | if ( ! in_array($content_struct['status'], $statuses) ) |
3442 | return new IXR_Error( 401, __( 'Invalid comment status.' ) ); |
3443 | $comment_approved = $content_struct['status']; |
3444 | } |
Line | Code |
3584 | return new IXR_Error( 403, __( 'A valid email address is required' ) ); |
3585 | } |
3586 | } |
3587 |
|
3588 | $comment['comment_parent'] = isset($content_struct['comment_parent']) ? absint($content_struct['comment_parent']) : 0; |
3589 |
|
3590 | $comment['comment_content'] = isset($content_struct['content']) ? $content_struct['content'] : null; |
3591 |
|
3592 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3593 | do_action( 'xmlrpc_call', 'wp.newComment' ); |
3594 |
|
3595 | $comment_ID = wp_new_comment( $comment ); |
3596 |
|
3597 | /** |
3598 | * Fires after a new comment has been successfully created via XML-RPC. |
3599 | * |
3600 | * @since 3.4.0 |
3601 | * |
3602 | * @param int $comment_ID ID of the new comment. |
Line | Code |
3630 | if ( ! $user = $this->login( $username, $password ) ) { |
3631 | return $this->error; |
3632 | } |
3633 |
|
3634 | if ( ! current_user_can( 'publish_posts' ) ) { |
3635 | return new IXR_Error( 403, __( 'Sorry, you are not allowed access to details about this site.' ) ); |
3636 | } |
3637 |
|
3638 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3639 | do_action( 'xmlrpc_call', 'wp.getCommentStatusList' ); |
3640 |
|
3641 | return get_comment_statuses(); |
3642 | } |
3643 |
|
3644 | /** |
3645 | * Retrieve comment count. |
3646 | * |
3647 | * @since 2.5.0 |
3648 | * |
Line | Code |
3671 | if ( empty( $post['ID'] ) ) { |
3672 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
3673 | } |
3674 |
|
3675 | if ( ! current_user_can( 'edit_post', $post_id ) ) { |
3676 | return new IXR_Error( 403, __( 'Sorry, you are not allowed access to details of this post.' ) ); |
3677 | } |
3678 |
|
3679 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3680 | do_action( 'xmlrpc_call', 'wp.getCommentCount' ); |
3681 |
|
3682 | $count = wp_count_comments( $post_id ); |
3683 |
|
3684 | return array( |
3685 | 'approved' => $count->approved, |
3686 | 'awaiting_moderation' => $count->moderated, |
3687 | 'spam' => $count->spam, |
3688 | 'total_comments' => $count->total_comments |
3689 | ); |
Line | Code |
3710 | $password = $args[2]; |
3711 |
|
3712 | if ( !$user = $this->login($username, $password) ) |
3713 | return $this->error; |
3714 |
|
3715 | if ( !current_user_can( 'edit_posts' ) ) |
3716 | return new IXR_Error( 403, __( 'Sorry, you are not allowed access to details about this site.' ) ); |
3717 |
|
3718 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3719 | do_action( 'xmlrpc_call', 'wp.getPostStatusList' ); |
3720 |
|
3721 | return get_post_statuses(); |
3722 | } |
3723 |
|
3724 | /** |
3725 | * Retrieve page statuses. |
3726 | * |
3727 | * @since 2.5.0 |
3728 | * |
Line | Code |
3742 | $password = $args[2]; |
3743 |
|
3744 | if ( !$user = $this->login($username, $password) ) |
3745 | return $this->error; |
3746 |
|
3747 | if ( !current_user_can( 'edit_pages' ) ) |
3748 | return new IXR_Error( 403, __( 'Sorry, you are not allowed access to details about this site.' ) ); |
3749 |
|
3750 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3751 | do_action( 'xmlrpc_call', 'wp.getPageStatusList' ); |
3752 |
|
3753 | return get_page_statuses(); |
3754 | } |
3755 |
|
3756 | /** |
3757 | * Retrieve page templates. |
3758 | * |
3759 | * @since 2.6.0 |
3760 | * |
Line | Code |
3920 | $attachment_id = (int) $args[3]; |
3921 |
|
3922 | if ( !$user = $this->login($username, $password) ) |
3923 | return $this->error; |
3924 |
|
3925 | if ( !current_user_can( 'upload_files' ) ) |
3926 | return new IXR_Error( 403, __( 'Sorry, you are not allowed to upload files.' ) ); |
3927 |
|
3928 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3929 | do_action( 'xmlrpc_call', 'wp.getMediaItem' ); |
3930 |
|
3931 | if ( ! $attachment = get_post($attachment_id) ) |
3932 | return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); |
3933 |
|
3934 | return $this->_prepare_media_item( $attachment ); |
3935 | } |
3936 |
|
3937 | /** |
3938 | * Retrieves a collection of media library items (or attachments) |
Line | Code |
3968 | $struct = isset( $args[3] ) ? $args[3] : array() ; |
3969 |
|
3970 | if ( !$user = $this->login($username, $password) ) |
3971 | return $this->error; |
3972 |
|
3973 | if ( !current_user_can( 'upload_files' ) ) |
3974 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to upload files.' ) ); |
3975 |
|
3976 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3977 | do_action( 'xmlrpc_call', 'wp.getMediaLibrary' ); |
3978 |
|
3979 | $parent_id = ( isset($struct['parent_id']) ) ? absint($struct['parent_id']) : '' ; |
3980 | $mime_type = ( isset($struct['mime_type']) ) ? $struct['mime_type'] : '' ; |
3981 | $offset = ( isset($struct['offset']) ) ? absint($struct['offset']) : 0 ; |
3982 | $number = ( isset($struct['number']) ) ? absint($struct['number']) : -1 ; |
3983 |
|
3984 | $attachments = get_posts( array('post_type' => 'attachment', 'post_parent' => $parent_id, 'offset' => $offset, 'numberposts' => $number, 'post_mime_type' => $mime_type ) ); |
3985 |
|
3986 | $attachments_struct = array(); |
Line | Code |
4012 | $password = $args[2]; |
4013 |
|
4014 | if ( !$user = $this->login( $username, $password ) ) |
4015 | return $this->error; |
4016 |
|
4017 | if ( !current_user_can( 'edit_posts' ) ) |
4018 | return new IXR_Error( 403, __( 'Sorry, you are not allowed access to details about this site.' ) ); |
4019 |
|
4020 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4021 | do_action( 'xmlrpc_call', 'wp.getPostFormats' ); |
4022 |
|
4023 | $formats = get_post_format_strings(); |
4024 |
|
4025 | // find out if they want a list of currently supports formats |
4026 | if ( isset( $args[3] ) && is_array( $args[3] ) ) { |
4027 | if ( $args[3]['show-supported'] ) { |
4028 | if ( current_theme_supports( 'post-formats' ) ) { |
4029 | $supported = get_theme_support( 'post-formats' ); |
4030 |
|
Line | Code |
4089 | * @param string $method The method name. |
4090 | */ |
4091 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostType' ); |
4092 | } |
4093 |
|
4094 | if ( !$user = $this->login( $username, $password ) ) |
4095 | return $this->error; |
4096 |
|
4097 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4098 | do_action( 'xmlrpc_call', 'wp.getPostType' ); |
4099 |
|
4100 | if ( ! post_type_exists( $post_type_name ) ) |
4101 | return new IXR_Error( 403, __( 'Invalid post type.' ) ); |
4102 |
|
4103 | $post_type = get_post_type_object( $post_type_name ); |
4104 |
|
4105 | if ( ! current_user_can( $post_type->cap->edit_posts ) ) |
4106 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post type.' ) ); |
4107 |
|
Line | Code |
4141 | } else { |
4142 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4143 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostTypes' ); |
4144 | } |
4145 |
|
4146 | if ( ! $user = $this->login( $username, $password ) ) |
4147 | return $this->error; |
4148 |
|
4149 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4150 | do_action( 'xmlrpc_call', 'wp.getPostTypes' ); |
4151 |
|
4152 | $post_types = get_post_types( $filter, 'objects' ); |
4153 |
|
4154 | $struct = array(); |
4155 |
|
4156 | foreach ( $post_types as $post_type ) { |
4157 | if ( ! current_user_can( $post_type->cap->edit_posts ) ) |
4158 | continue; |
4159 |
|
Line | Code |
4207 | * @param string $method The method name. |
4208 | */ |
4209 | $fields = apply_filters( 'xmlrpc_default_revision_fields', array( 'post_date', 'post_date_gmt' ), 'wp.getRevisions' ); |
4210 | } |
4211 |
|
4212 | if ( ! $user = $this->login( $username, $password ) ) |
4213 | return $this->error; |
4214 |
|
4215 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4216 | do_action( 'xmlrpc_call', 'wp.getRevisions' ); |
4217 |
|
4218 | if ( ! $post = get_post( $post_id ) ) |
4219 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
4220 |
|
4221 | if ( ! current_user_can( 'edit_post', $post_id ) ) |
4222 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
4223 |
|
4224 | // Check if revisions are enabled. |
4225 | if ( ! wp_revisions_enabled( $post ) ) |
Line | Code |
4271 |
|
4272 | $username = $args[1]; |
4273 | $password = $args[2]; |
4274 | $revision_id = (int) $args[3]; |
4275 |
|
4276 | if ( ! $user = $this->login( $username, $password ) ) |
4277 | return $this->error; |
4278 |
|
4279 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4280 | do_action( 'xmlrpc_call', 'wp.restoreRevision' ); |
4281 |
|
4282 | if ( ! $revision = wp_get_post_revision( $revision_id ) ) |
4283 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
4284 |
|
4285 | if ( wp_is_post_autosave( $revision ) ) |
4286 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
4287 |
|
4288 | if ( ! $post = get_post( $revision->post_parent ) ) |
4289 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
Line | Code |
4327 | $this->escape($args); |
4328 |
|
4329 | $username = $args[1]; |
4330 | $password = $args[2]; |
4331 |
|
4332 | if ( !$user = $this->login($username, $password) ) |
4333 | return $this->error; |
4334 |
|
4335 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4336 | do_action( 'xmlrpc_call', 'blogger.getUsersBlogs' ); |
4337 |
|
4338 | $is_admin = current_user_can('manage_options'); |
4339 |
|
4340 | $struct = array( |
4341 | 'isAdmin' => $is_admin, |
4342 | 'url' => get_option('home') . '/', |
4343 | 'blogid' => '1', |
4344 | 'blogName' => get_option('blogname'), |
4345 | 'xmlrpc' => site_url( 'xmlrpc.php', 'rpc' ), |
Line | Code |
4409 | $password = $args[2]; |
4410 |
|
4411 | if ( !$user = $this->login($username, $password) ) |
4412 | return $this->error; |
4413 |
|
4414 | if ( !current_user_can( 'edit_posts' ) ) |
4415 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to access user data on this site.' ) ); |
4416 |
|
4417 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4418 | do_action( 'xmlrpc_call', 'blogger.getUserInfo' ); |
4419 |
|
4420 | $struct = array( |
4421 | 'nickname' => $user->nickname, |
4422 | 'userid' => $user->ID, |
4423 | 'url' => $user->user_url, |
4424 | 'lastname' => $user->last_name, |
4425 | 'firstname' => $user->first_name |
4426 | ); |
4427 |
|
Line | Code |
4455 |
|
4456 | $post_data = get_post($post_ID, ARRAY_A); |
4457 | if ( ! $post_data ) |
4458 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
4459 |
|
4460 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
4461 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
4462 |
|
4463 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4464 | do_action( 'xmlrpc_call', 'blogger.getPost' ); |
4465 |
|
4466 | $categories = implode(',', wp_get_post_categories($post_ID)); |
4467 |
|
4468 | $content = '<title>'.wp_unslash($post_data['post_title']).'</title>'; |
4469 | $content .= '<category>'.$categories.'</category>'; |
4470 | $content .= wp_unslash($post_data['post_content']); |
4471 |
|
4472 | $struct = array( |
4473 | 'userid' => $post_data['post_author'], |
Line | Code |
4508 | $query = array(); |
4509 |
|
4510 | if ( !$user = $this->login($username, $password) ) |
4511 | return $this->error; |
4512 |
|
4513 | if ( ! current_user_can( 'edit_posts' ) ) |
4514 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
4515 |
|
4516 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4517 | do_action( 'xmlrpc_call', 'blogger.getRecentPosts' ); |
4518 |
|
4519 | $posts_list = wp_get_recent_posts( $query ); |
4520 |
|
4521 | if ( !$posts_list ) { |
4522 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
4523 | return $this->error; |
4524 | } |
4525 |
|
4526 | $recent_posts = array(); |
Line | Code |
4595 | $username = $args[2]; |
4596 | $password = $args[3]; |
4597 | $content = $args[4]; |
4598 | $publish = $args[5]; |
4599 |
|
4600 | if ( !$user = $this->login($username, $password) ) |
4601 | return $this->error; |
4602 |
|
4603 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4604 | do_action( 'xmlrpc_call', 'blogger.newPost' ); |
4605 |
|
4606 | $cap = ($publish) ? 'publish_posts' : 'edit_posts'; |
4607 | if ( ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) || !current_user_can($cap) ) |
4608 | return new IXR_Error(401, __('Sorry, you are not allowed to post on this site.')); |
4609 |
|
4610 | $post_status = ($publish) ? 'publish' : 'draft'; |
4611 |
|
4612 | $post_author = $user->ID; |
4613 |
|
Line | Code |
4668 | $password = $args[3]; |
4669 | $content = $args[4]; |
4670 | $publish = $args[5]; |
4671 |
|
4672 | if ( ! $user = $this->login( $username, $password ) ) { |
4673 | return $this->error; |
4674 | } |
4675 |
|
4676 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4677 | do_action( 'xmlrpc_call', 'blogger.editPost' ); |
4678 |
|
4679 | $actual_post = get_post( $post_ID, ARRAY_A ); |
4680 |
|
4681 | if ( ! $actual_post || $actual_post['post_type'] != 'post' ) { |
4682 | return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); |
4683 | } |
4684 |
|
4685 | $this->escape($actual_post); |
4686 |
|
Line | Code |
4740 |
|
4741 | $post_ID = (int) $args[1]; |
4742 | $username = $args[2]; |
4743 | $password = $args[3]; |
4744 |
|
4745 | if ( !$user = $this->login($username, $password) ) |
4746 | return $this->error; |
4747 |
|
4748 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4749 | do_action( 'xmlrpc_call', 'blogger.deletePost' ); |
4750 |
|
4751 | $actual_post = get_post( $post_ID, ARRAY_A ); |
4752 |
|
4753 | if ( ! $actual_post || $actual_post['post_type'] != 'post' ) { |
4754 | return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); |
4755 | } |
4756 |
|
4757 | if ( ! current_user_can( 'delete_post', $post_ID ) ) { |
4758 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) ); |
Line | Code |
4825 | $username = $args[1]; |
4826 | $password = $args[2]; |
4827 | $content_struct = $args[3]; |
4828 | $publish = isset( $args[4] ) ? $args[4] : 0; |
4829 |
|
4830 | if ( !$user = $this->login($username, $password) ) |
4831 | return $this->error; |
4832 |
|
4833 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4834 | do_action( 'xmlrpc_call', 'metaWeblog.newPost' ); |
4835 |
|
4836 | $page_template = ''; |
4837 | if ( !empty( $content_struct['post_type'] ) ) { |
4838 | if ( $content_struct['post_type'] == 'page' ) { |
4839 | if ( $publish ) |
4840 | $cap = 'publish_pages'; |
4841 | elseif ( isset( $content_struct['page_status'] ) && 'publish' == $content_struct['page_status'] ) |
4842 | $cap = 'publish_pages'; |
4843 | else |
Line | Code |
5171 | $username = $args[1]; |
5172 | $password = $args[2]; |
5173 | $content_struct = $args[3]; |
5174 | $publish = isset( $args[4] ) ? $args[4] : 0; |
5175 |
|
5176 | if ( ! $user = $this->login($username, $password) ) |
5177 | return $this->error; |
5178 |
|
5179 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5180 | do_action( 'xmlrpc_call', 'metaWeblog.editPost' ); |
5181 |
|
5182 | $postdata = get_post( $post_ID, ARRAY_A ); |
5183 |
|
5184 | /* |
5185 | * If there is no post data for the give post id, stop now and return an error. |
5186 | * Otherwise a new post will be created (which was the old behavior). |
5187 | */ |
5188 | if ( ! $postdata || empty( $postdata[ 'ID' ] ) ) |
5189 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
Line | Code |
5483 |
|
5484 | $postdata = get_post($post_ID, ARRAY_A); |
5485 | if ( ! $postdata ) |
5486 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
5487 |
|
5488 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
5489 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
5490 |
|
5491 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5492 | do_action( 'xmlrpc_call', 'metaWeblog.getPost' ); |
5493 |
|
5494 | if ($postdata['post_date'] != '') { |
5495 | $post_date = $this->_convert_date( $postdata['post_date'] ); |
5496 | $post_date_gmt = $this->_convert_date_gmt( $postdata['post_date_gmt'], $postdata['post_date'] ); |
5497 | $post_modified = $this->_convert_date( $postdata['post_modified'] ); |
5498 | $post_modified_gmt = $this->_convert_date_gmt( $postdata['post_modified_gmt'], $postdata['post_modified'] ); |
5499 |
|
5500 | $categories = array(); |
5501 | $catids = wp_get_post_categories($post_ID); |
Line | Code |
5613 | $query = array(); |
5614 |
|
5615 | if ( !$user = $this->login($username, $password) ) |
5616 | return $this->error; |
5617 |
|
5618 | if ( ! current_user_can( 'edit_posts' ) ) |
5619 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
5620 |
|
5621 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5622 | do_action( 'xmlrpc_call', 'metaWeblog.getRecentPosts' ); |
5623 |
|
5624 | $posts_list = wp_get_recent_posts( $query ); |
5625 |
|
5626 | if ( !$posts_list ) |
5627 | return array(); |
5628 |
|
5629 | $recent_posts = array(); |
5630 | foreach ($posts_list as $entry) { |
5631 | if ( !current_user_can( 'edit_post', $entry['ID'] ) ) |
Line | Code |
5726 | $password = $args[2]; |
5727 |
|
5728 | if ( !$user = $this->login($username, $password) ) |
5729 | return $this->error; |
5730 |
|
5731 | if ( !current_user_can( 'edit_posts' ) ) |
5732 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
5733 |
|
5734 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5735 | do_action( 'xmlrpc_call', 'metaWeblog.getCategories' ); |
5736 |
|
5737 | $categories_struct = array(); |
5738 |
|
5739 | if ( $cats = get_categories(array('get' => 'all')) ) { |
5740 | foreach ( $cats as $cat ) { |
5741 | $struct = array(); |
5742 | $struct['categoryId'] = $cat->term_id; |
5743 | $struct['parentId'] = $cat->parent; |
5744 | $struct['description'] = $cat->name; |
Line | Code |
5784 |
|
5785 | $name = sanitize_file_name( $data['name'] ); |
5786 | $type = $data['type']; |
5787 | $bits = $data['bits']; |
5788 |
|
5789 | if ( !$user = $this->login($username, $password) ) |
5790 | return $this->error; |
5791 |
|
5792 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5793 | do_action( 'xmlrpc_call', 'metaWeblog.newMediaObject' ); |
5794 |
|
5795 | if ( !current_user_can('upload_files') ) { |
5796 | $this->error = new IXR_Error( 401, __( 'Sorry, you are not allowed to upload files.' ) ); |
5797 | return $this->error; |
5798 | } |
5799 |
|
5800 | if ( is_multisite() && upload_is_user_over_quota( false ) ) { |
5801 | $this->error = new IXR_Error( 401, __( 'Sorry, you have used your space allocation.' ) ); |
5802 | return $this->error; |
Line | Code |
5889 | if ( isset( $args[3] ) ) |
5890 | $query = array( 'numberposts' => absint( $args[3] ) ); |
5891 | else |
5892 | $query = array(); |
5893 |
|
5894 | if ( !$user = $this->login($username, $password) ) |
5895 | return $this->error; |
5896 |
|
5897 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5898 | do_action( 'xmlrpc_call', 'mt.getRecentPostTitles' ); |
5899 |
|
5900 | $posts_list = wp_get_recent_posts( $query ); |
5901 |
|
5902 | if ( !$posts_list ) { |
5903 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
5904 | return $this->error; |
5905 | } |
5906 |
|
5907 | $recent_posts = array(); |
Line | Code |
5947 | $password = $args[2]; |
5948 |
|
5949 | if ( !$user = $this->login($username, $password) ) |
5950 | return $this->error; |
5951 |
|
5952 | if ( !current_user_can( 'edit_posts' ) ) |
5953 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
5954 |
|
5955 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5956 | do_action( 'xmlrpc_call', 'mt.getCategoryList' ); |
5957 |
|
5958 | $categories_struct = array(); |
5959 |
|
5960 | if ( $cats = get_categories(array('hide_empty' => 0, 'hierarchical' => 0)) ) { |
5961 | foreach ( $cats as $cat ) { |
5962 | $struct = array(); |
5963 | $struct['categoryId'] = $cat->term_id; |
5964 | $struct['categoryName'] = $cat->name; |
5965 |
|
Line | Code |
5995 | return $this->error; |
5996 |
|
5997 | if ( ! get_post( $post_ID ) ) |
5998 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
5999 |
|
6000 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
6001 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); |
6002 |
|
6003 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6004 | do_action( 'xmlrpc_call', 'mt.getPostCategories' ); |
6005 |
|
6006 | $categories = array(); |
6007 | $catids = wp_get_post_categories(intval($post_ID)); |
6008 | // first listed category will be the primary category |
6009 | $isPrimary = true; |
6010 | foreach ( $catids as $catid ) { |
6011 | $categories[] = array( |
6012 | 'categoryName' => get_cat_name($catid), |
6013 | 'categoryId' => (string) $catid, |
Line | Code |
6040 | $post_ID = (int) $args[0]; |
6041 | $username = $args[1]; |
6042 | $password = $args[2]; |
6043 | $categories = $args[3]; |
6044 |
|
6045 | if ( !$user = $this->login($username, $password) ) |
6046 | return $this->error; |
6047 |
|
6048 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6049 | do_action( 'xmlrpc_call', 'mt.setPostCategories' ); |
6050 |
|
6051 | if ( ! get_post( $post_ID ) ) |
6052 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
6053 |
|
6054 | if ( !current_user_can('edit_post', $post_ID) ) |
6055 | return new IXR_Error(401, __('Sorry, you are not allowed to edit this post.')); |
6056 |
|
6057 | $catids = array(); |
6058 | foreach ( $categories as $cat ) { |
Line | Code |
6067 | /** |
6068 | * Retrieve an array of methods supported by this server. |
6069 | * |
6070 | * @since 1.5.0 |
6071 | * |
6072 | * @return array |
6073 | */ |
6074 | public function mt_supportedMethods() { |
6075 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6076 | do_action( 'xmlrpc_call', 'mt.supportedMethods' ); |
6077 |
|
6078 | return array_keys( $this->methods ); |
6079 | } |
6080 |
|
6081 | /** |
6082 | * Retrieve an empty array because we don't support per-post text filters. |
6083 | * |
6084 | * @since 1.5.0 |
6085 | */ |
6086 | public function mt_supportedTextFilters() { |
6087 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6088 | do_action( 'xmlrpc_call', 'mt.supportedTextFilters' ); |
6089 |
|
6090 | /** |
6091 | * Filters the MoveableType text filters list for XML-RPC. |
6092 | * |
6093 | * @since 2.2.0 |
6094 | * |
6095 | * @param array $filters An array of text filters. |
6096 | */ |
6097 | return apply_filters( 'xmlrpc_text_filters', array() ); |
Line | Code |
6105 | * @global wpdb $wpdb WordPress database abstraction object. |
6106 | * |
6107 | * @param int $post_ID |
6108 | * @return array|IXR_Error |
6109 | */ |
6110 | public function mt_getTrackbackPings( $post_ID ) { |
6111 | global $wpdb; |
6112 |
|
6113 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6114 | do_action( 'xmlrpc_call', 'mt.getTrackbackPings' ); |
6115 |
|
6116 | $actual_post = get_post($post_ID, ARRAY_A); |
6117 |
|
6118 | if ( !$actual_post ) |
6119 | return new IXR_Error(404, __('Sorry, no such post.')); |
6120 |
|
6121 | $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) ); |
6122 |
|
6123 | if ( !$comments ) |
Line | Code |
6158 |
|
6159 | $post_ID = (int) $args[0]; |
6160 | $username = $args[1]; |
6161 | $password = $args[2]; |
6162 |
|
6163 | if ( !$user = $this->login($username, $password) ) |
6164 | return $this->error; |
6165 |
|
6166 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6167 | do_action( 'xmlrpc_call', 'mt.publishPost' ); |
6168 |
|
6169 | $postdata = get_post($post_ID, ARRAY_A); |
6170 | if ( ! $postdata ) |
6171 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
6172 |
|
6173 | if ( !current_user_can('publish_posts') || !current_user_can('edit_post', $post_ID) ) |
6174 | return new IXR_Error(401, __('Sorry, you are not allowed to publish this post.')); |
6175 |
|
6176 | $postdata['post_status'] = 'publish'; |
Line | Code |
6201 | * @type string $pagelinkedfrom |
6202 | * @type string $pagelinkedto |
6203 | * } |
6204 | * @return string|IXR_Error |
6205 | */ |
6206 | public function pingback_ping( $args ) { |
6207 | global $wpdb, $wp_version; |
6208 |
|
6209 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6210 | do_action( 'xmlrpc_call', 'pingback.ping' ); |
6211 |
|
6212 | $this->escape( $args ); |
6213 |
|
6214 | $pagelinkedfrom = str_replace( '&', '&', $args[0] ); |
6215 | $pagelinkedto = str_replace( '&', '&', $args[1] ); |
6216 | $pagelinkedto = str_replace( '&', '&', $pagelinkedto ); |
6217 |
|
6218 | /** |
6219 | * Filters the pingback source URI. |
Line | Code |
6411 | * @global wpdb $wpdb WordPress database abstraction object. |
6412 | * |
6413 | * @param string $url |
6414 | * @return array|IXR_Error |
6415 | */ |
6416 | public function pingback_extensions_getPingbacks( $url ) { |
6417 | global $wpdb; |
6418 |
|
6419 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
6420 | do_action( 'xmlrpc_call', 'pingback.extensions.getPingbacks' ); |
6421 |
|
6422 | $url = $this->escape( $url ); |
6423 |
|
6424 | $post_ID = url_to_postid($url); |
6425 | if ( !$post_ID ) { |
6426 | // We aren't sure that the resource is available and/or pingback enabled |
6427 | 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.' ) ); |
6428 | } |
6429 |
|