~canonical-sysadmins/wordpress/4.8.1

« back to all changes in this revision

Viewing changes to wp-includes/class-wp-xmlrpc-server.php

  • Committer: Barry Price
  • Date: 2016-08-17 04:50:12 UTC
  • mfrom: (1.1.18 upstream)
  • Revision ID: barry.price@canonical.com-20160817045012-qfui81zhqnqv2ba9
Merge WP4.6 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
 * options, etc.
15
15
 *
16
16
 * As of WordPress 3.5.0, XML-RPC is enabled by default. It can be disabled
17
 
 * via the xmlrpc_enabled filter found in wp_xmlrpc_server::login().
 
17
 * via the {@see 'xmlrpc_enabled'} filter found in wp_xmlrpc_server::login().
18
18
 *
19
19
 * @package WordPress
20
20
 * @subpackage Publishing
54
54
        protected $auth_failed = false;
55
55
 
56
56
        /**
57
 
         * Register all of the XMLRPC methods that XMLRPC server understands.
 
57
         * Registers all of the XMLRPC methods that XMLRPC server understands.
58
58
         *
59
59
         * Sets up server and method property. Passes XMLRPC
60
 
         * methods through the 'xmlrpc_methods' filter to allow plugins to extend
61
 
         * or replace XMLRPC methods.
 
60
         * methods through the {@see 'xmlrpc_methods'} filter to allow plugins to extend
 
61
         * or replace XML-RPC methods.
62
62
         *
63
63
         * @since 1.5.0
64
64
         */
159
159
                $this->initialise_blog_option_info();
160
160
 
161
161
                /**
162
 
                 * Filter the methods exposed by the XML-RPC server.
 
162
                 * Filters the methods exposed by the XML-RPC server.
163
163
                 *
164
164
                 * This filter can be used to add new methods, and remove built-in methods.
165
165
                 *
171
171
        }
172
172
 
173
173
        /**
174
 
         * Make private/protected methods readable for backwards compatibility.
 
174
         * Make private/protected methods readable for backward compatibility.
175
175
         *
176
176
         * @since 4.0.0
177
177
         * @access public
247
247
                }
248
248
 
249
249
                /**
250
 
                 * Filter whether XML-RPC methods requiring authentication are enabled.
 
250
                 * Filters whether XML-RPC methods requiring authentication are enabled.
251
251
                 *
252
252
                 * Contrary to the way it's named, this filter does not control whether XML-RPC is *fully*
253
253
                 * enabled, rather, it only controls whether XML-RPC methods requiring authentication - such
288
288
                        $this->auth_failed = true;
289
289
 
290
290
                        /**
291
 
                         * Filter the XML-RPC user login error message.
 
291
                         * Filters the XML-RPC user login error message.
292
292
                         *
293
293
                         * @since 3.5.0
294
294
                         *
562
562
                );
563
563
 
564
564
                /**
565
 
                 * Filter the XML-RPC blog options property.
 
565
                 * Filters the XML-RPC blog options property.
566
566
                 *
567
567
                 * @since 2.6.0
568
568
                 *
704
704
                        $_taxonomy['object_type'] = array_unique( (array) $taxonomy->object_type );
705
705
 
706
706
                /**
707
 
                 * Filter XML-RPC-prepared data for the given taxonomy.
 
707
                 * Filters XML-RPC-prepared data for the given taxonomy.
708
708
                 *
709
709
                 * @since 3.4.0
710
710
                 *
738
738
                $_term['count'] = intval( $_term['count'] );
739
739
 
740
740
                /**
741
 
                 * Filter XML-RPC-prepared data for the given term.
 
741
                 * Filters XML-RPC-prepared data for the given term.
742
742
                 *
743
743
                 * @since 3.4.0
744
744
                 *
867
867
                }
868
868
 
869
869
                /**
870
 
                 * Filter XML-RPC-prepared date for the given post.
 
870
                 * Filters XML-RPC-prepared date for the given post.
871
871
                 *
872
872
                 * @since 3.4.0
873
873
                 *
881
881
        /**
882
882
         * Prepares post data for return in an XML-RPC object.
883
883
         *
 
884
         * @since 3.4.0
 
885
         * @since 4.6.0 Converted the `$post_type` parameter to accept a WP_Post_Type object.
884
886
         * @access protected
885
887
         *
886
 
         * @param object $post_type Post type object.
887
 
         * @param array  $fields    The subset of post fields to return.
 
888
         * @param WP_Post_Type $post_type Post type object.
 
889
         * @param array        $fields    The subset of post fields to return.
888
890
         * @return array The prepared post type data.
889
891
         */
890
892
        protected function _prepare_post_type( $post_type, $fields ) {
918
920
                        $_post_type['taxonomies'] = get_object_taxonomies( $post_type->name, 'names' );
919
921
 
920
922
                /**
921
 
                 * Filter XML-RPC-prepared date for the given post type.
 
923
                 * Filters XML-RPC-prepared date for the given post type.
922
924
                 *
923
925
                 * @since 3.4.0
 
926
                 * @since 4.6.0 Converted the `$post_type` parameter to accept a WP_Post_Type object.
924
927
                 *
925
 
                 * @param array  $_post_type An array of post type data.
926
 
                 * @param object $post_type  Post type object.
 
928
                 * @param array        $_post_type An array of post type data.
 
929
                 * @param WP_Post_Type $post_type  Post type object.
927
930
                 */
928
931
                return apply_filters( 'xmlrpc_prepare_post_type', $_post_type, $post_type );
929
932
        }
