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 |
|---|---|
| 543 | * the method logic begins. |
| 544 | * |
| 545 | * All built-in XML-RPC methods use the action xmlrpc_call, with a parameter |
| 546 | * equal to the method's name, e.g., wp.getUsersBlogs, wp.newPost, etc. |
| 547 | * |
| 548 | * @since 2.5.0 |
| 549 | * |
| 550 | * @param method $name The method name. |
| 551 | */ |
| 552 | do_action( 'xmlrpc_call', 'wp.getUsersBlogs' ); |
| 553 | |
| 554 | $blogs = (array) get_blogs_of_user( $user->ID ); |
| 555 | $struct = array(); |
| 556 | |
| 557 | foreach ( $blogs as $blog ) { |
| 558 | // Don't include blogs that aren't hosted at this site |
| 559 | if ( $blog->site_id != get_current_site()->id ) |
| 560 | continue; |
| 561 | |
| Line | Code |
| 1125 | if ( isset( $content_struct['post_date_gmt'] ) && ! is_a( $content_struct['post_date_gmt'], 'IXR_Date' ) ) { |
| 1126 | if ( $content_struct['post_date_gmt'] == '0000-00-00 00:00:00' || isset( $content_struct['post_date'] ) ) { |
| 1127 | unset( $content_struct['post_date_gmt'] ); |
| 1128 | } else { |
| 1129 | $content_struct['post_date_gmt'] = $this->_convert_date( $content_struct['post_date_gmt'] ); |
| 1130 | } |
| 1131 | } |
| 1132 | |
| 1133 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1134 | do_action( 'xmlrpc_call', 'wp.newPost' ); |
| 1135 | |
| 1136 | unset( $content_struct['ID'] ); |
| 1137 | |
| 1138 | return $this->_insert_post( $user, $content_struct ); |
| 1139 | } |
| 1140 | |
| 1141 | /** |
| 1142 | * Helper method for filtering out elements from an array. |
| 1143 | * |
| Line | Code |
| 1419 | $username = $args[1]; |
| 1420 | $password = $args[2]; |
| 1421 | $post_id = (int) $args[3]; |
| 1422 | $content_struct = $args[4]; |
| 1423 | |
| 1424 | if ( ! $user = $this->login( $username, $password ) ) |
| 1425 | return $this->error; |
| 1426 | |
| 1427 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1428 | do_action( 'xmlrpc_call', 'wp.editPost' ); |
| 1429 | |
| 1430 | $post = get_post( $post_id, ARRAY_A ); |
| 1431 | |
| 1432 | if ( empty( $post['ID'] ) ) |
| 1433 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 1434 | |
| 1435 | if ( isset( $content_struct['if_not_modified_since'] ) ) { |
| 1436 | // If the post has been modified since the date provided, return an error. |
| 1437 | if ( mysql2date( 'U', $post['post_modified_gmt'] ) > $content_struct['if_not_modified_since']->getTimestamp() ) { |
| Line | Code |
| 1480 | |
| 1481 | $username = $args[1]; |
| 1482 | $password = $args[2]; |
| 1483 | $post_id = (int) $args[3]; |
| 1484 | |
| 1485 | if ( ! $user = $this->login( $username, $password ) ) |
| 1486 | return $this->error; |
| 1487 | |
| 1488 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1489 | do_action( 'xmlrpc_call', 'wp.deletePost' ); |
| 1490 | |
| 1491 | $post = get_post( $post_id, ARRAY_A ); |
| 1492 | if ( empty( $post['ID'] ) ) |
| 1493 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 1494 | |
| 1495 | if ( ! current_user_can( 'delete_post', $post_id ) ) |
| 1496 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) ); |
| 1497 | |
| 1498 | $result = wp_delete_post( $post_id ); |
| Line | Code |
| 1570 | * @param string $method Method name. |
| 1571 | */ |
| 1572 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPost' ); |
| 1573 | } |
| 1574 | |
| 1575 | if ( ! $user = $this->login( $username, $password ) ) |
| 1576 | return $this->error; |
| 1577 | |
| 1578 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1579 | do_action( 'xmlrpc_call', 'wp.getPost' ); |
| 1580 | |
| 1581 | $post = get_post( $post_id, ARRAY_A ); |
| 1582 | |
| 1583 | if ( empty( $post['ID'] ) ) |
| 1584 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 1585 | |
| 1586 | if ( ! current_user_can( 'edit_post', $post_id ) ) |
| 1587 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); |
| 1588 | |
| Line | Code |
| 1628 | } else { |
| 1629 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1630 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPosts' ); |
| 1631 | } |
| 1632 | |
| 1633 | if ( ! $user = $this->login( $username, $password ) ) |
| 1634 | return $this->error; |
| 1635 | |
| 1636 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1637 | do_action( 'xmlrpc_call', 'wp.getPosts' ); |
| 1638 | |
| 1639 | $query = array(); |
| 1640 | |
| 1641 | if ( isset( $filter['post_type'] ) ) { |
| 1642 | $post_type = get_post_type_object( $filter['post_type'] ); |
| 1643 | if ( ! ( (bool) $post_type ) ) |
| 1644 | return new IXR_Error( 403, __( 'The post type specified is not valid' ) ); |
| 1645 | } else { |
| 1646 | $post_type = get_post_type_object( 'post' ); |
| Line | Code |
| 1717 | |
| 1718 | $username = $args[1]; |
| 1719 | $password = $args[2]; |
| 1720 | $content_struct = $args[3]; |
| 1721 | |
| 1722 | if ( ! $user = $this->login( $username, $password ) ) |
| 1723 | return $this->error; |
| 1724 | |
| 1725 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1726 | do_action( 'xmlrpc_call', 'wp.newTerm' ); |
| 1727 | |
| 1728 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) |
| 1729 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
| 1730 | |
| 1731 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
| 1732 | |
| 1733 | if ( ! current_user_can( $taxonomy->cap->manage_terms ) ) |
| 1734 | return new IXR_Error( 401, __( 'You are not allowed to create terms in this taxonomy.' ) ); |
| 1735 | |
| Line | Code |
| 1805 | $username = $args[1]; |
| 1806 | $password = $args[2]; |
| 1807 | $term_id = (int) $args[3]; |
| 1808 | $content_struct = $args[4]; |
| 1809 | |
| 1810 | if ( ! $user = $this->login( $username, $password ) ) |
| 1811 | return $this->error; |
| 1812 | |
| 1813 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1814 | do_action( 'xmlrpc_call', 'wp.editTerm' ); |
| 1815 | |
| 1816 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) |
| 1817 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
| 1818 | |
| 1819 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
| 1820 | |
| 1821 | if ( ! current_user_can( $taxonomy->cap->edit_terms ) ) |
| 1822 | return new IXR_Error( 401, __( 'You are not allowed to edit terms in this taxonomy.' ) ); |
| 1823 | |
| Line | Code |
| 1897 | $username = $args[1]; |
| 1898 | $password = $args[2]; |
| 1899 | $taxonomy = $args[3]; |
| 1900 | $term_id = (int) $args[4]; |
| 1901 | |
| 1902 | if ( ! $user = $this->login( $username, $password ) ) |
| 1903 | return $this->error; |
| 1904 | |
| 1905 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1906 | do_action( 'xmlrpc_call', 'wp.deleteTerm' ); |
| 1907 | |
| 1908 | if ( ! taxonomy_exists( $taxonomy ) ) |
| 1909 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
| 1910 | |
| 1911 | $taxonomy = get_taxonomy( $taxonomy ); |
| 1912 | |
| 1913 | if ( ! current_user_can( $taxonomy->cap->delete_terms ) ) |
| 1914 | return new IXR_Error( 401, __( 'You are not allowed to delete terms in this taxonomy.' ) ); |
| 1915 | |
| Line | Code |
| 1964 | $username = $args[1]; |
| 1965 | $password = $args[2]; |
| 1966 | $taxonomy = $args[3]; |
| 1967 | $term_id = (int) $args[4]; |
| 1968 | |
| 1969 | if ( ! $user = $this->login( $username, $password ) ) |
| 1970 | return $this->error; |
| 1971 | |
| 1972 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1973 | do_action( 'xmlrpc_call', 'wp.getTerm' ); |
| 1974 | |
| 1975 | if ( ! taxonomy_exists( $taxonomy ) ) |
| 1976 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
| 1977 | |
| 1978 | $taxonomy = get_taxonomy( $taxonomy ); |
| 1979 | |
| 1980 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
| 1981 | return new IXR_Error( 401, __( 'You are not allowed to assign terms in this taxonomy.' ) ); |
| 1982 | |
| Line | Code |
| 2017 | $username = $args[1]; |
| 2018 | $password = $args[2]; |
| 2019 | $taxonomy = $args[3]; |
| 2020 | $filter = isset( $args[4] ) ? $args[4] : array(); |
| 2021 | |
| 2022 | if ( ! $user = $this->login( $username, $password ) ) |
| 2023 | return $this->error; |
| 2024 | |
| 2025 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2026 | do_action( 'xmlrpc_call', 'wp.getTerms' ); |
| 2027 | |
| 2028 | if ( ! taxonomy_exists( $taxonomy ) ) |
| 2029 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
| 2030 | |
| 2031 | $taxonomy = get_taxonomy( $taxonomy ); |
| 2032 | |
| 2033 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
| 2034 | return new IXR_Error( 401, __( 'You are not allowed to assign terms in this taxonomy.' ) ); |
| 2035 | |
| Line | Code |
| 2105 | * @param string $method The method name. |
| 2106 | */ |
| 2107 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomy' ); |
| 2108 | } |
| 2109 | |
| 2110 | if ( ! $user = $this->login( $username, $password ) ) |
| 2111 | return $this->error; |
| 2112 | |
| 2113 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2114 | do_action( 'xmlrpc_call', 'wp.getTaxonomy' ); |
| 2115 | |
| 2116 | if ( ! taxonomy_exists( $taxonomy ) ) |
| 2117 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
| 2118 | |
| 2119 | $taxonomy = get_taxonomy( $taxonomy ); |
| 2120 | |
| 2121 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
| 2122 | return new IXR_Error( 401, __( 'You are not allowed to assign terms in this taxonomy.' ) ); |
| 2123 | |
| Line | Code |
| 2151 | } else { |
| 2152 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2153 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomies' ); |
| 2154 | } |
| 2155 | |
| 2156 | if ( ! $user = $this->login( $username, $password ) ) |
| 2157 | return $this->error; |
| 2158 | |
| 2159 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2160 | do_action( 'xmlrpc_call', 'wp.getTaxonomies' ); |
| 2161 | |
| 2162 | $taxonomies = get_taxonomies( $filter, 'objects' ); |
| 2163 | |
| 2164 | // holds all the taxonomy data |
| 2165 | $struct = array(); |
| 2166 | |
| 2167 | foreach ( $taxonomies as $taxonomy ) { |
| 2168 | // capability check for post_types |
| 2169 | 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 |
| 2284 | } else { |
| 2285 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2286 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUsers' ); |
| 2287 | } |
| 2288 | |
| 2289 | if ( ! $user = $this->login( $username, $password ) ) |
| 2290 | return $this->error; |
| 2291 | |
| 2292 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2293 | do_action( 'xmlrpc_call', 'wp.getUsers' ); |
| 2294 | |
| 2295 | if ( ! current_user_can( 'list_users' ) ) |
| 2296 | return new IXR_Error( 401, __( 'Sorry, you cannot list users.' ) ); |
| 2297 | |
| 2298 | $query = array( 'fields' => 'all_with_meta' ); |
| 2299 | |
| 2300 | $query['number'] = ( isset( $filter['number'] ) ) ? absint( $filter['number'] ) : 50; |
| 2301 | $query['offset'] = ( isset( $filter['offset'] ) ) ? absint( $filter['offset'] ) : 0; |
| 2302 | |
| Line | Code |
| 2353 | } else { |
| 2354 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2355 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getProfile' ); |
| 2356 | } |
| 2357 | |
| 2358 | if ( ! $user = $this->login( $username, $password ) ) |
| 2359 | return $this->error; |
| 2360 | |
| 2361 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2362 | do_action( 'xmlrpc_call', 'wp.getProfile' ); |
| 2363 | |
| 2364 | if ( ! current_user_can( 'edit_user', $user->ID ) ) |
| 2365 | return new IXR_Error( 401, __( 'Sorry, you cannot edit your profile.' ) ); |
| 2366 | |
| 2367 | $user_data = get_userdata( $user->ID ); |
| 2368 | |
| 2369 | return $this->_prepare_user( $user_data, $fields ); |
| 2370 | } |
| 2371 | |
| Line | Code |
| 2396 | |
| 2397 | $username = $args[1]; |
| 2398 | $password = $args[2]; |
| 2399 | $content_struct = $args[3]; |
| 2400 | |
| 2401 | if ( ! $user = $this->login( $username, $password ) ) |
| 2402 | return $this->error; |
| 2403 | |
| 2404 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2405 | do_action( 'xmlrpc_call', 'wp.editProfile' ); |
| 2406 | |
| 2407 | if ( ! current_user_can( 'edit_user', $user->ID ) ) |
| 2408 | return new IXR_Error( 401, __( 'Sorry, you cannot edit your profile.' ) ); |
| 2409 | |
| 2410 | // holds data of the user |
| 2411 | $user_data = array(); |
| 2412 | $user_data['ID'] = $user->ID; |
| 2413 | |
| 2414 | // only set the user details if it was given |
| Line | Code |
| 2469 | |
| 2470 | $page = get_post($page_id); |
| 2471 | if ( ! $page ) |
| 2472 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 2473 | |
| 2474 | if ( !current_user_can( 'edit_page', $page_id ) ) |
| 2475 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this page.' ) ); |
| 2476 | |
| 2477 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2478 | do_action( 'xmlrpc_call', 'wp.getPage' ); |
| 2479 | |
| 2480 | // If we found the page then format the data. |
| 2481 | if ( $page->ID && ($page->post_type == 'page') ) { |
| 2482 | return $this->_prepare_page( $page ); |
| 2483 | } |
| 2484 | // If the page doesn't exist indicate that. |
| 2485 | else { |
| 2486 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
| 2487 | } |
| Line | Code |
| 2507 | $num_pages = isset($args[3]) ? (int) $args[3] : 10; |
| 2508 | |
| 2509 | if ( !$user = $this->login($username, $password) ) |
| 2510 | return $this->error; |
| 2511 | |
| 2512 | if ( !current_user_can( 'edit_pages' ) ) |
| 2513 | return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) ); |
| 2514 | |
| 2515 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2516 | do_action( 'xmlrpc_call', 'wp.getPages' ); |
| 2517 | |
| 2518 | $pages = get_posts( array('post_type' => 'page', 'post_status' => 'any', 'numberposts' => $num_pages) ); |
| 2519 | $num_pages = count($pages); |
| 2520 | |
| 2521 | // If we have pages, put together their info. |
| 2522 | if ( $num_pages >= 1 ) { |
| 2523 | $pages_struct = array(); |
| 2524 | |
| 2525 | foreach ($pages as $page) { |
| Line | Code |
| 2546 | $username = $this->escape($args[1]); |
| 2547 | $password = $this->escape($args[2]); |
| 2548 | $page = $args[3]; |
| 2549 | $publish = $args[4]; |
| 2550 | |
| 2551 | if ( !$user = $this->login($username, $password) ) |
| 2552 | return $this->error; |
| 2553 | |
| 2554 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2555 | do_action( 'xmlrpc_call', 'wp.newPage' ); |
| 2556 | |
| 2557 | // Mark this as content for a page. |
| 2558 | $args[3]["post_type"] = 'page'; |
| 2559 | |
| 2560 | // Let mw_newPost do all of the heavy lifting. |
| 2561 | return $this->mw_newPost( $args ); |
| 2562 | } |
| 2563 | |
| 2564 | /** |
| Line | Code |
| 2574 | |
| 2575 | $username = $args[1]; |
| 2576 | $password = $args[2]; |
| 2577 | $page_id = (int) $args[3]; |
| 2578 | |
| 2579 | if ( !$user = $this->login($username, $password) ) |
| 2580 | return $this->error; |
| 2581 | |
| 2582 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2583 | do_action( 'xmlrpc_call', 'wp.deletePage' ); |
| 2584 | |
| 2585 | // Get the current page based on the page_id and |
| 2586 | // make sure it is a page and not a post. |
| 2587 | $actual_page = get_post($page_id, ARRAY_A); |
| 2588 | if ( !$actual_page || ($actual_page['post_type'] != 'page') ) |
| 2589 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
| 2590 | |
| 2591 | // Make sure the user can delete pages. |
| 2592 | if ( !current_user_can('delete_page', $page_id) ) |
| Line | Code |
| 2624 | $username = $this->escape($args[2]); |
| 2625 | $password = $this->escape($args[3]); |
| 2626 | $content = $args[4]; |
| 2627 | $publish = $args[5]; |
| 2628 | |
| 2629 | if ( !$user = $this->login($username, $password) ) |
| 2630 | return $this->error; |
| 2631 | |
| 2632 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2633 | do_action( 'xmlrpc_call', 'wp.editPage' ); |
| 2634 | |
| 2635 | // Get the page data and make sure it is a page. |
| 2636 | $actual_page = get_post($page_id, ARRAY_A); |
| 2637 | if ( !$actual_page || ($actual_page['post_type'] != 'page') ) |
| 2638 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
| 2639 | |
| 2640 | // Make sure the user is allowed to edit pages. |
| 2641 | if ( !current_user_can('edit_page', $page_id) ) |
| 2642 | return new IXR_Error( 401, __( 'Sorry, you do not have the right to edit this page.' ) ); |
| Line | Code |
| 2674 | $password = $args[2]; |
| 2675 | |
| 2676 | if ( !$user = $this->login($username, $password) ) |
| 2677 | return $this->error; |
| 2678 | |
| 2679 | if ( !current_user_can( 'edit_pages' ) ) |
| 2680 | return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) ); |
| 2681 | |
| 2682 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2683 | do_action( 'xmlrpc_call', 'wp.getPageList' ); |
| 2684 | |
| 2685 | // Get list of pages ids and titles |
| 2686 | $page_list = $wpdb->get_results(" |
| 2687 | SELECT ID page_id, |
| 2688 | post_title page_title, |
| 2689 | post_parent page_parent_id, |
| 2690 | post_date_gmt, |
| 2691 | post_date, |
| 2692 | post_status |
| Line | Code |
| 2725 | $password = $args[2]; |
| 2726 | |
| 2727 | if ( !$user = $this->login($username, $password) ) |
| 2728 | return $this->error; |
| 2729 | |
| 2730 | if ( !current_user_can('edit_posts') ) |
| 2731 | return new IXR_Error( 401, __( 'Sorry, you cannot edit posts on this site.' ) ); |
| 2732 | |
| 2733 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2734 | do_action( 'xmlrpc_call', 'wp.getAuthors' ); |
| 2735 | |
| 2736 | $authors = array(); |
| 2737 | foreach ( get_users( array( 'fields' => array('ID','user_login','display_name') ) ) as $user ) { |
| 2738 | $authors[] = array( |
| 2739 | 'user_id' => $user->ID, |
| 2740 | 'user_login' => $user->user_login, |
| 2741 | 'display_name' => $user->display_name |
| 2742 | ); |
| 2743 | } |
| Line | Code |
| 2760 | $password = $args[2]; |
| 2761 | |
| 2762 | if ( !$user = $this->login($username, $password) ) |
| 2763 | return $this->error; |
| 2764 | |
| 2765 | if ( !current_user_can( 'edit_posts' ) ) |
| 2766 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view tags.' ) ); |
| 2767 | |
| 2768 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2769 | do_action( 'xmlrpc_call', 'wp.getKeywords' ); |
| 2770 | |
| 2771 | $tags = array(); |
| 2772 | |
| 2773 | if ( $all_tags = get_tags() ) { |
| 2774 | foreach( (array) $all_tags as $tag ) { |
| 2775 | $struct = array(); |
| 2776 | $struct['tag_id'] = $tag->term_id; |
| 2777 | $struct['name'] = $tag->name; |
| 2778 | $struct['count'] = $tag->count; |
| Line | Code |
| 2800 | |
| 2801 | $username = $args[1]; |
| 2802 | $password = $args[2]; |
| 2803 | $category = $args[3]; |
| 2804 | |
| 2805 | if ( !$user = $this->login($username, $password) ) |
| 2806 | return $this->error; |
| 2807 | |
| 2808 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2809 | do_action( 'xmlrpc_call', 'wp.newCategory' ); |
| 2810 | |
| 2811 | // Make sure the user is allowed to add a category. |
| 2812 | if ( !current_user_can('manage_categories') ) |
| 2813 | return new IXR_Error(401, __('Sorry, you do not have the right to add a category.')); |
| 2814 | |
| 2815 | // If no slug was provided make it empty so that |
| 2816 | // WordPress will generate one. |
| 2817 | if ( empty($category['slug']) ) |
| 2818 | $category['slug'] = ''; |
| Line | Code |
| 2869 | |
| 2870 | $username = $args[1]; |
| 2871 | $password = $args[2]; |
| 2872 | $category_id = (int) $args[3]; |
| 2873 | |
| 2874 | if ( !$user = $this->login($username, $password) ) |
| 2875 | return $this->error; |
| 2876 | |
| 2877 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2878 | do_action( 'xmlrpc_call', 'wp.deleteCategory' ); |
| 2879 | |
| 2880 | if ( !current_user_can('manage_categories') ) |
| 2881 | return new IXR_Error( 401, __( 'Sorry, you do not have the right to delete a category.' ) ); |
| 2882 | |
| 2883 | $status = wp_delete_term( $category_id, 'category' ); |
| 2884 | |
| 2885 | if ( true == $status ) { |
| 2886 | /** |
| 2887 | * Fires after a category has been successfully deleted via XML-RPC. |
| Line | Code |
| 2914 | $max_results = (int) $args[4]; |
| 2915 | |
| 2916 | if ( !$user = $this->login($username, $password) ) |
| 2917 | return $this->error; |
| 2918 | |
| 2919 | if ( !current_user_can( 'edit_posts' ) ) |
| 2920 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts to this site in order to view categories.' ) ); |
| 2921 | |
| 2922 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2923 | do_action( 'xmlrpc_call', 'wp.suggestCategories' ); |
| 2924 | |
| 2925 | $category_suggestions = array(); |
| 2926 | $args = array('get' => 'all', 'number' => $max_results, 'name__like' => $category); |
| 2927 | foreach ( (array) get_categories($args) as $cat ) { |
| 2928 | $category_suggestions[] = array( |
| 2929 | 'category_id' => $cat->term_id, |
| 2930 | 'category_name' => $cat->name |
| 2931 | ); |
| 2932 | } |
| Line | Code |
| 2950 | $comment_id = (int) $args[3]; |
| 2951 | |
| 2952 | if ( !$user = $this->login($username, $password) ) |
| 2953 | return $this->error; |
| 2954 | |
| 2955 | if ( !current_user_can( 'moderate_comments' ) ) |
| 2956 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
| 2957 | |
| 2958 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2959 | do_action( 'xmlrpc_call', 'wp.getComment' ); |
| 2960 | |
| 2961 | if ( ! $comment = get_comment($comment_id) ) |
| 2962 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 2963 | |
| 2964 | return $this->_prepare_comment( $comment ); |
| 2965 | } |
| 2966 | |
| 2967 | /** |
| 2968 | * Retrieve comments. |
| Line | Code |
| 2991 | $struct = isset( $args[3] ) ? $args[3] : array(); |
| 2992 | |
| 2993 | if ( !$user = $this->login($username, $password) ) |
| 2994 | return $this->error; |
| 2995 | |
| 2996 | if ( !current_user_can( 'moderate_comments' ) ) |
| 2997 | return new IXR_Error( 401, __( 'Sorry, you cannot edit comments.' ) ); |
| 2998 | |
| 2999 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3000 | do_action( 'xmlrpc_call', 'wp.getComments' ); |
| 3001 | |
| 3002 | if ( isset($struct['status']) ) |
| 3003 | $status = $struct['status']; |
| 3004 | else |
| 3005 | $status = ''; |
| 3006 | |
| 3007 | $post_id = ''; |
| 3008 | if ( isset($struct['post_id']) ) |
| 3009 | $post_id = absint($struct['post_id']); |
| Line | Code |
| 3057 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
| 3058 | |
| 3059 | if ( ! get_comment($comment_ID) ) |
| 3060 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 3061 | |
| 3062 | if ( !current_user_can( 'edit_comment', $comment_ID ) ) |
| 3063 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
| 3064 | |
| 3065 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3066 | do_action( 'xmlrpc_call', 'wp.deleteComment' ); |
| 3067 | |
| 3068 | $status = wp_delete_comment( $comment_ID ); |
| 3069 | |
| 3070 | if ( true == $status ) { |
| 3071 | /** |
| 3072 | * Fires after a comment has been successfully deleted via XML-RPC. |
| 3073 | * |
| 3074 | * @since 3.4.0 |
| 3075 | * |
| Line | Code |
| 3121 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
| 3122 | |
| 3123 | if ( ! get_comment($comment_ID) ) |
| 3124 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 3125 | |
| 3126 | if ( !current_user_can( 'edit_comment', $comment_ID ) ) |
| 3127 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
| 3128 | |
| 3129 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3130 | do_action( 'xmlrpc_call', 'wp.editComment' ); |
| 3131 | |
| 3132 | if ( isset($content_struct['status']) ) { |
| 3133 | $statuses = get_comment_statuses(); |
| 3134 | $statuses = array_keys($statuses); |
| 3135 | |
| 3136 | if ( ! in_array($content_struct['status'], $statuses) ) |
| 3137 | return new IXR_Error( 401, __( 'Invalid comment status.' ) ); |
| 3138 | $comment_approved = $content_struct['status']; |
| 3139 | } |
| Line | Code |
| 3260 | return new IXR_Error( 403, __( 'A valid email address is required' ) ); |
| 3261 | } |
| 3262 | } |
| 3263 | |
| 3264 | $comment['comment_parent'] = isset($content_struct['comment_parent']) ? absint($content_struct['comment_parent']) : 0; |
| 3265 | |
| 3266 | $comment['comment_content'] = isset($content_struct['content']) ? $content_struct['content'] : null; |
| 3267 | |
| 3268 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3269 | do_action( 'xmlrpc_call', 'wp.newComment' ); |
| 3270 | |
| 3271 | $comment_ID = wp_new_comment( $comment ); |
| 3272 | |
| 3273 | /** |
| 3274 | * Fires after a new comment has been successfully created via XML-RPC. |
| 3275 | * |
| 3276 | * @since 3.4.0 |
| 3277 | * |
| 3278 | * @param int $comment_ID ID of the new comment. |
| Line | Code |
| 3298 | $password = $args[2]; |
| 3299 | |
| 3300 | if ( !$user = $this->login($username, $password) ) |
| 3301 | return $this->error; |
| 3302 | |
| 3303 | if ( !current_user_can( 'moderate_comments' ) ) |
| 3304 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
| 3305 | |
| 3306 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3307 | do_action( 'xmlrpc_call', 'wp.getCommentStatusList' ); |
| 3308 | |
| 3309 | return get_comment_statuses(); |
| 3310 | } |
| 3311 | |
| 3312 | /** |
| 3313 | * Retrieve comment count. |
| 3314 | * |
| 3315 | * @since 2.5.0 |
| 3316 | * |
| Line | Code |
| 3325 | $post_id = (int) $args[3]; |
| 3326 | |
| 3327 | if ( !$user = $this->login($username, $password) ) |
| 3328 | return $this->error; |
| 3329 | |
| 3330 | if ( !current_user_can( 'edit_posts' ) ) |
| 3331 | return new IXR_Error( 403, __( 'You are not allowed access to details about comments.' ) ); |
| 3332 | |
| 3333 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3334 | do_action( 'xmlrpc_call', 'wp.getCommentCount' ); |
| 3335 | |
| 3336 | $count = wp_count_comments( $post_id ); |
| 3337 | return array( |
| 3338 | 'approved' => $count->approved, |
| 3339 | 'awaiting_moderation' => $count->moderated, |
| 3340 | 'spam' => $count->spam, |
| 3341 | 'total_comments' => $count->total_comments |
| 3342 | ); |
| 3343 | } |
| Line | Code |
| 3357 | $password = $args[2]; |
| 3358 | |
| 3359 | if ( !$user = $this->login($username, $password) ) |
| 3360 | return $this->error; |
| 3361 | |
| 3362 | if ( !current_user_can( 'edit_posts' ) ) |
| 3363 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
| 3364 | |
| 3365 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3366 | do_action( 'xmlrpc_call', 'wp.getPostStatusList' ); |
| 3367 | |
| 3368 | return get_post_statuses(); |
| 3369 | } |
| 3370 | |
| 3371 | /** |
| 3372 | * Retrieve page statuses. |
| 3373 | * |
| 3374 | * @since 2.5.0 |
| 3375 | * |
| Line | Code |
| 3383 | $password = $args[2]; |
| 3384 | |
| 3385 | if ( !$user = $this->login($username, $password) ) |
| 3386 | return $this->error; |
| 3387 | |
| 3388 | if ( !current_user_can( 'edit_pages' ) ) |
| 3389 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
| 3390 | |
| 3391 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3392 | do_action( 'xmlrpc_call', 'wp.getPageStatusList' ); |
| 3393 | |
| 3394 | return get_page_statuses(); |
| 3395 | } |
| 3396 | |
| 3397 | /** |
| 3398 | * Retrieve page templates. |
| 3399 | * |
| 3400 | * @since 2.6.0 |
| 3401 | * |
| Line | Code |
| 3538 | $attachment_id = (int) $args[3]; |
| 3539 | |
| 3540 | if ( !$user = $this->login($username, $password) ) |
| 3541 | return $this->error; |
| 3542 | |
| 3543 | if ( !current_user_can( 'upload_files' ) ) |
| 3544 | return new IXR_Error( 403, __( 'You do not have permission to upload files.' ) ); |
| 3545 | |
| 3546 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3547 | do_action( 'xmlrpc_call', 'wp.getMediaItem' ); |
| 3548 | |
| 3549 | if ( ! $attachment = get_post($attachment_id) ) |
| 3550 | return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); |
| 3551 | |
| 3552 | return $this->_prepare_media_item( $attachment ); |
| 3553 | } |
| 3554 | |
| 3555 | /** |
| 3556 | * Retrieves a collection of media library items (or attachments) |
| Line | Code |
| 3583 | $struct = isset( $args[3] ) ? $args[3] : array() ; |
| 3584 | |
| 3585 | if ( !$user = $this->login($username, $password) ) |
| 3586 | return $this->error; |
| 3587 | |
| 3588 | if ( !current_user_can( 'upload_files' ) ) |
| 3589 | return new IXR_Error( 401, __( 'You do not have permission to upload files.' ) ); |
| 3590 | |
| 3591 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3592 | do_action( 'xmlrpc_call', 'wp.getMediaLibrary' ); |
| 3593 | |
| 3594 | $parent_id = ( isset($struct['parent_id']) ) ? absint($struct['parent_id']) : '' ; |
| 3595 | $mime_type = ( isset($struct['mime_type']) ) ? $struct['mime_type'] : '' ; |
| 3596 | $offset = ( isset($struct['offset']) ) ? absint($struct['offset']) : 0 ; |
| 3597 | $number = ( isset($struct['number']) ) ? absint($struct['number']) : -1 ; |
| 3598 | |
| 3599 | $attachments = get_posts( array('post_type' => 'attachment', 'post_parent' => $parent_id, 'offset' => $offset, 'numberposts' => $number, 'post_mime_type' => $mime_type ) ); |
| 3600 | |
| 3601 | $attachments_struct = array(); |
| Line | Code |
| 3624 | $password = $args[2]; |
| 3625 | |
| 3626 | if ( !$user = $this->login( $username, $password ) ) |
| 3627 | return $this->error; |
| 3628 | |
| 3629 | if ( !current_user_can( 'edit_posts' ) ) |
| 3630 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
| 3631 | |
| 3632 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3633 | do_action( 'xmlrpc_call', 'wp.getPostFormats' ); |
| 3634 | |
| 3635 | $formats = get_post_format_strings(); |
| 3636 | |
| 3637 | # find out if they want a list of currently supports formats |
| 3638 | if ( isset( $args[3] ) && is_array( $args[3] ) ) { |
| 3639 | if ( $args[3]['show-supported'] ) { |
| 3640 | if ( current_theme_supports( 'post-formats' ) ) { |
| 3641 | $supported = get_theme_support( 'post-formats' ); |
| 3642 | |
| Line | Code |
| 3697 | * @param string $method The method name. |
| 3698 | */ |
| 3699 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostType' ); |
| 3700 | } |
| 3701 | |
| 3702 | if ( !$user = $this->login( $username, $password ) ) |
| 3703 | return $this->error; |
| 3704 | |
| 3705 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3706 | do_action( 'xmlrpc_call', 'wp.getPostType' ); |
| 3707 | |
| 3708 | if( ! post_type_exists( $post_type_name ) ) |
| 3709 | return new IXR_Error( 403, __( 'Invalid post type' ) ); |
| 3710 | |
| 3711 | $post_type = get_post_type_object( $post_type_name ); |
| 3712 | |
| 3713 | if( ! current_user_can( $post_type->cap->edit_posts ) ) |
| 3714 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post type.' ) ); |
| 3715 | |
| 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 |
| 3808 | * @param string $method The method name. |
| 3809 | */ |
| 3810 | $fields = apply_filters( 'xmlrpc_default_revision_fields', array( 'post_date', 'post_date_gmt' ), 'wp.getRevisions' ); |
| 3811 | } |
| 3812 | |
| 3813 | if ( ! $user = $this->login( $username, $password ) ) |
| 3814 | return $this->error; |
| 3815 | |
| 3816 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3817 | do_action( 'xmlrpc_call', 'wp.getRevisions' ); |
| 3818 | |
| 3819 | if ( ! $post = get_post( $post_id ) ) |
| 3820 | return new IXR_Error( 404, __( 'Invalid post ID' ) ); |
| 3821 | |
| 3822 | if ( ! current_user_can( 'edit_post', $post_id ) ) |
| 3823 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
| 3824 | |
| 3825 | // Check if revisions are enabled. |
| 3826 | if ( ! wp_revisions_enabled( $post ) ) |
| Line | Code |
| 3869 | |
| 3870 | $username = $args[1]; |
| 3871 | $password = $args[2]; |
| 3872 | $revision_id = (int) $args[3]; |
| 3873 | |
| 3874 | if ( ! $user = $this->login( $username, $password ) ) |
| 3875 | return $this->error; |
| 3876 | |
| 3877 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3878 | do_action( 'xmlrpc_call', 'wp.restoreRevision' ); |
| 3879 | |
| 3880 | if ( ! $revision = wp_get_post_revision( $revision_id ) ) |
| 3881 | return new IXR_Error( 404, __( 'Invalid post ID' ) ); |
| 3882 | |
| 3883 | if ( wp_is_post_autosave( $revision ) ) |
| 3884 | return new IXR_Error( 404, __( 'Invalid post ID' ) ); |
| 3885 | |
| 3886 | if ( ! $post = get_post( $revision->post_parent ) ) |
| 3887 | return new IXR_Error( 404, __( 'Invalid post ID' ) ); |
| Line | Code |
| 3919 | $this->escape($args); |
| 3920 | |
| 3921 | $username = $args[1]; |
| 3922 | $password = $args[2]; |
| 3923 | |
| 3924 | if ( !$user = $this->login($username, $password) ) |
| 3925 | return $this->error; |
| 3926 | |
| 3927 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3928 | do_action( 'xmlrpc_call', 'blogger.getUsersBlogs' ); |
| 3929 | |
| 3930 | $is_admin = current_user_can('manage_options'); |
| 3931 | |
| 3932 | $struct = array( |
| 3933 | 'isAdmin' => $is_admin, |
| 3934 | 'url' => get_option('home') . '/', |
| 3935 | 'blogid' => '1', |
| 3936 | 'blogName' => get_option('blogname'), |
| 3937 | '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 |
| 4074 | $query = array(); |
| 4075 | |
| 4076 | if ( !$user = $this->login($username, $password) ) |
| 4077 | return $this->error; |
| 4078 | |
| 4079 | if ( ! current_user_can( 'edit_posts' ) ) |
| 4080 | return new IXR_Error( 401, __( 'Sorry, you cannot edit posts on this site.' ) ); |
| 4081 | |
| 4082 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4083 | do_action( 'xmlrpc_call', 'blogger.getRecentPosts' ); |
| 4084 | |
| 4085 | $posts_list = wp_get_recent_posts( $query ); |
| 4086 | |
| 4087 | if ( !$posts_list ) { |
| 4088 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
| 4089 | return $this->error; |
| 4090 | } |
| 4091 | |
| 4092 | $recent_posts = array(); |
| Line | Code |
| 4149 | $username = $args[2]; |
| 4150 | $password = $args[3]; |
| 4151 | $content = $args[4]; |
| 4152 | $publish = $args[5]; |
| 4153 | |
| 4154 | if ( !$user = $this->login($username, $password) ) |
| 4155 | return $this->error; |
| 4156 | |
| 4157 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4158 | do_action( 'xmlrpc_call', 'blogger.newPost' ); |
| 4159 | |
| 4160 | $cap = ($publish) ? 'publish_posts' : 'edit_posts'; |
| 4161 | if ( ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) || !current_user_can($cap) ) |
| 4162 | return new IXR_Error(401, __('Sorry, you are not allowed to post on this site.')); |
| 4163 | |
| 4164 | $post_status = ($publish) ? 'publish' : 'draft'; |
| 4165 | |
| 4166 | $post_author = $user->ID; |
| 4167 | |
| Line | Code |
| 4213 | $password = $args[3]; |
| 4214 | $content = $args[4]; |
| 4215 | $publish = $args[5]; |
| 4216 | |
| 4217 | if ( ! $user = $this->login( $username, $password ) ) { |
| 4218 | return $this->error; |
| 4219 | } |
| 4220 | |
| 4221 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4222 | do_action( 'xmlrpc_call', 'blogger.editPost' ); |
| 4223 | |
| 4224 | $actual_post = get_post( $post_ID, ARRAY_A ); |
| 4225 | |
| 4226 | if ( ! $actual_post || $actual_post['post_type'] != 'post' ) { |
| 4227 | return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); |
| 4228 | } |
| 4229 | |
| 4230 | $this->escape($actual_post); |
| 4231 | |
| Line | Code |
| 4278 | $post_ID = (int) $args[1]; |
| 4279 | $username = $args[2]; |
| 4280 | $password = $args[3]; |
| 4281 | $publish = $args[4]; |
| 4282 | |
| 4283 | if ( !$user = $this->login($username, $password) ) |
| 4284 | return $this->error; |
| 4285 | |
| 4286 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4287 | do_action( 'xmlrpc_call', 'blogger.deletePost' ); |
| 4288 | |
| 4289 | $actual_post = get_post($post_ID,ARRAY_A); |
| 4290 | |
| 4291 | if ( !$actual_post || $actual_post['post_type'] != 'post' ) |
| 4292 | return new IXR_Error(404, __('Sorry, no such post.')); |
| 4293 | |
| 4294 | if ( !current_user_can('delete_post', $post_ID) ) |
| 4295 | return new IXR_Error(401, __('Sorry, you do not have the right to delete this post.')); |
| 4296 | |
| Line | Code |
| 4357 | $username = $args[1]; |
| 4358 | $password = $args[2]; |
| 4359 | $content_struct = $args[3]; |
| 4360 | $publish = isset( $args[4] ) ? $args[4] : 0; |
| 4361 | |
| 4362 | if ( !$user = $this->login($username, $password) ) |
| 4363 | return $this->error; |
| 4364 | |
| 4365 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4366 | do_action( 'xmlrpc_call', 'metaWeblog.newPost' ); |
| 4367 | |
| 4368 | $page_template = ''; |
| 4369 | if ( !empty( $content_struct['post_type'] ) ) { |
| 4370 | if ( $content_struct['post_type'] == 'page' ) { |
| 4371 | if ( $publish ) |
| 4372 | $cap = 'publish_pages'; |
| 4373 | elseif ( isset( $content_struct['page_status'] ) && 'publish' == $content_struct['page_status'] ) |
| 4374 | $cap = 'publish_pages'; |
| 4375 | else |
| Line | Code |
| 4689 | $username = $args[1]; |
| 4690 | $password = $args[2]; |
| 4691 | $content_struct = $args[3]; |
| 4692 | $publish = isset( $args[4] ) ? $args[4] : 0; |
| 4693 | |
| 4694 | if ( ! $user = $this->login($username, $password) ) |
| 4695 | return $this->error; |
| 4696 | |
| 4697 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4698 | do_action( 'xmlrpc_call', 'metaWeblog.editPost' ); |
| 4699 | |
| 4700 | $postdata = get_post( $post_ID, ARRAY_A ); |
| 4701 | |
| 4702 | // If there is no post data for the give post id, stop |
| 4703 | // now and return an error. Other wise a new post will be |
| 4704 | // created (which was the old behavior). |
| 4705 | if ( ! $postdata || empty( $postdata[ 'ID' ] ) ) |
| 4706 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4707 | |
| Line | Code |
| 4981 | |
| 4982 | $postdata = get_post($post_ID, ARRAY_A); |
| 4983 | if ( ! $postdata ) |
| 4984 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4985 | |
| 4986 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
| 4987 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); |
| 4988 | |
| 4989 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4990 | do_action( 'xmlrpc_call', 'metaWeblog.getPost' ); |
| 4991 | |
| 4992 | if ($postdata['post_date'] != '') { |
| 4993 | $post_date = $this->_convert_date( $postdata['post_date'] ); |
| 4994 | $post_date_gmt = $this->_convert_date_gmt( $postdata['post_date_gmt'], $postdata['post_date'] ); |
| 4995 | $post_modified = $this->_convert_date( $postdata['post_modified'] ); |
| 4996 | $post_modified_gmt = $this->_convert_date_gmt( $postdata['post_modified_gmt'], $postdata['post_modified'] ); |
| 4997 | |
| 4998 | $categories = array(); |
| 4999 | $catids = wp_get_post_categories($post_ID); |
| Line | Code |
| 5105 | $query = array(); |
| 5106 | |
| 5107 | if ( !$user = $this->login($username, $password) ) |
| 5108 | return $this->error; |
| 5109 | |
| 5110 | if ( ! current_user_can( 'edit_posts' ) ) |
| 5111 | return new IXR_Error( 401, __( 'Sorry, you cannot edit posts on this site.' ) ); |
| 5112 | |
| 5113 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5114 | do_action( 'xmlrpc_call', 'metaWeblog.getRecentPosts' ); |
| 5115 | |
| 5116 | $posts_list = wp_get_recent_posts( $query ); |
| 5117 | |
| 5118 | if ( !$posts_list ) |
| 5119 | return array(); |
| 5120 | |
| 5121 | $recent_posts = array(); |
| 5122 | foreach ($posts_list as $entry) { |
| 5123 | if ( !current_user_can( 'edit_post', $entry['ID'] ) ) |
| Line | Code |
| 5213 | $password = $args[2]; |
| 5214 | |
| 5215 | if ( !$user = $this->login($username, $password) ) |
| 5216 | return $this->error; |
| 5217 | |
| 5218 | if ( !current_user_can( 'edit_posts' ) ) |
| 5219 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
| 5220 | |
| 5221 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5222 | do_action( 'xmlrpc_call', 'metaWeblog.getCategories' ); |
| 5223 | |
| 5224 | $categories_struct = array(); |
| 5225 | |
| 5226 | if ( $cats = get_categories(array('get' => 'all')) ) { |
| 5227 | foreach ( $cats as $cat ) { |
| 5228 | $struct = array(); |
| 5229 | $struct['categoryId'] = $cat->term_id; |
| 5230 | $struct['parentId'] = $cat->parent; |
| 5231 | $struct['description'] = $cat->name; |
| Line | Code |
| 5262 | |
| 5263 | $name = sanitize_file_name( $data['name'] ); |
| 5264 | $type = $data['type']; |
| 5265 | $bits = $data['bits']; |
| 5266 | |
| 5267 | if ( !$user = $this->login($username, $password) ) |
| 5268 | return $this->error; |
| 5269 | |
| 5270 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5271 | do_action( 'xmlrpc_call', 'metaWeblog.newMediaObject' ); |
| 5272 | |
| 5273 | if ( !current_user_can('upload_files') ) { |
| 5274 | $this->error = new IXR_Error( 401, __( 'You do not have permission to upload files.' ) ); |
| 5275 | return $this->error; |
| 5276 | } |
| 5277 | |
| 5278 | /** |
| 5279 | * Filter whether to preempt the XML-RPC media upload. |
| 5280 | * |
| 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 | $recent_posts = array(); |
| Line | Code |
| 5428 | $password = $args[2]; |
| 5429 | |
| 5430 | if ( !$user = $this->login($username, $password) ) |
| 5431 | return $this->error; |
| 5432 | |
| 5433 | if ( !current_user_can( 'edit_posts' ) ) |
| 5434 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
| 5435 | |
| 5436 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5437 | do_action( 'xmlrpc_call', 'mt.getCategoryList' ); |
| 5438 | |
| 5439 | $categories_struct = array(); |
| 5440 | |
| 5441 | if ( $cats = get_categories(array('hide_empty' => 0, 'hierarchical' => 0)) ) { |
| 5442 | foreach ( $cats as $cat ) { |
| 5443 | $struct = array(); |
| 5444 | $struct['categoryId'] = $cat->term_id; |
| 5445 | $struct['categoryName'] = $cat->name; |
| 5446 | |
| Line | Code |
| 5471 | return $this->error; |
| 5472 | |
| 5473 | if ( ! get_post( $post_ID ) ) |
| 5474 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 5475 | |
| 5476 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
| 5477 | return new IXR_Error( 401, __( 'Sorry, you can not edit this post.' ) ); |
| 5478 | |
| 5479 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5480 | do_action( 'xmlrpc_call', 'mt.getPostCategories' ); |
| 5481 | |
| 5482 | $categories = array(); |
| 5483 | $catids = wp_get_post_categories(intval($post_ID)); |
| 5484 | // first listed category will be the primary category |
| 5485 | $isPrimary = true; |
| 5486 | foreach ( $catids as $catid ) { |
| 5487 | $categories[] = array( |
| 5488 | 'categoryName' => get_cat_name($catid), |
| 5489 | 'categoryId' => (string) $catid, |
| Line | Code |
| 5510 | $post_ID = (int) $args[0]; |
| 5511 | $username = $args[1]; |
| 5512 | $password = $args[2]; |
| 5513 | $categories = $args[3]; |
| 5514 | |
| 5515 | if ( !$user = $this->login($username, $password) ) |
| 5516 | return $this->error; |
| 5517 | |
| 5518 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5519 | do_action( 'xmlrpc_call', 'mt.setPostCategories' ); |
| 5520 | |
| 5521 | if ( ! get_post( $post_ID ) ) |
| 5522 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 5523 | |
| 5524 | if ( !current_user_can('edit_post', $post_ID) ) |
| 5525 | return new IXR_Error(401, __('Sorry, you cannot edit this post.')); |
| 5526 | |
| 5527 | $catids = array(); |
| 5528 | foreach ( $categories as $cat ) { |
| Line | Code |
| 5539 | * |
| 5540 | * @since 1.5.0 |
| 5541 | * |
| 5542 | * @param array $args Method parameters. |
| 5543 | * @return array |
| 5544 | */ |
| 5545 | public function mt_supportedMethods($args) { |
| 5546 | |
| 5547 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5548 | do_action( 'xmlrpc_call', 'mt.supportedMethods' ); |
| 5549 | |
| 5550 | $supported_methods = array(); |
| 5551 | foreach ( $this->methods as $key => $value ) { |
| 5552 | $supported_methods[] = $key; |
| 5553 | } |
| 5554 | |
| 5555 | return $supported_methods; |
| 5556 | } |
| 5557 | |
| 5558 | /** |
| 5559 | * Retrieve an empty array because we don't support per-post text filters. |
| 5560 | * |
| 5561 | * @since 1.5.0 |
| 5562 | * |
| 5563 | * @param array $args Method parameters. |
| 5564 | */ |
| 5565 | public function mt_supportedTextFilters($args) { |
| 5566 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5567 | do_action( 'xmlrpc_call', 'mt.supportedTextFilters' ); |
| 5568 | |
| 5569 | /** |
| 5570 | * Filter the MoveableType text filters list for XML-RPC. |
| 5571 | * |
| 5572 | * @since 2.2.0 |
| 5573 | * |
| 5574 | * @param array $filters An array of text filters. |
| 5575 | */ |
| 5576 | return apply_filters( 'xmlrpc_text_filters', array() ); |
| Line | Code |
| 5585 | * @return array|IXR_Error |
| 5586 | */ |
| 5587 | public function mt_getTrackbackPings($args) { |
| 5588 | |
| 5589 | global $wpdb; |
| 5590 | |
| 5591 | $post_ID = intval($args); |
| 5592 | |
| 5593 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5594 | do_action( 'xmlrpc_call', 'mt.getTrackbackPings' ); |
| 5595 | |
| 5596 | $actual_post = get_post($post_ID, ARRAY_A); |
| 5597 | |
| 5598 | if ( !$actual_post ) |
| 5599 | return new IXR_Error(404, __('Sorry, no such post.')); |
| 5600 | |
| 5601 | $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) ); |
| 5602 | |
| 5603 | if ( !$comments ) |
| Line | Code |
| 5633 | |
| 5634 | $post_ID = (int) $args[0]; |
| 5635 | $username = $args[1]; |
| 5636 | $password = $args[2]; |
| 5637 | |
| 5638 | if ( !$user = $this->login($username, $password) ) |
| 5639 | return $this->error; |
| 5640 | |
| 5641 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5642 | do_action( 'xmlrpc_call', 'mt.publishPost' ); |
| 5643 | |
| 5644 | $postdata = get_post($post_ID, ARRAY_A); |
| 5645 | if ( ! $postdata ) |
| 5646 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 5647 | |
| 5648 | if ( !current_user_can('publish_posts') || !current_user_can('edit_post', $post_ID) ) |
| 5649 | return new IXR_Error(401, __('Sorry, you cannot publish this post.')); |
| 5650 | |
| 5651 | $postdata['post_status'] = 'publish'; |
| Line | Code |
| 5670 | * @since 1.5.0 |
| 5671 | * |
| 5672 | * @param array $args Method parameters. |
| 5673 | * @return string|IXR_Error |
| 5674 | */ |
| 5675 | public function pingback_ping($args) { |
| 5676 | global $wpdb; |
| 5677 | |
| 5678 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5679 | do_action( 'xmlrpc_call', 'pingback.ping' ); |
| 5680 | |
| 5681 | $this->escape($args); |
| 5682 | |
| 5683 | $pagelinkedfrom = $args[0]; |
| 5684 | $pagelinkedto = $args[1]; |
| 5685 | |
| 5686 | $title = ''; |
| 5687 | |
| 5688 | $pagelinkedfrom = str_replace('&', '&', $pagelinkedfrom); |
| Line | Code |
| 5879 | * |
| 5880 | * @param array $args Method parameters. |
| 5881 | * @return array|IXR_Error |
| 5882 | */ |
| 5883 | public function pingback_extensions_getPingbacks($args) { |
| 5884 | |
| 5885 | global $wpdb; |
| 5886 | |
| 5887 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5888 | do_action( 'xmlrpc_call', 'pingback.extensions.getPingbacks' ); |
| 5889 | |
| 5890 | $this->escape($args); |
| 5891 | |
| 5892 | $url = $args; |
| 5893 | |
| 5894 | $post_ID = url_to_postid($url); |
| 5895 | if ( !$post_ID ) { |
| 5896 | // We aren't sure that the resource is available and/or pingback enabled |
| 5897 | 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.' ) ); |