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 |
---|---|
544 | * the method logic begins. |
545 | * |
546 | * All built-in XML-RPC methods use the action xmlrpc_call, with a parameter |
547 | * equal to the method's name, e.g., wp.getUsersBlogs, wp.newPost, etc. |
548 | * |
549 | * @since 2.5.0 |
550 | * |
551 | * @param method $name The method name. |
552 | */ |
553 | do_action( 'xmlrpc_call', 'wp.getUsersBlogs' ); |
554 |
|
555 | $blogs = (array) get_blogs_of_user( $user->ID ); |
556 | $struct = array(); |
557 |
|
558 | foreach ( $blogs as $blog ) { |
559 | // Don't include blogs that aren't hosted at this site |
560 | if ( $blog->site_id != get_current_site()->id ) |
561 | continue; |
562 |
|
Line | Code |
1126 | if ( isset( $content_struct['post_date_gmt'] ) && ! ( $content_struct['post_date_gmt'] instanceof IXR_Date ) ) { |
1127 | if ( $content_struct['post_date_gmt'] == '0000-00-00 00:00:00' || isset( $content_struct['post_date'] ) ) { |
1128 | unset( $content_struct['post_date_gmt'] ); |
1129 | } else { |
1130 | $content_struct['post_date_gmt'] = $this->_convert_date( $content_struct['post_date_gmt'] ); |
1131 | } |
1132 | } |
1133 |
|
1134 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
1135 | do_action( 'xmlrpc_call', 'wp.newPost' ); |
1136 |
|
1137 | unset( $content_struct['ID'] ); |
1138 |
|
1139 | return $this->_insert_post( $user, $content_struct ); |
1140 | } |
1141 |
|
1142 | /** |
1143 | * Helper method for filtering out elements from an array. |
1144 | * |
Line | Code |
1420 | $username = $args[1]; |
1421 | $password = $args[2]; |
1422 | $post_id = (int) $args[3]; |
1423 | $content_struct = $args[4]; |
1424 |
|
1425 | if ( ! $user = $this->login( $username, $password ) ) |
1426 | return $this->error; |
1427 |
|
1428 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
1429 | do_action( 'xmlrpc_call', 'wp.editPost' ); |
1430 |
|
1431 | $post = get_post( $post_id, ARRAY_A ); |
1432 |
|
1433 | if ( empty( $post['ID'] ) ) |
1434 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
1435 |
|
1436 | if ( isset( $content_struct['if_not_modified_since'] ) ) { |
1437 | // If the post has been modified since the date provided, return an error. |
1438 | if ( mysql2date( 'U', $post['post_modified_gmt'] ) > $content_struct['if_not_modified_since']->getTimestamp() ) { |
Line | Code |
1481 |
|
1482 | $username = $args[1]; |
1483 | $password = $args[2]; |
1484 | $post_id = (int) $args[3]; |
1485 |
|
1486 | if ( ! $user = $this->login( $username, $password ) ) |
1487 | return $this->error; |
1488 |
|
1489 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
1490 | do_action( 'xmlrpc_call', 'wp.deletePost' ); |
1491 |
|
1492 | $post = get_post( $post_id, ARRAY_A ); |
1493 | if ( empty( $post['ID'] ) ) |
1494 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
1495 |
|
1496 | if ( ! current_user_can( 'delete_post', $post_id ) ) |
1497 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) ); |
1498 |
|
1499 | $result = wp_delete_post( $post_id ); |
Line | Code |
1571 | * @param string $method Method name. |
1572 | */ |
1573 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPost' ); |
1574 | } |
1575 |
|
1576 | if ( ! $user = $this->login( $username, $password ) ) |
1577 | return $this->error; |
1578 |
|
1579 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
1580 | do_action( 'xmlrpc_call', 'wp.getPost' ); |
1581 |
|
1582 | $post = get_post( $post_id, ARRAY_A ); |
1583 |
|
1584 | if ( empty( $post['ID'] ) ) |
1585 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
1586 |
|
1587 | if ( ! current_user_can( 'edit_post', $post_id ) ) |
1588 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); |
1589 |
|
Line | Code |
1629 | } else { |
1630 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
1631 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPosts' ); |
1632 | } |
1633 |
|
1634 | if ( ! $user = $this->login( $username, $password ) ) |
1635 | return $this->error; |
1636 |
|
1637 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
1638 | do_action( 'xmlrpc_call', 'wp.getPosts' ); |
1639 |
|
1640 | $query = array(); |
1641 |
|
1642 | if ( isset( $filter['post_type'] ) ) { |
1643 | $post_type = get_post_type_object( $filter['post_type'] ); |
1644 | if ( ! ( (bool) $post_type ) ) |
1645 | return new IXR_Error( 403, __( 'The post type specified is not valid' ) ); |
1646 | } else { |
1647 | $post_type = get_post_type_object( 'post' ); |
Line | Code |
1718 |
|
1719 | $username = $args[1]; |
1720 | $password = $args[2]; |
1721 | $content_struct = $args[3]; |
1722 |
|
1723 | if ( ! $user = $this->login( $username, $password ) ) |
1724 | return $this->error; |
1725 |
|
1726 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
1727 | do_action( 'xmlrpc_call', 'wp.newTerm' ); |
1728 |
|
1729 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) |
1730 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
1731 |
|
1732 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
1733 |
|
1734 | if ( ! current_user_can( $taxonomy->cap->manage_terms ) ) |
1735 | return new IXR_Error( 401, __( 'You are not allowed to create terms in this taxonomy.' ) ); |
1736 |
|
Line | Code |
1806 | $username = $args[1]; |
1807 | $password = $args[2]; |
1808 | $term_id = (int) $args[3]; |
1809 | $content_struct = $args[4]; |
1810 |
|
1811 | if ( ! $user = $this->login( $username, $password ) ) |
1812 | return $this->error; |
1813 |
|
1814 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
1815 | do_action( 'xmlrpc_call', 'wp.editTerm' ); |
1816 |
|
1817 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) |
1818 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
1819 |
|
1820 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
1821 |
|
1822 | if ( ! current_user_can( $taxonomy->cap->edit_terms ) ) |
1823 | return new IXR_Error( 401, __( 'You are not allowed to edit terms in this taxonomy.' ) ); |
1824 |
|
Line | Code |
1898 | $username = $args[1]; |
1899 | $password = $args[2]; |
1900 | $taxonomy = $args[3]; |
1901 | $term_id = (int) $args[4]; |
1902 |
|
1903 | if ( ! $user = $this->login( $username, $password ) ) |
1904 | return $this->error; |
1905 |
|
1906 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
1907 | do_action( 'xmlrpc_call', 'wp.deleteTerm' ); |
1908 |
|
1909 | if ( ! taxonomy_exists( $taxonomy ) ) |
1910 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
1911 |
|
1912 | $taxonomy = get_taxonomy( $taxonomy ); |
1913 |
|
1914 | if ( ! current_user_can( $taxonomy->cap->delete_terms ) ) |
1915 | return new IXR_Error( 401, __( 'You are not allowed to delete terms in this taxonomy.' ) ); |
1916 |
|
Line | Code |
1965 | $username = $args[1]; |
1966 | $password = $args[2]; |
1967 | $taxonomy = $args[3]; |
1968 | $term_id = (int) $args[4]; |
1969 |
|
1970 | if ( ! $user = $this->login( $username, $password ) ) |
1971 | return $this->error; |
1972 |
|
1973 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
1974 | do_action( 'xmlrpc_call', 'wp.getTerm' ); |
1975 |
|
1976 | if ( ! taxonomy_exists( $taxonomy ) ) |
1977 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
1978 |
|
1979 | $taxonomy = get_taxonomy( $taxonomy ); |
1980 |
|
1981 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
1982 | return new IXR_Error( 401, __( 'You are not allowed to assign terms in this taxonomy.' ) ); |
1983 |
|
Line | Code |
2018 | $username = $args[1]; |
2019 | $password = $args[2]; |
2020 | $taxonomy = $args[3]; |
2021 | $filter = isset( $args[4] ) ? $args[4] : array(); |
2022 |
|
2023 | if ( ! $user = $this->login( $username, $password ) ) |
2024 | return $this->error; |
2025 |
|
2026 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2027 | do_action( 'xmlrpc_call', 'wp.getTerms' ); |
2028 |
|
2029 | if ( ! taxonomy_exists( $taxonomy ) ) |
2030 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
2031 |
|
2032 | $taxonomy = get_taxonomy( $taxonomy ); |
2033 |
|
2034 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
2035 | return new IXR_Error( 401, __( 'You are not allowed to assign terms in this taxonomy.' ) ); |
2036 |
|
Line | Code |
2106 | * @param string $method The method name. |
2107 | */ |
2108 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomy' ); |
2109 | } |
2110 |
|
2111 | if ( ! $user = $this->login( $username, $password ) ) |
2112 | return $this->error; |
2113 |
|
2114 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2115 | do_action( 'xmlrpc_call', 'wp.getTaxonomy' ); |
2116 |
|
2117 | if ( ! taxonomy_exists( $taxonomy ) ) |
2118 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
2119 |
|
2120 | $taxonomy = get_taxonomy( $taxonomy ); |
2121 |
|
2122 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
2123 | return new IXR_Error( 401, __( 'You are not allowed to assign terms in this taxonomy.' ) ); |
2124 |
|
Line | Code |
2152 | } else { |
2153 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2154 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomies' ); |
2155 | } |
2156 |
|
2157 | if ( ! $user = $this->login( $username, $password ) ) |
2158 | return $this->error; |
2159 |
|
2160 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2161 | do_action( 'xmlrpc_call', 'wp.getTaxonomies' ); |
2162 |
|
2163 | $taxonomies = get_taxonomies( $filter, 'objects' ); |
2164 |
|
2165 | // holds all the taxonomy data |
2166 | $struct = array(); |
2167 |
|
2168 | foreach ( $taxonomies as $taxonomy ) { |
2169 | // capability check for post_types |
2170 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
Line | Code |
2230 | * @param string $method The method name. |
2231 | */ |
2232 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUser' ); |
2233 | } |
2234 |
|
2235 | if ( ! $user = $this->login( $username, $password ) ) |
2236 | return $this->error; |
2237 |
|
2238 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2239 | do_action( 'xmlrpc_call', 'wp.getUser' ); |
2240 |
|
2241 | if ( ! current_user_can( 'edit_user', $user_id ) ) |
2242 | return new IXR_Error( 401, __( 'Sorry, you cannot edit users.' ) ); |
2243 |
|
2244 | $user_data = get_userdata( $user_id ); |
2245 |
|
2246 | if ( ! $user_data ) |
2247 | return new IXR_Error( 404, __( 'Invalid user ID' ) ); |
2248 |
|
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 |
2354 | } else { |
2355 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2356 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getProfile' ); |
2357 | } |
2358 |
|
2359 | if ( ! $user = $this->login( $username, $password ) ) |
2360 | return $this->error; |
2361 |
|
2362 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2363 | do_action( 'xmlrpc_call', 'wp.getProfile' ); |
2364 |
|
2365 | if ( ! current_user_can( 'edit_user', $user->ID ) ) |
2366 | return new IXR_Error( 401, __( 'Sorry, you cannot edit your profile.' ) ); |
2367 |
|
2368 | $user_data = get_userdata( $user->ID ); |
2369 |
|
2370 | return $this->_prepare_user( $user_data, $fields ); |
2371 | } |
2372 |
|
Line | Code |
2397 |
|
2398 | $username = $args[1]; |
2399 | $password = $args[2]; |
2400 | $content_struct = $args[3]; |
2401 |
|
2402 | if ( ! $user = $this->login( $username, $password ) ) |
2403 | return $this->error; |
2404 |
|
2405 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2406 | do_action( 'xmlrpc_call', 'wp.editProfile' ); |
2407 |
|
2408 | if ( ! current_user_can( 'edit_user', $user->ID ) ) |
2409 | return new IXR_Error( 401, __( 'Sorry, you cannot edit your profile.' ) ); |
2410 |
|
2411 | // holds data of the user |
2412 | $user_data = array(); |
2413 | $user_data['ID'] = $user->ID; |
2414 |
|
2415 | // only set the user details if it was given |
Line | Code |
2470 |
|
2471 | $page = get_post($page_id); |
2472 | if ( ! $page ) |
2473 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
2474 |
|
2475 | if ( !current_user_can( 'edit_page', $page_id ) ) |
2476 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this page.' ) ); |
2477 |
|
2478 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2479 | do_action( 'xmlrpc_call', 'wp.getPage' ); |
2480 |
|
2481 | // If we found the page then format the data. |
2482 | if ( $page->ID && ($page->post_type == 'page') ) { |
2483 | return $this->_prepare_page( $page ); |
2484 | } |
2485 | // If the page doesn't exist indicate that. |
2486 | else { |
2487 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
2488 | } |
Line | Code |
2508 | $num_pages = isset($args[3]) ? (int) $args[3] : 10; |
2509 |
|
2510 | if ( !$user = $this->login($username, $password) ) |
2511 | return $this->error; |
2512 |
|
2513 | if ( !current_user_can( 'edit_pages' ) ) |
2514 | return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) ); |
2515 |
|
2516 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2517 | do_action( 'xmlrpc_call', 'wp.getPages' ); |
2518 |
|
2519 | $pages = get_posts( array('post_type' => 'page', 'post_status' => 'any', 'numberposts' => $num_pages) ); |
2520 | $num_pages = count($pages); |
2521 |
|
2522 | // If we have pages, put together their info. |
2523 | if ( $num_pages >= 1 ) { |
2524 | $pages_struct = array(); |
2525 |
|
2526 | foreach ($pages as $page) { |
Line | Code |
2545 | public function wp_newPage($args) { |
2546 | // Items not escaped here will be escaped in newPost. |
2547 | $username = $this->escape($args[1]); |
2548 | $password = $this->escape($args[2]); |
2549 |
|
2550 | if ( !$user = $this->login($username, $password) ) |
2551 | return $this->error; |
2552 |
|
2553 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2554 | do_action( 'xmlrpc_call', 'wp.newPage' ); |
2555 |
|
2556 | // Mark this as content for a page. |
2557 | $args[3]["post_type"] = 'page'; |
2558 |
|
2559 | // Let mw_newPost do all of the heavy lifting. |
2560 | return $this->mw_newPost( $args ); |
2561 | } |
2562 |
|
2563 | /** |
Line | Code |
2573 |
|
2574 | $username = $args[1]; |
2575 | $password = $args[2]; |
2576 | $page_id = (int) $args[3]; |
2577 |
|
2578 | if ( !$user = $this->login($username, $password) ) |
2579 | return $this->error; |
2580 |
|
2581 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2582 | do_action( 'xmlrpc_call', 'wp.deletePage' ); |
2583 |
|
2584 | // Get the current page based on the page_id and |
2585 | // make sure it is a page and not a post. |
2586 | $actual_page = get_post($page_id, ARRAY_A); |
2587 | if ( !$actual_page || ($actual_page['post_type'] != 'page') ) |
2588 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
2589 |
|
2590 | // Make sure the user can delete pages. |
2591 | if ( !current_user_can('delete_page', $page_id) ) |
Line | Code |
2623 | $username = $this->escape($args[2]); |
2624 | $password = $this->escape($args[3]); |
2625 | $content = $args[4]; |
2626 | $publish = $args[5]; |
2627 |
|
2628 | if ( !$user = $this->login($username, $password) ) |
2629 | return $this->error; |
2630 |
|
2631 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2632 | do_action( 'xmlrpc_call', 'wp.editPage' ); |
2633 |
|
2634 | // Get the page data and make sure it is a page. |
2635 | $actual_page = get_post($page_id, ARRAY_A); |
2636 | if ( !$actual_page || ($actual_page['post_type'] != 'page') ) |
2637 | return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); |
2638 |
|
2639 | // Make sure the user is allowed to edit pages. |
2640 | if ( !current_user_can('edit_page', $page_id) ) |
2641 | return new IXR_Error( 401, __( 'Sorry, you do not have the right to edit this page.' ) ); |
Line | Code |
2673 | $password = $args[2]; |
2674 |
|
2675 | if ( !$user = $this->login($username, $password) ) |
2676 | return $this->error; |
2677 |
|
2678 | if ( !current_user_can( 'edit_pages' ) ) |
2679 | return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) ); |
2680 |
|
2681 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2682 | do_action( 'xmlrpc_call', 'wp.getPageList' ); |
2683 |
|
2684 | // Get list of pages ids and titles |
2685 | $page_list = $wpdb->get_results(" |
2686 | SELECT ID page_id, |
2687 | post_title page_title, |
2688 | post_parent page_parent_id, |
2689 | post_date_gmt, |
2690 | post_date, |
2691 | post_status |
Line | Code |
2724 | $password = $args[2]; |
2725 |
|
2726 | if ( !$user = $this->login($username, $password) ) |
2727 | return $this->error; |
2728 |
|
2729 | if ( !current_user_can('edit_posts') ) |
2730 | return new IXR_Error( 401, __( 'Sorry, you cannot edit posts on this site.' ) ); |
2731 |
|
2732 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2733 | do_action( 'xmlrpc_call', 'wp.getAuthors' ); |
2734 |
|
2735 | $authors = array(); |
2736 | foreach ( get_users( array( 'fields' => array('ID','user_login','display_name') ) ) as $user ) { |
2737 | $authors[] = array( |
2738 | 'user_id' => $user->ID, |
2739 | 'user_login' => $user->user_login, |
2740 | 'display_name' => $user->display_name |
2741 | ); |
2742 | } |
Line | Code |
2759 | $password = $args[2]; |
2760 |
|
2761 | if ( !$user = $this->login($username, $password) ) |
2762 | return $this->error; |
2763 |
|
2764 | if ( !current_user_can( 'edit_posts' ) ) |
2765 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view tags.' ) ); |
2766 |
|
2767 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2768 | do_action( 'xmlrpc_call', 'wp.getKeywords' ); |
2769 |
|
2770 | $tags = array(); |
2771 |
|
2772 | if ( $all_tags = get_tags() ) { |
2773 | foreach( (array) $all_tags as $tag ) { |
2774 | $struct = array(); |
2775 | $struct['tag_id'] = $tag->term_id; |
2776 | $struct['name'] = $tag->name; |
2777 | $struct['count'] = $tag->count; |
Line | Code |
2799 |
|
2800 | $username = $args[1]; |
2801 | $password = $args[2]; |
2802 | $category = $args[3]; |
2803 |
|
2804 | if ( !$user = $this->login($username, $password) ) |
2805 | return $this->error; |
2806 |
|
2807 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2808 | do_action( 'xmlrpc_call', 'wp.newCategory' ); |
2809 |
|
2810 | // Make sure the user is allowed to add a category. |
2811 | if ( !current_user_can('manage_categories') ) |
2812 | return new IXR_Error(401, __('Sorry, you do not have the right to add a category.')); |
2813 |
|
2814 | // If no slug was provided make it empty so that |
2815 | // WordPress will generate one. |
2816 | if ( empty($category['slug']) ) |
2817 | $category['slug'] = ''; |
Line | Code |
2868 |
|
2869 | $username = $args[1]; |
2870 | $password = $args[2]; |
2871 | $category_id = (int) $args[3]; |
2872 |
|
2873 | if ( !$user = $this->login($username, $password) ) |
2874 | return $this->error; |
2875 |
|
2876 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2877 | do_action( 'xmlrpc_call', 'wp.deleteCategory' ); |
2878 |
|
2879 | if ( !current_user_can('manage_categories') ) |
2880 | return new IXR_Error( 401, __( 'Sorry, you do not have the right to delete a category.' ) ); |
2881 |
|
2882 | $status = wp_delete_term( $category_id, 'category' ); |
2883 |
|
2884 | if ( true == $status ) { |
2885 | /** |
2886 | * Fires after a category has been successfully deleted via XML-RPC. |
Line | Code |
2913 | $max_results = (int) $args[4]; |
2914 |
|
2915 | if ( !$user = $this->login($username, $password) ) |
2916 | return $this->error; |
2917 |
|
2918 | if ( !current_user_can( 'edit_posts' ) ) |
2919 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
2920 |
|
2921 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2922 | do_action( 'xmlrpc_call', 'wp.suggestCategories' ); |
2923 |
|
2924 | $category_suggestions = array(); |
2925 | $args = array('get' => 'all', 'number' => $max_results, 'name__like' => $category); |
2926 | foreach ( (array) get_categories($args) as $cat ) { |
2927 | $category_suggestions[] = array( |
2928 | 'category_id' => $cat->term_id, |
2929 | 'category_name' => $cat->name |
2930 | ); |
2931 | } |
Line | Code |
2949 | $comment_id = (int) $args[3]; |
2950 |
|
2951 | if ( !$user = $this->login($username, $password) ) |
2952 | return $this->error; |
2953 |
|
2954 | if ( !current_user_can( 'moderate_comments' ) ) |
2955 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
2956 |
|
2957 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2958 | do_action( 'xmlrpc_call', 'wp.getComment' ); |
2959 |
|
2960 | if ( ! $comment = get_comment($comment_id) ) |
2961 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
2962 |
|
2963 | return $this->_prepare_comment( $comment ); |
2964 | } |
2965 |
|
2966 | /** |
2967 | * Retrieve comments. |
Line | Code |
2990 | $struct = isset( $args[3] ) ? $args[3] : array(); |
2991 |
|
2992 | if ( !$user = $this->login($username, $password) ) |
2993 | return $this->error; |
2994 |
|
2995 | if ( !current_user_can( 'moderate_comments' ) ) |
2996 | return new IXR_Error( 401, __( 'Sorry, you cannot edit comments.' ) ); |
2997 |
|
2998 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
2999 | do_action( 'xmlrpc_call', 'wp.getComments' ); |
3000 |
|
3001 | if ( isset($struct['status']) ) |
3002 | $status = $struct['status']; |
3003 | else |
3004 | $status = ''; |
3005 |
|
3006 | $post_id = ''; |
3007 | if ( isset($struct['post_id']) ) |
3008 | $post_id = absint($struct['post_id']); |
Line | Code |
3056 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
3057 |
|
3058 | if ( ! get_comment($comment_ID) ) |
3059 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
3060 |
|
3061 | if ( !current_user_can( 'edit_comment', $comment_ID ) ) |
3062 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
3063 |
|
3064 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3065 | do_action( 'xmlrpc_call', 'wp.deleteComment' ); |
3066 |
|
3067 | $status = wp_delete_comment( $comment_ID ); |
3068 |
|
3069 | if ( true == $status ) { |
3070 | /** |
3071 | * Fires after a comment has been successfully deleted via XML-RPC. |
3072 | * |
3073 | * @since 3.4.0 |
3074 | * |
Line | Code |
3120 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
3121 |
|
3122 | if ( ! get_comment($comment_ID) ) |
3123 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
3124 |
|
3125 | if ( !current_user_can( 'edit_comment', $comment_ID ) ) |
3126 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
3127 |
|
3128 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
3129 | do_action( 'xmlrpc_call', 'wp.editComment' ); |
3130 |
|
3131 | if ( isset($content_struct['status']) ) { |
3132 | $statuses = get_comment_statuses(); |
3133 | $statuses = array_keys($statuses); |
3134 |
|
3135 | if ( ! in_array($content_struct['status'], $statuses) ) |
3136 | return new IXR_Error( 401, __( 'Invalid comment status.' ) ); |
3137 | $comment_approved = $content_struct['status']; |
3138 | } |
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 |
4212 | $username = $args[2]; |
4213 | $password = $args[3]; |
4214 | $content = $args[4]; |
4215 |
|
4216 | if ( ! $user = $this->login( $username, $password ) ) { |
4217 | return $this->error; |
4218 | } |
4219 |
|
4220 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4221 | do_action( 'xmlrpc_call', 'blogger.editPost' ); |
4222 |
|
4223 | $actual_post = get_post( $post_ID, ARRAY_A ); |
4224 |
|
4225 | if ( ! $actual_post || $actual_post['post_type'] != 'post' ) { |
4226 | return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); |
4227 | } |
4228 |
|
4229 | $this->escape($actual_post); |
4230 |
|
Line | Code |
4276 |
|
4277 | $post_ID = (int) $args[1]; |
4278 | $username = $args[2]; |
4279 | $password = $args[3]; |
4280 |
|
4281 | if ( !$user = $this->login($username, $password) ) |
4282 | return $this->error; |
4283 |
|
4284 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4285 | do_action( 'xmlrpc_call', 'blogger.deletePost' ); |
4286 |
|
4287 | $actual_post = get_post($post_ID,ARRAY_A); |
4288 |
|
4289 | if ( !$actual_post || $actual_post['post_type'] != 'post' ) |
4290 | return new IXR_Error(404, __('Sorry, no such post.')); |
4291 |
|
4292 | if ( !current_user_can('delete_post', $post_ID) ) |
4293 | return new IXR_Error(401, __('Sorry, you do not have the right to delete this post.')); |
4294 |
|
Line | Code |
4355 | $username = $args[1]; |
4356 | $password = $args[2]; |
4357 | $content_struct = $args[3]; |
4358 | $publish = isset( $args[4] ) ? $args[4] : 0; |
4359 |
|
4360 | if ( !$user = $this->login($username, $password) ) |
4361 | return $this->error; |
4362 |
|
4363 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4364 | do_action( 'xmlrpc_call', 'metaWeblog.newPost' ); |
4365 |
|
4366 | $page_template = ''; |
4367 | if ( !empty( $content_struct['post_type'] ) ) { |
4368 | if ( $content_struct['post_type'] == 'page' ) { |
4369 | if ( $publish ) |
4370 | $cap = 'publish_pages'; |
4371 | elseif ( isset( $content_struct['page_status'] ) && 'publish' == $content_struct['page_status'] ) |
4372 | $cap = 'publish_pages'; |
4373 | else |
Line | Code |
4686 | $username = $args[1]; |
4687 | $password = $args[2]; |
4688 | $content_struct = $args[3]; |
4689 | $publish = isset( $args[4] ) ? $args[4] : 0; |
4690 |
|
4691 | if ( ! $user = $this->login($username, $password) ) |
4692 | return $this->error; |
4693 |
|
4694 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4695 | do_action( 'xmlrpc_call', 'metaWeblog.editPost' ); |
4696 |
|
4697 | $postdata = get_post( $post_ID, ARRAY_A ); |
4698 |
|
4699 | // If there is no post data for the give post id, stop |
4700 | // now and return an error. Other wise a new post will be |
4701 | // created (which was the old behavior). |
4702 | if ( ! $postdata || empty( $postdata[ 'ID' ] ) ) |
4703 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
4704 |
|
Line | Code |
4983 |
|
4984 | $postdata = get_post($post_ID, ARRAY_A); |
4985 | if ( ! $postdata ) |
4986 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
4987 |
|
4988 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
4989 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); |
4990 |
|
4991 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
4992 | do_action( 'xmlrpc_call', 'metaWeblog.getPost' ); |
4993 |
|
4994 | if ($postdata['post_date'] != '') { |
4995 | $post_date = $this->_convert_date( $postdata['post_date'] ); |
4996 | $post_date_gmt = $this->_convert_date_gmt( $postdata['post_date_gmt'], $postdata['post_date'] ); |
4997 | $post_modified = $this->_convert_date( $postdata['post_modified'] ); |
4998 | $post_modified_gmt = $this->_convert_date_gmt( $postdata['post_modified_gmt'], $postdata['post_modified'] ); |
4999 |
|
5000 | $categories = array(); |
5001 | $catids = wp_get_post_categories($post_ID); |
Line | Code |
5107 | $query = array(); |
5108 |
|
5109 | if ( !$user = $this->login($username, $password) ) |
5110 | return $this->error; |
5111 |
|
5112 | if ( ! current_user_can( 'edit_posts' ) ) |
5113 | return new IXR_Error( 401, __( 'Sorry, you cannot edit posts on this site.' ) ); |
5114 |
|
5115 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5116 | do_action( 'xmlrpc_call', 'metaWeblog.getRecentPosts' ); |
5117 |
|
5118 | $posts_list = wp_get_recent_posts( $query ); |
5119 |
|
5120 | if ( !$posts_list ) |
5121 | return array(); |
5122 |
|
5123 | $recent_posts = array(); |
5124 | foreach ($posts_list as $entry) { |
5125 | if ( !current_user_can( 'edit_post', $entry['ID'] ) ) |
Line | Code |
5215 | $password = $args[2]; |
5216 |
|
5217 | if ( !$user = $this->login($username, $password) ) |
5218 | return $this->error; |
5219 |
|
5220 | if ( !current_user_can( 'edit_posts' ) ) |
5221 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
5222 |
|
5223 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5224 | do_action( 'xmlrpc_call', 'metaWeblog.getCategories' ); |
5225 |
|
5226 | $categories_struct = array(); |
5227 |
|
5228 | if ( $cats = get_categories(array('get' => 'all')) ) { |
5229 | foreach ( $cats as $cat ) { |
5230 | $struct = array(); |
5231 | $struct['categoryId'] = $cat->term_id; |
5232 | $struct['parentId'] = $cat->parent; |
5233 | $struct['description'] = $cat->name; |
Line | Code |
5264 |
|
5265 | $name = sanitize_file_name( $data['name'] ); |
5266 | $type = $data['type']; |
5267 | $bits = $data['bits']; |
5268 |
|
5269 | if ( !$user = $this->login($username, $password) ) |
5270 | return $this->error; |
5271 |
|
5272 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5273 | do_action( 'xmlrpc_call', 'metaWeblog.newMediaObject' ); |
5274 |
|
5275 | if ( !current_user_can('upload_files') ) { |
5276 | $this->error = new IXR_Error( 401, __( 'You do not have permission to upload files.' ) ); |
5277 | return $this->error; |
5278 | } |
5279 |
|
5280 | /** |
5281 | * Filter whether to preempt the XML-RPC media upload. |
5282 | * |
Line | Code |
5377 | if ( isset( $args[3] ) ) |
5378 | $query = array( 'numberposts' => absint( $args[3] ) ); |
5379 | else |
5380 | $query = array(); |
5381 |
|
5382 | if ( !$user = $this->login($username, $password) ) |
5383 | return $this->error; |
5384 |
|
5385 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5386 | do_action( 'xmlrpc_call', 'mt.getRecentPostTitles' ); |
5387 |
|
5388 | $posts_list = wp_get_recent_posts( $query ); |
5389 |
|
5390 | if ( !$posts_list ) { |
5391 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
5392 | return $this->error; |
5393 | } |
5394 |
|
5395 | $recent_posts = array(); |
Line | Code |
5430 | $password = $args[2]; |
5431 |
|
5432 | if ( !$user = $this->login($username, $password) ) |
5433 | return $this->error; |
5434 |
|
5435 | if ( !current_user_can( 'edit_posts' ) ) |
5436 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
5437 |
|
5438 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5439 | do_action( 'xmlrpc_call', 'mt.getCategoryList' ); |
5440 |
|
5441 | $categories_struct = array(); |
5442 |
|
5443 | if ( $cats = get_categories(array('hide_empty' => 0, 'hierarchical' => 0)) ) { |
5444 | foreach ( $cats as $cat ) { |
5445 | $struct = array(); |
5446 | $struct['categoryId'] = $cat->term_id; |
5447 | $struct['categoryName'] = $cat->name; |
5448 |
|
Line | Code |
5473 | return $this->error; |
5474 |
|
5475 | if ( ! get_post( $post_ID ) ) |
5476 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
5477 |
|
5478 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
5479 | return new IXR_Error( 401, __( 'Sorry, you can not edit this post.' ) ); |
5480 |
|
5481 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5482 | do_action( 'xmlrpc_call', 'mt.getPostCategories' ); |
5483 |
|
5484 | $categories = array(); |
5485 | $catids = wp_get_post_categories(intval($post_ID)); |
5486 | // first listed category will be the primary category |
5487 | $isPrimary = true; |
5488 | foreach ( $catids as $catid ) { |
5489 | $categories[] = array( |
5490 | 'categoryName' => get_cat_name($catid), |
5491 | 'categoryId' => (string) $catid, |
Line | Code |
5512 | $post_ID = (int) $args[0]; |
5513 | $username = $args[1]; |
5514 | $password = $args[2]; |
5515 | $categories = $args[3]; |
5516 |
|
5517 | if ( !$user = $this->login($username, $password) ) |
5518 | return $this->error; |
5519 |
|
5520 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5521 | do_action( 'xmlrpc_call', 'mt.setPostCategories' ); |
5522 |
|
5523 | if ( ! get_post( $post_ID ) ) |
5524 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
5525 |
|
5526 | if ( !current_user_can('edit_post', $post_ID) ) |
5527 | return new IXR_Error(401, __('Sorry, you cannot edit this post.')); |
5528 |
|
5529 | $catids = array(); |
5530 | foreach ( $categories as $cat ) { |
Line | Code |
5541 | * |
5542 | * @since 1.5.0 |
5543 | * |
5544 | * @param array $args Method parameters. |
5545 | * @return array |
5546 | */ |
5547 | public function mt_supportedMethods($args) { |
5548 |
|
5549 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5550 | do_action( 'xmlrpc_call', 'mt.supportedMethods' ); |
5551 |
|
5552 | $supported_methods = array(); |
5553 | foreach ( $this->methods as $key => $value ) { |
5554 | $supported_methods[] = $key; |
5555 | } |
5556 |
|
5557 | return $supported_methods; |
5558 | } |
5559 |
|
5560 | /** |
5561 | * Retrieve an empty array because we don't support per-post text filters. |
5562 | * |
5563 | * @since 1.5.0 |
5564 | * |
5565 | * @param array $args Method parameters. |
5566 | */ |
5567 | public function mt_supportedTextFilters($args) { |
5568 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5569 | do_action( 'xmlrpc_call', 'mt.supportedTextFilters' ); |
5570 |
|
5571 | /** |
5572 | * Filter the MoveableType text filters list for XML-RPC. |
5573 | * |
5574 | * @since 2.2.0 |
5575 | * |
5576 | * @param array $filters An array of text filters. |
5577 | */ |
5578 | return apply_filters( 'xmlrpc_text_filters', array() ); |
Line | Code |
5587 | * @return array|IXR_Error |
5588 | */ |
5589 | public function mt_getTrackbackPings($args) { |
5590 |
|
5591 | global $wpdb; |
5592 |
|
5593 | $post_ID = intval($args); |
5594 |
|
5595 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5596 | do_action( 'xmlrpc_call', 'mt.getTrackbackPings' ); |
5597 |
|
5598 | $actual_post = get_post($post_ID, ARRAY_A); |
5599 |
|
5600 | if ( !$actual_post ) |
5601 | return new IXR_Error(404, __('Sorry, no such post.')); |
5602 |
|
5603 | $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) ); |
5604 |
|
5605 | if ( !$comments ) |
Line | Code |
5635 |
|
5636 | $post_ID = (int) $args[0]; |
5637 | $username = $args[1]; |
5638 | $password = $args[2]; |
5639 |
|
5640 | if ( !$user = $this->login($username, $password) ) |
5641 | return $this->error; |
5642 |
|
5643 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5644 | do_action( 'xmlrpc_call', 'mt.publishPost' ); |
5645 |
|
5646 | $postdata = get_post($post_ID, ARRAY_A); |
5647 | if ( ! $postdata ) |
5648 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
5649 |
|
5650 | if ( !current_user_can('publish_posts') || !current_user_can('edit_post', $post_ID) ) |
5651 | return new IXR_Error(401, __('Sorry, you cannot publish this post.')); |
5652 |
|
5653 | $postdata['post_status'] = 'publish'; |
Line | Code |
5672 | * @since 1.5.0 |
5673 | * |
5674 | * @param array $args Method parameters. |
5675 | * @return string|IXR_Error |
5676 | */ |
5677 | public function pingback_ping($args) { |
5678 | global $wpdb; |
5679 |
|
5680 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
5681 | do_action( 'xmlrpc_call', 'pingback.ping' ); |
5682 |
|
5683 | $this->escape($args); |
5684 |
|
5685 | $pagelinkedfrom = $args[0]; |
5686 | $pagelinkedto = $args[1]; |
5687 |
|
5688 | $pagelinkedfrom = str_replace('&', '&', $pagelinkedfrom); |
5689 | $pagelinkedto = str_replace('&', '&', $pagelinkedto); |
5690 | $pagelinkedto = str_replace('&', '&', $pagelinkedto); |
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.' ) ); |