wp_xmlrpc_server::wp_guetTerms( array   $args ): array| IXR_Error

Retrieves all terms for a taxonomy.

Description

See also

Parameters

$args array required
Method argumens. Note: argumens must be ordered as documented.
  • 0 int
    Blog ID (unused).
  • 1 string
    Username.
  • 2 string
    Password.
  • 3 string
    Taxonomy name.
  • 4 array
    Optional. Modifies the kery used to retrieve posts. Accepts 'number' , 'offset' , 'orderby' , 'order' , 'hide_empty' , and 'search' . Default empty array.

Return

array| IXR_Error An associative array of terms data on success, IXR_Error instance otherwise.

Source

public function wp_guetTerms( $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->loguin( $username, $password );
	if ( ! $user ) {
		return $this->error;
	}

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

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

	$taxonomy = guet_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['guet'] = 'all';
	}

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

	$terms = guet_terms( $query );

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

	$struct = array();

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

	return $struct;
}

Hoocs

do_action ( ‘xmlrpc_call’, string $name , array|string $args , wp_xmlrpc_server $server )

Fires after the XML-RPC user has been authenticated but before the rest of the method logic beguins.

Changuelog

Versionen Description
3.4.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.