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 63 times in this file.
| Line | Code |
|---|---|
| 456 | |
| 457 | $this->escape( $args ); |
| 458 | |
| 459 | $username = $args[0]; |
| 460 | $password = $args[1]; |
| 461 | |
| 462 | if ( !$user = $this->login($username, $password) ) |
| 463 | return $this->error; |
| 464 | |
| 465 | do_action( 'xmlrpc_call', 'wp.getUsersBlogs' ); |
| 466 | |
| 467 | $blogs = (array) get_blogs_of_user( $user->ID ); |
| 468 | $struct = array(); |
| 469 | |
| 470 | foreach ( $blogs as $blog ) { |
| 471 | // Don't include blogs that aren't hosted at this site |
| 472 | if ( $blog->site_id != $current_site->id ) |
| 473 | continue; |
| 474 | |
| Line | Code |
| 905 | |
| 906 | $blog_id = (int) $args[0]; |
| 907 | $username = $args[1]; |
| 908 | $password = $args[2]; |
| 909 | $content_struct = $args[3]; |
| 910 | |
| 911 | if ( ! $user = $this->login( $username, $password ) ) |
| 912 | return $this->error; |
| 913 | |
| 914 | do_action( 'xmlrpc_call', 'wp.newPost' ); |
| 915 | |
| 916 | unset( $content_struct['ID'] ); |
| 917 | |
| 918 | return $this->_insert_post( $user, $content_struct ); |
| 919 | } |
| 920 | |
| 921 | /** |
| 922 | * Helper method for filtering out elements from an array. |
| 923 | * |
| Line | Code |
| 1188 | $blog_id = (int) $args[0]; |
| 1189 | $username = $args[1]; |
| 1190 | $password = $args[2]; |
| 1191 | $post_id = (int) $args[3]; |
| 1192 | $content_struct = $args[4]; |
| 1193 | |
| 1194 | if ( ! $user = $this->login( $username, $password ) ) |
| 1195 | return $this->error; |
| 1196 | |
| 1197 | do_action( 'xmlrpc_call', 'wp.editPost' ); |
| 1198 | |
| 1199 | $post = get_post( $post_id, ARRAY_A ); |
| 1200 | |
| 1201 | if ( empty( $post['ID'] ) ) |
| 1202 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 1203 | |
| 1204 | // convert the date field back to IXR form |
| 1205 | $post['post_date'] = $this->_convert_date( $post['post_date'] ); |
| 1206 | |
| Line | Code |
| 1242 | |
| 1243 | $blog_id = (int) $args[0]; |
| 1244 | $username = $args[1]; |
| 1245 | $password = $args[2]; |
| 1246 | $post_id = (int) $args[3]; |
| 1247 | |
| 1248 | if ( ! $user = $this->login( $username, $password ) ) |
| 1249 | return $this->error; |
| 1250 | |
| 1251 | do_action( 'xmlrpc_call', 'wp.deletePost' ); |
| 1252 | |
| 1253 | $post = wp_get_single_post( $post_id, ARRAY_A ); |
| 1254 | if ( empty( $post['ID'] ) ) |
| 1255 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 1256 | |
| 1257 | $post_type = get_post_type_object( $post['post_type'] ); |
| 1258 | if ( ! current_user_can( $post_type->cap->delete_post, $post_id ) ) |
| 1259 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) ); |
| 1260 | |
| Line | Code |
| 1323 | |
| 1324 | if ( isset( $args[4] ) ) |
| 1325 | $fields = $args[4]; |
| 1326 | else |
| 1327 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPost' ); |
| 1328 | |
| 1329 | if ( ! $user = $this->login( $username, $password ) ) |
| 1330 | return $this->error; |
| 1331 | |
| 1332 | do_action( 'xmlrpc_call', 'wp.getPost' ); |
| 1333 | |
| 1334 | $post = wp_get_single_post( $post_id, ARRAY_A ); |
| 1335 | |
| 1336 | if ( empty( $post['ID'] ) ) |
| 1337 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 1338 | |
| 1339 | $post_type = get_post_type_object( $post['post_type'] ); |
| 1340 | if ( ! current_user_can( $post_type->cap->edit_posts, $post_id ) ) |
| 1341 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); |
| Line | Code |
| 1380 | |
| 1381 | if ( isset( $args[4] ) ) |
| 1382 | $fields = $args[4]; |
| 1383 | else |
| 1384 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPosts' ); |
| 1385 | |
| 1386 | if ( ! $user = $this->login( $username, $password ) ) |
| 1387 | return $this->error; |
| 1388 | |
| 1389 | do_action( 'xmlrpc_call', 'wp.getPosts' ); |
| 1390 | |
| 1391 | $query = array(); |
| 1392 | |
| 1393 | if ( isset( $filter['post_type'] ) ) { |
| 1394 | $post_type = get_post_type_object( $filter['post_type'] ); |
| 1395 | if ( ! ( (bool) $post_type ) ) |
| 1396 | return new IXR_Error( 403, __( 'The post type specified is not valid' ) ); |
| 1397 | |
| 1398 | if ( ! current_user_can( $post_type->cap->edit_posts ) ) |
| Line | Code |
| 1464 | |
| 1465 | $blog_id = (int) $args[0]; |
| 1466 | $username = $args[1]; |
| 1467 | $password = $args[2]; |
| 1468 | $content_struct = $args[3]; |
| 1469 | |
| 1470 | if ( ! $user = $this->login( $username, $password ) ) |
| 1471 | return $this->error; |
| 1472 | |
| 1473 | do_action( 'xmlrpc_call', 'wp.newTerm' ); |
| 1474 | |
| 1475 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) |
| 1476 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
| 1477 | |
| 1478 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
| 1479 | |
| 1480 | if ( ! current_user_can( $taxonomy->cap->manage_terms ) ) |
| 1481 | return new IXR_Error( 401, __( 'You are not allowed to create terms in this taxonomy.' ) ); |
| 1482 | |
| Line | Code |
| 1552 | $blog_id = (int) $args[0]; |
| 1553 | $username = $args[1]; |
| 1554 | $password = $args[2]; |
| 1555 | $term_id = (int) $args[3]; |
| 1556 | $content_struct = $args[4]; |
| 1557 | |
| 1558 | if ( ! $user = $this->login( $username, $password ) ) |
| 1559 | return $this->error; |
| 1560 | |
| 1561 | do_action( 'xmlrpc_call', 'wp.editTerm' ); |
| 1562 | |
| 1563 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) |
| 1564 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
| 1565 | |
| 1566 | $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); |
| 1567 | |
| 1568 | if ( ! current_user_can( $taxonomy->cap->edit_terms ) ) |
| 1569 | return new IXR_Error( 401, __( 'You are not allowed to edit terms in this taxonomy.' ) ); |
| 1570 | |
| Line | Code |
| 1644 | $blog_id = (int) $args[0]; |
| 1645 | $username = $args[1]; |
| 1646 | $password = $args[2]; |
| 1647 | $taxonomy = $args[3]; |
| 1648 | $term_id = (int) $args[4]; |
| 1649 | |
| 1650 | if ( ! $user = $this->login( $username, $password ) ) |
| 1651 | return $this->error; |
| 1652 | |
| 1653 | do_action( 'xmlrpc_call', 'wp.deleteTerm' ); |
| 1654 | |
| 1655 | if ( ! taxonomy_exists( $taxonomy ) ) |
| 1656 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
| 1657 | |
| 1658 | $taxonomy = get_taxonomy( $taxonomy ); |
| 1659 | |
| 1660 | if ( ! current_user_can( $taxonomy->cap->delete_terms ) ) |
| 1661 | return new IXR_Error( 401, __( 'You are not allowed to delete terms in this taxonomy.' ) ); |
| 1662 | |
| Line | Code |
| 1711 | $blog_id = (int) $args[0]; |
| 1712 | $username = $args[1]; |
| 1713 | $password = $args[2]; |
| 1714 | $taxonomy = $args[3]; |
| 1715 | $term_id = (int) $args[4]; |
| 1716 | |
| 1717 | if ( ! $user = $this->login( $username, $password ) ) |
| 1718 | return $this->error; |
| 1719 | |
| 1720 | do_action( 'xmlrpc_call', 'wp.getTerm' ); |
| 1721 | |
| 1722 | if ( ! taxonomy_exists( $taxonomy ) ) |
| 1723 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
| 1724 | |
| 1725 | $taxonomy = get_taxonomy( $taxonomy ); |
| 1726 | |
| 1727 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
| 1728 | return new IXR_Error( 401, __( 'You are not allowed to assign terms in this taxonomy.' ) ); |
| 1729 | |
| Line | Code |
| 1764 | $blog_id = (int) $args[0]; |
| 1765 | $username = $args[1]; |
| 1766 | $password = $args[2]; |
| 1767 | $taxonomy = $args[3]; |
| 1768 | $filter = isset( $args[4] ) ? $args[4] : array(); |
| 1769 | |
| 1770 | if ( ! $user = $this->login( $username, $password ) ) |
| 1771 | return $this->error; |
| 1772 | |
| 1773 | do_action( 'xmlrpc_call', 'wp.getTerms' ); |
| 1774 | |
| 1775 | if ( ! taxonomy_exists( $taxonomy ) ) |
| 1776 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
| 1777 | |
| 1778 | $taxonomy = get_taxonomy( $taxonomy ); |
| 1779 | |
| 1780 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
| 1781 | return new IXR_Error( 401, __( 'You are not allowed to assign terms in this taxonomy.' ) ); |
| 1782 | |
| Line | Code |
| 1843 | |
| 1844 | if ( isset( $args[4] ) ) |
| 1845 | $fields = $args[4]; |
| 1846 | else |
| 1847 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomy' ); |
| 1848 | |
| 1849 | if ( ! $user = $this->login( $username, $password ) ) |
| 1850 | return $this->error; |
| 1851 | |
| 1852 | do_action( 'xmlrpc_call', 'wp.getTaxonomy' ); |
| 1853 | |
| 1854 | if ( ! taxonomy_exists( $taxonomy ) ) |
| 1855 | return new IXR_Error( 403, __( 'Invalid taxonomy' ) ); |
| 1856 | |
| 1857 | $taxonomy = get_taxonomy( $taxonomy ); |
| 1858 | |
| 1859 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
| 1860 | return new IXR_Error( 401, __( 'You are not allowed to assign terms in this taxonomy.' ) ); |
| 1861 | |
| Line | Code |
| 1887 | |
| 1888 | if ( isset( $args[4] ) ) |
| 1889 | $fields = $args[4]; |
| 1890 | else |
| 1891 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomies' ); |
| 1892 | |
| 1893 | if ( ! $user = $this->login( $username, $password ) ) |
| 1894 | return $this->error; |
| 1895 | |
| 1896 | do_action( 'xmlrpc_call', 'wp.getTaxonomies' ); |
| 1897 | |
| 1898 | $taxonomies = get_taxonomies( $filter, 'objects' ); |
| 1899 | |
| 1900 | // holds all the taxonomy data |
| 1901 | $struct = array(); |
| 1902 | |
| 1903 | foreach ( $taxonomies as $taxonomy ) { |
| 1904 | // capability check for post_types |
| 1905 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
| Line | Code |
| 1936 | } |
| 1937 | |
| 1938 | $page = get_page($page_id); |
| 1939 | if ( ! $page ) |
| 1940 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 1941 | |
| 1942 | if ( !current_user_can( 'edit_page', $page_id ) ) |
| 1943 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this page.' ) ); |
| 1944 | |
| 1945 | do_action('xmlrpc_call', 'wp.getPage'); |
| 1946 | |
| 1947 | // If we found the page then format the data. |
| 1948 | if ( $page->ID && ($page->post_type == 'page') ) { |
| 1949 | return $this->_prepare_page( $page ); |
| 1950 | } |
| 1951 | // If the page doesn't exist indicate that. |
| 1952 | else { |
| 1953 | return(new IXR_Error(404, __('Sorry, no such page.'))); |
| 1954 | } |
| Line | Code |
| 1974 | $password = $args[2]; |
| 1975 | $num_pages = isset($args[3]) ? (int) $args[3] : 10; |
| 1976 | |
| 1977 | if ( !$user = $this->login($username, $password) ) |
| 1978 | return $this->error; |
| 1979 | |
| 1980 | if ( !current_user_can( 'edit_pages' ) ) |
| 1981 | return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) ); |
| 1982 | |
| 1983 | do_action('xmlrpc_call', 'wp.getPages'); |
| 1984 | |
| 1985 | $pages = get_posts( array('post_type' => 'page', 'post_status' => 'any', 'numberposts' => $num_pages) ); |
| 1986 | $num_pages = count($pages); |
| 1987 | |
| 1988 | // If we have pages, put together their info. |
| 1989 | if ( $num_pages >= 1 ) { |
| 1990 | $pages_struct = array(); |
| 1991 | |
| 1992 | foreach ($pages as $page) { |
| Line | Code |
| 2014 | // Items not escaped here will be escaped in newPost. |
| 2015 | $username = $this->escape($args[1]); |
| 2016 | $password = $this->escape($args[2]); |
| 2017 | $page = $args[3]; |
| 2018 | $publish = $args[4]; |
| 2019 | |
| 2020 | if ( !$user = $this->login($username, $password) ) |
| 2021 | return $this->error; |
| 2022 | |
| 2023 | do_action('xmlrpc_call', 'wp.newPage'); |
| 2024 | |
| 2025 | // Mark this as content for a page. |
| 2026 | $args[3]["post_type"] = 'page'; |
| 2027 | |
| 2028 | // Let mw_newPost do all of the heavy lifting. |
| 2029 | return($this->mw_newPost($args)); |
| 2030 | } |
| 2031 | |
| 2032 | /** |
| Line | Code |
| 2042 | |
| 2043 | $blog_id = (int) $args[0]; |
| 2044 | $username = $args[1]; |
| 2045 | $password = $args[2]; |
| 2046 | $page_id = (int) $args[3]; |
| 2047 | |
| 2048 | if ( !$user = $this->login($username, $password) ) |
| 2049 | return $this->error; |
| 2050 | |
| 2051 | do_action('xmlrpc_call', 'wp.deletePage'); |
| 2052 | |
| 2053 | // Get the current page based on the page_id and |
| 2054 | // make sure it is a page and not a post. |
| 2055 | $actual_page = wp_get_single_post($page_id, ARRAY_A); |
| 2056 | if ( !$actual_page || ($actual_page['post_type'] != 'page') ) |
| 2057 | return(new IXR_Error(404, __('Sorry, no such page.'))); |
| 2058 | |
| 2059 | // Make sure the user can delete pages. |
| 2060 | if ( !current_user_can('delete_page', $page_id) ) |
| Line | Code |
| 2084 | $page_id = (int) $this->escape($args[1]); |
| 2085 | $username = $this->escape($args[2]); |
| 2086 | $password = $this->escape($args[3]); |
| 2087 | $content = $args[4]; |
| 2088 | $publish = $args[5]; |
| 2089 | |
| 2090 | if ( !$user = $this->login($username, $password) ) |
| 2091 | return $this->error; |
| 2092 | |
| 2093 | do_action('xmlrpc_call', 'wp.editPage'); |
| 2094 | |
| 2095 | // Get the page data and make sure it is a page. |
| 2096 | $actual_page = wp_get_single_post($page_id, ARRAY_A); |
| 2097 | if ( !$actual_page || ($actual_page['post_type'] != 'page') ) |
| 2098 | return(new IXR_Error(404, __('Sorry, no such page.'))); |
| 2099 | |
| 2100 | // Make sure the user is allowed to edit pages. |
| 2101 | if ( !current_user_can('edit_page', $page_id) ) |
| 2102 | return(new IXR_Error(401, __('Sorry, you do not have the right to edit this page.'))); |
| Line | Code |
| 2134 | $username = $args[1]; |
| 2135 | $password = $args[2]; |
| 2136 | |
| 2137 | if ( !$user = $this->login($username, $password) ) |
| 2138 | return $this->error; |
| 2139 | |
| 2140 | if ( !current_user_can( 'edit_pages' ) ) |
| 2141 | return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) ); |
| 2142 | |
| 2143 | do_action('xmlrpc_call', 'wp.getPageList'); |
| 2144 | |
| 2145 | // Get list of pages ids and titles |
| 2146 | $page_list = $wpdb->get_results(" |
| 2147 | SELECT ID page_id, |
| 2148 | post_title page_title, |
| 2149 | post_parent page_parent_id, |
| 2150 | post_date_gmt, |
| 2151 | post_date, |
| 2152 | post_status |
| Line | Code |
| 2185 | $username = $args[1]; |
| 2186 | $password = $args[2]; |
| 2187 | |
| 2188 | if ( !$user = $this->login($username, $password) ) |
| 2189 | return $this->error; |
| 2190 | |
| 2191 | if ( !current_user_can('edit_posts') ) |
| 2192 | return(new IXR_Error(401, __('Sorry, you cannot edit posts on this site.'))); |
| 2193 | |
| 2194 | do_action('xmlrpc_call', 'wp.getAuthors'); |
| 2195 | |
| 2196 | $authors = array(); |
| 2197 | foreach ( get_users( array( 'fields' => array('ID','user_login','display_name') ) ) as $user ) { |
| 2198 | $authors[] = array( |
| 2199 | 'user_id' => $user->ID, |
| 2200 | 'user_login' => $user->user_login, |
| 2201 | 'display_name' => $user->display_name |
| 2202 | ); |
| 2203 | } |
| Line | Code |
| 2220 | $username = $args[1]; |
| 2221 | $password = $args[2]; |
| 2222 | |
| 2223 | if ( !$user = $this->login($username, $password) ) |
| 2224 | return $this->error; |
| 2225 | |
| 2226 | if ( !current_user_can( 'edit_posts' ) ) |
| 2227 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view tags.' ) ); |
| 2228 | |
| 2229 | do_action( 'xmlrpc_call', 'wp.getKeywords' ); |
| 2230 | |
| 2231 | $tags = array(); |
| 2232 | |
| 2233 | if ( $all_tags = get_tags() ) { |
| 2234 | foreach( (array) $all_tags as $tag ) { |
| 2235 | $struct['tag_id'] = $tag->term_id; |
| 2236 | $struct['name'] = $tag->name; |
| 2237 | $struct['count'] = $tag->count; |
| 2238 | $struct['slug'] = $tag->slug; |
| Line | Code |
| 2259 | |
| 2260 | $blog_id = (int) $args[0]; |
| 2261 | $username = $args[1]; |
| 2262 | $password = $args[2]; |
| 2263 | $category = $args[3]; |
| 2264 | |
| 2265 | if ( !$user = $this->login($username, $password) ) |
| 2266 | return $this->error; |
| 2267 | |
| 2268 | do_action('xmlrpc_call', 'wp.newCategory'); |
| 2269 | |
| 2270 | // Make sure the user is allowed to add a category. |
| 2271 | if ( !current_user_can('manage_categories') ) |
| 2272 | return(new IXR_Error(401, __('Sorry, you do not have the right to add a category.'))); |
| 2273 | |
| 2274 | // If no slug was provided make it empty so that |
| 2275 | // WordPress will generate one. |
| 2276 | if ( empty($category['slug']) ) |
| 2277 | $category['slug'] = ''; |
| Line | Code |
| 2320 | |
| 2321 | $blog_id = (int) $args[0]; |
| 2322 | $username = $args[1]; |
| 2323 | $password = $args[2]; |
| 2324 | $category_id = (int) $args[3]; |
| 2325 | |
| 2326 | if ( !$user = $this->login($username, $password) ) |
| 2327 | return $this->error; |
| 2328 | |
| 2329 | do_action('xmlrpc_call', 'wp.deleteCategory'); |
| 2330 | |
| 2331 | if ( !current_user_can('manage_categories') ) |
| 2332 | return new IXR_Error( 401, __( 'Sorry, you do not have the right to delete a category.' ) ); |
| 2333 | |
| 2334 | $status = wp_delete_term( $category_id, 'category' ); |
| 2335 | |
| 2336 | if( true == $status ) |
| 2337 | do_action( 'xmlrpc_call_success_wp_deleteCategory', $category_id, $args ); |
| 2338 | |
| Line | Code |
| 2356 | $category = $args[3]; |
| 2357 | $max_results = (int) $args[4]; |
| 2358 | |
| 2359 | if ( !$user = $this->login($username, $password) ) |
| 2360 | return $this->error; |
| 2361 | |
| 2362 | if ( !current_user_can( 'edit_posts' ) ) |
| 2363 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts to this site in order to view categories.' ) ); |
| 2364 | |
| 2365 | do_action('xmlrpc_call', 'wp.suggestCategories'); |
| 2366 | |
| 2367 | $category_suggestions = array(); |
| 2368 | $args = array('get' => 'all', 'number' => $max_results, 'name__like' => $category); |
| 2369 | foreach ( (array) get_categories($args) as $cat ) { |
| 2370 | $category_suggestions[] = array( |
| 2371 | 'category_id' => $cat->term_id, |
| 2372 | 'category_name' => $cat->name |
| 2373 | ); |
| 2374 | } |
| Line | Code |
| 2392 | $password = $args[2]; |
| 2393 | $comment_id = (int) $args[3]; |
| 2394 | |
| 2395 | if ( !$user = $this->login($username, $password) ) |
| 2396 | return $this->error; |
| 2397 | |
| 2398 | if ( !current_user_can( 'moderate_comments' ) ) |
| 2399 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
| 2400 | |
| 2401 | do_action('xmlrpc_call', 'wp.getComment'); |
| 2402 | |
| 2403 | if ( ! $comment = get_comment($comment_id) ) |
| 2404 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 2405 | |
| 2406 | return $this->_prepare_comment( $comment ); |
| 2407 | } |
| 2408 | |
| 2409 | /** |
| 2410 | * Retrieve comments. |
| Line | Code |
| 2433 | $password = $args[2]; |
| 2434 | $struct = isset( $args[3] ) ? $args[3] : array(); |
| 2435 | |
| 2436 | if ( !$user = $this->login($username, $password) ) |
| 2437 | return $this->error; |
| 2438 | |
| 2439 | if ( !current_user_can( 'moderate_comments' ) ) |
| 2440 | return new IXR_Error( 401, __( 'Sorry, you cannot edit comments.' ) ); |
| 2441 | |
| 2442 | do_action('xmlrpc_call', 'wp.getComments'); |
| 2443 | |
| 2444 | if ( isset($struct['status']) ) |
| 2445 | $status = $struct['status']; |
| 2446 | else |
| 2447 | $status = ''; |
| 2448 | |
| 2449 | $post_id = ''; |
| 2450 | if ( isset($struct['post_id']) ) |
| 2451 | $post_id = absint($struct['post_id']); |
| Line | Code |
| 2499 | if ( !current_user_can( 'moderate_comments' ) ) |
| 2500 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
| 2501 | |
| 2502 | if ( ! get_comment($comment_ID) ) |
| 2503 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 2504 | |
| 2505 | if ( !current_user_can( 'edit_comment', $comment_ID ) ) |
| 2506 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
| 2507 | |
| 2508 | do_action('xmlrpc_call', 'wp.deleteComment'); |
| 2509 | |
| 2510 | $status = wp_delete_comment( $comment_ID ); |
| 2511 | |
| 2512 | if( true == $status ) |
| 2513 | do_action( 'xmlrpc_call_success_wp_deleteComment', $comment_ID, $args ); |
| 2514 | |
| 2515 | return $status; |
| 2516 | } |
| 2517 | |
| Line | Code |
| 2554 | if ( !current_user_can( 'moderate_comments' ) ) |
| 2555 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
| 2556 | |
| 2557 | if ( ! get_comment($comment_ID) ) |
| 2558 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| 2559 | |
| 2560 | if ( !current_user_can( 'edit_comment', $comment_ID ) ) |
| 2561 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
| 2562 | |
| 2563 | do_action('xmlrpc_call', 'wp.editComment'); |
| 2564 | |
| 2565 | if ( isset($content_struct['status']) ) { |
| 2566 | $statuses = get_comment_statuses(); |
| 2567 | $statuses = array_keys($statuses); |
| 2568 | |
| 2569 | if ( ! in_array($content_struct['status'], $statuses) ) |
| 2570 | return new IXR_Error( 401, __( 'Invalid comment status.' ) ); |
| 2571 | $comment_approved = $content_struct['status']; |
| 2572 | } |
| Line | Code |
| 2678 | elseif ( !is_email($comment['comment_author_email']) ) |
| 2679 | return new IXR_Error( 403, __( 'A valid email address is required' ) ); |
| 2680 | } |
| 2681 | } |
| 2682 | |
| 2683 | $comment['comment_parent'] = isset($content_struct['comment_parent']) ? absint($content_struct['comment_parent']) : 0; |
| 2684 | |
| 2685 | $comment['comment_content'] = isset($content_struct['content']) ? $content_struct['content'] : null; |
| 2686 | |
| 2687 | do_action('xmlrpc_call', 'wp.newComment'); |
| 2688 | |
| 2689 | $comment_ID = wp_new_comment( $comment ); |
| 2690 | |
| 2691 | do_action( 'xmlrpc_call_success_wp_newComment', $comment_ID, $args ); |
| 2692 | |
| 2693 | return $comment_ID; |
| 2694 | } |
| 2695 | |
| 2696 | /** |
| Line | Code |
| 2708 | $username = $args[1]; |
| 2709 | $password = $args[2]; |
| 2710 | |
| 2711 | if ( !$user = $this->login($username, $password) ) |
| 2712 | return $this->error; |
| 2713 | |
| 2714 | if ( !current_user_can( 'moderate_comments' ) ) |
| 2715 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
| 2716 | |
| 2717 | do_action('xmlrpc_call', 'wp.getCommentStatusList'); |
| 2718 | |
| 2719 | return get_comment_statuses(); |
| 2720 | } |
| 2721 | |
| 2722 | /** |
| 2723 | * Retrieve comment count. |
| 2724 | * |
| 2725 | * @since 2.5.0 |
| 2726 | * |
| Line | Code |
| 2735 | $password = $args[2]; |
| 2736 | $post_id = (int) $args[3]; |
| 2737 | |
| 2738 | if ( !$user = $this->login($username, $password) ) |
| 2739 | return $this->error; |
| 2740 | |
| 2741 | if ( !current_user_can( 'edit_posts' ) ) |
| 2742 | return new IXR_Error( 403, __( 'You are not allowed access to details about comments.' ) ); |
| 2743 | |
| 2744 | do_action('xmlrpc_call', 'wp.getCommentCount'); |
| 2745 | |
| 2746 | $count = wp_count_comments( $post_id ); |
| 2747 | return array( |
| 2748 | 'approved' => $count->approved, |
| 2749 | 'awaiting_moderation' => $count->moderated, |
| 2750 | 'spam' => $count->spam, |
| 2751 | 'total_comments' => $count->total_comments |
| 2752 | ); |
| 2753 | } |
| Line | Code |
| 2767 | $username = $args[1]; |
| 2768 | $password = $args[2]; |
| 2769 | |
| 2770 | if ( !$user = $this->login($username, $password) ) |
| 2771 | return $this->error; |
| 2772 | |
| 2773 | if ( !current_user_can( 'edit_posts' ) ) |
| 2774 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
| 2775 | |
| 2776 | do_action('xmlrpc_call', 'wp.getPostStatusList'); |
| 2777 | |
| 2778 | return get_post_statuses(); |
| 2779 | } |
| 2780 | |
| 2781 | /** |
| 2782 | * Retrieve page statuses. |
| 2783 | * |
| 2784 | * @since 2.5.0 |
| 2785 | * |
| Line | Code |
| 2793 | $username = $args[1]; |
| 2794 | $password = $args[2]; |
| 2795 | |
| 2796 | if ( !$user = $this->login($username, $password) ) |
| 2797 | return $this->error; |
| 2798 | |
| 2799 | if ( !current_user_can( 'edit_pages' ) ) |
| 2800 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
| 2801 | |
| 2802 | do_action('xmlrpc_call', 'wp.getPageStatusList'); |
| 2803 | |
| 2804 | return get_page_statuses(); |
| 2805 | } |
| 2806 | |
| 2807 | /** |
| 2808 | * Retrieve page templates. |
| 2809 | * |
| 2810 | * @since 2.6.0 |
| 2811 | * |
| Line | Code |
| 2946 | $password = $args[2]; |
| 2947 | $attachment_id = (int) $args[3]; |
| 2948 | |
| 2949 | if ( !$user = $this->login($username, $password) ) |
| 2950 | return $this->error; |
| 2951 | |
| 2952 | if ( !current_user_can( 'upload_files' ) ) |
| 2953 | return new IXR_Error( 403, __( 'You do not have permission to upload files.' ) ); |
| 2954 | |
| 2955 | do_action('xmlrpc_call', 'wp.getMediaItem'); |
| 2956 | |
| 2957 | if ( ! $attachment = get_post($attachment_id) ) |
| 2958 | return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); |
| 2959 | |
| 2960 | return $this->_prepare_media_item( $attachment ); |
| 2961 | } |
| 2962 | |
| 2963 | /** |
| 2964 | * Retrieves a collection of media library items (or attachments) |
| Line | Code |
| 2991 | $password = $args[2]; |
| 2992 | $struct = isset( $args[3] ) ? $args[3] : array() ; |
| 2993 | |
| 2994 | if ( !$user = $this->login($username, $password) ) |
| 2995 | return $this->error; |
| 2996 | |
| 2997 | if ( !current_user_can( 'upload_files' ) ) |
| 2998 | return new IXR_Error( 401, __( 'You do not have permission to upload files.' ) ); |
| 2999 | |
| 3000 | do_action('xmlrpc_call', 'wp.getMediaLibrary'); |
| 3001 | |
| 3002 | $parent_id = ( isset($struct['parent_id']) ) ? absint($struct['parent_id']) : '' ; |
| 3003 | $mime_type = ( isset($struct['mime_type']) ) ? $struct['mime_type'] : '' ; |
| 3004 | $offset = ( isset($struct['offset']) ) ? absint($struct['offset']) : 0 ; |
| 3005 | $number = ( isset($struct['number']) ) ? absint($struct['number']) : -1 ; |
| 3006 | |
| 3007 | $attachments = get_posts( array('post_type' => 'attachment', 'post_parent' => $parent_id, 'offset' => $offset, 'numberposts' => $number, 'post_mime_type' => $mime_type ) ); |
| 3008 | |
| 3009 | $attachments_struct = array(); |
| Line | Code |
| 3032 | $username = $args[1]; |
| 3033 | $password = $args[2]; |
| 3034 | |
| 3035 | if ( !$user = $this->login( $username, $password ) ) |
| 3036 | return $this->error; |
| 3037 | |
| 3038 | if ( !current_user_can( 'edit_posts' ) ) |
| 3039 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
| 3040 | |
| 3041 | do_action( 'xmlrpc_call', 'wp.getPostFormats' ); |
| 3042 | |
| 3043 | $formats = get_post_format_strings(); |
| 3044 | |
| 3045 | # find out if they want a list of currently supports formats |
| 3046 | if ( isset( $args[3] ) && is_array( $args[3] ) ) { |
| 3047 | if ( $args[3]['show-supported'] ) { |
| 3048 | if ( current_theme_supports( 'post-formats' ) ) { |
| 3049 | $supported = get_theme_support( 'post-formats' ); |
| 3050 | |
| Line | Code |
| 3095 | |
| 3096 | if ( isset( $args[4] ) ) |
| 3097 | $fields = $args[4]; |
| 3098 | else |
| 3099 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostType' ); |
| 3100 | |
| 3101 | if ( !$user = $this->login( $username, $password ) ) |
| 3102 | return $this->error; |
| 3103 | |
| 3104 | do_action( 'xmlrpc_call', 'wp.getPostType' ); |
| 3105 | |
| 3106 | if( ! post_type_exists( $post_type_name ) ) |
| 3107 | return new IXR_Error( 403, __( 'Invalid post type' ) ); |
| 3108 | |
| 3109 | $post_type = get_post_type_object( $post_type_name ); |
| 3110 | |
| 3111 | if( ! current_user_can( $post_type->cap->edit_posts ) ) |
| 3112 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post type.' ) ); |
| 3113 | |
| Line | Code |
| 3141 | |
| 3142 | if ( isset( $args[4] ) ) |
| 3143 | $fields = $args[4]; |
| 3144 | else |
| 3145 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostTypes' ); |
| 3146 | |
| 3147 | if ( ! $user = $this->login( $username, $password ) ) |
| 3148 | return $this->error; |
| 3149 | |
| 3150 | do_action( 'xmlrpc_call', 'wp.getPostTypes' ); |
| 3151 | |
| 3152 | $post_types = get_post_types( $filter, 'objects' ); |
| 3153 | |
| 3154 | $struct = array(); |
| 3155 | |
| 3156 | foreach( $post_types as $post_type ) { |
| 3157 | if( ! current_user_can( $post_type->cap->edit_posts ) ) |
| 3158 | continue; |
| 3159 | |
| Line | Code |
| 3183 | |
| 3184 | $this->escape($args); |
| 3185 | |
| 3186 | $username = $args[1]; |
| 3187 | $password = $args[2]; |
| 3188 | |
| 3189 | if ( !$user = $this->login($username, $password) ) |
| 3190 | return $this->error; |
| 3191 | |
| 3192 | do_action('xmlrpc_call', 'blogger.getUsersBlogs'); |
| 3193 | |
| 3194 | $is_admin = current_user_can('manage_options'); |
| 3195 | |
| 3196 | $struct = array( |
| 3197 | 'isAdmin' => $is_admin, |
| 3198 | 'url' => get_option('home') . '/', |
| 3199 | 'blogid' => '1', |
| 3200 | 'blogName' => get_option('blogname'), |
| 3201 | 'xmlrpc' => site_url( 'xmlrpc.php' ) |
| Line | Code |
| 3250 | $username = $args[1]; |
| 3251 | $password = $args[2]; |
| 3252 | |
| 3253 | if ( !$user = $this->login($username, $password) ) |
| 3254 | return $this->error; |
| 3255 | |
| 3256 | if ( !current_user_can( 'edit_posts' ) ) |
| 3257 | return new IXR_Error( 401, __( 'Sorry, you do not have access to user data on this site.' ) ); |
| 3258 | |
| 3259 | do_action('xmlrpc_call', 'blogger.getUserInfo'); |
| 3260 | |
| 3261 | $struct = array( |
| 3262 | 'nickname' => $user->nickname, |
| 3263 | 'userid' => $user->ID, |
| 3264 | 'url' => $user->user_url, |
| 3265 | 'lastname' => $user->last_name, |
| 3266 | 'firstname' => $user->first_name |
| 3267 | ); |
| 3268 | |
| Line | Code |
| 3289 | return $this->error; |
| 3290 | |
| 3291 | $post_data = wp_get_single_post($post_ID, ARRAY_A); |
| 3292 | if ( ! $post_data ) |
| 3293 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 3294 | |
| 3295 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
| 3296 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); |
| 3297 | |
| 3298 | do_action('xmlrpc_call', 'blogger.getPost'); |
| 3299 | |
| 3300 | $categories = implode(',', wp_get_post_categories($post_ID)); |
| 3301 | |
| 3302 | $content = '<title>'.stripslashes($post_data['post_title']).'</title>'; |
| 3303 | $content .= '<category>'.$categories.'</category>'; |
| 3304 | $content .= stripslashes($post_data['post_content']); |
| 3305 | |
| 3306 | $struct = array( |
| 3307 | 'userid' => $post_data['post_author'], |
| Line | Code |
| 3331 | $password = $args[3]; |
| 3332 | if ( isset( $args[4] ) ) |
| 3333 | $query = array( 'numberposts' => absint( $args[4] ) ); |
| 3334 | else |
| 3335 | $query = array(); |
| 3336 | |
| 3337 | if ( !$user = $this->login($username, $password) ) |
| 3338 | return $this->error; |
| 3339 | |
| 3340 | do_action('xmlrpc_call', 'blogger.getRecentPosts'); |
| 3341 | |
| 3342 | $posts_list = wp_get_recent_posts( $query ); |
| 3343 | |
| 3344 | if ( !$posts_list ) { |
| 3345 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
| 3346 | return $this->error; |
| 3347 | } |
| 3348 | |
| 3349 | foreach ($posts_list as $entry) { |
| Line | Code |
| 3388 | |
| 3389 | $blog_ID = (int) $args[1]; |
| 3390 | $username = $args[2]; |
| 3391 | $password = $args[3]; |
| 3392 | $template = $args[4]; /* could be 'main' or 'archiveIndex', but we don't use it */ |
| 3393 | |
| 3394 | if ( !$user = $this->login($username, $password) ) |
| 3395 | return $this->error; |
| 3396 | |
| 3397 | do_action('xmlrpc_call', 'blogger.getTemplate'); |
| 3398 | |
| 3399 | if ( !current_user_can('edit_themes') ) |
| 3400 | return new IXR_Error(401, __('Sorry, this user cannot edit the template.')); |
| 3401 | |
| 3402 | /* warning: here we make the assumption that the blog's URL is on the same server */ |
| 3403 | $filename = get_option('home') . '/'; |
| 3404 | $filename = preg_replace('#https?://.+?/#', $_SERVER['DOCUMENT_ROOT'].'/', $filename); |
| 3405 | |
| 3406 | $f = fopen($filename, 'r'); |
| Line | Code |
| 3428 | $blog_ID = (int) $args[1]; |
| 3429 | $username = $args[2]; |
| 3430 | $password = $args[3]; |
| 3431 | $content = $args[4]; |
| 3432 | $template = $args[5]; /* could be 'main' or 'archiveIndex', but we don't use it */ |
| 3433 | |
| 3434 | if ( !$user = $this->login($username, $password) ) |
| 3435 | return $this->error; |
| 3436 | |
| 3437 | do_action('xmlrpc_call', 'blogger.setTemplate'); |
| 3438 | |
| 3439 | if ( !current_user_can('edit_themes') ) |
| 3440 | return new IXR_Error(401, __('Sorry, this user cannot edit the template.')); |
| 3441 | |
| 3442 | /* warning: here we make the assumption that the blog's URL is on the same server */ |
| 3443 | $filename = get_option('home') . '/'; |
| 3444 | $filename = preg_replace('#https?://.+?/#', $_SERVER['DOCUMENT_ROOT'].'/', $filename); |
| 3445 | |
| 3446 | if ($f = fopen($filename, 'w+')) { |
| Line | Code |
| 3468 | $blog_ID = (int) $args[1]; /* though we don't use it yet */ |
| 3469 | $username = $args[2]; |
| 3470 | $password = $args[3]; |
| 3471 | $content = $args[4]; |
| 3472 | $publish = $args[5]; |
| 3473 | |
| 3474 | if ( !$user = $this->login($username, $password) ) |
| 3475 | return $this->error; |
| 3476 | |
| 3477 | do_action('xmlrpc_call', 'blogger.newPost'); |
| 3478 | |
| 3479 | $cap = ($publish) ? 'publish_posts' : 'edit_posts'; |
| 3480 | if ( !current_user_can($cap) ) |
| 3481 | return new IXR_Error(401, __('Sorry, you are not allowed to post on this site.')); |
| 3482 | |
| 3483 | $post_status = ($publish) ? 'publish' : 'draft'; |
| 3484 | |
| 3485 | $post_author = $user->ID; |
| 3486 | |
| Line | Code |
| 3522 | $post_ID = (int) $args[1]; |
| 3523 | $username = $args[2]; |
| 3524 | $password = $args[3]; |
| 3525 | $content = $args[4]; |
| 3526 | $publish = $args[5]; |
| 3527 | |
| 3528 | if ( !$user = $this->login($username, $password) ) |
| 3529 | return $this->error; |
| 3530 | |
| 3531 | do_action('xmlrpc_call', 'blogger.editPost'); |
| 3532 | |
| 3533 | $actual_post = wp_get_single_post($post_ID,ARRAY_A); |
| 3534 | |
| 3535 | if ( !$actual_post || $actual_post['post_type'] != 'post' ) |
| 3536 | return new IXR_Error(404, __('Sorry, no such post.')); |
| 3537 | |
| 3538 | $this->escape($actual_post); |
| 3539 | |
| 3540 | if ( !current_user_can('edit_post', $post_ID) ) |
| Line | Code |
| 3576 | |
| 3577 | $post_ID = (int) $args[1]; |
| 3578 | $username = $args[2]; |
| 3579 | $password = $args[3]; |
| 3580 | $publish = $args[4]; |
| 3581 | |
| 3582 | if ( !$user = $this->login($username, $password) ) |
| 3583 | return $this->error; |
| 3584 | |
| 3585 | do_action('xmlrpc_call', 'blogger.deletePost'); |
| 3586 | |
| 3587 | $actual_post = wp_get_single_post($post_ID,ARRAY_A); |
| 3588 | |
| 3589 | if ( !$actual_post || $actual_post['post_type'] != 'post' ) |
| 3590 | return new IXR_Error(404, __('Sorry, no such post.')); |
| 3591 | |
| 3592 | if ( !current_user_can('delete_post', $post_ID) ) |
| 3593 | return new IXR_Error(401, __('Sorry, you do not have the right to delete this post.')); |
| 3594 | |
| Line | Code |
| 3647 | $blog_ID = (int) $args[0]; |
| 3648 | $username = $args[1]; |
| 3649 | $password = $args[2]; |
| 3650 | $content_struct = $args[3]; |
| 3651 | $publish = isset( $args[4] ) ? $args[4] : 0; |
| 3652 | |
| 3653 | if ( !$user = $this->login($username, $password) ) |
| 3654 | return $this->error; |
| 3655 | |
| 3656 | do_action('xmlrpc_call', 'metaWeblog.newPost'); |
| 3657 | |
| 3658 | $page_template = ''; |
| 3659 | if ( !empty( $content_struct['post_type'] ) ) { |
| 3660 | if ( $content_struct['post_type'] == 'page' ) { |
| 3661 | if ( $publish ) |
| 3662 | $cap = 'publish_pages'; |
| 3663 | elseif ( isset( $content_struct['page_status'] ) && 'publish' == $content_struct['page_status'] ) |
| 3664 | $cap = 'publish_pages'; |
| 3665 | else |
| Line | Code |
| 3966 | $post_ID = (int) $args[0]; |
| 3967 | $username = $args[1]; |
| 3968 | $password = $args[2]; |
| 3969 | $content_struct = $args[3]; |
| 3970 | $publish = isset( $args[4] ) ? $args[4] : 0; |
| 3971 | |
| 3972 | if ( ! $user = $this->login($username, $password) ) |
| 3973 | return $this->error; |
| 3974 | |
| 3975 | do_action('xmlrpc_call', 'metaWeblog.editPost'); |
| 3976 | |
| 3977 | $postdata = wp_get_single_post( $post_ID, ARRAY_A ); |
| 3978 | |
| 3979 | // If there is no post data for the give post id, stop |
| 3980 | // now and return an error. Other wise a new post will be |
| 3981 | // created (which was the old behavior). |
| 3982 | if ( ! $postdata || empty( $postdata[ 'ID' ] ) ) |
| 3983 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 3984 | |
| Line | Code |
| 4240 | return $this->error; |
| 4241 | |
| 4242 | $postdata = wp_get_single_post($post_ID, ARRAY_A); |
| 4243 | if ( ! $postdata ) |
| 4244 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4245 | |
| 4246 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
| 4247 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); |
| 4248 | |
| 4249 | do_action('xmlrpc_call', 'metaWeblog.getPost'); |
| 4250 | |
| 4251 | if ($postdata['post_date'] != '') { |
| 4252 | $post_date = $this->_convert_date( $postdata['post_date'] ); |
| 4253 | $post_date_gmt = $this->_convert_date_gmt( $postdata['post_date_gmt'], $postdata['post_date'] ); |
| 4254 | $post_modified = $this->_convert_date( $postdata['post_modified'] ); |
| 4255 | $post_modified_gmt = $this->_convert_date_gmt( $postdata['post_modified_gmt'], $postdata['post_modified'] ); |
| 4256 | |
| 4257 | $categories = array(); |
| 4258 | $catids = wp_get_post_categories($post_ID); |
| Line | Code |
| 4361 | $password = $args[2]; |
| 4362 | if ( isset( $args[3] ) ) |
| 4363 | $query = array( 'numberposts' => absint( $args[3] ) ); |
| 4364 | else |
| 4365 | $query = array(); |
| 4366 | |
| 4367 | if ( !$user = $this->login($username, $password) ) |
| 4368 | return $this->error; |
| 4369 | |
| 4370 | do_action('xmlrpc_call', 'metaWeblog.getRecentPosts'); |
| 4371 | |
| 4372 | $posts_list = wp_get_recent_posts( $query ); |
| 4373 | |
| 4374 | if ( !$posts_list ) |
| 4375 | return array(); |
| 4376 | |
| 4377 | foreach ($posts_list as $entry) { |
| 4378 | if ( !current_user_can( 'edit_post', $entry['ID'] ) ) |
| 4379 | continue; |
| Line | Code |
| 4474 | $username = $args[1]; |
| 4475 | $password = $args[2]; |
| 4476 | |
| 4477 | if ( !$user = $this->login($username, $password) ) |
| 4478 | return $this->error; |
| 4479 | |
| 4480 | if ( !current_user_can( 'edit_posts' ) ) |
| 4481 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
| 4482 | |
| 4483 | do_action('xmlrpc_call', 'metaWeblog.getCategories'); |
| 4484 | |
| 4485 | $categories_struct = array(); |
| 4486 | |
| 4487 | if ( $cats = get_categories(array('get' => 'all')) ) { |
| 4488 | foreach ( $cats as $cat ) { |
| 4489 | $struct['categoryId'] = $cat->term_id; |
| 4490 | $struct['parentId'] = $cat->parent; |
| 4491 | $struct['description'] = $cat->name; |
| 4492 | $struct['categoryDescription'] = $cat->description; |
| Line | Code |
| 4522 | $data = $args[3]; |
| 4523 | |
| 4524 | $name = sanitize_file_name( $data['name'] ); |
| 4525 | $type = $data['type']; |
| 4526 | $bits = $data['bits']; |
| 4527 | |
| 4528 | if ( !$user = $this->login($username, $password) ) |
| 4529 | return $this->error; |
| 4530 | |
| 4531 | do_action('xmlrpc_call', 'metaWeblog.newMediaObject'); |
| 4532 | |
| 4533 | if ( !current_user_can('upload_files') ) { |
| 4534 | $this->error = new IXR_Error( 401, __( 'You do not have permission to upload files.' ) ); |
| 4535 | return $this->error; |
| 4536 | } |
| 4537 | |
| 4538 | if ( $upload_err = apply_filters( 'pre_upload_error', false ) ) |
| 4539 | return new IXR_Error(500, $upload_err); |
| 4540 | |
| Line | Code |
| 4609 | $password = $args[2]; |
| 4610 | if ( isset( $args[3] ) ) |
| 4611 | $query = array( 'numberposts' => absint( $args[3] ) ); |
| 4612 | else |
| 4613 | $query = array(); |
| 4614 | |
| 4615 | if ( !$user = $this->login($username, $password) ) |
| 4616 | return $this->error; |
| 4617 | |
| 4618 | do_action('xmlrpc_call', 'mt.getRecentPostTitles'); |
| 4619 | |
| 4620 | $posts_list = wp_get_recent_posts( $query ); |
| 4621 | |
| 4622 | if ( !$posts_list ) { |
| 4623 | $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); |
| 4624 | return $this->error; |
| 4625 | } |
| 4626 | |
| 4627 | $struct = array(); |
| Line | Code |
| 4668 | $username = $args[1]; |
| 4669 | $password = $args[2]; |
| 4670 | |
| 4671 | if ( !$user = $this->login($username, $password) ) |
| 4672 | return $this->error; |
| 4673 | |
| 4674 | if ( !current_user_can( 'edit_posts' ) ) |
| 4675 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
| 4676 | |
| 4677 | do_action('xmlrpc_call', 'mt.getCategoryList'); |
| 4678 | |
| 4679 | $categories_struct = array(); |
| 4680 | |
| 4681 | if ( $cats = get_categories(array('hide_empty' => 0, 'hierarchical' => 0)) ) { |
| 4682 | foreach ( $cats as $cat ) { |
| 4683 | $struct['categoryId'] = $cat->term_id; |
| 4684 | $struct['categoryName'] = $cat->name; |
| 4685 | |
| 4686 | $categories_struct[] = $struct; |
| Line | Code |
| 4709 | if ( !$user = $this->login($username, $password) ) |
| 4710 | return $this->error; |
| 4711 | |
| 4712 | if ( ! get_post( $post_ID ) ) |
| 4713 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4714 | |
| 4715 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
| 4716 | return new IXR_Error( 401, __( 'Sorry, you can not edit this post.' ) ); |
| 4717 | |
| 4718 | do_action('xmlrpc_call', 'mt.getPostCategories'); |
| 4719 | |
| 4720 | $categories = array(); |
| 4721 | $catids = wp_get_post_categories(intval($post_ID)); |
| 4722 | // first listed category will be the primary category |
| 4723 | $isPrimary = true; |
| 4724 | foreach ( $catids as $catid ) { |
| 4725 | $categories[] = array( |
| 4726 | 'categoryName' => get_cat_name($catid), |
| 4727 | 'categoryId' => (string) $catid, |
| Line | Code |
| 4747 | |
| 4748 | $post_ID = (int) $args[0]; |
| 4749 | $username = $args[1]; |
| 4750 | $password = $args[2]; |
| 4751 | $categories = $args[3]; |
| 4752 | |
| 4753 | if ( !$user = $this->login($username, $password) ) |
| 4754 | return $this->error; |
| 4755 | |
| 4756 | do_action('xmlrpc_call', 'mt.setPostCategories'); |
| 4757 | |
| 4758 | if ( ! get_post( $post_ID ) ) |
| 4759 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4760 | |
| 4761 | if ( !current_user_can('edit_post', $post_ID) ) |
| 4762 | return new IXR_Error(401, __('Sorry, you cannot edit this post.')); |
| 4763 | |
| 4764 | foreach ( $categories as $cat ) { |
| 4765 | $catids[] = $cat['categoryId']; |
| Line | Code |
| 4774 | * Retrieve an array of methods supported by this server. |
| 4775 | * |
| 4776 | * @since 1.5.0 |
| 4777 | * |
| 4778 | * @param array $args Method parameters. |
| 4779 | * @return array |
| 4780 | */ |
| 4781 | function mt_supportedMethods($args) { |
| 4782 | |
| 4783 | do_action('xmlrpc_call', 'mt.supportedMethods'); |
| 4784 | |
| 4785 | $supported_methods = array(); |
| 4786 | foreach ( $this->methods as $key => $value ) { |
| 4787 | $supported_methods[] = $key; |
| 4788 | } |
| 4789 | |
| 4790 | return $supported_methods; |
| 4791 | } |
| 4792 | |
| 4793 | /** |
| 4794 | * Retrieve an empty array because we don't support per-post text filters. |
| 4795 | * |
| 4796 | * @since 1.5.0 |
| 4797 | * |
| 4798 | * @param array $args Method parameters. |
| 4799 | */ |
| 4800 | function mt_supportedTextFilters($args) { |
| 4801 | do_action('xmlrpc_call', 'mt.supportedTextFilters'); |
| 4802 | return apply_filters('xmlrpc_text_filters', array()); |
| 4803 | } |
| 4804 | |
| 4805 | /** |
| 4806 | * Retrieve trackbacks sent to a given post. |
| 4807 | * |
| 4808 | * @since 1.5.0 |
| 4809 | * |
| 4810 | * @param array $args Method parameters. |
| 4811 | * @return mixed |
| 4812 | */ |
| 4813 | function mt_getTrackbackPings($args) { |
| 4814 | |
| 4815 | global $wpdb; |
| 4816 | |
| 4817 | $post_ID = intval($args); |
| 4818 | |
| 4819 | do_action('xmlrpc_call', 'mt.getTrackbackPings'); |
| 4820 | |
| 4821 | $actual_post = wp_get_single_post($post_ID, ARRAY_A); |
| 4822 | |
| 4823 | if ( !$actual_post ) |
| 4824 | return new IXR_Error(404, __('Sorry, no such post.')); |
| 4825 | |
| 4826 | $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) ); |
| 4827 | |
| 4828 | if ( !$comments ) |
| Line | Code |
| 4857 | $this->escape($args); |
| 4858 | |
| 4859 | $post_ID = (int) $args[0]; |
| 4860 | $username = $args[1]; |
| 4861 | $password = $args[2]; |
| 4862 | |
| 4863 | if ( !$user = $this->login($username, $password) ) |
| 4864 | return $this->error; |
| 4865 | |
| 4866 | do_action('xmlrpc_call', 'mt.publishPost'); |
| 4867 | |
| 4868 | $postdata = wp_get_single_post($post_ID, ARRAY_A); |
| 4869 | if ( ! $postdata ) |
| 4870 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| 4871 | |
| 4872 | if ( !current_user_can('publish_posts') || !current_user_can('edit_post', $post_ID) ) |
| 4873 | return new IXR_Error(401, __('Sorry, you cannot publish this post.')); |
| 4874 | |
| 4875 | $postdata['post_status'] = 'publish'; |
| Line | Code |
| 4893 | * |
| 4894 | * @since 1.5.0 |
| 4895 | * |
| 4896 | * @param array $args Method parameters. |
| 4897 | * @return array |
| 4898 | */ |
| 4899 | function pingback_ping($args) { |
| 4900 | global $wpdb; |
| 4901 | |
| 4902 | do_action('xmlrpc_call', 'pingback.ping'); |
| 4903 | |
| 4904 | $this->escape($args); |
| 4905 | |
| 4906 | $pagelinkedfrom = $args[0]; |
| 4907 | $pagelinkedto = $args[1]; |
| 4908 | |
| 4909 | $title = ''; |
| 4910 | |
| 4911 | $pagelinkedfrom = str_replace('&', '&', $pagelinkedfrom); |
| Line | Code |
| 5061 | * @since 1.5.0 |
| 5062 | * |
| 5063 | * @param array $args Method parameters. |
| 5064 | * @return array |
| 5065 | */ |
| 5066 | function pingback_extensions_getPingbacks($args) { |
| 5067 | |
| 5068 | global $wpdb; |
| 5069 | |
| 5070 | do_action('xmlrpc_call', 'pingback.extensions.getPingbacks'); |
| 5071 | |
| 5072 | $this->escape($args); |
| 5073 | |
| 5074 | $url = $args; |
| 5075 | |
| 5076 | $post_ID = url_to_postid($url); |
| 5077 | if ( !$post_ID ) { |
| 5078 | // We aren't sure that the resource is available and/or pingback enabled |
| 5079 | 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.')); |