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 |
|---|---|
| 569 | * the method logic begins. |
| 570 | * |
| 571 | * All built-in XML-RPC methods use the action xmlrpc_call, with a parameter |
| 572 | * equal to the method's name, e.g., wp.getUsersBlogs, wp.newPost, etc. |
| 573 | * |
| 574 | * @since 2.5.0 |
| 575 | * |
| 576 | * @param string $name The method name. |
| 577 | */ |
| 578 | do_action( 'xmlrpc_call', 'wp.getUsersBlogs' ); |
| 579 | |
| 580 | $blogs = (array) get_blogs_of_user( $user->ID ); |
| 581 | $struct = array(); |
| 582 | |
| 583 | foreach ( $blogs as $blog ) { |
| 584 | // Don't include blogs that aren't hosted at this site. |
| 585 | if ( $blog->site_id != get_current_site()->id ) |
| 586 | continue; |
| 587 | |
| Line | Code |
| 1168 | if ( isset( $content_struct['post_date_gmt'] ) && ! ( $content_struct['post_date_gmt'] instanceof IXR_Date ) ) { |
| 1169 | if ( $content_struct['post_date_gmt'] == '0000-00-00 00:00:00' || isset( $content_struct['post_date'] ) ) { |
| 1170 | unset( $content_struct['post_date_gmt'] ); |
| 1171 | } else { |
| 1172 | $content_struct['post_date_gmt'] = $this->_convert_date( $content_struct['post_date_gmt'] ); |
| 1173 | } |
| 1174 | } |
| 1175 | |
| 1176 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1177 | do_action( 'xmlrpc_call', 'wp.newPost' ); |
| 1178 | |
| 1179 | unset( $content_struct['ID'] ); |
| 1180 | |
| 1181 | return $this->_insert_post( $user, $content_struct ); |
| 1182 | } |
| 1183 | |
| 1184 | /** |
| 1185 | * Helper method for filtering out elements from an array. |
| 1186 | * |
| Line | Code |
| 1498 | $username = $args[1]; |
| 1499 | $password = $args[2]; |
| 1500 | $post_id = (int) $args[3]; |
| 1501 | $content_struct = $args[4]; |
| 1502 | |
| 1503 | if ( ! $user = $this->login( $username, $password ) ) |
| 1504 | return $this->error; |
| 1505 | |
| 1506 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1507 | do_action( 'xmlrpc_call', 'wp.editPost' ); |
| 1508 | |
| 1509 | $post = get_post( $post_id, ARRAY_A ); |
| 1510 | |
| 1511 | if ( empty( $post['ID'] ) ) |
| 1512 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 1513 | |
| 1514 | if ( isset( $content_struct['if_not_modified_since'] ) ) { |
| 1515 | // If the post has been modified since the date provided, return an error. |
| 1516 | if ( mysql2date( 'U', $post['post_modified_gmt'] ) > $content_struct['if_not_modified_since']->getTimestamp() ) { |
| Line | Code |
| 1565 | |
| 1566 | $username = $args[1]; |
| 1567 | $password = $args[2]; |
| 1568 | $post_id = (int) $args[3]; |
| 1569 | |
| 1570 | if ( ! $user = $this->login( $username, $password ) ) |
| 1571 | return $this->error; |
| 1572 | |
| 1573 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1574 | do_action( 'xmlrpc_call', 'wp.deletePost' ); |
| 1575 | |
| 1576 | $post = get_post( $post_id, ARRAY_A ); |
| 1577 | if ( empty( $post['ID'] ) ) |
| 1578 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 1579 | |
| 1580 | if ( ! current_user_can( 'delete_post', $post_id ) ) |
| 1581 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) ); |
| 1582 | |
| 1583 | $result = wp_delete_post( $post_id ); |
| Line | Code |
| 1659 | * @param string $method Method name. |
| 1660 | */ |
| 1661 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPost' ); |
| 1662 | } |
| 1663 | |
| 1664 | if ( ! $user = $this->login( $username, $password ) ) |
| 1665 | return $this->error; |
| 1666 | |
| 1667 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1668 | do_action( 'xmlrpc_call', 'wp.getPost' ); |
| 1669 | |
| 1670 | $post = get_post( $post_id, ARRAY_A ); |
| 1671 | |
| 1672 | if ( empty( $post['ID'] ) ) |
| 1673 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 1674 | |
| 1675 | if ( ! current_user_can( 'edit_post', $post_id ) ) |
| 1676 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); |
| 1677 | |
| Line | Code |
| 1715 | } else { |
| 1716 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1717 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPosts' ); |
| 1718 | } |
| 1719 | |
| 1720 | if ( ! $user = $this->login( $username, $password ) ) |
| 1721 | return $this->error; |
| 1722 | |
| 1723 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1724 | do_action( 'xmlrpc_call', 'wp.getPosts' ); |
| 1725 | |
| 1726 | $query = array(); |
| 1727 | |
| 1728 | if ( isset( $filter['post_type'] ) ) { |
| 1729 | $post_type = get_post_type_object( $filter['post_type'] ); |
| 1730 | if ( ! ( (bool) $post_type ) ) |
| 1731 | return new IXR_Error( 403, __( 'The post type specified is not valid' ) ); |
| 1732 | } else { |
| 1733 | $post_type = get_post_type_object( 'post' ); |
| Line | Code |
| 1803 | |
| 1804 | $username = $args[1]; |
| 1805 | $password = $args[2]; |
| 1806 | $content_struct = $args[3]; |
| 1807 | |
| 1808 | if ( ! $user = $this->login( $username, $password ) ) |
| 1809 | return $this->error; |
| 1810 | |
| 1811 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1812 | do_action( 'xmlrpc_call', 'wp.newTerm' ); |
| 1813 | |
| 1814 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) |
| 1815 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
| 1816 | |
| 1817 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
| 1818 | |
| 1819 | if ( ! current_user_can( $taxonomy->cap->manage_terms ) ) |
| 1820 | return new IXR_Error( 401, __( 'You are not allowed to create terms in this taxonomy.' ) ); |
| 1821 | |
| Line | Code |
| 1890 | $username = $args[1]; |
| 1891 | $password = $args[2]; |
| 1892 | $term_id = (int) $args[3]; |
| 1893 | $content_struct = $args[4]; |
| 1894 | |
| 1895 | if ( ! $user = $this->login( $username, $password ) ) |
| 1896 | return $this->error; |
| 1897 | |
| 1898 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1899 | do_action( 'xmlrpc_call', 'wp.editTerm' ); |
| 1900 | |
| 1901 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) |
| 1902 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
| 1903 | |
| 1904 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
| 1905 | |
| 1906 | if ( ! current_user_can( $taxonomy->cap->edit_terms ) ) |
| 1907 | return new IXR_Error( 401, __( 'You are not allowed to edit terms in this taxonomy.' ) ); |
| 1908 | |
| Line | Code |
| 1986 | $username = $args[1]; |
| 1987 | $password = $args[2]; |
| 1988 | $taxonomy = $args[3]; |
| 1989 | $term_id = (int) $args[4]; |
| 1990 | |
| 1991 | if ( ! $user = $this->login( $username, $password ) ) |
| 1992 | return $this->error; |
| 1993 | |
| 1994 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1995 | do_action( 'xmlrpc_call', 'wp.deleteTerm' ); |
| 1996 | |
| 1997 | if ( ! taxonomy_exists( $taxonomy ) ) |
| 1998 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
| 1999 | |
| 2000 | $taxonomy = get_taxonomy( $taxonomy ); |
| 2001 | |
| 2002 | if ( ! current_user_can( $taxonomy->cap->delete_terms ) ) |
| 2003 | return new IXR_Error( 401, __( 'You are not allowed to delete terms in this taxonomy.' ) ); |
| 2004 | |
| Line | Code |
| 2057 | $username = $args[1]; |
| 2058 | $password = $args[2]; |
| 2059 | $taxonomy = $args[3]; |
| 2060 | $term_id = (int) $args[4]; |
| 2061 | |
| 2062 | if ( ! $user = $this->login( $username, $password ) ) |
| 2063 | return $this->error; |
| 2064 | |
| 2065 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2066 | do_action( 'xmlrpc_call', 'wp.getTerm' ); |
| 2067 | |
| 2068 | if ( ! taxonomy_exists( $taxonomy ) ) |
| 2069 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
| 2070 | |
| 2071 | $taxonomy = get_taxonomy( $taxonomy ); |
| 2072 | |
| 2073 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
| 2074 | return new IXR_Error( 401, __( 'You are not allowed to assign terms in this taxonomy.' ) ); |
| 2075 | |
| Line | Code |
| 2115 | $username = $args[1]; |
| 2116 | $password = $args[2]; |
| 2117 | $taxonomy = $args[3]; |
| 2118 | $filter = isset( $args[4] ) ? $args[4] : array(); |
| 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.getTerms' ); |
| 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 |
| 2210 | * @param string $method The method name. |
| 2211 | */ |
| 2212 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomy' ); |
| 2213 | } |
| 2214 | |
| 2215 | if ( ! $user = $this->login( $username, $password ) ) |
| 2216 | return $this->error; |
| 2217 | |
| 2218 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2219 | do_action( 'xmlrpc_call', 'wp.getTaxonomy' ); |
| 2220 | |
| 2221 | if ( ! taxonomy_exists( $taxonomy ) ) |
| 2222 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
| 2223 | |
| 2224 | $taxonomy = get_taxonomy( $taxonomy ); |
| 2225 | |
| 2226 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
| 2227 | return new IXR_Error( 401, __( 'You are not allowed to assign terms in this taxonomy.' ) ); |
| 2228 | |
| Line | Code |
| 2263 | } else { |
| 2264 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2265 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomies' ); |
| 2266 | } |
| 2267 | |
| 2268 | if ( ! $user = $this->login( $username, $password ) ) |
| 2269 | return $this->error; |
| 2270 | |
| 2271 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2272 | do_action( 'xmlrpc_call', 'wp.getTaxonomies' ); |
| 2273 | |
| 2274 | $taxonomies = get_taxonomies( $filter, 'objects' ); |
| 2275 | |
| 2276 | // holds all the taxonomy data |
| 2277 | $struct = array(); |
| 2278 | |
| 2279 | foreach ( $taxonomies as $taxonomy ) { |
| 2280 | // capability check for post_types |
| 2281 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
| Line | Code |
| 2345 | * @param string $method The method name. |
| 2346 | */ |
| 2347 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUser' ); |
| 2348 | } |
| 2349 | |
| 2350 | if ( ! $user = $this->login( $username, $password ) ) |
| 2351 | return $this->error; |
| 2352 | |
| 2353 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2354 | do_action( 'xmlrpc_call', 'wp.getUser' ); |
| 2355 | |
| 2356 | if ( ! current_user_can( 'edit_user', $user_id ) ) |
| 2357 | return new IXR_Error( 401, __( 'Sorry, you cannot edit users.' ) ); |
| 2358 | |
| 2359 | $user_data = get_userdata( $user_id ); |
| 2360 | |
| 2361 | if ( ! $user_data ) |
| 2362 | return new IXR_Error( 404, __( 'Invalid user ID.' ) ); |
| 2363 | |
| Line | Code |
| 2403 | } else { |
| 2404 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2405 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUsers' ); |
| 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.getUsers' ); |
| 2413 | |
| 2414 | if ( ! current_user_can( 'list_users' ) ) |
| 2415 | return new IXR_Error( 401, __( 'Sorry, you cannot list users.' ) ); |
| 2416 | |
| 2417 | $query = array( 'fields' => 'all_with_meta' ); |
| 2418 | |
| 2419 | $query['number'] = ( isset( $filter['number'] ) ) ? absint( $filter['number'] ) : 50; |
| 2420 | $query['offset'] = ( isset( $filter['offset'] ) ) ? absint( $filter['offset'] ) : 0; |
| 2421 | |
| Line | Code |
| 2476 | } else { |
| 2477 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2478 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getProfile' ); |
| 2479 | } |
| 2480 | |
| 2481 | if ( ! $user = $this->login( $username, $password ) ) |
| 2482 | return $this->error; |
| 2483 | |
| 2484 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2485 | do_action( 'xmlrpc_call', 'wp.getProfile' ); |
| 2486 | |
| 2487 | if ( ! current_user_can( 'edit_user', $user->ID ) ) |
| 2488 | return new IXR_Error( 401, __( 'Sorry, you cannot edit your profile.' ) ); |
| 2489 | |
| 2490 | $user_data = get_userdata( $user->ID ); |
| 2491 | |
| 2492 | return $this->_prepare_user( $user_data, $fields ); |
| 2493 | } |
| 2494 | |
| Line | Code |
| 2522 | |
| 2523 | $username = $args[1]; |
| 2524 | $password = $args[2]; |
| 2525 | $content_struct = $args[3]; |
| 2526 | |
| 2527 | if ( ! $user = $this->login( $username, $password ) ) |
| 2528 | return $this->error; |
| 2529 | |
| 2530 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2531 | do_action( 'xmlrpc_call', 'wp.editProfile' ); |
| 2532 | |
| 2533 | if ( ! current_user_can( 'edit_user', $user->ID ) ) |
| 2534 | return new IXR_Error( 401, __( 'Sorry, you cannot edit your profile.' ) ); |
| 2535 | |
| 2536 | // holds data of the user |
| 2537 | $user_data = array(); |
| 2538 | $user_data['ID'] = $user->ID; |
| 2539 | |
| 2540 | // only set the user details if it was given |
| Line | Code |
| 2598 | |
| 2599 | $page = get_post($page_id); |
| 2600 | if ( ! $page ) |
| 2601 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 2602 | |
| 2603 | if ( !current_user_can( 'edit_page', $page_id ) ) |
| 2604 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this page.' ) ); |
| 2605 | |
| 2606 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2607 | do_action( 'xmlrpc_call', 'wp.getPage' ); |
| 2608 | |
| 2609 | // If we found the page then format the data. |
| 2610 | if ( $page->ID && ($page->post_type == 'page') ) { |
| 2611 | return $this->_prepare_page( $page ); |
| 2612 | } |
| 2613 | // If the page doesn't exist indicate that. |
| 2614 | else { |
| 2615 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
| 2616 | } |
| Line | Code |
| 2639 | $num_pages = isset($args[3]) ? (int) $args[3] : 10; |
| 2640 | |
| 2641 | if ( !$user = $this->login($username, $password) ) |
| 2642 | return $this->error; |
| 2643 | |
| 2644 | if ( !current_user_can( 'edit_pages' ) ) |
| 2645 | return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) ); |
| 2646 | |
| 2647 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2648 | do_action( 'xmlrpc_call', 'wp.getPages' ); |
| 2649 | |
| 2650 | $pages = get_posts( array('post_type' => 'page', 'post_status' => 'any', 'numberposts' => $num_pages) ); |
| 2651 | $num_pages = count($pages); |
| 2652 | |
| 2653 | // If we have pages, put together their info. |
| 2654 | if ( $num_pages >= 1 ) { |
| 2655 | $pages_struct = array(); |
| 2656 | |
| 2657 | foreach ($pages as $page) { |
| Line | Code |
| 2685 | public function wp_newPage( $args ) { |
| 2686 | // Items not escaped here will be escaped in newPost. |
| 2687 | $username = $this->escape( $args[1] ); |
| 2688 | $password = $this->escape( $args[2] ); |
| 2689 | |
| 2690 | if ( !$user = $this->login($username, $password) ) |
| 2691 | return $this->error; |
| 2692 | |
| 2693 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2694 | do_action( 'xmlrpc_call', 'wp.newPage' ); |
| 2695 | |
| 2696 | // Mark this as content for a page. |
| 2697 | $args[3]["post_type"] = 'page'; |
| 2698 | |
| 2699 | // Let mw_newPost do all of the heavy lifting. |
| 2700 | return $this->mw_newPost( $args ); |
| 2701 | } |
| 2702 | |
| 2703 | /** |
| Line | Code |
| 2720 | |
| 2721 | $username = $args[1]; |
| 2722 | $password = $args[2]; |
| 2723 | $page_id = (int) $args[3]; |
| 2724 | |
| 2725 | if ( !$user = $this->login($username, $password) ) |
| 2726 | return $this->error; |
| 2727 | |
| 2728 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2729 | do_action( 'xmlrpc_call', 'wp.deletePage' ); |
| 2730 | |
| 2731 | // Get the current page based on the page_id and |
| 2732 | // make sure it is a page and not a post. |
| 2733 | $actual_page = get_post($page_id, ARRAY_A); |
| 2734 | if ( !$actual_page || ($actual_page['post_type'] != 'page') ) |
| 2735 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
| 2736 | |
| 2737 | // Make sure the user can delete pages. |
| 2738 | if ( !current_user_can('delete_page', $page_id) ) |
| Line | Code |
| 2783 | |
| 2784 | $escaped_username = $this->escape( $username ); |
| 2785 | $escaped_password = $this->escape( $password ); |
| 2786 | |
| 2787 | if ( !$user = $this->login( $escaped_username, $escaped_password ) ) { |
| 2788 | return $this->error; |
| 2789 | } |
| 2790 | |
| 2791 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2792 | do_action( 'xmlrpc_call', 'wp.editPage' ); |
| 2793 | |
| 2794 | // Get the page data and make sure it is a page. |
| 2795 | $actual_page = get_post($page_id, ARRAY_A); |
| 2796 | if ( !$actual_page || ($actual_page['post_type'] != 'page') ) |
| 2797 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
| 2798 | |
| 2799 | // Make sure the user is allowed to edit pages. |
| 2800 | if ( !current_user_can('edit_page', $page_id) ) |
| 2801 | return new IXR_Error( 401, __( 'Sorry, you do not have the right to edit this page.' ) ); |
| Line | Code |
| 2841 | $password = $args[2]; |
| 2842 | |
| 2843 | if ( !$user = $this->login($username, $password) ) |
| 2844 | return $this->error; |
| 2845 | |
| 2846 | if ( !current_user_can( 'edit_pages' ) ) |
| 2847 | return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) ); |
| 2848 | |
| 2849 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2850 | do_action( 'xmlrpc_call', 'wp.getPageList' ); |
| 2851 | |
| 2852 | // Get list of pages ids and titles |
| 2853 | $page_list = $wpdb->get_results(" |
| 2854 | SELECT ID page_id, |
| 2855 | post_title page_title, |
| 2856 | post_parent page_parent_id, |
| 2857 | post_date_gmt, |
| 2858 | post_date, |
| 2859 | post_status |
| Line | Code |
| 2897 | $password = $args[2]; |
| 2898 | |
| 2899 | if ( !$user = $this->login($username, $password) ) |
| 2900 | return $this->error; |
| 2901 | |
| 2902 | if ( !current_user_can('edit_posts') ) |
| 2903 | return new IXR_Error( 401, __( 'Sorry, you cannot edit posts on this site.' ) ); |
| 2904 | |
| 2905 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2906 | do_action( 'xmlrpc_call', 'wp.getAuthors' ); |
| 2907 | |
| 2908 | $authors = array(); |
| 2909 | foreach ( get_users( array( 'fields' => array('ID','user_login','display_name') ) ) as $user ) { |
| 2910 | $authors[] = array( |
| 2911 | 'user_id' => $user->ID, |
| 2912 | 'user_login' => $user->user_login, |
| 2913 | 'display_name' => $user->display_name |
| 2914 | ); |
| 2915 | } |
| Line | Code |
| 2938 | $password = $args[2]; |
| 2939 | |
| 2940 | if ( !$user = $this->login($username, $password) ) |
| 2941 | return $this->error; |
| 2942 | |
| 2943 | if ( !current_user_can( 'edit_posts' ) ) |
| 2944 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view tags.' ) ); |
| 2945 | |
| 2946 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2947 | do_action( 'xmlrpc_call', 'wp.getKeywords' ); |
| 2948 | |
| 2949 | $tags = array(); |
| 2950 | |
| 2951 | if ( $all_tags = get_tags() ) { |
| 2952 | foreach( (array) $all_tags as $tag ) { |
| 2953 | $struct = array(); |
| 2954 | $struct['tag_id'] = $tag->term_id; |
| 2955 | $struct['name'] = $tag->name; |
| 2956 | $struct['count'] = $tag->count; |
| Line | Code |
| 2985 | |
| 2986 | $username = $args[1]; |
| 2987 | $password = $args[2]; |
| 2988 | $category = $args[3]; |
| 2989 | |
| 2990 | if ( !$user = $this->login($username, $password) ) |
| 2991 | return $this->error; |
| 2992 | |
| 2993 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2994 | do_action( 'xmlrpc_call', 'wp.newCategory' ); |
| 2995 | |
| 2996 | // Make sure the user is allowed to add a category. |
| 2997 | if ( !current_user_can('manage_categories') ) |
| 2998 | return new IXR_Error(401, __('Sorry, you do not have the right to add a category.')); |
| 2999 | |
| 3000 | // If no slug was provided make it empty so that |
| 3001 | // WordPress will generate one. |
| 3002 | if ( empty($category['slug']) ) |
| 3003 | $category['slug'] = ''; |
| Line | Code |
| 3061 | |
| 3062 | $username = $args[1]; |
| 3063 | $password = $args[2]; |
| 3064 | $category_id = (int) $args[3]; |
| 3065 | |
| 3066 | if ( !$user = $this->login($username, $password) ) |
| 3067 | return $this->error; |
| 3068 | |
| 3069 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3070 | do_action( 'xmlrpc_call', 'wp.deleteCategory' ); |
| 3071 | |
| 3072 | if ( !current_user_can('manage_categories') ) |
| 3073 | return new IXR_Error( 401, __( 'Sorry, you do not have the right to delete a category.' ) ); |
| 3074 | |
| 3075 | $status = wp_delete_term( $category_id, 'category' ); |
| 3076 | |
| 3077 | if ( true == $status ) { |
| 3078 | /** |
| 3079 | * Fires after a category has been successfully deleted via XML-RPC. |
| Line | Code |
| 3114 | $max_results = (int) $args[4]; |
| 3115 | |
| 3116 | if ( !$user = $this->login($username, $password) ) |
| 3117 | return $this->error; |
| 3118 | |
| 3119 | if ( !current_user_can( 'edit_posts' ) ) |
| 3120 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
| 3121 | |
| 3122 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3123 | do_action( 'xmlrpc_call', 'wp.suggestCategories' ); |
| 3124 | |
| 3125 | $category_suggestions = array(); |
| 3126 | $args = array('get' => 'all', 'number' => $max_results, 'name__like' => $category); |
| 3127 | foreach ( (array) get_categories($args) as $cat ) { |
| 3128 | $category_suggestions[] = array( |
| 3129 | 'category_id' => $cat->term_id, |
| 3130 | 'category_name' => $cat->name |
| 3131 | ); |
| 3132 | } |
| Line | Code |
| 3157 | $comment_id = (int) $args[3]; |
| 3158 | |
| 3159 | if ( !$user = $this->login($username, $password) ) |
| 3160 | return $this->error; |
| 3161 | |
| 3162 | if ( !current_user_can( 'moderate_comments' ) ) |
| 3163 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
| 3164 | |
| 3165 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3166 | do_action( 'xmlrpc_call', 'wp.getComment' ); |
| 3167 | |
| 3168 | if ( ! $comment = get_comment($comment_id) ) |
| 3169 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 3170 | |
| 3171 | return $this->_prepare_comment( $comment ); |
| 3172 | } |
| 3173 | |
| 3174 | /** |
| 3175 | * Retrieve comments. |
| Line | Code |
| 3205 | $struct = isset( $args[3] ) ? $args[3] : array(); |
| 3206 | |
| 3207 | if ( !$user = $this->login($username, $password) ) |
| 3208 | return $this->error; |
| 3209 | |
| 3210 | if ( !current_user_can( 'moderate_comments' ) ) |
| 3211 | return new IXR_Error( 401, __( 'Sorry, you cannot edit comments.' ) ); |
| 3212 | |
| 3213 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3214 | do_action( 'xmlrpc_call', 'wp.getComments' ); |
| 3215 | |
| 3216 | if ( isset($struct['status']) ) |
| 3217 | $status = $struct['status']; |
| 3218 | else |
| 3219 | $status = ''; |
| 3220 | |
| 3221 | $post_id = ''; |
| 3222 | if ( isset($struct['post_id']) ) |
| 3223 | $post_id = absint($struct['post_id']); |
| Line | Code |
| 3275 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
| 3276 | |
| 3277 | if ( ! get_comment($comment_ID) ) |
| 3278 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 3279 | |
| 3280 | if ( !current_user_can( 'edit_comment', $comment_ID ) ) |
| 3281 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
| 3282 | |
| 3283 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3284 | do_action( 'xmlrpc_call', 'wp.deleteComment' ); |
| 3285 | |
| 3286 | $status = wp_delete_comment( $comment_ID ); |
| 3287 | |
| 3288 | if ( $status ) { |
| 3289 | /** |
| 3290 | * Fires after a comment has been successfully deleted via XML-RPC. |
| 3291 | * |
| 3292 | * @since 3.4.0 |
| 3293 | * |
| Line | Code |
| 3342 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
| 3343 | |
| 3344 | if ( ! get_comment($comment_ID) ) |
| 3345 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 3346 | |
| 3347 | if ( !current_user_can( 'edit_comment', $comment_ID ) ) |
| 3348 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
| 3349 | |
| 3350 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3351 | do_action( 'xmlrpc_call', 'wp.editComment' ); |
| 3352 | |
| 3353 | if ( isset($content_struct['status']) ) { |
| 3354 | $statuses = get_comment_statuses(); |
| 3355 | $statuses = array_keys($statuses); |
| 3356 | |
| 3357 | if ( ! in_array($content_struct['status'], $statuses) ) |
| 3358 | return new IXR_Error( 401, __( 'Invalid comment status.' ) ); |
| 3359 | $comment_approved = $content_struct['status']; |
| 3360 | } |
| Line | Code |
| 3490 | return new IXR_Error( 403, __( 'A valid email address is required' ) ); |
| 3491 | } |
| 3492 | } |
| 3493 | |
| 3494 | $comment['comment_parent'] = isset($content_struct['comment_parent']) ? absint($content_struct['comment_parent']) : 0; |
| 3495 | |
| 3496 | $comment['comment_content'] = isset($content_struct['content']) ? $content_struct['content'] : null; |
| 3497 | |
| 3498 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3499 | do_action( 'xmlrpc_call', 'wp.newComment' ); |
| 3500 | |
| 3501 | $comment_ID = wp_new_comment( $comment ); |
| 3502 | |
| 3503 | /** |
| 3504 | * Fires after a new comment has been successfully created via XML-RPC. |
| 3505 | * |
| 3506 | * @since 3.4.0 |
| 3507 | * |
| 3508 | * @param int $comment_ID ID of the new comment. |
| Line | Code |
| 3534 | $password = $args[2]; |
| 3535 | |
| 3536 | if ( !$user = $this->login($username, $password) ) |
| 3537 | return $this->error; |
| 3538 | |
| 3539 | if ( !current_user_can( 'moderate_comments' ) ) |
| 3540 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
| 3541 | |
| 3542 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3543 | do_action( 'xmlrpc_call', 'wp.getCommentStatusList' ); |
| 3544 | |
| 3545 | return get_comment_statuses(); |
| 3546 | } |
| 3547 | |
| 3548 | /** |
| 3549 | * Retrieve comment count. |
| 3550 | * |
| 3551 | * @since 2.5.0 |
| 3552 | * |
| Line | Code |
| 3568 | $post_id = (int) $args[3]; |
| 3569 | |
| 3570 | if ( !$user = $this->login($username, $password) ) |
| 3571 | return $this->error; |
| 3572 | |
| 3573 | if ( !current_user_can( 'edit_posts' ) ) |
| 3574 | return new IXR_Error( 403, __( 'You are not allowed access to details about comments.' ) ); |
| 3575 | |
| 3576 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3577 | do_action( 'xmlrpc_call', 'wp.getCommentCount' ); |
| 3578 | |
| 3579 | $count = wp_count_comments( $post_id ); |
| 3580 | return array( |
| 3581 | 'approved' => $count->approved, |
| 3582 | 'awaiting_moderation' => $count->moderated, |
| 3583 | 'spam' => $count->spam, |
| 3584 | 'total_comments' => $count->total_comments |
| 3585 | ); |
| 3586 | } |
| Line | Code |
| 3606 | $password = $args[2]; |
| 3607 | |
| 3608 | if ( !$user = $this->login($username, $password) ) |
| 3609 | return $this->error; |
| 3610 | |
| 3611 | if ( !current_user_can( 'edit_posts' ) ) |
| 3612 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
| 3613 | |
| 3614 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3615 | do_action( 'xmlrpc_call', 'wp.getPostStatusList' ); |
| 3616 | |
| 3617 | return get_post_statuses(); |
| 3618 | } |
| 3619 | |
| 3620 | /** |
| 3621 | * Retrieve page statuses. |
| 3622 | * |
| 3623 | * @since 2.5.0 |
| 3624 | * |
| Line | Code |
| 3638 | $password = $args[2]; |
| 3639 | |
| 3640 | if ( !$user = $this->login($username, $password) ) |
| 3641 | return $this->error; |
| 3642 | |
| 3643 | if ( !current_user_can( 'edit_pages' ) ) |
| 3644 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
| 3645 | |
| 3646 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3647 | do_action( 'xmlrpc_call', 'wp.getPageStatusList' ); |
| 3648 | |
| 3649 | return get_page_statuses(); |
| 3650 | } |
| 3651 | |
| 3652 | /** |
| 3653 | * Retrieve page templates. |
| 3654 | * |
| 3655 | * @since 2.6.0 |
| 3656 | * |
| Line | Code |
| 3816 | $attachment_id = (int) $args[3]; |
| 3817 | |
| 3818 | if ( !$user = $this->login($username, $password) ) |
| 3819 | return $this->error; |
| 3820 | |
| 3821 | if ( !current_user_can( 'upload_files' ) ) |
| 3822 | return new IXR_Error( 403, __( 'You do not have permission to upload files.' ) ); |
| 3823 | |
| 3824 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3825 | do_action( 'xmlrpc_call', 'wp.getMediaItem' ); |
| 3826 | |
| 3827 | if ( ! $attachment = get_post($attachment_id) ) |
| 3828 | return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); |
| 3829 | |
| 3830 | return $this->_prepare_media_item( $attachment ); |
| 3831 | } |
| 3832 | |
| 3833 | /** |
| 3834 | * Retrieves a collection of media library items (or attachments) |
| Line | Code |
| 3864 | $struct = isset( $args[3] ) ? $args[3] : array() ; |
| 3865 | |
| 3866 | if ( !$user = $this->login($username, $password) ) |
| 3867 | return $this->error; |
| 3868 | |
| 3869 | if ( !current_user_can( 'upload_files' ) ) |
| 3870 | return new IXR_Error( 401, __( 'You do not have permission to upload files.' ) ); |
| 3871 | |
| 3872 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3873 | do_action( 'xmlrpc_call', 'wp.getMediaLibrary' ); |
| 3874 | |
| 3875 | $parent_id = ( isset($struct['parent_id']) ) ? absint($struct['parent_id']) : '' ; |
| 3876 | $mime_type = ( isset($struct['mime_type']) ) ? $struct['mime_type'] : '' ; |
| 3877 | $offset = ( isset($struct['offset']) ) ? absint($struct['offset']) : 0 ; |
| 3878 | $number = ( isset($struct['number']) ) ? absint($struct['number']) : -1 ; |
| 3879 | |
| 3880 | $attachments = get_posts( array('post_type' => 'attachment', 'post_parent' => $parent_id, 'offset' => $offset, 'numberposts' => $number, 'post_mime_type' => $mime_type ) ); |
| 3881 | |
| 3882 | $attachments_struct = array(); |
| Line | Code |
| 3908 | $password = $args[2]; |
| 3909 | |
| 3910 | if ( !$user = $this->login( $username, $password ) ) |
| 3911 | return $this->error; |
| 3912 | |
| 3913 | if ( !current_user_can( 'edit_posts' ) ) |
| 3914 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
| 3915 | |
| 3916 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3917 | do_action( 'xmlrpc_call', 'wp.getPostFormats' ); |
| 3918 | |
| 3919 | $formats = get_post_format_strings(); |
| 3920 | |
| 3921 | // find out if they want a list of currently supports formats |
| 3922 | if ( isset( $args[3] ) && is_array( $args[3] ) ) { |
| 3923 | if ( $args[3]['show-supported'] ) { |
| 3924 | if ( current_theme_supports( 'post-formats' ) ) { |
| 3925 | $supported = get_theme_support( 'post-formats' ); |
| 3926 | |
| Line | Code |
| 3985 | * @param string $method The method name. |
| 3986 | */ |
| 3987 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostType' ); |
| 3988 | } |
| 3989 | |
| 3990 | if ( !$user = $this->login( $username, $password ) ) |
| 3991 | return $this->error; |
| 3992 | |
| 3993 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3994 | do_action( 'xmlrpc_call', 'wp.getPostType' ); |
| 3995 | |
| 3996 | if ( ! post_type_exists( $post_type_name ) ) |
| 3997 | return new IXR_Error( 403, __( 'Invalid post type' ) ); |
| 3998 | |
| 3999 | $post_type = get_post_type_object( $post_type_name ); |
| 4000 | |
| 4001 | if ( ! current_user_can( $post_type->cap->edit_posts ) ) |
| 4002 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post type.' ) ); |
| 4003 | |
| Line | Code |
| 4037 | } else { |
| 4038 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4039 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostTypes' ); |
| 4040 | } |
| 4041 | |
| 4042 | if ( ! $user = $this->login( $username, $password ) ) |
| 4043 | return $this->error; |
| 4044 | |
| 4045 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4046 | do_action( 'xmlrpc_call', 'wp.getPostTypes' ); |
| 4047 | |
| 4048 | $post_types = get_post_types( $filter, 'objects' ); |
| 4049 | |
| 4050 | $struct = array(); |
| 4051 | |
| 4052 | foreach( $post_types as $post_type ) { |
| 4053 | if ( ! current_user_can( $post_type->cap->edit_posts ) ) |
| 4054 | continue; |
| 4055 | |
| Line | Code |
| 4103 | * @param string $method The method name. |
| 4104 | */ |
| 4105 | $fields = apply_filters( 'xmlrpc_default_revision_fields', array( 'post_date', 'post_date_gmt' ), 'wp.getRevisions' ); |
| 4106 | } |
| 4107 | |
| 4108 | if ( ! $user = $this->login( $username, $password ) ) |
| 4109 | return $this->error; |
| 4110 | |
| 4111 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4112 | do_action( 'xmlrpc_call', 'wp.getRevisions' ); |
| 4113 | |
| 4114 | if ( ! $post = get_post( $post_id ) ) |
| 4115 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4116 | |
| 4117 | if ( ! current_user_can( 'edit_post', $post_id ) ) |
| 4118 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
| 4119 | |
| 4120 | // Check if revisions are enabled. |
| 4121 | if ( ! wp_revisions_enabled( $post ) ) |
| Line | Code |
| 4167 | |
| 4168 | $username = $args[1]; |
| 4169 | $password = $args[2]; |
| 4170 | $revision_id = (int) $args[3]; |
| 4171 | |
| 4172 | if ( ! $user = $this->login( $username, $password ) ) |
| 4173 | return $this->error; |
| 4174 | |
| 4175 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4176 | do_action( 'xmlrpc_call', 'wp.restoreRevision' ); |
| 4177 | |
| 4178 | if ( ! $revision = wp_get_post_revision( $revision_id ) ) |
| 4179 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4180 | |
| 4181 | if ( wp_is_post_autosave( $revision ) ) |
| 4182 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4183 | |
| 4184 | if ( ! $post = get_post( $revision->post_parent ) ) |
| 4185 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| Line | Code |
| 4223 | $this->escape($args); |
| 4224 | |
| 4225 | $username = $args[1]; |
| 4226 | $password = $args[2]; |
| 4227 | |
| 4228 | if ( !$user = $this->login($username, $password) ) |
| 4229 | return $this->error; |
| 4230 | |
| 4231 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4232 | do_action( 'xmlrpc_call', 'blogger.getUsersBlogs' ); |
| 4233 | |
| 4234 | $is_admin = current_user_can('manage_options'); |
| 4235 | |
| 4236 | $struct = array( |
| 4237 | 'isAdmin' => $is_admin, |
| 4238 | 'url' => get_option('home') . '/', |
| 4239 | 'blogid' => '1', |
| 4240 | 'blogName' => get_option('blogname'), |
| 4241 | 'xmlrpc' => site_url( 'xmlrpc.php', 'rpc' ), |
| Line | Code |
| 4298 | $password = $args[2]; |
| 4299 | |
| 4300 | if ( !$user = $this->login($username, $password) ) |
| 4301 | return $this->error; |
| 4302 | |
| 4303 | if ( !current_user_can( 'edit_posts' ) ) |
| 4304 | return new IXR_Error( 401, __( 'Sorry, you do not have access to user data on this site.' ) ); |
| 4305 | |
| 4306 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4307 | do_action( 'xmlrpc_call', 'blogger.getUserInfo' ); |
| 4308 | |
| 4309 | $struct = array( |
| 4310 | 'nickname' => $user->nickname, |
| 4311 | 'userid' => $user->ID, |
| 4312 | 'url' => $user->user_url, |
| 4313 | 'lastname' => $user->last_name, |
| 4314 | 'firstname' => $user->first_name |
| 4315 | ); |
| 4316 | |
| Line | Code |
| 4344 | |
| 4345 | $post_data = get_post($post_ID, ARRAY_A); |
| 4346 | if ( ! $post_data ) |
| 4347 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4348 | |
| 4349 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
| 4350 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); |
| 4351 | |
| 4352 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4353 | do_action( 'xmlrpc_call', 'blogger.getPost' ); |
| 4354 | |
| 4355 | $categories = implode(',', wp_get_post_categories($post_ID)); |
| 4356 | |
| 4357 | $content = '<title>'.wp_unslash($post_data['post_title']).'</title>'; |
| 4358 | $content .= '<category>'.$categories.'</category>'; |
| 4359 | $content .= wp_unslash($post_data['post_content']); |
| 4360 | |
| 4361 | $struct = array( |
| 4362 | 'userid' => $post_data['post_author'], |
| Line | Code |
| 4397 | $query = array(); |
| 4398 | |
| 4399 | if ( !$user = $this->login($username, $password) ) |
| 4400 | return $this->error; |
| 4401 | |
| 4402 | if ( ! current_user_can( 'edit_posts' ) ) |
| 4403 | return new IXR_Error( 401, __( 'Sorry, you cannot edit posts on this site.' ) ); |
| 4404 | |
| 4405 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4406 | do_action( 'xmlrpc_call', 'blogger.getRecentPosts' ); |
| 4407 | |
| 4408 | $posts_list = wp_get_recent_posts( $query ); |
| 4409 | |
| 4410 | if ( !$posts_list ) { |
| 4411 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
| 4412 | return $this->error; |
| 4413 | } |
| 4414 | |
| 4415 | $recent_posts = array(); |
| Line | Code |
| 4480 | $username = $args[2]; |
| 4481 | $password = $args[3]; |
| 4482 | $content = $args[4]; |
| 4483 | $publish = $args[5]; |
| 4484 | |
| 4485 | if ( !$user = $this->login($username, $password) ) |
| 4486 | return $this->error; |
| 4487 | |
| 4488 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4489 | do_action( 'xmlrpc_call', 'blogger.newPost' ); |
| 4490 | |
| 4491 | $cap = ($publish) ? 'publish_posts' : 'edit_posts'; |
| 4492 | if ( ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) || !current_user_can($cap) ) |
| 4493 | return new IXR_Error(401, __('Sorry, you are not allowed to post on this site.')); |
| 4494 | |
| 4495 | $post_status = ($publish) ? 'publish' : 'draft'; |
| 4496 | |
| 4497 | $post_author = $user->ID; |
| 4498 | |
| Line | Code |
| 4551 | $username = $args[2]; |
| 4552 | $password = $args[3]; |
| 4553 | $content = $args[4]; |
| 4554 | |
| 4555 | if ( ! $user = $this->login( $username, $password ) ) { |
| 4556 | return $this->error; |
| 4557 | } |
| 4558 | |
| 4559 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4560 | do_action( 'xmlrpc_call', 'blogger.editPost' ); |
| 4561 | |
| 4562 | $actual_post = get_post( $post_ID, ARRAY_A ); |
| 4563 | |
| 4564 | if ( ! $actual_post || $actual_post['post_type'] != 'post' ) { |
| 4565 | return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); |
| 4566 | } |
| 4567 | |
| 4568 | $this->escape($actual_post); |
| 4569 | |
| Line | Code |
| 4622 | |
| 4623 | $post_ID = (int) $args[1]; |
| 4624 | $username = $args[2]; |
| 4625 | $password = $args[3]; |
| 4626 | |
| 4627 | if ( !$user = $this->login($username, $password) ) |
| 4628 | return $this->error; |
| 4629 | |
| 4630 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4631 | do_action( 'xmlrpc_call', 'blogger.deletePost' ); |
| 4632 | |
| 4633 | $actual_post = get_post($post_ID,ARRAY_A); |
| 4634 | |
| 4635 | if ( !$actual_post || $actual_post['post_type'] != 'post' ) |
| 4636 | return new IXR_Error(404, __('Sorry, no such post.')); |
| 4637 | |
| 4638 | if ( !current_user_can('delete_post', $post_ID) ) |
| 4639 | return new IXR_Error(401, __('Sorry, you do not have the right to delete this post.')); |
| 4640 | |
| Line | Code |
| 4704 | $username = $args[1]; |
| 4705 | $password = $args[2]; |
| 4706 | $content_struct = $args[3]; |
| 4707 | $publish = isset( $args[4] ) ? $args[4] : 0; |
| 4708 | |
| 4709 | if ( !$user = $this->login($username, $password) ) |
| 4710 | return $this->error; |
| 4711 | |
| 4712 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4713 | do_action( 'xmlrpc_call', 'metaWeblog.newPost' ); |
| 4714 | |
| 4715 | $page_template = ''; |
| 4716 | if ( !empty( $content_struct['post_type'] ) ) { |
| 4717 | if ( $content_struct['post_type'] == 'page' ) { |
| 4718 | if ( $publish ) |
| 4719 | $cap = 'publish_pages'; |
| 4720 | elseif ( isset( $content_struct['page_status'] ) && 'publish' == $content_struct['page_status'] ) |
| 4721 | $cap = 'publish_pages'; |
| 4722 | else |
| Line | Code |
| 5046 | $username = $args[1]; |
| 5047 | $password = $args[2]; |
| 5048 | $content_struct = $args[3]; |
| 5049 | $publish = isset( $args[4] ) ? $args[4] : 0; |
| 5050 | |
| 5051 | if ( ! $user = $this->login($username, $password) ) |
| 5052 | return $this->error; |
| 5053 | |
| 5054 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5055 | do_action( 'xmlrpc_call', 'metaWeblog.editPost' ); |
| 5056 | |
| 5057 | $postdata = get_post( $post_ID, ARRAY_A ); |
| 5058 | |
| 5059 | /* |
| 5060 | * If there is no post data for the give post id, stop now and return an error. |
| 5061 | * Otherwise a new post will be created (which was the old behavior). |
| 5062 | */ |
| 5063 | if ( ! $postdata || empty( $postdata[ 'ID' ] ) ) |
| 5064 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| Line | Code |
| 5353 | |
| 5354 | $postdata = get_post($post_ID, ARRAY_A); |
| 5355 | if ( ! $postdata ) |
| 5356 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 5357 | |
| 5358 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
| 5359 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); |
| 5360 | |
| 5361 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5362 | do_action( 'xmlrpc_call', 'metaWeblog.getPost' ); |
| 5363 | |
| 5364 | if ($postdata['post_date'] != '') { |
| 5365 | $post_date = $this->_convert_date( $postdata['post_date'] ); |
| 5366 | $post_date_gmt = $this->_convert_date_gmt( $postdata['post_date_gmt'], $postdata['post_date'] ); |
| 5367 | $post_modified = $this->_convert_date( $postdata['post_modified'] ); |
| 5368 | $post_modified_gmt = $this->_convert_date_gmt( $postdata['post_modified_gmt'], $postdata['post_modified'] ); |
| 5369 | |
| 5370 | $categories = array(); |
| 5371 | $catids = wp_get_post_categories($post_ID); |
| Line | Code |
| 5483 | $query = array(); |
| 5484 | |
| 5485 | if ( !$user = $this->login($username, $password) ) |
| 5486 | return $this->error; |
| 5487 | |
| 5488 | if ( ! current_user_can( 'edit_posts' ) ) |
| 5489 | return new IXR_Error( 401, __( 'Sorry, you cannot edit posts on this site.' ) ); |
| 5490 | |
| 5491 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5492 | do_action( 'xmlrpc_call', 'metaWeblog.getRecentPosts' ); |
| 5493 | |
| 5494 | $posts_list = wp_get_recent_posts( $query ); |
| 5495 | |
| 5496 | if ( !$posts_list ) |
| 5497 | return array(); |
| 5498 | |
| 5499 | $recent_posts = array(); |
| 5500 | foreach ($posts_list as $entry) { |
| 5501 | if ( !current_user_can( 'edit_post', $entry['ID'] ) ) |
| Line | Code |
| 5596 | $password = $args[2]; |
| 5597 | |
| 5598 | if ( !$user = $this->login($username, $password) ) |
| 5599 | return $this->error; |
| 5600 | |
| 5601 | if ( !current_user_can( 'edit_posts' ) ) |
| 5602 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
| 5603 | |
| 5604 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5605 | do_action( 'xmlrpc_call', 'metaWeblog.getCategories' ); |
| 5606 | |
| 5607 | $categories_struct = array(); |
| 5608 | |
| 5609 | if ( $cats = get_categories(array('get' => 'all')) ) { |
| 5610 | foreach ( $cats as $cat ) { |
| 5611 | $struct = array(); |
| 5612 | $struct['categoryId'] = $cat->term_id; |
| 5613 | $struct['parentId'] = $cat->parent; |
| 5614 | $struct['description'] = $cat->name; |
| Line | Code |
| 5654 | |
| 5655 | $name = sanitize_file_name( $data['name'] ); |
| 5656 | $type = $data['type']; |
| 5657 | $bits = $data['bits']; |
| 5658 | |
| 5659 | if ( !$user = $this->login($username, $password) ) |
| 5660 | return $this->error; |
| 5661 | |
| 5662 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5663 | do_action( 'xmlrpc_call', 'metaWeblog.newMediaObject' ); |
| 5664 | |
| 5665 | if ( !current_user_can('upload_files') ) { |
| 5666 | $this->error = new IXR_Error( 401, __( 'You do not have permission to upload files.' ) ); |
| 5667 | return $this->error; |
| 5668 | } |
| 5669 | |
| 5670 | /** |
| 5671 | * Filter whether to preempt the XML-RPC media upload. |
| 5672 | * |
| Line | Code |
| 5773 | if ( isset( $args[3] ) ) |
| 5774 | $query = array( 'numberposts' => absint( $args[3] ) ); |
| 5775 | else |
| 5776 | $query = array(); |
| 5777 | |
| 5778 | if ( !$user = $this->login($username, $password) ) |
| 5779 | return $this->error; |
| 5780 | |
| 5781 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5782 | do_action( 'xmlrpc_call', 'mt.getRecentPostTitles' ); |
| 5783 | |
| 5784 | $posts_list = wp_get_recent_posts( $query ); |
| 5785 | |
| 5786 | if ( !$posts_list ) { |
| 5787 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
| 5788 | return $this->error; |
| 5789 | } |
| 5790 | |
| 5791 | $recent_posts = array(); |
| Line | Code |
| 5831 | $password = $args[2]; |
| 5832 | |
| 5833 | if ( !$user = $this->login($username, $password) ) |
| 5834 | return $this->error; |
| 5835 | |
| 5836 | if ( !current_user_can( 'edit_posts' ) ) |
| 5837 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
| 5838 | |
| 5839 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5840 | do_action( 'xmlrpc_call', 'mt.getCategoryList' ); |
| 5841 | |
| 5842 | $categories_struct = array(); |
| 5843 | |
| 5844 | if ( $cats = get_categories(array('hide_empty' => 0, 'hierarchical' => 0)) ) { |
| 5845 | foreach ( $cats as $cat ) { |
| 5846 | $struct = array(); |
| 5847 | $struct['categoryId'] = $cat->term_id; |
| 5848 | $struct['categoryName'] = $cat->name; |
| 5849 | |
| Line | Code |
| 5879 | return $this->error; |
| 5880 | |
| 5881 | if ( ! get_post( $post_ID ) ) |
| 5882 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 5883 | |
| 5884 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
| 5885 | return new IXR_Error( 401, __( 'Sorry, you can not edit this post.' ) ); |
| 5886 | |
| 5887 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5888 | do_action( 'xmlrpc_call', 'mt.getPostCategories' ); |
| 5889 | |
| 5890 | $categories = array(); |
| 5891 | $catids = wp_get_post_categories(intval($post_ID)); |
| 5892 | // first listed category will be the primary category |
| 5893 | $isPrimary = true; |
| 5894 | foreach ( $catids as $catid ) { |
| 5895 | $categories[] = array( |
| 5896 | 'categoryName' => get_cat_name($catid), |
| 5897 | 'categoryId' => (string) $catid, |
| Line | Code |
| 5924 | $post_ID = (int) $args[0]; |
| 5925 | $username = $args[1]; |
| 5926 | $password = $args[2]; |
| 5927 | $categories = $args[3]; |
| 5928 | |
| 5929 | if ( !$user = $this->login($username, $password) ) |
| 5930 | return $this->error; |
| 5931 | |
| 5932 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5933 | do_action( 'xmlrpc_call', 'mt.setPostCategories' ); |
| 5934 | |
| 5935 | if ( ! get_post( $post_ID ) ) |
| 5936 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 5937 | |
| 5938 | if ( !current_user_can('edit_post', $post_ID) ) |
| 5939 | return new IXR_Error(401, __('Sorry, you cannot edit this post.')); |
| 5940 | |
| 5941 | $catids = array(); |
| 5942 | foreach ( $categories as $cat ) { |
| Line | Code |
| 5951 | /** |
| 5952 | * Retrieve an array of methods supported by this server. |
| 5953 | * |
| 5954 | * @since 1.5.0 |
| 5955 | * |
| 5956 | * @return array |
| 5957 | */ |
| 5958 | public function mt_supportedMethods() { |
| 5959 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5960 | do_action( 'xmlrpc_call', 'mt.supportedMethods' ); |
| 5961 | |
| 5962 | return array_keys( $this->methods ); |
| 5963 | } |
| 5964 | |
| 5965 | /** |
| 5966 | * Retrieve an empty array because we don't support per-post text filters. |
| 5967 | * |
| 5968 | * @since 1.5.0 |
| 5969 | */ |
| 5970 | public function mt_supportedTextFilters() { |
| 5971 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5972 | do_action( 'xmlrpc_call', 'mt.supportedTextFilters' ); |
| 5973 | |
| 5974 | /** |
| 5975 | * Filter the MoveableType text filters list for XML-RPC. |
| 5976 | * |
| 5977 | * @since 2.2.0 |
| 5978 | * |
| 5979 | * @param array $filters An array of text filters. |
| 5980 | */ |
| 5981 | return apply_filters( 'xmlrpc_text_filters', array() ); |
| Line | Code |
| 5989 | * @global wpdb $wpdb |
| 5990 | * |
| 5991 | * @param int $post_ID |
| 5992 | * @return array|IXR_Error |
| 5993 | */ |
| 5994 | public function mt_getTrackbackPings( $post_ID ) { |
| 5995 | global $wpdb; |
| 5996 | |
| 5997 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5998 | do_action( 'xmlrpc_call', 'mt.getTrackbackPings' ); |
| 5999 | |
| 6000 | $actual_post = get_post($post_ID, ARRAY_A); |
| 6001 | |
| 6002 | if ( !$actual_post ) |
| 6003 | return new IXR_Error(404, __('Sorry, no such post.')); |
| 6004 | |
| 6005 | $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) ); |
| 6006 | |
| 6007 | if ( !$comments ) |
| Line | Code |
| 6042 | |
| 6043 | $post_ID = (int) $args[0]; |
| 6044 | $username = $args[1]; |
| 6045 | $password = $args[2]; |
| 6046 | |
| 6047 | if ( !$user = $this->login($username, $password) ) |
| 6048 | return $this->error; |
| 6049 | |
| 6050 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6051 | do_action( 'xmlrpc_call', 'mt.publishPost' ); |
| 6052 | |
| 6053 | $postdata = get_post($post_ID, ARRAY_A); |
| 6054 | if ( ! $postdata ) |
| 6055 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 6056 | |
| 6057 | if ( !current_user_can('publish_posts') || !current_user_can('edit_post', $post_ID) ) |
| 6058 | return new IXR_Error(401, __('Sorry, you cannot publish this post.')); |
| 6059 | |
| 6060 | $postdata['post_status'] = 'publish'; |
| Line | Code |
| 6085 | * @type string $pagelinkedfrom |
| 6086 | * @type string $pagelinkedto |
| 6087 | * } |
| 6088 | * @return string|IXR_Error |
| 6089 | */ |
| 6090 | public function pingback_ping( $args ) { |
| 6091 | global $wpdb, $wp_version; |
| 6092 | |
| 6093 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6094 | do_action( 'xmlrpc_call', 'pingback.ping' ); |
| 6095 | |
| 6096 | $this->escape( $args ); |
| 6097 | |
| 6098 | $pagelinkedfrom = str_replace( '&', '&', $args[0] ); |
| 6099 | $pagelinkedto = str_replace( '&', '&', $args[1] ); |
| 6100 | $pagelinkedto = str_replace( '&', '&', $pagelinkedto ); |
| 6101 | |
| 6102 | /** |
| 6103 | * Filter the pingback source URI. |
| Line | Code |
| 6290 | * @global wpdb $wpdb |
| 6291 | * |
| 6292 | * @param string $url |
| 6293 | * @return array|IXR_Error |
| 6294 | */ |
| 6295 | public function pingback_extensions_getPingbacks( $url ) { |
| 6296 | global $wpdb; |
| 6297 | |
| 6298 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 6299 | do_action( 'xmlrpc_call', 'pingback.extensions.getPingbacks' ); |
| 6300 | |
| 6301 | $url = $this->escape( $url ); |
| 6302 | |
| 6303 | $post_ID = url_to_postid($url); |
| 6304 | if ( !$post_ID ) { |
| 6305 | // We aren't sure that the resource is available and/or pingback enabled |
| 6306 | 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.' ) ); |
| 6307 | } |
| 6308 | |