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 |
|---|---|
| 517 | * the method logic begins. |
| 518 | * |
| 519 | * All built-in XML-RPC methods use the action xmlrpc_call, with a parameter |
| 520 | * equal to the method's name, e.g., wp.getUsersBlogs, wp.newPost, etc. |
| 521 | * |
| 522 | * @since 2.5.0 |
| 523 | * |
| 524 | * @param method $name The method name. |
| 525 | */ |
| 526 | do_action( 'xmlrpc_call', 'wp.getUsersBlogs' ); |
| 527 | |
| 528 | $blogs = (array) get_blogs_of_user( $user->ID ); |
| 529 | $struct = array(); |
| 530 | |
| 531 | foreach ( $blogs as $blog ) { |
| 532 | // Don't include blogs that aren't hosted at this site |
| 533 | if ( $blog->site_id != get_current_site()->id ) |
| 534 | continue; |
| 535 | |
| Line | Code |
| 1084 | $blog_id = (int) $args[0]; |
| 1085 | $username = $args[1]; |
| 1086 | $password = $args[2]; |
| 1087 | $content_struct = $args[3]; |
| 1088 | |
| 1089 | if ( ! $user = $this->login( $username, $password ) ) |
| 1090 | return $this->error; |
| 1091 | |
| 1092 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1093 | do_action( 'xmlrpc_call', 'wp.newPost' ); |
| 1094 | |
| 1095 | unset( $content_struct['ID'] ); |
| 1096 | |
| 1097 | return $this->_insert_post( $user, $content_struct ); |
| 1098 | } |
| 1099 | |
| 1100 | /** |
| 1101 | * Helper method for filtering out elements from an array. |
| 1102 | * |
| Line | Code |
| 1379 | $username = $args[1]; |
| 1380 | $password = $args[2]; |
| 1381 | $post_id = (int) $args[3]; |
| 1382 | $content_struct = $args[4]; |
| 1383 | |
| 1384 | if ( ! $user = $this->login( $username, $password ) ) |
| 1385 | return $this->error; |
| 1386 | |
| 1387 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1388 | do_action( 'xmlrpc_call', 'wp.editPost' ); |
| 1389 | |
| 1390 | $post = get_post( $post_id, ARRAY_A ); |
| 1391 | |
| 1392 | if ( empty( $post['ID'] ) ) |
| 1393 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 1394 | |
| 1395 | if ( isset( $content_struct['if_not_modified_since'] ) ) { |
| 1396 | // If the post has been modified since the date provided, return an error. |
| 1397 | if ( mysql2date( 'U', $post['post_modified_gmt'] ) > $content_struct['if_not_modified_since']->getTimestamp() ) { |
| Line | Code |
| 1441 | $blog_id = (int) $args[0]; |
| 1442 | $username = $args[1]; |
| 1443 | $password = $args[2]; |
| 1444 | $post_id = (int) $args[3]; |
| 1445 | |
| 1446 | if ( ! $user = $this->login( $username, $password ) ) |
| 1447 | return $this->error; |
| 1448 | |
| 1449 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1450 | do_action( 'xmlrpc_call', 'wp.deletePost' ); |
| 1451 | |
| 1452 | $post = get_post( $post_id, ARRAY_A ); |
| 1453 | if ( empty( $post['ID'] ) ) |
| 1454 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 1455 | |
| 1456 | if ( ! current_user_can( 'delete_post', $post_id ) ) |
| 1457 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) ); |
| 1458 | |
| 1459 | $result = wp_delete_post( $post_id ); |
| Line | Code |
| 1531 | * @param string $method Method name. |
| 1532 | */ |
| 1533 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPost' ); |
| 1534 | } |
| 1535 | |
| 1536 | if ( ! $user = $this->login( $username, $password ) ) |
| 1537 | return $this->error; |
| 1538 | |
| 1539 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1540 | do_action( 'xmlrpc_call', 'wp.getPost' ); |
| 1541 | |
| 1542 | $post = get_post( $post_id, ARRAY_A ); |
| 1543 | |
| 1544 | if ( empty( $post['ID'] ) ) |
| 1545 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 1546 | |
| 1547 | if ( ! current_user_can( 'edit_post', $post_id ) ) |
| 1548 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); |
| 1549 | |
| Line | Code |
| 1590 | } else { |
| 1591 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1592 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPosts' ); |
| 1593 | } |
| 1594 | |
| 1595 | if ( ! $user = $this->login( $username, $password ) ) |
| 1596 | return $this->error; |
| 1597 | |
| 1598 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1599 | do_action( 'xmlrpc_call', 'wp.getPosts' ); |
| 1600 | |
| 1601 | $query = array(); |
| 1602 | |
| 1603 | if ( isset( $filter['post_type'] ) ) { |
| 1604 | $post_type = get_post_type_object( $filter['post_type'] ); |
| 1605 | if ( ! ( (bool) $post_type ) ) |
| 1606 | return new IXR_Error( 403, __( 'The post type specified is not valid' ) ); |
| 1607 | } else { |
| 1608 | $post_type = get_post_type_object( 'post' ); |
| Line | Code |
| 1680 | $blog_id = (int) $args[0]; |
| 1681 | $username = $args[1]; |
| 1682 | $password = $args[2]; |
| 1683 | $content_struct = $args[3]; |
| 1684 | |
| 1685 | if ( ! $user = $this->login( $username, $password ) ) |
| 1686 | return $this->error; |
| 1687 | |
| 1688 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1689 | do_action( 'xmlrpc_call', 'wp.newTerm' ); |
| 1690 | |
| 1691 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) |
| 1692 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
| 1693 | |
| 1694 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
| 1695 | |
| 1696 | if ( ! current_user_can( $taxonomy->cap->manage_terms ) ) |
| 1697 | return new IXR_Error( 401, __( 'You are not allowed to create terms in this taxonomy.' ) ); |
| 1698 | |
| Line | Code |
| 1769 | $username = $args[1]; |
| 1770 | $password = $args[2]; |
| 1771 | $term_id = (int) $args[3]; |
| 1772 | $content_struct = $args[4]; |
| 1773 | |
| 1774 | if ( ! $user = $this->login( $username, $password ) ) |
| 1775 | return $this->error; |
| 1776 | |
| 1777 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1778 | do_action( 'xmlrpc_call', 'wp.editTerm' ); |
| 1779 | |
| 1780 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) |
| 1781 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
| 1782 | |
| 1783 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
| 1784 | |
| 1785 | if ( ! current_user_can( $taxonomy->cap->edit_terms ) ) |
| 1786 | return new IXR_Error( 401, __( 'You are not allowed to edit terms in this taxonomy.' ) ); |
| 1787 | |
| Line | Code |
| 1862 | $username = $args[1]; |
| 1863 | $password = $args[2]; |
| 1864 | $taxonomy = $args[3]; |
| 1865 | $term_id = (int) $args[4]; |
| 1866 | |
| 1867 | if ( ! $user = $this->login( $username, $password ) ) |
| 1868 | return $this->error; |
| 1869 | |
| 1870 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1871 | do_action( 'xmlrpc_call', 'wp.deleteTerm' ); |
| 1872 | |
| 1873 | if ( ! taxonomy_exists( $taxonomy ) ) |
| 1874 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
| 1875 | |
| 1876 | $taxonomy = get_taxonomy( $taxonomy ); |
| 1877 | |
| 1878 | if ( ! current_user_can( $taxonomy->cap->delete_terms ) ) |
| 1879 | return new IXR_Error( 401, __( 'You are not allowed to delete terms in this taxonomy.' ) ); |
| 1880 | |
| Line | Code |
| 1930 | $username = $args[1]; |
| 1931 | $password = $args[2]; |
| 1932 | $taxonomy = $args[3]; |
| 1933 | $term_id = (int) $args[4]; |
| 1934 | |
| 1935 | if ( ! $user = $this->login( $username, $password ) ) |
| 1936 | return $this->error; |
| 1937 | |
| 1938 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1939 | do_action( 'xmlrpc_call', 'wp.getTerm' ); |
| 1940 | |
| 1941 | if ( ! taxonomy_exists( $taxonomy ) ) |
| 1942 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
| 1943 | |
| 1944 | $taxonomy = get_taxonomy( $taxonomy ); |
| 1945 | |
| 1946 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
| 1947 | return new IXR_Error( 401, __( 'You are not allowed to assign terms in this taxonomy.' ) ); |
| 1948 | |
| Line | Code |
| 1984 | $username = $args[1]; |
| 1985 | $password = $args[2]; |
| 1986 | $taxonomy = $args[3]; |
| 1987 | $filter = isset( $args[4] ) ? $args[4] : array(); |
| 1988 | |
| 1989 | if ( ! $user = $this->login( $username, $password ) ) |
| 1990 | return $this->error; |
| 1991 | |
| 1992 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1993 | do_action( 'xmlrpc_call', 'wp.getTerms' ); |
| 1994 | |
| 1995 | if ( ! taxonomy_exists( $taxonomy ) ) |
| 1996 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
| 1997 | |
| 1998 | $taxonomy = get_taxonomy( $taxonomy ); |
| 1999 | |
| 2000 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
| 2001 | return new IXR_Error( 401, __( 'You are not allowed to assign terms in this taxonomy.' ) ); |
| 2002 | |
| Line | Code |
| 2073 | * @param string $method The method name. |
| 2074 | */ |
| 2075 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomy' ); |
| 2076 | } |
| 2077 | |
| 2078 | if ( ! $user = $this->login( $username, $password ) ) |
| 2079 | return $this->error; |
| 2080 | |
| 2081 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2082 | do_action( 'xmlrpc_call', 'wp.getTaxonomy' ); |
| 2083 | |
| 2084 | if ( ! taxonomy_exists( $taxonomy ) ) |
| 2085 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
| 2086 | |
| 2087 | $taxonomy = get_taxonomy( $taxonomy ); |
| 2088 | |
| 2089 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
| 2090 | return new IXR_Error( 401, __( 'You are not allowed to assign terms in this taxonomy.' ) ); |
| 2091 | |
| Line | Code |
| 2120 | } else { |
| 2121 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2122 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomies' ); |
| 2123 | } |
| 2124 | |
| 2125 | if ( ! $user = $this->login( $username, $password ) ) |
| 2126 | return $this->error; |
| 2127 | |
| 2128 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2129 | do_action( 'xmlrpc_call', 'wp.getTaxonomies' ); |
| 2130 | |
| 2131 | $taxonomies = get_taxonomies( $filter, 'objects' ); |
| 2132 | |
| 2133 | // holds all the taxonomy data |
| 2134 | $struct = array(); |
| 2135 | |
| 2136 | foreach ( $taxonomies as $taxonomy ) { |
| 2137 | // capability check for post_types |
| 2138 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
| Line | Code |
| 2199 | * @param string $method The method name. |
| 2200 | */ |
| 2201 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUser' ); |
| 2202 | } |
| 2203 | |
| 2204 | if ( ! $user = $this->login( $username, $password ) ) |
| 2205 | return $this->error; |
| 2206 | |
| 2207 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2208 | do_action( 'xmlrpc_call', 'wp.getUser' ); |
| 2209 | |
| 2210 | if ( ! current_user_can( 'edit_user', $user_id ) ) |
| 2211 | return new IXR_Error( 401, __( 'Sorry, you cannot edit users.' ) ); |
| 2212 | |
| 2213 | $user_data = get_userdata( $user_id ); |
| 2214 | |
| 2215 | if ( ! $user_data ) |
| 2216 | return new IXR_Error( 404, __( 'Invalid user ID' ) ); |
| 2217 | |
| Line | Code |
| 2255 | } else { |
| 2256 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2257 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUsers' ); |
| 2258 | } |
| 2259 | |
| 2260 | if ( ! $user = $this->login( $username, $password ) ) |
| 2261 | return $this->error; |
| 2262 | |
| 2263 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2264 | do_action( 'xmlrpc_call', 'wp.getUsers' ); |
| 2265 | |
| 2266 | if ( ! current_user_can( 'list_users' ) ) |
| 2267 | return new IXR_Error( 401, __( 'Sorry, you cannot list users.' ) ); |
| 2268 | |
| 2269 | $query = array( 'fields' => 'all_with_meta' ); |
| 2270 | |
| 2271 | $query['number'] = ( isset( $filter['number'] ) ) ? absint( $filter['number'] ) : 50; |
| 2272 | $query['offset'] = ( isset( $filter['offset'] ) ) ? absint( $filter['offset'] ) : 0; |
| 2273 | |
| Line | Code |
| 2325 | } else { |
| 2326 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2327 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getProfile' ); |
| 2328 | } |
| 2329 | |
| 2330 | if ( ! $user = $this->login( $username, $password ) ) |
| 2331 | return $this->error; |
| 2332 | |
| 2333 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2334 | do_action( 'xmlrpc_call', 'wp.getProfile' ); |
| 2335 | |
| 2336 | if ( ! current_user_can( 'edit_user', $user->ID ) ) |
| 2337 | return new IXR_Error( 401, __( 'Sorry, you cannot edit your profile.' ) ); |
| 2338 | |
| 2339 | $user_data = get_userdata( $user->ID ); |
| 2340 | |
| 2341 | return $this->_prepare_user( $user_data, $fields ); |
| 2342 | } |
| 2343 | |
| Line | Code |
| 2369 | $blog_id = (int) $args[0]; |
| 2370 | $username = $args[1]; |
| 2371 | $password = $args[2]; |
| 2372 | $content_struct = $args[3]; |
| 2373 | |
| 2374 | if ( ! $user = $this->login( $username, $password ) ) |
| 2375 | return $this->error; |
| 2376 | |
| 2377 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2378 | do_action( 'xmlrpc_call', 'wp.editProfile' ); |
| 2379 | |
| 2380 | if ( ! current_user_can( 'edit_user', $user->ID ) ) |
| 2381 | return new IXR_Error( 401, __( 'Sorry, you cannot edit your profile.' ) ); |
| 2382 | |
| 2383 | // holds data of the user |
| 2384 | $user_data = array(); |
| 2385 | $user_data['ID'] = $user->ID; |
| 2386 | |
| 2387 | // only set the user details if it was given |
| Line | Code |
| 2443 | |
| 2444 | $page = get_post($page_id); |
| 2445 | if ( ! $page ) |
| 2446 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 2447 | |
| 2448 | if ( !current_user_can( 'edit_page', $page_id ) ) |
| 2449 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this page.' ) ); |
| 2450 | |
| 2451 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2452 | do_action( 'xmlrpc_call', 'wp.getPage' ); |
| 2453 | |
| 2454 | // If we found the page then format the data. |
| 2455 | if ( $page->ID && ($page->post_type == 'page') ) { |
| 2456 | return $this->_prepare_page( $page ); |
| 2457 | } |
| 2458 | // If the page doesn't exist indicate that. |
| 2459 | else { |
| 2460 | return(new IXR_Error(404, __('Sorry, no such page.'))); |
| 2461 | } |
| Line | Code |
| 2482 | $num_pages = isset($args[3]) ? (int) $args[3] : 10; |
| 2483 | |
| 2484 | if ( !$user = $this->login($username, $password) ) |
| 2485 | return $this->error; |
| 2486 | |
| 2487 | if ( !current_user_can( 'edit_pages' ) ) |
| 2488 | return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) ); |
| 2489 | |
| 2490 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2491 | do_action( 'xmlrpc_call', 'wp.getPages' ); |
| 2492 | |
| 2493 | $pages = get_posts( array('post_type' => 'page', 'post_status' => 'any', 'numberposts' => $num_pages) ); |
| 2494 | $num_pages = count($pages); |
| 2495 | |
| 2496 | // If we have pages, put together their info. |
| 2497 | if ( $num_pages >= 1 ) { |
| 2498 | $pages_struct = array(); |
| 2499 | |
| 2500 | foreach ($pages as $page) { |
| Line | Code |
| 2523 | $username = $this->escape($args[1]); |
| 2524 | $password = $this->escape($args[2]); |
| 2525 | $page = $args[3]; |
| 2526 | $publish = $args[4]; |
| 2527 | |
| 2528 | if ( !$user = $this->login($username, $password) ) |
| 2529 | return $this->error; |
| 2530 | |
| 2531 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2532 | do_action( 'xmlrpc_call', 'wp.newPage' ); |
| 2533 | |
| 2534 | // Mark this as content for a page. |
| 2535 | $args[3]["post_type"] = 'page'; |
| 2536 | |
| 2537 | // Let mw_newPost do all of the heavy lifting. |
| 2538 | return($this->mw_newPost($args)); |
| 2539 | } |
| 2540 | |
| 2541 | /** |
| Line | Code |
| 2552 | $blog_id = (int) $args[0]; |
| 2553 | $username = $args[1]; |
| 2554 | $password = $args[2]; |
| 2555 | $page_id = (int) $args[3]; |
| 2556 | |
| 2557 | if ( !$user = $this->login($username, $password) ) |
| 2558 | return $this->error; |
| 2559 | |
| 2560 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2561 | do_action( 'xmlrpc_call', 'wp.deletePage' ); |
| 2562 | |
| 2563 | // Get the current page based on the page_id and |
| 2564 | // make sure it is a page and not a post. |
| 2565 | $actual_page = get_post($page_id, ARRAY_A); |
| 2566 | if ( !$actual_page || ($actual_page['post_type'] != 'page') ) |
| 2567 | return(new IXR_Error(404, __('Sorry, no such page.'))); |
| 2568 | |
| 2569 | // Make sure the user can delete pages. |
| 2570 | if ( !current_user_can('delete_page', $page_id) ) |
| Line | Code |
| 2603 | $username = $this->escape($args[2]); |
| 2604 | $password = $this->escape($args[3]); |
| 2605 | $content = $args[4]; |
| 2606 | $publish = $args[5]; |
| 2607 | |
| 2608 | if ( !$user = $this->login($username, $password) ) |
| 2609 | return $this->error; |
| 2610 | |
| 2611 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2612 | do_action( 'xmlrpc_call', 'wp.editPage' ); |
| 2613 | |
| 2614 | // Get the page data and make sure it is a page. |
| 2615 | $actual_page = get_post($page_id, ARRAY_A); |
| 2616 | if ( !$actual_page || ($actual_page['post_type'] != 'page') ) |
| 2617 | return(new IXR_Error(404, __('Sorry, no such page.'))); |
| 2618 | |
| 2619 | // Make sure the user is allowed to edit pages. |
| 2620 | if ( !current_user_can('edit_page', $page_id) ) |
| 2621 | return(new IXR_Error(401, __('Sorry, you do not have the right to edit this page.'))); |
| Line | Code |
| 2654 | $password = $args[2]; |
| 2655 | |
| 2656 | if ( !$user = $this->login($username, $password) ) |
| 2657 | return $this->error; |
| 2658 | |
| 2659 | if ( !current_user_can( 'edit_pages' ) ) |
| 2660 | return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) ); |
| 2661 | |
| 2662 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2663 | do_action( 'xmlrpc_call', 'wp.getPageList' ); |
| 2664 | |
| 2665 | // Get list of pages ids and titles |
| 2666 | $page_list = $wpdb->get_results(" |
| 2667 | SELECT ID page_id, |
| 2668 | post_title page_title, |
| 2669 | post_parent page_parent_id, |
| 2670 | post_date_gmt, |
| 2671 | post_date, |
| 2672 | post_status |
| Line | Code |
| 2706 | $password = $args[2]; |
| 2707 | |
| 2708 | if ( !$user = $this->login($username, $password) ) |
| 2709 | return $this->error; |
| 2710 | |
| 2711 | if ( !current_user_can('edit_posts') ) |
| 2712 | return(new IXR_Error(401, __('Sorry, you cannot edit posts on this site.'))); |
| 2713 | |
| 2714 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2715 | do_action( 'xmlrpc_call', 'wp.getAuthors' ); |
| 2716 | |
| 2717 | $authors = array(); |
| 2718 | foreach ( get_users( array( 'fields' => array('ID','user_login','display_name') ) ) as $user ) { |
| 2719 | $authors[] = array( |
| 2720 | 'user_id' => $user->ID, |
| 2721 | 'user_login' => $user->user_login, |
| 2722 | 'display_name' => $user->display_name |
| 2723 | ); |
| 2724 | } |
| Line | Code |
| 2742 | $password = $args[2]; |
| 2743 | |
| 2744 | if ( !$user = $this->login($username, $password) ) |
| 2745 | return $this->error; |
| 2746 | |
| 2747 | if ( !current_user_can( 'edit_posts' ) ) |
| 2748 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view tags.' ) ); |
| 2749 | |
| 2750 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2751 | do_action( 'xmlrpc_call', 'wp.getKeywords' ); |
| 2752 | |
| 2753 | $tags = array(); |
| 2754 | |
| 2755 | if ( $all_tags = get_tags() ) { |
| 2756 | foreach( (array) $all_tags as $tag ) { |
| 2757 | $struct['tag_id'] = $tag->term_id; |
| 2758 | $struct['name'] = $tag->name; |
| 2759 | $struct['count'] = $tag->count; |
| 2760 | $struct['slug'] = $tag->slug; |
| Line | Code |
| 2782 | $blog_id = (int) $args[0]; |
| 2783 | $username = $args[1]; |
| 2784 | $password = $args[2]; |
| 2785 | $category = $args[3]; |
| 2786 | |
| 2787 | if ( !$user = $this->login($username, $password) ) |
| 2788 | return $this->error; |
| 2789 | |
| 2790 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2791 | do_action( 'xmlrpc_call', 'wp.newCategory' ); |
| 2792 | |
| 2793 | // Make sure the user is allowed to add a category. |
| 2794 | if ( !current_user_can('manage_categories') ) |
| 2795 | return(new IXR_Error(401, __('Sorry, you do not have the right to add a category.'))); |
| 2796 | |
| 2797 | // If no slug was provided make it empty so that |
| 2798 | // WordPress will generate one. |
| 2799 | if ( empty($category['slug']) ) |
| 2800 | $category['slug'] = ''; |
| Line | Code |
| 2852 | $blog_id = (int) $args[0]; |
| 2853 | $username = $args[1]; |
| 2854 | $password = $args[2]; |
| 2855 | $category_id = (int) $args[3]; |
| 2856 | |
| 2857 | if ( !$user = $this->login($username, $password) ) |
| 2858 | return $this->error; |
| 2859 | |
| 2860 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2861 | do_action( 'xmlrpc_call', 'wp.deleteCategory' ); |
| 2862 | |
| 2863 | if ( !current_user_can('manage_categories') ) |
| 2864 | return new IXR_Error( 401, __( 'Sorry, you do not have the right to delete a category.' ) ); |
| 2865 | |
| 2866 | $status = wp_delete_term( $category_id, 'category' ); |
| 2867 | |
| 2868 | if ( true == $status ) { |
| 2869 | /** |
| 2870 | * Fires after a category has been successfully deleted via XML-RPC. |
| Line | Code |
| 2898 | $max_results = (int) $args[4]; |
| 2899 | |
| 2900 | if ( !$user = $this->login($username, $password) ) |
| 2901 | return $this->error; |
| 2902 | |
| 2903 | if ( !current_user_can( 'edit_posts' ) ) |
| 2904 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts to this site in order to view categories.' ) ); |
| 2905 | |
| 2906 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2907 | do_action( 'xmlrpc_call', 'wp.suggestCategories' ); |
| 2908 | |
| 2909 | $category_suggestions = array(); |
| 2910 | $args = array('get' => 'all', 'number' => $max_results, 'name__like' => $category); |
| 2911 | foreach ( (array) get_categories($args) as $cat ) { |
| 2912 | $category_suggestions[] = array( |
| 2913 | 'category_id' => $cat->term_id, |
| 2914 | 'category_name' => $cat->name |
| 2915 | ); |
| 2916 | } |
| Line | Code |
| 2935 | $comment_id = (int) $args[3]; |
| 2936 | |
| 2937 | if ( !$user = $this->login($username, $password) ) |
| 2938 | return $this->error; |
| 2939 | |
| 2940 | if ( !current_user_can( 'moderate_comments' ) ) |
| 2941 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
| 2942 | |
| 2943 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2944 | do_action( 'xmlrpc_call', 'wp.getComment' ); |
| 2945 | |
| 2946 | if ( ! $comment = get_comment($comment_id) ) |
| 2947 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 2948 | |
| 2949 | return $this->_prepare_comment( $comment ); |
| 2950 | } |
| 2951 | |
| 2952 | /** |
| 2953 | * Retrieve comments. |
| Line | Code |
| 2977 | $struct = isset( $args[3] ) ? $args[3] : array(); |
| 2978 | |
| 2979 | if ( !$user = $this->login($username, $password) ) |
| 2980 | return $this->error; |
| 2981 | |
| 2982 | if ( !current_user_can( 'moderate_comments' ) ) |
| 2983 | return new IXR_Error( 401, __( 'Sorry, you cannot edit comments.' ) ); |
| 2984 | |
| 2985 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2986 | do_action( 'xmlrpc_call', 'wp.getComments' ); |
| 2987 | |
| 2988 | if ( isset($struct['status']) ) |
| 2989 | $status = $struct['status']; |
| 2990 | else |
| 2991 | $status = ''; |
| 2992 | |
| 2993 | $post_id = ''; |
| 2994 | if ( isset($struct['post_id']) ) |
| 2995 | $post_id = absint($struct['post_id']); |
| Line | Code |
| 3044 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
| 3045 | |
| 3046 | if ( ! get_comment($comment_ID) ) |
| 3047 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 3048 | |
| 3049 | if ( !current_user_can( 'edit_comment', $comment_ID ) ) |
| 3050 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
| 3051 | |
| 3052 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3053 | do_action( 'xmlrpc_call', 'wp.deleteComment' ); |
| 3054 | |
| 3055 | $status = wp_delete_comment( $comment_ID ); |
| 3056 | |
| 3057 | if ( true == $status ) { |
| 3058 | /** |
| 3059 | * Fires after a comment has been successfully deleted via XML-RPC. |
| 3060 | * |
| 3061 | * @since 3.4.0 |
| 3062 | * |
| Line | Code |
| 3109 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
| 3110 | |
| 3111 | if ( ! get_comment($comment_ID) ) |
| 3112 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 3113 | |
| 3114 | if ( !current_user_can( 'edit_comment', $comment_ID ) ) |
| 3115 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
| 3116 | |
| 3117 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3118 | do_action( 'xmlrpc_call', 'wp.editComment' ); |
| 3119 | |
| 3120 | if ( isset($content_struct['status']) ) { |
| 3121 | $statuses = get_comment_statuses(); |
| 3122 | $statuses = array_keys($statuses); |
| 3123 | |
| 3124 | if ( ! in_array($content_struct['status'], $statuses) ) |
| 3125 | return new IXR_Error( 401, __( 'Invalid comment status.' ) ); |
| 3126 | $comment_approved = $content_struct['status']; |
| 3127 | } |
| Line | Code |
| 3250 | return new IXR_Error( 403, __( 'A valid email address is required' ) ); |
| 3251 | } |
| 3252 | } |
| 3253 | |
| 3254 | $comment['comment_parent'] = isset($content_struct['comment_parent']) ? absint($content_struct['comment_parent']) : 0; |
| 3255 | |
| 3256 | $comment['comment_content'] = isset($content_struct['content']) ? $content_struct['content'] : null; |
| 3257 | |
| 3258 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3259 | do_action( 'xmlrpc_call', 'wp.newComment' ); |
| 3260 | |
| 3261 | $comment_ID = wp_new_comment( $comment ); |
| 3262 | |
| 3263 | /** |
| 3264 | * Fires after a new comment has been successfully created via XML-RPC. |
| 3265 | * |
| 3266 | * @since 3.4.0 |
| 3267 | * |
| 3268 | * @param int $comment_ID ID of the new comment. |
| Line | Code |
| 3289 | $password = $args[2]; |
| 3290 | |
| 3291 | if ( !$user = $this->login($username, $password) ) |
| 3292 | return $this->error; |
| 3293 | |
| 3294 | if ( !current_user_can( 'moderate_comments' ) ) |
| 3295 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
| 3296 | |
| 3297 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3298 | do_action( 'xmlrpc_call', 'wp.getCommentStatusList' ); |
| 3299 | |
| 3300 | return get_comment_statuses(); |
| 3301 | } |
| 3302 | |
| 3303 | /** |
| 3304 | * Retrieve comment count. |
| 3305 | * |
| 3306 | * @since 2.5.0 |
| 3307 | * |
| Line | Code |
| 3317 | $post_id = (int) $args[3]; |
| 3318 | |
| 3319 | if ( !$user = $this->login($username, $password) ) |
| 3320 | return $this->error; |
| 3321 | |
| 3322 | if ( !current_user_can( 'edit_posts' ) ) |
| 3323 | return new IXR_Error( 403, __( 'You are not allowed access to details about comments.' ) ); |
| 3324 | |
| 3325 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3326 | do_action( 'xmlrpc_call', 'wp.getCommentCount' ); |
| 3327 | |
| 3328 | $count = wp_count_comments( $post_id ); |
| 3329 | return array( |
| 3330 | 'approved' => $count->approved, |
| 3331 | 'awaiting_moderation' => $count->moderated, |
| 3332 | 'spam' => $count->spam, |
| 3333 | 'total_comments' => $count->total_comments |
| 3334 | ); |
| 3335 | } |
| Line | Code |
| 3350 | $password = $args[2]; |
| 3351 | |
| 3352 | if ( !$user = $this->login($username, $password) ) |
| 3353 | return $this->error; |
| 3354 | |
| 3355 | if ( !current_user_can( 'edit_posts' ) ) |
| 3356 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
| 3357 | |
| 3358 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3359 | do_action( 'xmlrpc_call', 'wp.getPostStatusList' ); |
| 3360 | |
| 3361 | return get_post_statuses(); |
| 3362 | } |
| 3363 | |
| 3364 | /** |
| 3365 | * Retrieve page statuses. |
| 3366 | * |
| 3367 | * @since 2.5.0 |
| 3368 | * |
| Line | Code |
| 3377 | $password = $args[2]; |
| 3378 | |
| 3379 | if ( !$user = $this->login($username, $password) ) |
| 3380 | return $this->error; |
| 3381 | |
| 3382 | if ( !current_user_can( 'edit_pages' ) ) |
| 3383 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
| 3384 | |
| 3385 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3386 | do_action( 'xmlrpc_call', 'wp.getPageStatusList' ); |
| 3387 | |
| 3388 | return get_page_statuses(); |
| 3389 | } |
| 3390 | |
| 3391 | /** |
| 3392 | * Retrieve page templates. |
| 3393 | * |
| 3394 | * @since 2.6.0 |
| 3395 | * |
| Line | Code |
| 3535 | $attachment_id = (int) $args[3]; |
| 3536 | |
| 3537 | if ( !$user = $this->login($username, $password) ) |
| 3538 | return $this->error; |
| 3539 | |
| 3540 | if ( !current_user_can( 'upload_files' ) ) |
| 3541 | return new IXR_Error( 403, __( 'You do not have permission to upload files.' ) ); |
| 3542 | |
| 3543 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3544 | do_action( 'xmlrpc_call', 'wp.getMediaItem' ); |
| 3545 | |
| 3546 | if ( ! $attachment = get_post($attachment_id) ) |
| 3547 | return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); |
| 3548 | |
| 3549 | return $this->_prepare_media_item( $attachment ); |
| 3550 | } |
| 3551 | |
| 3552 | /** |
| 3553 | * Retrieves a collection of media library items (or attachments) |
| Line | Code |
| 3581 | $struct = isset( $args[3] ) ? $args[3] : array() ; |
| 3582 | |
| 3583 | if ( !$user = $this->login($username, $password) ) |
| 3584 | return $this->error; |
| 3585 | |
| 3586 | if ( !current_user_can( 'upload_files' ) ) |
| 3587 | return new IXR_Error( 401, __( 'You do not have permission to upload files.' ) ); |
| 3588 | |
| 3589 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3590 | do_action( 'xmlrpc_call', 'wp.getMediaLibrary' ); |
| 3591 | |
| 3592 | $parent_id = ( isset($struct['parent_id']) ) ? absint($struct['parent_id']) : '' ; |
| 3593 | $mime_type = ( isset($struct['mime_type']) ) ? $struct['mime_type'] : '' ; |
| 3594 | $offset = ( isset($struct['offset']) ) ? absint($struct['offset']) : 0 ; |
| 3595 | $number = ( isset($struct['number']) ) ? absint($struct['number']) : -1 ; |
| 3596 | |
| 3597 | $attachments = get_posts( array('post_type' => 'attachment', 'post_parent' => $parent_id, 'offset' => $offset, 'numberposts' => $number, 'post_mime_type' => $mime_type ) ); |
| 3598 | |
| 3599 | $attachments_struct = array(); |
| Line | Code |
| 3623 | $password = $args[2]; |
| 3624 | |
| 3625 | if ( !$user = $this->login( $username, $password ) ) |
| 3626 | return $this->error; |
| 3627 | |
| 3628 | if ( !current_user_can( 'edit_posts' ) ) |
| 3629 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
| 3630 | |
| 3631 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3632 | do_action( 'xmlrpc_call', 'wp.getPostFormats' ); |
| 3633 | |
| 3634 | $formats = get_post_format_strings(); |
| 3635 | |
| 3636 | # find out if they want a list of currently supports formats |
| 3637 | if ( isset( $args[3] ) && is_array( $args[3] ) ) { |
| 3638 | if ( $args[3]['show-supported'] ) { |
| 3639 | if ( current_theme_supports( 'post-formats' ) ) { |
| 3640 | $supported = get_theme_support( 'post-formats' ); |
| 3641 | |
| Line | Code |
| 3696 | * @param string $method The method name. |
| 3697 | */ |
| 3698 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostType' ); |
| 3699 | } |
| 3700 | |
| 3701 | if ( !$user = $this->login( $username, $password ) ) |
| 3702 | return $this->error; |
| 3703 | |
| 3704 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3705 | do_action( 'xmlrpc_call', 'wp.getPostType' ); |
| 3706 | |
| 3707 | if( ! post_type_exists( $post_type_name ) ) |
| 3708 | return new IXR_Error( 403, __( 'Invalid post type' ) ); |
| 3709 | |
| 3710 | $post_type = get_post_type_object( $post_type_name ); |
| 3711 | |
| 3712 | if( ! current_user_can( $post_type->cap->edit_posts ) ) |
| 3713 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post type.' ) ); |
| 3714 | |
| Line | Code |
| 3745 | } else { |
| 3746 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3747 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostTypes' ); |
| 3748 | } |
| 3749 | |
| 3750 | if ( ! $user = $this->login( $username, $password ) ) |
| 3751 | return $this->error; |
| 3752 | |
| 3753 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3754 | do_action( 'xmlrpc_call', 'wp.getPostTypes' ); |
| 3755 | |
| 3756 | $post_types = get_post_types( $filter, 'objects' ); |
| 3757 | |
| 3758 | $struct = array(); |
| 3759 | |
| 3760 | foreach( $post_types as $post_type ) { |
| 3761 | if( ! current_user_can( $post_type->cap->edit_posts ) ) |
| 3762 | continue; |
| 3763 | |
| Line | Code |
| 3809 | * @param string $method The method name. |
| 3810 | */ |
| 3811 | $fields = apply_filters( 'xmlrpc_default_revision_fields', array( 'post_date', 'post_date_gmt' ), 'wp.getRevisions' ); |
| 3812 | } |
| 3813 | |
| 3814 | if ( ! $user = $this->login( $username, $password ) ) |
| 3815 | return $this->error; |
| 3816 | |
| 3817 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3818 | do_action( 'xmlrpc_call', 'wp.getRevisions' ); |
| 3819 | |
| 3820 | if ( ! $post = get_post( $post_id ) ) |
| 3821 | return new IXR_Error( 404, __( 'Invalid post ID' ) ); |
| 3822 | |
| 3823 | if ( ! current_user_can( 'edit_post', $post_id ) ) |
| 3824 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
| 3825 | |
| 3826 | // Check if revisions are enabled. |
| 3827 | if ( ! wp_revisions_enabled( $post ) ) |
| Line | Code |
| 3871 | $blog_id = (int) $args[0]; |
| 3872 | $username = $args[1]; |
| 3873 | $password = $args[2]; |
| 3874 | $revision_id = (int) $args[3]; |
| 3875 | |
| 3876 | if ( ! $user = $this->login( $username, $password ) ) |
| 3877 | return $this->error; |
| 3878 | |
| 3879 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3880 | do_action( 'xmlrpc_call', 'wp.restoreRevision' ); |
| 3881 | |
| 3882 | if ( ! $revision = wp_get_post_revision( $revision_id ) ) |
| 3883 | return new IXR_Error( 404, __( 'Invalid post ID' ) ); |
| 3884 | |
| 3885 | if ( wp_is_post_autosave( $revision ) ) |
| 3886 | return new IXR_Error( 404, __( 'Invalid post ID' ) ); |
| 3887 | |
| 3888 | if ( ! $post = get_post( $revision->post_parent ) ) |
| 3889 | return new IXR_Error( 404, __( 'Invalid post ID' ) ); |
| Line | Code |
| 3921 | $this->escape($args); |
| 3922 | |
| 3923 | $username = $args[1]; |
| 3924 | $password = $args[2]; |
| 3925 | |
| 3926 | if ( !$user = $this->login($username, $password) ) |
| 3927 | return $this->error; |
| 3928 | |
| 3929 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3930 | do_action( 'xmlrpc_call', 'blogger.getUsersBlogs' ); |
| 3931 | |
| 3932 | $is_admin = current_user_can('manage_options'); |
| 3933 | |
| 3934 | $struct = array( |
| 3935 | 'isAdmin' => $is_admin, |
| 3936 | 'url' => get_option('home') . '/', |
| 3937 | 'blogid' => '1', |
| 3938 | 'blogName' => get_option('blogname'), |
| 3939 | 'xmlrpc' => site_url( 'xmlrpc.php', 'rpc' ), |
| Line | Code |
| 3989 | $password = $args[2]; |
| 3990 | |
| 3991 | if ( !$user = $this->login($username, $password) ) |
| 3992 | return $this->error; |
| 3993 | |
| 3994 | if ( !current_user_can( 'edit_posts' ) ) |
| 3995 | return new IXR_Error( 401, __( 'Sorry, you do not have access to user data on this site.' ) ); |
| 3996 | |
| 3997 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3998 | do_action( 'xmlrpc_call', 'blogger.getUserInfo' ); |
| 3999 | |
| 4000 | $struct = array( |
| 4001 | 'nickname' => $user->nickname, |
| 4002 | 'userid' => $user->ID, |
| 4003 | 'url' => $user->user_url, |
| 4004 | 'lastname' => $user->last_name, |
| 4005 | 'firstname' => $user->first_name |
| 4006 | ); |
| 4007 | |
| Line | Code |
| 4029 | |
| 4030 | $post_data = get_post($post_ID, ARRAY_A); |
| 4031 | if ( ! $post_data ) |
| 4032 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4033 | |
| 4034 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
| 4035 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); |
| 4036 | |
| 4037 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4038 | do_action( 'xmlrpc_call', 'blogger.getPost' ); |
| 4039 | |
| 4040 | $categories = implode(',', wp_get_post_categories($post_ID)); |
| 4041 | |
| 4042 | $content = '<title>'.wp_unslash($post_data['post_title']).'</title>'; |
| 4043 | $content .= '<category>'.$categories.'</category>'; |
| 4044 | $content .= wp_unslash($post_data['post_content']); |
| 4045 | |
| 4046 | $struct = array( |
| 4047 | 'userid' => $post_data['post_author'], |
| Line | Code |
| 4075 | $query = array(); |
| 4076 | |
| 4077 | if ( !$user = $this->login($username, $password) ) |
| 4078 | return $this->error; |
| 4079 | |
| 4080 | if ( ! current_user_can( 'edit_posts' ) ) |
| 4081 | return new IXR_Error( 401, __( 'Sorry, you cannot edit posts on this site.' ) ); |
| 4082 | |
| 4083 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4084 | do_action( 'xmlrpc_call', 'blogger.getRecentPosts' ); |
| 4085 | |
| 4086 | $posts_list = wp_get_recent_posts( $query ); |
| 4087 | |
| 4088 | if ( !$posts_list ) { |
| 4089 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
| 4090 | return $this->error; |
| 4091 | } |
| 4092 | |
| 4093 | foreach ($posts_list as $entry) { |
| Line | Code |
| 4154 | $username = $args[2]; |
| 4155 | $password = $args[3]; |
| 4156 | $content = $args[4]; |
| 4157 | $publish = $args[5]; |
| 4158 | |
| 4159 | if ( !$user = $this->login($username, $password) ) |
| 4160 | return $this->error; |
| 4161 | |
| 4162 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4163 | do_action( 'xmlrpc_call', 'blogger.newPost' ); |
| 4164 | |
| 4165 | $cap = ($publish) ? 'publish_posts' : 'edit_posts'; |
| 4166 | if ( ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) || !current_user_can($cap) ) |
| 4167 | return new IXR_Error(401, __('Sorry, you are not allowed to post on this site.')); |
| 4168 | |
| 4169 | $post_status = ($publish) ? 'publish' : 'draft'; |
| 4170 | |
| 4171 | $post_author = $user->ID; |
| 4172 | |
| Line | Code |
| 4217 | $username = $args[2]; |
| 4218 | $password = $args[3]; |
| 4219 | $content = $args[4]; |
| 4220 | $publish = $args[5]; |
| 4221 | |
| 4222 | if ( !$user = $this->login($username, $password) ) |
| 4223 | return $this->error; |
| 4224 | |
| 4225 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4226 | do_action( 'xmlrpc_call', 'blogger.editPost' ); |
| 4227 | |
| 4228 | $actual_post = get_post($post_ID,ARRAY_A); |
| 4229 | |
| 4230 | if ( !$actual_post || $actual_post['post_type'] != 'post' ) |
| 4231 | return new IXR_Error(404, __('Sorry, no such post.')); |
| 4232 | |
| 4233 | $this->escape($actual_post); |
| 4234 | |
| 4235 | if ( !current_user_can('edit_post', $post_ID) ) |
| Line | Code |
| 4280 | $post_ID = (int) $args[1]; |
| 4281 | $username = $args[2]; |
| 4282 | $password = $args[3]; |
| 4283 | $publish = $args[4]; |
| 4284 | |
| 4285 | if ( !$user = $this->login($username, $password) ) |
| 4286 | return $this->error; |
| 4287 | |
| 4288 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4289 | do_action( 'xmlrpc_call', 'blogger.deletePost' ); |
| 4290 | |
| 4291 | $actual_post = get_post($post_ID,ARRAY_A); |
| 4292 | |
| 4293 | if ( !$actual_post || $actual_post['post_type'] != 'post' ) |
| 4294 | return new IXR_Error(404, __('Sorry, no such post.')); |
| 4295 | |
| 4296 | if ( !current_user_can('delete_post', $post_ID) ) |
| 4297 | return new IXR_Error(401, __('Sorry, you do not have the right to delete this post.')); |
| 4298 | |
| Line | Code |
| 4360 | $username = $args[1]; |
| 4361 | $password = $args[2]; |
| 4362 | $content_struct = $args[3]; |
| 4363 | $publish = isset( $args[4] ) ? $args[4] : 0; |
| 4364 | |
| 4365 | if ( !$user = $this->login($username, $password) ) |
| 4366 | return $this->error; |
| 4367 | |
| 4368 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4369 | do_action( 'xmlrpc_call', 'metaWeblog.newPost' ); |
| 4370 | |
| 4371 | $page_template = ''; |
| 4372 | if ( !empty( $content_struct['post_type'] ) ) { |
| 4373 | if ( $content_struct['post_type'] == 'page' ) { |
| 4374 | if ( $publish ) |
| 4375 | $cap = 'publish_pages'; |
| 4376 | elseif ( isset( $content_struct['page_status'] ) && 'publish' == $content_struct['page_status'] ) |
| 4377 | $cap = 'publish_pages'; |
| 4378 | else |
| Line | Code |
| 4688 | $username = $args[1]; |
| 4689 | $password = $args[2]; |
| 4690 | $content_struct = $args[3]; |
| 4691 | $publish = isset( $args[4] ) ? $args[4] : 0; |
| 4692 | |
| 4693 | if ( ! $user = $this->login($username, $password) ) |
| 4694 | return $this->error; |
| 4695 | |
| 4696 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4697 | do_action( 'xmlrpc_call', 'metaWeblog.editPost' ); |
| 4698 | |
| 4699 | $postdata = get_post( $post_ID, ARRAY_A ); |
| 4700 | |
| 4701 | // If there is no post data for the give post id, stop |
| 4702 | // now and return an error. Other wise a new post will be |
| 4703 | // created (which was the old behavior). |
| 4704 | if ( ! $postdata || empty( $postdata[ 'ID' ] ) ) |
| 4705 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4706 | |
| Line | Code |
| 4971 | |
| 4972 | $postdata = get_post($post_ID, ARRAY_A); |
| 4973 | if ( ! $postdata ) |
| 4974 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4975 | |
| 4976 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
| 4977 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); |
| 4978 | |
| 4979 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4980 | do_action( 'xmlrpc_call', 'metaWeblog.getPost' ); |
| 4981 | |
| 4982 | if ($postdata['post_date'] != '') { |
| 4983 | $post_date = $this->_convert_date( $postdata['post_date'] ); |
| 4984 | $post_date_gmt = $this->_convert_date_gmt( $postdata['post_date_gmt'], $postdata['post_date'] ); |
| 4985 | $post_modified = $this->_convert_date( $postdata['post_modified'] ); |
| 4986 | $post_modified_gmt = $this->_convert_date_gmt( $postdata['post_modified_gmt'], $postdata['post_modified'] ); |
| 4987 | |
| 4988 | $categories = array(); |
| 4989 | $catids = wp_get_post_categories($post_ID); |
| Line | Code |
| 5096 | $query = array(); |
| 5097 | |
| 5098 | if ( !$user = $this->login($username, $password) ) |
| 5099 | return $this->error; |
| 5100 | |
| 5101 | if ( ! current_user_can( 'edit_posts' ) ) |
| 5102 | return new IXR_Error( 401, __( 'Sorry, you cannot edit posts on this site.' ) ); |
| 5103 | |
| 5104 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5105 | do_action( 'xmlrpc_call', 'metaWeblog.getRecentPosts' ); |
| 5106 | |
| 5107 | $posts_list = wp_get_recent_posts( $query ); |
| 5108 | |
| 5109 | if ( !$posts_list ) |
| 5110 | return array(); |
| 5111 | |
| 5112 | $struct = array(); |
| 5113 | foreach ($posts_list as $entry) { |
| 5114 | if ( !current_user_can( 'edit_post', $entry['ID'] ) ) |
| Line | Code |
| 5212 | $password = $args[2]; |
| 5213 | |
| 5214 | if ( !$user = $this->login($username, $password) ) |
| 5215 | return $this->error; |
| 5216 | |
| 5217 | if ( !current_user_can( 'edit_posts' ) ) |
| 5218 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
| 5219 | |
| 5220 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5221 | do_action( 'xmlrpc_call', 'metaWeblog.getCategories' ); |
| 5222 | |
| 5223 | $categories_struct = array(); |
| 5224 | |
| 5225 | if ( $cats = get_categories(array('get' => 'all')) ) { |
| 5226 | foreach ( $cats as $cat ) { |
| 5227 | $struct['categoryId'] = $cat->term_id; |
| 5228 | $struct['parentId'] = $cat->parent; |
| 5229 | $struct['description'] = $cat->name; |
| 5230 | $struct['categoryDescription'] = $cat->description; |
| Line | Code |
| 5261 | |
| 5262 | $name = sanitize_file_name( $data['name'] ); |
| 5263 | $type = $data['type']; |
| 5264 | $bits = $data['bits']; |
| 5265 | |
| 5266 | if ( !$user = $this->login($username, $password) ) |
| 5267 | return $this->error; |
| 5268 | |
| 5269 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5270 | do_action( 'xmlrpc_call', 'metaWeblog.newMediaObject' ); |
| 5271 | |
| 5272 | if ( !current_user_can('upload_files') ) { |
| 5273 | $this->error = new IXR_Error( 401, __( 'You do not have permission to upload files.' ) ); |
| 5274 | return $this->error; |
| 5275 | } |
| 5276 | |
| 5277 | /** |
| 5278 | * Filter whether to preempt the XML-RPC media upload. |
| 5279 | * |
| Line | Code |
| 5375 | if ( isset( $args[3] ) ) |
| 5376 | $query = array( 'numberposts' => absint( $args[3] ) ); |
| 5377 | else |
| 5378 | $query = array(); |
| 5379 | |
| 5380 | if ( !$user = $this->login($username, $password) ) |
| 5381 | return $this->error; |
| 5382 | |
| 5383 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5384 | do_action( 'xmlrpc_call', 'mt.getRecentPostTitles' ); |
| 5385 | |
| 5386 | $posts_list = wp_get_recent_posts( $query ); |
| 5387 | |
| 5388 | if ( !$posts_list ) { |
| 5389 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
| 5390 | return $this->error; |
| 5391 | } |
| 5392 | |
| 5393 | $struct = array(); |
| Line | Code |
| 5435 | $password = $args[2]; |
| 5436 | |
| 5437 | if ( !$user = $this->login($username, $password) ) |
| 5438 | return $this->error; |
| 5439 | |
| 5440 | if ( !current_user_can( 'edit_posts' ) ) |
| 5441 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
| 5442 | |
| 5443 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5444 | do_action( 'xmlrpc_call', 'mt.getCategoryList' ); |
| 5445 | |
| 5446 | $categories_struct = array(); |
| 5447 | |
| 5448 | if ( $cats = get_categories(array('hide_empty' => 0, 'hierarchical' => 0)) ) { |
| 5449 | foreach ( $cats as $cat ) { |
| 5450 | $struct['categoryId'] = $cat->term_id; |
| 5451 | $struct['categoryName'] = $cat->name; |
| 5452 | |
| 5453 | $categories_struct[] = $struct; |
| Line | Code |
| 5477 | return $this->error; |
| 5478 | |
| 5479 | if ( ! get_post( $post_ID ) ) |
| 5480 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 5481 | |
| 5482 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
| 5483 | return new IXR_Error( 401, __( 'Sorry, you can not edit this post.' ) ); |
| 5484 | |
| 5485 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5486 | do_action( 'xmlrpc_call', 'mt.getPostCategories' ); |
| 5487 | |
| 5488 | $categories = array(); |
| 5489 | $catids = wp_get_post_categories(intval($post_ID)); |
| 5490 | // first listed category will be the primary category |
| 5491 | $isPrimary = true; |
| 5492 | foreach ( $catids as $catid ) { |
| 5493 | $categories[] = array( |
| 5494 | 'categoryName' => get_cat_name($catid), |
| 5495 | 'categoryId' => (string) $catid, |
| Line | Code |
| 5516 | $post_ID = (int) $args[0]; |
| 5517 | $username = $args[1]; |
| 5518 | $password = $args[2]; |
| 5519 | $categories = $args[3]; |
| 5520 | |
| 5521 | if ( !$user = $this->login($username, $password) ) |
| 5522 | return $this->error; |
| 5523 | |
| 5524 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5525 | do_action( 'xmlrpc_call', 'mt.setPostCategories' ); |
| 5526 | |
| 5527 | if ( ! get_post( $post_ID ) ) |
| 5528 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 5529 | |
| 5530 | if ( !current_user_can('edit_post', $post_ID) ) |
| 5531 | return new IXR_Error(401, __('Sorry, you cannot edit this post.')); |
| 5532 | |
| 5533 | $catids = array(); |
| 5534 | foreach ( $categories as $cat ) { |
| Line | Code |
| 5545 | * |
| 5546 | * @since 1.5.0 |
| 5547 | * |
| 5548 | * @param array $args Method parameters. |
| 5549 | * @return array |
| 5550 | */ |
| 5551 | function mt_supportedMethods($args) { |
| 5552 | |
| 5553 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5554 | do_action( 'xmlrpc_call', 'mt.supportedMethods' ); |
| 5555 | |
| 5556 | $supported_methods = array(); |
| 5557 | foreach ( $this->methods as $key => $value ) { |
| 5558 | $supported_methods[] = $key; |
| 5559 | } |
| 5560 | |
| 5561 | return $supported_methods; |
| 5562 | } |
| 5563 | |
| 5564 | /** |
| 5565 | * Retrieve an empty array because we don't support per-post text filters. |
| 5566 | * |
| 5567 | * @since 1.5.0 |
| 5568 | * |
| 5569 | * @param array $args Method parameters. |
| 5570 | */ |
| 5571 | function mt_supportedTextFilters($args) { |
| 5572 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5573 | do_action( 'xmlrpc_call', 'mt.supportedTextFilters' ); |
| 5574 | |
| 5575 | /** |
| 5576 | * Filter the MoveableType text filters list for XML-RPC. |
| 5577 | * |
| 5578 | * @since 2.2.0 |
| 5579 | * |
| 5580 | * @param array $filters An array of text filters. |
| 5581 | */ |
| 5582 | return apply_filters( 'xmlrpc_text_filters', array() ); |
| Line | Code |
| 5591 | * @return mixed |
| 5592 | */ |
| 5593 | function mt_getTrackbackPings($args) { |
| 5594 | |
| 5595 | global $wpdb; |
| 5596 | |
| 5597 | $post_ID = intval($args); |
| 5598 | |
| 5599 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5600 | do_action( 'xmlrpc_call', 'mt.getTrackbackPings' ); |
| 5601 | |
| 5602 | $actual_post = get_post($post_ID, ARRAY_A); |
| 5603 | |
| 5604 | if ( !$actual_post ) |
| 5605 | return new IXR_Error(404, __('Sorry, no such post.')); |
| 5606 | |
| 5607 | $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) ); |
| 5608 | |
| 5609 | if ( !$comments ) |
| Line | Code |
| 5639 | |
| 5640 | $post_ID = (int) $args[0]; |
| 5641 | $username = $args[1]; |
| 5642 | $password = $args[2]; |
| 5643 | |
| 5644 | if ( !$user = $this->login($username, $password) ) |
| 5645 | return $this->error; |
| 5646 | |
| 5647 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5648 | do_action( 'xmlrpc_call', 'mt.publishPost' ); |
| 5649 | |
| 5650 | $postdata = get_post($post_ID, ARRAY_A); |
| 5651 | if ( ! $postdata ) |
| 5652 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 5653 | |
| 5654 | if ( !current_user_can('publish_posts') || !current_user_can('edit_post', $post_ID) ) |
| 5655 | return new IXR_Error(401, __('Sorry, you cannot publish this post.')); |
| 5656 | |
| 5657 | $postdata['post_status'] = 'publish'; |
| Line | Code |
| 5676 | * @since 1.5.0 |
| 5677 | * |
| 5678 | * @param array $args Method parameters. |
| 5679 | * @return array |
| 5680 | */ |
| 5681 | function pingback_ping($args) { |
| 5682 | global $wpdb; |
| 5683 | |
| 5684 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5685 | do_action( 'xmlrpc_call', 'pingback.ping' ); |
| 5686 | |
| 5687 | $this->escape($args); |
| 5688 | |
| 5689 | $pagelinkedfrom = $args[0]; |
| 5690 | $pagelinkedto = $args[1]; |
| 5691 | |
| 5692 | $title = ''; |
| 5693 | |
| 5694 | $pagelinkedfrom = str_replace('&', '&', $pagelinkedfrom); |
| Line | Code |
| 5890 | * |
| 5891 | * @param array $args Method parameters. |
| 5892 | * @return array |
| 5893 | */ |
| 5894 | function pingback_extensions_getPingbacks($args) { |
| 5895 | |
| 5896 | global $wpdb; |
| 5897 | |
| 5898 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5899 | do_action( 'xmlrpc_call', 'pingback.extensions.getPingbacks' ); |
| 5900 | |
| 5901 | $this->escape($args); |
| 5902 | |
| 5903 | $url = $args; |
| 5904 | |
| 5905 | $post_ID = url_to_postid($url); |
| 5906 | if ( !$post_ID ) { |
| 5907 | // We aren't sure that the resource is available and/or pingback enabled |
| 5908 | 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.' ) ); |