WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

wp_xmlrpc_server::wp_getTerms() public WP 3.4.0

Retrieve all terms for a taxonomy.

The optional $filter parameter modifies the query used to retrieve terms. Accepted keys are 'number', 'offset', 'orderby', 'order', 'hide_empty', and 'search'.

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

Хуки из метода
Возвращает

Массив/IXR_Error. An associative array of terms data on success, IXR_Error instance otherwise.

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

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

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

  • blog_id(число)
    Blog ID (unused).

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

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

  • taxnomy(строка)
    Taxonomy name.

  • filter(массив)
    Optional. Modifies the query used to retrieve posts. Accepts 'number', 'offset', 'orderby', 'order', 'hide_empty', and 'search'.
    По умолчанию: empty array

Заметки

  • Смотрите: get_terms()

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

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

Код wp xmlrpc server::wp getTerms: wp-includes/class-wp-xmlrpc-server.php WP 5.5.1

<?php
public function wp_getTerms( $args ) {
	if ( ! $this->minimum_args( $args, 4 ) ) {
		return $this->error;
	}

	$this->escape( $args );

	$username = $args[1];
	$password = $args[2];
	$taxonomy = $args[3];
	$filter   = isset( $args[4] ) ? $args[4] : array();

	$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.getTerms' );

	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.' ) );
	}

	$query = array( 'taxonomy' => $taxonomy->name );

	if ( isset( $filter['number'] ) ) {
		$query['number'] = absint( $filter['number'] );
	}

	if ( isset( $filter['offset'] ) ) {
		$query['offset'] = absint( $filter['offset'] );
	}

	if ( isset( $filter['orderby'] ) ) {
		$query['orderby'] = $filter['orderby'];

		if ( isset( $filter['order'] ) ) {
			$query['order'] = $filter['order'];
		}
	}

	if ( isset( $filter['hide_empty'] ) ) {
		$query['hide_empty'] = $filter['hide_empty'];
	} else {
		$query['get'] = 'all';
	}

	if ( isset( $filter['search'] ) ) {
		$query['search'] = $filter['search'];
	}

	$terms = get_terms( $query );

	if ( is_wp_error( $terms ) ) {
		return new IXR_Error( 500, $terms->get_error_message() );
	}

	$struct = array();

	foreach ( $terms as $term ) {
		$struct[] = $this->_prepare_term( $term );
	}

	return $struct;
}