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
727            * equal to the method's name, e.g., wp.getUsersBlogs, wp.newPost, etc.
728            *
729            * @since 2.5.0
730            * @since 5.7.0 Added the `$args` and `$server` parameters.
731            *
732            * @param string           $name   The method name.
733            * @param array|string     $args   The escaped arguments passed to the method.
734            * @param wp_xmlrpc_server $server The XML-RPC server instance.
735            */
736           do_action( 'xmlrpc_call', 'wp.getUsersBlogs', $args, $this );
737
738           $blogs           = (array) get_blogs_of_user( $user->ID );
739           $struct          = array();
740           $primary_blog_id = 0;
741           $active_blog     = get_active_blog_for_user( $user->ID );
742           if ( $active_blog ) {
743                $primary_blog_id = (int) $active_blog->blog_id;
744           }
745
 
Line Code
1337           if ( isset( $content_struct['post_date_gmt'] ) && ! ( $content_struct['post_date_gmt'] instanceof IXR_Date ) ) {
1338                if ( '0000-00-00 00:00:00' === $content_struct['post_date_gmt'] || isset( $content_struct['post_date'] ) ) {
1339                     unset( $content_struct['post_date_gmt'] );
1340                } else {
1341                     $content_struct['post_date_gmt'] = $this->_convert_date( $content_struct['post_date_gmt'] );
1342                }
1343           }
1344
1345           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
1346           do_action( 'xmlrpc_call', 'wp.newPost', $args, $this );
1347
1348           unset( $content_struct['ID'] );
1349
1350           return $this->_insert_post( $user, $content_struct );
1351      }
1352
1353      /**
1354       * Helper method for filtering out elements from an array.
1355       *
 
Line Code
1738           $post_id        = (int) $args[3];
1739           $content_struct = $args[4];
1740
1741           $user = $this->login( $username, $password );
1742           if ( ! $user ) {
1743                return $this->error;
1744           }
1745
1746           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
1747           do_action( 'xmlrpc_call', 'wp.editPost', $args, $this );
1748
1749           $post = get_post( $post_id, ARRAY_A );
1750
1751           if ( empty( $post['ID'] ) ) {
1752                return new IXR_Error( 404, __( 'Invalid post ID.' ) );
1753           }
1754
1755           if ( isset( $content_struct['if_not_modified_since'] ) ) {
1756                // If the post has been modified since the date provided, return an error.
 
Line Code
1821           $password = $args[2];
1822           $post_id  = (int) $args[3];
1823
1824           $user = $this->login( $username, $password );
1825           if ( ! $user ) {
1826                return $this->error;
1827           }
1828
1829           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
1830           do_action( 'xmlrpc_call', 'wp.deletePost', $args, $this );
1831
1832           $post = get_post( $post_id, ARRAY_A );
1833           if ( empty( $post['ID'] ) ) {
1834                return new IXR_Error( 404, __( 'Invalid post ID.' ) );
1835           }
1836
1837           if ( ! current_user_can( 'delete_post', $post_id ) ) {
1838                return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) );
1839           }
 
Line Code
1922                $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPost' );
1923           }
1924
1925           $user = $this->login( $username, $password );
1926           if ( ! $user ) {
1927                return $this->error;
1928           }
1929
1930           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
1931           do_action( 'xmlrpc_call', 'wp.getPost', $args, $this );
1932
1933           $post = get_post( $post_id, ARRAY_A );
1934
1935           if ( empty( $post['ID'] ) ) {
1936                return new IXR_Error( 404, __( 'Invalid post ID.' ) );
1937           }
1938
1939           if ( ! current_user_can( 'edit_post', $post_id ) ) {
1940                return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
 
Line Code
1983                $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPosts' );
1984           }
1985
1986           $user = $this->login( $username, $password );
1987           if ( ! $user ) {
1988                return $this->error;
1989           }
1990
1991           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
1992           do_action( 'xmlrpc_call', 'wp.getPosts', $args, $this );
1993
1994           $query = array();
1995
1996           if ( isset( $filter['post_type'] ) ) {
1997                $post_type = get_post_type_object( $filter['post_type'] );
1998                if ( ! ( (bool) $post_type ) ) {
1999                     return new IXR_Error( 403, __( 'Invalid post type.' ) );
2000                }
2001           } else {
 
Line Code
2082           $password       = $args[2];
2083           $content_struct = $args[3];
2084
2085           $user = $this->login( $username, $password );
2086           if ( ! $user ) {
2087                return $this->error;
2088           }
2089
2090           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
2091           do_action( 'xmlrpc_call', 'wp.newTerm', $args, $this );
2092
2093           if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) {
2094                return new IXR_Error( 403, __( 'Invalid taxonomy.' ) );
2095           }
2096
2097           $taxonomy = get_taxonomy( $content_struct['taxonomy'] );
2098
2099           if ( ! current_user_can( $taxonomy->cap->edit_terms ) ) {
2100                return new IXR_Error( 401, __( 'Sorry, you are not allowed to create terms in this taxonomy.' ) );
 
Line Code
2187           $term_id        = (int) $args[3];
2188           $content_struct = $args[4];
2189
2190           $user = $this->login( $username, $password );
2191           if ( ! $user ) {
2192                return $this->error;
2193           }
2194
2195           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
2196           do_action( 'xmlrpc_call', 'wp.editTerm', $args, $this );
2197
2198           if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) {
2199                return new IXR_Error( 403, __( 'Invalid taxonomy.' ) );
2200           }
2201
2202           $taxonomy = get_taxonomy( $content_struct['taxonomy'] );
2203
2204           $taxonomy = (array) $taxonomy;
2205
 
Line Code
2303           $taxonomy = $args[3];
2304           $term_id  = (int) $args[4];
2305
2306           $user = $this->login( $username, $password );
2307           if ( ! $user ) {
2308                return $this->error;
2309           }
2310
2311           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
2312           do_action( 'xmlrpc_call', 'wp.deleteTerm', $args, $this );
2313
2314           if ( ! taxonomy_exists( $taxonomy ) ) {
2315                return new IXR_Error( 403, __( 'Invalid taxonomy.' ) );
2316           }
2317
2318           $taxonomy = get_taxonomy( $taxonomy );
2319           $term     = get_term( $term_id, $taxonomy->name );
2320
2321           if ( is_wp_error( $term ) ) {
 
Line Code
2382           $taxonomy = $args[3];
2383           $term_id  = (int) $args[4];
2384
2385           $user = $this->login( $username, $password );
2386           if ( ! $user ) {
2387                return $this->error;
2388           }
2389
2390           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
2391           do_action( 'xmlrpc_call', 'wp.getTerm', $args, $this );
2392
2393           if ( ! taxonomy_exists( $taxonomy ) ) {
2394                return new IXR_Error( 403, __( 'Invalid taxonomy.' ) );
2395           }
2396
2397           $taxonomy = get_taxonomy( $taxonomy );
2398
2399           $term = get_term( $term_id, $taxonomy->name, ARRAY_A );
2400
 
Line Code
2447           $taxonomy = $args[3];
2448           $filter   = isset( $args[4] ) ? $args[4] : array();
2449
2450           $user = $this->login( $username, $password );
2451           if ( ! $user ) {
2452                return $this->error;
2453           }
2454
2455           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
2456           do_action( 'xmlrpc_call', 'wp.getTerms', $args, $this );
2457
2458           if ( ! taxonomy_exists( $taxonomy ) ) {
2459                return new IXR_Error( 403, __( 'Invalid taxonomy.' ) );
2460           }
2461
2462           $taxonomy = get_taxonomy( $taxonomy );
2463
2464           if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) {
2465                return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ) );
 
Line Code
2554                $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomy' );
2555           }
2556
2557           $user = $this->login( $username, $password );
2558           if ( ! $user ) {
2559                return $this->error;
2560           }
2561
2562           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
2563           do_action( 'xmlrpc_call', 'wp.getTaxonomy', $args, $this );
2564
2565           if ( ! taxonomy_exists( $taxonomy ) ) {
2566                return new IXR_Error( 403, __( 'Invalid taxonomy.' ) );
2567           }
2568
2569           $taxonomy = get_taxonomy( $taxonomy );
2570
2571           if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) {
2572                return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ) );
 
Line Code
2612                $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomies' );
2613           }
2614
2615           $user = $this->login( $username, $password );
2616           if ( ! $user ) {
2617                return $this->error;
2618           }
2619
2620           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
2621           do_action( 'xmlrpc_call', 'wp.getTaxonomies', $args, $this );
2622
2623           $taxonomies = get_taxonomies( $filter, 'objects' );
2624
2625           // Holds all the taxonomy data.
2626           $struct = array();
2627
2628           foreach ( $taxonomies as $taxonomy ) {
2629                // Capability check for post types.
2630                if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) {
 
Line Code
2698                $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUser' );
2699           }
2700
2701           $user = $this->login( $username, $password );
2702           if ( ! $user ) {
2703                return $this->error;
2704           }
2705
2706           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
2707           do_action( 'xmlrpc_call', 'wp.getUser', $args, $this );
2708
2709           if ( ! current_user_can( 'edit_user', $user_id ) ) {
2710                return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this user.' ) );
2711           }
2712
2713           $user_data = get_userdata( $user_id );
2714
2715           if ( ! $user_data ) {
2716                return new IXR_Error( 404, __( 'Invalid user ID.' ) );
 
Line Code
2761                $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUsers' );
2762           }
2763
2764           $user = $this->login( $username, $password );
2765           if ( ! $user ) {
2766                return $this->error;
2767           }
2768
2769           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
2770           do_action( 'xmlrpc_call', 'wp.getUsers', $args, $this );
2771
2772           if ( ! current_user_can( 'list_users' ) ) {
2773                return new IXR_Error( 401, __( 'Sorry, you are not allowed to list users.' ) );
2774           }
2775
2776           $query = array( 'fields' => 'all_with_meta' );
2777
2778           $query['number'] = ( isset( $filter['number'] ) ) ? absint( $filter['number'] ) : 50;
2779           $query['offset'] = ( isset( $filter['offset'] ) ) ? absint( $filter['offset'] ) : 0;
 
Line Code
2841                $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getProfile' );
2842           }
2843
2844           $user = $this->login( $username, $password );
2845           if ( ! $user ) {
2846                return $this->error;
2847           }
2848
2849           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
2850           do_action( 'xmlrpc_call', 'wp.getProfile', $args, $this );
2851
2852           if ( ! current_user_can( 'edit_user', $user->ID ) ) {
2853                return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit your profile.' ) );
2854           }
2855
2856           $user_data = get_userdata( $user->ID );
2857
2858           return $this->_prepare_user( $user_data, $fields );
2859      }
 
Line Code
2891           $password       = $args[2];
2892           $content_struct = $args[3];
2893
2894           $user = $this->login( $username, $password );
2895           if ( ! $user ) {
2896                return $this->error;
2897           }
2898
2899           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
2900           do_action( 'xmlrpc_call', 'wp.editProfile', $args, $this );
2901
2902           if ( ! current_user_can( 'edit_user', $user->ID ) ) {
2903                return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit your profile.' ) );
2904           }
2905
2906           // Holds data of the user.
2907           $user_data       = array();
2908           $user_data['ID'] = $user->ID;
2909
 
Line Code
2980           if ( ! $page ) {
2981                return new IXR_Error( 404, __( 'Invalid post ID.' ) );
2982           }
2983
2984           if ( ! current_user_can( 'edit_page', $page_id ) ) {
2985                return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this page.' ) );
2986           }
2987
2988           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
2989           do_action( 'xmlrpc_call', 'wp.getPage', $args, $this );
2990
2991           // If we found the page then format the data.
2992           if ( $page->ID && ( 'page' === $page->post_type ) ) {
2993                return $this->_prepare_page( $page );
2994           } else {
2995                // If the page doesn't exist, indicate that.
2996                return new IXR_Error( 404, __( 'Sorry, no such page.' ) );
2997           }
2998      }
 
Line Code
3023           if ( ! $user ) {
3024                return $this->error;
3025           }
3026
3027           if ( ! current_user_can( 'edit_pages' ) ) {
3028                return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit pages.' ) );
3029           }
3030
3031           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
3032           do_action( 'xmlrpc_call', 'wp.getPages', $args, $this );
3033
3034           $pages     = get_posts(
3035                array(
3036                     'post_type'   => 'page',
3037                     'post_status' => 'any',
3038                     'numberposts' => $num_pages,
3039                )
3040           );
3041           $num_pages = count( $pages );
 
Line Code
3078           $username = $this->escape( $args[1] );
3079           $password = $this->escape( $args[2] );
3080
3081           $user = $this->login( $username, $password );
3082           if ( ! $user ) {
3083                return $this->error;
3084           }
3085
3086           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
3087           do_action( 'xmlrpc_call', 'wp.newPage', $args, $this );
3088
3089           // Mark this as content for a page.
3090           $args[3]['post_type'] = 'page';
3091
3092           // Let mw_newPost() do all of the heavy lifting.
3093           return $this->mw_newPost( $args );
3094      }
3095
3096      /**
 
Line Code
3115           $password = $args[2];
3116           $page_id  = (int) $args[3];
3117
3118           $user = $this->login( $username, $password );
3119           if ( ! $user ) {
3120                return $this->error;
3121           }
3122
3123           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
3124           do_action( 'xmlrpc_call', 'wp.deletePage', $args, $this );
3125
3126           /*
3127            * Get the current page based on the 'page_id' and
3128            * make sure it is a page and not a post.
3129            */
3130           $actual_page = get_post( $page_id, ARRAY_A );
3131           if ( ! $actual_page || ( 'page' !== $actual_page['post_type'] ) ) {
3132                return new IXR_Error( 404, __( 'Sorry, no such page.' ) );
3133           }
 
