wp_xmlrpc_server::wp_getTaxonomy() WordPress Method

This method is used to retrieve a taxonomy. The first parameter is the taxonomy name. The second parameter is an array of arguments. The following arguments are supported: 'hide_empty' - Whether to hide empty terms (default is true). 'fields' - Which fields to return (default is all fields). 'name' - The 'name' field to return (default is 'name'). This method returns an array of taxonomy data.

wp_xmlrpc_server::wp_getTaxonomy( array $args ) #

Retrieve a taxonomy.


Description

Top ↑

See also


Top ↑

Parameters

$args

(array)(Required)Method arguments. Note: arguments must be ordered as documented.

  • 'blog_id'
    (int) Blog ID (unused).
  • 'username'
    (string) Username.
  • 'password'
    (string) Password.
  • 'taxonomy'
    (string) Taxonomy name.
  • 'fields'
    (array) Optional. Array of taxonomy fields to limit to in the return. Accepts 'labels', 'cap', 'menu', and 'object_type'. Default empty array.


Top ↑

Return

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


Top ↑

Source

File: wp-includes/class-wp-xmlrpc-server.php

	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 taxonomy query fields used by the given XML-RPC method.
			 *
			 * @since 3.4.0
			 *
			 * @param array  $fields An array of taxonomy fields to retrieve.
			 * @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 );
	}


Top ↑

Changelog

Changelog
VersionDescription
3.4.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More