wp_xmlrpc_server::wp_getTaxonomy
Retrieves a taxonomy.
Метод класса: wp_xmlrpc_server{}
Хуки из метода
Возвращает
Массив|IXR_Error. An array of taxonomy data on success, IXR_Error instance otherwise.
Использование
$wp_xmlrpc_server = new wp_xmlrpc_server(); $wp_xmlrpc_server->wp_getTaxonomy( $args );
- $args(массив) (обязательный)
Method arguments. Note: arguments must be ordered as documented.
-
0(int)
Blog ID (unused). -
1(строка)
Username. -
2(строка)
Password. -
3(строка)
Taxonomy name. - 4(массив)
Optional. Array of taxonomy fields to limit to in the return. Accepts 'labels', 'cap', 'menu', and 'object_type'.
По умолчанию: empty array
-
Заметки
- Смотрите: get_taxonomy()
Список изменений
| С версии 3.4.0 | Введена. |
Код wp_xmlrpc_server::wp_getTaxonomy() wp xmlrpc server::wp getTaxonomy WP 7.0
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 default taxonomy query fields used by the given XML-RPC method.
*
* @since 3.4.0
*
* @param array $fields An array of taxonomy fields to retrieve. By default,
* contains 'labels', 'cap', and 'object_type'.
* @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 );
}