@@ 2261-2300 (lines=40) @@ | ||
2258 | * } |
|
2259 | * @return array|IXR_Error An array of taxonomy data on success, IXR_Error instance otherwise. |
|
2260 | */ |
|
2261 | public function wp_getTaxonomy( $args ) { |
|
2262 | if ( ! $this->minimum_args( $args, 4 ) ) |
|
2263 | return $this->error; |
|
2264 | ||
2265 | $this->escape( $args ); |
|
2266 | ||
2267 | $username = $args[1]; |
|
2268 | $password = $args[2]; |
|
2269 | $taxonomy = $args[3]; |
|
2270 | ||
2271 | if ( isset( $args[4] ) ) { |
|
2272 | $fields = $args[4]; |
|
2273 | } else { |
|
2274 | /** |
|
2275 | * Filters the taxonomy query fields used by the given XML-RPC method. |
|
2276 | * |
|
2277 | * @since 3.4.0 |
|
2278 | * |
|
2279 | * @param array $fields An array of taxonomy fields to retrieve. |
|
2280 | * @param string $method The method name. |
|
2281 | */ |
|
2282 | $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomy' ); |
|
2283 | } |
|
2284 | ||
2285 | if ( ! $user = $this->login( $username, $password ) ) |
|
2286 | return $this->error; |
|
2287 | ||
2288 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
|
2289 | do_action( 'xmlrpc_call', 'wp.getTaxonomy' ); |
|
2290 | ||
2291 | if ( ! taxonomy_exists( $taxonomy ) ) |
|
2292 | return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); |
|
2293 | ||
2294 | $taxonomy = get_taxonomy( $taxonomy ); |
|
2295 | ||
2296 | if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) |
|
2297 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ) ); |
|
2298 | ||
2299 | return $this->_prepare_taxonomy( $taxonomy, $fields ); |
|
2300 | } |
|
2301 | ||
2302 | /** |
|
2303 | * Retrieve all taxonomies. |
|
@@ 4075-4114 (lines=40) @@ | ||
4072 | * - 'taxonomies' |
|
4073 | * - 'supports' |
|
4074 | */ |
|
4075 | public function wp_getPostType( $args ) { |
|
4076 | if ( ! $this->minimum_args( $args, 4 ) ) |
|
4077 | return $this->error; |
|
4078 | ||
4079 | $this->escape( $args ); |
|
4080 | ||
4081 | $username = $args[1]; |
|
4082 | $password = $args[2]; |
|
4083 | $post_type_name = $args[3]; |
|
4084 | ||
4085 | if ( isset( $args[4] ) ) { |
|
4086 | $fields = $args[4]; |
|
4087 | } else { |
|
4088 | /** |
|
4089 | * Filters the default query fields used by the given XML-RPC method. |
|
4090 | * |
|
4091 | * @since 3.4.0 |
|
4092 | * |
|
4093 | * @param array $fields An array of post type query fields for the given method. |
|
4094 | * @param string $method The method name. |
|
4095 | */ |
|
4096 | $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostType' ); |
|
4097 | } |
|
4098 | ||
4099 | if ( !$user = $this->login( $username, $password ) ) |
|
4100 | return $this->error; |
|
4101 | ||
4102 | /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ |
|
4103 | do_action( 'xmlrpc_call', 'wp.getPostType' ); |
|
4104 | ||
4105 | if ( ! post_type_exists( $post_type_name ) ) |
|
4106 | return new IXR_Error( 403, __( 'Invalid post type.' ) ); |
|
4107 | ||
4108 | $post_type = get_post_type_object( $post_type_name ); |
|
4109 | ||
4110 | if ( ! current_user_can( $post_type->cap->edit_posts ) ) |
|
4111 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post type.' ) ); |
|
4112 | ||
4113 | return $this->_prepare_post_type( $post_type, $fields ); |
|
4114 | } |
|
4115 | ||
4116 | /** |
|
4117 | * Retrieves a post types |