wp_xmlrpc_server::wp_getTaxonomy()publicWP 3.4.0

Retrieves a taxonomy.

Method of the class: wp_xmlrpc_server{}

Return

Array|IXR_Error. An array of taxonomy data on success, IXR_Error instance otherwise.

Usage

$wp_xmlrpc_server = new wp_xmlrpc_server();
$wp_xmlrpc_server->wp_getTaxonomy( $args );
$args(array) (required)

Method arguments. Note: arguments must be ordered as documented.

  • 0(int)
    Blog ID (unused).

  • 1(string)
    Username.

  • 2(string)
    Password.

  • 3(string)
    Taxonomy name.

  • 4(array)
    Optional. Array of taxonomy fields to limit to in the return. Accepts 'labels', 'cap', 'menu', and 'object_type'.
    Default: empty array

Notes

Changelog

Since 3.4.0 Introduced.

wp_xmlrpc_server::wp_getTaxonomy() code WP 6.6.2

public function wp_getTaxonomy( $args ) {
	if ( ! $this->minimum_args( $args, 4 ) ) {
		return $this->error;
	}

	$this->escape( $args );

	$username = $args[1];
	$password = $args[2];
	$taxonomy = $args[3];

	if ( isset( $args[4] ) ) {
		$fields = $args[4];
	} else {
		/**
		 * Filters the default taxonomy query fields used by the given XML-RPC method.
		 *
		 * @since 3.4.0
		 *
		 * @param array  $fields An array of taxonomy fields to retrieve. By default,
		 *                       contains 'labels', 'cap', and 'object_type'.
		 * @param string $method The method name.
		 */
		$fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomy' );
	}

	$user = $this->login( $username, $password );
	if ( ! $user ) {
		return $this->error;
	}

	/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
	do_action( 'xmlrpc_call', 'wp.getTaxonomy', $args, $this );

	if ( ! taxonomy_exists( $taxonomy ) ) {
		return new IXR_Error( 403, __( 'Invalid taxonomy.' ) );
	}

	$taxonomy = get_taxonomy( $taxonomy );

	if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) {
		return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ) );
	}

	return $this->_prepare_taxonomy( $taxonomy, $fields );
}