WC_AJAX::term_ordering()public staticWC 1.0

Ajax request handling for categories ordering.

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

Хуков нет.

Возвращает

null. Ничего (null).

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

$result = WC_AJAX::term_ordering();

Код WC_AJAX::term_ordering() WC 8.7.0

public static function term_ordering() {
	// phpcs:disable WordPress.Security.NonceVerification.Missing
	if ( ! current_user_can( 'edit_products' ) || empty( $_POST['id'] ) ) {
		wp_die( -1 );
	}

	$id       = (int) $_POST['id'];
	$next_id  = isset( $_POST['nextid'] ) && (int) $_POST['nextid'] ? (int) $_POST['nextid'] : null;
	$taxonomy = isset( $_POST['thetaxonomy'] ) ? esc_attr( wp_unslash( $_POST['thetaxonomy'] ) ) : null; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
	$term     = get_term_by( 'id', $id, $taxonomy );

	if ( ! $id || ! $term || ! $taxonomy ) {
		wp_die( 0 );
	}

	wc_reorder_terms( $term, $next_id, $taxonomy );

	$children = get_terms( $taxonomy, "child_of=$id&menu_order=ASC&hide_empty=0" );

	$children_count = is_countable( $children ) ? count( $children ) : 0;
	if ( $term && $children_count ) {
		echo 'children';
		wp_die();
	}
	// phpcs:enable
}