Code Duplication    Length = 40-40 lines in 2 locations

src/wp-includes/class-wp-xmlrpc-server.php 2 locations

@@ 2353-2392 (lines=40) @@
2350
	 * }
2351
	 * @return array|IXR_Error An array of taxonomy data on success, IXR_Error instance otherwise.
2352
	 */
2353
	public function wp_getTaxonomy( $args ) {
2354
		if ( ! $this->minimum_args( $args, 4 ) )
2355
			return $this->error;
2356
2357
		$this->escape( $args );
2358
2359
		$username = $args[1];
2360
		$password = $args[2];
2361
		$taxonomy = $args[3];
2362
2363
		if ( isset( $args[4] ) ) {
2364
			$fields = $args[4];
2365
		} else {
2366
			/**
2367
			 * Filters the taxonomy query fields used by the given XML-RPC method.
2368
			 *
2369
			 * @since 3.4.0
2370
			 *
2371
			 * @param array  $fields An array of taxonomy fields to retrieve.
2372
			 * @param string $method The method name.
2373
			 */
2374
			$fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomy' );
2375
		}
2376
2377
		if ( ! $user = $this->login( $username, $password ) )
2378
			return $this->error;
2379
2380
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
2381
		do_action( 'xmlrpc_call', 'wp.getTaxonomy' );
2382
2383
		if ( ! taxonomy_exists( $taxonomy ) )
2384
			return new IXR_Error( 403, __( 'Invalid taxonomy.' ) );
2385
2386
		$taxonomy = get_taxonomy( $taxonomy );
2387
2388
		if ( ! current_user_can( $taxonomy->cap->assign_terms ) )
2389
			return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ) );
2390
2391
		return $this->_prepare_taxonomy( $taxonomy, $fields );
2392
	}
2393
2394
	/**
2395
	 * Retrieve all taxonomies.
@@ 4182-4221 (lines=40) @@
4179
	 *  - 'taxonomies'
4180
	 *  - 'supports'
4181
	 */
4182
	public function wp_getPostType( $args ) {
4183
		if ( ! $this->minimum_args( $args, 4 ) )
4184
			return $this->error;
4185
4186
		$this->escape( $args );
4187
4188
		$username       = $args[1];
4189
		$password       = $args[2];
4190
		$post_type_name = $args[3];
4191
4192
		if ( isset( $args[4] ) ) {
4193
			$fields = $args[4];
4194
		} else {
4195
			/**
4196
			 * Filters the default query fields used by the given XML-RPC method.
4197
			 *
4198
			 * @since 3.4.0
4199
			 *
4200
			 * @param array  $fields An array of post type query fields for the given method.
4201
			 * @param string $method The method name.
4202
			 */
4203
			$fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostType' );
4204
		}
4205
4206
		if ( !$user = $this->login( $username, $password ) )
4207
			return $this->error;
4208
4209
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
4210
		do_action( 'xmlrpc_call', 'wp.getPostType' );
4211
4212
		if ( ! post_type_exists( $post_type_name ) )
4213
			return new IXR_Error( 403, __( 'Invalid post type.' ) );
4214
4215
		$post_type = get_post_type_object( $post_type_name );
4216
4217
		if ( ! current_user_can( $post_type->cap->edit_posts ) )
4218
			return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts in this post type.' ) );
4219
4220
		return $this->_prepare_post_type( $post_type, $fields );
4221
	}
4222
4223
	/**
4224
	 * Retrieves a post types