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