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

WC_AJAX::json_search_categories() public WC 1.0

Search for categories and return json.

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

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

Null. Ничего.

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

$result = WC_AJAX::json_search_categories();

Код WC_AJAX::json_search_categories() WC 4.7.1

<?php
public static function json_search_categories() {
	ob_start();

	check_ajax_referer( 'search-categories', 'security' );

	if ( ! current_user_can( 'edit_products' ) ) {
		wp_die( -1 );
	}

	$search_text = isset( $_GET['term'] ) ? wc_clean( wp_unslash( $_GET['term'] ) ) : '';

	if ( ! $search_text ) {
		wp_die();
	}

	$found_categories = array();
	$args             = array(
		'taxonomy'   => array( 'product_cat' ),
		'orderby'    => 'id',
		'order'      => 'ASC',
		'hide_empty' => true,
		'fields'     => 'all',
		'name__like' => $search_text,
	);

	$terms = get_terms( $args );

	if ( $terms ) {
		foreach ( $terms as $term ) {
			$term->formatted_name = '';

			if ( $term->parent ) {
				$ancestors = array_reverse( get_ancestors( $term->term_id, 'product_cat' ) );
				foreach ( $ancestors as $ancestor ) {
					$ancestor_term = get_term( $ancestor, 'product_cat' );
					if ( $ancestor_term ) {
						$term->formatted_name .= $ancestor_term->name . ' > ';
					}
				}
			}

			$term->formatted_name              .= $term->name . ' (' . $term->count . ')';
			$found_categories[ $term->term_id ] = $term;
		}
	}

	wp_send_json( apply_filters( 'woocommerce_json_search_found_categories', $found_categories ) );
}