wp_xmlrpc_server::wp_getTaxonomies()publicWP 3.4.0

Retrieves all taxonomies.

Метод класса: wp_xmlrpc_server{}

Хуки из метода

Возвращает

Массив|IXR_Error. An associative array of taxonomy data with returned fields determined by $fields, or an IXR_Error instance on failure.

Использование

$wp_xmlrpc_server = new wp_xmlrpc_server();
$wp_xmlrpc_server->wp_getTaxonomies( $args );
$args(массив) (обязательный)

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

  • 0(int)
    Blog ID (unused).

  • 1(строка)
    Username.

  • 2(строка)
    Password.

  • 3(массив)
    Optional. An array of arguments for retrieving taxonomies.

  • 4(массив)
    Optional. The subset of taxonomy fields to return.

Заметки

Список изменений

С версии 3.4.0 Введена.

Код wp_xmlrpc_server::wp_getTaxonomies() WP 6.6.2

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;
}