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 |
|---|---|
| 532 | * the method logic begins. |
| 533 | * |
| 534 | * All built-in XML-RPC methods use the action xmlrpc_call, with a parameter |
| 535 | * equal to the method's name, e.g., wp.getUsersBlogs, wp.newPost, etc. |
| 536 | * |
| 537 | * @since 2.5.0 |
| 538 | * |
| 539 | * @param method $name The method name. |
| 540 | */ |
| 541 | do_action( 'xmlrpc_call', 'wp.getUsersBlogs' ); |
| 542 | |
| 543 | $blogs = (array) get_blogs_of_user( $user->ID ); |
| 544 | $struct = array(); |
| 545 | |
| 546 | foreach ( $blogs as $blog ) { |
| 547 | // Don't include blogs that aren't hosted at this site |
| 548 | if ( $blog->site_id != get_current_site()->id ) |
| 549 | continue; |
| 550 | |
| Line | Code |
| 1114 | if ( isset( $content_struct['post_date_gmt'] ) && ! is_a( $content_struct['post_date_gmt'], 'IXR_Date' ) ) { |
| 1115 | if ( $content_struct['post_date_gmt'] == '0000-00-00 00:00:00' || isset( $content_struct['post_date'] ) ) { |
| 1116 | unset( $content_struct['post_date_gmt'] ); |
| 1117 | } else { |
| 1118 | $content_struct['post_date_gmt'] = $this->_convert_date( $content_struct['post_date_gmt'] ); |
| 1119 | } |
| 1120 | } |
| 1121 | |
| 1122 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1123 | do_action( 'xmlrpc_call', 'wp.newPost' ); |
| 1124 | |
| 1125 | unset( $content_struct['ID'] ); |
| 1126 | |
| 1127 | return $this->_insert_post( $user, $content_struct ); |
| 1128 | } |
| 1129 | |
| 1130 | /** |
| 1131 | * Helper method for filtering out elements from an array. |
| 1132 | * |
| Line | Code |
| 1409 | $username = $args[1]; |
| 1410 | $password = $args[2]; |
| 1411 | $post_id = (int) $args[3]; |
| 1412 | $content_struct = $args[4]; |
| 1413 | |
| 1414 | if ( ! $user = $this->login( $username, $password ) ) |
| 1415 | return $this->error; |
| 1416 | |
| 1417 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1418 | do_action( 'xmlrpc_call', 'wp.editPost' ); |
| 1419 | |
| 1420 | $post = get_post( $post_id, ARRAY_A ); |
| 1421 | |
| 1422 | if ( empty( $post['ID'] ) ) |
| 1423 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 1424 | |
| 1425 | if ( isset( $content_struct['if_not_modified_since'] ) ) { |
| 1426 | // If the post has been modified since the date provided, return an error. |
| 1427 | if ( mysql2date( 'U', $post['post_modified_gmt'] ) > $content_struct['if_not_modified_since']->getTimestamp() ) { |
| Line | Code |
| 1471 | $blog_id = (int) $args[0]; |
| 1472 | $username = $args[1]; |
| 1473 | $password = $args[2]; |
| 1474 | $post_id = (int) $args[3]; |
| 1475 | |
| 1476 | if ( ! $user = $this->login( $username, $password ) ) |
| 1477 | return $this->error; |
| 1478 | |
| 1479 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1480 | do_action( 'xmlrpc_call', 'wp.deletePost' ); |
| 1481 | |
| 1482 | $post = get_post( $post_id, ARRAY_A ); |
| 1483 | if ( empty( $post['ID'] ) ) |
| 1484 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 1485 | |
| 1486 | if ( ! current_user_can( 'delete_post', $post_id ) ) |
| 1487 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) ); |
| 1488 | |
| 1489 | $result = wp_delete_post( $post_id ); |
| Line | Code |
| 1561 | * @param string $method Method name. |
| 1562 | */ |
| 1563 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPost' ); |
| 1564 | } |
| 1565 | |
| 1566 | if ( ! $user = $this->login( $username, $password ) ) |
| 1567 | return $this->error; |
| 1568 | |
| 1569 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1570 | do_action( 'xmlrpc_call', 'wp.getPost' ); |
| 1571 | |
| 1572 | $post = get_post( $post_id, ARRAY_A ); |
| 1573 | |
| 1574 | if ( empty( $post['ID'] ) ) |
| 1575 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 1576 | |
| 1577 | if ( ! current_user_can( 'edit_post', $post_id ) ) |
| 1578 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); |
| 1579 | |
| Line | Code |
| 1620 | } else { |
| 1621 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1622 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPosts' ); |
| 1623 | } |
| 1624 | |
| 1625 | if ( ! $user = $this->login( $username, $password ) ) |
| 1626 | return $this->error; |
| 1627 | |
| 1628 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1629 | do_action( 'xmlrpc_call', 'wp.getPosts' ); |
| 1630 | |
| 1631 | $query = array(); |
| 1632 | |
| 1633 | if ( isset( $filter['post_type'] ) ) { |
| 1634 | $post_type = get_post_type_object( $filter['post_type'] ); |
| 1635 | if ( ! ( (bool) $post_type ) ) |
| 1636 | return new IXR_Error( 403, __( 'The post type specified is not valid' ) ); |
| 1637 | } else { |
| 1638 | $post_type = get_post_type_object( 'post' ); |
| Line | Code |
| 1710 | $blog_id = (int) $args[0]; |
| 1711 | $username = $args[1]; |
| 1712 | $password = $args[2]; |
| 1713 | $content_struct = $args[3]; |
| 1714 | |
| 1715 | if ( ! $user = $this->login( $username, $password ) ) |
| 1716 | return $this->error; |
| 1717 | |
| 1718 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1719 | do_action( 'xmlrpc_call', 'wp.newTerm' ); |
| 1720 | |
| 1721 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) |
| 1722 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
| 1723 | |
| 1724 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
| 1725 | |
| 1726 | if ( ! current_user_can( $taxonomy->cap->manage_terms ) ) |
| 1727 | return new IXR_Error( 401, __( 'You are not allowed to create terms in this taxonomy.' ) ); |
| 1728 | |
| Line | Code |
| 1799 | $username = $args[1]; |
| 1800 | $password = $args[2]; |
| 1801 | $term_id = (int) $args[3]; |
| 1802 | $content_struct = $args[4]; |
| 1803 | |
| 1804 | if ( ! $user = $this->login( $username, $password ) ) |
| 1805 | return $this->error; |
| 1806 | |
| 1807 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1808 | do_action( 'xmlrpc_call', 'wp.editTerm' ); |
| 1809 | |
| 1810 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) |
| 1811 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
| 1812 | |
| 1813 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
| 1814 | |
| 1815 | if ( ! current_user_can( $taxonomy->cap->edit_terms ) ) |
| 1816 | return new IXR_Error( 401, __( 'You are not allowed to edit terms in this taxonomy.' ) ); |
| 1817 | |
| Line | Code |
| 1892 | $username = $args[1]; |
| 1893 | $password = $args[2]; |
| 1894 | $taxonomy = $args[3]; |
| 1895 | $term_id = (int) $args[4]; |
| 1896 | |
| 1897 | if ( ! $user = $this->login( $username, $password ) ) |
| 1898 | return $this->error; |
| 1899 | |
| 1900 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1901 | do_action( 'xmlrpc_call', 'wp.deleteTerm' ); |
| 1902 | |
| 1903 | if ( ! taxonomy_exists( $taxonomy ) ) |
| 1904 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
| 1905 | |
| 1906 | $taxonomy = get_taxonomy( $taxonomy ); |
| 1907 | |
| 1908 | if ( ! current_user_can( $taxonomy->cap->delete_terms ) ) |
| 1909 | return new IXR_Error( 401, __( 'You are not allowed to delete terms in this taxonomy.' ) ); |
| 1910 | |
| Line | Code |
| 1960 | $username = $args[1]; |
| 1961 | $password = $args[2]; |
| 1962 | $taxonomy = $args[3]; |
| 1963 | $term_id = (int) $args[4]; |
| 1964 | |
| 1965 | if ( ! $user = $this->login( $username, $password ) ) |
| 1966 | return $this->error; |
| 1967 | |
| 1968 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1969 | do_action( 'xmlrpc_call', 'wp.getTerm' ); |
| 1970 | |
| 1971 | if ( ! taxonomy_exists( $taxonomy ) ) |
| 1972 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
| 1973 | |
| 1974 | $taxonomy = get_taxonomy( $taxonomy ); |
| 1975 | |
| 1976 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
| 1977 | return new IXR_Error( 401, __( 'You are not allowed to assign terms in this taxonomy.' ) ); |
| 1978 | |
| Line | Code |
| 2014 | $username = $args[1]; |
| 2015 | $password = $args[2]; |
| 2016 | $taxonomy = $args[3]; |
| 2017 | $filter = isset( $args[4] ) ? $args[4] : array(); |
| 2018 | |
| 2019 | if ( ! $user = $this->login( $username, $password ) ) |
| 2020 | return $this->error; |
| 2021 | |
| 2022 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2023 | do_action( 'xmlrpc_call', 'wp.getTerms' ); |
| 2024 | |
| 2025 | if ( ! taxonomy_exists( $taxonomy ) ) |
| 2026 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
| 2027 | |
| 2028 | $taxonomy = get_taxonomy( $taxonomy ); |
| 2029 | |
| 2030 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
| 2031 | return new IXR_Error( 401, __( 'You are not allowed to assign terms in this taxonomy.' ) ); |
| 2032 | |
| Line | Code |
| 2103 | * @param string $method The method name. |
| 2104 | */ |
| 2105 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomy' ); |
| 2106 | } |
| 2107 | |
| 2108 | if ( ! $user = $this->login( $username, $password ) ) |
| 2109 | return $this->error; |
| 2110 | |
| 2111 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2112 | do_action( 'xmlrpc_call', 'wp.getTaxonomy' ); |
| 2113 | |
| 2114 | if ( ! taxonomy_exists( $taxonomy ) ) |
| 2115 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
| 2116 | |
| 2117 | $taxonomy = get_taxonomy( $taxonomy ); |
| 2118 | |
| 2119 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
| 2120 | return new IXR_Error( 401, __( 'You are not allowed to assign terms in this taxonomy.' ) ); |
| 2121 | |
| Line | Code |
| 2150 | } else { |
| 2151 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2152 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomies' ); |
| 2153 | } |
| 2154 | |
| 2155 | if ( ! $user = $this->login( $username, $password ) ) |
| 2156 | return $this->error; |
| 2157 | |
| 2158 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2159 | do_action( 'xmlrpc_call', 'wp.getTaxonomies' ); |
| 2160 | |
| 2161 | $taxonomies = get_taxonomies( $filter, 'objects' ); |
| 2162 | |
| 2163 | // holds all the taxonomy data |
| 2164 | $struct = array(); |
| 2165 | |
| 2166 | foreach ( $taxonomies as $taxonomy ) { |
| 2167 | // capability check for post_types |
| 2168 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
| Line | Code |
| 2229 | * @param string $method The method name. |
| 2230 | */ |
| 2231 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUser' ); |
| 2232 | } |
| 2233 | |
| 2234 | if ( ! $user = $this->login( $username, $password ) ) |
| 2235 | return $this->error; |
| 2236 | |
| 2237 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2238 | do_action( 'xmlrpc_call', 'wp.getUser' ); |
| 2239 | |
| 2240 | if ( ! current_user_can( 'edit_user', $user_id ) ) |
| 2241 | return new IXR_Error( 401, __( 'Sorry, you cannot edit users.' ) ); |
| 2242 | |
| 2243 | $user_data = get_userdata( $user_id ); |
| 2244 | |
| 2245 | if ( ! $user_data ) |
| 2246 | return new IXR_Error( 404, __( 'Invalid user ID' ) ); |
| 2247 | |
| Line | Code |
| 2285 | } else { |
| 2286 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2287 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUsers' ); |
| 2288 | } |
| 2289 | |
| 2290 | if ( ! $user = $this->login( $username, $password ) ) |
| 2291 | return $this->error; |
| 2292 | |
| 2293 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2294 | do_action( 'xmlrpc_call', 'wp.getUsers' ); |
| 2295 | |
| 2296 | if ( ! current_user_can( 'list_users' ) ) |
| 2297 | return new IXR_Error( 401, __( 'Sorry, you cannot list users.' ) ); |
| 2298 | |
| 2299 | $query = array( 'fields' => 'all_with_meta' ); |
| 2300 | |
| 2301 | $query['number'] = ( isset( $filter['number'] ) ) ? absint( $filter['number'] ) : 50; |
| 2302 | $query['offset'] = ( isset( $filter['offset'] ) ) ? absint( $filter['offset'] ) : 0; |
| 2303 | |
| Line | Code |
| 2355 | } else { |
| 2356 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2357 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getProfile' ); |
| 2358 | } |
| 2359 | |
| 2360 | if ( ! $user = $this->login( $username, $password ) ) |
| 2361 | return $this->error; |
| 2362 | |
| 2363 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2364 | do_action( 'xmlrpc_call', 'wp.getProfile' ); |
| 2365 | |
| 2366 | if ( ! current_user_can( 'edit_user', $user->ID ) ) |
| 2367 | return new IXR_Error( 401, __( 'Sorry, you cannot edit your profile.' ) ); |
| 2368 | |
| 2369 | $user_data = get_userdata( $user->ID ); |
| 2370 | |
| 2371 | return $this->_prepare_user( $user_data, $fields ); |
| 2372 | } |
| 2373 | |
| Line | Code |
| 2399 | $blog_id = (int) $args[0]; |
| 2400 | $username = $args[1]; |
| 2401 | $password = $args[2]; |
| 2402 | $content_struct = $args[3]; |
| 2403 | |
| 2404 | if ( ! $user = $this->login( $username, $password ) ) |
| 2405 | return $this->error; |
| 2406 | |
| 2407 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2408 | do_action( 'xmlrpc_call', 'wp.editProfile' ); |
| 2409 | |
| 2410 | if ( ! current_user_can( 'edit_user', $user->ID ) ) |
| 2411 | return new IXR_Error( 401, __( 'Sorry, you cannot edit your profile.' ) ); |
| 2412 | |
| 2413 | // holds data of the user |
| 2414 | $user_data = array(); |
| 2415 | $user_data['ID'] = $user->ID; |
| 2416 | |
| 2417 | // only set the user details if it was given |
| Line | Code |
| 2473 | |
| 2474 | $page = get_post($page_id); |
| 2475 | if ( ! $page ) |
| 2476 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 2477 | |
| 2478 | if ( !current_user_can( 'edit_page', $page_id ) ) |
| 2479 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this page.' ) ); |
| 2480 | |
| 2481 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2482 | do_action( 'xmlrpc_call', 'wp.getPage' ); |
| 2483 | |
| 2484 | // If we found the page then format the data. |
| 2485 | if ( $page->ID && ($page->post_type == 'page') ) { |
| 2486 | return $this->_prepare_page( $page ); |
| 2487 | } |
| 2488 | // If the page doesn't exist indicate that. |
| 2489 | else { |
| 2490 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
| 2491 | } |
| Line | Code |
| 2512 | $num_pages = isset($args[3]) ? (int) $args[3] : 10; |
| 2513 | |
| 2514 | if ( !$user = $this->login($username, $password) ) |
| 2515 | return $this->error; |
| 2516 | |
| 2517 | if ( !current_user_can( 'edit_pages' ) ) |
| 2518 | return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) ); |
| 2519 | |
| 2520 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2521 | do_action( 'xmlrpc_call', 'wp.getPages' ); |
| 2522 | |
| 2523 | $pages = get_posts( array('post_type' => 'page', 'post_status' => 'any', 'numberposts' => $num_pages) ); |
| 2524 | $num_pages = count($pages); |
| 2525 | |
| 2526 | // If we have pages, put together their info. |
| 2527 | if ( $num_pages >= 1 ) { |
| 2528 | $pages_struct = array(); |
| 2529 | |
| 2530 | foreach ($pages as $page) { |
| Line | Code |
| 2553 | $username = $this->escape($args[1]); |
| 2554 | $password = $this->escape($args[2]); |
| 2555 | $page = $args[3]; |
| 2556 | $publish = $args[4]; |
| 2557 | |
| 2558 | if ( !$user = $this->login($username, $password) ) |
| 2559 | return $this->error; |
| 2560 | |
| 2561 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2562 | do_action( 'xmlrpc_call', 'wp.newPage' ); |
| 2563 | |
| 2564 | // Mark this as content for a page. |
| 2565 | $args[3]["post_type"] = 'page'; |
| 2566 | |
| 2567 | // Let mw_newPost do all of the heavy lifting. |
| 2568 | return($this->mw_newPost($args)); |
| 2569 | } |
| 2570 | |
| 2571 | /** |
| Line | Code |
| 2582 | $blog_id = (int) $args[0]; |
| 2583 | $username = $args[1]; |
| 2584 | $password = $args[2]; |
| 2585 | $page_id = (int) $args[3]; |
| 2586 | |
| 2587 | if ( !$user = $this->login($username, $password) ) |
| 2588 | return $this->error; |
| 2589 | |
| 2590 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2591 | do_action( 'xmlrpc_call', 'wp.deletePage' ); |
| 2592 | |
| 2593 | // Get the current page based on the page_id and |
| 2594 | // make sure it is a page and not a post. |
| 2595 | $actual_page = get_post($page_id, ARRAY_A); |
| 2596 | if ( !$actual_page || ($actual_page['post_type'] != 'page') ) |
| 2597 | return(new IXR_Error(404, __('Sorry, no such page.'))); |
| 2598 | |
| 2599 | // Make sure the user can delete pages. |
| 2600 | if ( !current_user_can('delete_page', $page_id) ) |
| Line | Code |
| 2633 | $username = $this->escape($args[2]); |
| 2634 | $password = $this->escape($args[3]); |
| 2635 | $content = $args[4]; |
| 2636 | $publish = $args[5]; |
| 2637 | |
| 2638 | if ( !$user = $this->login($username, $password) ) |
| 2639 | return $this->error; |
| 2640 | |
| 2641 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2642 | do_action( 'xmlrpc_call', 'wp.editPage' ); |
| 2643 | |
| 2644 | // Get the page data and make sure it is a page. |
| 2645 | $actual_page = get_post($page_id, ARRAY_A); |
| 2646 | if ( !$actual_page || ($actual_page['post_type'] != 'page') ) |
| 2647 | return(new IXR_Error(404, __('Sorry, no such page.'))); |
| 2648 | |
| 2649 | // Make sure the user is allowed to edit pages. |
| 2650 | if ( !current_user_can('edit_page', $page_id) ) |
| 2651 | return(new IXR_Error(401, __('Sorry, you do not have the right to edit this page.'))); |
| Line | Code |
| 2684 | $password = $args[2]; |
| 2685 | |
| 2686 | if ( !$user = $this->login($username, $password) ) |
| 2687 | return $this->error; |
| 2688 | |
| 2689 | if ( !current_user_can( 'edit_pages' ) ) |
| 2690 | return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) ); |
| 2691 | |
| 2692 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2693 | do_action( 'xmlrpc_call', 'wp.getPageList' ); |
| 2694 | |
| 2695 | // Get list of pages ids and titles |
| 2696 | $page_list = $wpdb->get_results(" |
| 2697 | SELECT ID page_id, |
| 2698 | post_title page_title, |
| 2699 | post_parent page_parent_id, |
| 2700 | post_date_gmt, |
| 2701 | post_date, |
| 2702 | post_status |
| Line | Code |
| 2736 | $password = $args[2]; |
| 2737 | |
| 2738 | if ( !$user = $this->login($username, $password) ) |
| 2739 | return $this->error; |
| 2740 | |
| 2741 | if ( !current_user_can('edit_posts') ) |
| 2742 | return(new IXR_Error(401, __('Sorry, you cannot edit posts on this site.'))); |
| 2743 | |
| 2744 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2745 | do_action( 'xmlrpc_call', 'wp.getAuthors' ); |
| 2746 | |
| 2747 | $authors = array(); |
| 2748 | foreach ( get_users( array( 'fields' => array('ID','user_login','display_name') ) ) as $user ) { |
| 2749 | $authors[] = array( |
| 2750 | 'user_id' => $user->ID, |
| 2751 | 'user_login' => $user->user_login, |
| 2752 | 'display_name' => $user->display_name |
| 2753 | ); |
| 2754 | } |
| Line | Code |
| 2772 | $password = $args[2]; |
| 2773 | |
| 2774 | if ( !$user = $this->login($username, $password) ) |
| 2775 | return $this->error; |
| 2776 | |
| 2777 | if ( !current_user_can( 'edit_posts' ) ) |
| 2778 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view tags.' ) ); |
| 2779 | |
| 2780 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2781 | do_action( 'xmlrpc_call', 'wp.getKeywords' ); |
| 2782 | |
| 2783 | $tags = array(); |
| 2784 | |
| 2785 | if ( $all_tags = get_tags() ) { |
| 2786 | foreach( (array) $all_tags as $tag ) { |
| 2787 | $struct['tag_id'] = $tag->term_id; |
| 2788 | $struct['name'] = $tag->name; |
| 2789 | $struct['count'] = $tag->count; |
| 2790 | $struct['slug'] = $tag->slug; |
| Line | Code |
| 2812 | $blog_id = (int) $args[0]; |
| 2813 | $username = $args[1]; |
| 2814 | $password = $args[2]; |
| 2815 | $category = $args[3]; |
| 2816 | |
| 2817 | if ( !$user = $this->login($username, $password) ) |
| 2818 | return $this->error; |
| 2819 | |
| 2820 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2821 | do_action( 'xmlrpc_call', 'wp.newCategory' ); |
| 2822 | |
| 2823 | // Make sure the user is allowed to add a category. |
| 2824 | if ( !current_user_can('manage_categories') ) |
| 2825 | return(new IXR_Error(401, __('Sorry, you do not have the right to add a category.'))); |
| 2826 | |
| 2827 | // If no slug was provided make it empty so that |
| 2828 | // WordPress will generate one. |
| 2829 | if ( empty($category['slug']) ) |
| 2830 | $category['slug'] = ''; |
| Line | Code |
| 2882 | $blog_id = (int) $args[0]; |
| 2883 | $username = $args[1]; |
| 2884 | $password = $args[2]; |
| 2885 | $category_id = (int) $args[3]; |
| 2886 | |
| 2887 | if ( !$user = $this->login($username, $password) ) |
| 2888 | return $this->error; |
| 2889 | |
| 2890 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2891 | do_action( 'xmlrpc_call', 'wp.deleteCategory' ); |
| 2892 | |
| 2893 | if ( !current_user_can('manage_categories') ) |
| 2894 | return new IXR_Error( 401, __( 'Sorry, you do not have the right to delete a category.' ) ); |
| 2895 | |
| 2896 | $status = wp_delete_term( $category_id, 'category' ); |
| 2897 | |
| 2898 | if ( true == $status ) { |
| 2899 | /** |
| 2900 | * Fires after a category has been successfully deleted via XML-RPC. |
| Line | Code |
| 2928 | $max_results = (int) $args[4]; |
| 2929 | |
| 2930 | if ( !$user = $this->login($username, $password) ) |
| 2931 | return $this->error; |
| 2932 | |
| 2933 | if ( !current_user_can( 'edit_posts' ) ) |
| 2934 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts to this site in order to view categories.' ) ); |
| 2935 | |
| 2936 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2937 | do_action( 'xmlrpc_call', 'wp.suggestCategories' ); |
| 2938 | |
| 2939 | $category_suggestions = array(); |
| 2940 | $args = array('get' => 'all', 'number' => $max_results, 'name__like' => $category); |
| 2941 | foreach ( (array) get_categories($args) as $cat ) { |
| 2942 | $category_suggestions[] = array( |
| 2943 | 'category_id' => $cat->term_id, |
| 2944 | 'category_name' => $cat->name |
| 2945 | ); |
| 2946 | } |
| Line | Code |
| 2965 | $comment_id = (int) $args[3]; |
| 2966 | |
| 2967 | if ( !$user = $this->login($username, $password) ) |
| 2968 | return $this->error; |
| 2969 | |
| 2970 | if ( !current_user_can( 'moderate_comments' ) ) |
| 2971 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
| 2972 | |
| 2973 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2974 | do_action( 'xmlrpc_call', 'wp.getComment' ); |
| 2975 | |
| 2976 | if ( ! $comment = get_comment($comment_id) ) |
| 2977 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 2978 | |
| 2979 | return $this->_prepare_comment( $comment ); |
| 2980 | } |
| 2981 | |
| 2982 | /** |
| 2983 | * Retrieve comments. |
| Line | Code |
| 3007 | $struct = isset( $args[3] ) ? $args[3] : array(); |
| 3008 | |
| 3009 | if ( !$user = $this->login($username, $password) ) |
| 3010 | return $this->error; |
| 3011 | |
| 3012 | if ( !current_user_can( 'moderate_comments' ) ) |
| 3013 | return new IXR_Error( 401, __( 'Sorry, you cannot edit comments.' ) ); |
| 3014 | |
| 3015 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3016 | do_action( 'xmlrpc_call', 'wp.getComments' ); |
| 3017 | |
| 3018 | if ( isset($struct['status']) ) |
| 3019 | $status = $struct['status']; |
| 3020 | else |
| 3021 | $status = ''; |
| 3022 | |
| 3023 | $post_id = ''; |
| 3024 | if ( isset($struct['post_id']) ) |
| 3025 | $post_id = absint($struct['post_id']); |
| Line | Code |
| 3074 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
| 3075 | |
| 3076 | if ( ! get_comment($comment_ID) ) |
| 3077 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 3078 | |
| 3079 | if ( !current_user_can( 'edit_comment', $comment_ID ) ) |
| 3080 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
| 3081 | |
| 3082 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3083 | do_action( 'xmlrpc_call', 'wp.deleteComment' ); |
| 3084 | |
| 3085 | $status = wp_delete_comment( $comment_ID ); |
| 3086 | |
| 3087 | if ( true == $status ) { |
| 3088 | /** |
| 3089 | * Fires after a comment has been successfully deleted via XML-RPC. |
| 3090 | * |
| 3091 | * @since 3.4.0 |
| 3092 | * |
| Line | Code |
| 3139 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
| 3140 | |
| 3141 | if ( ! get_comment($comment_ID) ) |
| 3142 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 3143 | |
| 3144 | if ( !current_user_can( 'edit_comment', $comment_ID ) ) |
| 3145 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
| 3146 | |
| 3147 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3148 | do_action( 'xmlrpc_call', 'wp.editComment' ); |
| 3149 | |
| 3150 | if ( isset($content_struct['status']) ) { |
| 3151 | $statuses = get_comment_statuses(); |
| 3152 | $statuses = array_keys($statuses); |
| 3153 | |
| 3154 | if ( ! in_array($content_struct['status'], $statuses) ) |
| 3155 | return new IXR_Error( 401, __( 'Invalid comment status.' ) ); |
| 3156 | $comment_approved = $content_struct['status']; |
| 3157 | } |
| Line | Code |
| 3278 | return new IXR_Error( 403, __( 'A valid email address is required' ) ); |
| 3279 | } |
| 3280 | } |
| 3281 | |
| 3282 | $comment['comment_parent'] = isset($content_struct['comment_parent']) ? absint($content_struct['comment_parent']) : 0; |
| 3283 | |
| 3284 | $comment['comment_content'] = isset($content_struct['content']) ? $content_struct['content'] : null; |
| 3285 | |
| 3286 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3287 | do_action( 'xmlrpc_call', 'wp.newComment' ); |
| 3288 | |
| 3289 | $comment_ID = wp_new_comment( $comment ); |
| 3290 | |
| 3291 | /** |
| 3292 | * Fires after a new comment has been successfully created via XML-RPC. |
| 3293 | * |
| 3294 | * @since 3.4.0 |
| 3295 | * |
| 3296 | * @param int $comment_ID ID of the new comment. |
| Line | Code |
| 3317 | $password = $args[2]; |
| 3318 | |
| 3319 | if ( !$user = $this->login($username, $password) ) |
| 3320 | return $this->error; |
| 3321 | |
| 3322 | if ( !current_user_can( 'moderate_comments' ) ) |
| 3323 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
| 3324 | |
| 3325 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3326 | do_action( 'xmlrpc_call', 'wp.getCommentStatusList' ); |
| 3327 | |
| 3328 | return get_comment_statuses(); |
| 3329 | } |
| 3330 | |
| 3331 | /** |
| 3332 | * Retrieve comment count. |
| 3333 | * |
| 3334 | * @since 2.5.0 |
| 3335 | * |
| Line | Code |
| 3345 | $post_id = (int) $args[3]; |
| 3346 | |
| 3347 | if ( !$user = $this->login($username, $password) ) |
| 3348 | return $this->error; |
| 3349 | |
| 3350 | if ( !current_user_can( 'edit_posts' ) ) |
| 3351 | return new IXR_Error( 403, __( 'You are not allowed access to details about comments.' ) ); |
| 3352 | |
| 3353 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3354 | do_action( 'xmlrpc_call', 'wp.getCommentCount' ); |
| 3355 | |
| 3356 | $count = wp_count_comments( $post_id ); |
| 3357 | return array( |
| 3358 | 'approved' => $count->approved, |
| 3359 | 'awaiting_moderation' => $count->moderated, |
| 3360 | 'spam' => $count->spam, |
| 3361 | 'total_comments' => $count->total_comments |
| 3362 | ); |
| 3363 | } |
| Line | Code |
| 3378 | $password = $args[2]; |
| 3379 | |
| 3380 | if ( !$user = $this->login($username, $password) ) |
| 3381 | return $this->error; |
| 3382 | |
| 3383 | if ( !current_user_can( 'edit_posts' ) ) |
| 3384 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
| 3385 | |
| 3386 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3387 | do_action( 'xmlrpc_call', 'wp.getPostStatusList' ); |
| 3388 | |
| 3389 | return get_post_statuses(); |
| 3390 | } |
| 3391 | |
| 3392 | /** |
| 3393 | * Retrieve page statuses. |
| 3394 | * |
| 3395 | * @since 2.5.0 |
| 3396 | * |
| Line | Code |
| 3405 | $password = $args[2]; |
| 3406 | |
| 3407 | if ( !$user = $this->login($username, $password) ) |
| 3408 | return $this->error; |
| 3409 | |
| 3410 | if ( !current_user_can( 'edit_pages' ) ) |
| 3411 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
| 3412 | |
| 3413 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3414 | do_action( 'xmlrpc_call', 'wp.getPageStatusList' ); |
| 3415 | |
| 3416 | return get_page_statuses(); |
| 3417 | } |
| 3418 | |
| 3419 | /** |
| 3420 | * Retrieve page templates. |
| 3421 | * |
| 3422 | * @since 2.6.0 |
| 3423 | * |
| Line | Code |
| 3563 | $attachment_id = (int) $args[3]; |
| 3564 | |
| 3565 | if ( !$user = $this->login($username, $password) ) |
| 3566 | return $this->error; |
| 3567 | |
| 3568 | if ( !current_user_can( 'upload_files' ) ) |
| 3569 | return new IXR_Error( 403, __( 'You do not have permission to upload files.' ) ); |
| 3570 | |
| 3571 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3572 | do_action( 'xmlrpc_call', 'wp.getMediaItem' ); |
| 3573 | |
| 3574 | if ( ! $attachment = get_post($attachment_id) ) |
| 3575 | return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); |
| 3576 | |
| 3577 | return $this->_prepare_media_item( $attachment ); |
| 3578 | } |
| 3579 | |
| 3580 | /** |
| 3581 | * Retrieves a collection of media library items (or attachments) |
| Line | Code |
| 3609 | $struct = isset( $args[3] ) ? $args[3] : array() ; |
| 3610 | |
| 3611 | if ( !$user = $this->login($username, $password) ) |
| 3612 | return $this->error; |
| 3613 | |
| 3614 | if ( !current_user_can( 'upload_files' ) ) |
| 3615 | return new IXR_Error( 401, __( 'You do not have permission to upload files.' ) ); |
| 3616 | |
| 3617 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3618 | do_action( 'xmlrpc_call', 'wp.getMediaLibrary' ); |
| 3619 | |
| 3620 | $parent_id = ( isset($struct['parent_id']) ) ? absint($struct['parent_id']) : '' ; |
| 3621 | $mime_type = ( isset($struct['mime_type']) ) ? $struct['mime_type'] : '' ; |
| 3622 | $offset = ( isset($struct['offset']) ) ? absint($struct['offset']) : 0 ; |
| 3623 | $number = ( isset($struct['number']) ) ? absint($struct['number']) : -1 ; |
| 3624 | |
| 3625 | $attachments = get_posts( array('post_type' => 'attachment', 'post_parent' => $parent_id, 'offset' => $offset, 'numberposts' => $number, 'post_mime_type' => $mime_type ) ); |
| 3626 | |
| 3627 | $attachments_struct = array(); |
| Line | Code |
| 3651 | $password = $args[2]; |
| 3652 | |
| 3653 | if ( !$user = $this->login( $username, $password ) ) |
| 3654 | return $this->error; |
| 3655 | |
| 3656 | if ( !current_user_can( 'edit_posts' ) ) |
| 3657 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
| 3658 | |
| 3659 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3660 | do_action( 'xmlrpc_call', 'wp.getPostFormats' ); |
| 3661 | |
| 3662 | $formats = get_post_format_strings(); |
| 3663 | |
| 3664 | # find out if they want a list of currently supports formats |
| 3665 | if ( isset( $args[3] ) && is_array( $args[3] ) ) { |
| 3666 | if ( $args[3]['show-supported'] ) { |
| 3667 | if ( current_theme_supports( 'post-formats' ) ) { |
| 3668 | $supported = get_theme_support( 'post-formats' ); |
| 3669 | |
| Line | Code |
| 3724 | * @param string $method The method name. |
| 3725 | */ |
| 3726 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostType' ); |
| 3727 | } |
| 3728 | |
| 3729 | if ( !$user = $this->login( $username, $password ) ) |
| 3730 | return $this->error; |
| 3731 | |
| 3732 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3733 | do_action( 'xmlrpc_call', 'wp.getPostType' ); |
| 3734 | |
| 3735 | if( ! post_type_exists( $post_type_name ) ) |
| 3736 | return new IXR_Error( 403, __( 'Invalid post type' ) ); |
| 3737 | |
| 3738 | $post_type = get_post_type_object( $post_type_name ); |
| 3739 | |
| 3740 | if( ! current_user_can( $post_type->cap->edit_posts ) ) |
| 3741 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post type.' ) ); |
| 3742 | |
| Line | Code |
| 3773 | } else { |
| 3774 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3775 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostTypes' ); |
| 3776 | } |
| 3777 | |
| 3778 | if ( ! $user = $this->login( $username, $password ) ) |
| 3779 | return $this->error; |
| 3780 | |
| 3781 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3782 | do_action( 'xmlrpc_call', 'wp.getPostTypes' ); |
| 3783 | |
| 3784 | $post_types = get_post_types( $filter, 'objects' ); |
| 3785 | |
| 3786 | $struct = array(); |
| 3787 | |
| 3788 | foreach( $post_types as $post_type ) { |
| 3789 | if( ! current_user_can( $post_type->cap->edit_posts ) ) |
| 3790 | continue; |
| 3791 | |
| Line | Code |
| 3837 | * @param string $method The method name. |
| 3838 | */ |
| 3839 | $fields = apply_filters( 'xmlrpc_default_revision_fields', array( 'post_date', 'post_date_gmt' ), 'wp.getRevisions' ); |
| 3840 | } |
| 3841 | |
| 3842 | if ( ! $user = $this->login( $username, $password ) ) |
| 3843 | return $this->error; |
| 3844 | |
| 3845 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3846 | do_action( 'xmlrpc_call', 'wp.getRevisions' ); |
| 3847 | |
| 3848 | if ( ! $post = get_post( $post_id ) ) |
| 3849 | return new IXR_Error( 404, __( 'Invalid post ID' ) ); |
| 3850 | |
| 3851 | if ( ! current_user_can( 'edit_post', $post_id ) ) |
| 3852 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
| 3853 | |
| 3854 | // Check if revisions are enabled. |
| 3855 | if ( ! wp_revisions_enabled( $post ) ) |
| Line | Code |
| 3899 | $blog_id = (int) $args[0]; |
| 3900 | $username = $args[1]; |
| 3901 | $password = $args[2]; |
| 3902 | $revision_id = (int) $args[3]; |
| 3903 | |
| 3904 | if ( ! $user = $this->login( $username, $password ) ) |
| 3905 | return $this->error; |
| 3906 | |
| 3907 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3908 | do_action( 'xmlrpc_call', 'wp.restoreRevision' ); |
| 3909 | |
| 3910 | if ( ! $revision = wp_get_post_revision( $revision_id ) ) |
| 3911 | return new IXR_Error( 404, __( 'Invalid post ID' ) ); |
| 3912 | |
| 3913 | if ( wp_is_post_autosave( $revision ) ) |
| 3914 | return new IXR_Error( 404, __( 'Invalid post ID' ) ); |
| 3915 | |
| 3916 | if ( ! $post = get_post( $revision->post_parent ) ) |
| 3917 | return new IXR_Error( 404, __( 'Invalid post ID' ) ); |
| Line | Code |
| 3949 | $this->escape($args); |
| 3950 | |
| 3951 | $username = $args[1]; |
| 3952 | $password = $args[2]; |
| 3953 | |
| 3954 | if ( !$user = $this->login($username, $password) ) |
| 3955 | return $this->error; |
| 3956 | |
| 3957 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3958 | do_action( 'xmlrpc_call', 'blogger.getUsersBlogs' ); |
| 3959 | |
| 3960 | $is_admin = current_user_can('manage_options'); |
| 3961 | |
| 3962 | $struct = array( |
| 3963 | 'isAdmin' => $is_admin, |
| 3964 | 'url' => get_option('home') . '/', |
| 3965 | 'blogid' => '1', |
| 3966 | 'blogName' => get_option('blogname'), |
| 3967 | 'xmlrpc' => site_url( 'xmlrpc.php', 'rpc' ), |
| Line | Code |
| 4017 | $password = $args[2]; |
| 4018 | |
| 4019 | if ( !$user = $this->login($username, $password) ) |
| 4020 | return $this->error; |
| 4021 | |
| 4022 | if ( !current_user_can( 'edit_posts' ) ) |
| 4023 | return new IXR_Error( 401, __( 'Sorry, you do not have access to user data on this site.' ) ); |
| 4024 | |
| 4025 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4026 | do_action( 'xmlrpc_call', 'blogger.getUserInfo' ); |
| 4027 | |
| 4028 | $struct = array( |
| 4029 | 'nickname' => $user->nickname, |
| 4030 | 'userid' => $user->ID, |
| 4031 | 'url' => $user->user_url, |
| 4032 | 'lastname' => $user->last_name, |
| 4033 | 'firstname' => $user->first_name |
| 4034 | ); |
| 4035 | |
| Line | Code |
| 4057 | |
| 4058 | $post_data = get_post($post_ID, ARRAY_A); |
| 4059 | if ( ! $post_data ) |
| 4060 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4061 | |
| 4062 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
| 4063 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); |
| 4064 | |
| 4065 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4066 | do_action( 'xmlrpc_call', 'blogger.getPost' ); |
| 4067 | |
| 4068 | $categories = implode(',', wp_get_post_categories($post_ID)); |
| 4069 | |
| 4070 | $content = '<title>'.wp_unslash($post_data['post_title']).'</title>'; |
| 4071 | $content .= '<category>'.$categories.'</category>'; |
| 4072 | $content .= wp_unslash($post_data['post_content']); |
| 4073 | |
| 4074 | $struct = array( |
| 4075 | 'userid' => $post_data['post_author'], |
| Line | Code |
| 4103 | $query = array(); |
| 4104 | |
| 4105 | if ( !$user = $this->login($username, $password) ) |
| 4106 | return $this->error; |
| 4107 | |
| 4108 | if ( ! current_user_can( 'edit_posts' ) ) |
| 4109 | return new IXR_Error( 401, __( 'Sorry, you cannot edit posts on this site.' ) ); |
| 4110 | |
| 4111 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4112 | do_action( 'xmlrpc_call', 'blogger.getRecentPosts' ); |
| 4113 | |
| 4114 | $posts_list = wp_get_recent_posts( $query ); |
| 4115 | |
| 4116 | if ( !$posts_list ) { |
| 4117 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
| 4118 | return $this->error; |
| 4119 | } |
| 4120 | |
| 4121 | foreach ($posts_list as $entry) { |
| Line | Code |
| 4182 | $username = $args[2]; |
| 4183 | $password = $args[3]; |
| 4184 | $content = $args[4]; |
| 4185 | $publish = $args[5]; |
| 4186 | |
| 4187 | if ( !$user = $this->login($username, $password) ) |
| 4188 | return $this->error; |
| 4189 | |
| 4190 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4191 | do_action( 'xmlrpc_call', 'blogger.newPost' ); |
| 4192 | |
| 4193 | $cap = ($publish) ? 'publish_posts' : 'edit_posts'; |
| 4194 | if ( ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) || !current_user_can($cap) ) |
| 4195 | return new IXR_Error(401, __('Sorry, you are not allowed to post on this site.')); |
| 4196 | |
| 4197 | $post_status = ($publish) ? 'publish' : 'draft'; |
| 4198 | |
| 4199 | $post_author = $user->ID; |
| 4200 | |
| Line | Code |
| 4246 | $password = $args[3]; |
| 4247 | $content = $args[4]; |
| 4248 | $publish = $args[5]; |
| 4249 | |
| 4250 | if ( ! $user = $this->login( $username, $password ) ) { |
| 4251 | return $this->error; |
| 4252 | } |
| 4253 | |
| 4254 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4255 | do_action( 'xmlrpc_call', 'blogger.editPost' ); |
| 4256 | |
| 4257 | $actual_post = get_post( $post_ID, ARRAY_A ); |
| 4258 | |
| 4259 | if ( ! $actual_post || $actual_post['post_type'] != 'post' ) { |
| 4260 | return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); |
| 4261 | } |
| 4262 | |
| 4263 | $this->escape($actual_post); |
| 4264 | |
| Line | Code |
| 4311 | $post_ID = (int) $args[1]; |
| 4312 | $username = $args[2]; |
| 4313 | $password = $args[3]; |
| 4314 | $publish = $args[4]; |
| 4315 | |
| 4316 | if ( !$user = $this->login($username, $password) ) |
| 4317 | return $this->error; |
| 4318 | |
| 4319 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4320 | do_action( 'xmlrpc_call', 'blogger.deletePost' ); |
| 4321 | |
| 4322 | $actual_post = get_post($post_ID,ARRAY_A); |
| 4323 | |
| 4324 | if ( !$actual_post || $actual_post['post_type'] != 'post' ) |
| 4325 | return new IXR_Error(404, __('Sorry, no such post.')); |
| 4326 | |
| 4327 | if ( !current_user_can('delete_post', $post_ID) ) |
| 4328 | return new IXR_Error(401, __('Sorry, you do not have the right to delete this post.')); |
| 4329 | |
| Line | Code |
| 4391 | $username = $args[1]; |
| 4392 | $password = $args[2]; |
| 4393 | $content_struct = $args[3]; |
| 4394 | $publish = isset( $args[4] ) ? $args[4] : 0; |
| 4395 | |
| 4396 | if ( !$user = $this->login($username, $password) ) |
| 4397 | return $this->error; |
| 4398 | |
| 4399 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4400 | do_action( 'xmlrpc_call', 'metaWeblog.newPost' ); |
| 4401 | |
| 4402 | $page_template = ''; |
| 4403 | if ( !empty( $content_struct['post_type'] ) ) { |
| 4404 | if ( $content_struct['post_type'] == 'page' ) { |
| 4405 | if ( $publish ) |
| 4406 | $cap = 'publish_pages'; |
| 4407 | elseif ( isset( $content_struct['page_status'] ) && 'publish' == $content_struct['page_status'] ) |
| 4408 | $cap = 'publish_pages'; |
| 4409 | else |
| Line | Code |
| 4719 | $username = $args[1]; |
| 4720 | $password = $args[2]; |
| 4721 | $content_struct = $args[3]; |
| 4722 | $publish = isset( $args[4] ) ? $args[4] : 0; |
| 4723 | |
| 4724 | if ( ! $user = $this->login($username, $password) ) |
| 4725 | return $this->error; |
| 4726 | |
| 4727 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4728 | do_action( 'xmlrpc_call', 'metaWeblog.editPost' ); |
| 4729 | |
| 4730 | $postdata = get_post( $post_ID, ARRAY_A ); |
| 4731 | |
| 4732 | // If there is no post data for the give post id, stop |
| 4733 | // now and return an error. Other wise a new post will be |
| 4734 | // created (which was the old behavior). |
| 4735 | if ( ! $postdata || empty( $postdata[ 'ID' ] ) ) |
| 4736 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4737 | |
| Line | Code |
| 5011 | |
| 5012 | $postdata = get_post($post_ID, ARRAY_A); |
| 5013 | if ( ! $postdata ) |
| 5014 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 5015 | |
| 5016 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
| 5017 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); |
| 5018 | |
| 5019 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5020 | do_action( 'xmlrpc_call', 'metaWeblog.getPost' ); |
| 5021 | |
| 5022 | if ($postdata['post_date'] != '') { |
| 5023 | $post_date = $this->_convert_date( $postdata['post_date'] ); |
| 5024 | $post_date_gmt = $this->_convert_date_gmt( $postdata['post_date_gmt'], $postdata['post_date'] ); |
| 5025 | $post_modified = $this->_convert_date( $postdata['post_modified'] ); |
| 5026 | $post_modified_gmt = $this->_convert_date_gmt( $postdata['post_modified_gmt'], $postdata['post_modified'] ); |
| 5027 | |
| 5028 | $categories = array(); |
| 5029 | $catids = wp_get_post_categories($post_ID); |
| Line | Code |
| 5136 | $query = array(); |
| 5137 | |
| 5138 | if ( !$user = $this->login($username, $password) ) |
| 5139 | return $this->error; |
| 5140 | |
| 5141 | if ( ! current_user_can( 'edit_posts' ) ) |
| 5142 | return new IXR_Error( 401, __( 'Sorry, you cannot edit posts on this site.' ) ); |
| 5143 | |
| 5144 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5145 | do_action( 'xmlrpc_call', 'metaWeblog.getRecentPosts' ); |
| 5146 | |
| 5147 | $posts_list = wp_get_recent_posts( $query ); |
| 5148 | |
| 5149 | if ( !$posts_list ) |
| 5150 | return array(); |
| 5151 | |
| 5152 | $struct = array(); |
| 5153 | foreach ($posts_list as $entry) { |
| 5154 | if ( !current_user_can( 'edit_post', $entry['ID'] ) ) |
| Line | Code |
| 5252 | $password = $args[2]; |
| 5253 | |
| 5254 | if ( !$user = $this->login($username, $password) ) |
| 5255 | return $this->error; |
| 5256 | |
| 5257 | if ( !current_user_can( 'edit_posts' ) ) |
| 5258 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
| 5259 | |
| 5260 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5261 | do_action( 'xmlrpc_call', 'metaWeblog.getCategories' ); |
| 5262 | |
| 5263 | $categories_struct = array(); |
| 5264 | |
| 5265 | if ( $cats = get_categories(array('get' => 'all')) ) { |
| 5266 | foreach ( $cats as $cat ) { |
| 5267 | $struct['categoryId'] = $cat->term_id; |
| 5268 | $struct['parentId'] = $cat->parent; |
| 5269 | $struct['description'] = $cat->name; |
| 5270 | $struct['categoryDescription'] = $cat->description; |
| Line | Code |
| 5301 | |
| 5302 | $name = sanitize_file_name( $data['name'] ); |
| 5303 | $type = $data['type']; |
| 5304 | $bits = $data['bits']; |
| 5305 | |
| 5306 | if ( !$user = $this->login($username, $password) ) |
| 5307 | return $this->error; |
| 5308 | |
| 5309 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5310 | do_action( 'xmlrpc_call', 'metaWeblog.newMediaObject' ); |
| 5311 | |
| 5312 | if ( !current_user_can('upload_files') ) { |
| 5313 | $this->error = new IXR_Error( 401, __( 'You do not have permission to upload files.' ) ); |
| 5314 | return $this->error; |
| 5315 | } |
| 5316 | |
| 5317 | /** |
| 5318 | * Filter whether to preempt the XML-RPC media upload. |
| 5319 | * |
| Line | Code |
| 5415 | if ( isset( $args[3] ) ) |
| 5416 | $query = array( 'numberposts' => absint( $args[3] ) ); |
| 5417 | else |
| 5418 | $query = array(); |
| 5419 | |
| 5420 | if ( !$user = $this->login($username, $password) ) |
| 5421 | return $this->error; |
| 5422 | |
| 5423 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5424 | do_action( 'xmlrpc_call', 'mt.getRecentPostTitles' ); |
| 5425 | |
| 5426 | $posts_list = wp_get_recent_posts( $query ); |
| 5427 | |
| 5428 | if ( !$posts_list ) { |
| 5429 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
| 5430 | return $this->error; |
| 5431 | } |
| 5432 | |
| 5433 | $struct = array(); |
| Line | Code |
| 5475 | $password = $args[2]; |
| 5476 | |
| 5477 | if ( !$user = $this->login($username, $password) ) |
| 5478 | return $this->error; |
| 5479 | |
| 5480 | if ( !current_user_can( 'edit_posts' ) ) |
| 5481 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
| 5482 | |
| 5483 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5484 | do_action( 'xmlrpc_call', 'mt.getCategoryList' ); |
| 5485 | |
| 5486 | $categories_struct = array(); |
| 5487 | |
| 5488 | if ( $cats = get_categories(array('hide_empty' => 0, 'hierarchical' => 0)) ) { |
| 5489 | foreach ( $cats as $cat ) { |
| 5490 | $struct['categoryId'] = $cat->term_id; |
| 5491 | $struct['categoryName'] = $cat->name; |
| 5492 | |
| 5493 | $categories_struct[] = $struct; |
| Line | Code |
| 5517 | return $this->error; |
| 5518 | |
| 5519 | if ( ! get_post( $post_ID ) ) |
| 5520 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 5521 | |
| 5522 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
| 5523 | return new IXR_Error( 401, __( 'Sorry, you can not edit this post.' ) ); |
| 5524 | |
| 5525 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5526 | do_action( 'xmlrpc_call', 'mt.getPostCategories' ); |
| 5527 | |
| 5528 | $categories = array(); |
| 5529 | $catids = wp_get_post_categories(intval($post_ID)); |
| 5530 | // first listed category will be the primary category |
| 5531 | $isPrimary = true; |
| 5532 | foreach ( $catids as $catid ) { |
| 5533 | $categories[] = array( |
| 5534 | 'categoryName' => get_cat_name($catid), |
| 5535 | 'categoryId' => (string) $catid, |
| Line | Code |
| 5556 | $post_ID = (int) $args[0]; |
| 5557 | $username = $args[1]; |
| 5558 | $password = $args[2]; |
| 5559 | $categories = $args[3]; |
| 5560 | |
| 5561 | if ( !$user = $this->login($username, $password) ) |
| 5562 | return $this->error; |
| 5563 | |
| 5564 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5565 | do_action( 'xmlrpc_call', 'mt.setPostCategories' ); |
| 5566 | |
| 5567 | if ( ! get_post( $post_ID ) ) |
| 5568 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 5569 | |
| 5570 | if ( !current_user_can('edit_post', $post_ID) ) |
| 5571 | return new IXR_Error(401, __('Sorry, you cannot edit this post.')); |
| 5572 | |
| 5573 | $catids = array(); |
| 5574 | foreach ( $categories as $cat ) { |
| Line | Code |
| 5585 | * |
| 5586 | * @since 1.5.0 |
| 5587 | * |
| 5588 | * @param array $args Method parameters. |
| 5589 | * @return array |
| 5590 | */ |
| 5591 | public function mt_supportedMethods($args) { |
| 5592 | |
| 5593 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5594 | do_action( 'xmlrpc_call', 'mt.supportedMethods' ); |
| 5595 | |
| 5596 | $supported_methods = array(); |
| 5597 | foreach ( $this->methods as $key => $value ) { |
| 5598 | $supported_methods[] = $key; |
| 5599 | } |
| 5600 | |
| 5601 | return $supported_methods; |
| 5602 | } |
| 5603 | |
| 5604 | /** |
| 5605 | * Retrieve an empty array because we don't support per-post text filters. |
| 5606 | * |
| 5607 | * @since 1.5.0 |
| 5608 | * |
| 5609 | * @param array $args Method parameters. |
| 5610 | */ |
| 5611 | public function mt_supportedTextFilters($args) { |
| 5612 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5613 | do_action( 'xmlrpc_call', 'mt.supportedTextFilters' ); |
| 5614 | |
| 5615 | /** |
| 5616 | * Filter the MoveableType text filters list for XML-RPC. |
| 5617 | * |
| 5618 | * @since 2.2.0 |
| 5619 | * |
| 5620 | * @param array $filters An array of text filters. |
| 5621 | */ |
| 5622 | return apply_filters( 'xmlrpc_text_filters', array() ); |
| Line | Code |
| 5631 | * @return mixed |
| 5632 | */ |
| 5633 | public function mt_getTrackbackPings($args) { |
| 5634 | |
| 5635 | global $wpdb; |
| 5636 | |
| 5637 | $post_ID = intval($args); |
| 5638 | |
| 5639 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5640 | do_action( 'xmlrpc_call', 'mt.getTrackbackPings' ); |
| 5641 | |
| 5642 | $actual_post = get_post($post_ID, ARRAY_A); |
| 5643 | |
| 5644 | if ( !$actual_post ) |
| 5645 | return new IXR_Error(404, __('Sorry, no such post.')); |
| 5646 | |
| 5647 | $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) ); |
| 5648 | |
| 5649 | if ( !$comments ) |
| Line | Code |
| 5679 | |
| 5680 | $post_ID = (int) $args[0]; |
| 5681 | $username = $args[1]; |
| 5682 | $password = $args[2]; |
| 5683 | |
| 5684 | if ( !$user = $this->login($username, $password) ) |
| 5685 | return $this->error; |
| 5686 | |
| 5687 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5688 | do_action( 'xmlrpc_call', 'mt.publishPost' ); |
| 5689 | |
| 5690 | $postdata = get_post($post_ID, ARRAY_A); |
| 5691 | if ( ! $postdata ) |
| 5692 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 5693 | |
| 5694 | if ( !current_user_can('publish_posts') || !current_user_can('edit_post', $post_ID) ) |
| 5695 | return new IXR_Error(401, __('Sorry, you cannot publish this post.')); |
| 5696 | |
| 5697 | $postdata['post_status'] = 'publish'; |
| Line | Code |
| 5716 | * @since 1.5.0 |
| 5717 | * |
| 5718 | * @param array $args Method parameters. |
| 5719 | * @return array |
| 5720 | */ |
| 5721 | public function pingback_ping($args) { |
| 5722 | global $wpdb; |
| 5723 | |
| 5724 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5725 | do_action( 'xmlrpc_call', 'pingback.ping' ); |
| 5726 | |
| 5727 | $this->escape($args); |
| 5728 | |
| 5729 | $pagelinkedfrom = $args[0]; |
| 5730 | $pagelinkedto = $args[1]; |
| 5731 | |
| 5732 | $title = ''; |
| 5733 | |
| 5734 | $pagelinkedfrom = str_replace('&', '&', $pagelinkedfrom); |
| Line | Code |
| 5930 | * |
| 5931 | * @param array $args Method parameters. |
| 5932 | * @return array |
| 5933 | */ |
| 5934 | public function pingback_extensions_getPingbacks($args) { |
| 5935 | |
| 5936 | global $wpdb; |
| 5937 | |
| 5938 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5939 | do_action( 'xmlrpc_call', 'pingback.extensions.getPingbacks' ); |
| 5940 | |
| 5941 | $this->escape($args); |
| 5942 | |
| 5943 | $url = $args; |
| 5944 | |
| 5945 | $post_ID = url_to_postid($url); |
| 5946 | if ( !$post_ID ) { |
| 5947 | // We aren't sure that the resource is available and/or pingback enabled |
| 5948 | 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.' ) ); |