Line Code
3184           $escaped_username = $this->escape( $username );
3185           $escaped_password = $this->escape( $password );
3186
3187           $user = $this->login( $escaped_username, $escaped_password );
3188           if ( ! $user ) {
3189                return $this->error;
3190           }
3191
3192           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
3193           do_action( 'xmlrpc_call', 'wp.editPage', $args, $this );
3194
3195           // Get the page data and make sure it is a page.
3196           $actual_page = get_post( $page_id, ARRAY_A );
3197           if ( ! $actual_page || ( 'page' !== $actual_page['post_type'] ) ) {
3198                return new IXR_Error( 404, __( 'Sorry, no such page.' ) );
3199           }
3200
3201           // Make sure the user is allowed to edit pages.
3202           if ( ! current_user_can( 'edit_page', $page_id ) ) {
 
Line Code
3247           if ( ! $user ) {
3248                return $this->error;
3249           }
3250
3251           if ( ! current_user_can( 'edit_pages' ) ) {
3252                return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit pages.' ) );
3253           }
3254
3255           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
3256           do_action( 'xmlrpc_call', 'wp.getPageList', $args, $this );
3257
3258           // Get list of page IDs and titles.
3259           $page_list = $wpdb->get_results(
3260                "
3261                SELECT ID page_id,
3262                     post_title page_title,
3263                     post_parent page_parent_id,
3264                     post_date_gmt,
3265                     post_date,
 
Line Code
3308           if ( ! $user ) {
3309                return $this->error;
3310           }
3311
3312           if ( ! current_user_can( 'edit_posts' ) ) {
3313                return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) );
3314           }
3315
3316           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
3317           do_action( 'xmlrpc_call', 'wp.getAuthors', $args, $this );
3318
3319           $authors = array();
3320           foreach ( get_users( array( 'fields' => array( 'ID', 'user_login', 'display_name' ) ) ) as $user ) {
3321                $authors[] = array(
3322                     'user_id'      => $user->ID,
3323                     'user_login'   => $user->user_login,
3324                     'display_name' => $user->display_name,
3325                );
3326           }
 
