wp_xmlrpc_server::wp_getTaxonomies() WordPress Method

The wp_xmlrpc_server::wp_getTaxonomies() method gets a list of taxonomies for a given post type. It takes two parameters: $post_type: (string) The post type for which to get the taxonomies. $args: (array) Optional. An array of arguments. This method returns an array of taxonomy objects.

wp_xmlrpc_server::wp_getTaxonomies( array $args ) #

Retrieve all taxonomies.


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.
  • 'filter'
    (array) Optional. An array of arguments for retrieving taxonomies.
  • 'fields'
    (array) Optional. The subset of taxonomy fields to return.


Top ↑

Return

(array|IXR_Error) An associative array of taxonomy data with returned fields determined by $fields, or an IXR_Error instance on failure.


Top ↑

Source

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

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

		$this->escape( $args );

		$username = $args[1];
		$password = $args[2];
		$filter   = isset( $args[3] ) ? $args[3] : array( 'public' => true );

		if ( isset( $args[4] ) ) {
			$fields = $args[4];
		} else {
			/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
			$fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomies' );
		}

		$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.getTaxonomies', $args, $this );

		$taxonomies = get_taxonomies( $filter, 'objects' );

		// Holds all the taxonomy data.
		$struct = array();

		foreach ( $taxonomies as $taxonomy ) {
			// Capability check for post types.
			if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) {
				continue;
			}

			$struct[] = $this->_prepare_taxonomy( $taxonomy, $fields );
		}

		return $struct;
	}


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