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 |
|---|---|
| 468 | |
| 469 | $this->escape( $args ); |
| 470 | |
| 471 | $username = $args[0]; |
| 472 | $password = $args[1]; |
| 473 | |
| 474 | if ( !$user = $this->login($username, $password) ) |
| 475 | return $this->error; |
| 476 | |
| 477 | do_action( 'xmlrpc_call', 'wp.getUsersBlogs' ); |
| 478 | |
| 479 | $blogs = (array) get_blogs_of_user( $user->ID ); |
| 480 | $struct = array(); |
| 481 | |
| 482 | foreach ( $blogs as $blog ) { |
| 483 | // Don't include blogs that aren't hosted at this site |
| 484 | if ( $blog->site_id != $current_site->id ) |
| 485 | continue; |
| 486 | |
| Line | Code |
| 963 | |
| 964 | $blog_id = (int) $args[0]; |
| 965 | $username = $args[1]; |
| 966 | $password = $args[2]; |
| 967 | $content_struct = $args[3]; |
| 968 | |
| 969 | if ( ! $user = $this->login( $username, $password ) ) |
| 970 | return $this->error; |
| 971 | |
| 972 | do_action( 'xmlrpc_call', 'wp.newPost' ); |
| 973 | |
| 974 | unset( $content_struct['ID'] ); |
| 975 | |
| 976 | return $this->_insert_post( $user, $content_struct ); |
| 977 | } |
| 978 | |
| 979 | /** |
| 980 | * Helper method for filtering out elements from an array. |
| 981 | * |
| Line | Code |
| 1248 | $blog_id = (int) $args[0]; |
| 1249 | $username = $args[1]; |
| 1250 | $password = $args[2]; |
| 1251 | $post_id = (int) $args[3]; |
| 1252 | $content_struct = $args[4]; |
| 1253 | |
| 1254 | if ( ! $user = $this->login( $username, $password ) ) |
| 1255 | return $this->error; |
| 1256 | |
| 1257 | do_action( 'xmlrpc_call', 'wp.editPost' ); |
| 1258 | |
| 1259 | $post = get_post( $post_id, ARRAY_A ); |
| 1260 | |
| 1261 | if ( empty( $post['ID'] ) ) |
| 1262 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 1263 | |
| 1264 | if ( isset( $content_struct['if_not_modified_since'] ) ) { |
| 1265 | // If the post has been modified since the date provided, return an error. |
| 1266 | if ( mysql2date( 'U', $post['post_modified_gmt'] ) > $content_struct['if_not_modified_since']->getTimestamp() ) { |
| Line | Code |
| 1309 | |
| 1310 | $blog_id = (int) $args[0]; |
| 1311 | $username = $args[1]; |
| 1312 | $password = $args[2]; |
| 1313 | $post_id = (int) $args[3]; |
| 1314 | |
| 1315 | if ( ! $user = $this->login( $username, $password ) ) |
| 1316 | return $this->error; |
| 1317 | |
| 1318 | do_action( 'xmlrpc_call', 'wp.deletePost' ); |
| 1319 | |
| 1320 | $post = get_post( $post_id, ARRAY_A ); |
| 1321 | if ( empty( $post['ID'] ) ) |
| 1322 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 1323 | |
| 1324 | if ( ! current_user_can( 'delete_post', $post_id ) ) |
| 1325 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) ); |
| 1326 | |
| 1327 | $result = wp_delete_post( $post_id ); |
| Line | Code |
| 1389 | |
| 1390 | if ( isset( $args[4] ) ) |
| 1391 | $fields = $args[4]; |
| 1392 | else |
| 1393 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPost' ); |
| 1394 | |
| 1395 | if ( ! $user = $this->login( $username, $password ) ) |
| 1396 | return $this->error; |
| 1397 | |
| 1398 | do_action( 'xmlrpc_call', 'wp.getPost' ); |
| 1399 | |
| 1400 | $post = get_post( $post_id, ARRAY_A ); |
| 1401 | |
| 1402 | if ( empty( $post['ID'] ) ) |
| 1403 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 1404 | |
| 1405 | if ( ! current_user_can( 'edit_post', $post_id ) ) |
| 1406 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); |
| 1407 | |
| Line | Code |
| 1445 | |
| 1446 | if ( isset( $args[4] ) ) |
| 1447 | $fields = $args[4]; |
| 1448 | else |
| 1449 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPosts' ); |
| 1450 | |
| 1451 | if ( ! $user = $this->login( $username, $password ) ) |
| 1452 | return $this->error; |
| 1453 | |
| 1454 | do_action( 'xmlrpc_call', 'wp.getPosts' ); |
| 1455 | |
| 1456 | $query = array(); |
| 1457 | |
| 1458 | if ( isset( $filter['post_type'] ) ) { |
| 1459 | $post_type = get_post_type_object( $filter['post_type'] ); |
| 1460 | if ( ! ( (bool) $post_type ) ) |
| 1461 | return new IXR_Error( 403, __( 'The post type specified is not valid' ) ); |
| 1462 | } else { |
| 1463 | $post_type = get_post_type_object( 'post' ); |
| Line | Code |
| 1534 | |
| 1535 | $blog_id = (int) $args[0]; |
| 1536 | $username = $args[1]; |
| 1537 | $password = $args[2]; |
| 1538 | $content_struct = $args[3]; |
| 1539 | |
| 1540 | if ( ! $user = $this->login( $username, $password ) ) |
| 1541 | return $this->error; |
| 1542 | |
| 1543 | do_action( 'xmlrpc_call', 'wp.newTerm' ); |
| 1544 | |
| 1545 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) |
| 1546 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
| 1547 | |
| 1548 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
| 1549 | |
| 1550 | if ( ! current_user_can( $taxonomy->cap->manage_terms ) ) |
| 1551 | return new IXR_Error( 401, __( 'You are not allowed to create terms in this taxonomy.' ) ); |
| 1552 | |
| Line | Code |
| 1622 | $blog_id = (int) $args[0]; |
| 1623 | $username = $args[1]; |
| 1624 | $password = $args[2]; |
| 1625 | $term_id = (int) $args[3]; |
| 1626 | $content_struct = $args[4]; |
| 1627 | |
| 1628 | if ( ! $user = $this->login( $username, $password ) ) |
| 1629 | return $this->error; |
| 1630 | |
| 1631 | do_action( 'xmlrpc_call', 'wp.editTerm' ); |
| 1632 | |
| 1633 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) |
| 1634 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
| 1635 | |
| 1636 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
| 1637 | |
| 1638 | if ( ! current_user_can( $taxonomy->cap->edit_terms ) ) |
| 1639 | return new IXR_Error( 401, __( 'You are not allowed to edit terms in this taxonomy.' ) ); |
| 1640 | |
| Line | Code |
| 1714 | $blog_id = (int) $args[0]; |
| 1715 | $username = $args[1]; |
| 1716 | $password = $args[2]; |
| 1717 | $taxonomy = $args[3]; |
| 1718 | $term_id = (int) $args[4]; |
| 1719 | |
| 1720 | if ( ! $user = $this->login( $username, $password ) ) |
| 1721 | return $this->error; |
| 1722 | |
| 1723 | do_action( 'xmlrpc_call', 'wp.deleteTerm' ); |
| 1724 | |
| 1725 | if ( ! taxonomy_exists( $taxonomy ) ) |
| 1726 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
| 1727 | |
| 1728 | $taxonomy = get_taxonomy( $taxonomy ); |
| 1729 | |
| 1730 | if ( ! current_user_can( $taxonomy->cap->delete_terms ) ) |
| 1731 | return new IXR_Error( 401, __( 'You are not allowed to delete terms in this taxonomy.' ) ); |
| 1732 | |
| Line | Code |
| 1781 | $blog_id = (int) $args[0]; |
| 1782 | $username = $args[1]; |
| 1783 | $password = $args[2]; |
| 1784 | $taxonomy = $args[3]; |
| 1785 | $term_id = (int) $args[4]; |
| 1786 | |
| 1787 | if ( ! $user = $this->login( $username, $password ) ) |
| 1788 | return $this->error; |
| 1789 | |
| 1790 | do_action( 'xmlrpc_call', 'wp.getTerm' ); |
| 1791 | |
| 1792 | if ( ! taxonomy_exists( $taxonomy ) ) |
| 1793 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
| 1794 | |
| 1795 | $taxonomy = get_taxonomy( $taxonomy ); |
| 1796 | |
| 1797 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
| 1798 | return new IXR_Error( 401, __( 'You are not allowed to assign terms in this taxonomy.' ) ); |
| 1799 | |
| Line | Code |
| 1834 | $blog_id = (int) $args[0]; |
| 1835 | $username = $args[1]; |
| 1836 | $password = $args[2]; |
| 1837 | $taxonomy = $args[3]; |
| 1838 | $filter = isset( $args[4] ) ? $args[4] : array(); |
| 1839 | |
| 1840 | if ( ! $user = $this->login( $username, $password ) ) |
| 1841 | return $this->error; |
| 1842 | |
| 1843 | do_action( 'xmlrpc_call', 'wp.getTerms' ); |
| 1844 | |
| 1845 | if ( ! taxonomy_exists( $taxonomy ) ) |
| 1846 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
| 1847 | |
| 1848 | $taxonomy = get_taxonomy( $taxonomy ); |
| 1849 | |
| 1850 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
| 1851 | return new IXR_Error( 401, __( 'You are not allowed to assign terms in this taxonomy.' ) ); |
| 1852 | |
| Line | Code |
| 1913 | |
| 1914 | if ( isset( $args[4] ) ) |
| 1915 | $fields = $args[4]; |
| 1916 | else |
| 1917 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomy' ); |
| 1918 | |
| 1919 | if ( ! $user = $this->login( $username, $password ) ) |
| 1920 | return $this->error; |
| 1921 | |
| 1922 | do_action( 'xmlrpc_call', 'wp.getTaxonomy' ); |
| 1923 | |
| 1924 | if ( ! taxonomy_exists( $taxonomy ) ) |
| 1925 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
| 1926 | |
| 1927 | $taxonomy = get_taxonomy( $taxonomy ); |
| 1928 | |
| 1929 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
| 1930 | return new IXR_Error( 401, __( 'You are not allowed to assign terms in this taxonomy.' ) ); |
| 1931 | |
| Line | Code |
| 1957 | |
| 1958 | if ( isset( $args[4] ) ) |
| 1959 | $fields = $args[4]; |
| 1960 | else |
| 1961 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomies' ); |
| 1962 | |
| 1963 | if ( ! $user = $this->login( $username, $password ) ) |
| 1964 | return $this->error; |
| 1965 | |
| 1966 | do_action( 'xmlrpc_call', 'wp.getTaxonomies' ); |
| 1967 | |
| 1968 | $taxonomies = get_taxonomies( $filter, 'objects' ); |
| 1969 | |
| 1970 | // holds all the taxonomy data |
| 1971 | $struct = array(); |
| 1972 | |
| 1973 | foreach ( $taxonomies as $taxonomy ) { |
| 1974 | // capability check for post_types |
| 1975 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
| Line | Code |
| 2026 | |
| 2027 | if ( isset( $args[4] ) ) |
| 2028 | $fields = $args[4]; |
| 2029 | else |
| 2030 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUser' ); |
| 2031 | |
| 2032 | if ( ! $user = $this->login( $username, $password ) ) |
| 2033 | return $this->error; |
| 2034 | |
| 2035 | do_action( 'xmlrpc_call', 'wp.getUser' ); |
| 2036 | |
| 2037 | if ( ! current_user_can( 'edit_user', $user_id ) ) |
| 2038 | return new IXR_Error( 401, __( 'Sorry, you cannot edit users.' ) ); |
| 2039 | |
| 2040 | $user_data = get_userdata( $user_id ); |
| 2041 | |
| 2042 | if ( ! $user_data ) |
| 2043 | return new IXR_Error( 404, __( 'Invalid user ID' ) ); |
| 2044 | |
| Line | Code |
| 2079 | |
| 2080 | if ( isset( $args[4] ) ) |
| 2081 | $fields = $args[4]; |
| 2082 | else |
| 2083 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUsers' ); |
| 2084 | |
| 2085 | if ( ! $user = $this->login( $username, $password ) ) |
| 2086 | return $this->error; |
| 2087 | |
| 2088 | do_action( 'xmlrpc_call', 'wp.getUsers' ); |
| 2089 | |
| 2090 | if ( ! current_user_can( 'list_users' ) ) |
| 2091 | return new IXR_Error( 401, __( 'Sorry, you cannot list users.' ) ); |
| 2092 | |
| 2093 | $query = array( 'fields' => 'all_with_meta' ); |
| 2094 | |
| 2095 | $query['number'] = ( isset( $filter['number'] ) ) ? absint( $filter['number'] ) : 50; |
| 2096 | $query['offset'] = ( isset( $filter['offset'] ) ) ? absint( $filter['offset'] ) : 0; |
| 2097 | |
| Line | Code |
| 2146 | |
| 2147 | if ( isset( $args[3] ) ) |
| 2148 | $fields = $args[3]; |
| 2149 | else |
| 2150 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getProfile' ); |
| 2151 | |
| 2152 | if ( ! $user = $this->login( $username, $password ) ) |
| 2153 | return $this->error; |
| 2154 | |
| 2155 | do_action( 'xmlrpc_call', 'wp.getProfile' ); |
| 2156 | |
| 2157 | if ( ! current_user_can( 'edit_user', $user->ID ) ) |
| 2158 | return new IXR_Error( 401, __( 'Sorry, you cannot edit your profile.' ) ); |
| 2159 | |
| 2160 | $user_data = get_userdata( $user->ID ); |
| 2161 | |
| 2162 | return $this->_prepare_user( $user_data, $fields ); |
| 2163 | } |
| 2164 | |
| Line | Code |
| 2189 | |
| 2190 | $blog_id = (int) $args[0]; |
| 2191 | $username = $args[1]; |
| 2192 | $password = $args[2]; |
| 2193 | $content_struct = $args[3]; |
| 2194 | |
| 2195 | if ( ! $user = $this->login( $username, $password ) ) |
| 2196 | return $this->error; |
| 2197 | |
| 2198 | do_action( 'xmlrpc_call', 'wp.editProfile' ); |
| 2199 | |
| 2200 | if ( ! current_user_can( 'edit_user', $user->ID ) ) |
| 2201 | return new IXR_Error( 401, __( 'Sorry, you cannot edit your profile.' ) ); |
| 2202 | |
| 2203 | // holds data of the user |
| 2204 | $user_data = array(); |
| 2205 | $user_data['ID'] = $user->ID; |
| 2206 | |
| 2207 | // only set the user details if it was given |
| Line | Code |
| 2262 | } |
| 2263 | |
| 2264 | $page = get_post($page_id); |
| 2265 | if ( ! $page ) |
| 2266 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 2267 | |
| 2268 | if ( !current_user_can( 'edit_page', $page_id ) ) |
| 2269 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this page.' ) ); |
| 2270 | |
| 2271 | do_action('xmlrpc_call', 'wp.getPage'); |
| 2272 | |
| 2273 | // If we found the page then format the data. |
| 2274 | if ( $page->ID && ($page->post_type == 'page') ) { |
| 2275 | return $this->_prepare_page( $page ); |
| 2276 | } |
| 2277 | // If the page doesn't exist indicate that. |
| 2278 | else { |
| 2279 | return(new IXR_Error(404, __('Sorry, no such page.'))); |
| 2280 | } |
| Line | Code |
| 2300 | $password = $args[2]; |
| 2301 | $num_pages = isset($args[3]) ? (int) $args[3] : 10; |
| 2302 | |
| 2303 | if ( !$user = $this->login($username, $password) ) |
| 2304 | return $this->error; |
| 2305 | |
| 2306 | if ( !current_user_can( 'edit_pages' ) ) |
| 2307 | return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) ); |
| 2308 | |
| 2309 | do_action('xmlrpc_call', 'wp.getPages'); |
| 2310 | |
| 2311 | $pages = get_posts( array('post_type' => 'page', 'post_status' => 'any', 'numberposts' => $num_pages) ); |
| 2312 | $num_pages = count($pages); |
| 2313 | |
| 2314 | // If we have pages, put together their info. |
| 2315 | if ( $num_pages >= 1 ) { |
| 2316 | $pages_struct = array(); |
| 2317 | |
| 2318 | foreach ($pages as $page) { |
| Line | Code |
| 2340 | // Items not escaped here will be escaped in newPost. |
| 2341 | $username = $this->escape($args[1]); |
| 2342 | $password = $this->escape($args[2]); |
| 2343 | $page = $args[3]; |
| 2344 | $publish = $args[4]; |
| 2345 | |
| 2346 | if ( !$user = $this->login($username, $password) ) |
| 2347 | return $this->error; |
| 2348 | |
| 2349 | do_action('xmlrpc_call', 'wp.newPage'); |
| 2350 | |
| 2351 | // Mark this as content for a page. |
| 2352 | $args[3]["post_type"] = 'page'; |
| 2353 | |
| 2354 | // Let mw_newPost do all of the heavy lifting. |
| 2355 | return($this->mw_newPost($args)); |
| 2356 | } |
| 2357 | |
| 2358 | /** |
| Line | Code |
| 2368 | |
| 2369 | $blog_id = (int) $args[0]; |
| 2370 | $username = $args[1]; |
| 2371 | $password = $args[2]; |
| 2372 | $page_id = (int) $args[3]; |
| 2373 | |
| 2374 | if ( !$user = $this->login($username, $password) ) |
| 2375 | return $this->error; |
| 2376 | |
| 2377 | do_action('xmlrpc_call', 'wp.deletePage'); |
| 2378 | |
| 2379 | // Get the current page based on the page_id and |
| 2380 | // make sure it is a page and not a post. |
| 2381 | $actual_page = get_post($page_id, ARRAY_A); |
| 2382 | if ( !$actual_page || ($actual_page['post_type'] != 'page') ) |
| 2383 | return(new IXR_Error(404, __('Sorry, no such page.'))); |
| 2384 | |
| 2385 | // Make sure the user can delete pages. |
| 2386 | if ( !current_user_can('delete_page', $page_id) ) |
| Line | Code |
| 2410 | $page_id = (int) $this->escape($args[1]); |
| 2411 | $username = $this->escape($args[2]); |
| 2412 | $password = $this->escape($args[3]); |
| 2413 | $content = $args[4]; |
| 2414 | $publish = $args[5]; |
| 2415 | |
| 2416 | if ( !$user = $this->login($username, $password) ) |
| 2417 | return $this->error; |
| 2418 | |
| 2419 | do_action('xmlrpc_call', 'wp.editPage'); |
| 2420 | |
| 2421 | // Get the page data and make sure it is a page. |
| 2422 | $actual_page = get_post($page_id, ARRAY_A); |
| 2423 | if ( !$actual_page || ($actual_page['post_type'] != 'page') ) |
| 2424 | return(new IXR_Error(404, __('Sorry, no such page.'))); |
| 2425 | |
| 2426 | // Make sure the user is allowed to edit pages. |
| 2427 | if ( !current_user_can('edit_page', $page_id) ) |
| 2428 | return(new IXR_Error(401, __('Sorry, you do not have the right to edit this page.'))); |
| Line | Code |
| 2460 | $username = $args[1]; |
| 2461 | $password = $args[2]; |
| 2462 | |
| 2463 | if ( !$user = $this->login($username, $password) ) |
| 2464 | return $this->error; |
| 2465 | |
| 2466 | if ( !current_user_can( 'edit_pages' ) ) |
| 2467 | return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) ); |
| 2468 | |
| 2469 | do_action('xmlrpc_call', 'wp.getPageList'); |
| 2470 | |
| 2471 | // Get list of pages ids and titles |
| 2472 | $page_list = $wpdb->get_results(" |
| 2473 | SELECT ID page_id, |
| 2474 | post_title page_title, |
| 2475 | post_parent page_parent_id, |
| 2476 | post_date_gmt, |
| 2477 | post_date, |
| 2478 | post_status |
| Line | Code |
| 2511 | $username = $args[1]; |
| 2512 | $password = $args[2]; |
| 2513 | |
| 2514 | if ( !$user = $this->login($username, $password) ) |
| 2515 | return $this->error; |
| 2516 | |
| 2517 | if ( !current_user_can('edit_posts') ) |
| 2518 | return(new IXR_Error(401, __('Sorry, you cannot edit posts on this site.'))); |
| 2519 | |
| 2520 | do_action('xmlrpc_call', 'wp.getAuthors'); |
| 2521 | |
| 2522 | $authors = array(); |
| 2523 | foreach ( get_users( array( 'fields' => array('ID','user_login','display_name') ) ) as $user ) { |
| 2524 | $authors[] = array( |
| 2525 | 'user_id' => $user->ID, |
| 2526 | 'user_login' => $user->user_login, |
| 2527 | 'display_name' => $user->display_name |
| 2528 | ); |
| 2529 | } |
| Line | Code |
| 2546 | $username = $args[1]; |
| 2547 | $password = $args[2]; |
| 2548 | |
| 2549 | if ( !$user = $this->login($username, $password) ) |
| 2550 | return $this->error; |
| 2551 | |
| 2552 | if ( !current_user_can( 'edit_posts' ) ) |
| 2553 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view tags.' ) ); |
| 2554 | |
| 2555 | do_action( 'xmlrpc_call', 'wp.getKeywords' ); |
| 2556 | |
| 2557 | $tags = array(); |
| 2558 | |
| 2559 | if ( $all_tags = get_tags() ) { |
| 2560 | foreach( (array) $all_tags as $tag ) { |
| 2561 | $struct['tag_id'] = $tag->term_id; |
| 2562 | $struct['name'] = $tag->name; |
| 2563 | $struct['count'] = $tag->count; |
| 2564 | $struct['slug'] = $tag->slug; |
| Line | Code |
| 2585 | |
| 2586 | $blog_id = (int) $args[0]; |
| 2587 | $username = $args[1]; |
| 2588 | $password = $args[2]; |
| 2589 | $category = $args[3]; |
| 2590 | |
| 2591 | if ( !$user = $this->login($username, $password) ) |
| 2592 | return $this->error; |
| 2593 | |
| 2594 | do_action('xmlrpc_call', 'wp.newCategory'); |
| 2595 | |
| 2596 | // Make sure the user is allowed to add a category. |
| 2597 | if ( !current_user_can('manage_categories') ) |
| 2598 | return(new IXR_Error(401, __('Sorry, you do not have the right to add a category.'))); |
| 2599 | |
| 2600 | // If no slug was provided make it empty so that |
| 2601 | // WordPress will generate one. |
| 2602 | if ( empty($category['slug']) ) |
| 2603 | $category['slug'] = ''; |
| Line | Code |
| 2646 | |
| 2647 | $blog_id = (int) $args[0]; |
| 2648 | $username = $args[1]; |
| 2649 | $password = $args[2]; |
| 2650 | $category_id = (int) $args[3]; |
| 2651 | |
| 2652 | if ( !$user = $this->login($username, $password) ) |
| 2653 | return $this->error; |
| 2654 | |
| 2655 | do_action('xmlrpc_call', 'wp.deleteCategory'); |
| 2656 | |
| 2657 | if ( !current_user_can('manage_categories') ) |
| 2658 | return new IXR_Error( 401, __( 'Sorry, you do not have the right to delete a category.' ) ); |
| 2659 | |
| 2660 | $status = wp_delete_term( $category_id, 'category' ); |
| 2661 | |
| 2662 | if( true == $status ) |
| 2663 | do_action( 'xmlrpc_call_success_wp_deleteCategory', $category_id, $args ); |
| 2664 | |
| Line | Code |
| 2682 | $category = $args[3]; |
| 2683 | $max_results = (int) $args[4]; |
| 2684 | |
| 2685 | if ( !$user = $this->login($username, $password) ) |
| 2686 | return $this->error; |
| 2687 | |
| 2688 | if ( !current_user_can( 'edit_posts' ) ) |
| 2689 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts to this site in order to view categories.' ) ); |
| 2690 | |
| 2691 | do_action('xmlrpc_call', 'wp.suggestCategories'); |
| 2692 | |
| 2693 | $category_suggestions = array(); |
| 2694 | $args = array('get' => 'all', 'number' => $max_results, 'name__like' => $category); |
| 2695 | foreach ( (array) get_categories($args) as $cat ) { |
| 2696 | $category_suggestions[] = array( |
| 2697 | 'category_id' => $cat->term_id, |
| 2698 | 'category_name' => $cat->name |
| 2699 | ); |
| 2700 | } |
| Line | Code |
| 2718 | $password = $args[2]; |
| 2719 | $comment_id = (int) $args[3]; |
| 2720 | |
| 2721 | if ( !$user = $this->login($username, $password) ) |
| 2722 | return $this->error; |
| 2723 | |
| 2724 | if ( !current_user_can( 'moderate_comments' ) ) |
| 2725 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
| 2726 | |
| 2727 | do_action('xmlrpc_call', 'wp.getComment'); |
| 2728 | |
| 2729 | if ( ! $comment = get_comment($comment_id) ) |
| 2730 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 2731 | |
| 2732 | return $this->_prepare_comment( $comment ); |
| 2733 | } |
| 2734 | |
| 2735 | /** |
| 2736 | * Retrieve comments. |
| Line | Code |
| 2759 | $password = $args[2]; |
| 2760 | $struct = isset( $args[3] ) ? $args[3] : array(); |
| 2761 | |
| 2762 | if ( !$user = $this->login($username, $password) ) |
| 2763 | return $this->error; |
| 2764 | |
| 2765 | if ( !current_user_can( 'moderate_comments' ) ) |
| 2766 | return new IXR_Error( 401, __( 'Sorry, you cannot edit comments.' ) ); |
| 2767 | |
| 2768 | do_action('xmlrpc_call', 'wp.getComments'); |
| 2769 | |
| 2770 | if ( isset($struct['status']) ) |
| 2771 | $status = $struct['status']; |
| 2772 | else |
| 2773 | $status = ''; |
| 2774 | |
| 2775 | $post_id = ''; |
| 2776 | if ( isset($struct['post_id']) ) |
| 2777 | $post_id = absint($struct['post_id']); |
| Line | Code |
| 2825 | if ( !current_user_can( 'moderate_comments' ) ) |
| 2826 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
| 2827 | |
| 2828 | if ( ! get_comment($comment_ID) ) |
| 2829 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 2830 | |
| 2831 | if ( !current_user_can( 'edit_comment', $comment_ID ) ) |
| 2832 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
| 2833 | |
| 2834 | do_action('xmlrpc_call', 'wp.deleteComment'); |
| 2835 | |
| 2836 | $status = wp_delete_comment( $comment_ID ); |
| 2837 | |
| 2838 | if( true == $status ) |
| 2839 | do_action( 'xmlrpc_call_success_wp_deleteComment', $comment_ID, $args ); |
| 2840 | |
| 2841 | return $status; |
| 2842 | } |
| 2843 | |
| Line | Code |
| 2880 | if ( !current_user_can( 'moderate_comments' ) ) |
| 2881 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
| 2882 | |
| 2883 | if ( ! get_comment($comment_ID) ) |
| 2884 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 2885 | |
| 2886 | if ( !current_user_can( 'edit_comment', $comment_ID ) ) |
| 2887 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
| 2888 | |
| 2889 | do_action('xmlrpc_call', 'wp.editComment'); |
| 2890 | |
| 2891 | if ( isset($content_struct['status']) ) { |
| 2892 | $statuses = get_comment_statuses(); |
| 2893 | $statuses = array_keys($statuses); |
| 2894 | |
| 2895 | if ( ! in_array($content_struct['status'], $statuses) ) |
| 2896 | return new IXR_Error( 401, __( 'Invalid comment status.' ) ); |
| 2897 | $comment_approved = $content_struct['status']; |
| 2898 | } |
| Line | Code |
| 3004 | elseif ( !is_email($comment['comment_author_email']) ) |
| 3005 | return new IXR_Error( 403, __( 'A valid email address is required' ) ); |
| 3006 | } |
| 3007 | } |
| 3008 | |
| 3009 | $comment['comment_parent'] = isset($content_struct['comment_parent']) ? absint($content_struct['comment_parent']) : 0; |
| 3010 | |
| 3011 | $comment['comment_content'] = isset($content_struct['content']) ? $content_struct['content'] : null; |
| 3012 | |
| 3013 | do_action('xmlrpc_call', 'wp.newComment'); |
| 3014 | |
| 3015 | $comment_ID = wp_new_comment( $comment ); |
| 3016 | |
| 3017 | do_action( 'xmlrpc_call_success_wp_newComment', $comment_ID, $args ); |
| 3018 | |
| 3019 | return $comment_ID; |
| 3020 | } |
| 3021 | |
| 3022 | /** |
| Line | Code |
| 3034 | $username = $args[1]; |
| 3035 | $password = $args[2]; |
| 3036 | |
| 3037 | if ( !$user = $this->login($username, $password) ) |
| 3038 | return $this->error; |
| 3039 | |
| 3040 | if ( !current_user_can( 'moderate_comments' ) ) |
| 3041 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
| 3042 | |
| 3043 | do_action('xmlrpc_call', 'wp.getCommentStatusList'); |
| 3044 | |
| 3045 | return get_comment_statuses(); |
| 3046 | } |
| 3047 | |
| 3048 | /** |
| 3049 | * Retrieve comment count. |
| 3050 | * |
| 3051 | * @since 2.5.0 |
| 3052 | * |
| Line | Code |
| 3061 | $password = $args[2]; |
| 3062 | $post_id = (int) $args[3]; |
| 3063 | |
| 3064 | if ( !$user = $this->login($username, $password) ) |
| 3065 | return $this->error; |
| 3066 | |
| 3067 | if ( !current_user_can( 'edit_posts' ) ) |
| 3068 | return new IXR_Error( 403, __( 'You are not allowed access to details about comments.' ) ); |
| 3069 | |
| 3070 | do_action('xmlrpc_call', 'wp.getCommentCount'); |
| 3071 | |
| 3072 | $count = wp_count_comments( $post_id ); |
| 3073 | return array( |
| 3074 | 'approved' => $count->approved, |
| 3075 | 'awaiting_moderation' => $count->moderated, |
| 3076 | 'spam' => $count->spam, |
| 3077 | 'total_comments' => $count->total_comments |
| 3078 | ); |
| 3079 | } |
| Line | Code |
| 3093 | $username = $args[1]; |
| 3094 | $password = $args[2]; |
| 3095 | |
| 3096 | if ( !$user = $this->login($username, $password) ) |
| 3097 | return $this->error; |
| 3098 | |
| 3099 | if ( !current_user_can( 'edit_posts' ) ) |
| 3100 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
| 3101 | |
| 3102 | do_action('xmlrpc_call', 'wp.getPostStatusList'); |
| 3103 | |
| 3104 | return get_post_statuses(); |
| 3105 | } |
| 3106 | |
| 3107 | /** |
| 3108 | * Retrieve page statuses. |
| 3109 | * |
| 3110 | * @since 2.5.0 |
| 3111 | * |
| Line | Code |
| 3119 | $username = $args[1]; |
| 3120 | $password = $args[2]; |
| 3121 | |
| 3122 | if ( !$user = $this->login($username, $password) ) |
| 3123 | return $this->error; |
| 3124 | |
| 3125 | if ( !current_user_can( 'edit_pages' ) ) |
| 3126 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
| 3127 | |
| 3128 | do_action('xmlrpc_call', 'wp.getPageStatusList'); |
| 3129 | |
| 3130 | return get_page_statuses(); |
| 3131 | } |
| 3132 | |
| 3133 | /** |
| 3134 | * Retrieve page templates. |
| 3135 | * |
| 3136 | * @since 2.6.0 |
| 3137 | * |
| Line | Code |
| 3276 | $password = $args[2]; |
| 3277 | $attachment_id = (int) $args[3]; |
| 3278 | |
| 3279 | if ( !$user = $this->login($username, $password) ) |
| 3280 | return $this->error; |
| 3281 | |
| 3282 | if ( !current_user_can( 'upload_files' ) ) |
| 3283 | return new IXR_Error( 403, __( 'You do not have permission to upload files.' ) ); |
| 3284 | |
| 3285 | do_action('xmlrpc_call', 'wp.getMediaItem'); |
| 3286 | |
| 3287 | if ( ! $attachment = get_post($attachment_id) ) |
| 3288 | return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); |
| 3289 | |
| 3290 | return $this->_prepare_media_item( $attachment ); |
| 3291 | } |
| 3292 | |
| 3293 | /** |
| 3294 | * Retrieves a collection of media library items (or attachments) |
| Line | Code |
| 3321 | $password = $args[2]; |
| 3322 | $struct = isset( $args[3] ) ? $args[3] : array() ; |
| 3323 | |
| 3324 | if ( !$user = $this->login($username, $password) ) |
| 3325 | return $this->error; |
| 3326 | |
| 3327 | if ( !current_user_can( 'upload_files' ) ) |
| 3328 | return new IXR_Error( 401, __( 'You do not have permission to upload files.' ) ); |
| 3329 | |
| 3330 | do_action('xmlrpc_call', 'wp.getMediaLibrary'); |
| 3331 | |
| 3332 | $parent_id = ( isset($struct['parent_id']) ) ? absint($struct['parent_id']) : '' ; |
| 3333 | $mime_type = ( isset($struct['mime_type']) ) ? $struct['mime_type'] : '' ; |
| 3334 | $offset = ( isset($struct['offset']) ) ? absint($struct['offset']) : 0 ; |
| 3335 | $number = ( isset($struct['number']) ) ? absint($struct['number']) : -1 ; |
| 3336 | |
| 3337 | $attachments = get_posts( array('post_type' => 'attachment', 'post_parent' => $parent_id, 'offset' => $offset, 'numberposts' => $number, 'post_mime_type' => $mime_type ) ); |
| 3338 | |
| 3339 | $attachments_struct = array(); |
| Line | Code |
| 3362 | $username = $args[1]; |
| 3363 | $password = $args[2]; |
| 3364 | |
| 3365 | if ( !$user = $this->login( $username, $password ) ) |
| 3366 | return $this->error; |
| 3367 | |
| 3368 | if ( !current_user_can( 'edit_posts' ) ) |
| 3369 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
| 3370 | |
| 3371 | do_action( 'xmlrpc_call', 'wp.getPostFormats' ); |
| 3372 | |
| 3373 | $formats = get_post_format_strings(); |
| 3374 | |
| 3375 | # find out if they want a list of currently supports formats |
| 3376 | if ( isset( $args[3] ) && is_array( $args[3] ) ) { |
| 3377 | if ( $args[3]['show-supported'] ) { |
| 3378 | if ( current_theme_supports( 'post-formats' ) ) { |
| 3379 | $supported = get_theme_support( 'post-formats' ); |
| 3380 | |
| Line | Code |
| 3425 | |
| 3426 | if ( isset( $args[4] ) ) |
| 3427 | $fields = $args[4]; |
| 3428 | else |
| 3429 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostType' ); |
| 3430 | |
| 3431 | if ( !$user = $this->login( $username, $password ) ) |
| 3432 | return $this->error; |
| 3433 | |
| 3434 | do_action( 'xmlrpc_call', 'wp.getPostType' ); |
| 3435 | |
| 3436 | if( ! post_type_exists( $post_type_name ) ) |
| 3437 | return new IXR_Error( 403, __( 'Invalid post type' ) ); |
| 3438 | |
| 3439 | $post_type = get_post_type_object( $post_type_name ); |
| 3440 | |
| 3441 | if( ! current_user_can( $post_type->cap->edit_posts ) ) |
| 3442 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post type.' ) ); |
| 3443 | |
| Line | Code |
| 3471 | |
| 3472 | if ( isset( $args[4] ) ) |
| 3473 | $fields = $args[4]; |
| 3474 | else |
| 3475 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostTypes' ); |
| 3476 | |
| 3477 | if ( ! $user = $this->login( $username, $password ) ) |
| 3478 | return $this->error; |
| 3479 | |
| 3480 | do_action( 'xmlrpc_call', 'wp.getPostTypes' ); |
| 3481 | |
| 3482 | $post_types = get_post_types( $filter, 'objects' ); |
| 3483 | |
| 3484 | $struct = array(); |
| 3485 | |
| 3486 | foreach( $post_types as $post_type ) { |
| 3487 | if( ! current_user_can( $post_type->cap->edit_posts ) ) |
| 3488 | continue; |
| 3489 | |
| Line | Code |
| 3525 | |
| 3526 | if ( isset( $args[4] ) ) |
| 3527 | $fields = $args[4]; |
| 3528 | else |
| 3529 | $fields = apply_filters( 'xmlrpc_default_revision_fields', array( 'post_date', 'post_date_gmt' ), 'wp.getRevisions' ); |
| 3530 | |
| 3531 | if ( ! $user = $this->login( $username, $password ) ) |
| 3532 | return $this->error; |
| 3533 | |
| 3534 | do_action( 'xmlrpc_call', 'wp.getRevisions' ); |
| 3535 | |
| 3536 | if ( ! $post = get_post( $post_id ) ) |
| 3537 | return new IXR_Error( 404, __( 'Invalid post ID' ) ); |
| 3538 | |
| 3539 | if ( ! current_user_can( 'edit_post', $post_id ) ) |
| 3540 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
| 3541 | |
| 3542 | // Check if revisions are enabled. |
| 3543 | if ( ! wp_revisions_enabled( $post ) ) |
| Line | Code |
| 3586 | |
| 3587 | $blog_id = (int) $args[0]; |
| 3588 | $username = $args[1]; |
| 3589 | $password = $args[2]; |
| 3590 | $revision_id = (int) $args[3]; |
| 3591 | |
| 3592 | if ( ! $user = $this->login( $username, $password ) ) |
| 3593 | return $this->error; |
| 3594 | |
| 3595 | do_action( 'xmlrpc_call', 'wp.restoreRevision' ); |
| 3596 | |
| 3597 | if ( ! $revision = wp_get_post_revision( $revision_id ) ) |
| 3598 | return new IXR_Error( 404, __( 'Invalid post ID' ) ); |
| 3599 | |
| 3600 | if ( wp_is_post_autosave( $revision ) ) |
| 3601 | return new IXR_Error( 404, __( 'Invalid post ID' ) ); |
| 3602 | |
| 3603 | if ( ! $post = get_post( $revision->post_parent ) ) |
| 3604 | return new IXR_Error( 404, __( 'Invalid post ID' ) ); |
| Line | Code |
| 3635 | |
| 3636 | $this->escape($args); |
| 3637 | |
| 3638 | $username = $args[1]; |
| 3639 | $password = $args[2]; |
| 3640 | |
| 3641 | if ( !$user = $this->login($username, $password) ) |
| 3642 | return $this->error; |
| 3643 | |
| 3644 | do_action('xmlrpc_call', 'blogger.getUsersBlogs'); |
| 3645 | |
| 3646 | $is_admin = current_user_can('manage_options'); |
| 3647 | |
| 3648 | $struct = array( |
| 3649 | 'isAdmin' => $is_admin, |
| 3650 | 'url' => get_option('home') . '/', |
| 3651 | 'blogid' => '1', |
| 3652 | 'blogName' => get_option('blogname'), |
| 3653 | 'xmlrpc' => site_url( 'xmlrpc.php', 'rpc' ), |
| Line | Code |
| 3702 | $username = $args[1]; |
| 3703 | $password = $args[2]; |
| 3704 | |
| 3705 | if ( !$user = $this->login($username, $password) ) |
| 3706 | return $this->error; |
| 3707 | |
| 3708 | if ( !current_user_can( 'edit_posts' ) ) |
| 3709 | return new IXR_Error( 401, __( 'Sorry, you do not have access to user data on this site.' ) ); |
| 3710 | |
| 3711 | do_action('xmlrpc_call', 'blogger.getUserInfo'); |
| 3712 | |
| 3713 | $struct = array( |
| 3714 | 'nickname' => $user->nickname, |
| 3715 | 'userid' => $user->ID, |
| 3716 | 'url' => $user->user_url, |
| 3717 | 'lastname' => $user->last_name, |
| 3718 | 'firstname' => $user->first_name |
| 3719 | ); |
| 3720 | |
| Line | Code |
| 3741 | return $this->error; |
| 3742 | |
| 3743 | $post_data = get_post($post_ID, ARRAY_A); |
| 3744 | if ( ! $post_data ) |
| 3745 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 3746 | |
| 3747 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
| 3748 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); |
| 3749 | |
| 3750 | do_action('xmlrpc_call', 'blogger.getPost'); |
| 3751 | |
| 3752 | $categories = implode(',', wp_get_post_categories($post_ID)); |
| 3753 | |
| 3754 | $content = '<title>'.wp_unslash($post_data['post_title']).'</title>'; |
| 3755 | $content .= '<category>'.$categories.'</category>'; |
| 3756 | $content .= wp_unslash($post_data['post_content']); |
| 3757 | |
| 3758 | $struct = array( |
| 3759 | 'userid' => $post_data['post_author'], |
| Line | Code |
| 3786 | else |
| 3787 | $query = array(); |
| 3788 | |
| 3789 | if ( !$user = $this->login($username, $password) ) |
| 3790 | return $this->error; |
| 3791 | |
| 3792 | if ( ! current_user_can( 'edit_posts' ) ) |
| 3793 | return new IXR_Error( 401, __( 'Sorry, you cannot edit posts on this site.' ) ); |
| 3794 | |
| 3795 | do_action('xmlrpc_call', 'blogger.getRecentPosts'); |
| 3796 | |
| 3797 | $posts_list = wp_get_recent_posts( $query ); |
| 3798 | |
| 3799 | if ( !$posts_list ) { |
| 3800 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
| 3801 | return $this->error; |
| 3802 | } |
| 3803 | |
| 3804 | foreach ($posts_list as $entry) { |
| Line | Code |
| 3864 | $blog_ID = (int) $args[1]; /* though we don't use it yet */ |
| 3865 | $username = $args[2]; |
| 3866 | $password = $args[3]; |
| 3867 | $content = $args[4]; |
| 3868 | $publish = $args[5]; |
| 3869 | |
| 3870 | if ( !$user = $this->login($username, $password) ) |
| 3871 | return $this->error; |
| 3872 | |
| 3873 | do_action('xmlrpc_call', 'blogger.newPost'); |
| 3874 | |
| 3875 | $cap = ($publish) ? 'publish_posts' : 'edit_posts'; |
| 3876 | if ( ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) || !current_user_can($cap) ) |
| 3877 | return new IXR_Error(401, __('Sorry, you are not allowed to post on this site.')); |
| 3878 | |
| 3879 | $post_status = ($publish) ? 'publish' : 'draft'; |
| 3880 | |
| 3881 | $post_author = $user->ID; |
| 3882 | |
| Line | Code |
| 3918 | $post_ID = (int) $args[1]; |
| 3919 | $username = $args[2]; |
| 3920 | $password = $args[3]; |
| 3921 | $content = $args[4]; |
| 3922 | $publish = $args[5]; |
| 3923 | |
| 3924 | if ( !$user = $this->login($username, $password) ) |
| 3925 | return $this->error; |
| 3926 | |
| 3927 | do_action('xmlrpc_call', 'blogger.editPost'); |
| 3928 | |
| 3929 | $actual_post = get_post($post_ID,ARRAY_A); |
| 3930 | |
| 3931 | if ( !$actual_post || $actual_post['post_type'] != 'post' ) |
| 3932 | return new IXR_Error(404, __('Sorry, no such post.')); |
| 3933 | |
| 3934 | $this->escape($actual_post); |
| 3935 | |
| 3936 | if ( !current_user_can('edit_post', $post_ID) ) |
| Line | Code |
| 3972 | |
| 3973 | $post_ID = (int) $args[1]; |
| 3974 | $username = $args[2]; |
| 3975 | $password = $args[3]; |
| 3976 | $publish = $args[4]; |
| 3977 | |
| 3978 | if ( !$user = $this->login($username, $password) ) |
| 3979 | return $this->error; |
| 3980 | |
| 3981 | do_action('xmlrpc_call', 'blogger.deletePost'); |
| 3982 | |
| 3983 | $actual_post = get_post($post_ID,ARRAY_A); |
| 3984 | |
| 3985 | if ( !$actual_post || $actual_post['post_type'] != 'post' ) |
| 3986 | return new IXR_Error(404, __('Sorry, no such post.')); |
| 3987 | |
| 3988 | if ( !current_user_can('delete_post', $post_ID) ) |
| 3989 | return new IXR_Error(401, __('Sorry, you do not have the right to delete this post.')); |
| 3990 | |
| Line | Code |
| 4043 | $blog_ID = (int) $args[0]; |
| 4044 | $username = $args[1]; |
| 4045 | $password = $args[2]; |
| 4046 | $content_struct = $args[3]; |
| 4047 | $publish = isset( $args[4] ) ? $args[4] : 0; |
| 4048 | |
| 4049 | if ( !$user = $this->login($username, $password) ) |
| 4050 | return $this->error; |
| 4051 | |
| 4052 | do_action('xmlrpc_call', 'metaWeblog.newPost'); |
| 4053 | |
| 4054 | $page_template = ''; |
| 4055 | if ( !empty( $content_struct['post_type'] ) ) { |
| 4056 | if ( $content_struct['post_type'] == 'page' ) { |
| 4057 | if ( $publish ) |
| 4058 | $cap = 'publish_pages'; |
| 4059 | elseif ( isset( $content_struct['page_status'] ) && 'publish' == $content_struct['page_status'] ) |
| 4060 | $cap = 'publish_pages'; |
| 4061 | else |
| Line | Code |
| 4362 | $post_ID = (int) $args[0]; |
| 4363 | $username = $args[1]; |
| 4364 | $password = $args[2]; |
| 4365 | $content_struct = $args[3]; |
| 4366 | $publish = isset( $args[4] ) ? $args[4] : 0; |
| 4367 | |
| 4368 | if ( ! $user = $this->login($username, $password) ) |
| 4369 | return $this->error; |
| 4370 | |
| 4371 | do_action('xmlrpc_call', 'metaWeblog.editPost'); |
| 4372 | |
| 4373 | $postdata = get_post( $post_ID, ARRAY_A ); |
| 4374 | |
| 4375 | // If there is no post data for the give post id, stop |
| 4376 | // now and return an error. Other wise a new post will be |
| 4377 | // created (which was the old behavior). |
| 4378 | if ( ! $postdata || empty( $postdata[ 'ID' ] ) ) |
| 4379 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4380 | |
| Line | Code |
| 4636 | return $this->error; |
| 4637 | |
| 4638 | $postdata = get_post($post_ID, ARRAY_A); |
| 4639 | if ( ! $postdata ) |
| 4640 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4641 | |
| 4642 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
| 4643 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); |
| 4644 | |
| 4645 | do_action('xmlrpc_call', 'metaWeblog.getPost'); |
| 4646 | |
| 4647 | if ($postdata['post_date'] != '') { |
| 4648 | $post_date = $this->_convert_date( $postdata['post_date'] ); |
| 4649 | $post_date_gmt = $this->_convert_date_gmt( $postdata['post_date_gmt'], $postdata['post_date'] ); |
| 4650 | $post_modified = $this->_convert_date( $postdata['post_modified'] ); |
| 4651 | $post_modified_gmt = $this->_convert_date_gmt( $postdata['post_modified_gmt'], $postdata['post_modified'] ); |
| 4652 | |
| 4653 | $categories = array(); |
| 4654 | $catids = wp_get_post_categories($post_ID); |
| Line | Code |
| 4760 | else |
| 4761 | $query = array(); |
| 4762 | |
| 4763 | if ( !$user = $this->login($username, $password) ) |
| 4764 | return $this->error; |
| 4765 | |
| 4766 | if ( ! current_user_can( 'edit_posts' ) ) |
| 4767 | return new IXR_Error( 401, __( 'Sorry, you cannot edit posts on this site.' ) ); |
| 4768 | |
| 4769 | do_action('xmlrpc_call', 'metaWeblog.getRecentPosts'); |
| 4770 | |
| 4771 | $posts_list = wp_get_recent_posts( $query ); |
| 4772 | |
| 4773 | if ( !$posts_list ) |
| 4774 | return array(); |
| 4775 | |
| 4776 | $struct = array(); |
| 4777 | foreach ($posts_list as $entry) { |
| 4778 | if ( !current_user_can( 'edit_post', $entry['ID'] ) ) |
| Line | Code |
| 4874 | $username = $args[1]; |
| 4875 | $password = $args[2]; |
| 4876 | |
| 4877 | if ( !$user = $this->login($username, $password) ) |
| 4878 | return $this->error; |
| 4879 | |
| 4880 | if ( !current_user_can( 'edit_posts' ) ) |
| 4881 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
| 4882 | |
| 4883 | do_action('xmlrpc_call', 'metaWeblog.getCategories'); |
| 4884 | |
| 4885 | $categories_struct = array(); |
| 4886 | |
| 4887 | if ( $cats = get_categories(array('get' => 'all')) ) { |
| 4888 | foreach ( $cats as $cat ) { |
| 4889 | $struct['categoryId'] = $cat->term_id; |
| 4890 | $struct['parentId'] = $cat->parent; |
| 4891 | $struct['description'] = $cat->name; |
| 4892 | $struct['categoryDescription'] = $cat->description; |
| Line | Code |
| 4922 | $data = $args[3]; |
| 4923 | |
| 4924 | $name = sanitize_file_name( $data['name'] ); |
| 4925 | $type = $data['type']; |
| 4926 | $bits = $data['bits']; |
| 4927 | |
| 4928 | if ( !$user = $this->login($username, $password) ) |
| 4929 | return $this->error; |
| 4930 | |
| 4931 | do_action('xmlrpc_call', 'metaWeblog.newMediaObject'); |
| 4932 | |
| 4933 | if ( !current_user_can('upload_files') ) { |
| 4934 | $this->error = new IXR_Error( 401, __( 'You do not have permission to upload files.' ) ); |
| 4935 | return $this->error; |
| 4936 | } |
| 4937 | |
| 4938 | if ( $upload_err = apply_filters( 'pre_upload_error', false ) ) |
| 4939 | return new IXR_Error(500, $upload_err); |
| 4940 | |
| Line | Code |
| 5014 | $password = $args[2]; |
| 5015 | if ( isset( $args[3] ) ) |
| 5016 | $query = array( 'numberposts' => absint( $args[3] ) ); |
| 5017 | else |
| 5018 | $query = array(); |
| 5019 | |
| 5020 | if ( !$user = $this->login($username, $password) ) |
| 5021 | return $this->error; |
| 5022 | |
| 5023 | do_action('xmlrpc_call', 'mt.getRecentPostTitles'); |
| 5024 | |
| 5025 | $posts_list = wp_get_recent_posts( $query ); |
| 5026 | |
| 5027 | if ( !$posts_list ) { |
| 5028 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
| 5029 | return $this->error; |
| 5030 | } |
| 5031 | |
| 5032 | $struct = array(); |
| Line | Code |
| 5073 | $username = $args[1]; |
| 5074 | $password = $args[2]; |
| 5075 | |
| 5076 | if ( !$user = $this->login($username, $password) ) |
| 5077 | return $this->error; |
| 5078 | |
| 5079 | if ( !current_user_can( 'edit_posts' ) ) |
| 5080 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
| 5081 | |
| 5082 | do_action('xmlrpc_call', 'mt.getCategoryList'); |
| 5083 | |
| 5084 | $categories_struct = array(); |
| 5085 | |
| 5086 | if ( $cats = get_categories(array('hide_empty' => 0, 'hierarchical' => 0)) ) { |
| 5087 | foreach ( $cats as $cat ) { |
| 5088 | $struct['categoryId'] = $cat->term_id; |
| 5089 | $struct['categoryName'] = $cat->name; |
| 5090 | |
| 5091 | $categories_struct[] = $struct; |
| Line | Code |
| 5114 | if ( !$user = $this->login($username, $password) ) |
| 5115 | return $this->error; |
| 5116 | |
| 5117 | if ( ! get_post( $post_ID ) ) |
| 5118 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 5119 | |
| 5120 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
| 5121 | return new IXR_Error( 401, __( 'Sorry, you can not edit this post.' ) ); |
| 5122 | |
| 5123 | do_action('xmlrpc_call', 'mt.getPostCategories'); |
| 5124 | |
| 5125 | $categories = array(); |
| 5126 | $catids = wp_get_post_categories(intval($post_ID)); |
| 5127 | // first listed category will be the primary category |
| 5128 | $isPrimary = true; |
| 5129 | foreach ( $catids as $catid ) { |
| 5130 | $categories[] = array( |
| 5131 | 'categoryName' => get_cat_name($catid), |
| 5132 | 'categoryId' => (string) $catid, |
| Line | Code |
| 5152 | |
| 5153 | $post_ID = (int) $args[0]; |
| 5154 | $username = $args[1]; |
| 5155 | $password = $args[2]; |
| 5156 | $categories = $args[3]; |
| 5157 | |
| 5158 | if ( !$user = $this->login($username, $password) ) |
| 5159 | return $this->error; |
| 5160 | |
| 5161 | do_action('xmlrpc_call', 'mt.setPostCategories'); |
| 5162 | |
| 5163 | if ( ! get_post( $post_ID ) ) |
| 5164 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 5165 | |
| 5166 | if ( !current_user_can('edit_post', $post_ID) ) |
| 5167 | return new IXR_Error(401, __('Sorry, you cannot edit this post.')); |
| 5168 | |
| 5169 | $catids = array(); |
| 5170 | foreach ( $categories as $cat ) { |
| Line | Code |
| 5180 | * Retrieve an array of methods supported by this server. |
| 5181 | * |
| 5182 | * @since 1.5.0 |
| 5183 | * |
| 5184 | * @param array $args Method parameters. |
| 5185 | * @return array |
| 5186 | */ |
| 5187 | function mt_supportedMethods($args) { |
| 5188 | |
| 5189 | do_action('xmlrpc_call', 'mt.supportedMethods'); |
| 5190 | |
| 5191 | $supported_methods = array(); |
| 5192 | foreach ( $this->methods as $key => $value ) { |
| 5193 | $supported_methods[] = $key; |
| 5194 | } |
| 5195 | |
| 5196 | return $supported_methods; |
| 5197 | } |
| 5198 | |
| 5199 | /** |
| 5200 | * Retrieve an empty array because we don't support per-post text filters. |
| 5201 | * |
| 5202 | * @since 1.5.0 |
| 5203 | * |
| 5204 | * @param array $args Method parameters. |
| 5205 | */ |
| 5206 | function mt_supportedTextFilters($args) { |
| 5207 | do_action('xmlrpc_call', 'mt.supportedTextFilters'); |
| 5208 | return apply_filters('xmlrpc_text_filters', array()); |
| 5209 | } |
| 5210 | |
| 5211 | /** |
| 5212 | * Retrieve trackbacks sent to a given post. |
| 5213 | * |
| 5214 | * @since 1.5.0 |
| 5215 | * |
| 5216 | * @param array $args Method parameters. |
| 5217 | * @return mixed |
| 5218 | */ |
| 5219 | function mt_getTrackbackPings($args) { |
| 5220 | |
| 5221 | global $wpdb; |
| 5222 | |
| 5223 | $post_ID = intval($args); |
| 5224 | |
| 5225 | do_action('xmlrpc_call', 'mt.getTrackbackPings'); |
| 5226 | |
| 5227 | $actual_post = get_post($post_ID, ARRAY_A); |
| 5228 | |
| 5229 | if ( !$actual_post ) |
| 5230 | return new IXR_Error(404, __('Sorry, no such post.')); |
| 5231 | |
| 5232 | $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) ); |
| 5233 | |
| 5234 | if ( !$comments ) |
| Line | Code |
| 5263 | $this->escape($args); |
| 5264 | |
| 5265 | $post_ID = (int) $args[0]; |
| 5266 | $username = $args[1]; |
| 5267 | $password = $args[2]; |
| 5268 | |
| 5269 | if ( !$user = $this->login($username, $password) ) |
| 5270 | return $this->error; |
| 5271 | |
| 5272 | do_action('xmlrpc_call', 'mt.publishPost'); |
| 5273 | |
| 5274 | $postdata = get_post($post_ID, ARRAY_A); |
| 5275 | if ( ! $postdata ) |
| 5276 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 5277 | |
| 5278 | if ( !current_user_can('publish_posts') || !current_user_can('edit_post', $post_ID) ) |
| 5279 | return new IXR_Error(401, __('Sorry, you cannot publish this post.')); |
| 5280 | |
| 5281 | $postdata['post_status'] = 'publish'; |
| Line | Code |
| 5299 | * |
| 5300 | * @since 1.5.0 |
| 5301 | * |
| 5302 | * @param array $args Method parameters. |
| 5303 | * @return array |
| 5304 | */ |
| 5305 | function pingback_ping($args) { |
| 5306 | global $wpdb; |
| 5307 | |
| 5308 | do_action('xmlrpc_call', 'pingback.ping'); |
| 5309 | |
| 5310 | $this->escape($args); |
| 5311 | |
| 5312 | $pagelinkedfrom = $args[0]; |
| 5313 | $pagelinkedto = $args[1]; |
| 5314 | |
| 5315 | $title = ''; |
| 5316 | |
| 5317 | $pagelinkedfrom = str_replace('&', '&', $pagelinkedfrom); |
| Line | Code |
| 5477 | * @since 1.5.0 |
| 5478 | * |
| 5479 | * @param array $args Method parameters. |
| 5480 | * @return array |
| 5481 | */ |
| 5482 | function pingback_extensions_getPingbacks($args) { |
| 5483 | |
| 5484 | global $wpdb; |
| 5485 | |
| 5486 | do_action('xmlrpc_call', 'pingback.extensions.getPingbacks'); |
| 5487 | |
| 5488 | $this->escape($args); |
| 5489 | |
| 5490 | $url = $args; |
| 5491 | |
| 5492 | $post_ID = url_to_postid($url); |
| 5493 | if ( !$post_ID ) { |
| 5494 | // We aren't sure that the resource is available and/or pingback enabled |
| 5495 | 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.' ) ); |