Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: xmlrpc_call

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

This hook occurs 67 times in this file.

Line Code
735            * equal to the method's name, e.g., wp.getUsersBlogs, wp.newPost, etc.
736            *
737            * @since 2.5.0
738            * @since 5.7.0 Added the `$args` and `$server` parameters.
739            *
740            * @param string           $name   The method name.
741            * @param array|string     $args   The escaped arguments passed to the method.
742            * @param wp_xmlrpc_server $server The XML-RPC server instance.
743            */
744           do_action( 'xmlrpc_call', 'wp.getUsersBlogs', $args, $this );
745
746           $blogs  = (array) get_blogs_of_user( $user->ID );
747           $struct = array();
748
749           $primary_blog_id = 0;
750           $active_blog     = get_active_blog_for_user( $user->ID );
751           if ( $active_blog ) {
752                $primary_blog_id = (int) $active_blog->blog_id;
753           }
 
Line Code
1349           if ( isset( $content_struct['post_date_gmt'] ) && ! ( $content_struct['post_date_gmt'] instanceof IXR_Date ) ) {
1350                if ( '0000-00-00 00:00:00' === $content_struct['post_date_gmt'] || isset( $content_struct['post_date'] ) ) {
1351                     unset( $content_struct['post_date_gmt'] );
1352                } else {
1353                     $content_struct['post_date_gmt'] = $this->_convert_date( $content_struct['post_date_gmt'] );
1354                }
1355           }
1356
1357           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
1358           do_action( 'xmlrpc_call', 'wp.newPost', $args, $this );
1359
1360           unset( $content_struct['ID'] );
1361
1362           return $this->_insert_post( $user, $content_struct );
1363      }
1364
1365      /**
1366       * Helper method for filtering out elements from an array.
1367       *
 
Line Code
1750           $post_id        = (int) $args[3];
1751           $content_struct = $args[4];
1752
1753           $user = $this->login( $username, $password );
1754           if ( ! $user ) {
1755                return $this->error;
1756           }
1757
1758           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
1759           do_action( 'xmlrpc_call', 'wp.editPost', $args, $this );
1760
1761           $post = get_post( $post_id, ARRAY_A );
1762
1763           if ( empty( $post['ID'] ) ) {
1764                return new IXR_Error( 404, __( 'Invalid post ID.' ) );
1765           }
1766
1767           if ( isset( $content_struct['if_not_modified_since'] ) ) {
1768                // If the post has been modified since the date provided, return an error.
 
Line Code
1833           $password = $args[2];
1834           $post_id  = (int) $args[3];
1835
1836           $user = $this->login( $username, $password );
1837           if ( ! $user ) {
1838                return $this->error;
1839           }
1840
1841           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
1842           do_action( 'xmlrpc_call', 'wp.deletePost', $args, $this );
1843
1844           $post = get_post( $post_id, ARRAY_A );
1845           if ( empty( $post['ID'] ) ) {
1846                return new IXR_Error( 404, __( 'Invalid post ID.' ) );
1847           }
1848
1849           if ( ! current_user_can( 'delete_post', $post_id ) ) {
1850                return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) );
1851           }
 
Line Code
1934                $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPost' );
1935           }
1936
1937           $user = $this->login( $username, $password );
1938           if ( ! $user ) {
1939                return $this->error;
1940           }
1941
1942           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
1943           do_action( 'xmlrpc_call', 'wp.getPost', $args, $this );
1944
1945           $post = get_post( $post_id, ARRAY_A );
1946
1947           if ( empty( $post['ID'] ) ) {
1948                return new IXR_Error( 404, __( 'Invalid post ID.' ) );
1949           }
1950
1951           if ( ! current_user_can( 'edit_post', $post_id ) ) {
1952                return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
 
Line Code
1995                $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPosts' );
1996           }
1997
1998           $user = $this->login( $username, $password );
1999           if ( ! $user ) {
2000                return $this->error;
2001           }
2002
2003           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
2004           do_action( 'xmlrpc_call', 'wp.getPosts', $args, $this );
2005
2006           $query = array();
2007
2008           if ( isset( $filter['post_type'] ) ) {
2009                $post_type = get_post_type_object( $filter['post_type'] );
2010                if ( ! ( (bool) $post_type ) ) {
2011                     return new IXR_Error( 403, __( 'Invalid post type.' ) );
2012                }
2013           } else {
 
Line Code
2094           $password       = $args[2];
2095           $content_struct = $args[3];
2096
2097           $user = $this->login( $username, $password );
2098           if ( ! $user ) {
2099                return $this->error;
2100           }
2101
2102           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
2103           do_action( 'xmlrpc_call', 'wp.newTerm', $args, $this );
2104
2105           if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) {
2106                return new IXR_Error( 403, __( 'Invalid taxonomy.' ) );
2107           }
2108
2109           $taxonomy = get_taxonomy( $content_struct['taxonomy'] );
2110
2111           if ( ! current_user_can( $taxonomy->cap->edit_terms ) ) {
2112                return new IXR_Error( 401, __( 'Sorry, you are not allowed to create terms in this taxonomy.' ) );
 
Line Code
2199           $term_id        = (int) $args[3];
2200           $content_struct = $args[4];
2201
2202           $user = $this->login( $username, $password );
2203           if ( ! $user ) {
2204                return $this->error;
2205           }
2206
2207           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
2208           do_action( 'xmlrpc_call', 'wp.editTerm', $args, $this );
2209
2210           if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) {
2211                return new IXR_Error( 403, __( 'Invalid taxonomy.' ) );
2212           }
2213
2214           $taxonomy = get_taxonomy( $content_struct['taxonomy'] );
2215
2216           $taxonomy = (array) $taxonomy;
2217
 
Line Code
2315           $taxonomy = $args[3];
2316           $term_id  = (int) $args[4];
2317
2318           $user = $this->login( $username, $password );
2319           if ( ! $user ) {
2320                return $this->error;
2321           }
2322
2323           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
2324           do_action( 'xmlrpc_call', 'wp.deleteTerm', $args, $this );
2325
2326           if ( ! taxonomy_exists( $taxonomy ) ) {
2327                return new IXR_Error( 403, __( 'Invalid taxonomy.' ) );
2328           }
2329
2330           $taxonomy = get_taxonomy( $taxonomy );
2331           $term     = get_term( $term_id, $taxonomy->name );
2332
2333           if ( is_wp_error( $term ) ) {
 
Line Code
2394           $taxonomy = $args[3];
2395           $term_id  = (int) $args[4];
2396
2397           $user = $this->login( $username, $password );
2398           if ( ! $user ) {
2399                return $this->error;
2400           }
2401
2402           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
2403           do_action( 'xmlrpc_call', 'wp.getTerm', $args, $this );
2404
2405           if ( ! taxonomy_exists( $taxonomy ) ) {
2406                return new IXR_Error( 403, __( 'Invalid taxonomy.' ) );
2407           }
2408
2409           $taxonomy = get_taxonomy( $taxonomy );
2410
2411           $term = get_term( $term_id, $taxonomy->name, ARRAY_A );
2412
 
Line Code
2459           $taxonomy = $args[3];
2460           $filter   = isset( $args[4] ) ? $args[4] : array();
2461
2462           $user = $this->login( $username, $password );
2463           if ( ! $user ) {
2464                return $this->error;
2465           }
2466
2467           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
2468           do_action( 'xmlrpc_call', 'wp.getTerms', $args, $this );
2469
2470           if ( ! taxonomy_exists( $taxonomy ) ) {
2471                return new IXR_Error( 403, __( 'Invalid taxonomy.' ) );
2472           }
2473
2474           $taxonomy = get_taxonomy( $taxonomy );
2475
2476           if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) {
2477                return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ) );
 
Line Code
2566                $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomy' );
2567           }
2568
2569           $user = $this->login( $username, $password );
2570           if ( ! $user ) {
2571                return $this->error;
2572           }
2573
2574           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
2575           do_action( 'xmlrpc_call', 'wp.getTaxonomy', $args, $this );
2576
2577           if ( ! taxonomy_exists( $taxonomy ) ) {
2578                return new IXR_Error( 403, __( 'Invalid taxonomy.' ) );
2579           }
2580
2581           $taxonomy = get_taxonomy( $taxonomy );
2582
2583           if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) {
2584                return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ) );
 
Line Code
2624                $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomies' );
2625           }
2626
2627           $user = $this->login( $username, $password );
2628           if ( ! $user ) {
2629                return $this->error;
2630           }
2631
2632           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
2633           do_action( 'xmlrpc_call', 'wp.getTaxonomies', $args, $this );
2634
2635           $taxonomies = get_taxonomies( $filter, 'objects' );
2636
2637           // Holds all the taxonomy data.
2638           $struct = array();
2639
2640           foreach ( $taxonomies as $taxonomy ) {
2641                // Capability check for post types.
2642                if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) {
 
Line Code
2710                $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUser' );
2711           }
2712
2713           $user = $this->login( $username, $password );
2714           if ( ! $user ) {
2715                return $this->error;
2716           }
2717
2718           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
2719           do_action( 'xmlrpc_call', 'wp.getUser', $args, $this );
2720
2721           if ( ! current_user_can( 'edit_user', $user_id ) ) {
2722                return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this user.' ) );
2723           }
2724
2725           $user_data = get_userdata( $user_id );
2726
2727           if ( ! $user_data ) {
2728                return new IXR_Error( 404, __( 'Invalid user ID.' ) );
 
Line Code
2773                $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUsers' );
2774           }
2775
2776           $user = $this->login( $username, $password );
2777           if ( ! $user ) {
2778                return $this->error;
2779           }
2780
2781           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
2782           do_action( 'xmlrpc_call', 'wp.getUsers', $args, $this );
2783
2784           if ( ! current_user_can( 'list_users' ) ) {
2785                return new IXR_Error( 401, __( 'Sorry, you are not allowed to list users.' ) );
2786           }
2787
2788           $query = array( 'fields' => 'all_with_meta' );
2789
2790           $query['number'] = ( isset( $filter['number'] ) ) ? absint( $filter['number'] ) : 50;
2791           $query['offset'] = ( isset( $filter['offset'] ) ) ? absint( $filter['offset'] ) : 0;
 
Line Code
2853                $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getProfile' );
2854           }
2855
2856           $user = $this->login( $username, $password );
2857           if ( ! $user ) {
2858                return $this->error;
2859           }
2860
2861           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
2862           do_action( 'xmlrpc_call', 'wp.getProfile', $args, $this );
2863
2864           if ( ! current_user_can( 'edit_user', $user->ID ) ) {
2865                return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit your profile.' ) );
2866           }
2867
2868           $user_data = get_userdata( $user->ID );
2869
2870           return $this->_prepare_user( $user_data, $fields );
2871      }
 
Line Code
2903           $password       = $args[2];
2904           $content_struct = $args[3];
2905
2906           $user = $this->login( $username, $password );
2907           if ( ! $user ) {
2908                return $this->error;
2909           }
2910
2911           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
2912           do_action( 'xmlrpc_call', 'wp.editProfile', $args, $this );
2913
2914           if ( ! current_user_can( 'edit_user', $user->ID ) ) {
2915                return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit your profile.' ) );
2916           }
2917
2918           // Holds data of the user.
2919           $user_data       = array();
2920           $user_data['ID'] = $user->ID;
2921
 
Line Code
2992           if ( ! $page ) {
2993                return new IXR_Error( 404, __( 'Invalid post ID.' ) );
2994           }
2995
2996           if ( ! current_user_can( 'edit_page', $page_id ) ) {
2997                return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this page.' ) );
2998           }
2999
3000           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
3001           do_action( 'xmlrpc_call', 'wp.getPage', $args, $this );
3002
3003           // If we found the page then format the data.
3004           if ( $page->ID && ( 'page' === $page->post_type ) ) {
3005                return $this->_prepare_page( $page );
3006           } else {
3007                // If the page doesn't exist, indicate that.
3008                return new IXR_Error( 404, __( 'Sorry, no such page.' ) );
3009           }
3010      }
 
Line Code
3035           if ( ! $user ) {
3036                return $this->error;
3037           }
3038
3039           if ( ! current_user_can( 'edit_pages' ) ) {
3040                return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit pages.' ) );
3041           }
3042
3043           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
3044           do_action( 'xmlrpc_call', 'wp.getPages', $args, $this );
3045
3046           $pages     = get_posts(
3047                array(
3048                     'post_type'   => 'page',
3049                     'post_status' => 'any',
3050                     'numberposts' => $num_pages,
3051                )
3052           );
3053           $num_pages = count( $pages );
 
Line Code
3090           $username = $this->escape( $args[1] );
3091           $password = $this->escape( $args[2] );
3092
3093           $user = $this->login( $username, $password );
3094           if ( ! $user ) {
3095                return $this->error;
3096           }
3097
3098           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
3099           do_action( 'xmlrpc_call', 'wp.newPage', $args, $this );
3100
3101           // Mark this as content for a page.
3102           $args[3]['post_type'] = 'page';
3103
3104           // Let mw_newPost() do all of the heavy lifting.
3105           return $this->mw_newPost( $args );
3106      }
3107
3108      /**
 
Line Code
3127           $password = $args[2];
3128           $page_id  = (int) $args[3];
3129
3130           $user = $this->login( $username, $password );
3131           if ( ! $user ) {
3132                return $this->error;
3133           }
3134
3135           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
3136           do_action( 'xmlrpc_call', 'wp.deletePage', $args, $this );
3137
3138           /*
3139            * Get the current page based on the 'page_id' and
3140            * make sure it is a page and not a post.
3141            */
3142           $actual_page = get_post( $page_id, ARRAY_A );
3143           if ( ! $actual_page || ( 'page' !== $actual_page['post_type'] ) ) {
3144                return new IXR_Error( 404, __( 'Sorry, no such page.' ) );
3145           }
 
