wp_xmlrpc_server::get_term_custom_fields()publicWP 4.9.0

Retrieves custom fields for a term.

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

Хуков нет.

Возвращает

Массив. Array of custom fields, if they exist.

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

$wp_xmlrpc_server = new wp_xmlrpc_server();
$wp_xmlrpc_server->get_term_custom_fields( $term_id );
$term_id(int) (обязательный)
Term ID.

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

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

Код wp_xmlrpc_server::get_term_custom_fields() WP 6.6.2

public function get_term_custom_fields( $term_id ) {
	$term_id = (int) $term_id;

	$custom_fields = array();

	foreach ( (array) has_term_meta( $term_id ) as $meta ) {

		if ( ! current_user_can( 'edit_term_meta', $term_id ) ) {
			continue;
		}

		$custom_fields[] = array(
			'id'    => $meta['meta_id'],
			'key'   => $meta['meta_key'],
			'value' => $meta['meta_value'],
		);
	}

	return $custom_fields;
}