957
960
                        $_media_item['thumbnail'] = $_media_item['link'];
958
961
 
959
962
                /**
960
 
                 * Filter XML-RPC-prepared data for the given media item.
 
963
                 * Filters XML-RPC-prepared data for the given media item.
961
964
                 *
962
965
                 * @since 3.4.0
963
966
                 *
1039
1042
                );
1040
1043
 
1041
1044
                /**
1042
 
                 * Filter XML-RPC-prepared data for the given page.
 
1045
                 * Filters XML-RPC-prepared data for the given page.
1043
1046
                 *
1044
1047
                 * @since 3.4.0
1045
1048
                 *
1088
1091
                );
1089
1092
 
1090
1093
                /**
1091
 
                 * Filter XML-RPC-prepared data for the given comment.
 
1094
                 * Filters XML-RPC-prepared data for the given comment.
1092
1095
                 *
1093
1096
                 * @since 3.4.0
1094
1097
                 *
1136
1139
                }
1137
1140
 
1138
1141
                /**
1139
 
                 * Filter XML-RPC-prepared data for the given user.
 
1142
                 * Filters XML-RPC-prepared data for the given user.
1140
1143
                 *
1141
1144
                 * @since 3.5.0
1142
1145
                 *
1152
1155
         *
1153
1156
         * @since 3.4.0
1154
1157
         *
1155
 
         * @link http://en.wikipedia.org/wiki/RSS_enclosure for information on RSS enclosures.
 
1158
         * @link https://en.wikipedia.org/wiki/RSS_enclosure for information on RSS enclosures.
1156
1159
         *
1157
1160
         * @param array  $args {
1158
1161
         *     Method arguments. Note: top-level arguments must be ordered as documented.
1299
1302
 
1300
1303
                $post_type = get_post_type_object( $post_data['post_type'] );
1301
1304
                if ( ! $post_type )
1302
 
                        return new IXR_Error( 403, __( 'Invalid post type' ) );
 
1305
                        return new IXR_Error( 403, __( 'Invalid post type.' ) );
1303
1306
 
1304
1307
                $update = ! empty( $post_data['ID'] );
1305
1308
 
1340
1343
                $post_data['post_author'] = absint( $post_data['post_author'] );
1341
1344
                if ( ! empty( $post_data['post_author'] ) && $post_data['post_author'] != $user->ID ) {
1342
1345
                        if ( ! current_user_can( $post_type->cap->edit_others_posts ) )
1343
 
                                return new IXR_Error( 401, __( 'You are not allowed to create posts as this user.' ) );
 
1346
                                return new IXR_Error( 401, __( 'Sorry, you are not allowed to create posts as this user.' ) );
1344
1347
 
1345
1348
                        $author = get_userdata( $post_data['post_author'] );
1346
1349
 
1423
1426
                                                $term = get_term_by( 'id', $term_id, $taxonomy );
1424
1427
 
1425
1428
                                                if ( ! $term )
1426
 
                                                        return new IXR_Error( 403, __( 'Invalid term ID' ) );
 
1429
                                                        return new IXR_Error( 403, __( 'Invalid term ID.' ) );
1427
1430
 
1428
1431
                                                $terms[$taxonomy][] = (int) $term_id;
1429
1432
                                        }
1506
1509
                $this->attach_uploads( $post_ID, $post_data['post_content'] );
1507
1510
 
1508
1511
                /**
1509
 
                 * Filter post data array to be inserted via XML-RPC.
 
1512
                 * Filters post data array to be inserted via XML-RPC.
1510
1513
                 *
1511
1514
                 * @since 3.4.0
1512
1515
                 *
1634
1637
                }
1635
1638
 
1636
1639
                if ( ! current_user_can( 'delete_post', $post_id ) ) {
1637
 
                        return new IXR_Error( 401, __( 'Sorry, you do not have the right to delete this post.' ) );
 
1640
                        return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) );
1638
1641
                }
1639
1642
 
1640
1643
                $result = wp_delete_post( $post_id );
1709
1712
                        $fields = $args[4];
1710
1713
                } else {
1711
1714
                        /**
1712
 
                         * Filter the list of post query fields used by the given XML-RPC method.
 
1715
                         * Filters the list of post query fields used by the given XML-RPC method.
1713
1716
                         *
1714
1717
                         * @since 3.4.0
1715
1718
                         *
1731
1734
                        return new IXR_Error( 404, __( 'Invalid post ID.' ) );
1732
1735
 
1733
1736
                if ( ! current_user_can( 'edit_post', $post_id ) )
1734
 
                        return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) );
 
1737
                        return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
1735
1738
 
1736
1739
                return $this->_prepare_post( $post, $fields );
1737
1740
        }
1792
1795
                }
1793
1796
 
1794
1797
                if ( ! current_user_can( $post_type->cap->edit_posts ) )
1795
 
                        return new IXR_Error( 401, __( 'You are not allowed to edit posts in this post type.' ));
 
1798
                        return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts in this post type.' ));
1796
1799
 
1797
1800
                $query['post_type'] = $post_type->name;
1798
1801
 
1870
1873
                do_action( 'xmlrpc_call', 'wp.newTerm' );
1871
1874
 
1872
1875
                if ( ! taxonomy_exists( $content_struct['taxonomy'] ) )
1873
 
                        return new IXR_Error( 403, __( 'Invalid taxonomy' ) );
 
1876
                        return new IXR_Error( 403, __( 'Invalid taxonomy.' ) );
1874
1877
 
1875
1878
                $taxonomy = get_taxonomy( $content_struct['taxonomy'] );
1876
1879
 
1877
1880
                if ( ! current_user_can( $taxonomy->cap->manage_terms ) )
1878
 
                        return new IXR_Error( 401, __( 'You are not allowed to create terms in this taxonomy.' ) );
 
1881
                        return new IXR_Error( 401, __( 'Sorry, you are not allowed to create terms in this taxonomy.' ) );
1879
1882
 
1880
1883
                $taxonomy = (array) $taxonomy;
1881
1884
 
1957
1960
                do_action( 'xmlrpc_call', 'wp.editTerm' );
1958
1961
 
1959
1962
                if ( ! taxonomy_exists( $content_struct['taxonomy'] ) )
1960
 
                        return new IXR_Error( 403, __( 'Invalid taxonomy' ) );
 
1963
                        return new IXR_Error( 403, __( 'Invalid taxonomy.' ) );
1961
1964
 
1962
1965
                $taxonomy = get_taxonomy( $content_struct['taxonomy'] );
1963
1966
 
1964
1967
                if ( ! current_user_can( $taxonomy->cap->edit_terms ) )
1965
 
                        return new IXR_Error( 401, __( 'You are not allowed to edit terms in this taxonomy.' ) );
 
1968
                        return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit terms in this taxonomy.' ) );
1966
1969
 
1967
1970
                $taxonomy = (array) $taxonomy;
1968
1971
 
1975
1978
                        return new IXR_Error( 500, $term->get_error_message() );
1976
1979
 
1977
1980
                if ( ! $term )
1978
 
                        return new IXR_Error( 404, __( 'Invalid term ID' ) );
 
1981
                        return new IXR_Error( 404, __( 'Invalid term ID.' ) );
1979
1982
 
1980
1983
                if ( isset( $content_struct['name'] ) ) {
1981
1984
                        $term_data['name'] = trim( $content_struct['name'] );
2053
2056
                do_action( 'xmlrpc_call', 'wp.deleteTerm' );
2054
2057
 
2055
2058
                if ( ! taxonomy_exists( $taxonomy ) )
2056
 
                        return new IXR_Error( 403, __( 'Invalid taxonomy' ) );
 
2059
                        return new IXR_Error( 403, __( 'Invalid taxonomy.' ) );
2057
2060
 
2058
2061
                $taxonomy = get_taxonomy( $taxonomy );
2059
2062
 
2060
2063
                if ( ! current_user_can( $taxonomy->cap->delete_terms ) )
2061
 
                        return new IXR_Error( 401, __( 'You are not allowed to delete terms in this taxonomy.' ) );
 
2064
                        return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete terms in this taxonomy.' ) );
2062
2065
 
2063
2066
                $term = get_term( $term_id, $taxonomy->name );
2064
2067
 
2066
2069
                        return new IXR_Error( 500, $term->get_error_message() );
2067
2070
 
2068
2071
                if ( ! $term )
2069
 
                        return new IXR_Error( 404, __( 'Invalid term ID' ) );
 
2072
                        return new IXR_Error( 404, __( 'Invalid term ID.' ) );
2070
2073
 
2071
2074
                $result = wp_delete_term( $term_id, $taxonomy->name );
2072
2075
 
2124
2127
                do_action( 'xmlrpc_call', 'wp.getTerm' );
2125
2128
 
2126
2129
                if ( ! taxonomy_exists( $taxonomy ) )
2127
 
                        return new IXR_Error( 403, __( 'Invalid taxonomy' ) );
 
2130
                        return new IXR_Error( 403, __( 'Invalid taxonomy.' ) );
2128
2131
 
2129
2132
                $taxonomy = get_taxonomy( $taxonomy );
2130
2133
 
2131
2134
                if ( ! current_user_can( $taxonomy->cap->assign_terms ) )
2132
 
                        return new IXR_Error( 401, __( 'You are not allowed to assign terms in this taxonomy.' ) );
 
2135
                        return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ) );
2133
2136
 
2134
2137
                $term = get_term( $term_id , $taxonomy->name, ARRAY_A );
2135
2138
 
2137
2140
                        return new IXR_Error( 500, $term->get_error_message() );
2138
2141
 
2139
2142
                if ( ! $term )
2140
 
                        return new IXR_Error( 404, __( 'Invalid term ID' ) );
 
2143
                        return new IXR_Error( 404, __( 'Invalid term ID.' ) );
2141
2144
 
2142
2145
                return $this->_prepare_term( $term );
2143
2146
        }
2182
2185
                do_action( 'xmlrpc_call', 'wp.getTerms' );
2183
2186
 
2184
2187
                if ( ! taxonomy_exists( $taxonomy ) )
2185
 
                        return new IXR_Error( 403, __( 'Invalid taxonomy' ) );
 
2188
                        return new IXR_Error( 403, __( 'Invalid taxonomy.' ) );
2186
2189
 
2187
2190
                $taxonomy = get_taxonomy( $taxonomy );
2188
2191
 
2189
2192
                if ( ! current_user_can( $taxonomy->cap->assign_terms ) )
2190
 
                        return new IXR_Error( 401, __( 'You are not allowed to assign terms in this taxonomy.' ) );
 
2193
                        return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ) );
2191
2194
 
2192
2195
                $query = array();
2193
2196
 
2260
2263
                        $fields = $args[4];
2261
2264
                } else {
2262
2265
                        /**
2263
 
                         * Filter the taxonomy query fields used by the given XML-RPC method.
 
2266
                         * Filters the taxonomy query fields used by the given XML-RPC method.
2264
2267
                         *
2265
2268
                         * @since 3.4.0
2266
2269
                         *
2277
2280
                do_action( 'xmlrpc_call', 'wp.getTaxonomy' );
2278
2281
 
2279
2282
                if ( ! taxonomy_exists( $taxonomy ) )
2280
 
                        return new IXR_Error( 403, __( 'Invalid taxonomy' ) );
 
2283
                        return new IXR_Error( 403, __( 'Invalid taxonomy.' ) );
2281
2284
 
2282
2285
                $taxonomy = get_taxonomy( $taxonomy );
2283
2286
 
2284
2287
                if ( ! current_user_can( $taxonomy->cap->assign_terms ) )
2285
 
                        return new IXR_Error( 401, __( 'You are not allowed to assign terms in this taxonomy.' ) );
 
2288
                        return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ) );
2286
2289
 
2287
2290
                return $this->_prepare_taxonomy( $taxonomy, $fields );
2288
2291
        }
2395
2398
                        $fields = $args[4];
2396
2399
                } else {
2397
2400
                        /**
2398
 
                         * Filter the default user query fields used by the given XML-RPC method.
 
2401
                         * Filters the default user query fields used by the given XML-RPC method.
2399
2402
                         *
2400
2403
                         * @since 3.5.0
2401
2404
                         *
2412
2415
                do_action( 'xmlrpc_call', 'wp.getUser' );
2413
2416
 
2414
2417
                if ( ! current_user_can( 'edit_user', $user_id ) )
2415
 
                        return new IXR_Error( 401, __( 'Sorry, you cannot edit users.' ) );
 
2418
                        return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this user.' ) );
2416
2419
 
2417
2420
                $user_data = get_userdata( $user_id );
2418
2421
 
2470
2473
                do_action( 'xmlrpc_call', 'wp.getUsers' );
2471
2474
 
2472
2475
                if ( ! current_user_can( 'list_users' ) )
2473
 
                        return new IXR_Error( 401, __( 'You are not allowed to browse users.' ) );
 
2476
                        return new IXR_Error( 401, __( 'Sorry, you are not allowed to browse users.' ) );
2474
2477
 
2475
2478
                $query = array( 'fields' => 'all_with_meta' );
2476
2479
 
2543
2546
                do_action( 'xmlrpc_call', 'wp.getProfile' );
2544
2547
 
2545
2548
                if ( ! current_user_can( 'edit_user', $user->ID ) )
2546
 
                        return new IXR_Error( 401, __( 'Sorry, you cannot edit your profile.' ) );
 
2549
                        return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit your profile.' ) );
2547
2550
 
2548
2551
                $user_data = get_userdata( $user->ID );
2549
2552
 
2589
2592
                do_action( 'xmlrpc_call', 'wp.editProfile' );
2590
2593
 
2591
2594
                if ( ! current_user_can( 'edit_user', $user->ID ) )
2592
 
                        return new IXR_Error( 401, __( 'Sorry, you cannot edit your profile.' ) );
 
2595
                        return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit your profile.' ) );
2593
2596
 
2594
2597
                // holds data of the user
2595
2598
                $user_data = array();
2659
2662
                        return new IXR_Error( 404, __( 'Invalid post ID.' ) );
2660
2663
 
2661
2664
                if ( !current_user_can( 'edit_page', $page_id ) )
2662
 
                        return new IXR_Error( 401, __( 'Sorry, you cannot edit this page.' ) );
 
2665
                        return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this page.' ) );
2663
2666
 
2664
2667
                /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
2665
2668
                do_action( 'xmlrpc_call', 'wp.getPage' );
2700
2703
                        return $this->error;
2701
2704
 
2702
2705
                if ( !current_user_can( 'edit_pages' ) )
2703
 
                        return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) );
 
2706
                        return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit pages.' ) );
2704
2707
 
2705
2708
                /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
2706
2709
                do_action( 'xmlrpc_call', 'wp.getPages' );
2794
2797
 
2795
2798
                // Make sure the user can delete pages.
2796
2799
                if ( !current_user_can('delete_page', $page_id) )
2797
 
                        return new IXR_Error( 401, __( 'Sorry, you do not have the right to delete this page.' ) );
 
2800
                        return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this page.' ) );
2798
2801
 
2799
2802
                // Attempt to delete the page.
2800
2803
                $result = wp_delete_post($page_id);
2856
2859
 
2857
2860
                // Make sure the user is allowed to edit pages.
2858
2861
                if ( !current_user_can('edit_page', $page_id) )
2859
 
                        return new IXR_Error( 401, __( 'Sorry, you do not have the right to edit this page.' ) );
 
2862
                        return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this page.' ) );
2860
2863
 
2861
2864
                // Mark this as content for a page.
2862
2865
                $content['post_type'] = 'page';
2902
2905
                        return $this->error;
2903
2906
 
2904
2907
                if ( !current_user_can( 'edit_pages' ) )
2905
 
                        return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) );
 
2908
                        return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit pages.' ) );
2906
2909
 
2907
2910
                /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
2908
2911
                do_action( 'xmlrpc_call', 'wp.getPageList' );
2958
2961
                        return $this->error;
2959
2962
 
2960
2963
                if ( !current_user_can('edit_posts') )
2961
 
                        return new IXR_Error( 401, __( 'Sorry, you cannot edit posts on this site.' ) );
 
2964
                        return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) );
2962
2965
 
2963
2966
                /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
2964
2967
                do_action( 'xmlrpc_call', 'wp.getAuthors' );
3053
3056
 
3054
3057
                // Make sure the user is allowed to add a category.
3055
3058
                if ( !current_user_can('manage_categories') )
3056
 
                        return new IXR_Error(401, __('Sorry, you do not have the right to add a category.'));
 
3059
                        return new IXR_Error(401, __('Sorry, you are not allowed to add a category.'));
3057
3060
 
3058
3061
                // If no slug was provided make it empty so that
3059
3062
                // WordPress will generate one.
3112
3115
         *     @type string $password
3113
3116
         *     @type int    $category_id
3114
3117
         * }
3115
 
         * @return bool|IXR_Error See {@link wp_delete_term()} for return info.
 
3118
         * @return bool|IXR_Error See wp_delete_term() for return info.
3116
3119
         */
