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 |
---|---|
464 |
|
465 | $this->escape( $args ); |
466 |
|
467 | $username = $args[0]; |
468 | $password = $args[1]; |
469 |
|
470 | if ( !$user = $this->login($username, $password) ) |
471 | return $this->error; |
472 |
|
473 | do_action( 'xmlrpc_call', 'wp.getUsersBlogs' ); |
474 |
|
475 | $blogs = (array) get_blogs_of_user( $user->ID ); |
476 | $struct = array(); |
477 |
|
478 | foreach ( $blogs as $blog ) { |
479 | // Don't include blogs that aren't hosted at this site |
480 | if ( $blog->site_id != $current_site->id ) |
481 | continue; |
482 |
|
Line | Code |
959 |
|
960 | $blog_id = (int) $args[0]; |
961 | $username = $args[1]; |
962 | $password = $args[2]; |
963 | $content_struct = $args[3]; |
964 |
|
965 | if ( ! $user = $this->login( $username, $password ) ) |
966 | return $this->error; |
967 |
|
968 | do_action( 'xmlrpc_call', 'wp.newPost' ); |
969 |
|
970 | unset( $content_struct['ID'] ); |
971 |
|
972 | return $this->_insert_post( $user, $content_struct ); |
973 | } |
974 |
|
975 | /** |
976 | * Helper method for filtering out elements from an array. |
977 | * |
Line | Code |
1244 | $blog_id = (int) $args[0]; |
1245 | $username = $args[1]; |
1246 | $password = $args[2]; |
1247 | $post_id = (int) $args[3]; |
1248 | $content_struct = $args[4]; |
1249 |
|
1250 | if ( ! $user = $this->login( $username, $password ) ) |
1251 | return $this->error; |
1252 |
|
1253 | do_action( 'xmlrpc_call', 'wp.editPost' ); |
1254 |
|
1255 | $post = get_post( $post_id, ARRAY_A ); |
1256 |
|
1257 | if ( empty( $post['ID'] ) ) |
1258 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
1259 |
|
1260 | if ( isset( $content_struct['if_not_modified_since'] ) ) { |
1261 | // If the post has been modified since the date provided, return an error. |
1262 | if ( mysql2date( 'U', $post['post_modified_gmt'] ) > $content_struct['if_not_modified_since']->getTimestamp() ) { |
Line | Code |
1305 |
|
1306 | $blog_id = (int) $args[0]; |
1307 | $username = $args[1]; |
1308 | $password = $args[2]; |
1309 | $post_id = (int) $args[3]; |
1310 |
|
1311 | if ( ! $user = $this->login( $username, $password ) ) |
1312 | return $this->error; |
1313 |
|
1314 | do_action( 'xmlrpc_call', 'wp.deletePost' ); |
1315 |
|
1316 | $post = get_post( $post_id, ARRAY_A ); |
1317 | if ( empty( $post['ID'] ) ) |
1318 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
1319 |
|
1320 | $post_type = get_post_type_object( $post['post_type'] ); |
1321 | if ( ! current_user_can( $post_type->cap->delete_post, $post_id ) ) |
1322 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) ); |
1323 |
|
Line | Code |
1386 |
|
1387 | if ( isset( $args[4] ) ) |
1388 | $fields = $args[4]; |
1389 | else |
1390 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPost' ); |
1391 |
|
1392 | if ( ! $user = $this->login( $username, $password ) ) |
1393 | return $this->error; |
1394 |
|
1395 | do_action( 'xmlrpc_call', 'wp.getPost' ); |
1396 |
|
1397 | $post = get_post( $post_id, ARRAY_A ); |
1398 |
|
1399 | if ( empty( $post['ID'] ) ) |
1400 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
1401 |
|
1402 | $post_type = get_post_type_object( $post['post_type'] ); |
1403 | if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) ) |
1404 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); |
Line | Code |
1443 |
|
1444 | if ( isset( $args[4] ) ) |
1445 | $fields = $args[4]; |
1446 | else |
1447 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPosts' ); |
1448 |
|
1449 | if ( ! $user = $this->login( $username, $password ) ) |
1450 | return $this->error; |
1451 |
|
1452 | do_action( 'xmlrpc_call', 'wp.getPosts' ); |
1453 |
|
1454 | $query = array(); |
1455 |
|
1456 | if ( isset( $filter['post_type'] ) ) { |
1457 | $post_type = get_post_type_object( $filter['post_type'] ); |
1458 | if ( ! ( (bool) $post_type ) ) |
1459 | return new IXR_Error( 403, __( 'The post type specified is not valid' ) ); |
1460 | } else { |
1461 | $post_type = get_post_type_object( 'post' ); |
Line | Code |
1533 |
|
1534 | $blog_id = (int) $args[0]; |
1535 | $username = $args[1]; |
1536 | $password = $args[2]; |
1537 | $content_struct = $args[3]; |
1538 |
|
1539 | if ( ! $user = $this->login( $username, $password ) ) |
1540 | return $this->error; |
1541 |
|
1542 | do_action( 'xmlrpc_call', 'wp.newTerm' ); |
1543 |
|
1544 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) |
1545 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
1546 |
|
1547 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
1548 |
|
1549 | if ( ! current_user_can( $taxonomy->cap->manage_terms ) ) |
1550 | return new IXR_Error( 401, __( 'You are not allowed to create terms in this taxonomy.' ) ); |
1551 |
|
Line | Code |
1621 | $blog_id = (int) $args[0]; |
1622 | $username = $args[1]; |
1623 | $password = $args[2]; |
1624 | $term_id = (int) $args[3]; |
1625 | $content_struct = $args[4]; |
1626 |
|
1627 | if ( ! $user = $this->login( $username, $password ) ) |
1628 | return $this->error; |
1629 |
|
1630 | do_action( 'xmlrpc_call', 'wp.editTerm' ); |
1631 |
|
1632 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) |
1633 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
1634 |
|
1635 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
1636 |
|
1637 | if ( ! current_user_can( $taxonomy->cap->edit_terms ) ) |
1638 | return new IXR_Error( 401, __( 'You are not allowed to edit terms in this taxonomy.' ) ); |
1639 |
|
Line | Code |
1713 | $blog_id = (int) $args[0]; |
1714 | $username = $args[1]; |
1715 | $password = $args[2]; |
1716 | $taxonomy = $args[3]; |
1717 | $term_id = (int) $args[4]; |
1718 |
|
1719 | if ( ! $user = $this->login( $username, $password ) ) |
1720 | return $this->error; |
1721 |
|
1722 | do_action( 'xmlrpc_call', 'wp.deleteTerm' ); |
1723 |
|
1724 | if ( ! taxonomy_exists( $taxonomy ) ) |
1725 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
1726 |
|
1727 | $taxonomy = get_taxonomy( $taxonomy ); |
1728 |
|
1729 | if ( ! current_user_can( $taxonomy->cap->delete_terms ) ) |
1730 | return new IXR_Error( 401, __( 'You are not allowed to delete terms in this taxonomy.' ) ); |
1731 |
|
Line | Code |
1780 | $blog_id = (int) $args[0]; |
1781 | $username = $args[1]; |
1782 | $password = $args[2]; |
1783 | $taxonomy = $args[3]; |
1784 | $term_id = (int) $args[4]; |
1785 |
|
1786 | if ( ! $user = $this->login( $username, $password ) ) |
1787 | return $this->error; |
1788 |
|
1789 | do_action( 'xmlrpc_call', 'wp.getTerm' ); |
1790 |
|
1791 | if ( ! taxonomy_exists( $taxonomy ) ) |
1792 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
1793 |
|
1794 | $taxonomy = get_taxonomy( $taxonomy ); |
1795 |
|
1796 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
1797 | return new IXR_Error( 401, __( 'You are not allowed to assign terms in this taxonomy.' ) ); |
1798 |
|
Line | Code |
1833 | $blog_id = (int) $args[0]; |
1834 | $username = $args[1]; |
1835 | $password = $args[2]; |
1836 | $taxonomy = $args[3]; |
1837 | $filter = isset( $args[4] ) ? $args[4] : array(); |
1838 |
|
1839 | if ( ! $user = $this->login( $username, $password ) ) |
1840 | return $this->error; |
1841 |
|
1842 | do_action( 'xmlrpc_call', 'wp.getTerms' ); |
1843 |
|
1844 | if ( ! taxonomy_exists( $taxonomy ) ) |
1845 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
1846 |
|
1847 | $taxonomy = get_taxonomy( $taxonomy ); |
1848 |
|
1849 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
1850 | return new IXR_Error( 401, __( 'You are not allowed to assign terms in this taxonomy.' ) ); |
1851 |
|
Line | Code |
1912 |
|
1913 | if ( isset( $args[4] ) ) |
1914 | $fields = $args[4]; |
1915 | else |
1916 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomy' ); |
1917 |
|
1918 | if ( ! $user = $this->login( $username, $password ) ) |
1919 | return $this->error; |
1920 |
|
1921 | do_action( 'xmlrpc_call', 'wp.getTaxonomy' ); |
1922 |
|
1923 | if ( ! taxonomy_exists( $taxonomy ) ) |
1924 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
1925 |
|
1926 | $taxonomy = get_taxonomy( $taxonomy ); |
1927 |
|
1928 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
1929 | return new IXR_Error( 401, __( 'You are not allowed to assign terms in this taxonomy.' ) ); |
1930 |
|
Line | Code |
1956 |
|
1957 | if ( isset( $args[4] ) ) |
1958 | $fields = $args[4]; |
1959 | else |
1960 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomies' ); |
1961 |
|
1962 | if ( ! $user = $this->login( $username, $password ) ) |
1963 | return $this->error; |
1964 |
|
1965 | do_action( 'xmlrpc_call', 'wp.getTaxonomies' ); |
1966 |
|
1967 | $taxonomies = get_taxonomies( $filter, 'objects' ); |
1968 |
|
1969 | // holds all the taxonomy data |
1970 | $struct = array(); |
1971 |
|
1972 | foreach ( $taxonomies as $taxonomy ) { |
1973 | // capability check for post_types |
1974 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
Line | Code |
2025 |
|
2026 | if ( isset( $args[4] ) ) |
2027 | $fields = $args[4]; |
2028 | else |
2029 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUser' ); |
2030 |
|
2031 | if ( ! $user = $this->login( $username, $password ) ) |
2032 | return $this->error; |
2033 |
|
2034 | do_action( 'xmlrpc_call', 'wp.getUser' ); |
2035 |
|
2036 | if ( ! current_user_can( 'edit_user', $user_id ) ) |
2037 | return new IXR_Error( 401, __( 'Sorry, you cannot edit users.' ) ); |
2038 |
|
2039 | $user_data = get_userdata( $user_id ); |
2040 |
|
2041 | if ( ! $user_data ) |
2042 | return new IXR_Error( 404, __( 'Invalid user ID' ) ); |
2043 |
|
Line | Code |
2078 |
|
2079 | if ( isset( $args[4] ) ) |
2080 | $fields = $args[4]; |
2081 | else |
2082 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUsers' ); |
2083 |
|
2084 | if ( ! $user = $this->login( $username, $password ) ) |
2085 | return $this->error; |
2086 |
|
2087 | do_action( 'xmlrpc_call', 'wp.getUsers' ); |
2088 |
|
2089 | if ( ! current_user_can( 'list_users' ) ) |
2090 | return new IXR_Error( 401, __( 'Sorry, you cannot list users.' ) ); |
2091 |
|
2092 | $query = array( 'fields' => 'all_with_meta' ); |
2093 |
|
2094 | $query['number'] = ( isset( $filter['number'] ) ) ? absint( $filter['number'] ) : 50; |
2095 | $query['offset'] = ( isset( $filter['offset'] ) ) ? absint( $filter['offset'] ) : 0; |
2096 |
|
Line | Code |
2145 |
|
2146 | if ( isset( $args[3] ) ) |
2147 | $fields = $args[3]; |
2148 | else |
2149 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getProfile' ); |
2150 |
|
2151 | if ( ! $user = $this->login( $username, $password ) ) |
2152 | return $this->error; |
2153 |
|
2154 | do_action( 'xmlrpc_call', 'wp.getProfile' ); |
2155 |
|
2156 | if ( ! current_user_can( 'edit_user', $user->ID ) ) |
2157 | return new IXR_Error( 401, __( 'Sorry, you cannot edit your profile.' ) ); |
2158 |
|
2159 | $user_data = get_userdata( $user->ID ); |
2160 |
|
2161 | return $this->_prepare_user( $user_data, $fields ); |
2162 | } |
2163 |
|
Line | Code |
2188 |
|
2189 | $blog_id = (int) $args[0]; |
2190 | $username = $args[1]; |
2191 | $password = $args[2]; |
2192 | $content_struct = $args[3]; |
2193 |
|
2194 | if ( ! $user = $this->login( $username, $password ) ) |
2195 | return $this->error; |
2196 |
|
2197 | do_action( 'xmlrpc_call', 'wp.editProfile' ); |
2198 |
|
2199 | if ( ! current_user_can( 'edit_user', $user->ID ) ) |
2200 | return new IXR_Error( 401, __( 'Sorry, you cannot edit your profile.' ) ); |
2201 |
|
2202 | // holds data of the user |
2203 | $user_data = array(); |
2204 | $user_data['ID'] = $user->ID; |
2205 |
|
2206 | // only set the user details if it was given |
Line | Code |
2261 | } |
2262 |
|
2263 | $page = get_post($page_id); |
2264 | if ( ! $page ) |
2265 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
2266 |
|
2267 | if ( !current_user_can( 'edit_page', $page_id ) ) |
2268 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this page.' ) ); |
2269 |
|
2270 | do_action('xmlrpc_call', 'wp.getPage'); |
2271 |
|
2272 | // If we found the page then format the data. |
2273 | if ( $page->ID && ($page->post_type == 'page') ) { |
2274 | return $this->_prepare_page( $page ); |
2275 | } |
2276 | // If the page doesn't exist indicate that. |
2277 | else { |
2278 | return(new IXR_Error(404, __('Sorry, no such page.'))); |
2279 | } |
Line | Code |
2299 | $password = $args[2]; |
2300 | $num_pages = isset($args[3]) ? (int) $args[3] : 10; |
2301 |
|
2302 | if ( !$user = $this->login($username, $password) ) |
2303 | return $this->error; |
2304 |
|
2305 | if ( !current_user_can( 'edit_pages' ) ) |
2306 | return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) ); |
2307 |
|
2308 | do_action('xmlrpc_call', 'wp.getPages'); |
2309 |
|
2310 | $pages = get_posts( array('post_type' => 'page', 'post_status' => 'any', 'numberposts' => $num_pages) ); |
2311 | $num_pages = count($pages); |
2312 |
|
2313 | // If we have pages, put together their info. |
2314 | if ( $num_pages >= 1 ) { |
2315 | $pages_struct = array(); |
2316 |
|
2317 | foreach ($pages as $page) { |
Line | Code |
2339 | // Items not escaped here will be escaped in newPost. |
2340 | $username = $this->escape($args[1]); |
2341 | $password = $this->escape($args[2]); |
2342 | $page = $args[3]; |
2343 | $publish = $args[4]; |
2344 |
|
2345 | if ( !$user = $this->login($username, $password) ) |
2346 | return $this->error; |
2347 |
|
2348 | do_action('xmlrpc_call', 'wp.newPage'); |
2349 |
|
2350 | // Mark this as content for a page. |
2351 | $args[3]["post_type"] = 'page'; |
2352 |
|
2353 | // Let mw_newPost do all of the heavy lifting. |
2354 | return($this->mw_newPost($args)); |
2355 | } |
2356 |
|
2357 | /** |
Line | Code |
2367 |
|
2368 | $blog_id = (int) $args[0]; |
2369 | $username = $args[1]; |
2370 | $password = $args[2]; |
2371 | $page_id = (int) $args[3]; |
2372 |
|
2373 | if ( !$user = $this->login($username, $password) ) |
2374 | return $this->error; |
2375 |
|
2376 | do_action('xmlrpc_call', 'wp.deletePage'); |
2377 |
|
2378 | // Get the current page based on the page_id and |
2379 | // make sure it is a page and not a post. |
2380 | $actual_page = get_post($page_id, ARRAY_A); |
2381 | if ( !$actual_page || ($actual_page['post_type'] != 'page') ) |
2382 | return(new IXR_Error(404, __('Sorry, no such page.'))); |
2383 |
|
2384 | // Make sure the user can delete pages. |
2385 | if ( !current_user_can('delete_page', $page_id) ) |
Line | Code |
2409 | $page_id = (int) $this->escape($args[1]); |
2410 | $username = $this->escape($args[2]); |
2411 | $password = $this->escape($args[3]); |
2412 | $content = $args[4]; |
2413 | $publish = $args[5]; |
2414 |
|
2415 | if ( !$user = $this->login($username, $password) ) |
2416 | return $this->error; |
2417 |
|
2418 | do_action('xmlrpc_call', 'wp.editPage'); |
2419 |
|
2420 | // Get the page data and make sure it is a page. |
2421 | $actual_page = get_post($page_id, ARRAY_A); |
2422 | if ( !$actual_page || ($actual_page['post_type'] != 'page') ) |
2423 | return(new IXR_Error(404, __('Sorry, no such page.'))); |
2424 |
|
2425 | // Make sure the user is allowed to edit pages. |
2426 | if ( !current_user_can('edit_page', $page_id) ) |
2427 | return(new IXR_Error(401, __('Sorry, you do not have the right to edit this page.'))); |
Line | Code |
2459 | $username = $args[1]; |
2460 | $password = $args[2]; |
2461 |
|
2462 | if ( !$user = $this->login($username, $password) ) |
2463 | return $this->error; |
2464 |
|
2465 | if ( !current_user_can( 'edit_pages' ) ) |
2466 | return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) ); |
2467 |
|
2468 | do_action('xmlrpc_call', 'wp.getPageList'); |
2469 |
|
2470 | // Get list of pages ids and titles |
2471 | $page_list = $wpdb->get_results(" |
2472 | SELECT ID page_id, |
2473 | post_title page_title, |
2474 | post_parent page_parent_id, |
2475 | post_date_gmt, |
2476 | post_date, |
2477 | post_status |
Line | Code |
2510 | $username = $args[1]; |
2511 | $password = $args[2]; |
2512 |
|
2513 | if ( !$user = $this->login($username, $password) ) |
2514 | return $this->error; |
2515 |
|
2516 | if ( !current_user_can('edit_posts') ) |
2517 | return(new IXR_Error(401, __('Sorry, you cannot edit posts on this site.'))); |
2518 |
|
2519 | do_action('xmlrpc_call', 'wp.getAuthors'); |
2520 |
|
2521 | $authors = array(); |
2522 | foreach ( get_users( array( 'fields' => array('ID','user_login','display_name') ) ) as $user ) { |
2523 | $authors[] = array( |
2524 | 'user_id' => $user->ID, |
2525 | 'user_login' => $user->user_login, |
2526 | 'display_name' => $user->display_name |
2527 | ); |
2528 | } |
Line | Code |
2545 | $username = $args[1]; |
2546 | $password = $args[2]; |
2547 |
|
2548 | if ( !$user = $this->login($username, $password) ) |
2549 | return $this->error; |
2550 |
|
2551 | if ( !current_user_can( 'edit_posts' ) ) |
2552 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view tags.' ) ); |
2553 |
|
2554 | do_action( 'xmlrpc_call', 'wp.getKeywords' ); |
2555 |
|
2556 | $tags = array(); |
2557 |
|
2558 | if ( $all_tags = get_tags() ) { |
2559 | foreach( (array) $all_tags as $tag ) { |
2560 | $struct['tag_id'] = $tag->term_id; |
2561 | $struct['name'] = $tag->name; |
2562 | $struct['count'] = $tag->count; |
2563 | $struct['slug'] = $tag->slug; |
Line | Code |
2584 |
|
2585 | $blog_id = (int) $args[0]; |
2586 | $username = $args[1]; |
2587 | $password = $args[2]; |
2588 | $category = $args[3]; |
2589 |
|
2590 | if ( !$user = $this->login($username, $password) ) |
2591 | return $this->error; |
2592 |
|
2593 | do_action('xmlrpc_call', 'wp.newCategory'); |
2594 |
|
2595 | // Make sure the user is allowed to add a category. |
2596 | if ( !current_user_can('manage_categories') ) |
2597 | return(new IXR_Error(401, __('Sorry, you do not have the right to add a category.'))); |
2598 |
|
2599 | // If no slug was provided make it empty so that |
2600 | // WordPress will generate one. |
2601 | if ( empty($category['slug']) ) |
2602 | $category['slug'] = ''; |
Line | Code |
2645 |
|
2646 | $blog_id = (int) $args[0]; |
2647 | $username = $args[1]; |
2648 | $password = $args[2]; |
2649 | $category_id = (int) $args[3]; |
2650 |
|
2651 | if ( !$user = $this->login($username, $password) ) |
2652 | return $this->error; |
2653 |
|
2654 | do_action('xmlrpc_call', 'wp.deleteCategory'); |
2655 |
|
2656 | if ( !current_user_can('manage_categories') ) |
2657 | return new IXR_Error( 401, __( 'Sorry, you do not have the right to delete a category.' ) ); |
2658 |
|
2659 | $status = wp_delete_term( $category_id, 'category' ); |
2660 |
|
2661 | if( true == $status ) |
2662 | do_action( 'xmlrpc_call_success_wp_deleteCategory', $category_id, $args ); |
2663 |
|
Line | Code |
2681 | $category = $args[3]; |
2682 | $max_results = (int) $args[4]; |
2683 |
|
2684 | if ( !$user = $this->login($username, $password) ) |
2685 | return $this->error; |
2686 |
|
2687 | if ( !current_user_can( 'edit_posts' ) ) |
2688 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts to this site in order to view categories.' ) ); |
2689 |
|
2690 | do_action('xmlrpc_call', 'wp.suggestCategories'); |
2691 |
|
2692 | $category_suggestions = array(); |
2693 | $args = array('get' => 'all', 'number' => $max_results, 'name__like' => $category); |
2694 | foreach ( (array) get_categories($args) as $cat ) { |
2695 | $category_suggestions[] = array( |
2696 | 'category_id' => $cat->term_id, |
2697 | 'category_name' => $cat->name |
2698 | ); |
2699 | } |
Line | Code |
2717 | $password = $args[2]; |
2718 | $comment_id = (int) $args[3]; |
2719 |
|
2720 | if ( !$user = $this->login($username, $password) ) |
2721 | return $this->error; |
2722 |
|
2723 | if ( !current_user_can( 'moderate_comments' ) ) |
2724 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
2725 |
|
2726 | do_action('xmlrpc_call', 'wp.getComment'); |
2727 |
|
2728 | if ( ! $comment = get_comment($comment_id) ) |
2729 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
2730 |
|
2731 | return $this->_prepare_comment( $comment ); |
2732 | } |
2733 |
|
2734 | /** |
2735 | * Retrieve comments. |
Line | Code |
2758 | $password = $args[2]; |
2759 | $struct = isset( $args[3] ) ? $args[3] : array(); |
2760 |
|
2761 | if ( !$user = $this->login($username, $password) ) |
2762 | return $this->error; |
2763 |
|
2764 | if ( !current_user_can( 'moderate_comments' ) ) |
2765 | return new IXR_Error( 401, __( 'Sorry, you cannot edit comments.' ) ); |
2766 |
|
2767 | do_action('xmlrpc_call', 'wp.getComments'); |
2768 |
|
2769 | if ( isset($struct['status']) ) |
2770 | $status = $struct['status']; |
2771 | else |
2772 | $status = ''; |
2773 |
|
2774 | $post_id = ''; |
2775 | if ( isset($struct['post_id']) ) |
2776 | $post_id = absint($struct['post_id']); |
Line | Code |
2824 | if ( !current_user_can( 'moderate_comments' ) ) |
2825 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
2826 |
|
2827 | if ( ! get_comment($comment_ID) ) |
2828 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
2829 |
|
2830 | if ( !current_user_can( 'edit_comment', $comment_ID ) ) |
2831 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
2832 |
|
2833 | do_action('xmlrpc_call', 'wp.deleteComment'); |
2834 |
|
2835 | $status = wp_delete_comment( $comment_ID ); |
2836 |
|
2837 | if( true == $status ) |
2838 | do_action( 'xmlrpc_call_success_wp_deleteComment', $comment_ID, $args ); |
2839 |
|
2840 | return $status; |
2841 | } |
2842 |
|
Line | Code |
2879 | if ( !current_user_can( 'moderate_comments' ) ) |
2880 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
2881 |
|
2882 | if ( ! get_comment($comment_ID) ) |
2883 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
2884 |
|
2885 | if ( !current_user_can( 'edit_comment', $comment_ID ) ) |
2886 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
2887 |
|
2888 | do_action('xmlrpc_call', 'wp.editComment'); |
2889 |
|
2890 | if ( isset($content_struct['status']) ) { |
2891 | $statuses = get_comment_statuses(); |
2892 | $statuses = array_keys($statuses); |
2893 |
|
2894 | if ( ! in_array($content_struct['status'], $statuses) ) |
2895 | return new IXR_Error( 401, __( 'Invalid comment status.' ) ); |
2896 | $comment_approved = $content_struct['status']; |
2897 | } |
Line | Code |
3003 | elseif ( !is_email($comment['comment_author_email']) ) |
3004 | return new IXR_Error( 403, __( 'A valid email address is required' ) ); |
3005 | } |
3006 | } |
3007 |
|
3008 | $comment['comment_parent'] = isset($content_struct['comment_parent']) ? absint($content_struct['comment_parent']) : 0; |
3009 |
|
3010 | $comment['comment_content'] = isset($content_struct['content']) ? $content_struct['content'] : null; |
3011 |
|
3012 | do_action('xmlrpc_call', 'wp.newComment'); |
3013 |
|
3014 | $comment_ID = wp_new_comment( $comment ); |
3015 |
|
3016 | do_action( 'xmlrpc_call_success_wp_newComment', $comment_ID, $args ); |
3017 |
|
3018 | return $comment_ID; |
3019 | } |
3020 |
|
3021 | /** |
Line | Code |
3033 | $username = $args[1]; |
3034 | $password = $args[2]; |
3035 |
|
3036 | if ( !$user = $this->login($username, $password) ) |
3037 | return $this->error; |
3038 |
|
3039 | if ( !current_user_can( 'moderate_comments' ) ) |
3040 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
3041 |
|
3042 | do_action('xmlrpc_call', 'wp.getCommentStatusList'); |
3043 |
|
3044 | return get_comment_statuses(); |
3045 | } |
3046 |
|
3047 | /** |
3048 | * Retrieve comment count. |
3049 | * |
3050 | * @since 2.5.0 |
3051 | * |
Line | Code |
3060 | $password = $args[2]; |
3061 | $post_id = (int) $args[3]; |
3062 |
|
3063 | if ( !$user = $this->login($username, $password) ) |
3064 | return $this->error; |
3065 |
|
3066 | if ( !current_user_can( 'edit_posts' ) ) |
3067 | return new IXR_Error( 403, __( 'You are not allowed access to details about comments.' ) ); |
3068 |
|
3069 | do_action('xmlrpc_call', 'wp.getCommentCount'); |
3070 |
|
3071 | $count = wp_count_comments( $post_id ); |
3072 | return array( |
3073 | 'approved' => $count->approved, |
3074 | 'awaiting_moderation' => $count->moderated, |
3075 | 'spam' => $count->spam, |
3076 | 'total_comments' => $count->total_comments |
3077 | ); |
3078 | } |
Line | Code |
3092 | $username = $args[1]; |
3093 | $password = $args[2]; |
3094 |
|
3095 | if ( !$user = $this->login($username, $password) ) |
3096 | return $this->error; |
3097 |
|
3098 | if ( !current_user_can( 'edit_posts' ) ) |
3099 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
3100 |
|
3101 | do_action('xmlrpc_call', 'wp.getPostStatusList'); |
3102 |
|
3103 | return get_post_statuses(); |
3104 | } |
3105 |
|
3106 | /** |
3107 | * Retrieve page statuses. |
3108 | * |
3109 | * @since 2.5.0 |
3110 | * |
Line | Code |
3118 | $username = $args[1]; |
3119 | $password = $args[2]; |
3120 |
|
3121 | if ( !$user = $this->login($username, $password) ) |
3122 | return $this->error; |
3123 |
|
3124 | if ( !current_user_can( 'edit_pages' ) ) |
3125 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
3126 |
|
3127 | do_action('xmlrpc_call', 'wp.getPageStatusList'); |
3128 |
|
3129 | return get_page_statuses(); |
3130 | } |
3131 |
|
3132 | /** |
3133 | * Retrieve page templates. |
3134 | * |
3135 | * @since 2.6.0 |
3136 | * |
Line | Code |
3271 | $password = $args[2]; |
3272 | $attachment_id = (int) $args[3]; |
3273 |
|
3274 | if ( !$user = $this->login($username, $password) ) |
3275 | return $this->error; |
3276 |
|
3277 | if ( !current_user_can( 'upload_files' ) ) |
3278 | return new IXR_Error( 403, __( 'You do not have permission to upload files.' ) ); |
3279 |
|
3280 | do_action('xmlrpc_call', 'wp.getMediaItem'); |
3281 |
|
3282 | if ( ! $attachment = get_post($attachment_id) ) |
3283 | return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); |
3284 |
|
3285 | return $this->_prepare_media_item( $attachment ); |
3286 | } |
3287 |
|
3288 | /** |
3289 | * Retrieves a collection of media library items (or attachments) |
Line | Code |
3316 | $password = $args[2]; |
3317 | $struct = isset( $args[3] ) ? $args[3] : array() ; |
3318 |
|
3319 | if ( !$user = $this->login($username, $password) ) |
3320 | return $this->error; |
3321 |
|
3322 | if ( !current_user_can( 'upload_files' ) ) |
3323 | return new IXR_Error( 401, __( 'You do not have permission to upload files.' ) ); |
3324 |
|
3325 | do_action('xmlrpc_call', 'wp.getMediaLibrary'); |
3326 |
|
3327 | $parent_id = ( isset($struct['parent_id']) ) ? absint($struct['parent_id']) : '' ; |
3328 | $mime_type = ( isset($struct['mime_type']) ) ? $struct['mime_type'] : '' ; |
3329 | $offset = ( isset($struct['offset']) ) ? absint($struct['offset']) : 0 ; |
3330 | $number = ( isset($struct['number']) ) ? absint($struct['number']) : -1 ; |
3331 |
|
3332 | $attachments = get_posts( array('post_type' => 'attachment', 'post_parent' => $parent_id, 'offset' => $offset, 'numberposts' => $number, 'post_mime_type' => $mime_type ) ); |
3333 |
|
3334 | $attachments_struct = array(); |
Line | Code |
3357 | $username = $args[1]; |
3358 | $password = $args[2]; |
3359 |
|
3360 | if ( !$user = $this->login( $username, $password ) ) |
3361 | return $this->error; |
3362 |
|
3363 | if ( !current_user_can( 'edit_posts' ) ) |
3364 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
3365 |
|
3366 | do_action( 'xmlrpc_call', 'wp.getPostFormats' ); |
3367 |
|
3368 | $formats = get_post_format_strings(); |
3369 |
|
3370 | # find out if they want a list of currently supports formats |
3371 | if ( isset( $args[3] ) && is_array( $args[3] ) ) { |
3372 | if ( $args[3]['show-supported'] ) { |
3373 | if ( current_theme_supports( 'post-formats' ) ) { |
3374 | $supported = get_theme_support( 'post-formats' ); |
3375 |
|
Line | Code |
3420 |
|
3421 | if ( isset( $args[4] ) ) |
3422 | $fields = $args[4]; |
3423 | else |
3424 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostType' ); |
3425 |
|
3426 | if ( !$user = $this->login( $username, $password ) ) |
3427 | return $this->error; |
3428 |
|
3429 | do_action( 'xmlrpc_call', 'wp.getPostType' ); |
3430 |
|
3431 | if( ! post_type_exists( $post_type_name ) ) |
3432 | return new IXR_Error( 403, __( 'Invalid post type' ) ); |
3433 |
|
3434 | $post_type = get_post_type_object( $post_type_name ); |
3435 |
|
3436 | if( ! current_user_can( $post_type->cap->edit_posts ) ) |
3437 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post type.' ) ); |
3438 |
|
Line | Code |
3466 |
|
3467 | if ( isset( $args[4] ) ) |
3468 | $fields = $args[4]; |
3469 | else |
3470 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostTypes' ); |
3471 |
|
3472 | if ( ! $user = $this->login( $username, $password ) ) |
3473 | return $this->error; |
3474 |
|
3475 | do_action( 'xmlrpc_call', 'wp.getPostTypes' ); |
3476 |
|
3477 | $post_types = get_post_types( $filter, 'objects' ); |
3478 |
|
3479 | $struct = array(); |
3480 |
|
3481 | foreach( $post_types as $post_type ) { |
3482 | if( ! current_user_can( $post_type->cap->edit_posts ) ) |
3483 | continue; |
3484 |
|
Line | Code |
3520 |
|
3521 | if ( isset( $args[4] ) ) |
3522 | $fields = $args[4]; |
3523 | else |
3524 | $fields = apply_filters( 'xmlrpc_default_revision_fields', array( 'post_date', 'post_date_gmt' ), 'wp.getRevisions' ); |
3525 |
|
3526 | if ( ! $user = $this->login( $username, $password ) ) |
3527 | return $this->error; |
3528 |
|
3529 | do_action( 'xmlrpc_call', 'wp.getRevisions' ); |
3530 |
|
3531 | if ( ! $post = get_post( $post_id ) ) |
3532 | return new IXR_Error( 404, __( 'Invalid post ID' ) ); |
3533 |
|
3534 | if ( ! current_user_can( 'edit_post', $post_id ) ) |
3535 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); |
3536 |
|
3537 | // Check if revisions are enabled. |
3538 | if ( ! WP_POST_REVISIONS || ! post_type_supports( $post->post_type, 'revisions' ) ) |
Line | Code |
3581 |
|
3582 | $blog_id = (int) $args[0]; |
3583 | $username = $args[1]; |
3584 | $password = $args[2]; |
3585 | $revision_id = (int) $args[3]; |
3586 |
|
3587 | if ( ! $user = $this->login( $username, $password ) ) |
3588 | return $this->error; |
3589 |
|
3590 | do_action( 'xmlrpc_call', 'wp.restoreRevision' ); |
3591 |
|
3592 | if ( ! $revision = wp_get_post_revision( $revision_id ) ) |
3593 | return new IXR_Error( 404, __( 'Invalid post ID' ) ); |
3594 |
|
3595 | if ( wp_is_post_autosave( $revision ) ) |
3596 | return new IXR_Error( 404, __( 'Invalid post ID' ) ); |
3597 |
|
3598 | if ( ! $post = get_post( $revision->post_parent ) ) |
3599 | return new IXR_Error( 404, __( 'Invalid post ID' ) ); |
Line | Code |
3630 |
|
3631 | $this->escape($args); |
3632 |
|
3633 | $username = $args[1]; |
3634 | $password = $args[2]; |
3635 |
|
3636 | if ( !$user = $this->login($username, $password) ) |
3637 | return $this->error; |
3638 |
|
3639 | do_action('xmlrpc_call', 'blogger.getUsersBlogs'); |
3640 |
|
3641 | $is_admin = current_user_can('manage_options'); |
3642 |
|
3643 | $struct = array( |
3644 | 'isAdmin' => $is_admin, |
3645 | 'url' => get_option('home') . '/', |
3646 | 'blogid' => '1', |
3647 | 'blogName' => get_option('blogname'), |
3648 | 'xmlrpc' => site_url( 'xmlrpc.php', 'rpc' ), |
Line | Code |
3697 | $username = $args[1]; |
3698 | $password = $args[2]; |
3699 |
|
3700 | if ( !$user = $this->login($username, $password) ) |
3701 | return $this->error; |
3702 |
|
3703 | if ( !current_user_can( 'edit_posts' ) ) |
3704 | return new IXR_Error( 401, __( 'Sorry, you do not have access to user data on this site.' ) ); |
3705 |
|
3706 | do_action('xmlrpc_call', 'blogger.getUserInfo'); |
3707 |
|
3708 | $struct = array( |
3709 | 'nickname' => $user->nickname, |
3710 | 'userid' => $user->ID, |
3711 | 'url' => $user->user_url, |
3712 | 'lastname' => $user->last_name, |
3713 | 'firstname' => $user->first_name |
3714 | ); |
3715 |
|
Line | Code |
3736 | return $this->error; |
3737 |
|
3738 | $post_data = get_post($post_ID, ARRAY_A); |
3739 | if ( ! $post_data ) |
3740 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
3741 |
|
3742 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
3743 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); |
3744 |
|
3745 | do_action('xmlrpc_call', 'blogger.getPost'); |
3746 |
|
3747 | $categories = implode(',', wp_get_post_categories($post_ID)); |
3748 |
|
3749 | $content = '<title>'.stripslashes($post_data['post_title']).'</title>'; |
3750 | $content .= '<category>'.$categories.'</category>'; |
3751 | $content .= stripslashes($post_data['post_content']); |
3752 |
|
3753 | $struct = array( |
3754 | 'userid' => $post_data['post_author'], |
Line | Code |
3778 | $password = $args[3]; |
3779 | if ( isset( $args[4] ) ) |
3780 | $query = array( 'numberposts' => absint( $args[4] ) ); |
3781 | else |
3782 | $query = array(); |
3783 |
|
3784 | if ( !$user = $this->login($username, $password) ) |
3785 | return $this->error; |
3786 |
|
3787 | do_action('xmlrpc_call', 'blogger.getRecentPosts'); |
3788 |
|
3789 | $posts_list = wp_get_recent_posts( $query ); |
3790 |
|
3791 | if ( !$posts_list ) { |
3792 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
3793 | return $this->error; |
3794 | } |
3795 |
|
3796 | foreach ($posts_list as $entry) { |
Line | Code |
3856 | $blog_ID = (int) $args[1]; /* though we don't use it yet */ |
3857 | $username = $args[2]; |
3858 | $password = $args[3]; |
3859 | $content = $args[4]; |
3860 | $publish = $args[5]; |
3861 |
|
3862 | if ( !$user = $this->login($username, $password) ) |
3863 | return $this->error; |
3864 |
|
3865 | do_action('xmlrpc_call', 'blogger.newPost'); |
3866 |
|
3867 | $cap = ($publish) ? 'publish_posts' : 'edit_posts'; |
3868 | if ( ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) || !current_user_can($cap) ) |
3869 | return new IXR_Error(401, __('Sorry, you are not allowed to post on this site.')); |
3870 |
|
3871 | $post_status = ($publish) ? 'publish' : 'draft'; |
3872 |
|
3873 | $post_author = $user->ID; |
3874 |
|
Line | Code |
3910 | $post_ID = (int) $args[1]; |
3911 | $username = $args[2]; |
3912 | $password = $args[3]; |
3913 | $content = $args[4]; |
3914 | $publish = $args[5]; |
3915 |
|
3916 | if ( !$user = $this->login($username, $password) ) |
3917 | return $this->error; |
3918 |
|
3919 | do_action('xmlrpc_call', 'blogger.editPost'); |
3920 |
|
3921 | $actual_post = get_post($post_ID,ARRAY_A); |
3922 |
|
3923 | if ( !$actual_post || $actual_post['post_type'] != 'post' ) |
3924 | return new IXR_Error(404, __('Sorry, no such post.')); |
3925 |
|
3926 | $this->escape($actual_post); |
3927 |
|
3928 | if ( !current_user_can('edit_post', $post_ID) ) |
Line | Code |
3964 |
|
3965 | $post_ID = (int) $args[1]; |
3966 | $username = $args[2]; |
3967 | $password = $args[3]; |
3968 | $publish = $args[4]; |
3969 |
|
3970 | if ( !$user = $this->login($username, $password) ) |
3971 | return $this->error; |
3972 |
|
3973 | do_action('xmlrpc_call', 'blogger.deletePost'); |
3974 |
|
3975 | $actual_post = get_post($post_ID,ARRAY_A); |
3976 |
|
3977 | if ( !$actual_post || $actual_post['post_type'] != 'post' ) |
3978 | return new IXR_Error(404, __('Sorry, no such post.')); |
3979 |
|
3980 | if ( !current_user_can('delete_post', $post_ID) ) |
3981 | return new IXR_Error(401, __('Sorry, you do not have the right to delete this post.')); |
3982 |
|
Line | Code |
4035 | $blog_ID = (int) $args[0]; |
4036 | $username = $args[1]; |
4037 | $password = $args[2]; |
4038 | $content_struct = $args[3]; |
4039 | $publish = isset( $args[4] ) ? $args[4] : 0; |
4040 |
|
4041 | if ( !$user = $this->login($username, $password) ) |
4042 | return $this->error; |
4043 |
|
4044 | do_action('xmlrpc_call', 'metaWeblog.newPost'); |
4045 |
|
4046 | $page_template = ''; |
4047 | if ( !empty( $content_struct['post_type'] ) ) { |
4048 | if ( $content_struct['post_type'] == 'page' ) { |
4049 | if ( $publish ) |
4050 | $cap = 'publish_pages'; |
4051 | elseif ( isset( $content_struct['page_status'] ) && 'publish' == $content_struct['page_status'] ) |
4052 | $cap = 'publish_pages'; |
4053 | else |
Line | Code |
4356 | $post_ID = (int) $args[0]; |
4357 | $username = $args[1]; |
4358 | $password = $args[2]; |
4359 | $content_struct = $args[3]; |
4360 | $publish = isset( $args[4] ) ? $args[4] : 0; |
4361 |
|
4362 | if ( ! $user = $this->login($username, $password) ) |
4363 | return $this->error; |
4364 |
|
4365 | do_action('xmlrpc_call', 'metaWeblog.editPost'); |
4366 |
|
4367 | $postdata = get_post( $post_ID, ARRAY_A ); |
4368 |
|
4369 | // If there is no post data for the give post id, stop |
4370 | // now and return an error. Other wise a new post will be |
4371 | // created (which was the old behavior). |
4372 | if ( ! $postdata || empty( $postdata[ 'ID' ] ) ) |
4373 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
4374 |
|
Line | Code |
4630 | return $this->error; |
4631 |
|
4632 | $postdata = get_post($post_ID, ARRAY_A); |
4633 | if ( ! $postdata ) |
4634 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
4635 |
|
4636 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
4637 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); |
4638 |
|
4639 | do_action('xmlrpc_call', 'metaWeblog.getPost'); |
4640 |
|
4641 | if ($postdata['post_date'] != '') { |
4642 | $post_date = $this->_convert_date( $postdata['post_date'] ); |
4643 | $post_date_gmt = $this->_convert_date_gmt( $postdata['post_date_gmt'], $postdata['post_date'] ); |
4644 | $post_modified = $this->_convert_date( $postdata['post_modified'] ); |
4645 | $post_modified_gmt = $this->_convert_date_gmt( $postdata['post_modified_gmt'], $postdata['post_modified'] ); |
4646 |
|
4647 | $categories = array(); |
4648 | $catids = wp_get_post_categories($post_ID); |
Line | Code |
4751 | $password = $args[2]; |
4752 | if ( isset( $args[3] ) ) |
4753 | $query = array( 'numberposts' => absint( $args[3] ) ); |
4754 | else |
4755 | $query = array(); |
4756 |
|
4757 | if ( !$user = $this->login($username, $password) ) |
4758 | return $this->error; |
4759 |
|
4760 | do_action('xmlrpc_call', 'metaWeblog.getRecentPosts'); |
4761 |
|
4762 | $posts_list = wp_get_recent_posts( $query ); |
4763 |
|
4764 | if ( !$posts_list ) |
4765 | return array(); |
4766 |
|
4767 | $struct = array(); |
4768 | foreach ($posts_list as $entry) { |
4769 | if ( !current_user_can( 'edit_post', $entry['ID'] ) ) |
Line | Code |
4865 | $username = $args[1]; |
4866 | $password = $args[2]; |
4867 |
|
4868 | if ( !$user = $this->login($username, $password) ) |
4869 | return $this->error; |
4870 |
|
4871 | if ( !current_user_can( 'edit_posts' ) ) |
4872 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
4873 |
|
4874 | do_action('xmlrpc_call', 'metaWeblog.getCategories'); |
4875 |
|
4876 | $categories_struct = array(); |
4877 |
|
4878 | if ( $cats = get_categories(array('get' => 'all')) ) { |
4879 | foreach ( $cats as $cat ) { |
4880 | $struct['categoryId'] = $cat->term_id; |
4881 | $struct['parentId'] = $cat->parent; |
4882 | $struct['description'] = $cat->name; |
4883 | $struct['categoryDescription'] = $cat->description; |
Line | Code |
4913 | $data = $args[3]; |
4914 |
|
4915 | $name = sanitize_file_name( $data['name'] ); |
4916 | $type = $data['type']; |
4917 | $bits = $data['bits']; |
4918 |
|
4919 | if ( !$user = $this->login($username, $password) ) |
4920 | return $this->error; |
4921 |
|
4922 | do_action('xmlrpc_call', 'metaWeblog.newMediaObject'); |
4923 |
|
4924 | if ( !current_user_can('upload_files') ) { |
4925 | $this->error = new IXR_Error( 401, __( 'You do not have permission to upload files.' ) ); |
4926 | return $this->error; |
4927 | } |
4928 |
|
4929 | if ( $upload_err = apply_filters( 'pre_upload_error', false ) ) |
4930 | return new IXR_Error(500, $upload_err); |
4931 |
|
Line | Code |
5005 | $password = $args[2]; |
5006 | if ( isset( $args[3] ) ) |
5007 | $query = array( 'numberposts' => absint( $args[3] ) ); |
5008 | else |
5009 | $query = array(); |
5010 |
|
5011 | if ( !$user = $this->login($username, $password) ) |
5012 | return $this->error; |
5013 |
|
5014 | do_action('xmlrpc_call', 'mt.getRecentPostTitles'); |
5015 |
|
5016 | $posts_list = wp_get_recent_posts( $query ); |
5017 |
|
5018 | if ( !$posts_list ) { |
5019 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
5020 | return $this->error; |
5021 | } |
5022 |
|
5023 | $struct = array(); |
Line | Code |
5064 | $username = $args[1]; |
5065 | $password = $args[2]; |
5066 |
|
5067 | if ( !$user = $this->login($username, $password) ) |
5068 | return $this->error; |
5069 |
|
5070 | if ( !current_user_can( 'edit_posts' ) ) |
5071 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
5072 |
|
5073 | do_action('xmlrpc_call', 'mt.getCategoryList'); |
5074 |
|
5075 | $categories_struct = array(); |
5076 |
|
5077 | if ( $cats = get_categories(array('hide_empty' => 0, 'hierarchical' => 0)) ) { |
5078 | foreach ( $cats as $cat ) { |
5079 | $struct['categoryId'] = $cat->term_id; |
5080 | $struct['categoryName'] = $cat->name; |
5081 |
|
5082 | $categories_struct[] = $struct; |
Line | Code |
5105 | if ( !$user = $this->login($username, $password) ) |
5106 | return $this->error; |
5107 |
|
5108 | if ( ! get_post( $post_ID ) ) |
5109 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
5110 |
|
5111 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
5112 | return new IXR_Error( 401, __( 'Sorry, you can not edit this post.' ) ); |
5113 |
|
5114 | do_action('xmlrpc_call', 'mt.getPostCategories'); |
5115 |
|
5116 | $categories = array(); |
5117 | $catids = wp_get_post_categories(intval($post_ID)); |
5118 | // first listed category will be the primary category |
5119 | $isPrimary = true; |
5120 | foreach ( $catids as $catid ) { |
5121 | $categories[] = array( |
5122 | 'categoryName' => get_cat_name($catid), |
5123 | 'categoryId' => (string) $catid, |
Line | Code |
5143 |
|
5144 | $post_ID = (int) $args[0]; |
5145 | $username = $args[1]; |
5146 | $password = $args[2]; |
5147 | $categories = $args[3]; |
5148 |
|
5149 | if ( !$user = $this->login($username, $password) ) |
5150 | return $this->error; |
5151 |
|
5152 | do_action('xmlrpc_call', 'mt.setPostCategories'); |
5153 |
|
5154 | if ( ! get_post( $post_ID ) ) |
5155 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
5156 |
|
5157 | if ( !current_user_can('edit_post', $post_ID) ) |
5158 | return new IXR_Error(401, __('Sorry, you cannot edit this post.')); |
5159 |
|
5160 | $catids = array(); |
5161 | foreach ( $categories as $cat ) { |
Line | Code |
5171 | * Retrieve an array of methods supported by this server. |
5172 | * |
5173 | * @since 1.5.0 |
5174 | * |
5175 | * @param array $args Method parameters. |
5176 | * @return array |
5177 | */ |
5178 | function mt_supportedMethods($args) { |
5179 |
|
5180 | do_action('xmlrpc_call', 'mt.supportedMethods'); |
5181 |
|
5182 | $supported_methods = array(); |
5183 | foreach ( $this->methods as $key => $value ) { |
5184 | $supported_methods[] = $key; |
5185 | } |
5186 |
|
5187 | return $supported_methods; |
5188 | } |
5189 |
|
5190 | /** |
5191 | * Retrieve an empty array because we don't support per-post text filters. |
5192 | * |
5193 | * @since 1.5.0 |
5194 | * |
5195 | * @param array $args Method parameters. |
5196 | */ |
5197 | function mt_supportedTextFilters($args) { |
5198 | do_action('xmlrpc_call', 'mt.supportedTextFilters'); |
5199 | return apply_filters('xmlrpc_text_filters', array()); |
5200 | } |
5201 |
|
5202 | /** |
5203 | * Retrieve trackbacks sent to a given post. |
5204 | * |
5205 | * @since 1.5.0 |
5206 | * |
5207 | * @param array $args Method parameters. |
5208 | * @return mixed |
5209 | */ |
5210 | function mt_getTrackbackPings($args) { |
5211 |
|
5212 | global $wpdb; |
5213 |
|
5214 | $post_ID = intval($args); |
5215 |
|
5216 | do_action('xmlrpc_call', 'mt.getTrackbackPings'); |
5217 |
|
5218 | $actual_post = get_post($post_ID, ARRAY_A); |
5219 |
|
5220 | if ( !$actual_post ) |
5221 | return new IXR_Error(404, __('Sorry, no such post.')); |
5222 |
|
5223 | $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) ); |
5224 |
|
5225 | if ( !$comments ) |
Line | Code |
5254 | $this->escape($args); |
5255 |
|
5256 | $post_ID = (int) $args[0]; |
5257 | $username = $args[1]; |
5258 | $password = $args[2]; |
5259 |
|
5260 | if ( !$user = $this->login($username, $password) ) |
5261 | return $this->error; |
5262 |
|
5263 | do_action('xmlrpc_call', 'mt.publishPost'); |
5264 |
|
5265 | $postdata = get_post($post_ID, ARRAY_A); |
5266 | if ( ! $postdata ) |
5267 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
5268 |
|
5269 | if ( !current_user_can('publish_posts') || !current_user_can('edit_post', $post_ID) ) |
5270 | return new IXR_Error(401, __('Sorry, you cannot publish this post.')); |
5271 |
|
5272 | $postdata['post_status'] = 'publish'; |
Line | Code |
5290 | * |
5291 | * @since 1.5.0 |
5292 | * |
5293 | * @param array $args Method parameters. |
5294 | * @return array |
5295 | */ |
5296 | function pingback_ping($args) { |
5297 | global $wpdb; |
5298 |
|
5299 | do_action('xmlrpc_call', 'pingback.ping'); |
5300 |
|
5301 | $this->escape($args); |
5302 |
|
5303 | $pagelinkedfrom = $args[0]; |
5304 | $pagelinkedto = $args[1]; |
5305 |
|
5306 | $title = ''; |
5307 |
|
5308 | $pagelinkedfrom = str_replace('&', '&', $pagelinkedfrom); |
Line | Code |
5458 | * @since 1.5.0 |
5459 | * |
5460 | * @param array $args Method parameters. |
5461 | * @return array |
5462 | */ |
5463 | function pingback_extensions_getPingbacks($args) { |
5464 |
|
5465 | global $wpdb; |
5466 |
|
5467 | do_action('xmlrpc_call', 'pingback.extensions.getPingbacks'); |
5468 |
|
5469 | $this->escape($args); |
5470 |
|
5471 | $url = $args; |
5472 |
|
5473 | $post_ID = url_to_postid($url); |
5474 | if ( !$post_ID ) { |
5475 | // We aren't sure that the resource is available and/or pingback enabled |
5476 | return new IXR_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.')); |