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 |
966 |
|
967 | $blog_id = (int) $args[0]; |
968 | $username = $args[1]; |
969 | $password = $args[2]; |
970 | $content_struct = $args[3]; |
971 |
|
972 | if ( ! $user = $this->login( $username, $password ) ) |
973 | return $this->error; |
974 |
|
975 | do_action( 'xmlrpc_call', 'wp.newPost' ); |
976 |
|
977 | unset( $content_struct['ID'] ); |
978 |
|
979 | return $this->_insert_post( $user, $content_struct ); |
980 | } |
981 |
|
982 | /** |
983 | * Helper method for filtering out elements from an array. |
984 | * |
Line | Code |
1251 | $blog_id = (int) $args[0]; |
1252 | $username = $args[1]; |
1253 | $password = $args[2]; |
1254 | $post_id = (int) $args[3]; |
1255 | $content_struct = $args[4]; |
1256 |
|
1257 | if ( ! $user = $this->login( $username, $password ) ) |
1258 | return $this->error; |
1259 |
|
1260 | do_action( 'xmlrpc_call', 'wp.editPost' ); |
1261 |
|
1262 | $post = get_post( $post_id, ARRAY_A ); |
1263 |
|
1264 | if ( empty( $post['ID'] ) ) |
1265 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
1266 |
|
1267 | if ( isset( $content_struct['if_not_modified_since'] ) ) { |
1268 | // If the post has been modified since the date provided, return an error. |
1269 | if ( mysql2date( 'U', $post['post_modified_gmt'] ) > $content_struct['if_not_modified_since']->getTimestamp() ) { |
Line | Code |
1312 |
|
1313 | $blog_id = (int) $args[0]; |
1314 | $username = $args[1]; |
1315 | $password = $args[2]; |
1316 | $post_id = (int) $args[3]; |
1317 |
|
1318 | if ( ! $user = $this->login( $username, $password ) ) |
1319 | return $this->error; |
1320 |
|
1321 | do_action( 'xmlrpc_call', 'wp.deletePost' ); |
1322 |
|
1323 | $post = get_post( $post_id, ARRAY_A ); |
1324 | if ( empty( $post['ID'] ) ) |
1325 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
1326 |
|
1327 | if ( ! current_user_can( 'delete_post', $post_id ) ) |
1328 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) ); |
1329 |
|
1330 | $result = wp_delete_post( $post_id ); |
Line | Code |
1392 |
|
1393 | if ( isset( $args[4] ) ) |
1394 | $fields = $args[4]; |
1395 | else |
1396 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPost' ); |
1397 |
|
1398 | if ( ! $user = $this->login( $username, $password ) ) |
1399 | return $this->error; |
1400 |
|
1401 | do_action( 'xmlrpc_call', 'wp.getPost' ); |
1402 |
|
1403 | $post = get_post( $post_id, ARRAY_A ); |
1404 |
|
1405 | if ( empty( $post['ID'] ) ) |
1406 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
1407 |
|
1408 | if ( ! current_user_can( 'edit_post', $post_id ) ) |
1409 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); |
1410 |
|
Line | Code |
1448 |
|
1449 | if ( isset( $args[4] ) ) |
1450 | $fields = $args[4]; |
1451 | else |
1452 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPosts' ); |
1453 |
|
1454 | if ( ! $user = $this->login( $username, $password ) ) |
1455 | return $this->error; |
1456 |
|
1457 | do_action( 'xmlrpc_call', 'wp.getPosts' ); |
1458 |
|
1459 | $query = array(); |
1460 |
|
1461 | if ( isset( $filter['post_type'] ) ) { |
1462 | $post_type = get_post_type_object( $filter['post_type'] ); |
1463 | if ( ! ( (bool) $post_type ) ) |
1464 | return new IXR_Error( 403, __( 'The post type specified is not valid' ) ); |
1465 | } else { |
1466 | $post_type = get_post_type_object( 'post' ); |
Line | Code |
1537 |
|
1538 | $blog_id = (int) $args[0]; |
1539 | $username = $args[1]; |
1540 | $password = $args[2]; |
1541 | $content_struct = $args[3]; |
1542 |
|
1543 | if ( ! $user = $this->login( $username, $password ) ) |
1544 | return $this->error; |
1545 |
|
1546 | do_action( 'xmlrpc_call', 'wp.newTerm' ); |
1547 |
|
1548 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) |
1549 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
1550 |
|
1551 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
1552 |
|
1553 | if ( ! current_user_can( $taxonomy->cap->manage_terms ) ) |
1554 | return new IXR_Error( 401, __( 'You are not allowed to create terms in this taxonomy.' ) ); |
1555 |
|
Line | Code |
1625 | $blog_id = (int) $args[0]; |
1626 | $username = $args[1]; |
1627 | $password = $args[2]; |
1628 | $term_id = (int) $args[3]; |
1629 | $content_struct = $args[4]; |
1630 |
|
1631 | if ( ! $user = $this->login( $username, $password ) ) |
1632 | return $this->error; |
1633 |
|
1634 | do_action( 'xmlrpc_call', 'wp.editTerm' ); |
1635 |
|
1636 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) |
1637 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
1638 |
|
1639 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
1640 |
|
1641 | if ( ! current_user_can( $taxonomy->cap->edit_terms ) ) |
1642 | return new IXR_Error( 401, __( 'You are not allowed to edit terms in this taxonomy.' ) ); |
1643 |
|
Line | Code |
1717 | $blog_id = (int) $args[0]; |
1718 | $username = $args[1]; |
1719 | $password = $args[2]; |
1720 | $taxonomy = $args[3]; |
1721 | $term_id = (int) $args[4]; |
1722 |
|
1723 | if ( ! $user = $this->login( $username, $password ) ) |
1724 | return $this->error; |
1725 |
|
1726 | do_action( 'xmlrpc_call', 'wp.deleteTerm' ); |
1727 |
|
1728 | if ( ! taxonomy_exists( $taxonomy ) ) |
1729 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
1730 |
|
1731 | $taxonomy = get_taxonomy( $taxonomy ); |
1732 |
|
1733 | if ( ! current_user_can( $taxonomy->cap->delete_terms ) ) |
1734 | return new IXR_Error( 401, __( 'You are not allowed to delete terms in this taxonomy.' ) ); |
1735 |
|
Line | Code |
1784 | $blog_id = (int) $args[0]; |
1785 | $username = $args[1]; |
1786 | $password = $args[2]; |
1787 | $taxonomy = $args[3]; |
1788 | $term_id = (int) $args[4]; |
1789 |
|
1790 | if ( ! $user = $this->login( $username, $password ) ) |
1791 | return $this->error; |
1792 |
|
1793 | do_action( 'xmlrpc_call', 'wp.getTerm' ); |
1794 |
|
1795 | if ( ! taxonomy_exists( $taxonomy ) ) |
1796 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
1797 |
|
1798 | $taxonomy = get_taxonomy( $taxonomy ); |
1799 |
|
1800 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
1801 | return new IXR_Error( 401, __( 'You are not allowed to assign terms in this taxonomy.' ) ); |
1802 |
|
Line | Code |
1837 | $blog_id = (int) $args[0]; |
1838 | $username = $args[1]; |
1839 | $password = $args[2]; |
1840 | $taxonomy = $args[3]; |
1841 | $filter = isset( $args[4] ) ? $args[4] : array(); |
1842 |
|
1843 | if ( ! $user = $this->login( $username, $password ) ) |
1844 | return $this->error; |
1845 |
|
1846 | do_action( 'xmlrpc_call', 'wp.getTerms' ); |
1847 |
|
1848 | if ( ! taxonomy_exists( $taxonomy ) ) |
1849 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
1850 |
|
1851 | $taxonomy = get_taxonomy( $taxonomy ); |
1852 |
|
1853 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
1854 | return new IXR_Error( 401, __( 'You are not allowed to assign terms in this taxonomy.' ) ); |
1855 |
|
Line | Code |
1916 |
|
1917 | if ( isset( $args[4] ) ) |
1918 | $fields = $args[4]; |
1919 | else |
1920 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomy' ); |
1921 |
|
1922 | if ( ! $user = $this->login( $username, $password ) ) |
1923 | return $this->error; |
1924 |
|
1925 | do_action( 'xmlrpc_call', 'wp.getTaxonomy' ); |
1926 |
|
1927 | if ( ! taxonomy_exists( $taxonomy ) ) |
1928 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
1929 |
|
1930 | $taxonomy = get_taxonomy( $taxonomy ); |
1931 |
|
1932 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
1933 | return new IXR_Error( 401, __( 'You are not allowed to assign terms in this taxonomy.' ) ); |
1934 |
|
Line | Code |
1960 |
|
1961 | if ( isset( $args[4] ) ) |
1962 | $fields = $args[4]; |
1963 | else |
1964 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomies' ); |
1965 |
|
1966 | if ( ! $user = $this->login( $username, $password ) ) |
1967 | return $this->error; |
1968 |
|
1969 | do_action( 'xmlrpc_call', 'wp.getTaxonomies' ); |
1970 |
|
1971 | $taxonomies = get_taxonomies( $filter, 'objects' ); |
1972 |
|
1973 | // holds all the taxonomy data |
1974 | $struct = array(); |
1975 |
|
1976 | foreach ( $taxonomies as $taxonomy ) { |
1977 | // capability check for post_types |
1978 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
Line | Code |
2029 |
|
2030 | if ( isset( $args[4] ) ) |
2031 | $fields = $args[4]; |
2032 | else |
2033 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUser' ); |
2034 |
|
2035 | if ( ! $user = $this->login( $username, $password ) ) |
2036 | return $this->error; |
2037 |
|
2038 | do_action( 'xmlrpc_call', 'wp.getUser' ); |
2039 |
|
2040 | if ( ! current_user_can( 'edit_user', $user_id ) ) |
2041 | return new IXR_Error( 401, __( 'Sorry, you cannot edit users.' ) ); |
2042 |
|
2043 | $user_data = get_userdata( $user_id ); |
2044 |
|
2045 | if ( ! $user_data ) |
2046 | return new IXR_Error( 404, __( 'Invalid user ID' ) ); |
2047 |
|
Line | Code |
2082 |
|
2083 | if ( isset( $args[4] ) ) |
2084 | $fields = $args[4]; |
2085 | else |
2086 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUsers' ); |
2087 |
|
2088 | if ( ! $user = $this->login( $username, $password ) ) |
2089 | return $this->error; |
2090 |
|
2091 | do_action( 'xmlrpc_call', 'wp.getUsers' ); |
2092 |
|
2093 | if ( ! current_user_can( 'list_users' ) ) |
2094 | return new IXR_Error( 401, __( 'Sorry, you cannot list users.' ) ); |
2095 |
|
2096 | $query = array( 'fields' => 'all_with_meta' ); |
2097 |
|
2098 | $query['number'] = ( isset( $filter['number'] ) ) ? absint( $filter['number'] ) : 50; |
2099 | $query['offset'] = ( isset( $filter['offset'] ) ) ? absint( $filter['offset'] ) : 0; |
2100 |
|
Line | Code |
2149 |
|
2150 | if ( isset( $args[3] ) ) |
2151 | $fields = $args[3]; |
2152 | else |
2153 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getProfile' ); |
2154 |
|
2155 | if ( ! $user = $this->login( $username, $password ) ) |
2156 | return $this->error; |
2157 |
|
2158 | do_action( 'xmlrpc_call', 'wp.getProfile' ); |
2159 |
|
2160 | if ( ! current_user_can( 'edit_user', $user->ID ) ) |
2161 | return new IXR_Error( 401, __( 'Sorry, you cannot edit your profile.' ) ); |
2162 |
|
2163 | $user_data = get_userdata( $user->ID ); |
2164 |
|
2165 | return $this->_prepare_user( $user_data, $fields ); |
2166 | } |
2167 |
|
Line | Code |
2192 |
|
2193 | $blog_id = (int) $args[0]; |
2194 | $username = $args[1]; |
2195 | $password = $args[2]; |
2196 | $content_struct = $args[3]; |
2197 |
|
2198 | if ( ! $user = $this->login( $username, $password ) ) |
2199 | return $this->error; |
2200 |
|
2201 | do_action( 'xmlrpc_call', 'wp.editProfile' ); |
2202 |
|
2203 | if ( ! current_user_can( 'edit_user', $user->ID ) ) |
2204 | return new IXR_Error( 401, __( 'Sorry, you cannot edit your profile.' ) ); |
2205 |
|
2206 | // holds data of the user |
2207 | $user_data = array(); |
2208 | $user_data['ID'] = $user->ID; |
2209 |
|
2210 | // only set the user details if it was given |
Line | Code |
2265 | } |
2266 |
|
2267 | $page = get_post($page_id); |
2268 | if ( ! $page ) |
2269 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
2270 |
|
2271 | if ( !current_user_can( 'edit_page', $page_id ) ) |
2272 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this page.' ) ); |
2273 |
|
2274 | do_action('xmlrpc_call', 'wp.getPage'); |
2275 |
|
2276 | // If we found the page then format the data. |
2277 | if ( $page->ID && ($page->post_type == 'page') ) { |
2278 | return $this->_prepare_page( $page ); |
2279 | } |
2280 | // If the page doesn't exist indicate that. |
2281 | else { |
2282 | return(new IXR_Error(404, __('Sorry, no such page.'))); |
2283 | } |
Line | Code |
2303 | $password = $args[2]; |
2304 | $num_pages = isset($args[3]) ? (int) $args[3] : 10; |
2305 |
|
2306 | if ( !$user = $this->login($username, $password) ) |
2307 | return $this->error; |
2308 |
|
2309 | if ( !current_user_can( 'edit_pages' ) ) |
2310 | return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) ); |
2311 |
|
2312 | do_action('xmlrpc_call', 'wp.getPages'); |
2313 |
|
2314 | $pages = get_posts( array('post_type' => 'page', 'post_status' => 'any', 'numberposts' => $num_pages) ); |
2315 | $num_pages = count($pages); |
2316 |
|
2317 | // If we have pages, put together their info. |
2318 | if ( $num_pages >= 1 ) { |
2319 | $pages_struct = array(); |
2320 |
|
2321 | foreach ($pages as $page) { |
Line | Code |
2343 | // Items not escaped here will be escaped in newPost. |
2344 | $username = $this->escape($args[1]); |
2345 | $password = $this->escape($args[2]); |
2346 | $page = $args[3]; |
2347 | $publish = $args[4]; |
2348 |
|
2349 | if ( !$user = $this->login($username, $password) ) |
2350 | return $this->error; |
2351 |
|
2352 | do_action('xmlrpc_call', 'wp.newPage'); |
2353 |
|
2354 | // Mark this as content for a page. |
2355 | $args[3]["post_type"] = 'page'; |
2356 |
|
2357 | // Let mw_newPost do all of the heavy lifting. |
2358 | return($this->mw_newPost($args)); |
2359 | } |
2360 |
|
2361 | /** |
Line | Code |
2371 |
|
2372 | $blog_id = (int) $args[0]; |
2373 | $username = $args[1]; |
2374 | $password = $args[2]; |
2375 | $page_id = (int) $args[3]; |
2376 |
|
2377 | if ( !$user = $this->login($username, $password) ) |
2378 | return $this->error; |
2379 |
|
2380 | do_action('xmlrpc_call', 'wp.deletePage'); |
2381 |
|
2382 | // Get the current page based on the page_id and |
2383 | // make sure it is a page and not a post. |
2384 | $actual_page = get_post($page_id, ARRAY_A); |
2385 | if ( !$actual_page || ($actual_page['post_type'] != 'page') ) |
2386 | return(new IXR_Error(404, __('Sorry, no such page.'))); |
2387 |
|
2388 | // Make sure the user can delete pages. |
2389 | if ( !current_user_can('delete_page', $page_id) ) |
Line | Code |
2413 | $page_id = (int) $this->escape($args[1]); |
2414 | $username = $this->escape($args[2]); |
2415 | $password = $this->escape($args[3]); |
2416 | $content = $args[4]; |
2417 | $publish = $args[5]; |
2418 |
|
2419 | if ( !$user = $this->login($username, $password) ) |
2420 | return $this->error; |
2421 |
|
2422 | do_action('xmlrpc_call', 'wp.editPage'); |
2423 |
|
2424 | // Get the page data and make sure it is a page. |
2425 | $actual_page = get_post($page_id, ARRAY_A); |
2426 | if ( !$actual_page || ($actual_page['post_type'] != 'page') ) |
2427 | return(new IXR_Error(404, __('Sorry, no such page.'))); |
2428 |
|
2429 | // Make sure the user is allowed to edit pages. |
2430 | if ( !current_user_can('edit_page', $page_id) ) |
2431 | return(new IXR_Error(401, __('Sorry, you do not have the right to edit this page.'))); |
Line | Code |
2463 | $username = $args[1]; |
2464 | $password = $args[2]; |
2465 |
|
2466 | if ( !$user = $this->login($username, $password) ) |
2467 | return $this->error; |
2468 |
|
2469 | if ( !current_user_can( 'edit_pages' ) ) |
2470 | return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) ); |
2471 |
|
2472 | do_action('xmlrpc_call', 'wp.getPageList'); |
2473 |
|
2474 | // Get list of pages ids and titles |
2475 | $page_list = $wpdb->get_results(" |
2476 | SELECT ID page_id, |
2477 | post_title page_title, |
2478 | post_parent page_parent_id, |
2479 | post_date_gmt, |
2480 | post_date, |
2481 | post_status |
Line | Code |
2514 | $username = $args[1]; |
2515 | $password = $args[2]; |
2516 |
|
2517 | if ( !$user = $this->login($username, $password) ) |
2518 | return $this->error; |
2519 |
|
2520 | if ( !current_user_can('edit_posts') ) |
2521 | return(new IXR_Error(401, __('Sorry, you cannot edit posts on this site.'))); |
2522 |
|
2523 | do_action('xmlrpc_call', 'wp.getAuthors'); |
2524 |
|
2525 | $authors = array(); |
2526 | foreach ( get_users( array( 'fields' => array('ID','user_login','display_name') ) ) as $user ) { |
2527 | $authors[] = array( |
2528 | 'user_id' => $user->ID, |
2529 | 'user_login' => $user->user_login, |
2530 | 'display_name' => $user->display_name |
2531 | ); |
2532 | } |
Line | Code |
2549 | $username = $args[1]; |
2550 | $password = $args[2]; |
2551 |
|
2552 | if ( !$user = $this->login($username, $password) ) |
2553 | return $this->error; |
2554 |
|
2555 | if ( !current_user_can( 'edit_posts' ) ) |
2556 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view tags.' ) ); |
2557 |
|
2558 | do_action( 'xmlrpc_call', 'wp.getKeywords' ); |
2559 |
|
2560 | $tags = array(); |
2561 |
|
2562 | if ( $all_tags = get_tags() ) { |
2563 | foreach( (array) $all_tags as $tag ) { |
2564 | $struct['tag_id'] = $tag->term_id; |
2565 | $struct['name'] = $tag->name; |
2566 | $struct['count'] = $tag->count; |
2567 | $struct['slug'] = $tag->slug; |
Line | Code |
2588 |
|
2589 | $blog_id = (int) $args[0]; |
2590 | $username = $args[1]; |
2591 | $password = $args[2]; |
2592 | $category = $args[3]; |
2593 |
|
2594 | if ( !$user = $this->login($username, $password) ) |
2595 | return $this->error; |
2596 |
|
2597 | do_action('xmlrpc_call', 'wp.newCategory'); |
2598 |
|
2599 | // Make sure the user is allowed to add a category. |
2600 | if ( !current_user_can('manage_categories') ) |
2601 | return(new IXR_Error(401, __('Sorry, you do not have the right to add a category.'))); |
2602 |
|
2603 | // If no slug was provided make it empty so that |
2604 | // WordPress will generate one. |
2605 | if ( empty($category['slug']) ) |
2606 | $category['slug'] = ''; |
Line | Code |
2649 |
|
2650 | $blog_id = (int) $args[0]; |
2651 | $username = $args[1]; |
2652 | $password = $args[2]; |
2653 | $category_id = (int) $args[3]; |
2654 |
|
2655 | if ( !$user = $this->login($username, $password) ) |
2656 | return $this->error; |
2657 |
|
2658 | do_action('xmlrpc_call', 'wp.deleteCategory'); |
2659 |
|
2660 | if ( !current_user_can('manage_categories') ) |
2661 | return new IXR_Error( 401, __( 'Sorry, you do not have the right to delete a category.' ) ); |
2662 |
|
2663 | $status = wp_delete_term( $category_id, 'category' ); |
2664 |
|
2665 | if( true == $status ) |
2666 | do_action( 'xmlrpc_call_success_wp_deleteCategory', $category_id, $args ); |
2667 |
|
Line | Code |
2685 | $category = $args[3]; |
2686 | $max_results = (int) $args[4]; |
2687 |
|
2688 | if ( !$user = $this->login($username, $password) ) |
2689 | return $this->error; |
2690 |
|
2691 | if ( !current_user_can( 'edit_posts' ) ) |
2692 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts to this site in order to view categories.' ) ); |
2693 |
|
2694 | do_action('xmlrpc_call', 'wp.suggestCategories'); |
2695 |
|
2696 | $category_suggestions = array(); |
2697 | $args = array('get' => 'all', 'number' => $max_results, 'name__like' => $category); |
2698 | foreach ( (array) get_categories($args) as $cat ) { |
2699 | $category_suggestions[] = array( |
2700 | 'category_id' => $cat->term_id, |
2701 | 'category_name' => $cat->name |
2702 | ); |
2703 | } |
Line | Code |
2721 | $password = $args[2]; |
2722 | $comment_id = (int) $args[3]; |
2723 |
|
2724 | if ( !$user = $this->login($username, $password) ) |
2725 | return $this->error; |
2726 |
|
2727 | if ( !current_user_can( 'moderate_comments' ) ) |
2728 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
2729 |
|
2730 | do_action('xmlrpc_call', 'wp.getComment'); |
2731 |
|
2732 | if ( ! $comment = get_comment($comment_id) ) |
2733 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
2734 |
|
2735 | return $this->_prepare_comment( $comment ); |
2736 | } |
2737 |
|
2738 | /** |
2739 | * Retrieve comments. |
Line | Code |
2762 | $password = $args[2]; |
2763 | $struct = isset( $args[3] ) ? $args[3] : array(); |
2764 |
|
2765 | if ( !$user = $this->login($username, $password) ) |
2766 | return $this->error; |
2767 |
|
2768 | if ( !current_user_can( 'moderate_comments' ) ) |
2769 | return new IXR_Error( 401, __( 'Sorry, you cannot edit comments.' ) ); |
2770 |
|
2771 | do_action('xmlrpc_call', 'wp.getComments'); |
2772 |
|
2773 | if ( isset($struct['status']) ) |
2774 | $status = $struct['status']; |
2775 | else |
2776 | $status = ''; |
2777 |
|
2778 | $post_id = ''; |
2779 | if ( isset($struct['post_id']) ) |
2780 | $post_id = absint($struct['post_id']); |
Line | Code |
2828 | if ( !current_user_can( 'moderate_comments' ) ) |
2829 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
2830 |
|
2831 | if ( ! get_comment($comment_ID) ) |
2832 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
2833 |
|
2834 | if ( !current_user_can( 'edit_comment', $comment_ID ) ) |
2835 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
2836 |
|
2837 | do_action('xmlrpc_call', 'wp.deleteComment'); |
2838 |
|
2839 | $status = wp_delete_comment( $comment_ID ); |
2840 |
|
2841 | if( true == $status ) |
2842 | do_action( 'xmlrpc_call_success_wp_deleteComment', $comment_ID, $args ); |
2843 |
|
2844 | return $status; |
2845 | } |
2846 |
|
Line | Code |
2883 | if ( !current_user_can( 'moderate_comments' ) ) |
2884 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
2885 |
|
2886 | if ( ! get_comment($comment_ID) ) |
2887 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
2888 |
|
2889 | if ( !current_user_can( 'edit_comment', $comment_ID ) ) |
2890 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
2891 |
|
2892 | do_action('xmlrpc_call', 'wp.editComment'); |
2893 |
|
2894 | if ( isset($content_struct['status']) ) { |
2895 | $statuses = get_comment_statuses(); |
2896 | $statuses = array_keys($statuses); |
2897 |
|
2898 | if ( ! in_array($content_struct['status'], $statuses) ) |
2899 | return new IXR_Error( 401, __( 'Invalid comment status.' ) ); |
2900 | $comment_approved = $content_struct['status']; |
2901 | } |
Line | Code |
3007 | elseif ( !is_email($comment['comment_author_email']) ) |
3008 | return new IXR_Error( 403, __( 'A valid email address is required' ) ); |
3009 | } |
3010 | } |
3011 |
|
3012 | $comment['comment_parent'] = isset($content_struct['comment_parent']) ? absint($content_struct['comment_parent']) : 0; |
3013 |
|
3014 | $comment['comment_content'] = isset($content_struct['content']) ? $content_struct['content'] : null; |
3015 |
|
3016 | do_action('xmlrpc_call', 'wp.newComment'); |
3017 |
|
3018 | $comment_ID = wp_new_comment( $comment ); |
3019 |
|
3020 | do_action( 'xmlrpc_call_success_wp_newComment', $comment_ID, $args ); |
3021 |
|
3022 | return $comment_ID; |
3023 | } |
3024 |
|
3025 | /** |
Line | Code |
3037 | $username = $args[1]; |
3038 | $password = $args[2]; |
3039 |
|
3040 | if ( !$user = $this->login($username, $password) ) |
3041 | return $this->error; |
3042 |
|
3043 | if ( !current_user_can( 'moderate_comments' ) ) |
3044 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
3045 |
|
3046 | do_action('xmlrpc_call', 'wp.getCommentStatusList'); |
3047 |
|
3048 | return get_comment_statuses(); |
3049 | } |
3050 |
|
3051 | /** |
3052 | * Retrieve comment count. |
3053 | * |
3054 | * @since 2.5.0 |
3055 | * |
Line | Code |
3064 | $password = $args[2]; |
3065 | $post_id = (int) $args[3]; |
3066 |
|
3067 | if ( !$user = $this->login($username, $password) ) |
3068 | return $this->error; |
3069 |
|
3070 | if ( !current_user_can( 'edit_posts' ) ) |
3071 | return new IXR_Error( 403, __( 'You are not allowed access to details about comments.' ) ); |
3072 |
|
3073 | do_action('xmlrpc_call', 'wp.getCommentCount'); |
3074 |
|
3075 | $count = wp_count_comments( $post_id ); |
3076 | return array( |
3077 | 'approved' => $count->approved, |
3078 | 'awaiting_moderation' => $count->moderated, |
3079 | 'spam' => $count->spam, |
3080 | 'total_comments' => $count->total_comments |
3081 | ); |
3082 | } |
Line | Code |
3096 | $username = $args[1]; |
3097 | $password = $args[2]; |
3098 |
|
3099 | if ( !$user = $this->login($username, $password) ) |
3100 | return $this->error; |
3101 |
|
3102 | if ( !current_user_can( 'edit_posts' ) ) |
3103 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
3104 |
|
3105 | do_action('xmlrpc_call', 'wp.getPostStatusList'); |
3106 |
|
3107 | return get_post_statuses(); |
3108 | } |
3109 |
|
3110 | /** |
3111 | * Retrieve page statuses. |
3112 | * |
3113 | * @since 2.5.0 |
3114 | * |
Line | Code |
3122 | $username = $args[1]; |
3123 | $password = $args[2]; |
3124 |
|
3125 | if ( !$user = $this->login($username, $password) ) |
3126 | return $this->error; |
3127 |
|
3128 | if ( !current_user_can( 'edit_pages' ) ) |
3129 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
3130 |
|
3131 | do_action('xmlrpc_call', 'wp.getPageStatusList'); |
3132 |
|
3133 | return get_page_statuses(); |
3134 | } |
3135 |
|
3136 | /** |
3137 | * Retrieve page templates. |
3138 | * |
3139 | * @since 2.6.0 |
3140 | * |
Line | Code |
3279 | $password = $args[2]; |
3280 | $attachment_id = (int) $args[3]; |
3281 |
|
3282 | if ( !$user = $this->login($username, $password) ) |
3283 | return $this->error; |
3284 |
|
3285 | if ( !current_user_can( 'upload_files' ) ) |
3286 | return new IXR_Error( 403, __( 'You do not have permission to upload files.' ) ); |
3287 |
|
3288 | do_action('xmlrpc_call', 'wp.getMediaItem'); |
3289 |
|
3290 | if ( ! $attachment = get_post($attachment_id) ) |
3291 | return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); |
3292 |
|
3293 | return $this->_prepare_media_item( $attachment ); |
3294 | } |
3295 |
|
3296 | /** |
3297 | * Retrieves a collection of media library items (or attachments) |
Line | Code |
3324 | $password = $args[2]; |
3325 | $struct = isset( $args[3] ) ? $args[3] : array() ; |
3326 |
|
3327 | if ( !$user = $this->login($username, $password) ) |
3328 | return $this->error; |
3329 |
|
3330 | if ( !current_user_can( 'upload_files' ) ) |
3331 | return new IXR_Error( 401, __( 'You do not have permission to upload files.' ) ); |
3332 |
|
3333 | do_action('xmlrpc_call', 'wp.getMediaLibrary'); |
3334 |
|
3335 | $parent_id = ( isset($struct['parent_id']) ) ? absint($struct['parent_id']) : '' ; |
3336 | $mime_type = ( isset($struct['mime_type']) ) ? $struct['mime_type'] : '' ; |
3337 | $offset = ( isset($struct['offset']) ) ? absint($struct['offset']) : 0 ; |
3338 | $number = ( isset($struct['number']) ) ? absint($struct['number']) : -1 ; |
3339 |
|
3340 | $attachments = get_posts( array('post_type' => 'attachment', 'post_parent' => $parent_id, 'offset' => $offset, 'numberposts' => $number, 'post_mime_type' => $mime_type ) ); |
3341 |
|
3342 | $attachments_struct = array(); |
Line | Code |
3365 | $username = $args[1]; |
3366 | $password = $args[2]; |
3367 |
|
3368 | if ( !$user = $this->login( $username, $password ) ) |
3369 | return $this->error; |
3370 |
|
3371 | if ( !current_user_can( 'edit_posts' ) ) |
3372 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
3373 |
|
3374 | do_action( 'xmlrpc_call', 'wp.getPostFormats' ); |
3375 |
|
3376 | $formats = get_post_format_strings(); |
3377 |
|
3378 | # find out if they want a list of currently supports formats |
3379 | if ( isset( $args[3] ) && is_array( $args[3] ) ) { |
3380 | if ( $args[3]['show-supported'] ) { |
3381 | if ( current_theme_supports( 'post-formats' ) ) { |
3382 | $supported = get_theme_support( 'post-formats' ); |
3383 |
|
Line | Code |
3428 |
|
3429 | if ( isset( $args[4] ) ) |
3430 | $fields = $args[4]; |
3431 | else |
3432 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostType' ); |
3433 |
|
3434 | if ( !$user = $this->login( $username, $password ) ) |
3435 | return $this->error; |
3436 |
|
3437 | do_action( 'xmlrpc_call', 'wp.getPostType' ); |
3438 |
|
3439 | if( ! post_type_exists( $post_type_name ) ) |
3440 | return new IXR_Error( 403, __( 'Invalid post type' ) ); |
3441 |
|
3442 | $post_type = get_post_type_object( $post_type_name ); |
3443 |
|
3444 | if( ! current_user_can( $post_type->cap->edit_posts ) ) |
3445 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post type.' ) ); |
3446 |
|
Line | Code |
3474 |
|
3475 | if ( isset( $args[4] ) ) |
3476 | $fields = $args[4]; |
3477 | else |
3478 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostTypes' ); |
3479 |
|
3480 | if ( ! $user = $this->login( $username, $password ) ) |
3481 | return $this->error; |
3482 |
|
3483 | do_action( 'xmlrpc_call', 'wp.getPostTypes' ); |
3484 |
|
3485 | $post_types = get_post_types( $filter, 'objects' ); |
3486 |
|
3487 | $struct = array(); |
3488 |
|
3489 | foreach( $post_types as $post_type ) { |
3490 | if( ! current_user_can( $post_type->cap->edit_posts ) ) |
3491 | continue; |
3492 |
|
Line | Code |
3528 |
|
3529 | if ( isset( $args[4] ) ) |
3530 | $fields = $args[4]; |
3531 | else |
3532 | $fields = apply_filters( 'xmlrpc_default_revision_fields', array( 'post_date', 'post_date_gmt' ), 'wp.getRevisions' ); |
3533 |
|
3534 | if ( ! $user = $this->login( $username, $password ) ) |
3535 | return $this->error; |
3536 |
|
3537 | do_action( 'xmlrpc_call', 'wp.getRevisions' ); |
3538 |
|
3539 | if ( ! $post = get_post( $post_id ) ) |
3540 | return new IXR_Error( 404, __( 'Invalid post ID' ) ); |
3541 |
|
3542 | if ( ! current_user_can( 'edit_post', $post_id ) ) |
3543 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
3544 |
|
3545 | // Check if revisions are enabled. |
3546 | if ( ! wp_revisions_enabled( $post ) ) |
Line | Code |
3589 |
|
3590 | $blog_id = (int) $args[0]; |
3591 | $username = $args[1]; |
3592 | $password = $args[2]; |
3593 | $revision_id = (int) $args[3]; |
3594 |
|
3595 | if ( ! $user = $this->login( $username, $password ) ) |
3596 | return $this->error; |
3597 |
|
3598 | do_action( 'xmlrpc_call', 'wp.restoreRevision' ); |
3599 |
|
3600 | if ( ! $revision = wp_get_post_revision( $revision_id ) ) |
3601 | return new IXR_Error( 404, __( 'Invalid post ID' ) ); |
3602 |
|
3603 | if ( wp_is_post_autosave( $revision ) ) |
3604 | return new IXR_Error( 404, __( 'Invalid post ID' ) ); |
3605 |
|
3606 | if ( ! $post = get_post( $revision->post_parent ) ) |
3607 | return new IXR_Error( 404, __( 'Invalid post ID' ) ); |
Line | Code |
3638 |
|
3639 | $this->escape($args); |
3640 |
|
3641 | $username = $args[1]; |
3642 | $password = $args[2]; |
3643 |
|
3644 | if ( !$user = $this->login($username, $password) ) |
3645 | return $this->error; |
3646 |
|
3647 | do_action('xmlrpc_call', 'blogger.getUsersBlogs'); |
3648 |
|
3649 | $is_admin = current_user_can('manage_options'); |
3650 |
|
3651 | $struct = array( |
3652 | 'isAdmin' => $is_admin, |
3653 | 'url' => get_option('home') . '/', |
3654 | 'blogid' => '1', |
3655 | 'blogName' => get_option('blogname'), |
3656 | 'xmlrpc' => site_url( 'xmlrpc.php', 'rpc' ), |
Line | Code |
3705 | $username = $args[1]; |
3706 | $password = $args[2]; |
3707 |
|
3708 | if ( !$user = $this->login($username, $password) ) |
3709 | return $this->error; |
3710 |
|
3711 | if ( !current_user_can( 'edit_posts' ) ) |
3712 | return new IXR_Error( 401, __( 'Sorry, you do not have access to user data on this site.' ) ); |
3713 |
|
3714 | do_action('xmlrpc_call', 'blogger.getUserInfo'); |
3715 |
|
3716 | $struct = array( |
3717 | 'nickname' => $user->nickname, |
3718 | 'userid' => $user->ID, |
3719 | 'url' => $user->user_url, |
3720 | 'lastname' => $user->last_name, |
3721 | 'firstname' => $user->first_name |
3722 | ); |
3723 |
|
Line | Code |
3744 | return $this->error; |
3745 |
|
3746 | $post_data = get_post($post_ID, ARRAY_A); |
3747 | if ( ! $post_data ) |
3748 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
3749 |
|
3750 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
3751 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); |
3752 |
|
3753 | do_action('xmlrpc_call', 'blogger.getPost'); |
3754 |
|
3755 | $categories = implode(',', wp_get_post_categories($post_ID)); |
3756 |
|
3757 | $content = '<title>'.wp_unslash($post_data['post_title']).'</title>'; |
3758 | $content .= '<category>'.$categories.'</category>'; |
3759 | $content .= wp_unslash($post_data['post_content']); |
3760 |
|
3761 | $struct = array( |
3762 | 'userid' => $post_data['post_author'], |
Line | Code |
3789 | else |
3790 | $query = array(); |
3791 |
|
3792 | if ( !$user = $this->login($username, $password) ) |
3793 | return $this->error; |
3794 |
|
3795 | if ( ! current_user_can( 'edit_posts' ) ) |
3796 | return new IXR_Error( 401, __( 'Sorry, you cannot edit posts on this site.' ) ); |
3797 |
|
3798 | do_action('xmlrpc_call', 'blogger.getRecentPosts'); |
3799 |
|
3800 | $posts_list = wp_get_recent_posts( $query ); |
3801 |
|
3802 | if ( !$posts_list ) { |
3803 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
3804 | return $this->error; |
3805 | } |
3806 |
|
3807 | foreach ($posts_list as $entry) { |
Line | Code |
3867 | $blog_ID = (int) $args[1]; /* though we don't use it yet */ |
3868 | $username = $args[2]; |
3869 | $password = $args[3]; |
3870 | $content = $args[4]; |
3871 | $publish = $args[5]; |
3872 |
|
3873 | if ( !$user = $this->login($username, $password) ) |
3874 | return $this->error; |
3875 |
|
3876 | do_action('xmlrpc_call', 'blogger.newPost'); |
3877 |
|
3878 | $cap = ($publish) ? 'publish_posts' : 'edit_posts'; |
3879 | if ( ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) || !current_user_can($cap) ) |
3880 | return new IXR_Error(401, __('Sorry, you are not allowed to post on this site.')); |
3881 |
|
3882 | $post_status = ($publish) ? 'publish' : 'draft'; |
3883 |
|
3884 | $post_author = $user->ID; |
3885 |
|
Line | Code |
3921 | $post_ID = (int) $args[1]; |
3922 | $username = $args[2]; |
3923 | $password = $args[3]; |
3924 | $content = $args[4]; |
3925 | $publish = $args[5]; |
3926 |
|
3927 | if ( !$user = $this->login($username, $password) ) |
3928 | return $this->error; |
3929 |
|
3930 | do_action('xmlrpc_call', 'blogger.editPost'); |
3931 |
|
3932 | $actual_post = get_post($post_ID,ARRAY_A); |
3933 |
|
3934 | if ( !$actual_post || $actual_post['post_type'] != 'post' ) |
3935 | return new IXR_Error(404, __('Sorry, no such post.')); |
3936 |
|
3937 | $this->escape($actual_post); |
3938 |
|
3939 | if ( !current_user_can('edit_post', $post_ID) ) |
Line | Code |
3975 |
|
3976 | $post_ID = (int) $args[1]; |
3977 | $username = $args[2]; |
3978 | $password = $args[3]; |
3979 | $publish = $args[4]; |
3980 |
|
3981 | if ( !$user = $this->login($username, $password) ) |
3982 | return $this->error; |
3983 |
|
3984 | do_action('xmlrpc_call', 'blogger.deletePost'); |
3985 |
|
3986 | $actual_post = get_post($post_ID,ARRAY_A); |
3987 |
|
3988 | if ( !$actual_post || $actual_post['post_type'] != 'post' ) |
3989 | return new IXR_Error(404, __('Sorry, no such post.')); |
3990 |
|
3991 | if ( !current_user_can('delete_post', $post_ID) ) |
3992 | return new IXR_Error(401, __('Sorry, you do not have the right to delete this post.')); |
3993 |
|
Line | Code |
4046 | $blog_ID = (int) $args[0]; |
4047 | $username = $args[1]; |
4048 | $password = $args[2]; |
4049 | $content_struct = $args[3]; |
4050 | $publish = isset( $args[4] ) ? $args[4] : 0; |
4051 |
|
4052 | if ( !$user = $this->login($username, $password) ) |
4053 | return $this->error; |
4054 |
|
4055 | do_action('xmlrpc_call', 'metaWeblog.newPost'); |
4056 |
|
4057 | $page_template = ''; |
4058 | if ( !empty( $content_struct['post_type'] ) ) { |
4059 | if ( $content_struct['post_type'] == 'page' ) { |
4060 | if ( $publish ) |
4061 | $cap = 'publish_pages'; |
4062 | elseif ( isset( $content_struct['page_status'] ) && 'publish' == $content_struct['page_status'] ) |
4063 | $cap = 'publish_pages'; |
4064 | else |
Line | Code |
4365 | $post_ID = (int) $args[0]; |
4366 | $username = $args[1]; |
4367 | $password = $args[2]; |
4368 | $content_struct = $args[3]; |
4369 | $publish = isset( $args[4] ) ? $args[4] : 0; |
4370 |
|
4371 | if ( ! $user = $this->login($username, $password) ) |
4372 | return $this->error; |
4373 |
|
4374 | do_action('xmlrpc_call', 'metaWeblog.editPost'); |
4375 |
|
4376 | $postdata = get_post( $post_ID, ARRAY_A ); |
4377 |
|
4378 | // If there is no post data for the give post id, stop |
4379 | // now and return an error. Other wise a new post will be |
4380 | // created (which was the old behavior). |
4381 | if ( ! $postdata || empty( $postdata[ 'ID' ] ) ) |
4382 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
4383 |
|
Line | Code |
4639 | return $this->error; |
4640 |
|
4641 | $postdata = get_post($post_ID, ARRAY_A); |
4642 | if ( ! $postdata ) |
4643 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
4644 |
|
4645 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
4646 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); |
4647 |
|
4648 | do_action('xmlrpc_call', 'metaWeblog.getPost'); |
4649 |
|
4650 | if ($postdata['post_date'] != '') { |
4651 | $post_date = $this->_convert_date( $postdata['post_date'] ); |
4652 | $post_date_gmt = $this->_convert_date_gmt( $postdata['post_date_gmt'], $postdata['post_date'] ); |
4653 | $post_modified = $this->_convert_date( $postdata['post_modified'] ); |
4654 | $post_modified_gmt = $this->_convert_date_gmt( $postdata['post_modified_gmt'], $postdata['post_modified'] ); |
4655 |
|
4656 | $categories = array(); |
4657 | $catids = wp_get_post_categories($post_ID); |
Line | Code |
4763 | else |
4764 | $query = array(); |
4765 |
|
4766 | if ( !$user = $this->login($username, $password) ) |
4767 | return $this->error; |
4768 |
|
4769 | if ( ! current_user_can( 'edit_posts' ) ) |
4770 | return new IXR_Error( 401, __( 'Sorry, you cannot edit posts on this site.' ) ); |
4771 |
|
4772 | do_action('xmlrpc_call', 'metaWeblog.getRecentPosts'); |
4773 |
|
4774 | $posts_list = wp_get_recent_posts( $query ); |
4775 |
|
4776 | if ( !$posts_list ) |
4777 | return array(); |
4778 |
|
4779 | $struct = array(); |
4780 | foreach ($posts_list as $entry) { |
4781 | if ( !current_user_can( 'edit_post', $entry['ID'] ) ) |
Line | Code |
4877 | $username = $args[1]; |
4878 | $password = $args[2]; |
4879 |
|
4880 | if ( !$user = $this->login($username, $password) ) |
4881 | return $this->error; |
4882 |
|
4883 | if ( !current_user_can( 'edit_posts' ) ) |
4884 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
4885 |
|
4886 | do_action('xmlrpc_call', 'metaWeblog.getCategories'); |
4887 |
|
4888 | $categories_struct = array(); |
4889 |
|
4890 | if ( $cats = get_categories(array('get' => 'all')) ) { |
4891 | foreach ( $cats as $cat ) { |
4892 | $struct['categoryId'] = $cat->term_id; |
4893 | $struct['parentId'] = $cat->parent; |
4894 | $struct['description'] = $cat->name; |
4895 | $struct['categoryDescription'] = $cat->description; |
Line | Code |
4925 | $data = $args[3]; |
4926 |
|
4927 | $name = sanitize_file_name( $data['name'] ); |
4928 | $type = $data['type']; |
4929 | $bits = $data['bits']; |
4930 |
|
4931 | if ( !$user = $this->login($username, $password) ) |
4932 | return $this->error; |
4933 |
|
4934 | do_action('xmlrpc_call', 'metaWeblog.newMediaObject'); |
4935 |
|
4936 | if ( !current_user_can('upload_files') ) { |
4937 | $this->error = new IXR_Error( 401, __( 'You do not have permission to upload files.' ) ); |
4938 | return $this->error; |
4939 | } |
4940 |
|
4941 | if ( $upload_err = apply_filters( 'pre_upload_error', false ) ) |
4942 | return new IXR_Error(500, $upload_err); |
4943 |
|
Line | Code |
5017 | $password = $args[2]; |
5018 | if ( isset( $args[3] ) ) |
5019 | $query = array( 'numberposts' => absint( $args[3] ) ); |
5020 | else |
5021 | $query = array(); |
5022 |
|
5023 | if ( !$user = $this->login($username, $password) ) |
5024 | return $this->error; |
5025 |
|
5026 | do_action('xmlrpc_call', 'mt.getRecentPostTitles'); |
5027 |
|
5028 | $posts_list = wp_get_recent_posts( $query ); |
5029 |
|
5030 | if ( !$posts_list ) { |
5031 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
5032 | return $this->error; |
5033 | } |
5034 |
|
5035 | $struct = array(); |
Line | Code |
5076 | $username = $args[1]; |
5077 | $password = $args[2]; |
5078 |
|
5079 | if ( !$user = $this->login($username, $password) ) |
5080 | return $this->error; |
5081 |
|
5082 | if ( !current_user_can( 'edit_posts' ) ) |
5083 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
5084 |
|
5085 | do_action('xmlrpc_call', 'mt.getCategoryList'); |
5086 |
|
5087 | $categories_struct = array(); |
5088 |
|
5089 | if ( $cats = get_categories(array('hide_empty' => 0, 'hierarchical' => 0)) ) { |
5090 | foreach ( $cats as $cat ) { |
5091 | $struct['categoryId'] = $cat->term_id; |
5092 | $struct['categoryName'] = $cat->name; |
5093 |
|
5094 | $categories_struct[] = $struct; |
Line | Code |
5117 | if ( !$user = $this->login($username, $password) ) |
5118 | return $this->error; |
5119 |
|
5120 | if ( ! get_post( $post_ID ) ) |
5121 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
5122 |
|
5123 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
5124 | return new IXR_Error( 401, __( 'Sorry, you can not edit this post.' ) ); |
5125 |
|
5126 | do_action('xmlrpc_call', 'mt.getPostCategories'); |
5127 |
|
5128 | $categories = array(); |
5129 | $catids = wp_get_post_categories(intval($post_ID)); |
5130 | // first listed category will be the primary category |
5131 | $isPrimary = true; |
5132 | foreach ( $catids as $catid ) { |
5133 | $categories[] = array( |
5134 | 'categoryName' => get_cat_name($catid), |
5135 | 'categoryId' => (string) $catid, |
Line | Code |
5155 |
|
5156 | $post_ID = (int) $args[0]; |
5157 | $username = $args[1]; |
5158 | $password = $args[2]; |
5159 | $categories = $args[3]; |
5160 |
|
5161 | if ( !$user = $this->login($username, $password) ) |
5162 | return $this->error; |
5163 |
|
5164 | do_action('xmlrpc_call', 'mt.setPostCategories'); |
5165 |
|
5166 | if ( ! get_post( $post_ID ) ) |
5167 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
5168 |
|
5169 | if ( !current_user_can('edit_post', $post_ID) ) |
5170 | return new IXR_Error(401, __('Sorry, you cannot edit this post.')); |
5171 |
|
5172 | $catids = array(); |
5173 | foreach ( $categories as $cat ) { |
Line | Code |
5183 | * Retrieve an array of methods supported by this server. |
5184 | * |
5185 | * @since 1.5.0 |
5186 | * |
5187 | * @param array $args Method parameters. |
5188 | * @return array |
5189 | */ |
5190 | function mt_supportedMethods($args) { |
5191 |
|
5192 | do_action('xmlrpc_call', 'mt.supportedMethods'); |
5193 |
|
5194 | $supported_methods = array(); |
5195 | foreach ( $this->methods as $key => $value ) { |
5196 | $supported_methods[] = $key; |
5197 | } |
5198 |
|
5199 | return $supported_methods; |
5200 | } |
5201 |
|
5202 | /** |
5203 | * Retrieve an empty array because we don't support per-post text filters. |
5204 | * |
5205 | * @since 1.5.0 |
5206 | * |
5207 | * @param array $args Method parameters. |
5208 | */ |
5209 | function mt_supportedTextFilters($args) { |
5210 | do_action('xmlrpc_call', 'mt.supportedTextFilters'); |
5211 | return apply_filters('xmlrpc_text_filters', array()); |
5212 | } |
5213 |
|
5214 | /** |
5215 | * Retrieve trackbacks sent to a given post. |
5216 | * |
5217 | * @since 1.5.0 |
5218 | * |
5219 | * @param array $args Method parameters. |
5220 | * @return mixed |
5221 | */ |
5222 | function mt_getTrackbackPings($args) { |
5223 |
|
5224 | global $wpdb; |
5225 |
|
5226 | $post_ID = intval($args); |
5227 |
|
5228 | do_action('xmlrpc_call', 'mt.getTrackbackPings'); |
5229 |
|
5230 | $actual_post = get_post($post_ID, ARRAY_A); |
5231 |
|
5232 | if ( !$actual_post ) |
5233 | return new IXR_Error(404, __('Sorry, no such post.')); |
5234 |
|
5235 | $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) ); |
5236 |
|
5237 | if ( !$comments ) |
Line | Code |
5266 | $this->escape($args); |
5267 |
|
5268 | $post_ID = (int) $args[0]; |
5269 | $username = $args[1]; |
5270 | $password = $args[2]; |
5271 |
|
5272 | if ( !$user = $this->login($username, $password) ) |
5273 | return $this->error; |
5274 |
|
5275 | do_action('xmlrpc_call', 'mt.publishPost'); |
5276 |
|
5277 | $postdata = get_post($post_ID, ARRAY_A); |
5278 | if ( ! $postdata ) |
5279 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
5280 |
|
5281 | if ( !current_user_can('publish_posts') || !current_user_can('edit_post', $post_ID) ) |
5282 | return new IXR_Error(401, __('Sorry, you cannot publish this post.')); |
5283 |
|
5284 | $postdata['post_status'] = 'publish'; |
Line | Code |
5302 | * |
5303 | * @since 1.5.0 |
5304 | * |
5305 | * @param array $args Method parameters. |
5306 | * @return array |
5307 | */ |
5308 | function pingback_ping($args) { |
5309 | global $wpdb; |
5310 |
|
5311 | do_action('xmlrpc_call', 'pingback.ping'); |
5312 |
|
5313 | $this->escape($args); |
5314 |
|
5315 | $pagelinkedfrom = $args[0]; |
5316 | $pagelinkedto = $args[1]; |
5317 |
|
5318 | $title = ''; |
5319 |
|
5320 | $pagelinkedfrom = str_replace('&', '&', $pagelinkedfrom); |
Line | Code |
5480 | * @since 1.5.0 |
5481 | * |
5482 | * @param array $args Method parameters. |
5483 | * @return array |
5484 | */ |
5485 | function pingback_extensions_getPingbacks($args) { |
5486 |
|
5487 | global $wpdb; |
5488 |
|
5489 | do_action('xmlrpc_call', 'pingback.extensions.getPingbacks'); |
5490 |
|
5491 | $this->escape($args); |
5492 |
|
5493 | $url = $args; |
5494 |
|
5495 | $post_ID = url_to_postid($url); |
5496 | if ( !$post_ID ) { |
5497 | // We aren't sure that the resource is available and/or pingback enabled |
5498 | 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.' ) ); |