3117
3120
        public function wp_deleteCategory( $args ) {
3118
3121
                $this->escape( $args );
3128
3131
                do_action( 'xmlrpc_call', 'wp.deleteCategory' );
3129
3132
 
3130
3133
                if ( !current_user_can('manage_categories') )
3131
 
                        return new IXR_Error( 401, __( 'Sorry, you do not have the right to delete a category.' ) );
 
3134
                        return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete a category.' ) );
3132
3135
 
3133
3136
                $status = wp_delete_term( $category_id, 'category' );
3134
3137
 
3226
3229
                }
3227
3230
 
3228
3231
                if ( ! current_user_can( 'edit_comment', $comment_id ) ) {
3229
 
                        return new IXR_Error( 403, __( 'You are not allowed to moderate or edit this comment.' ) );
 
3232
                        return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) );
3230
3233
                }
3231
3234
 
3232
3235
                return $this->_prepare_comment( $comment );
3244
3247
         * - 'status' - Default is ''. Filter by status (e.g., 'approve', 'hold')
3245
3248
         * - 'post_id' - Default is ''. The post where the comment is posted. Empty string shows all comments.
3246
3249
         * - 'number' - Default is 10. Total number of media items to retrieve.
3247
 
         * - 'offset' - Default is 0. See {@link WP_Query::query()} for more.
 
