Make WordPress Core

Ticket #28014: class-wp-xmlrpc-server.php.28014.2.diff

File class-wp-xmlrpc-server.php.28014.2.diff, 50.6 KB (added by rtvenge, 13 years ago)

Adding switch_to_blog() fix on ALL functions in XML-RPC, not just addPost.

  • src/wp-includes/class-wp-xmlrpc-server.php

    diff --git src/wp-includes/class-wp-xmlrpc-server.php src/wp-includes/class-wp-xmlrpc-server.php
    index 0f617db..c2c5450 100644
     
    33 * XML-RPC protocol support for WordPress
    44 *
    55 * @package WordPress
    6  * @subpackage Publishing
    76 */
    87
    98/**
    … … class wp_xmlrpc_server extends IXR_Server {  
    127126                );
    128127
    129128                $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);
    141130        }
    142131
    143132        function serve_request() {
    … … class wp_xmlrpc_server extends IXR_Server {  
    180169         * @return mixed WP_User object if authentication passed, false otherwise
    181170         */
    182171        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
    191176
    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.
    201178                $enabled = apply_filters( 'xmlrpc_enabled', $enabled );
    202179
    203180                if ( ! $enabled ) {
    … … class wp_xmlrpc_server extends IXR_Server {  
    209186
    210187                if (is_wp_error($user)) {
    211188                        $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                          */
    221189                        $this->error = apply_filters( 'xmlrpc_login_error', $this->error, $user );
    222190                        return false;
    223191                }
    … … class wp_xmlrpc_server extends IXR_Server {  
    472440                        )
    473441                );
    474442
    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                  */
    482443                $this->blog_options = apply_filters( 'xmlrpc_blog_options', $this->blog_options );
    483444        }
    484445
    … … class wp_xmlrpc_server extends IXR_Server {  
    512473                if ( !$user = $this->login($username, $password) )
    513474                        return $this->error;
    514475
    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                  */
    526476                do_action( 'xmlrpc_call', 'wp.getUsersBlogs' );
    527477
    528478                $blogs = (array) get_blogs_of_user( $user->ID );
    … … class wp_xmlrpc_server extends IXR_Server {  
    602552                if ( in_array( 'object_type', $fields ) )
    603553                        $_taxonomy['object_type'] = array_unique( (array) $taxonomy->object_type );
    604554
    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                  */
    614555                return apply_filters( 'xmlrpc_prepare_taxonomy', $_taxonomy, $taxonomy, $fields );
    615556        }
    616557
    … … class wp_xmlrpc_server extends IXR_Server {  
    636577                // Count we are happy to return as an integer because people really shouldn't use terms that much.
    637578                $_term['count'] = intval( $_term['count'] );
    638579
    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                  */
    647580                return apply_filters( 'xmlrpc_prepare_term', $_term, $term );
    648581        }
    649582
    … … class wp_xmlrpc_server extends IXR_Server {  
    765698                        }
    766699                }
    767700
    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                  */
    777701                return apply_filters( 'xmlrpc_prepare_post', $_post, $post, $fields );
    778702        }
    779703
    … … class wp_xmlrpc_server extends IXR_Server {  
    816740                if ( in_array( 'taxonomies', $fields ) )
    817741                        $_post_type['taxonomies'] = get_object_taxonomies( $post_type->name, 'names' );
    818742
    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                  */
    827743                return apply_filters( 'xmlrpc_prepare_post_type', $_post_type, $post_type );
    828744        }
    829745
    … … class wp_xmlrpc_server extends IXR_Server {  
    854770                else
    855771                        $_media_item['thumbnail'] = $_media_item['link'];
    856772
    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                  */
    866773                return apply_filters( 'xmlrpc_prepare_media_item', $_media_item, $media_item, $thumbnail_size );
    867774        }
    868775
    … … class wp_xmlrpc_server extends IXR_Server {  
    934841                        'wp_page_template'       => $page_template
    935842                );
    936843
    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                  */
    945844                return apply_filters( 'xmlrpc_prepare_page', $_page, $page );
    946845        }
    947846
    … … class wp_xmlrpc_server extends IXR_Server {  
    984883                        'type'             => $comment->comment_type,
    985884                );
    986885
    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                  */
    995886                return apply_filters( 'xmlrpc_prepare_comment', $_comment, $comment );
    996887        }
    997888
    … … class wp_xmlrpc_server extends IXR_Server {  
    1032923                        $_user = array_merge( $_user, $requested_fields );
    1033924                }
    1034925
    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                  */
    1044926                return apply_filters( 'xmlrpc_prepare_user', $_user, $user, $fields );
    1045927        }
    1046928
    … … class wp_xmlrpc_server extends IXR_Server {  
    1086968                $password       = $args[2];
    1087969                $content_struct = $args[3];
    1088970
     971                switch_to_blog($blog_id);
     972
    1089973                if ( ! $user = $this->login( $username, $password ) )
    1090974                        return $this->error;
    1091975
    1092                 /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    1093976                do_action( 'xmlrpc_call', 'wp.newPost' );
    1094977
    1095978                unset( $content_struct['ID'] );
    … … class wp_xmlrpc_server extends IXR_Server {  
    12491132                                                return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign a term to one of the given taxonomies.' ) );
    12501133
    12511134                                        $term_ids = $post_data['terms'][$taxonomy];
    1252                                         $terms[ $taxonomy ] = array();
    12531135                                        foreach ( $term_ids as $term_id ) {
    12541136                                                $term = get_term_by( 'id', $term_id, $taxonomy );
    12551137
    … … class wp_xmlrpc_server extends IXR_Server {  
    13331215
    13341216                $this->attach_uploads( $post_ID, $post_data['post_content'] );
    13351217
    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                  */
    13441218                $post_data = apply_filters( 'xmlrpc_wp_insert_post_data', $post_data, $content_struct );
    13451219
    13461220                $post_ID = $update ? wp_update_post( $post_data, true ) : wp_insert_post( $post_data, true );
    … … class wp_xmlrpc_server extends IXR_Server {  
    13811255                $post_id        = (int) $args[3];
    13821256                $content_struct = $args[4];
    13831257
     1258                switch_to_blog($blog_id);
     1259
    13841260                if ( ! $user = $this->login( $username, $password ) )
    13851261                        return $this->error;
    13861262
    1387                 /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    13881263                do_action( 'xmlrpc_call', 'wp.editPost' );
    13891264
    13901265                $post = get_post( $post_id, ARRAY_A );
    … … class wp_xmlrpc_server extends IXR_Server {  
    14431318                $password   = $args[2];
    14441319                $post_id    = (int) $args[3];
    14451320
     1321                switch_to_blog($blog_id);
     1322
    14461323                if ( ! $user = $this->login( $username, $password ) )
    14471324                        return $this->error;
    14481325
    1449                 /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    14501326                do_action( 'xmlrpc_call', 'wp.deletePost' );
    14511327
    14521328                $post = get_post( $post_id, ARRAY_A );
    … … class wp_xmlrpc_server extends IXR_Server {  
    15191395                $password           = $args[2];
    15201396                $post_id            = (int) $args[3];
    15211397
    1522                 if ( isset( $args[4] ) ) {
     1398                switch_to_blog($blog_id);
     1399
     1400                if ( isset( $args[4] ) )
    15231401                        $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
    15331403                        $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPost' );
    1534                 }
    15351404
    15361405                if ( ! $user = $this->login( $username, $password ) )
    15371406                        return $this->error;
    15381407
    1539                 /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    15401408                do_action( 'xmlrpc_call', 'wp.getPost' );
    15411409
    15421410                $post = get_post( $post_id, ARRAY_A );
    … … class wp_xmlrpc_server extends IXR_Server {  
    15851453                $password   = $args[2];
    15861454                $filter     = isset( $args[3] ) ? $args[3] : array();
    15871455
    1588                 if ( isset( $args[4] ) ) {
     1456                switch_to_blog($blog_id);
     1457
     1458                if ( isset( $args[4] ) )
    15891459                        $fields = $args[4];
    1590                 } else {
    1591                         /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
     1460                else
    15921461                        $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPosts' );
    1593                 }
    15941462
    15951463                if ( ! $user = $this->login( $username, $password ) )
    15961464                        return $this->error;
    15971465
    1598                 /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    15991466                do_action( 'xmlrpc_call', 'wp.getPosts' );
    16001467
    16011468                $query = array();
    … … class wp_xmlrpc_server extends IXR_Server {  
    16851552                if ( ! $user = $this->login( $username, $password ) )
    16861553                        return $this->error;
    16871554
    1688                 /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    16891555                do_action( 'xmlrpc_call', 'wp.newTerm' );
    16901556
    16911557                if ( ! taxonomy_exists( $content_struct['taxonomy'] ) )
    … … class wp_xmlrpc_server extends IXR_Server {  
    17741640                if ( ! $user = $this->login( $username, $password ) )
    17751641                        return $this->error;
    17761642
    1777                 /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    17781643                do_action( 'xmlrpc_call', 'wp.editTerm' );
    17791644
    17801645                if ( ! taxonomy_exists( $content_struct['taxonomy'] ) )
    … … class wp_xmlrpc_server extends IXR_Server {  
    18671732                if ( ! $user = $this->login( $username, $password ) )
    18681733                        return $this->error;
    18691734
    1870                 /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    18711735                do_action( 'xmlrpc_call', 'wp.deleteTerm' );
    18721736
    18731737                if ( ! taxonomy_exists( $taxonomy ) )
    … … class wp_xmlrpc_server extends IXR_Server {  
    19351799                if ( ! $user = $this->login( $username, $password ) )
    19361800                        return $this->error;
    19371801
    1938                 /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    19391802                do_action( 'xmlrpc_call', 'wp.getTerm' );
    19401803
    19411804                if ( ! taxonomy_exists( $taxonomy ) )
    … … class wp_xmlrpc_server extends IXR_Server {  
    19891852                if ( ! $user = $this->login( $username, $password ) )
    19901853                        return $this->error;
    19911854
    1992                 /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    19931855                do_action( 'xmlrpc_call', 'wp.getTerms' );
    19941856
    19951857                if ( ! taxonomy_exists( $taxonomy ) )
    … … class wp_xmlrpc_server extends IXR_Server {  
    20611923                $password       = $args[2];
    20621924                $taxonomy       = $args[3];
    20631925
    2064                 if ( isset( $args[4] ) ) {
     1926                if ( isset( $args[4] ) )
    20651927                        $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
    20751929                        $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomy' );
    2076                 }
    20771930
    20781931                if ( ! $user = $this->login( $username, $password ) )
    20791932                        return $this->error;
    20801933
    2081                 /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    20821934                do_action( 'xmlrpc_call', 'wp.getTaxonomy' );
    20831935
    20841936                if ( ! taxonomy_exists( $taxonomy ) )
    … … class wp_xmlrpc_server extends IXR_Server {  
    21151967                $password           = $args[2];
    21161968                $filter             = isset( $args[3] ) ? $args[3] : array( 'public' => true );
    21171969
    2118                 if ( isset( $args[4] ) ) {
     1970                if ( isset( $args[4] ) )
    21191971                        $fields = $args[4];
    2120                 } else {
    2121                         /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
     1972                else
    21221973                        $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomies' );
    2123                 }
    21241974
    21251975                if ( ! $user = $this->login( $username, $password ) )
    21261976                        return $this->error;
    21271977
    2128                 /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    21291978                do_action( 'xmlrpc_call', 'wp.getTaxonomies' );
    21301979
    21311980                $taxonomies = get_taxonomies( $filter, 'objects' );
    … … class wp_xmlrpc_server extends IXR_Server {  
    21872036                $password   = $args[2];
    21882037                $user_id    = (int) $args[3];
    21892038
    2190                 if ( isset( $args[4] ) ) {
     2039                if ( isset( $args[4] ) )
    21912040                        $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
    22012042                        $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUser' );
    2202                 }
    22032043
    22042044                if ( ! $user = $this->login( $username, $password ) )
    22052045                        return $this->error;
    22062046
    2207                 /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    22082047                do_action( 'xmlrpc_call', 'wp.getUser' );
    22092048
    22102049                if ( ! current_user_can( 'edit_user', $user_id ) )
    … … class wp_xmlrpc_server extends IXR_Server {  
    22502089                $password   = $args[2];
    22512090                $filter     = isset( $args[3] ) ? $args[3] : array();
    22522091
    2253                 if ( isset( $args[4] ) ) {
     2092                if ( isset( $args[4] ) )
    22542093                        $fields = $args[4];
    2255                 } else {
    2256                         /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
     2094                else
    22572095                        $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUsers' );
    2258                 }
    22592096
    22602097                if ( ! $user = $this->login( $username, $password ) )
    22612098                        return $this->error;
    22622099
    2263                 /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    22642100                do_action( 'xmlrpc_call', 'wp.getUsers' );
    22652101
    22662102                if ( ! current_user_can( 'list_users' ) )
    … … class wp_xmlrpc_server extends IXR_Server {  
    23202156                $username   = $args[1];
    23212157                $password   = $args[2];
    23222158
    2323                 if ( isset( $args[3] ) ) {
     2159                if ( isset( $args[3] ) )
    23242160                        $fields = $args[3];
    2325                 } else {
    2326                         /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
     2161                else
    23272162                        $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getProfile' );
    2328                 }
    23292163
    23302164                if ( ! $user = $this->login( $username, $password ) )
    23312165                        return $this->error;
    23322166
    2333                 /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    23342167                do_action( 'xmlrpc_call', 'wp.getProfile' );
    23352168
    23362169                if ( ! current_user_can( 'edit_user', $user->ID ) )
    … … class wp_xmlrpc_server extends IXR_Server {  
    23742207                if ( ! $user = $this->login( $username, $password ) )
    23752208                        return $this->error;
    23762209
    2377                 /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    23782210                do_action( 'xmlrpc_call', 'wp.editProfile' );
    23792211
    23802212                if ( ! current_user_can( 'edit_user', $user->ID ) )
    … … class wp_xmlrpc_server extends IXR_Server {  
    24482280                if ( !current_user_can( 'edit_page', $page_id ) )
    24492281                        return new IXR_Error( 401, __( 'Sorry, you cannot edit this page.' ) );
    24502282
    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');
    24532284
    24542285                // If we found the page then format the data.
    24552286                if ( $page->ID && ($page->post_type == 'page') ) {
    … … class wp_xmlrpc_server extends IXR_Server {  
    24872318                if ( !current_user_can( 'edit_pages' ) )
    24882319                        return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) );
    24892320
    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');
    24922322
    24932323                $pages = get_posts( array('post_type' => 'page', 'post_status' => 'any', 'numberposts' => $num_pages) );
    24942324                $num_pages = count($pages);
    … … class wp_xmlrpc_server extends IXR_Server {  
    25282358                if ( !$user = $this->login($username, $password) )
    25292359                        return $this->error;
    25302360
    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');
    25332362
    25342363                // Mark this as content for a page.
    25352364                $args[3]["post_type"] = 'page';
    … … class wp_xmlrpc_server extends IXR_Server {  
    25572386                if ( !$user = $this->login($username, $password) )
    25582387                        return $this->error;
    25592388
    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');
    25622390
    25632391                // Get the current page based on the page_id and
    25642392                // make sure it is a page and not a post.
    … … class wp_xmlrpc_server extends IXR_Server {  
    25752403                if ( !$result )
    25762404                        return(new IXR_Error(500, __('Failed to delete the page.')));
    25772405
    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                  */
    25862406                do_action( 'xmlrpc_call_success_wp_deletePage', $page_id, $args );
    25872407
    25882408                return(true);
    … … class wp_xmlrpc_server extends IXR_Server {  
    26082428                if ( !$user = $this->login($username, $password) )
    26092429                        return $this->error;
    26102430
    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');
    26132432
    26142433                // Get the page data and make sure it is a page.
    26152434                $actual_page = get_post($page_id, ARRAY_A);
    … … class wp_xmlrpc_server extends IXR_Server {  
    26592478                if ( !current_user_can( 'edit_pages' ) )
    26602479                        return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) );
    26612480
    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');
    26642482
    26652483                // Get list of pages ids and titles
    26662484                $page_list = $wpdb->get_results("
    … … class wp_xmlrpc_server extends IXR_Server {  
    27112529                if ( !current_user_can('edit_posts') )
    27122530                        return(new IXR_Error(401, __('Sorry, you cannot edit posts on this site.')));
    27132531
    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');
    27162533
    27172534                $authors = array();
    27182535                foreach ( get_users( array( 'fields' => array('ID','user_login','display_name') ) ) as $user ) {
    … … class wp_xmlrpc_server extends IXR_Server {  
    27472564                if ( !current_user_can( 'edit_posts' ) )
    27482565                        return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view tags.' ) );
    27492566
    2750                 /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    27512567                do_action( 'xmlrpc_call', 'wp.getKeywords' );
    27522568
    27532569                $tags = array();
    … … class wp_xmlrpc_server extends IXR_Server {  
    27872603                if ( !$user = $this->login($username, $password) )
    27882604                        return $this->error;
    27892605
    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');
    27922607
    27932608                // Make sure the user is allowed to add a category.
    27942609                if ( !current_user_can('manage_categories') )
    … … class wp_xmlrpc_server extends IXR_Server {  
    28252640                        return(new IXR_Error(500, __('Sorry, the new category failed.')));
    28262641                }
    28272642
    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                  */
    28362643                do_action( 'xmlrpc_call_success_wp_newCategory', $cat_id, $args );
    28372644
    28382645                return $cat_id;
    … … class wp_xmlrpc_server extends IXR_Server {  
    28572664                if ( !$user = $this->login($username, $password) )
    28582665                        return $this->error;
    28592666
    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');
    28622668
    28632669                if ( !current_user_can('manage_categories') )
    28642670                        return new IXR_Error( 401, __( 'Sorry, you do not have the right to delete a category.' ) );
    28652671
    28662672                $status = wp_delete_term( $category_id, 'category' );
    28672673
    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 )
    28772675                        do_action( 'xmlrpc_call_success_wp_deleteCategory', $category_id, $args );
    2878                 }
    28792676
    28802677                return $status;
    28812678        }
    … … class wp_xmlrpc_server extends IXR_Server {  
    29032700                if ( !current_user_can( 'edit_posts' ) )
    29042701                        return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts to this site in order to view categories.' ) );
    29052702
    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');
    29082704
    29092705                $category_suggestions = array();
    29102706                $args = array('get' => 'all', 'number' => $max_results, 'name__like' => $category);
    … … class wp_xmlrpc_server extends IXR_Server {  
    29402736                if ( !current_user_can( 'moderate_comments' ) )
    29412737                        return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) );
    29422738
    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');
    29452740
    29462741                if ( ! $comment = get_comment($comment_id) )
    29472742                        return new IXR_Error( 404, __( 'Invalid comment ID.' ) );
    … … class wp_xmlrpc_server extends IXR_Server {  
    29822777                if ( !current_user_can( 'moderate_comments' ) )
    29832778                        return new IXR_Error( 401, __( 'Sorry, you cannot edit comments.' ) );
    29842779
    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');
    29872781
    29882782                if ( isset($struct['status']) )
    29892783                        $status = $struct['status'];
    … … class wp_xmlrpc_server extends IXR_Server {  
    30492843                if ( !current_user_can( 'edit_comment', $comment_ID ) )
    30502844                        return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) );
    30512845
    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');
    30542847
    30552848                $status = wp_delete_comment( $comment_ID );
    30562849
    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 )
    30662851                        do_action( 'xmlrpc_call_success_wp_deleteComment', $comment_ID, $args );
    3067                 }
    30682852
    30692853                return $status;
    30702854        }
    … … class wp_xmlrpc_server extends IXR_Server {  
    31142898                if ( !current_user_can( 'edit_comment', $comment_ID ) )
    31152899                        return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) );
    31162900
    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');
    31192902
    31202903                if ( isset($content_struct['status']) ) {
    31212904                        $statuses = get_comment_statuses();
    … … class wp_xmlrpc_server extends IXR_Server {  
    31562939                if ( !$result )
    31572940                        return new IXR_Error(500, __('Sorry, the comment could not be edited. Something wrong happened.'));
    31582941
    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                  */
    31672942                do_action( 'xmlrpc_call_success_wp_editComment', $comment_ID, $args );
    31682943
    31692944                return true;
    … … class wp_xmlrpc_server extends IXR_Server {  
    31882963                $post           = $args[3];
    31892964                $content_struct = $args[4];
    31902965
    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);
    32002967
    32012968                $user = $this->login($username, $password);
    32022969
    … … class wp_xmlrpc_server extends IXR_Server {  
    32553022
    32563023                $comment['comment_content'] =  isset($content_struct['content']) ? $content_struct['content'] : null;
    32573024
    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');
    32603026
    32613027                $comment_ID = wp_new_comment( $comment );
    32623028
    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                  */
    32713029                do_action( 'xmlrpc_call_success_wp_newComment', $comment_ID, $args );
    32723030
    32733031                return $comment_ID;
    … … class wp_xmlrpc_server extends IXR_Server {  
    32943052                if ( !current_user_can( 'moderate_comments' ) )
    32953053                        return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) );
    32963054
    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');
    32993056
    33003057                return get_comment_statuses();
    33013058        }
    … … class wp_xmlrpc_server extends IXR_Server {  
    33223079                if ( !current_user_can( 'edit_posts' ) )
    33233080                        return new IXR_Error( 403, __( 'You are not allowed access to details about comments.' ) );
    33243081
    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');
    33273083
    33283084                $count = wp_count_comments( $post_id );
    33293085                return array(
    … … class wp_xmlrpc_server extends IXR_Server {  
    33493105                $username       = $args[1];
    33503106                $password       = $args[2];
    33513107
     3108                switch_to_blog($blog_id);
     3109
    33523110                if ( !$user = $this->login($username, $password) )
    33533111                        return $this->error;
    33543112
    33553113                if ( !current_user_can( 'edit_posts' ) )
    33563114                        return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) );
    33573115
    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');
    33603117
    33613118                return get_post_statuses();
    33623119        }
    … … class wp_xmlrpc_server extends IXR_Server {  
    33823139                if ( !current_user_can( 'edit_pages' ) )
    33833140                        return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) );
    33843141
    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');
    33873143
    33883144                return get_page_statuses();
    33893145        }
    … … class wp_xmlrpc_server extends IXR_Server {  
    34993255                        if ( $this->blog_options[$o_name]['readonly'] == true )
    35003256                                continue;
    35013257
    3502                         update_option( $this->blog_options[$o_name]['option'], wp_unslash( $o_value ) );
     3258                        update_option( $this->blog_options[$o_name]['option'], $o_value );
    35033259                }
    35043260
    35053261                //Now return the updated values
    … … class wp_xmlrpc_server extends IXR_Server {  
    35403296                if ( !current_user_can( 'upload_files' ) )
    35413297                        return new IXR_Error( 403, __( 'You do not have permission to upload files.' ) );
    35423298
    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');
    35453300
    35463301                if ( ! $attachment = get_post($attachment_id) )
    35473302                        return new IXR_Error( 404, __( 'Invalid attachment ID.' ) );
    … … class wp_xmlrpc_server extends IXR_Server {  
    35863341                if ( !current_user_can( 'upload_files' ) )
    35873342                        return new IXR_Error( 401, __( 'You do not have permission to upload files.' ) );
    35883343
    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');
    35913345
    35923346                $parent_id = ( isset($struct['parent_id']) ) ? absint($struct['parent_id']) : '' ;
    35933347                $mime_type = ( isset($struct['mime_type']) ) ? $struct['mime_type'] : '' ;
    … … class wp_xmlrpc_server extends IXR_Server {  
    36073361        /**
    36083362          * Retrieves a list of post formats used by the site
    36093363          *
    3610           * @since 3.1.0
     3364          * @since 3.1
    36113365          *
    36123366          * @param array $args Method parameters. Contains:
    36133367          *  - blog_id
    … … class wp_xmlrpc_server extends IXR_Server {  
    36223376                $username = $args[1];
    36233377                $password = $args[2];
    36243378
     3379                switch_to_blog($blog_id);
     3380
    36253381                if ( !$user = $this->login( $username, $password ) )
    36263382                        return $this->error;
    36273383
    36283384                if ( !current_user_can( 'edit_posts' ) )
    36293385                        return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) );
    36303386
    3631                 /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    36323387                do_action( 'xmlrpc_call', 'wp.getPostFormats' );
    36333388
    36343389                $formats = get_post_format_strings();
    … … class wp_xmlrpc_server extends IXR_Server {  
    36843439                $password       = $args[2];
    36853440                $post_type_name = $args[3];
    36863441
    3687                 if ( isset( $args[4] ) ) {
     3442                switch_to_blog($blog_id);
     3443
     3444                if ( isset( $args[4] ) )
    36883445                        $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
    36983447                        $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostType' );
    3699                 }
    37003448
    37013449                if ( !$user = $this->login( $username, $password ) )
    37023450                        return $this->error;
    37033451
    3704                 /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    37053452                do_action( 'xmlrpc_call', 'wp.getPostType' );
    37063453
    37073454                if( ! post_type_exists( $post_type_name ) )
    … … class wp_xmlrpc_server extends IXR_Server {  
    37403487                $password           = $args[2];
    37413488                $filter             = isset( $args[3] ) ? $args[3] : array( 'public' => true );
    37423489
    3743                 if ( isset( $args[4] ) ) {
     3490                switch_to_blog($blog_id);
     3491
     3492                if ( isset( $args[4] ) )
    37443493                        $fields = $args[4];
    3745                 } else {
    3746                         /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
     3494                else
    37473495                        $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostTypes' );
    3748                 }
    37493496
    37503497                if ( ! $user = $this->login( $username, $password ) )
    37513498                        return $this->error;
    37523499
    3753                 /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    37543500                do_action( 'xmlrpc_call', 'wp.getPostTypes' );
    37553501
    37563502                $post_types = get_post_types( $filter, 'objects' );
    … … class wp_xmlrpc_server extends IXR_Server {  
    37973543                $password   = $args[2];
    37983544                $post_id    = (int) $args[3];
    37993545
    3800                 if ( isset( $args[4] ) ) {
     3546                if ( isset( $args[4] ) )
    38013547                        $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
    38113549                        $fields = apply_filters( 'xmlrpc_default_revision_fields', array( 'post_date', 'post_date_gmt' ), 'wp.getRevisions' );
    3812                 }
    38133550
    38143551                if ( ! $user = $this->login( $username, $password ) )
    38153552                        return $this->error;
    38163553
    3817                 /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    38183554                do_action( 'xmlrpc_call', 'wp.getRevisions' );
    38193555
    38203556                if ( ! $post = get_post( $post_id ) )
    … … class wp_xmlrpc_server extends IXR_Server {  
    38763612                if ( ! $user = $this->login( $username, $password ) )
    38773613                        return $this->error;
    38783614
    3879                 /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    38803615                do_action( 'xmlrpc_call', 'wp.restoreRevision' );
    38813616
    38823617                if ( ! $revision = wp_get_post_revision( $revision_id ) )
    … … class wp_xmlrpc_server extends IXR_Server {  
    39263661                if ( !$user = $this->login($username, $password) )
    39273662                        return $this->error;
    39283663
    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');
    39313665
    39323666                $is_admin = current_user_can('manage_options');
    39333667
    … … class wp_xmlrpc_server extends IXR_Server {  
    39943728                if ( !current_user_can( 'edit_posts' ) )
    39953729                        return new IXR_Error( 401, __( 'Sorry, you do not have access to user data on this site.' ) );
    39963730
    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');
    39993732
    40003733                $struct = array(
    40013734                        'nickname'  => $user->nickname,
    … … class wp_xmlrpc_server extends IXR_Server {  
    40343767                if ( !current_user_can( 'edit_post', $post_ID ) )
    40353768                        return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) );
    40363769
    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');
    40393771
    40403772                $categories = implode(',', wp_get_post_categories($post_ID));
    40413773
    … … class wp_xmlrpc_server extends IXR_Server {  
    40803812                if ( ! current_user_can( 'edit_posts' ) )
    40813813                        return new IXR_Error( 401, __( 'Sorry, you cannot edit posts on this site.' ) );
    40823814
    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');
    40853816
    40863817                $posts_list = wp_get_recent_posts( $query );
    40873818
    … … class wp_xmlrpc_server extends IXR_Server {  
    41593890                if ( !$user = $this->login($username, $password) )
    41603891                        return $this->error;
    41613892
    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');
    41643894
    41653895                $cap = ($publish) ? 'publish_posts' : 'edit_posts';
    41663896                if ( ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) || !current_user_can($cap) )
    … … class wp_xmlrpc_server extends IXR_Server {  
    41883918
    41893919                $this->attach_uploads( $post_ID, $post_content );
    41903920
    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                  */
    41993921                do_action( 'xmlrpc_call_success_blogger_newPost', $post_ID, $args );
    42003922
    42013923                return $post_ID;
    … … class wp_xmlrpc_server extends IXR_Server {  
    42223944                if ( !$user = $this->login($username, $password) )
    42233945                        return $this->error;
    42243946
    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');
    42273948
    42283949                $actual_post = get_post($post_ID,ARRAY_A);
    42293950
    … … class wp_xmlrpc_server extends IXR_Server {  
    42533974
    42543975                $this->attach_uploads( $ID, $post_content );
    42553976
    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                  */
    42643977                do_action( 'xmlrpc_call_success_blogger_editPost', $post_ID, $args );
    42653978
    42663979                return true;
    … … class wp_xmlrpc_server extends IXR_Server {  
    42853998                if ( !$user = $this->login($username, $password) )
    42863999                        return $this->error;
    42874000
    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');
    42904002
    42914003                $actual_post = get_post($post_ID,ARRAY_A);
    42924004
    … … class wp_xmlrpc_server extends IXR_Server {  
    43014013                if ( !$result )
    43024014                        return new IXR_Error(500, __('For some strange yet very annoying reason, this post could not be deleted.'));
    43034015
    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                  */
    43124016                do_action( 'xmlrpc_call_success_blogger_deletePost', $post_ID, $args );
    43134017
    43144018                return true;
    … … class wp_xmlrpc_server extends IXR_Server {  
    43654069                if ( !$user = $this->login($username, $password) )
    43664070                        return $this->error;
    43674071
    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');
    43704073
    43714074                $page_template = '';
    43724075                if ( !empty( $content_struct['post_type'] ) ) {
    … … class wp_xmlrpc_server extends IXR_Server {  
    46204323                if ( !$post_ID )
    46214324                        return new IXR_Error(500, __('Sorry, your entry could not be posted. Something wrong happened.'));
    46224325
    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                  */
    46314326                do_action( 'xmlrpc_call_success_mw_newPost', $post_ID, $args );
    46324327
    46334328                return strval($post_ID);
    … … class wp_xmlrpc_server extends IXR_Server {  
    46934388                if ( ! $user = $this->login($username, $password) )
    46944389                        return $this->error;
    46954390
    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');
    46984392
    46994393                $postdata = get_post( $post_ID, ARRAY_A );
    47004394
    … … class wp_xmlrpc_server extends IXR_Server {  
    49374631                if ( isset( $content_struct['wp_post_format'] ) )
    49384632                        set_post_format( $post_ID, $content_struct['wp_post_format'] );
    49394633
    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                  */
    49484634                do_action( 'xmlrpc_call_success_mw_editPost', $post_ID, $args );
    49494635
    49504636                return true;
    … … class wp_xmlrpc_server extends IXR_Server {  
    49764662                if ( !current_user_can( 'edit_post', $post_ID ) )
    49774663                        return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) );
    49784664
    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');
    49814666
    49824667                if ($postdata['post_date'] != '') {
    49834668                        $post_date = $this->_convert_date( $postdata['post_date'] );
    … … class wp_xmlrpc_server extends IXR_Server {  
    51014786                if ( ! current_user_can( 'edit_posts' ) )
    51024787                        return new IXR_Error( 401, __( 'Sorry, you cannot edit posts on this site.' ) );
    51034788
    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');
    51064790
    51074791                $posts_list = wp_get_recent_posts( $query );
    51084792
    … … class wp_xmlrpc_server extends IXR_Server {  
    51794863                                'custom_fields' => $this->get_custom_fields($entry['ID']),
    51804864                                'wp_post_format' => $post_format,
    51814865                                '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
    51844867                        );
    51854868
    51864869                        $entry_index = count( $struct ) - 1;
    … … class wp_xmlrpc_server extends IXR_Server {  
    52174900                if ( !current_user_can( 'edit_posts' ) )
    52184901                        return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) );
    52194902
    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');
    52224904
    52234905                $categories_struct = array();
    52244906
    … … class wp_xmlrpc_server extends IXR_Server {  
    52664948                if ( !$user = $this->login($username, $password) )
    52674949                        return $this->error;
    52684950
    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');
    52714952
    52724953                if ( !current_user_can('upload_files') ) {
    52734954                        $this->error = new IXR_Error( 401, __( 'You do not have permission to upload files.' ) );
    52744955                        return $this->error;
    52754956                }
    52764957
    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);
    52904960
    52914961                if ( !empty($data['overwrite']) && ($data['overwrite'] == true) ) {
    52924962                        // Get postmeta info on the object.
    … … class wp_xmlrpc_server extends IXR_Server {  
    53325002                $id = wp_insert_attachment( $attachment, $upload[ 'file' ], $post_id );
    53335003                wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $upload['file'] ) );
    53345004
    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                  */
    53435005                do_action( 'xmlrpc_call_success_mw_newMediaObject', $id, $args );
    53445006
    53455007                $struct = array(
    … … class wp_xmlrpc_server extends IXR_Server {  
    53485010                        'url'  => $upload[ 'url' ],
    53495011                        'type' => $type
    53505012                );
    5351 
    5352                 /** This filter is documented in wp-admin/includes/file.php */
    53535013                return apply_filters( 'wp_handle_upload', $struct, 'upload' );
    53545014        }
    53555015
    … … class wp_xmlrpc_server extends IXR_Server {  
    53805040                if ( !$user = $this->login($username, $password) )
    53815041                        return $this->error;
    53825042
    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');
    53855044
    53865045                $posts_list = wp_get_recent_posts( $query );
    53875046
    … … class wp_xmlrpc_server extends IXR_Server {  
    54405099                if ( !current_user_can( 'edit_posts' ) )
    54415100                        return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) );
    54425101
    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');
    54455103
    54465104                $categories_struct = array();
    54475105
    … … class wp_xmlrpc_server extends IXR_Server {  
    54825140                if ( !current_user_can( 'edit_post', $post_ID ) )
    54835141                        return new IXR_Error( 401, __( 'Sorry, you can not edit this post.' ) );
    54845142
    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');
    54875144
    54885145                $categories = array();
    54895146                $catids = wp_get_post_categories(intval($post_ID));
    … … class wp_xmlrpc_server extends IXR_Server {  
    55215178                if ( !$user = $this->login($username, $password) )
    55225179                        return $this->error;
    55235180
    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');
    55265182
    55275183                if ( ! get_post( $post_ID ) )
    55285184                        return new IXR_Error( 404, __( 'Invalid post ID.' ) );
    … … class wp_xmlrpc_server extends IXR_Server {  
    55505206         */
    55515207        function mt_supportedMethods($args) {
    55525208
    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');
    55555210
    55565211                $supported_methods = array();
    55575212                foreach ( $this->methods as $key => $value ) {
    … … class wp_xmlrpc_server extends IXR_Server {  
    55695224         * @param array $args Method parameters.
    55705225         */
    55715226        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());
    55835229        }
    55845230
    55855231        /**
    … … class wp_xmlrpc_server extends IXR_Server {  
    55965242
    55975243                $post_ID = intval($args);
    55985244
    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');
    56015246
    56025247                $actual_post = get_post($post_ID, ARRAY_A);
    56035248
    … … class wp_xmlrpc_server extends IXR_Server {  
    56445289                if ( !$user = $this->login($username, $password) )
    56455290                        return $this->error;
    56465291
    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');
    56495293
    56505294                $postdata = get_post($post_ID, ARRAY_A);
    56515295                if ( ! $postdata )
    … … class wp_xmlrpc_server extends IXR_Server {  
    56815325        function pingback_ping($args) {
    56825326                global $wpdb;
    56835327
    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');
    56865329
    56875330                $this->escape($args);
    56885331
    … … class wp_xmlrpc_server extends IXR_Server {  
    56955338                $pagelinkedto = str_replace('&', '&', $pagelinkedto);
    56965339                $pagelinkedto = str_replace('&', '&', $pagelinkedto);
    56975340
    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                  */
    57065341                $pagelinkedfrom = apply_filters( 'pingback_ping_source_uri', $pagelinkedfrom, $pagelinkedto );
    5707 
    57085342                if ( ! $pagelinkedfrom )
    57095343                        return $this->pingback_error( 0, __( 'A valid URL was not provided.' ) );
    57105344
    … … class wp_xmlrpc_server extends IXR_Server {  
    57745408                // very stupid, but gives time to the 'from' server to publish !
    57755409                sleep(1);
    57765410
    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 
    57825411                // Let's check the remote site
    57835412                $http_api_args = array(
    57845413                        'timeout' => 10,
    57855414                        'redirection' => 0,
    57865415                        '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                         ),
    57915416                );
    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 ) );
    57945418
    57955419                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);
    58075423
    58085424                // Work around bug in strip_tags():
    58095425                $linea = str_replace('<!DOC', '<DOC', $linea);
    … … class wp_xmlrpc_server extends IXR_Server {  
    58685484                $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_author_email', 'comment_content', 'comment_type');
    58695485
    58705486                $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);
    58805488
    58815489                return sprintf(__('Pingback from %1$s to %2$s registered. Keep the web talking! :-)'), $pagelinkedfrom, $pagelinkedto);
    58825490        }
    … … class wp_xmlrpc_server extends IXR_Server {  
    58955503
    58965504                global $wpdb;
    58975505
    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');
    59005507
    59015508                $this->escape($args);
    59025509
    … … class wp_xmlrpc_server extends IXR_Server {  
    59305537        }
    59315538
    59325539        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                  */
    59405540                return apply_filters( 'xmlrpc_pingback_error', new IXR_Error( $code, $message ) );
    59415541        }
    59425542}