diff --git src/wp-includes/class-wp-xmlrpc-server.php src/wp-includes/class-wp-xmlrpc-server.php
index 0f617db..c2c5450 100644
|
|
|
|
| 3 | 3 | * XML-RPC protocol support for WordPress |
| 4 | 4 | * |
| 5 | 5 | * @package WordPress |
| 6 | | * @subpackage Publishing |
| 7 | 6 | */ |
| 8 | 7 | |
| 9 | 8 | /** |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 127 | 126 | ); |
| 128 | 127 | |
| 129 | 128 | $this->initialise_blog_option_info(); |
| 130 | | |
| 131 | | /** |
| 132 | | * Filter the methods exposed by the XML-RPC server. |
| 133 | | * |
| 134 | | * This filter can be used to add new methods, and remove built-in methods. |
| 135 | | * |
| 136 | | * @since 1.5.0 |
| 137 | | * |
| 138 | | * @param array $methods An array of XML-RPC methods. |
| 139 | | */ |
| 140 | | $this->methods = apply_filters( 'xmlrpc_methods', $this->methods ); |
| | 129 | $this->methods = apply_filters('xmlrpc_methods', $this->methods); |
| 141 | 130 | } |
| 142 | 131 | |
| 143 | 132 | function serve_request() { |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 180 | 169 | * @return mixed WP_User object if authentication passed, false otherwise |
| 181 | 170 | */ |
| 182 | 171 | function login( $username, $password ) { |
| 183 | | /* |
| 184 | | * Respect old get_option() filters left for back-compat when the 'enable_xmlrpc' |
| 185 | | * option was deprecated in 3.5.0. Use the 'xmlrpc_enabled' hook instead. |
| 186 | | */ |
| 187 | | $enabled = apply_filters( 'pre_option_enable_xmlrpc', false ); |
| 188 | | if ( false === $enabled ) { |
| 189 | | $enabled = apply_filters( 'option_enable_xmlrpc', true ); |
| 190 | | } |
| | 172 | // Respect any old filters against get_option() for 'enable_xmlrpc'. |
| | 173 | $enabled = apply_filters( 'pre_option_enable_xmlrpc', false ); // Deprecated |
| | 174 | if ( false === $enabled ) |
| | 175 | $enabled = apply_filters( 'option_enable_xmlrpc', true ); // Deprecated |
| 191 | 176 | |
| 192 | | /** |
| 193 | | * Filter whether XML-RPC is enabled. |
| 194 | | * |
| 195 | | * This is the proper filter for turning off XML-RPC. |
| 196 | | * |
| 197 | | * @since 3.5.0 |
| 198 | | * |
| 199 | | * @param bool $enabled Whether XML-RPC is enabled. Default true. |
| 200 | | */ |
| | 177 | // Proper filter for turning off XML-RPC. It is on by default. |
| 201 | 178 | $enabled = apply_filters( 'xmlrpc_enabled', $enabled ); |
| 202 | 179 | |
| 203 | 180 | if ( ! $enabled ) { |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 209 | 186 | |
| 210 | 187 | if (is_wp_error($user)) { |
| 211 | 188 | $this->error = new IXR_Error( 403, __( 'Incorrect username or password.' ) ); |
| 212 | | |
| 213 | | /** |
| 214 | | * Filter the XML-RPC user login error message. |
| 215 | | * |
| 216 | | * @since 3.5.0 |
| 217 | | * |
| 218 | | * @param string $error The XML-RPC error message. |
| 219 | | * @param WP_User $user WP_User object. |
| 220 | | */ |
| 221 | 189 | $this->error = apply_filters( 'xmlrpc_login_error', $this->error, $user ); |
| 222 | 190 | return false; |
| 223 | 191 | } |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 472 | 440 | ) |
| 473 | 441 | ); |
| 474 | 442 | |
| 475 | | /** |
| 476 | | * Filter the XML-RPC blog options property. |
| 477 | | * |
| 478 | | * @since 2.6.0 |
| 479 | | * |
| 480 | | * @param array $blog_options An array of XML-RPC blog options. |
| 481 | | */ |
| 482 | 443 | $this->blog_options = apply_filters( 'xmlrpc_blog_options', $this->blog_options ); |
| 483 | 444 | } |
| 484 | 445 | |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 512 | 473 | if ( !$user = $this->login($username, $password) ) |
| 513 | 474 | return $this->error; |
| 514 | 475 | |
| 515 | | /** |
| 516 | | * Fires after the XML-RPC user has been authenticated but before the rest of |
| 517 | | * the method logic begins. |
| 518 | | * |
| 519 | | * All built-in XML-RPC methods use the action xmlrpc_call, with a parameter |
| 520 | | * equal to the method's name, e.g., wp.getUsersBlogs, wp.newPost, etc. |
| 521 | | * |
| 522 | | * @since 2.5.0 |
| 523 | | * |
| 524 | | * @param method $name The method name. |
| 525 | | */ |
| 526 | 476 | do_action( 'xmlrpc_call', 'wp.getUsersBlogs' ); |
| 527 | 477 | |
| 528 | 478 | $blogs = (array) get_blogs_of_user( $user->ID ); |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 602 | 552 | if ( in_array( 'object_type', $fields ) ) |
| 603 | 553 | $_taxonomy['object_type'] = array_unique( (array) $taxonomy->object_type ); |
| 604 | 554 | |
| 605 | | /** |
| 606 | | * Filter XML-RPC-prepared data for the given taxonomy. |
| 607 | | * |
| 608 | | * @since 3.4.0 |
| 609 | | * |
| 610 | | * @param array $_taxonomy An array of taxonomy data. |
| 611 | | * @param object $taxonomy Taxonomy object. |
| 612 | | * @param array $fields The subset of taxonomy fields to return. |
| 613 | | */ |
| 614 | 555 | return apply_filters( 'xmlrpc_prepare_taxonomy', $_taxonomy, $taxonomy, $fields ); |
| 615 | 556 | } |
| 616 | 557 | |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 636 | 577 | // Count we are happy to return as an integer because people really shouldn't use terms that much. |
| 637 | 578 | $_term['count'] = intval( $_term['count'] ); |
| 638 | 579 | |
| 639 | | /** |
| 640 | | * Filter XML-RPC-prepared data for the given term. |
| 641 | | * |
| 642 | | * @since 3.4.0 |
| 643 | | * |
| 644 | | * @param array $_term An array of term data. |
| 645 | | * @param array|object $term Term object or array. |
| 646 | | */ |
| 647 | 580 | return apply_filters( 'xmlrpc_prepare_term', $_term, $term ); |
| 648 | 581 | } |
| 649 | 582 | |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 765 | 698 | } |
| 766 | 699 | } |
| 767 | 700 | |
| 768 | | /** |
| 769 | | * Filter XML-RPC-prepared date for the given post. |
| 770 | | * |
| 771 | | * @since 3.4.0 |
| 772 | | * |
| 773 | | * @param array $_post An array of modified post data. |
| 774 | | * @param array $post An array of post data. |
| 775 | | * @param array $fields An array of post fields. |
| 776 | | */ |
| 777 | 701 | return apply_filters( 'xmlrpc_prepare_post', $_post, $post, $fields ); |
| 778 | 702 | } |
| 779 | 703 | |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 816 | 740 | if ( in_array( 'taxonomies', $fields ) ) |
| 817 | 741 | $_post_type['taxonomies'] = get_object_taxonomies( $post_type->name, 'names' ); |
| 818 | 742 | |
| 819 | | /** |
| 820 | | * Filter XML-RPC-prepared date for the given post type. |
| 821 | | * |
| 822 | | * @since 3.4.0 |
| 823 | | * |
| 824 | | * @param array $_post_type An array of post type data. |
| 825 | | * @param object $post_type Post type object. |
| 826 | | */ |
| 827 | 743 | return apply_filters( 'xmlrpc_prepare_post_type', $_post_type, $post_type ); |
| 828 | 744 | } |
| 829 | 745 | |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 854 | 770 | else |
| 855 | 771 | $_media_item['thumbnail'] = $_media_item['link']; |
| 856 | 772 | |
| 857 | | /** |
| 858 | | * Filter XML-RPC-prepared data for the given media item. |
| 859 | | * |
| 860 | | * @since 3.4.0 |
| 861 | | * |
| 862 | | * @param array $_media_item An array of media item data. |
| 863 | | * @param object $media_item Media item object. |
| 864 | | * @param string $thumbnail_size Image size. |
| 865 | | */ |
| 866 | 773 | return apply_filters( 'xmlrpc_prepare_media_item', $_media_item, $media_item, $thumbnail_size ); |
| 867 | 774 | } |
| 868 | 775 | |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 934 | 841 | 'wp_page_template' => $page_template |
| 935 | 842 | ); |
| 936 | 843 | |
| 937 | | /** |
| 938 | | * Filter XML-RPC-prepared data for the given page. |
| 939 | | * |
| 940 | | * @since 3.4.0 |
| 941 | | * |
| 942 | | * @param array $_page An array of page data. |
| 943 | | * @param WP_Post $page Page object. |
| 944 | | */ |
| 945 | 844 | return apply_filters( 'xmlrpc_prepare_page', $_page, $page ); |
| 946 | 845 | } |
| 947 | 846 | |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 984 | 883 | 'type' => $comment->comment_type, |
| 985 | 884 | ); |
| 986 | 885 | |
| 987 | | /** |
| 988 | | * Filter XML-RPC-prepared data for the given comment. |
| 989 | | * |
| 990 | | * @since 3.4.0 |
| 991 | | * |
| 992 | | * @param array $_comment An array of prepared comment data. |
| 993 | | * @param object $comment Comment object. |
| 994 | | */ |
| 995 | 886 | return apply_filters( 'xmlrpc_prepare_comment', $_comment, $comment ); |
| 996 | 887 | } |
| 997 | 888 | |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 1032 | 923 | $_user = array_merge( $_user, $requested_fields ); |
| 1033 | 924 | } |
| 1034 | 925 | |
| 1035 | | /** |
| 1036 | | * Filter XML-RPC-prepared data for the given user. |
| 1037 | | * |
| 1038 | | * @since 3.5.0 |
| 1039 | | * |
| 1040 | | * @param array $_user An array of user data. |
| 1041 | | * @param WP_User $user User object. |
| 1042 | | * @param array $fields An array of user fields. |
| 1043 | | */ |
| 1044 | 926 | return apply_filters( 'xmlrpc_prepare_user', $_user, $user, $fields ); |
| 1045 | 927 | } |
| 1046 | 928 | |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 1086 | 968 | $password = $args[2]; |
| 1087 | 969 | $content_struct = $args[3]; |
| 1088 | 970 | |
| | 971 | switch_to_blog($blog_id); |
| | 972 | |
| 1089 | 973 | if ( ! $user = $this->login( $username, $password ) ) |
| 1090 | 974 | return $this->error; |
| 1091 | 975 | |
| 1092 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1093 | 976 | do_action( 'xmlrpc_call', 'wp.newPost' ); |
| 1094 | 977 | |
| 1095 | 978 | unset( $content_struct['ID'] ); |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 1249 | 1132 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign a term to one of the given taxonomies.' ) ); |
| 1250 | 1133 | |
| 1251 | 1134 | $term_ids = $post_data['terms'][$taxonomy]; |
| 1252 | | $terms[ $taxonomy ] = array(); |
| 1253 | 1135 | foreach ( $term_ids as $term_id ) { |
| 1254 | 1136 | $term = get_term_by( 'id', $term_id, $taxonomy ); |
| 1255 | 1137 | |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 1333 | 1215 | |
| 1334 | 1216 | $this->attach_uploads( $post_ID, $post_data['post_content'] ); |
| 1335 | 1217 | |
| 1336 | | /** |
| 1337 | | * Filter post data array to be inserted via XML-RPC. |
| 1338 | | * |
| 1339 | | * @since 3.4.0 |
| 1340 | | * |
| 1341 | | * @param array $post_data Parsed array of post data. |
| 1342 | | * @param array $content_struct Post data array. |
| 1343 | | */ |
| 1344 | 1218 | $post_data = apply_filters( 'xmlrpc_wp_insert_post_data', $post_data, $content_struct ); |
| 1345 | 1219 | |
| 1346 | 1220 | $post_ID = $update ? wp_update_post( $post_data, true ) : wp_insert_post( $post_data, true ); |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 1381 | 1255 | $post_id = (int) $args[3]; |
| 1382 | 1256 | $content_struct = $args[4]; |
| 1383 | 1257 | |
| | 1258 | switch_to_blog($blog_id); |
| | 1259 | |
| 1384 | 1260 | if ( ! $user = $this->login( $username, $password ) ) |
| 1385 | 1261 | return $this->error; |
| 1386 | 1262 | |
| 1387 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1388 | 1263 | do_action( 'xmlrpc_call', 'wp.editPost' ); |
| 1389 | 1264 | |
| 1390 | 1265 | $post = get_post( $post_id, ARRAY_A ); |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 1443 | 1318 | $password = $args[2]; |
| 1444 | 1319 | $post_id = (int) $args[3]; |
| 1445 | 1320 | |
| | 1321 | switch_to_blog($blog_id); |
| | 1322 | |
| 1446 | 1323 | if ( ! $user = $this->login( $username, $password ) ) |
| 1447 | 1324 | return $this->error; |
| 1448 | 1325 | |
| 1449 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1450 | 1326 | do_action( 'xmlrpc_call', 'wp.deletePost' ); |
| 1451 | 1327 | |
| 1452 | 1328 | $post = get_post( $post_id, ARRAY_A ); |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 1519 | 1395 | $password = $args[2]; |
| 1520 | 1396 | $post_id = (int) $args[3]; |
| 1521 | 1397 | |
| 1522 | | if ( isset( $args[4] ) ) { |
| | 1398 | switch_to_blog($blog_id); |
| | 1399 | |
| | 1400 | if ( isset( $args[4] ) ) |
| 1523 | 1401 | $fields = $args[4]; |
| 1524 | | } else { |
| 1525 | | /** |
| 1526 | | * Filter the list of post query fields used by the given XML-RPC method. |
| 1527 | | * |
| 1528 | | * @since 3.4.0 |
| 1529 | | * |
| 1530 | | * @param array $fields Array of post fields. |
| 1531 | | * @param string $method Method name. |
| 1532 | | */ |
| | 1402 | else |
| 1533 | 1403 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPost' ); |
| 1534 | | } |
| 1535 | 1404 | |
| 1536 | 1405 | if ( ! $user = $this->login( $username, $password ) ) |
| 1537 | 1406 | return $this->error; |
| 1538 | 1407 | |
| 1539 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1540 | 1408 | do_action( 'xmlrpc_call', 'wp.getPost' ); |
| 1541 | 1409 | |
| 1542 | 1410 | $post = get_post( $post_id, ARRAY_A ); |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 1585 | 1453 | $password = $args[2]; |
| 1586 | 1454 | $filter = isset( $args[3] ) ? $args[3] : array(); |
| 1587 | 1455 | |
| 1588 | | if ( isset( $args[4] ) ) { |
| | 1456 | switch_to_blog($blog_id); |
| | 1457 | |
| | 1458 | if ( isset( $args[4] ) ) |
| 1589 | 1459 | $fields = $args[4]; |
| 1590 | | } else { |
| 1591 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| | 1460 | else |
| 1592 | 1461 | $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPosts' ); |
| 1593 | | } |
| 1594 | 1462 | |
| 1595 | 1463 | if ( ! $user = $this->login( $username, $password ) ) |
| 1596 | 1464 | return $this->error; |
| 1597 | 1465 | |
| 1598 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1599 | 1466 | do_action( 'xmlrpc_call', 'wp.getPosts' ); |
| 1600 | 1467 | |
| 1601 | 1468 | $query = array(); |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 1685 | 1552 | if ( ! $user = $this->login( $username, $password ) ) |
| 1686 | 1553 | return $this->error; |
| 1687 | 1554 | |
| 1688 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1689 | 1555 | do_action( 'xmlrpc_call', 'wp.newTerm' ); |
| 1690 | 1556 | |
| 1691 | 1557 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 1774 | 1640 | if ( ! $user = $this->login( $username, $password ) ) |
| 1775 | 1641 | return $this->error; |
| 1776 | 1642 | |
| 1777 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1778 | 1643 | do_action( 'xmlrpc_call', 'wp.editTerm' ); |
| 1779 | 1644 | |
| 1780 | 1645 | if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 1867 | 1732 | if ( ! $user = $this->login( $username, $password ) ) |
| 1868 | 1733 | return $this->error; |
| 1869 | 1734 | |
| 1870 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1871 | 1735 | do_action( 'xmlrpc_call', 'wp.deleteTerm' ); |
| 1872 | 1736 | |
| 1873 | 1737 | if ( ! taxonomy_exists( $taxonomy ) ) |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 1935 | 1799 | if ( ! $user = $this->login( $username, $password ) ) |
| 1936 | 1800 | return $this->error; |
| 1937 | 1801 | |
| 1938 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1939 | 1802 | do_action( 'xmlrpc_call', 'wp.getTerm' ); |
| 1940 | 1803 | |
| 1941 | 1804 | if ( ! taxonomy_exists( $taxonomy ) ) |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 1989 | 1852 | if ( ! $user = $this->login( $username, $password ) ) |
| 1990 | 1853 | return $this->error; |
| 1991 | 1854 | |
| 1992 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 1993 | 1855 | do_action( 'xmlrpc_call', 'wp.getTerms' ); |
| 1994 | 1856 | |
| 1995 | 1857 | if ( ! taxonomy_exists( $taxonomy ) ) |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 2061 | 1923 | $password = $args[2]; |
| 2062 | 1924 | $taxonomy = $args[3]; |
| 2063 | 1925 | |
| 2064 | | if ( isset( $args[4] ) ) { |
| | 1926 | if ( isset( $args[4] ) ) |
| 2065 | 1927 | $fields = $args[4]; |
| 2066 | | } else { |
| 2067 | | /** |
| 2068 | | * Filter the taxonomy query fields used by the given XML-RPC method. |
| 2069 | | * |
| 2070 | | * @since 3.4.0 |
| 2071 | | * |
| 2072 | | * @param array $fields An array of taxonomy fields to retrieve. |
| 2073 | | * @param string $method The method name. |
| 2074 | | */ |
| | 1928 | else |
| 2075 | 1929 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomy' ); |
| 2076 | | } |
| 2077 | 1930 | |
| 2078 | 1931 | if ( ! $user = $this->login( $username, $password ) ) |
| 2079 | 1932 | return $this->error; |
| 2080 | 1933 | |
| 2081 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2082 | 1934 | do_action( 'xmlrpc_call', 'wp.getTaxonomy' ); |
| 2083 | 1935 | |
| 2084 | 1936 | if ( ! taxonomy_exists( $taxonomy ) ) |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 2115 | 1967 | $password = $args[2]; |
| 2116 | 1968 | $filter = isset( $args[3] ) ? $args[3] : array( 'public' => true ); |
| 2117 | 1969 | |
| 2118 | | if ( isset( $args[4] ) ) { |
| | 1970 | if ( isset( $args[4] ) ) |
| 2119 | 1971 | $fields = $args[4]; |
| 2120 | | } else { |
| 2121 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| | 1972 | else |
| 2122 | 1973 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomies' ); |
| 2123 | | } |
| 2124 | 1974 | |
| 2125 | 1975 | if ( ! $user = $this->login( $username, $password ) ) |
| 2126 | 1976 | return $this->error; |
| 2127 | 1977 | |
| 2128 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2129 | 1978 | do_action( 'xmlrpc_call', 'wp.getTaxonomies' ); |
| 2130 | 1979 | |
| 2131 | 1980 | $taxonomies = get_taxonomies( $filter, 'objects' ); |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 2187 | 2036 | $password = $args[2]; |
| 2188 | 2037 | $user_id = (int) $args[3]; |
| 2189 | 2038 | |
| 2190 | | if ( isset( $args[4] ) ) { |
| | 2039 | if ( isset( $args[4] ) ) |
| 2191 | 2040 | $fields = $args[4]; |
| 2192 | | } else { |
| 2193 | | /** |
| 2194 | | * Filter the default user query fields used by the given XML-RPC method. |
| 2195 | | * |
| 2196 | | * @since 3.5.0 |
| 2197 | | * |
| 2198 | | * @param array $fields User query fields for given method. Default 'all'. |
| 2199 | | * @param string $method The method name. |
| 2200 | | */ |
| | 2041 | else |
| 2201 | 2042 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUser' ); |
| 2202 | | } |
| 2203 | 2043 | |
| 2204 | 2044 | if ( ! $user = $this->login( $username, $password ) ) |
| 2205 | 2045 | return $this->error; |
| 2206 | 2046 | |
| 2207 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2208 | 2047 | do_action( 'xmlrpc_call', 'wp.getUser' ); |
| 2209 | 2048 | |
| 2210 | 2049 | if ( ! current_user_can( 'edit_user', $user_id ) ) |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 2250 | 2089 | $password = $args[2]; |
| 2251 | 2090 | $filter = isset( $args[3] ) ? $args[3] : array(); |
| 2252 | 2091 | |
| 2253 | | if ( isset( $args[4] ) ) { |
| | 2092 | if ( isset( $args[4] ) ) |
| 2254 | 2093 | $fields = $args[4]; |
| 2255 | | } else { |
| 2256 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| | 2094 | else |
| 2257 | 2095 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUsers' ); |
| 2258 | | } |
| 2259 | 2096 | |
| 2260 | 2097 | if ( ! $user = $this->login( $username, $password ) ) |
| 2261 | 2098 | return $this->error; |
| 2262 | 2099 | |
| 2263 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2264 | 2100 | do_action( 'xmlrpc_call', 'wp.getUsers' ); |
| 2265 | 2101 | |
| 2266 | 2102 | if ( ! current_user_can( 'list_users' ) ) |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 2320 | 2156 | $username = $args[1]; |
| 2321 | 2157 | $password = $args[2]; |
| 2322 | 2158 | |
| 2323 | | if ( isset( $args[3] ) ) { |
| | 2159 | if ( isset( $args[3] ) ) |
| 2324 | 2160 | $fields = $args[3]; |
| 2325 | | } else { |
| 2326 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| | 2161 | else |
| 2327 | 2162 | $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getProfile' ); |
| 2328 | | } |
| 2329 | 2163 | |
| 2330 | 2164 | if ( ! $user = $this->login( $username, $password ) ) |
| 2331 | 2165 | return $this->error; |
| 2332 | 2166 | |
| 2333 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2334 | 2167 | do_action( 'xmlrpc_call', 'wp.getProfile' ); |
| 2335 | 2168 | |
| 2336 | 2169 | if ( ! current_user_can( 'edit_user', $user->ID ) ) |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 2374 | 2207 | if ( ! $user = $this->login( $username, $password ) ) |
| 2375 | 2208 | return $this->error; |
| 2376 | 2209 | |
| 2377 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2378 | 2210 | do_action( 'xmlrpc_call', 'wp.editProfile' ); |
| 2379 | 2211 | |
| 2380 | 2212 | if ( ! current_user_can( 'edit_user', $user->ID ) ) |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 2448 | 2280 | if ( !current_user_can( 'edit_page', $page_id ) ) |
| 2449 | 2281 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this page.' ) ); |
| 2450 | 2282 | |
| 2451 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2452 | | do_action( 'xmlrpc_call', 'wp.getPage' ); |
| | 2283 | do_action('xmlrpc_call', 'wp.getPage'); |
| 2453 | 2284 | |
| 2454 | 2285 | // If we found the page then format the data. |
| 2455 | 2286 | if ( $page->ID && ($page->post_type == 'page') ) { |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 2487 | 2318 | if ( !current_user_can( 'edit_pages' ) ) |
| 2488 | 2319 | return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) ); |
| 2489 | 2320 | |
| 2490 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2491 | | do_action( 'xmlrpc_call', 'wp.getPages' ); |
| | 2321 | do_action('xmlrpc_call', 'wp.getPages'); |
| 2492 | 2322 | |
| 2493 | 2323 | $pages = get_posts( array('post_type' => 'page', 'post_status' => 'any', 'numberposts' => $num_pages) ); |
| 2494 | 2324 | $num_pages = count($pages); |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 2528 | 2358 | if ( !$user = $this->login($username, $password) ) |
| 2529 | 2359 | return $this->error; |
| 2530 | 2360 | |
| 2531 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2532 | | do_action( 'xmlrpc_call', 'wp.newPage' ); |
| | 2361 | do_action('xmlrpc_call', 'wp.newPage'); |
| 2533 | 2362 | |
| 2534 | 2363 | // Mark this as content for a page. |
| 2535 | 2364 | $args[3]["post_type"] = 'page'; |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 2557 | 2386 | if ( !$user = $this->login($username, $password) ) |
| 2558 | 2387 | return $this->error; |
| 2559 | 2388 | |
| 2560 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2561 | | do_action( 'xmlrpc_call', 'wp.deletePage' ); |
| | 2389 | do_action('xmlrpc_call', 'wp.deletePage'); |
| 2562 | 2390 | |
| 2563 | 2391 | // Get the current page based on the page_id and |
| 2564 | 2392 | // make sure it is a page and not a post. |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 2575 | 2403 | if ( !$result ) |
| 2576 | 2404 | return(new IXR_Error(500, __('Failed to delete the page.'))); |
| 2577 | 2405 | |
| 2578 | | /** |
| 2579 | | * Fires after a page has been successfully deleted via XML-RPC. |
| 2580 | | * |
| 2581 | | * @since 3.4.0 |
| 2582 | | * |
| 2583 | | * @param int $page_id ID of the deleted page. |
| 2584 | | * @param array $args An array of arguments to delete the page. |
| 2585 | | */ |
| 2586 | 2406 | do_action( 'xmlrpc_call_success_wp_deletePage', $page_id, $args ); |
| 2587 | 2407 | |
| 2588 | 2408 | return(true); |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 2608 | 2428 | if ( !$user = $this->login($username, $password) ) |
| 2609 | 2429 | return $this->error; |
| 2610 | 2430 | |
| 2611 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2612 | | do_action( 'xmlrpc_call', 'wp.editPage' ); |
| | 2431 | do_action('xmlrpc_call', 'wp.editPage'); |
| 2613 | 2432 | |
| 2614 | 2433 | // Get the page data and make sure it is a page. |
| 2615 | 2434 | $actual_page = get_post($page_id, ARRAY_A); |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 2659 | 2478 | if ( !current_user_can( 'edit_pages' ) ) |
| 2660 | 2479 | return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) ); |
| 2661 | 2480 | |
| 2662 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2663 | | do_action( 'xmlrpc_call', 'wp.getPageList' ); |
| | 2481 | do_action('xmlrpc_call', 'wp.getPageList'); |
| 2664 | 2482 | |
| 2665 | 2483 | // Get list of pages ids and titles |
| 2666 | 2484 | $page_list = $wpdb->get_results(" |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 2711 | 2529 | if ( !current_user_can('edit_posts') ) |
| 2712 | 2530 | return(new IXR_Error(401, __('Sorry, you cannot edit posts on this site.'))); |
| 2713 | 2531 | |
| 2714 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2715 | | do_action( 'xmlrpc_call', 'wp.getAuthors' ); |
| | 2532 | do_action('xmlrpc_call', 'wp.getAuthors'); |
| 2716 | 2533 | |
| 2717 | 2534 | $authors = array(); |
| 2718 | 2535 | foreach ( get_users( array( 'fields' => array('ID','user_login','display_name') ) ) as $user ) { |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 2747 | 2564 | if ( !current_user_can( 'edit_posts' ) ) |
| 2748 | 2565 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view tags.' ) ); |
| 2749 | 2566 | |
| 2750 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2751 | 2567 | do_action( 'xmlrpc_call', 'wp.getKeywords' ); |
| 2752 | 2568 | |
| 2753 | 2569 | $tags = array(); |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 2787 | 2603 | if ( !$user = $this->login($username, $password) ) |
| 2788 | 2604 | return $this->error; |
| 2789 | 2605 | |
| 2790 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2791 | | do_action( 'xmlrpc_call', 'wp.newCategory' ); |
| | 2606 | do_action('xmlrpc_call', 'wp.newCategory'); |
| 2792 | 2607 | |
| 2793 | 2608 | // Make sure the user is allowed to add a category. |
| 2794 | 2609 | if ( !current_user_can('manage_categories') ) |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 2825 | 2640 | return(new IXR_Error(500, __('Sorry, the new category failed.'))); |
| 2826 | 2641 | } |
| 2827 | 2642 | |
| 2828 | | /** |
| 2829 | | * Fires after a new category has been successfully created via XML-RPC. |
| 2830 | | * |
| 2831 | | * @since 3.4.0 |
| 2832 | | * |
| 2833 | | * @param int $cat_id ID of the new category. |
| 2834 | | * @param array $args An array of new category arguments. |
| 2835 | | */ |
| 2836 | 2643 | do_action( 'xmlrpc_call_success_wp_newCategory', $cat_id, $args ); |
| 2837 | 2644 | |
| 2838 | 2645 | return $cat_id; |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 2857 | 2664 | if ( !$user = $this->login($username, $password) ) |
| 2858 | 2665 | return $this->error; |
| 2859 | 2666 | |
| 2860 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2861 | | do_action( 'xmlrpc_call', 'wp.deleteCategory' ); |
| | 2667 | do_action('xmlrpc_call', 'wp.deleteCategory'); |
| 2862 | 2668 | |
| 2863 | 2669 | if ( !current_user_can('manage_categories') ) |
| 2864 | 2670 | return new IXR_Error( 401, __( 'Sorry, you do not have the right to delete a category.' ) ); |
| 2865 | 2671 | |
| 2866 | 2672 | $status = wp_delete_term( $category_id, 'category' ); |
| 2867 | 2673 | |
| 2868 | | if ( true == $status ) { |
| 2869 | | /** |
| 2870 | | * Fires after a category has been successfully deleted via XML-RPC. |
| 2871 | | * |
| 2872 | | * @since 3.4.0 |
| 2873 | | * |
| 2874 | | * @param int $category_id ID of the deleted category. |
| 2875 | | * @param array $args An array of arguments to delete the category. |
| 2876 | | */ |
| | 2674 | if( true == $status ) |
| 2877 | 2675 | do_action( 'xmlrpc_call_success_wp_deleteCategory', $category_id, $args ); |
| 2878 | | } |
| 2879 | 2676 | |
| 2880 | 2677 | return $status; |
| 2881 | 2678 | } |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 2903 | 2700 | if ( !current_user_can( 'edit_posts' ) ) |
| 2904 | 2701 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts to this site in order to view categories.' ) ); |
| 2905 | 2702 | |
| 2906 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2907 | | do_action( 'xmlrpc_call', 'wp.suggestCategories' ); |
| | 2703 | do_action('xmlrpc_call', 'wp.suggestCategories'); |
| 2908 | 2704 | |
| 2909 | 2705 | $category_suggestions = array(); |
| 2910 | 2706 | $args = array('get' => 'all', 'number' => $max_results, 'name__like' => $category); |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 2940 | 2736 | if ( !current_user_can( 'moderate_comments' ) ) |
| 2941 | 2737 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
| 2942 | 2738 | |
| 2943 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2944 | | do_action( 'xmlrpc_call', 'wp.getComment' ); |
| | 2739 | do_action('xmlrpc_call', 'wp.getComment'); |
| 2945 | 2740 | |
| 2946 | 2741 | if ( ! $comment = get_comment($comment_id) ) |
| 2947 | 2742 | return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 2982 | 2777 | if ( !current_user_can( 'moderate_comments' ) ) |
| 2983 | 2778 | return new IXR_Error( 401, __( 'Sorry, you cannot edit comments.' ) ); |
| 2984 | 2779 | |
| 2985 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 2986 | | do_action( 'xmlrpc_call', 'wp.getComments' ); |
| | 2780 | do_action('xmlrpc_call', 'wp.getComments'); |
| 2987 | 2781 | |
| 2988 | 2782 | if ( isset($struct['status']) ) |
| 2989 | 2783 | $status = $struct['status']; |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 3049 | 2843 | if ( !current_user_can( 'edit_comment', $comment_ID ) ) |
| 3050 | 2844 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
| 3051 | 2845 | |
| 3052 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3053 | | do_action( 'xmlrpc_call', 'wp.deleteComment' ); |
| | 2846 | do_action('xmlrpc_call', 'wp.deleteComment'); |
| 3054 | 2847 | |
| 3055 | 2848 | $status = wp_delete_comment( $comment_ID ); |
| 3056 | 2849 | |
| 3057 | | if ( true == $status ) { |
| 3058 | | /** |
| 3059 | | * Fires after a comment has been successfully deleted via XML-RPC. |
| 3060 | | * |
| 3061 | | * @since 3.4.0 |
| 3062 | | * |
| 3063 | | * @param int $comment_ID ID of the deleted comment. |
| 3064 | | * @param array $args An array of arguments to delete the comment. |
| 3065 | | */ |
| | 2850 | if( true == $status ) |
| 3066 | 2851 | do_action( 'xmlrpc_call_success_wp_deleteComment', $comment_ID, $args ); |
| 3067 | | } |
| 3068 | 2852 | |
| 3069 | 2853 | return $status; |
| 3070 | 2854 | } |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 3114 | 2898 | if ( !current_user_can( 'edit_comment', $comment_ID ) ) |
| 3115 | 2899 | return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); |
| 3116 | 2900 | |
| 3117 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3118 | | do_action( 'xmlrpc_call', 'wp.editComment' ); |
| | 2901 | do_action('xmlrpc_call', 'wp.editComment'); |
| 3119 | 2902 | |
| 3120 | 2903 | if ( isset($content_struct['status']) ) { |
| 3121 | 2904 | $statuses = get_comment_statuses(); |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 3156 | 2939 | if ( !$result ) |
| 3157 | 2940 | return new IXR_Error(500, __('Sorry, the comment could not be edited. Something wrong happened.')); |
| 3158 | 2941 | |
| 3159 | | /** |
| 3160 | | * Fires after a comment has been successfully updated via XML-RPC. |
| 3161 | | * |
| 3162 | | * @since 3.4.0 |
| 3163 | | * |
| 3164 | | * @param int $comment_ID ID of the updated comment. |
| 3165 | | * @param array $args An array of arguments to update the comment. |
| 3166 | | */ |
| 3167 | 2942 | do_action( 'xmlrpc_call_success_wp_editComment', $comment_ID, $args ); |
| 3168 | 2943 | |
| 3169 | 2944 | return true; |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 3188 | 2963 | $post = $args[3]; |
| 3189 | 2964 | $content_struct = $args[4]; |
| 3190 | 2965 | |
| 3191 | | /** |
| 3192 | | * Filter whether to allow anonymous comments over XML-RPC. |
| 3193 | | * |
| 3194 | | * @since 2.7.0 |
| 3195 | | * |
| 3196 | | * @param bool $allow Whether to allow anonymous commenting via XML-RPC. |
| 3197 | | * Default false. |
| 3198 | | */ |
| 3199 | | $allow_anon = apply_filters( 'xmlrpc_allow_anonymous_comments', false ); |
| | 2966 | $allow_anon = apply_filters('xmlrpc_allow_anonymous_comments', false); |
| 3200 | 2967 | |
| 3201 | 2968 | $user = $this->login($username, $password); |
| 3202 | 2969 | |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 3255 | 3022 | |
| 3256 | 3023 | $comment['comment_content'] = isset($content_struct['content']) ? $content_struct['content'] : null; |
| 3257 | 3024 | |
| 3258 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3259 | | do_action( 'xmlrpc_call', 'wp.newComment' ); |
| | 3025 | do_action('xmlrpc_call', 'wp.newComment'); |
| 3260 | 3026 | |
| 3261 | 3027 | $comment_ID = wp_new_comment( $comment ); |
| 3262 | 3028 | |
| 3263 | | /** |
| 3264 | | * Fires after a new comment has been successfully created via XML-RPC. |
| 3265 | | * |
| 3266 | | * @since 3.4.0 |
| 3267 | | * |
| 3268 | | * @param int $comment_ID ID of the new comment. |
| 3269 | | * @param array $args An array of new comment arguments. |
| 3270 | | */ |
| 3271 | 3029 | do_action( 'xmlrpc_call_success_wp_newComment', $comment_ID, $args ); |
| 3272 | 3030 | |
| 3273 | 3031 | return $comment_ID; |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 3294 | 3052 | if ( !current_user_can( 'moderate_comments' ) ) |
| 3295 | 3053 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
| 3296 | 3054 | |
| 3297 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3298 | | do_action( 'xmlrpc_call', 'wp.getCommentStatusList' ); |
| | 3055 | do_action('xmlrpc_call', 'wp.getCommentStatusList'); |
| 3299 | 3056 | |
| 3300 | 3057 | return get_comment_statuses(); |
| 3301 | 3058 | } |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 3322 | 3079 | if ( !current_user_can( 'edit_posts' ) ) |
| 3323 | 3080 | return new IXR_Error( 403, __( 'You are not allowed access to details about comments.' ) ); |
| 3324 | 3081 | |
| 3325 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3326 | | do_action( 'xmlrpc_call', 'wp.getCommentCount' ); |
| | 3082 | do_action('xmlrpc_call', 'wp.getCommentCount'); |
| 3327 | 3083 | |
| 3328 | 3084 | $count = wp_count_comments( $post_id ); |
| 3329 | 3085 | return array( |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 3349 | 3105 | $username = $args[1]; |
| 3350 | 3106 | $password = $args[2]; |
| 3351 | 3107 | |
| | 3108 | switch_to_blog($blog_id); |
| | 3109 | |
| 3352 | 3110 | if ( !$user = $this->login($username, $password) ) |
| 3353 | 3111 | return $this->error; |
| 3354 | 3112 | |
| 3355 | 3113 | if ( !current_user_can( 'edit_posts' ) ) |
| 3356 | 3114 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
| 3357 | 3115 | |
| 3358 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3359 | | do_action( 'xmlrpc_call', 'wp.getPostStatusList' ); |
| | 3116 | do_action('xmlrpc_call', 'wp.getPostStatusList'); |
| 3360 | 3117 | |
| 3361 | 3118 | return get_post_statuses(); |
| 3362 | 3119 | } |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 3382 | 3139 | if ( !current_user_can( 'edit_pages' ) ) |
| 3383 | 3140 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
| 3384 | 3141 | |
| 3385 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3386 | | do_action( 'xmlrpc_call', 'wp.getPageStatusList' ); |
| | 3142 | do_action('xmlrpc_call', 'wp.getPageStatusList'); |
| 3387 | 3143 | |
| 3388 | 3144 | return get_page_statuses(); |
| 3389 | 3145 | } |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 3499 | 3255 | if ( $this->blog_options[$o_name]['readonly'] == true ) |
| 3500 | 3256 | continue; |
| 3501 | 3257 | |
| 3502 | | update_option( $this->blog_options[$o_name]['option'], wp_unslash( $o_value ) ); |
| | 3258 | update_option( $this->blog_options[$o_name]['option'], $o_value ); |
| 3503 | 3259 | } |
| 3504 | 3260 | |
| 3505 | 3261 | //Now return the updated values |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 3540 | 3296 | if ( !current_user_can( 'upload_files' ) ) |
| 3541 | 3297 | return new IXR_Error( 403, __( 'You do not have permission to upload files.' ) ); |
| 3542 | 3298 | |
| 3543 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3544 | | do_action( 'xmlrpc_call', 'wp.getMediaItem' ); |
| | 3299 | do_action('xmlrpc_call', 'wp.getMediaItem'); |
| 3545 | 3300 | |
| 3546 | 3301 | if ( ! $attachment = get_post($attachment_id) ) |
| 3547 | 3302 | return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 3586 | 3341 | if ( !current_user_can( 'upload_files' ) ) |
| 3587 | 3342 | return new IXR_Error( 401, __( 'You do not have permission to upload files.' ) ); |
| 3588 | 3343 | |
| 3589 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3590 | | do_action( 'xmlrpc_call', 'wp.getMediaLibrary' ); |
| | 3344 | do_action('xmlrpc_call', 'wp.getMediaLibrary'); |
| 3591 | 3345 | |
| 3592 | 3346 | $parent_id = ( isset($struct['parent_id']) ) ? absint($struct['parent_id']) : '' ; |
| 3593 | 3347 | $mime_type = ( isset($struct['mime_type']) ) ? $struct['mime_type'] : '' ; |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 3607 | 3361 | /** |
| 3608 | 3362 | * Retrieves a list of post formats used by the site |
| 3609 | 3363 | * |
| 3610 | | * @since 3.1.0 |
| | 3364 | * @since 3.1 |
| 3611 | 3365 | * |
| 3612 | 3366 | * @param array $args Method parameters. Contains: |
| 3613 | 3367 | * - blog_id |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 3622 | 3376 | $username = $args[1]; |
| 3623 | 3377 | $password = $args[2]; |
| 3624 | 3378 | |
| | 3379 | switch_to_blog($blog_id); |
| | 3380 | |
| 3625 | 3381 | if ( !$user = $this->login( $username, $password ) ) |
| 3626 | 3382 | return $this->error; |
| 3627 | 3383 | |
| 3628 | 3384 | if ( !current_user_can( 'edit_posts' ) ) |
| 3629 | 3385 | return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); |
| 3630 | 3386 | |
| 3631 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3632 | 3387 | do_action( 'xmlrpc_call', 'wp.getPostFormats' ); |
| 3633 | 3388 | |
| 3634 | 3389 | $formats = get_post_format_strings(); |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 3684 | 3439 | $password = $args[2]; |
| 3685 | 3440 | $post_type_name = $args[3]; |
| 3686 | 3441 | |
| 3687 | | if ( isset( $args[4] ) ) { |
| | 3442 | switch_to_blog($blog_id); |
| | 3443 | |
| | 3444 | if ( isset( $args[4] ) ) |
| 3688 | 3445 | $fields = $args[4]; |
| 3689 | | } else { |
| 3690 | | /** |
| 3691 | | * Filter the default query fields used by the given XML-RPC method. |
| 3692 | | * |
| 3693 | | * @since 3.4.0 |
| 3694 | | * |
| 3695 | | * @param array $fields An array of post type query fields for the given method. |
| 3696 | | * @param string $method The method name. |
| 3697 | | */ |
| | 3446 | else |
| 3698 | 3447 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostType' ); |
| 3699 | | } |
| 3700 | 3448 | |
| 3701 | 3449 | if ( !$user = $this->login( $username, $password ) ) |
| 3702 | 3450 | return $this->error; |
| 3703 | 3451 | |
| 3704 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3705 | 3452 | do_action( 'xmlrpc_call', 'wp.getPostType' ); |
| 3706 | 3453 | |
| 3707 | 3454 | if( ! post_type_exists( $post_type_name ) ) |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 3740 | 3487 | $password = $args[2]; |
| 3741 | 3488 | $filter = isset( $args[3] ) ? $args[3] : array( 'public' => true ); |
| 3742 | 3489 | |
| 3743 | | if ( isset( $args[4] ) ) { |
| | 3490 | switch_to_blog($blog_id); |
| | 3491 | |
| | 3492 | if ( isset( $args[4] ) ) |
| 3744 | 3493 | $fields = $args[4]; |
| 3745 | | } else { |
| 3746 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| | 3494 | else |
| 3747 | 3495 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostTypes' ); |
| 3748 | | } |
| 3749 | 3496 | |
| 3750 | 3497 | if ( ! $user = $this->login( $username, $password ) ) |
| 3751 | 3498 | return $this->error; |
| 3752 | 3499 | |
| 3753 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3754 | 3500 | do_action( 'xmlrpc_call', 'wp.getPostTypes' ); |
| 3755 | 3501 | |
| 3756 | 3502 | $post_types = get_post_types( $filter, 'objects' ); |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 3797 | 3543 | $password = $args[2]; |
| 3798 | 3544 | $post_id = (int) $args[3]; |
| 3799 | 3545 | |
| 3800 | | if ( isset( $args[4] ) ) { |
| | 3546 | if ( isset( $args[4] ) ) |
| 3801 | 3547 | $fields = $args[4]; |
| 3802 | | } else { |
| 3803 | | /** |
| 3804 | | * Filter the default revision query fields used by the given XML-RPC method. |
| 3805 | | * |
| 3806 | | * @since 3.5.0 |
| 3807 | | * |
| 3808 | | * @param array $field An array of revision query fields. |
| 3809 | | * @param string $method The method name. |
| 3810 | | */ |
| | 3548 | else |
| 3811 | 3549 | $fields = apply_filters( 'xmlrpc_default_revision_fields', array( 'post_date', 'post_date_gmt' ), 'wp.getRevisions' ); |
| 3812 | | } |
| 3813 | 3550 | |
| 3814 | 3551 | if ( ! $user = $this->login( $username, $password ) ) |
| 3815 | 3552 | return $this->error; |
| 3816 | 3553 | |
| 3817 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3818 | 3554 | do_action( 'xmlrpc_call', 'wp.getRevisions' ); |
| 3819 | 3555 | |
| 3820 | 3556 | if ( ! $post = get_post( $post_id ) ) |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 3876 | 3612 | if ( ! $user = $this->login( $username, $password ) ) |
| 3877 | 3613 | return $this->error; |
| 3878 | 3614 | |
| 3879 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3880 | 3615 | do_action( 'xmlrpc_call', 'wp.restoreRevision' ); |
| 3881 | 3616 | |
| 3882 | 3617 | if ( ! $revision = wp_get_post_revision( $revision_id ) ) |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 3926 | 3661 | if ( !$user = $this->login($username, $password) ) |
| 3927 | 3662 | return $this->error; |
| 3928 | 3663 | |
| 3929 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3930 | | do_action( 'xmlrpc_call', 'blogger.getUsersBlogs' ); |
| | 3664 | do_action('xmlrpc_call', 'blogger.getUsersBlogs'); |
| 3931 | 3665 | |
| 3932 | 3666 | $is_admin = current_user_can('manage_options'); |
| 3933 | 3667 | |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 3994 | 3728 | if ( !current_user_can( 'edit_posts' ) ) |
| 3995 | 3729 | return new IXR_Error( 401, __( 'Sorry, you do not have access to user data on this site.' ) ); |
| 3996 | 3730 | |
| 3997 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 3998 | | do_action( 'xmlrpc_call', 'blogger.getUserInfo' ); |
| | 3731 | do_action('xmlrpc_call', 'blogger.getUserInfo'); |
| 3999 | 3732 | |
| 4000 | 3733 | $struct = array( |
| 4001 | 3734 | 'nickname' => $user->nickname, |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 4034 | 3767 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
| 4035 | 3768 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); |
| 4036 | 3769 | |
| 4037 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4038 | | do_action( 'xmlrpc_call', 'blogger.getPost' ); |
| | 3770 | do_action('xmlrpc_call', 'blogger.getPost'); |
| 4039 | 3771 | |
| 4040 | 3772 | $categories = implode(',', wp_get_post_categories($post_ID)); |
| 4041 | 3773 | |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 4080 | 3812 | if ( ! current_user_can( 'edit_posts' ) ) |
| 4081 | 3813 | return new IXR_Error( 401, __( 'Sorry, you cannot edit posts on this site.' ) ); |
| 4082 | 3814 | |
| 4083 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4084 | | do_action( 'xmlrpc_call', 'blogger.getRecentPosts' ); |
| | 3815 | do_action('xmlrpc_call', 'blogger.getRecentPosts'); |
| 4085 | 3816 | |
| 4086 | 3817 | $posts_list = wp_get_recent_posts( $query ); |
| 4087 | 3818 | |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 4159 | 3890 | if ( !$user = $this->login($username, $password) ) |
| 4160 | 3891 | return $this->error; |
| 4161 | 3892 | |
| 4162 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4163 | | do_action( 'xmlrpc_call', 'blogger.newPost' ); |
| | 3893 | do_action('xmlrpc_call', 'blogger.newPost'); |
| 4164 | 3894 | |
| 4165 | 3895 | $cap = ($publish) ? 'publish_posts' : 'edit_posts'; |
| 4166 | 3896 | if ( ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) || !current_user_can($cap) ) |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 4188 | 3918 | |
| 4189 | 3919 | $this->attach_uploads( $post_ID, $post_content ); |
| 4190 | 3920 | |
| 4191 | | /** |
| 4192 | | * Fires after a new post has been successfully created via the XML-RPC Blogger API. |
| 4193 | | * |
| 4194 | | * @since 3.4.0 |
| 4195 | | * |
| 4196 | | * @param int $post_ID ID of the new post. |
| 4197 | | * @param array $args An array of new post arguments. |
| 4198 | | */ |
| 4199 | 3921 | do_action( 'xmlrpc_call_success_blogger_newPost', $post_ID, $args ); |
| 4200 | 3922 | |
| 4201 | 3923 | return $post_ID; |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 4222 | 3944 | if ( !$user = $this->login($username, $password) ) |
| 4223 | 3945 | return $this->error; |
| 4224 | 3946 | |
| 4225 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4226 | | do_action( 'xmlrpc_call', 'blogger.editPost' ); |
| | 3947 | do_action('xmlrpc_call', 'blogger.editPost'); |
| 4227 | 3948 | |
| 4228 | 3949 | $actual_post = get_post($post_ID,ARRAY_A); |
| 4229 | 3950 | |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 4253 | 3974 | |
| 4254 | 3975 | $this->attach_uploads( $ID, $post_content ); |
| 4255 | 3976 | |
| 4256 | | /** |
| 4257 | | * Fires after a post has been successfully updated via the XML-RPC Blogger API. |
| 4258 | | * |
| 4259 | | * @since 3.4.0 |
| 4260 | | * |
| 4261 | | * @param int $post_ID ID of the updated post. |
| 4262 | | * @param array $args An array of arguments for the post to edit. |
| 4263 | | */ |
| 4264 | 3977 | do_action( 'xmlrpc_call_success_blogger_editPost', $post_ID, $args ); |
| 4265 | 3978 | |
| 4266 | 3979 | return true; |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 4285 | 3998 | if ( !$user = $this->login($username, $password) ) |
| 4286 | 3999 | return $this->error; |
| 4287 | 4000 | |
| 4288 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4289 | | do_action( 'xmlrpc_call', 'blogger.deletePost' ); |
| | 4001 | do_action('xmlrpc_call', 'blogger.deletePost'); |
| 4290 | 4002 | |
| 4291 | 4003 | $actual_post = get_post($post_ID,ARRAY_A); |
| 4292 | 4004 | |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 4301 | 4013 | if ( !$result ) |
| 4302 | 4014 | return new IXR_Error(500, __('For some strange yet very annoying reason, this post could not be deleted.')); |
| 4303 | 4015 | |
| 4304 | | /** |
| 4305 | | * Fires after a post has been successfully deleted via the XML-RPC Blogger API. |
| 4306 | | * |
| 4307 | | * @since 3.4.0 |
| 4308 | | * |
| 4309 | | * @param int $post_ID ID of the deleted post. |
| 4310 | | * @param array $args An array of arguments to delete the post. |
| 4311 | | */ |
| 4312 | 4016 | do_action( 'xmlrpc_call_success_blogger_deletePost', $post_ID, $args ); |
| 4313 | 4017 | |
| 4314 | 4018 | return true; |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 4365 | 4069 | if ( !$user = $this->login($username, $password) ) |
| 4366 | 4070 | return $this->error; |
| 4367 | 4071 | |
| 4368 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4369 | | do_action( 'xmlrpc_call', 'metaWeblog.newPost' ); |
| | 4072 | do_action('xmlrpc_call', 'metaWeblog.newPost'); |
| 4370 | 4073 | |
| 4371 | 4074 | $page_template = ''; |
| 4372 | 4075 | if ( !empty( $content_struct['post_type'] ) ) { |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 4620 | 4323 | if ( !$post_ID ) |
| 4621 | 4324 | return new IXR_Error(500, __('Sorry, your entry could not be posted. Something wrong happened.')); |
| 4622 | 4325 | |
| 4623 | | /** |
| 4624 | | * Fires after a new post has been successfully created via the XML-RPC MovableType API. |
| 4625 | | * |
| 4626 | | * @since 3.4.0 |
| 4627 | | * |
| 4628 | | * @param int $post_ID ID of the new post. |
| 4629 | | * @param array $args An array of arguments to create the new post. |
| 4630 | | */ |
| 4631 | 4326 | do_action( 'xmlrpc_call_success_mw_newPost', $post_ID, $args ); |
| 4632 | 4327 | |
| 4633 | 4328 | return strval($post_ID); |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 4693 | 4388 | if ( ! $user = $this->login($username, $password) ) |
| 4694 | 4389 | return $this->error; |
| 4695 | 4390 | |
| 4696 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4697 | | do_action( 'xmlrpc_call', 'metaWeblog.editPost' ); |
| | 4391 | do_action('xmlrpc_call', 'metaWeblog.editPost'); |
| 4698 | 4392 | |
| 4699 | 4393 | $postdata = get_post( $post_ID, ARRAY_A ); |
| 4700 | 4394 | |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 4937 | 4631 | if ( isset( $content_struct['wp_post_format'] ) ) |
| 4938 | 4632 | set_post_format( $post_ID, $content_struct['wp_post_format'] ); |
| 4939 | 4633 | |
| 4940 | | /** |
| 4941 | | * Fires after a post has been successfully updated via the XML-RPC MovableType API. |
| 4942 | | * |
| 4943 | | * @since 3.4.0 |
| 4944 | | * |
| 4945 | | * @param int $post_ID ID of the updated post. |
| 4946 | | * @param array $args An array of arguments to update the post. |
| 4947 | | */ |
| 4948 | 4634 | do_action( 'xmlrpc_call_success_mw_editPost', $post_ID, $args ); |
| 4949 | 4635 | |
| 4950 | 4636 | return true; |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 4976 | 4662 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
| 4977 | 4663 | return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); |
| 4978 | 4664 | |
| 4979 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 4980 | | do_action( 'xmlrpc_call', 'metaWeblog.getPost' ); |
| | 4665 | do_action('xmlrpc_call', 'metaWeblog.getPost'); |
| 4981 | 4666 | |
| 4982 | 4667 | if ($postdata['post_date'] != '') { |
| 4983 | 4668 | $post_date = $this->_convert_date( $postdata['post_date'] ); |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 5101 | 4786 | if ( ! current_user_can( 'edit_posts' ) ) |
| 5102 | 4787 | return new IXR_Error( 401, __( 'Sorry, you cannot edit posts on this site.' ) ); |
| 5103 | 4788 | |
| 5104 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5105 | | do_action( 'xmlrpc_call', 'metaWeblog.getRecentPosts' ); |
| | 4789 | do_action('xmlrpc_call', 'metaWeblog.getRecentPosts'); |
| 5106 | 4790 | |
| 5107 | 4791 | $posts_list = wp_get_recent_posts( $query ); |
| 5108 | 4792 | |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 5179 | 4863 | 'custom_fields' => $this->get_custom_fields($entry['ID']), |
| 5180 | 4864 | 'wp_post_format' => $post_format, |
| 5181 | 4865 | 'date_modified' => $post_modified, |
| 5182 | | 'date_modified_gmt' => $post_modified_gmt, |
| 5183 | | 'sticky' => ( $entry['post_type'] === 'post' && is_sticky( $entry['ID'] ) ), |
| | 4866 | 'date_modified_gmt' => $post_modified_gmt |
| 5184 | 4867 | ); |
| 5185 | 4868 | |
| 5186 | 4869 | $entry_index = count( $struct ) - 1; |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 5217 | 4900 | if ( !current_user_can( 'edit_posts' ) ) |
| 5218 | 4901 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
| 5219 | 4902 | |
| 5220 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5221 | | do_action( 'xmlrpc_call', 'metaWeblog.getCategories' ); |
| | 4903 | do_action('xmlrpc_call', 'metaWeblog.getCategories'); |
| 5222 | 4904 | |
| 5223 | 4905 | $categories_struct = array(); |
| 5224 | 4906 | |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 5266 | 4948 | if ( !$user = $this->login($username, $password) ) |
| 5267 | 4949 | return $this->error; |
| 5268 | 4950 | |
| 5269 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5270 | | do_action( 'xmlrpc_call', 'metaWeblog.newMediaObject' ); |
| | 4951 | do_action('xmlrpc_call', 'metaWeblog.newMediaObject'); |
| 5271 | 4952 | |
| 5272 | 4953 | if ( !current_user_can('upload_files') ) { |
| 5273 | 4954 | $this->error = new IXR_Error( 401, __( 'You do not have permission to upload files.' ) ); |
| 5274 | 4955 | return $this->error; |
| 5275 | 4956 | } |
| 5276 | 4957 | |
| 5277 | | /** |
| 5278 | | * Filter whether to preempt the XML-RPC media upload. |
| 5279 | | * |
| 5280 | | * Passing a truthy value will effectively short-circuit the media upload, |
| 5281 | | * returning that value as a 500 error instead. |
| 5282 | | * |
| 5283 | | * @since 2.1.0 |
| 5284 | | * |
| 5285 | | * @param bool $error Whether to pre-empt the media upload. Default false. |
| 5286 | | */ |
| 5287 | | if ( $upload_err = apply_filters( 'pre_upload_error', false ) ) { |
| 5288 | | return new IXR_Error( 500, $upload_err ); |
| 5289 | | } |
| | 4958 | if ( $upload_err = apply_filters( 'pre_upload_error', false ) ) |
| | 4959 | return new IXR_Error(500, $upload_err); |
| 5290 | 4960 | |
| 5291 | 4961 | if ( !empty($data['overwrite']) && ($data['overwrite'] == true) ) { |
| 5292 | 4962 | // Get postmeta info on the object. |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 5332 | 5002 | $id = wp_insert_attachment( $attachment, $upload[ 'file' ], $post_id ); |
| 5333 | 5003 | wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $upload['file'] ) ); |
| 5334 | 5004 | |
| 5335 | | /** |
| 5336 | | * Fires after a new attachment has been added via the XML-RPC MovableType API. |
| 5337 | | * |
| 5338 | | * @since 3.4.0 |
| 5339 | | * |
| 5340 | | * @param int $id ID of the new attachment. |
| 5341 | | * @param array $args An array of arguments to add the attachment. |
| 5342 | | */ |
| 5343 | 5005 | do_action( 'xmlrpc_call_success_mw_newMediaObject', $id, $args ); |
| 5344 | 5006 | |
| 5345 | 5007 | $struct = array( |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 5348 | 5010 | 'url' => $upload[ 'url' ], |
| 5349 | 5011 | 'type' => $type |
| 5350 | 5012 | ); |
| 5351 | | |
| 5352 | | /** This filter is documented in wp-admin/includes/file.php */ |
| 5353 | 5013 | return apply_filters( 'wp_handle_upload', $struct, 'upload' ); |
| 5354 | 5014 | } |
| 5355 | 5015 | |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 5380 | 5040 | if ( !$user = $this->login($username, $password) ) |
| 5381 | 5041 | return $this->error; |
| 5382 | 5042 | |
| 5383 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5384 | | do_action( 'xmlrpc_call', 'mt.getRecentPostTitles' ); |
| | 5043 | do_action('xmlrpc_call', 'mt.getRecentPostTitles'); |
| 5385 | 5044 | |
| 5386 | 5045 | $posts_list = wp_get_recent_posts( $query ); |
| 5387 | 5046 | |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 5440 | 5099 | if ( !current_user_can( 'edit_posts' ) ) |
| 5441 | 5100 | return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); |
| 5442 | 5101 | |
| 5443 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5444 | | do_action( 'xmlrpc_call', 'mt.getCategoryList' ); |
| | 5102 | do_action('xmlrpc_call', 'mt.getCategoryList'); |
| 5445 | 5103 | |
| 5446 | 5104 | $categories_struct = array(); |
| 5447 | 5105 | |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 5482 | 5140 | if ( !current_user_can( 'edit_post', $post_ID ) ) |
| 5483 | 5141 | return new IXR_Error( 401, __( 'Sorry, you can not edit this post.' ) ); |
| 5484 | 5142 | |
| 5485 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5486 | | do_action( 'xmlrpc_call', 'mt.getPostCategories' ); |
| | 5143 | do_action('xmlrpc_call', 'mt.getPostCategories'); |
| 5487 | 5144 | |
| 5488 | 5145 | $categories = array(); |
| 5489 | 5146 | $catids = wp_get_post_categories(intval($post_ID)); |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 5521 | 5178 | if ( !$user = $this->login($username, $password) ) |
| 5522 | 5179 | return $this->error; |
| 5523 | 5180 | |
| 5524 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5525 | | do_action( 'xmlrpc_call', 'mt.setPostCategories' ); |
| | 5181 | do_action('xmlrpc_call', 'mt.setPostCategories'); |
| 5526 | 5182 | |
| 5527 | 5183 | if ( ! get_post( $post_ID ) ) |
| 5528 | 5184 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 5550 | 5206 | */ |
| 5551 | 5207 | function mt_supportedMethods($args) { |
| 5552 | 5208 | |
| 5553 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5554 | | do_action( 'xmlrpc_call', 'mt.supportedMethods' ); |
| | 5209 | do_action('xmlrpc_call', 'mt.supportedMethods'); |
| 5555 | 5210 | |
| 5556 | 5211 | $supported_methods = array(); |
| 5557 | 5212 | foreach ( $this->methods as $key => $value ) { |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 5569 | 5224 | * @param array $args Method parameters. |
| 5570 | 5225 | */ |
| 5571 | 5226 | function mt_supportedTextFilters($args) { |
| 5572 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5573 | | do_action( 'xmlrpc_call', 'mt.supportedTextFilters' ); |
| 5574 | | |
| 5575 | | /** |
| 5576 | | * Filter the MoveableType text filters list for XML-RPC. |
| 5577 | | * |
| 5578 | | * @since 2.2.0 |
| 5579 | | * |
| 5580 | | * @param array $filters An array of text filters. |
| 5581 | | */ |
| 5582 | | return apply_filters( 'xmlrpc_text_filters', array() ); |
| | 5227 | do_action('xmlrpc_call', 'mt.supportedTextFilters'); |
| | 5228 | return apply_filters('xmlrpc_text_filters', array()); |
| 5583 | 5229 | } |
| 5584 | 5230 | |
| 5585 | 5231 | /** |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 5596 | 5242 | |
| 5597 | 5243 | $post_ID = intval($args); |
| 5598 | 5244 | |
| 5599 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5600 | | do_action( 'xmlrpc_call', 'mt.getTrackbackPings' ); |
| | 5245 | do_action('xmlrpc_call', 'mt.getTrackbackPings'); |
| 5601 | 5246 | |
| 5602 | 5247 | $actual_post = get_post($post_ID, ARRAY_A); |
| 5603 | 5248 | |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 5644 | 5289 | if ( !$user = $this->login($username, $password) ) |
| 5645 | 5290 | return $this->error; |
| 5646 | 5291 | |
| 5647 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5648 | | do_action( 'xmlrpc_call', 'mt.publishPost' ); |
| | 5292 | do_action('xmlrpc_call', 'mt.publishPost'); |
| 5649 | 5293 | |
| 5650 | 5294 | $postdata = get_post($post_ID, ARRAY_A); |
| 5651 | 5295 | if ( ! $postdata ) |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 5681 | 5325 | function pingback_ping($args) { |
| 5682 | 5326 | global $wpdb; |
| 5683 | 5327 | |
| 5684 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5685 | | do_action( 'xmlrpc_call', 'pingback.ping' ); |
| | 5328 | do_action('xmlrpc_call', 'pingback.ping'); |
| 5686 | 5329 | |
| 5687 | 5330 | $this->escape($args); |
| 5688 | 5331 | |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 5695 | 5338 | $pagelinkedto = str_replace('&', '&', $pagelinkedto); |
| 5696 | 5339 | $pagelinkedto = str_replace('&', '&', $pagelinkedto); |
| 5697 | 5340 | |
| 5698 | | /** |
| 5699 | | * Filter the pingback source URI. |
| 5700 | | * |
| 5701 | | * @since 3.6.0 |
| 5702 | | * |
| 5703 | | * @param string $pagelinkedfrom URI of the page linked from. |
| 5704 | | * @param string $pagelinkedto URI of the page linked to. |
| 5705 | | */ |
| 5706 | 5341 | $pagelinkedfrom = apply_filters( 'pingback_ping_source_uri', $pagelinkedfrom, $pagelinkedto ); |
| 5707 | | |
| 5708 | 5342 | if ( ! $pagelinkedfrom ) |
| 5709 | 5343 | return $this->pingback_error( 0, __( 'A valid URL was not provided.' ) ); |
| 5710 | 5344 | |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 5774 | 5408 | // very stupid, but gives time to the 'from' server to publish ! |
| 5775 | 5409 | sleep(1); |
| 5776 | 5410 | |
| 5777 | | $remote_ip = preg_replace( '/[^0-9a-fA-F:., ]/', '', $_SERVER['REMOTE_ADDR'] ); |
| 5778 | | |
| 5779 | | /** This filter is documented in wp-includes/class-http.php */ |
| 5780 | | $user_agent = apply_filters( 'http_headers_useragent', 'WordPress/' . $GLOBALS['wp_version'] . '; ' . get_bloginfo( 'url' ) ); |
| 5781 | | |
| 5782 | 5411 | // Let's check the remote site |
| 5783 | 5412 | $http_api_args = array( |
| 5784 | 5413 | 'timeout' => 10, |
| 5785 | 5414 | 'redirection' => 0, |
| 5786 | 5415 | 'limit_response_size' => 153600, // 150 KB |
| 5787 | | 'user-agent' => "$user_agent; verifying pingback from $remote_ip", |
| 5788 | | 'headers' => array( |
| 5789 | | 'X-Pingback-Forwarded-For' => $remote_ip, |
| 5790 | | ), |
| 5791 | 5416 | ); |
| 5792 | | $request = wp_safe_remote_get( $pagelinkedfrom, $http_api_args ); |
| 5793 | | $linea = wp_remote_retrieve_body( $request ); |
| | 5417 | $linea = wp_remote_retrieve_body( wp_safe_remote_get( $pagelinkedfrom, $http_api_args ) ); |
| 5794 | 5418 | |
| 5795 | 5419 | if ( !$linea ) |
| 5796 | | return $this->pingback_error( 16, __( 'The source URL does not exist.' ) ); |
| 5797 | | |
| 5798 | | /** |
| 5799 | | * Filter the pingback remote source. |
| 5800 | | * |
| 5801 | | * @since 2.5.0 |
| 5802 | | * |
| 5803 | | * @param string $linea Response object for the page linked from. |
| 5804 | | * @param string $pagelinkedto URL of the page linked to. |
| 5805 | | */ |
| 5806 | | $linea = apply_filters( 'pre_remote_source', $linea, $pagelinkedto ); |
| | 5420 | return $this->pingback_error( 16, __( 'The source URL does not exist.' ) ); |
| | 5421 | |
| | 5422 | $linea = apply_filters('pre_remote_source', $linea, $pagelinkedto); |
| 5807 | 5423 | |
| 5808 | 5424 | // Work around bug in strip_tags(): |
| 5809 | 5425 | $linea = str_replace('<!DOC', '<DOC', $linea); |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 5868 | 5484 | $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_author_email', 'comment_content', 'comment_type'); |
| 5869 | 5485 | |
| 5870 | 5486 | $comment_ID = wp_new_comment($commentdata); |
| 5871 | | |
| 5872 | | /** |
| 5873 | | * Fires after a post pingback has been sent. |
| 5874 | | * |
| 5875 | | * @since 0.71 |
| 5876 | | * |
| 5877 | | * @param int $comment_ID Comment ID. |
| 5878 | | */ |
| 5879 | | do_action( 'pingback_post', $comment_ID ); |
| | 5487 | do_action('pingback_post', $comment_ID); |
| 5880 | 5488 | |
| 5881 | 5489 | return sprintf(__('Pingback from %1$s to %2$s registered. Keep the web talking! :-)'), $pagelinkedfrom, $pagelinkedto); |
| 5882 | 5490 | } |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 5895 | 5503 | |
| 5896 | 5504 | global $wpdb; |
| 5897 | 5505 | |
| 5898 | | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
| 5899 | | do_action( 'xmlrpc_call', 'pingback.extensions.getPingbacks' ); |
| | 5506 | do_action('xmlrpc_call', 'pingback.extensions.getPingbacks'); |
| 5900 | 5507 | |
| 5901 | 5508 | $this->escape($args); |
| 5902 | 5509 | |
| … |
… |
class wp_xmlrpc_server extends IXR_Server {
|
| 5930 | 5537 | } |
| 5931 | 5538 | |
| 5932 | 5539 | protected function pingback_error( $code, $message ) { |
| 5933 | | /** |
| 5934 | | * Filter the XML-RPC pingback error return. |
| 5935 | | * |
| 5936 | | * @since 3.5.1 |
| 5937 | | * |
| 5938 | | * @param IXR_Error $error An IXR_Error object containing the error code and message. |
| 5939 | | */ |
| 5940 | 5540 | return apply_filters( 'xmlrpc_pingback_error', new IXR_Error( $code, $message ) ); |
| 5941 | 5541 | } |
| 5942 | 5542 | } |