3250
         * - 'offset' - Default is 0. See WP_Query::query() for more.
3248
3251
         *
3249
3252
         * @since 2.7.0
3250
3253
         *
3256
3259
         *     @type string $password
3257
3260
         *     @type array  $struct
3258
3261
         * }
3259
 
         * @return array|IXR_Error Contains a collection of comments. See {@link wp_xmlrpc_server::wp_getComment()} for a description of each item contents
 
3262
         * @return array|IXR_Error Contains a collection of comments. See wp_xmlrpc_server::wp_getComment() for a description of each item contents
3260
3263
         */
3261
3264
        public function wp_getComments( $args ) {
3262
3265
                $this->escape( $args );
3328
3331
         * Delete a comment.
3329
3332
         *
3330
3333
         * By default, the comment will be moved to the trash instead of deleted.
3331
 
         * See {@link wp_delete_comment()} for more information on
3332
 
         * this behavior.
 
3334
         * See wp_delete_comment() for more information on this behavior.
3333
3335
         *
3334
3336
         * @since 2.7.0
3335
3337
         *
3341
3343
         *     @type string $password
3342
3344
         *     @type int    $comment_ID
3343
3345
         * }
3344
 
         * @return bool|IXR_Error {@link wp_delete_comment()}
 
3346
         * @return bool|IXR_Error See wp_delete_comment().