Line Code
3196           $escaped_username = $this->escape( $username );
3197           $escaped_password = $this->escape( $password );
3198
3199           $user = $this->login( $escaped_username, $escaped_password );
3200           if ( ! $user ) {
3201                return $this->error;
3202           }
3203
3204           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
3205           do_action( 'xmlrpc_call', 'wp.editPage', $args, $this );
3206
3207           // Get the page data and make sure it is a page.
3208           $actual_page = get_post( $page_id, ARRAY_A );
3209           if ( ! $actual_page || ( 'page' !== $actual_page['post_type'] ) ) {
3210                return new IXR_Error( 404, __( 'Sorry, no such page.' ) );
3211           }
3212
3213           // Make sure the user is allowed to edit pages.
3214           if ( ! current_user_can( 'edit_page', $page_id ) ) {
 
Line Code
3259           if ( ! $user ) {
3260                return $this->error;
3261           }
3262
3263           if ( ! current_user_can( 'edit_pages' ) ) {
3264                return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit pages.' ) );
3265           }
3266
3267           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
3268           do_action( 'xmlrpc_call', 'wp.getPageList', $args, $this );
3269
3270           // Get list of page IDs and titles.
3271           $page_list = $wpdb->get_results(
3272                "
3273                SELECT ID page_id,
3274                     post_title page_title,
3275                     post_parent page_parent_id,
3276                     post_date_gmt,
3277                     post_date,
 
Line Code
3320           if ( ! $user ) {
3321                return $this->error;
3322           }
3323
3324           if ( ! current_user_can( 'edit_posts' ) ) {
3325                return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) );
3326           }
3327
3328           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
3329           do_action( 'xmlrpc_call', 'wp.getAuthors', $args, $this );
3330
3331           $authors = array();
3332           foreach ( get_users( array( 'fields' => array( 'ID', 'user_login', 'display_name' ) ) ) as $user ) {
3333                $authors[] = array(
3334                     'user_id'      => $user->ID,
3335                     'user_login'   => $user->user_login,
3336                     'display_name' => $user->display_name,
3337                );
3338           }
 