Line Code
3352           if ( ! $user ) {
3353                return $this->error;
3354           }
3355
3356           if ( ! current_user_can( 'edit_posts' ) ) {
3357                return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view tags.' ) );
3358           }
3359
3360           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
3361           do_action( 'xmlrpc_call', 'wp.getKeywords', $args, $this );
3362
3363           $tags = array();
3364
3365           $all_tags = get_tags();
3366           if ( $all_tags ) {
3367                foreach ( (array) $all_tags as $tag ) {
3368                     $struct             = array();
3369                     $struct['tag_id']   = $tag->term_id;
3370                     $struct['name']     = $tag->name;
 
Line Code
3402           $password = $args[2];
3403           $category = $args[3];
3404
3405           $user = $this->login( $username, $password );
3406           if ( ! $user ) {
3407                return $this->error;
3408           }
3409
3410           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
3411           do_action( 'xmlrpc_call', 'wp.newCategory', $args, $this );
3412
3413           // Make sure the user is allowed to add a category.
3414           if ( ! current_user_can( 'manage_categories' ) ) {
3415                return new IXR_Error( 401, __( 'Sorry, you are not allowed to add a category.' ) );
3416           }
3417
3418           /*
3419            * If no slug was provided, make it empty
3420            * so that WordPress will generate one.
 
Line Code
3489           $password    = $args[2];
3490           $category_id = (int) $args[3];
3491
3492           $user = $this->login( $username, $password );
3493           if ( ! $user ) {
3494                return $this->error;
3495           }
3496
3497           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
3498           do_action( 'xmlrpc_call', 'wp.deleteCategory', $args, $this );
3499
3500           if ( ! current_user_can( 'delete_term', $category_id ) ) {
3501                return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this category.' ) );
3502           }
3503
3504           $status = wp_delete_term( $category_id, 'category' );
3505
3506           if ( true == $status ) {
3507                /**
 
Line Code
3546           if ( ! $user ) {
3547                return $this->error;
3548           }
3549
3550           if ( ! current_user_can( 'edit_posts' ) ) {
3551                return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) );
3552           }
3553
3554           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
3555           do_action( 'xmlrpc_call', 'wp.suggestCategories', $args, $this );
3556
3557           $category_suggestions = array();
3558           $args                 = array(
3559                'get'        => 'all',
3560                'number'     => $max_results,
3561                'name__like' => $category,
3562           );
3563           foreach ( (array) get_categories( $args ) as $cat ) {
3564                $category_suggestions[] = array(
 
Line Code
3592           $password   = $args[2];
3593           $comment_id = (int) $args[3];
3594
3595           $user = $this->login( $username, $password );
3596           if ( ! $user ) {
3597                return $this->error;
3598           }
3599
3600           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
3601           do_action( 'xmlrpc_call', 'wp.getComment', $args, $this );
3602
3603           $comment = get_comment( $comment_id );
3604           if ( ! $comment ) {
3605                return new IXR_Error( 404, __( 'Invalid comment ID.' ) );
3606           }
3607
3608           if ( ! current_user_can( 'edit_comment', $comment_id ) ) {
3609                return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) );
3610           }
 
Line Code
3648           $password = $args[2];
3649           $struct   = isset( $args[3] ) ? $args[3] : array();
3650
3651           $user = $this->login( $username, $password );
3652           if ( ! $user ) {
3653                return $this->error;
3654           }
3655
3656           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
3657           do_action( 'xmlrpc_call', 'wp.getComments', $args, $this );
3658
3659           if ( isset( $struct['status'] ) ) {
3660                $status = $struct['status'];
3661           } else {
3662                $status = '';
3663           }
3664
3665           if ( ! current_user_can( 'moderate_comments' ) && 'approve' !== $status ) {
3666                return new IXR_Error( 401, __( 'Invalid comment status.' ) );
 
Line Code
3743           if ( ! get_comment( $comment_id ) ) {
3744                return new IXR_Error( 404, __( 'Invalid comment ID.' ) );
3745           }
3746
3747           if ( ! current_user_can( 'edit_comment', $comment_id ) ) {
3748                return new IXR_Error( 403, __( 'Sorry, you are not allowed to delete this comment.' ) );
3749           }
3750
3751           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
3752           do_action( 'xmlrpc_call', 'wp.deleteComment', $args, $this );
3753
3754           $status = wp_delete_comment( $comment_id );
3755
3756           if ( $status ) {
3757                /**
3758                 * Fires after a comment has been successfully deleted via XML-RPC.
3759                 *
3760                 * @since 3.4.0
3761                 *
 
Line Code
3811           if ( ! get_comment( $comment_id ) ) {
3812                return new IXR_Error( 404, __( 'Invalid comment ID.' ) );
3813           }
3814
3815           if ( ! current_user_can( 'edit_comment', $comment_id ) ) {
3816                return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) );
3817           }
3818
3819           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
3820           do_action( 'xmlrpc_call', 'wp.editComment', $args, $this );
3821           $comment = array(
3822                'comment_ID' => $comment_id,
3823           );
3824
3825           if ( isset( $content_struct['status'] ) ) {
3826                $statuses = get_comment_statuses();
3827                $statuses = array_keys( $statuses );
3828
3829                if ( ! in_array( $content_struct['status'], $statuses, true ) ) {
 
Line Code
4004
4005           /** This filter is documented in wp-includes/comment.php */
4006           $allow_empty = apply_filters( 'allow_empty_comment', false, $comment );
4007
4008           if ( ! $allow_empty && '' === $comment['comment_content'] ) {
4009                return new IXR_Error( 403, __( 'Comment is required.' ) );
4010           }
4011
4012           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
4013           do_action( 'xmlrpc_call', 'wp.newComment', $args, $this );
4014
4015           $comment_id = wp_new_comment( $comment, true );
4016           if ( is_wp_error( $comment_id ) ) {
4017                return new IXR_Error( 403, $comment_id->get_error_message() );
4018           }
4019
4020           if ( ! $comment_id ) {
4021                return new IXR_Error( 403, __( 'Something went wrong.' ) );
4022           }
 
Line Code
4058           if ( ! $user ) {
4059                return $this->error;
4060           }
4061
4062           if ( ! current_user_can( 'publish_posts' ) ) {
4063                return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) );
4064           }
4065
4066           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
4067           do_action( 'xmlrpc_call', 'wp.getCommentStatusList', $args, $this );
4068
4069           return get_comment_statuses();
4070      }
4071
4072      /**
4073       * Retrieves comment counts.
4074       *
4075       * @since 2.5.0
4076       *
 
Line Code
4100           if ( empty( $post['ID'] ) ) {
4101                return new IXR_Error( 404, __( 'Invalid post ID.' ) );
4102           }
4103
4104           if ( ! current_user_can( 'edit_post', $post_id ) ) {
4105                return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details of this post.' ) );
4106           }
4107
4108           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
4109           do_action( 'xmlrpc_call', 'wp.getCommentCount', $args, $this );
4110
4111           $count = wp_count_comments( $post_id );
4112
4113           return array(
4114                'approved'            => $count->approved,
4115                'awaiting_moderation' => $count->moderated,
4116                'spam'                => $count->spam,
4117                'total_comments'      => $count->total_comments,
4118           );
 
Line Code
4142           if ( ! $user ) {
4143                return $this->error;
4144           }
4145
4146           if ( ! current_user_can( 'edit_posts' ) ) {
4147                return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) );
4148           }
4149
4150           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
4151           do_action( 'xmlrpc_call', 'wp.getPostStatusList', $args, $this );
4152
4153           return get_post_statuses();
4154      }
4155
4156      /**
4157       * Retrieves page statuses.
4158       *
4159       * @since 2.5.0
4160       *
 
Line Code
4177           if ( ! $user ) {
4178                return $this->error;
4179           }
4180
4181           if ( ! current_user_can( 'edit_pages' ) ) {
4182                return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) );
4183           }
4184
4185           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
4186           do_action( 'xmlrpc_call', 'wp.getPageStatusList', $args, $this );
4187
4188           return get_page_statuses();
4189      }
4190
4191      /**
4192       * Retrieves page templates.
4193       *
4194       * @since 2.6.0
4195       *
 
Line Code
4370           if ( ! $user ) {
4371                return $this->error;
4372           }
4373
4374           if ( ! current_user_can( 'upload_files' ) ) {
4375                return new IXR_Error( 403, __( 'Sorry, you are not allowed to upload files.' ) );
4376           }
4377
4378           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
4379           do_action( 'xmlrpc_call', 'wp.getMediaItem', $args, $this );
4380
4381           $attachment = get_post( $attachment_id );
4382           if ( ! $attachment || 'attachment' !== $attachment->post_type ) {
4383                return new IXR_Error( 404, __( 'Invalid attachment ID.' ) );
4384           }
4385
4386           return $this->_prepare_media_item( $attachment );
4387      }
4388
 
Line Code
4426           if ( ! $user ) {
4427                return $this->error;
4428           }
4429
4430           if ( ! current_user_can( 'upload_files' ) ) {
4431                return new IXR_Error( 401, __( 'Sorry, you are not allowed to upload files.' ) );
4432           }
4433
4434           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
4435           do_action( 'xmlrpc_call', 'wp.getMediaLibrary', $args, $this );
4436
4437           $parent_id = ( isset( $struct['parent_id'] ) ) ? absint( $struct['parent_id'] ) : '';
4438           $mime_type = ( isset( $struct['mime_type'] ) ) ? $struct['mime_type'] : '';
4439           $offset    = ( isset( $struct['offset'] ) ) ? absint( $struct['offset'] ) : 0;
4440           $number    = ( isset( $struct['number'] ) ) ? absint( $struct['number'] ) : -1;
4441
4442           $attachments = get_posts(
4443                array(
4444                     'post_type'      => 'attachment',
 
Line Code
4482           if ( ! $user ) {
4483                return $this->error;
4484           }
4485
4486           if ( ! current_user_can( 'edit_posts' ) ) {
4487                return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) );
4488           }
4489
4490           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
4491           do_action( 'xmlrpc_call', 'wp.getPostFormats', $args, $this );
4492
4493           $formats = get_post_format_strings();
4494
4495           // Find out if they want a list of currently supports formats.
4496           if ( isset( $args[3] ) && is_array( $args[3] ) ) {
4497                if ( $args[3]['show-supported'] ) {
4498                     if ( current_theme_supports( 'post-formats' ) ) {
4499                          $supported = get_theme_support( 'post-formats' );
4500
 
Line Code
4563                $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostType' );
4564           }
4565
4566           $user = $this->login( $username, $password );
4567           if ( ! $user ) {
4568                return $this->error;
4569           }
4570
4571           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
4572           do_action( 'xmlrpc_call', 'wp.getPostType', $args, $this );
4573
4574           if ( ! post_type_exists( $post_type_name ) ) {
4575                return new IXR_Error( 403, __( 'Invalid post type.' ) );
4576           }
4577
4578           $post_type = get_post_type_object( $post_type_name );
4579
4580           if ( ! current_user_can( $post_type->cap->edit_posts ) ) {
4581                return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts in this post type.' ) );
 
Line Code
4620                $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostTypes' );
4621           }
4622
4623           $user = $this->login( $username, $password );
4624           if ( ! $user ) {
4625                return $this->error;
4626           }
4627
4628           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
4629           do_action( 'xmlrpc_call', 'wp.getPostTypes', $args, $this );
4630
4631           $post_types = get_post_types( $filter, 'objects' );
4632
4633           $struct = array();
4634
4635           foreach ( $post_types as $post_type ) {
4636                if ( ! current_user_can( $post_type->cap->edit_posts ) ) {
4637                     continue;
4638                }
 
Line Code
4691                $fields = apply_filters( 'xmlrpc_default_revision_fields', array( 'post_date', 'post_date_gmt' ), 'wp.getRevisions' );
4692           }
4693
4694           $user = $this->login( $username, $password );
4695           if ( ! $user ) {
4696                return $this->error;
4697           }
4698
4699           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
4700           do_action( 'xmlrpc_call', 'wp.getRevisions', $args, $this );
4701
4702           $post = get_post( $post_id );
4703           if ( ! $post ) {
4704                return new IXR_Error( 404, __( 'Invalid post ID.' ) );
4705           }
4706
4707           if ( ! current_user_can( 'edit_post', $post_id ) ) {
4708                return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) );
4709           }
 
Line Code
4765           $password    = $args[2];
4766           $revision_id = (int) $args[3];
4767
4768           $user = $this->login( $username, $password );
4769           if ( ! $user ) {
4770                return $this->error;
4771           }
4772
4773           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
4774           do_action( 'xmlrpc_call', 'wp.restoreRevision', $args, $this );
4775
4776           $revision = wp_get_post_revision( $revision_id );
4777           if ( ! $revision ) {
4778                return new IXR_Error( 404, __( 'Invalid post ID.' ) );
4779           }
4780
4781           if ( wp_is_post_autosave( $revision ) ) {
4782                return new IXR_Error( 404, __( 'Invalid post ID.' ) );
4783           }
 
Line Code
4836           $username = $args[1];
4837           $password = $args[2];
4838
4839           $user = $this->login( $username, $password );
4840           if ( ! $user ) {
4841                return $this->error;
4842           }
4843
4844           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
4845           do_action( 'xmlrpc_call', 'blogger.getUsersBlogs', $args, $this );
4846
4847           $is_admin = current_user_can( 'manage_options' );
4848
4849           $struct = array(
4850                'isAdmin'  => $is_admin,
4851                'url'      => get_option( 'home' ) . '/',
4852                'blogid'   => '1',
4853                'blogName' => get_option( 'blogname' ),
4854                'xmlrpc'   => site_url( 'xmlrpc.php', 'rpc' ),
 
Line Code
4920           if ( ! $user ) {
4921                return $this->error;
4922           }
4923
4924           if ( ! current_user_can( 'edit_posts' ) ) {
4925                return new IXR_Error( 401, __( 'Sorry, you are not allowed to access user data on this site.' ) );
4926           }
4927
4928           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
4929           do_action( 'xmlrpc_call', 'blogger.getUserInfo', $args, $this );
4930
4931           $struct = array(
4932                'nickname'  => $user->nickname,
4933                'userid'    => $user->ID,
4934                'url'       => $user->user_url,
4935                'lastname'  => $user->last_name,
4936                'firstname' => $user->first_name,
4937           );
4938
 
Line Code
4970           if ( ! $post_data ) {
4971                return new IXR_Error( 404, __( 'Invalid post ID.' ) );
4972           }
4973
4974           if ( ! current_user_can( 'edit_post', $post_id ) ) {
4975                return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
4976           }
4977
4978           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
4979           do_action( 'xmlrpc_call', 'blogger.getPost', $args, $this );
4980
4981           $categories = implode( ',', wp_get_post_categories( $post_id ) );
4982
4983           $content  = '<title>' . wp_unslash( $post_data['post_title'] ) . '</title>';
4984           $content .= '<category>' . $categories . '</category>';
4985           $content .= wp_unslash( $post_data['post_content'] );
4986
4987           $struct = array(
4988                'userid'      => $post_data['post_author'],
 
Line Code
5027           if ( ! $user ) {
5028                return $this->error;
5029           }
5030
5031           if ( ! current_user_can( 'edit_posts' ) ) {
5032                return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) );
5033           }
5034
5035           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
5036           do_action( 'xmlrpc_call', 'blogger.getRecentPosts', $args, $this );
5037
5038           $posts_list = wp_get_recent_posts( $query );
5039
5040           if ( ! $posts_list ) {
5041                $this->error = new IXR_Error( 500, __( 'Either there are no posts, or something went wrong.' ) );
5042                return $this->error;
5043           }
5044
5045           $recent_posts = array();
 
Line Code
5117           $content  = $args[4];
5118           $publish  = $args[5];
5119
5120           $user = $this->login( $username, $password );
5121           if ( ! $user ) {
5122                return $this->error;
5123           }
5124
5125           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
5126           do_action( 'xmlrpc_call', 'blogger.newPost', $args, $this );
5127
5128           $cap = ( $publish ) ? 'publish_posts' : 'edit_posts';
5129           if ( ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) || ! current_user_can( $cap ) ) {
5130                return new IXR_Error( 401, __( 'Sorry, you are not allowed to post on this site.' ) );
5131           }
5132
5133           $post_status = ( $publish ) ? 'publish' : 'draft';
5134
5135           $post_author = $user->ID;
 
Line Code
5194           $content  = $args[4];
5195           $publish  = $args[5];
5196
5197           $user = $this->login( $username, $password );
5198           if ( ! $user ) {
5199                return $this->error;
5200           }
5201
5202           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
5203           do_action( 'xmlrpc_call', 'blogger.editPost', $args, $this );
5204
5205           $actual_post = get_post( $post_id, ARRAY_A );
5206
5207           if ( ! $actual_post || 'post' !== $actual_post['post_type'] ) {
5208                return new IXR_Error( 404, __( 'Sorry, no such post.' ) );
5209           }
5210
5211           $this->escape( $actual_post );
5212
 
Line Code
5268           $username = $args[2];
5269           $password = $args[3];
5270
5271           $user = $this->login( $username, $password );
5272           if ( ! $user ) {
5273                return $this->error;
5274           }
5275
5276           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
5277           do_action( 'xmlrpc_call', 'blogger.deletePost', $args, $this );
5278
5279           $actual_post = get_post( $post_id, ARRAY_A );
5280
5281           if ( ! $actual_post || 'post' !== $actual_post['post_type'] ) {
5282                return new IXR_Error( 404, __( 'Sorry, no such post.' ) );
5283           }
5284
5285           if ( ! current_user_can( 'delete_post', $post_id ) ) {
5286                return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) );
 
Line Code
5356           $content_struct = $args[3];
5357           $publish        = isset( $args[4] ) ? $args[4] : 0;
5358
5359           $user = $this->login( $username, $password );
5360           if ( ! $user ) {
5361                return $this->error;
5362           }
5363
5364           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
5365           do_action( 'xmlrpc_call', 'metaWeblog.newPost', $args, $this );
5366
5367           $page_template = '';
5368           if ( ! empty( $content_struct['post_type'] ) ) {
5369                if ( 'page' === $content_struct['post_type'] ) {
5370                     if ( $publish ) {
5371                          $cap = 'publish_pages';
5372                     } elseif ( isset( $content_struct['page_status'] ) && 'publish' === $content_struct['page_status'] ) {
5373                          $cap = 'publish_pages';
5374                     } else {
 
Line Code
5733           $content_struct = $args[3];
5734           $publish        = isset( $args[4] ) ? $args[4] : 0;
5735
5736           $user = $this->login( $username, $password );
5737           if ( ! $user ) {
5738                return $this->error;
5739           }
5740
5741           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
5742           do_action( 'xmlrpc_call', 'metaWeblog.editPost', $args, $this );
5743
5744           $postdata = get_post( $post_id, ARRAY_A );
5745
5746           /*
5747            * If there is no post data for the give post ID, stop now and return an error.
5748            * Otherwise a new post will be created (which was the old behavior).
5749            */
5750           if ( ! $postdata || empty( $postdata['ID'] ) ) {
5751                return new IXR_Error( 404, __( 'Invalid post ID.' ) );
 
Line Code
6070           if ( ! $postdata ) {
6071                return new IXR_Error( 404, __( 'Invalid post ID.' ) );
6072           }
6073
6074           if ( ! current_user_can( 'edit_post', $post_id ) ) {
6075                return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
6076           }
6077
6078           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
6079           do_action( 'xmlrpc_call', 'metaWeblog.getPost', $args, $this );
6080
6081           if ( '' !== $postdata['post_date'] ) {
6082                $post_date         = $this->_convert_date( $postdata['post_date'] );
6083                $post_date_gmt     = $this->_convert_date_gmt( $postdata['post_date_gmt'], $postdata['post_date'] );
6084                $post_modified     = $this->_convert_date( $postdata['post_modified'] );
6085                $post_modified_gmt = $this->_convert_date_gmt( $postdata['post_modified_gmt'], $postdata['post_modified'] );
6086
6087                $categories = array();
6088                $catids     = wp_get_post_categories( $post_id );
 
Line Code
6211           if ( ! $user ) {
6212                return $this->error;
6213           }
6214
6215           if ( ! current_user_can( 'edit_posts' ) ) {
6216                return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) );
6217           }
6218
6219           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
6220           do_action( 'xmlrpc_call', 'metaWeblog.getRecentPosts', $args, $this );
6221
6222           $posts_list = wp_get_recent_posts( $query );
6223
6224           if ( ! $posts_list ) {
6225                return array();
6226           }
6227
6228           $recent_posts = array();
6229           foreach ( $posts_list as $entry ) {
 
Line Code
6332           if ( ! $user ) {
6333                return $this->error;
6334           }
6335
6336           if ( ! current_user_can( 'edit_posts' ) ) {
6337                return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) );
6338           }
6339
6340           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
6341           do_action( 'xmlrpc_call', 'metaWeblog.getCategories', $args, $this );
6342
6343           $categories_struct = array();
6344
6345           $cats = get_categories( array( 'get' => 'all' ) );
6346           if ( $cats ) {
6347                foreach ( $cats as $cat ) {
6348                     $struct                        = array();
6349                     $struct['categoryId']          = $cat->term_id;
6350                     $struct['parentId']            = $cat->parent;
 
Line Code
6393           $type = $data['type'];
6394           $bits = $data['bits'];
6395
6396           $user = $this->login( $username, $password );
6397           if ( ! $user ) {
6398                return $this->error;
6399           }
6400
6401           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
6402           do_action( 'xmlrpc_call', 'metaWeblog.newMediaObject', $args, $this );
6403
6404           if ( ! current_user_can( 'upload_files' ) ) {
6405                $this->error = new IXR_Error( 401, __( 'Sorry, you are not allowed to upload files.' ) );
6406                return $this->error;
6407           }
6408
6409           if ( is_multisite() && upload_is_user_over_quota( false ) ) {
6410                $this->error = new IXR_Error(
6411                     401,
 
Line Code
6512                $query = array();
6513           }
6514
6515           $user = $this->login( $username, $password );
6516           if ( ! $user ) {
6517                return $this->error;
6518           }
6519
6520           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
6521           do_action( 'xmlrpc_call', 'mt.getRecentPostTitles', $args, $this );
6522
6523           $posts_list = wp_get_recent_posts( $query );
6524
6525           if ( ! $posts_list ) {
6526                $this->error = new IXR_Error( 500, __( 'Either there are no posts, or something went wrong.' ) );
6527                return $this->error;
6528           }
6529
6530           $recent_posts = array();
 
Line Code
6574           if ( ! $user ) {
6575                return $this->error;
6576           }
6577
6578           if ( ! current_user_can( 'edit_posts' ) ) {
6579                return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) );
6580           }
6581
6582           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
6583           do_action( 'xmlrpc_call', 'mt.getCategoryList', $args, $this );
6584
6585           $categories_struct = array();
6586
6587           $cats = get_categories(
6588                array(
6589                     'hide_empty'   => 0,
6590                     'hierarchical' => 0,
6591                )
6592           );
 
Line Code
6632           if ( ! get_post( $post_id ) ) {
6633                return new IXR_Error( 404, __( 'Invalid post ID.' ) );
6634           }
6635
6636           if ( ! current_user_can( 'edit_post', $post_id ) ) {
6637                return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
6638           }
6639
6640           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
6641           do_action( 'xmlrpc_call', 'mt.getPostCategories', $args, $this );
6642
6643           $categories = array();
6644           $catids     = wp_get_post_categories( (int) $post_id );
6645           // First listed category will be the primary category.
6646           $isPrimary = true;
6647           foreach ( $catids as $catid ) {
6648                $categories[] = array(
6649                     'categoryName' => get_cat_name( $catid ),
6650                     'categoryId'   => (string) $catid,
 
Line Code
6679           $password   = $args[2];
6680           $categories = $args[3];
6681
6682           $user = $this->login( $username, $password );
6683           if ( ! $user ) {
6684                return $this->error;
6685           }
6686
6687           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
6688           do_action( 'xmlrpc_call', 'mt.setPostCategories', $args, $this );
6689
6690           if ( ! get_post( $post_id ) ) {
6691                return new IXR_Error( 404, __( 'Invalid post ID.' ) );
6692           }
6693
6694           if ( ! current_user_can( 'edit_post', $post_id ) ) {
6695                return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
6696           }
6697
 
Line Code
6708      /**
6709       * Retrieves an array of methods supported by this server.
6710       *
6711       * @since 1.5.0
6712       *
6713       * @return array
6714       */
6715      public function mt_supportedMethods() {
6716           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
6717           do_action( 'xmlrpc_call', 'mt.supportedMethods', array(), $this );
6718
6719           return array_keys( $this->methods );
6720      }
6721
6722      /**
6723       * Retrieves an empty array because we don't support per-post text filters.
6724       *
6725       * @since 1.5.0
6726       */
6727      public function mt_supportedTextFilters() {
6728           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
6729           do_action( 'xmlrpc_call', 'mt.supportedTextFilters', array(), $this );
6730
6731           /**
6732            * Filters the MoveableType text filters list for XML-RPC.
6733            *
6734            * @since 2.2.0
6735            *
6736            * @param array $filters An array of text filters.
6737            */
6738           return apply_filters( 'xmlrpc_text_filters', array() );
 
Line Code
6746       * @global wpdb $wpdb WordPress database abstraction object.
6747       *
6748       * @param int $post_id
6749       * @return array|IXR_Error
6750       */
6751      public function mt_getTrackbackPings( $post_id ) {
6752           global $wpdb;
6753
6754           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
6755           do_action( 'xmlrpc_call', 'mt.getTrackbackPings', $post_id, $this );
6756
6757           $actual_post = get_post( $post_id, ARRAY_A );
6758
6759           if ( ! $actual_post ) {
6760                return new IXR_Error( 404, __( 'Sorry, no such post.' ) );
6761           }
6762
6763           $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 ) );
6764
 
Line Code
6803           $username = $args[1];
6804           $password = $args[2];
6805
6806           $user = $this->login( $username, $password );
6807           if ( ! $user ) {
6808                return $this->error;
6809           }
6810
6811           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
6812           do_action( 'xmlrpc_call', 'mt.publishPost', $args, $this );
6813
6814           $postdata = get_post( $post_id, ARRAY_A );
6815           if ( ! $postdata ) {
6816                return new IXR_Error( 404, __( 'Invalid post ID.' ) );
6817           }
6818
6819           if ( ! current_user_can( 'publish_posts' ) || ! current_user_can( 'edit_post', $post_id ) ) {
6820                return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish this post.' ) );
6821           }
 
Line Code
6847       *     @type string $0 URL of page linked from.
6848       *     @type string $1 URL of page linked to.
6849       * }
6850       * @return string|IXR_Error
6851       */
6852      public function pingback_ping( $args ) {
6853           global $wpdb;
6854
6855           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
6856           do_action( 'xmlrpc_call', 'pingback.ping', $args, $this );
6857
6858           $this->escape( $args );
6859
6860           $pagelinkedfrom = str_replace( '&amp;', '&', $args[0] );
6861           $pagelinkedto   = str_replace( '&amp;', '&', $args[1] );
6862           $pagelinkedto   = str_replace( '&', '&amp;', $pagelinkedto );
6863
6864           /**
6865            * Filters the pingback source URI.
 
Line Code
7091       * @global wpdb $wpdb WordPress database abstraction object.
7092       *
7093       * @param string $url
7094       * @return array|IXR_Error
7095       */
7096      public function pingback_extensions_getPingbacks( $url ) {
7097           global $wpdb;
7098
7099           /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
7100           do_action( 'xmlrpc_call', 'pingback.extensions.getPingbacks', $url, $this );
7101
7102           $url = $this->escape( $url );
7103
7104           $post_id = url_to_postid( $url );
7105           if ( ! $post_id ) {
7106                // We aren't sure that the resource is available and/or pingback enabled.
7107                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.' ) );
7108           }
7109