3345
3347
         */
3346
3348
        public function wp_deleteComment( $args ) {
3347
3349
                $this->escape($args);
3359
3361
                }
3360
3362
 
3361
3363
                if ( !current_user_can( 'edit_comment', $comment_ID ) ) {
3362
 
                        return new IXR_Error( 403, __( 'You are not allowed to moderate or edit this comment.' ) );
 
3364
                        return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) );
3363
3365
                }
3364
3366
 
3365
3367
                /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
3426
3428
                }
3427
3429
 
3428
3430
                if ( ! current_user_can( 'edit_comment', $comment_ID ) ) {
3429
 
                        return new IXR_Error( 403, __( 'You are not allowed to moderate or edit this comment.' ) );
 
3431
                        return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) );
3430
3432
                }
3431
3433
 
3432
3434
                /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
3498
3500
         *     @type string|int $post
3499
3501
         *     @type array      $content_struct
3500
3502
         * }
3501
 
         * @return int|IXR_Error {@link wp_new_comment()}
 
3503
         * @return int|IXR_Error See wp_new_comment().
3502
3504
         */
3503
3505
        public function wp_newComment($args) {
3504
3506
                $this->escape($args);
3509
3511
                $content_struct = $args[4];
3510
3512
 
3511
3513
                /**
3512
 
                 * Filter whether to allow anonymous comments over XML-RPC.
 
3514
                 * Filters whether to allow anonymous comments over XML-RPC.
3513
3515
                 *
3514
3516
                 * @since 2.7.0
3515
3517
                 *
3630
3632
                }
3631
3633
 
3632
3634
                if ( ! current_user_can( 'publish_posts' ) ) {
3633
 
                        return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) );
 
3635
                        return new IXR_Error( 403, __( 'Sorry, you are not allowed access to details about this site.' ) );
3634
3636
                }
3635
3637
 
3636
3638
                /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
3671
3673
                }
3672
3674
 
3673
3675
                if ( ! current_user_can( 'edit_post', $post_id ) ) {
3674
 
                        return new IXR_Error( 403, __( 'You are not allowed access to details of this post.' ) );
 
3676
                        return new IXR_Error( 403, __( 'Sorry, you are not allowed access to details of this post.' ) );
3675
3677
                }
3676
3678
 
3677
3679
                /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
3711
3713
                        return $this->error;
3712
3714
 
3713
3715
                if ( !current_user_can( 'edit_posts' ) )
3714
 
                        return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) );
 
3716
                        return new IXR_Error( 403, __( 'Sorry, you are not allowed access to details about this site.' ) );
3715
3717
 
3716
3718
                /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
3717
3719
                do_action( 'xmlrpc_call', 'wp.getPostStatusList' );
3743
3745
                        return $this->error;
3744
3746
 
3745
3747
                if ( !current_user_can( 'edit_pages' ) )
3746
 
                        return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) );
 
3748
                        return new IXR_Error( 403, __( 'Sorry, you are not allowed access to details about this site.' ) );
3747
3749
 
3748
3750
                /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
3749
3751
                do_action( 'xmlrpc_call', 'wp.getPageStatusList' );
3775
3777
                        return $this->error;
3776
3778
 
3777
3779
                if ( !current_user_can( 'edit_pages' ) )
3778
 
                        return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) );
 
3780
                        return new IXR_Error( 403, __( 'Sorry, you are not allowed access to details about this site.' ) );
3779
3781
 
3780
3782
                $templates = get_page_templates();
3781
3783
                $templates['Default'] = 'default';
3869
3871
                        return $this->error;
3870
3872
 
3871
3873
                if ( !current_user_can( 'manage_options' ) )
3872
 
                        return new IXR_Error( 403, __( 'You are not allowed to update options.' ) );
 
3874
                        return new IXR_Error( 403, __( 'Sorry, you are not allowed to update options.' ) );
3873
3875
 
3874
3876
                $option_names = array();
3875
3877
                foreach ( $options as $o_name => $o_value ) {
3921
3923
                        return $this->error;
3922
3924
 
3923
3925
                if ( !current_user_can( 'upload_files' ) )
3924
 
                        return new IXR_Error( 403, __( 'You do not have permission to upload files.' ) );
 
3926
                        return new IXR_Error( 403, __( 'Sorry, you are not allowed to upload files.' ) );
3925
3927
 
3926
3928
                /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
3927
3929
                do_action( 'xmlrpc_call', 'wp.getMediaItem' );
3969
3971
                        return $this->error;
3970
3972
 
3971
3973
                if ( !current_user_can( 'upload_files' ) )
3972
 
                        return new IXR_Error( 401, __( 'You do not have permission to upload files.' ) );
 
3974
                        return new IXR_Error( 401, __( 'Sorry, you are not allowed to upload files.' ) );
3973
3975
 
3974
3976
                /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
3975
3977
                do_action( 'xmlrpc_call', 'wp.getMediaLibrary' );
4013
4015
                        return $this->error;
4014
4016
 
4015
4017
                if ( !current_user_can( 'edit_posts' ) )
4016
 
                        return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) );
 
4018
                        return new IXR_Error( 403, __( 'Sorry, you are not allowed access to details about this site.' ) );
4017
4019
 
4018
4020
                /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
4019
4021
                do_action( 'xmlrpc_call', 'wp.getPostFormats' );
4079
4081
                        $fields = $args[4];
4080
4082
                } else {
4081
4083
                        /**
4082
 
                         * Filter the default query fields used by the given XML-RPC method.
 
4084
                         * Filters the default query fields used by the given XML-RPC method.
4083
4085
                         *
4084
4086
                         * @since 3.4.0
4085
4087
                         *
4096
4098
                do_action( 'xmlrpc_call', 'wp.getPostType' );
4097
4099
 
4098
4100
                if ( ! post_type_exists( $post_type_name ) )
4099
 
                        return new IXR_Error( 403, __( 'Invalid post type' ) );
 
4101
                        return new IXR_Error( 403, __( 'Invalid post type.' ) );
4100
4102
 
4101
4103
                $post_type = get_post_type_object( $post_type_name );
4102
4104
 
4197
4199
                        $fields = $args[4];
4198
4200
                } else {
4199
4201
                        /**
4200
 
                         * Filter the default revision query fields used by the given XML-RPC method.
 
4202
                         * Filters the default revision query fields used by the given XML-RPC method.
4201
4203
                         *
4202
4204
                         * @since 3.5.0
4203
4205
                         *
4287
4289
                        return new IXR_Error( 404, __( 'Invalid post ID.' ) );
4288
4290
 
4289
4291
                if ( ! current_user_can( 'edit_post', $revision->post_parent ) )
4290
 
                        return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) );
 
4292
                        return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
4291
4293
 
4292
4294
                // Check if revisions are disabled.
4293
4295
                if ( ! wp_revisions_enabled( $post ) )
4299
4301
        }
4300
4302
 
4301
4303
        /* Blogger API functions.
4302
 
         * specs on http://plant.blogger.com/api and http://groups.yahoo.com/group/bloggerDev/
 
4304
         * specs on http://plant.blogger.com/api and https://groups.yahoo.com/group/bloggerDev/
4303
4305
         */
4304
4306
 
4305
4307
        /**
4410
4412
                        return $this->error;
4411
4413
 
4412
4414
                if ( !current_user_can( 'edit_posts' ) )
4413
 
                        return new IXR_Error( 401, __( 'Sorry, you do not have access to user data on this site.' ) );
 
4415
                        return new IXR_Error( 401, __( 'Sorry, you are not allowed to access user data on this site.' ) );
4414
4416
 
4415
4417
                /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
4416
4418
                do_action( 'xmlrpc_call', 'blogger.getUserInfo' );
4456
4458
                        return new IXR_Error( 404, __( 'Invalid post ID.' ) );
4457
4459
 
4458
4460
                if ( !current_user_can( 'edit_post', $post_ID ) )
4459
 
                        return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) );
 
4461
                        return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
4460
4462
 
4461
4463
                /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
4462
4464
                do_action( 'xmlrpc_call', 'blogger.getPost' );
4509
4511
                        return $this->error;
4510
4512
 
4511
4513
                if ( ! current_user_can( 'edit_posts' ) )
4512
 
                        return new IXR_Error( 401, __( 'Sorry, you cannot edit posts on this site.' ) );
 
4514
                        return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) );
4513
4515
 
4514
4516
                /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
4515
4517
                do_action( 'xmlrpc_call', 'blogger.getRecentPosts' );
4683
4685
                $this->escape($actual_post);
4684
4686
 
4685
4687
                if ( ! current_user_can( 'edit_post', $post_ID ) ) {
4686
 
                        return new IXR_Error(401, __('Sorry, you do not have the right to edit this post.'));
 
4688
                        return new IXR_Error(401, __('Sorry, you are not allowed to edit this post.'));
4687
4689
                }
4688
4690
                if ( 'publish' == $actual_post['post_status'] && ! current_user_can( 'publish_posts' ) ) {
4689
 
                        return new IXR_Error( 401, __( 'Sorry, you do not have the right to publish this post.' ) );
 
4691
                        return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish this post.' ) );
4690
4692
                }
4691
4693
 
4692
4694
                $postdata = array();
4753
4755
                }
4754
4756
 
4755
4757
                if ( ! current_user_can( 'delete_post', $post_ID ) ) {
4756
 
                        return new IXR_Error( 401, __( 'Sorry, you do not have the right to delete this post.' ) );
 
4758
                        return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) );
4757
4759
                }
4758
4760
 
4759
4761
                $result = wp_delete_post( $post_ID );
4855
4857
                                $post_type = 'post';
4856
4858
                        } else {
4857
4859
                                // No other post_type values are allowed here
4858
 
                                return new IXR_Error( 401, __( 'Invalid post type' ) );
 
4860
                                return new IXR_Error( 401, __( 'Invalid post type.' ) );
4859
4861
                        }
4860
4862
                } else {
4861
4863
                        if ( $publish )
4906
4908
                        switch ( $post_type ) {
4907
4909
                                case "post":
4908
4910
                                        if ( !current_user_can( 'edit_others_posts' ) )
4909
 
                                                return new IXR_Error( 401, __( 'You are not allowed to create posts as this user.' ) );
 
4911
                                                return new IXR_Error( 401, __( 'Sorry, you are not allowed to create posts as this user.' ) );
4910
4912
                                        break;
4911
4913
                                case "page":
4912
4914
                                        if ( !current_user_can( 'edit_others_pages' ) )
4913
 
                                                return new IXR_Error( 401, __( 'You are not allowed to create pages as this user.' ) );
 
4915
                                                return new IXR_Error( 401, __( 'Sorry, you are not allowed to create pages as this user.' ) );
4914
4916
                                        break;
4915
4917
                                default:
4916
 
                                        return new IXR_Error( 401, __( 'Invalid post type' ) );
 
4918
                                        return new IXR_Error( 401, __( 'Invalid post type.' ) );
4917
4919
                        }
4918
4920
                        $author = get_userdata( $content_struct['wp_author_id'] );
4919
4921
                        if ( ! $author )
5187
5189
                        return new IXR_Error( 404, __( 'Invalid post ID.' ) );
5188
5190
 
5189
5191
                if ( ! current_user_can( 'edit_post', $post_ID ) )
5190
 
                        return new IXR_Error( 401, __( 'Sorry, you do not have the right to edit this post.' ) );
 
5192
                        return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
5191
5193
 
5192
5194
                // Use wp.editPost to edit post types other than post and page.
5193
5195
                if ( ! in_array( $postdata[ 'post_type' ], array( 'post', 'page' ) ) )
5194
 
                        return new IXR_Error( 401, __( 'Invalid post type' ) );
 
5196
                        return new IXR_Error( 401, __( 'Invalid post type.' ) );
5195
5197
 
5196
5198
                // Thwart attempt to change the post type.
5197
5199
                if ( ! empty( $content_struct[ 'post_type' ] ) && ( $content_struct['post_type'] != $postdata[ 'post_type' ] ) )
5246
5248
                                switch ( $post_type ) {
5247
5249
                                        case 'post':
5248
5250
                                                if ( ! current_user_can( 'edit_others_posts' ) ) {
5249
 
                                                        return new IXR_Error( 401, __( 'You are not allowed to change the post author as this user.' ) );
 
5251
                                                        return new IXR_Error( 401, __( 'Sorry, you are not allowed to change the post author as this user.' ) );
5250
5252
                                                }
5251
5253
                                                break;
5252
5254
                                        case 'page':
5253
5255
                                                if ( ! current_user_can( 'edit_others_pages' ) ) {
5254
 
                                                        return new IXR_Error( 401, __( 'You are not allowed to change the page author as this user.' ) );
 
5256
                                                        return new IXR_Error( 401, __( 'Sorry, you are not allowed to change the page author as this user.' ) );
5255
5257
                                                }
5256
5258
                                                break;
5257
5259
                                        default:
5258
 
                                                return new IXR_Error( 401, __( 'Invalid post type' ) );
 
5260
                                                return new IXR_Error( 401, __( 'Invalid post type.' ) );
5259
5261
                                }
5260
5262
                                $post_author = $content_struct['wp_author_id'];
5261
5263
                        }
5358
5360
 
5359
5361
                if ( 'publish' == $post_status || 'private' == $post_status ) {
5360
5362
                        if ( 'page' == $post_type && ! current_user_can( 'publish_pages' ) ) {
5361
 
                                return new IXR_Error( 401, __( 'Sorry, you do not have the right to publish this page.' ) );
 
5363
                                return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish this page.' ) );
5362
5364
                        } elseif ( ! current_user_can( 'publish_posts' ) ) {
5363
 
                                return new IXR_Error( 401, __( 'Sorry, you do not have the right to publish this post.' ) );
 
5365
                                return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish this post.' ) );
5364
5366
                        }
5365
5367
                }
5366
5368
 
5484
5486
                        return new IXR_Error( 404, __( 'Invalid post ID.' ) );
5485
5487
 
5486
5488
                if ( !current_user_can( 'edit_post', $post_ID ) )
5487
 
                        return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) );
 
5489
                        return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
5488
5490
 
5489
5491
                /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
5490
5492
                do_action( 'xmlrpc_call', 'metaWeblog.getPost' );
5614
5616
                        return $this->error;
5615
5617
 
5616
5618
                if ( ! current_user_can( 'edit_posts' ) )
5617
 
                        return new IXR_Error( 401, __( 'Sorry, you cannot edit posts on this site.' ) );
 
5619
                        return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) );
5618
5620
 
5619
5621
                /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
5620
5622
                do_action( 'xmlrpc_call', 'metaWeblog.getRecentPosts' );
5791
5793
                do_action( 'xmlrpc_call', 'metaWeblog.newMediaObject' );
5792
5794
 
5793
5795
                if ( !current_user_can('upload_files') ) {
5794
 
                        $this->error = new IXR_Error( 401, __( 'You do not have permission to upload files.' ) );
 
5796
                        $this->error = new IXR_Error( 401, __( 'Sorry, you are not allowed to upload files.' ) );
5795
5797
                        return $this->error;
5796
5798
                }
5797
5799
 
5801
5803
                }
5802
5804
 
5803
5805
                /**
5804
 
                 * Filter whether to preempt the XML-RPC media upload.
 
5806
                 * Filters whether to preempt the XML-RPC media upload.
5805
5807
                 *
5806
5808
                 * Passing a truthy value will effectively short-circuit the media upload,
5807
5809
                 * returning that value as a 500 error instead.
5825
5827
                        $post_id = (int) $data['post_id'];
5826
5828
 
5827
5829
                        if ( ! current_user_can( 'edit_post', $post_id ) )
5828
 
                                return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) );
 
5830
                                return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
5829
5831
                }
5830
5832
                $attachment = array(
5831
5833
                        'post_title' => $name,
5996
5998
                        return new IXR_Error( 404, __( 'Invalid post ID.' ) );
5997
5999
 
5998
6000
                if ( !current_user_can( 'edit_post', $post_ID ) )
5999
 
                        return new IXR_Error( 401, __( 'Sorry, you can not edit this post.' ) );
 
6001
                        return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
6000
6002
 
6001
6003
                /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
6002
6004
                do_action( 'xmlrpc_call', 'mt.getPostCategories' );
6050
6052
                        return new IXR_Error( 404, __( 'Invalid post ID.' ) );
6051
6053
 
6052
6054
                if ( !current_user_can('edit_post', $post_ID) )
6053
 
                        return new IXR_Error(401, __('Sorry, you cannot edit this post.'));
 
6055
                        return new IXR_Error(401, __('Sorry, you are not allowed to edit this post.'));
6054
6056
 
6055
6057
                $catids = array();
6056
6058
                foreach ( $categories as $cat ) {
6086
6088
                do_action( 'xmlrpc_call', 'mt.supportedTextFilters' );
6087
6089
 
6088
6090
                /**
6089
 
                 * Filter the MoveableType text filters list for XML-RPC.
 
6091
                 * Filters the MoveableType text filters list for XML-RPC.
6090
6092
                 *
6091
6093
                 * @since 2.2.0
6092
6094
                 *
6169
6171
                        return new IXR_Error( 404, __( 'Invalid post ID.' ) );
6170
6172
 
6171
6173
                if ( !current_user_can('publish_posts') || !current_user_can('edit_post', $post_ID) )
6172
 
                        return new IXR_Error(401, __('Sorry, you cannot publish this post.'));
 
6174
                        return new IXR_Error(401, __('Sorry, you are not allowed to publish this post.'));
6173
6175
 
6174
6176
                $postdata['post_status'] = 'publish';
6175
6177
 
6214
6216
                $pagelinkedto = str_replace( '&', '&', $pagelinkedto );
6215
6217
 
6216
6218
                /**
6217
 
                 * Filter the pingback source URI.
 
6219
                 * Filters the pingback source URI.
6218
6220
                 *
6219
6221
                 * @since 3.6.0
6220
6222
                 *
6311
6313
                }
6312
6314
 
6313
6315
                /**
6314
 
                 * Filter the pingback remote source.
 
6316
                 * Filters the pingback remote source.
6315
6317
                 *
6316
6318
                 * @since 2.5.0
6317
6319
                 *
6457
6459
         */
6458
6460
        protected function pingback_error( $code, $message ) {
6459
6461
                /**
6460
 
                 * Filter the XML-RPC pingback error return.
 
6462
                 * Filters the XML-RPC pingback error return.
6461
6463
                 *
6462
6464
                 * @since 3.5.1
6463
6465
                 *