Line Code
3364           if ( ! $user ) {
3365                return $this->error;
3366           }
3367
3368           if ( ! current_user_can( 'edit_posts' ) ) {
3369                return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view tags.' ) );
3370           }
3371
3372           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
3373           do_action( 'xmlrpc_call', 'wp.getKeywords', $args, $this );
3374
3375           $tags = array();
3376
3377           $all_tags = get_tags();
3378           if ( $all_tags ) {
3379                foreach ( (array) $all_tags as $tag ) {
3380                     $struct             = array();
3381                     $struct['tag_id']   = $tag->term_id;
3382                     $struct['name']     = $tag->name;
 
Line Code
3414           $password = $args[2];
3415           $category = $args[3];
3416
3417           $user = $this->login( $username, $password );
3418           if ( ! $user ) {
3419                return $this->error;
3420           }
3421
3422           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
3423           do_action( 'xmlrpc_call', 'wp.newCategory', $args, $this );
3424
3425           // Make sure the user is allowed to add a category.
3426           if ( ! current_user_can( 'manage_categories' ) ) {
3427                return new IXR_Error( 401, __( 'Sorry, you are not allowed to add a category.' ) );
3428           }
3429
3430           /*
3431            * If no slug was provided, make it empty
3432            * so that WordPress will generate one.
 
Line Code
3501           $password    = $args[2];
3502           $category_id = (int) $args[3];
3503
3504           $user = $this->login( $username, $password );
3505           if ( ! $user ) {
3506                return $this->error;
3507           }
3508
3509           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
3510           do_action( 'xmlrpc_call', 'wp.deleteCategory', $args, $this );
3511
3512           if ( ! current_user_can( 'delete_term', $category_id ) ) {
3513                return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this category.' ) );
3514           }
3515
3516           $status = wp_delete_term( $category_id, 'category' );
3517
3518           if ( true === $status ) {
3519                /**
 
Line Code
3558           if ( ! $user ) {
3559                return $this->error;
3560           }
3561
3562           if ( ! current_user_can( 'edit_posts' ) ) {
3563                return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) );
3564           }
3565
3566           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
3567           do_action( 'xmlrpc_call', 'wp.suggestCategories', $args, $this );
3568
3569           $category_suggestions = array();
3570           $args                 = array(
3571                'get'        => 'all',
3572                'number'     => $max_results,
3573                'name__like' => $category,
3574           );
3575           foreach ( (array) get_categories( $args ) as $cat ) {
3576                $category_suggestions[] = array(
 
Line Code
3604           $password   = $args[2];
3605           $comment_id = (int) $args[3];
3606
3607           $user = $this->login( $username, $password );
3608           if ( ! $user ) {
3609                return $this->error;
3610           }
3611
3612           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
3613           do_action( 'xmlrpc_call', 'wp.getComment', $args, $this );
3614
3615           $comment = get_comment( $comment_id );
3616           if ( ! $comment ) {
3617                return new IXR_Error( 404, __( 'Invalid comment ID.' ) );
3618           }
3619
3620           if ( ! current_user_can( 'edit_comment', $comment_id ) ) {
3621                return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) );
3622           }
 
Line Code
3660           $password = $args[2];
3661           $struct   = isset( $args[3] ) ? $args[3] : array();
3662
3663           $user = $this->login( $username, $password );
3664           if ( ! $user ) {
3665                return $this->error;
3666           }
3667
3668           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
3669           do_action( 'xmlrpc_call', 'wp.getComments', $args, $this );
3670
3671           if ( isset( $struct['status'] ) ) {
3672                $status = $struct['status'];
3673           } else {
3674                $status = '';
3675           }
3676
3677           if ( ! current_user_can( 'moderate_comments' ) && 'approve' !== $status ) {
3678                return new IXR_Error( 401, __( 'Invalid comment status.' ) );
 
Line Code
3755           if ( ! get_comment( $comment_id ) ) {
3756                return new IXR_Error( 404, __( 'Invalid comment ID.' ) );
3757           }
3758
3759           if ( ! current_user_can( 'edit_comment', $comment_id ) ) {
3760                return new IXR_Error( 403, __( 'Sorry, you are not allowed to delete this comment.' ) );
3761           }
3762
3763           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
3764           do_action( 'xmlrpc_call', 'wp.deleteComment', $args, $this );
3765
3766           $status = wp_delete_comment( $comment_id );
3767
3768           if ( true === $status ) {
3769                /**
3770                 * Fires after a comment has been successfully deleted via XML-RPC.
3771                 *
3772                 * @since 3.4.0
3773                 *
 
Line Code
3823           if ( ! get_comment( $comment_id ) ) {
3824                return new IXR_Error( 404, __( 'Invalid comment ID.' ) );
3825           }
3826
3827           if ( ! current_user_can( 'edit_comment', $comment_id ) ) {
3828                return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) );
3829           }
3830
3831           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
3832           do_action( 'xmlrpc_call', 'wp.editComment', $args, $this );
3833           $comment = array(
3834                'comment_ID' => $comment_id,
3835           );
3836
3837           if ( isset( $content_struct['status'] ) ) {
3838                $statuses = get_comment_statuses();
3839                $statuses = array_keys( $statuses );
3840
3841                if ( ! in_array( $content_struct['status'], $statuses, true ) ) {
 
Line Code
4017
4018           /** This filter is documented in wp-includes/comment.php */
4019           $allow_empty = apply_filters( 'allow_empty_comment', false, $comment );
4020
4021           if ( ! $allow_empty && '' === $comment['comment_content'] ) {
4022                return new IXR_Error( 403, __( 'Comment is required.' ) );
4023           }
4024
4025           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
4026           do_action( 'xmlrpc_call', 'wp.newComment', $args, $this );
4027
4028           $comment_id = wp_new_comment( $comment, true );
4029           if ( is_wp_error( $comment_id ) ) {
4030                return new IXR_Error( 403, $comment_id->get_error_message() );
4031           }
4032
4033           if ( ! $comment_id ) {
4034                return new IXR_Error( 403, __( 'An error occurred while processing your comment. Please ensure all fields are filled correctly and try again.' ) );
4035           }
 
Line Code
4071           if ( ! $user ) {
4072                return $this->error;
4073           }
4074
4075           if ( ! current_user_can( 'publish_posts' ) ) {
4076                return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) );
4077           }
4078
4079           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
4080           do_action( 'xmlrpc_call', 'wp.getCommentStatusList', $args, $this );
4081
4082           return get_comment_statuses();
4083      }
4084
4085      /**
4086       * Retrieves comment counts.
4087       *
4088       * @since 2.5.0
4089       *
 
Line Code
4113           if ( empty( $post['ID'] ) ) {
4114                return new IXR_Error( 404, __( 'Invalid post ID.' ) );
4115           }
4116
4117           if ( ! current_user_can( 'edit_post', $post_id ) ) {
4118                return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details of this post.' ) );
4119           }
4120
4121           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
4122           do_action( 'xmlrpc_call', 'wp.getCommentCount', $args, $this );
4123
4124           $count = wp_count_comments( $post_id );
4125
4126           return array(
4127                'approved'            => $count->approved,
4128                'awaiting_moderation' => $count->moderated,
4129                'spam'                => $count->spam,
4130                'total_comments'      => $count->total_comments,
4131           );
 
Line Code
4155           if ( ! $user ) {
4156                return $this->error;
4157           }
4158
4159           if ( ! current_user_can( 'edit_posts' ) ) {
4160                return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) );
4161           }
4162
4163           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
4164           do_action( 'xmlrpc_call', 'wp.getPostStatusList', $args, $this );
4165
4166           return get_post_statuses();
4167      }
4168
4169      /**
4170       * Retrieves page statuses.
4171       *
4172       * @since 2.5.0
4173       *
 
Line Code
4190           if ( ! $user ) {
4191                return $this->error;
4192           }
4193
4194           if ( ! current_user_can( 'edit_pages' ) ) {
4195                return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) );
4196           }
4197
4198           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
4199           do_action( 'xmlrpc_call', 'wp.getPageStatusList', $args, $this );
4200
4201           return get_page_statuses();
4202      }
4203
4204      /**
4205       * Retrieves page templates.
4206       *
4207       * @since 2.6.0
4208       *
 
Line Code
4383           if ( ! $user ) {
4384                return $this->error;
4385           }
4386
4387           if ( ! current_user_can( 'upload_files' ) ) {
4388                return new IXR_Error( 403, __( 'Sorry, you are not allowed to upload files.' ) );
4389           }
4390
4391           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
4392           do_action( 'xmlrpc_call', 'wp.getMediaItem', $args, $this );
4393
4394           $attachment = get_post( $attachment_id );
4395           if ( ! $attachment || 'attachment' !== $attachment->post_type ) {
4396                return new IXR_Error( 404, __( 'Invalid attachment ID.' ) );
4397           }
4398
4399           return $this->_prepare_media_item( $attachment );
4400      }
4401
 
Line Code
4439           if ( ! $user ) {
4440                return $this->error;
4441           }
4442
4443           if ( ! current_user_can( 'upload_files' ) ) {
4444                return new IXR_Error( 401, __( 'Sorry, you are not allowed to upload files.' ) );
4445           }
4446
4447           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
4448           do_action( 'xmlrpc_call', 'wp.getMediaLibrary', $args, $this );
4449
4450           $parent_id = ( isset( $struct['parent_id'] ) ) ? absint( $struct['parent_id'] ) : '';
4451           $mime_type = ( isset( $struct['mime_type'] ) ) ? $struct['mime_type'] : '';
4452           $offset    = ( isset( $struct['offset'] ) ) ? absint( $struct['offset'] ) : 0;
4453           $number    = ( isset( $struct['number'] ) ) ? absint( $struct['number'] ) : -1;
4454
4455           $attachments = get_posts(
4456                array(
4457                     'post_type'      => 'attachment',
 
Line Code
4495           if ( ! $user ) {
4496                return $this->error;
4497           }
4498
4499           if ( ! current_user_can( 'edit_posts' ) ) {
4500                return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) );
4501           }
4502
4503           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
4504           do_action( 'xmlrpc_call', 'wp.getPostFormats', $args, $this );
4505
4506           $formats = get_post_format_strings();
4507
4508           // Find out if they want a list of currently supports formats.
4509           if ( isset( $args[3] ) && is_array( $args[3] ) ) {
4510                if ( $args[3]['show-supported'] ) {
4511                     if ( current_theme_supports( 'post-formats' ) ) {
4512                          $supported = get_theme_support( 'post-formats' );
4513
 
Line Code
4576                $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostType' );
4577           }
4578
4579           $user = $this->login( $username, $password );
4580           if ( ! $user ) {
4581                return $this->error;
4582           }
4583
4584           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
4585           do_action( 'xmlrpc_call', 'wp.getPostType', $args, $this );
4586
4587           if ( ! post_type_exists( $post_type_name ) ) {
4588                return new IXR_Error( 403, __( 'Invalid post type.' ) );
4589           }
4590
4591           $post_type = get_post_type_object( $post_type_name );
4592
4593           if ( ! current_user_can( $post_type->cap->edit_posts ) ) {
4594                return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts in this post type.' ) );
 
Line Code
4633                $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostTypes' );
4634           }
4635
4636           $user = $this->login( $username, $password );
4637           if ( ! $user ) {
4638                return $this->error;
4639           }
4640
4641           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
4642           do_action( 'xmlrpc_call', 'wp.getPostTypes', $args, $this );
4643
4644           $post_types = get_post_types( $filter, 'objects' );
4645
4646           $struct = array();
4647
4648           foreach ( $post_types as $post_type ) {
4649                if ( ! current_user_can( $post_type->cap->edit_posts ) ) {
4650                     continue;
4651                }
 
Line Code
4704                $fields = apply_filters( 'xmlrpc_default_revision_fields', array( 'post_date', 'post_date_gmt' ), 'wp.getRevisions' );
4705           }
4706
4707           $user = $this->login( $username, $password );
4708           if ( ! $user ) {
4709                return $this->error;
4710           }
4711
4712           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
4713           do_action( 'xmlrpc_call', 'wp.getRevisions', $args, $this );
4714
4715           $post = get_post( $post_id );
4716           if ( ! $post ) {
4717                return new IXR_Error( 404, __( 'Invalid post ID.' ) );
4718           }
4719
4720           if ( ! current_user_can( 'edit_post', $post_id ) ) {
4721                return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) );
4722           }
 
Line Code
4778           $password    = $args[2];
4779           $revision_id = (int) $args[3];
4780
4781           $user = $this->login( $username, $password );
4782           if ( ! $user ) {
4783                return $this->error;
4784           }
4785
4786           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
4787           do_action( 'xmlrpc_call', 'wp.restoreRevision', $args, $this );
4788
4789           $revision = wp_get_post_revision( $revision_id );
4790           if ( ! $revision ) {
4791                return new IXR_Error( 404, __( 'Invalid post ID.' ) );
4792           }
4793
4794           if ( wp_is_post_autosave( $revision ) ) {
4795                return new IXR_Error( 404, __( 'Invalid post ID.' ) );
4796           }
 
Line Code
4849           $username = $args[1];
4850           $password = $args[2];
4851
4852           $user = $this->login( $username, $password );
4853           if ( ! $user ) {
4854                return $this->error;
4855           }
4856
4857           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
4858           do_action( 'xmlrpc_call', 'blogger.getUsersBlogs', $args, $this );
4859
4860           $is_admin = current_user_can( 'manage_options' );
4861
4862           $struct = array(
4863                'isAdmin'  => $is_admin,
4864                'url'      => get_option( 'home' ) . '/',
4865                'blogid'   => '1',
4866                'blogName' => get_option( 'blogname' ),
4867                'xmlrpc'   => site_url( 'xmlrpc.php', 'rpc' ),
 
Line Code
4933           if ( ! $user ) {
4934                return $this->error;
4935           }
4936
4937           if ( ! current_user_can( 'edit_posts' ) ) {
4938                return new IXR_Error( 401, __( 'Sorry, you are not allowed to access user data on this site.' ) );
4939           }
4940
4941           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
4942           do_action( 'xmlrpc_call', 'blogger.getUserInfo', $args, $this );
4943
4944           $struct = array(
4945                'nickname'  => $user->nickname,
4946                'userid'    => $user->ID,
4947                'url'       => $user->user_url,
4948                'lastname'  => $user->last_name,
4949                'firstname' => $user->first_name,
4950           );
4951
 
Line Code
4983           if ( ! $post_data ) {
4984                return new IXR_Error( 404, __( 'Invalid post ID.' ) );
4985           }
4986
4987           if ( ! current_user_can( 'edit_post', $post_id ) ) {
4988                return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
4989           }
4990
4991           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
4992           do_action( 'xmlrpc_call', 'blogger.getPost', $args, $this );
4993
4994           $categories = implode( ',', wp_get_post_categories( $post_id ) );
4995
4996           $content  = '<title>' . wp_unslash( $post_data['post_title'] ) . '</title>';
4997           $content .= '<category>' . $categories . '</category>';
4998           $content .= wp_unslash( $post_data['post_content'] );
4999
5000           $struct = array(
5001                'userid'      => $post_data['post_author'],
 
Line Code
5040           if ( ! $user ) {
5041                return $this->error;
5042           }
5043
5044           if ( ! current_user_can( 'edit_posts' ) ) {
5045                return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) );
5046           }
5047
5048           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
5049           do_action( 'xmlrpc_call', 'blogger.getRecentPosts', $args, $this );
5050
5051           $posts_list = wp_get_recent_posts( $query );
5052
5053           if ( ! $posts_list ) {
5054                $this->error = new IXR_Error( 500, __( 'No posts found or an error occurred while retrieving posts.' ) );
5055                return $this->error;
5056           }
5057
5058           $recent_posts = array();
 
Line Code
5130           $content  = $args[4];
5131           $publish  = $args[5];
5132
5133           $user = $this->login( $username, $password );
5134           if ( ! $user ) {
5135                return $this->error;
5136           }
5137
5138           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
5139           do_action( 'xmlrpc_call', 'blogger.newPost', $args, $this );
5140
5141           $cap = ( $publish ) ? 'publish_posts' : 'edit_posts';
5142           if ( ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) || ! current_user_can( $cap ) ) {
5143                return new IXR_Error( 401, __( 'Sorry, you are not allowed to post on this site.' ) );
5144           }
5145
5146           $post_status = ( $publish ) ? 'publish' : 'draft';
5147
5148           $post_author = $user->ID;
 
Line Code
5215           $content  = $args[4];
5216           $publish  = $args[5];
5217
5218           $user = $this->login( $username, $password );
5219           if ( ! $user ) {
5220                return $this->error;
5221           }
5222
5223           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
5224           do_action( 'xmlrpc_call', 'blogger.editPost', $args, $this );
5225
5226           $actual_post = get_post( $post_id, ARRAY_A );
5227
5228           if ( ! $actual_post || 'post' !== $actual_post['post_type'] ) {
5229                return new IXR_Error( 404, __( 'Sorry, no such post.' ) );
5230           }
5231
5232           $this->escape( $actual_post );
5233
 
Line Code
5289           $username = $args[2];
5290           $password = $args[3];
5291
5292           $user = $this->login( $username, $password );
5293           if ( ! $user ) {
5294                return $this->error;
5295           }
5296
5297           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
5298           do_action( 'xmlrpc_call', 'blogger.deletePost', $args, $this );
5299
5300           $actual_post = get_post( $post_id, ARRAY_A );
5301
5302           if ( ! $actual_post || 'post' !== $actual_post['post_type'] ) {
5303                return new IXR_Error( 404, __( 'Sorry, no such post.' ) );
5304           }
5305
5306           if ( ! current_user_can( 'delete_post', $post_id ) ) {
5307                return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) );
 
Line Code
5377           $content_struct = $args[3];
5378           $publish        = isset( $args[4] ) ? $args[4] : 0;
5379
5380           $user = $this->login( $username, $password );
5381           if ( ! $user ) {
5382                return $this->error;
5383           }
5384
5385           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
5386           do_action( 'xmlrpc_call', 'metaWeblog.newPost', $args, $this );
5387
5388           $page_template = '';
5389           if ( ! empty( $content_struct['post_type'] ) ) {
5390                if ( 'page' === $content_struct['post_type'] ) {
5391                     if ( $publish ) {
5392                          $cap = 'publish_pages';
5393                     } elseif ( isset( $content_struct['page_status'] ) && 'publish' === $content_struct['page_status'] ) {
5394                          $cap = 'publish_pages';
5395                     } else {
 
Line Code
5773           $content_struct = $args[3];
5774           $publish        = isset( $args[4] ) ? $args[4] : 0;
5775
5776           $user = $this->login( $username, $password );
5777           if ( ! $user ) {
5778                return $this->error;
5779           }
5780
5781           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
5782           do_action( 'xmlrpc_call', 'metaWeblog.editPost', $args, $this );
5783
5784           $postdata = get_post( $post_id, ARRAY_A );
5785
5786           /*
5787            * If there is no post data for the give post ID, stop now and return an error.
5788            * Otherwise a new post will be created (which was the old behavior).
5789            */
5790           if ( ! $postdata || empty( $postdata['ID'] ) ) {
5791                return new IXR_Error( 404, __( 'Invalid post ID.' ) );
 
Line Code
6133           if ( ! $postdata ) {
6134                return new IXR_Error( 404, __( 'Invalid post ID.' ) );
6135           }
6136
6137           if ( ! current_user_can( 'edit_post', $post_id ) ) {
6138                return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
6139           }
6140
6141           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
6142           do_action( 'xmlrpc_call', 'metaWeblog.getPost', $args, $this );
6143
6144           if ( '' !== $postdata['post_date'] ) {
6145                $post_date         = $this->_convert_date( $postdata['post_date'] );
6146                $post_date_gmt     = $this->_convert_date_gmt( $postdata['post_date_gmt'], $postdata['post_date'] );
6147                $post_modified     = $this->_convert_date( $postdata['post_modified'] );
6148                $post_modified_gmt = $this->_convert_date_gmt( $postdata['post_modified_gmt'], $postdata['post_modified'] );
6149
6150                $categories = array();
6151                $cat_ids    = wp_get_post_categories( $post_id );
 
Line Code
6274           if ( ! $user ) {
6275                return $this->error;
6276           }
6277
6278           if ( ! current_user_can( 'edit_posts' ) ) {
6279                return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) );
6280           }
6281
6282           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
6283           do_action( 'xmlrpc_call', 'metaWeblog.getRecentPosts', $args, $this );
6284
6285           $posts_list = wp_get_recent_posts( $query );
6286
6287           if ( ! $posts_list ) {
6288                return array();
6289           }
6290
6291           $recent_posts = array();
6292           foreach ( $posts_list as $entry ) {
 
Line Code
6395           if ( ! $user ) {
6396                return $this->error;
6397           }
6398
6399           if ( ! current_user_can( 'edit_posts' ) ) {
6400                return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) );
6401           }
6402
6403           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
6404           do_action( 'xmlrpc_call', 'metaWeblog.getCategories', $args, $this );
6405
6406           $categories_struct = array();
6407
6408           $cats = get_categories( array( 'get' => 'all' ) );
6409           if ( $cats ) {
6410                foreach ( $cats as $cat ) {
6411                     $struct                        = array();
6412                     $struct['categoryId']          = $cat->term_id;
6413                     $struct['parentId']            = $cat->parent;
 
Line Code
6452           $type = $data['type'];
6453           $bits = $data['bits'];
6454
6455           $user = $this->login( $username, $password );
6456           if ( ! $user ) {
6457                return $this->error;
6458           }
6459
6460           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
6461           do_action( 'xmlrpc_call', 'metaWeblog.newMediaObject', $args, $this );
6462
6463           if ( ! current_user_can( 'upload_files' ) ) {
6464                $this->error = new IXR_Error( 401, __( 'Sorry, you are not allowed to upload files.' ) );
6465                return $this->error;
6466           }
6467
6468           if ( is_multisite() && upload_is_user_over_quota( false ) ) {
6469                $this->error = new IXR_Error(
6470                     401,
 
Line Code
6573                $query = array();
6574           }
6575
6576           $user = $this->login( $username, $password );
6577           if ( ! $user ) {
6578                return $this->error;
6579           }
6580
6581           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
6582           do_action( 'xmlrpc_call', 'mt.getRecentPostTitles', $args, $this );
6583
6584           $posts_list = wp_get_recent_posts( $query );
6585
6586           if ( ! $posts_list ) {
6587                $this->error = new IXR_Error( 500, __( 'No posts found or an error occurred while retrieving posts.' ) );
6588                return $this->error;
6589           }
6590
6591           $recent_posts = array();
 
Line Code
6635           if ( ! $user ) {
6636                return $this->error;
6637           }
6638
6639           if ( ! current_user_can( 'edit_posts' ) ) {
6640                return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) );
6641           }
6642
6643           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
6644           do_action( 'xmlrpc_call', 'mt.getCategoryList', $args, $this );
6645
6646           $categories_struct = array();
6647
6648           $cats = get_categories(
6649                array(
6650                     'hide_empty'   => 0,
6651                     'hierarchical' => 0,
6652                )
6653           );
 
Line Code
6693           if ( ! get_post( $post_id ) ) {
6694                return new IXR_Error( 404, __( 'Invalid post ID.' ) );
6695           }
6696
6697           if ( ! current_user_can( 'edit_post', $post_id ) ) {
6698                return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
6699           }
6700
6701           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
6702           do_action( 'xmlrpc_call', 'mt.getPostCategories', $args, $this );
6703
6704           $categories = array();
6705           $cat_ids    = wp_get_post_categories( (int) $post_id );
6706           // First listed category will be the primary category.
6707           $is_primary = true;
6708           foreach ( $cat_ids as $cat_id ) {
6709                $categories[] = array(
6710                     'categoryName' => get_cat_name( $cat_id ),
6711                     'categoryId'   => (string) $cat_id,
 
Line Code
6740           $password   = $args[2];
6741           $categories = $args[3];
6742
6743           $user = $this->login( $username, $password );
6744           if ( ! $user ) {
6745                return $this->error;
6746           }
6747
6748           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
6749           do_action( 'xmlrpc_call', 'mt.setPostCategories', $args, $this );
6750
6751           if ( ! get_post( $post_id ) ) {
6752                return new IXR_Error( 404, __( 'Invalid post ID.' ) );
6753           }
6754
6755           if ( ! current_user_can( 'edit_post', $post_id ) ) {
6756                return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
6757           }
6758
 
Line Code
6769      /**
6770       * Retrieves an array of methods supported by this server.
6771       *
6772       * @since 1.5.0
6773       *
6774       * @return array
6775       */
6776      public function mt_supportedMethods() {
6777           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
6778           do_action( 'xmlrpc_call', 'mt.supportedMethods', array(), $this );
6779
6780           return array_keys( $this->methods );
6781      }
6782
6783      /**
6784       * Retrieves an empty array because we don't support per-post text filters.
6785       *
6786       * @since 1.5.0
6787       */
6788      public function mt_supportedTextFilters() {
6789           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
6790           do_action( 'xmlrpc_call', 'mt.supportedTextFilters', array(), $this );
6791
6792           /**
6793            * Filters the MoveableType text filters list for XML-RPC.
6794            *
6795            * @since 2.2.0
6796            *
6797            * @param array $filters An array of text filters.
6798            */
6799           return apply_filters( 'xmlrpc_text_filters', array() );
 
Line Code
6807       * @global wpdb $wpdb WordPress database abstraction object.
6808       *
6809       * @param int $post_id
6810       * @return array|IXR_Error
6811       */
6812      public function mt_getTrackbackPings( $post_id ) {
6813           global $wpdb;
6814
6815           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
6816           do_action( 'xmlrpc_call', 'mt.getTrackbackPings', $post_id, $this );
6817
6818           $actual_post = get_post( $post_id, ARRAY_A );
6819
6820           if ( ! $actual_post ) {
6821                return new IXR_Error( 404, __( 'Sorry, no such post.' ) );
6822           }
6823
6824           $comments = $wpdb->get_results( $wpdb->prepare( "SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->comments WHERE comment_post_ID = %d", $post_id ) );
6825
 
Line Code
6864           $username = $args[1];
6865           $password = $args[2];
6866
6867           $user = $this->login( $username, $password );
6868           if ( ! $user ) {
6869                return $this->error;
6870           }
6871
6872           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
6873           do_action( 'xmlrpc_call', 'mt.publishPost', $args, $this );
6874
6875           $postdata = get_post( $post_id, ARRAY_A );
6876           if ( ! $postdata ) {
6877                return new IXR_Error( 404, __( 'Invalid post ID.' ) );
6878           }
6879
6880           if ( ! current_user_can( 'publish_posts' ) || ! current_user_can( 'edit_post', $post_id ) ) {
6881                return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish this post.' ) );
6882           }
 
Line Code
6908       *     @type string $0 URL of page linked from.
6909       *     @type string $1 URL of page linked to.
6910       * }
6911       * @return string|IXR_Error
6912       */
6913      public function pingback_ping( $args ) {
6914           global $wpdb;
6915
6916           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
6917           do_action( 'xmlrpc_call', 'pingback.ping', $args, $this );
6918
6919           $this->escape( $args );
6920
6921           $pagelinkedfrom = str_replace( '&amp;', '&', $args[0] );
6922           $pagelinkedto   = str_replace( '&amp;', '&', $args[1] );
6923           $pagelinkedto   = str_replace( '&', '&amp;', $pagelinkedto );
6924
6925           /**
6926            * Filters the pingback source URI.
 
Line Code
7165       * @global wpdb $wpdb WordPress database abstraction object.
7166       *
7167       * @param string $url
7168       * @return array|IXR_Error
7169       */
7170      public function pingback_extensions_getPingbacks( $url ) {
7171           global $wpdb;
7172
7173           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
7174           do_action( 'xmlrpc_call', 'pingback.extensions.getPingbacks', $url, $this );
7175
7176           $url = $this->escape( $url );
7177
7178           $post_id = url_to_postid( $url );
7179           if ( ! $post_id ) {
7180                // We aren't sure that the resource is available and/or pingback enabled.
7181                return $this->pingback_error( 33, __( 'The specified target URL cannot be used as a target. It either does not exist, or it is not a pingback-enabled resource.' ) );
7182           }
7183