Inventory_Presser_Taxonomies::sort_terms_as_numbers( string $order_by, array $args, string[] $taxonomies )

sort_terms_as_numbers


Description Description

Makes sure that taxonomy terms that are numbers are sorted as numbers.


Top ↑

Parameters Parameters

$order_by

(string) (Required) ORDERBY clause of the terms query.

$args

(array) (Required) An array of term query arguments.

$taxonomies

(string[]) (Required) An array of taxonomy names.


Top ↑

Return Return

(string) The changed ORDERBY clause of the terms query


Top ↑

Source Source

File: includes/class-taxonomies.php

	function sort_terms_as_numbers( $order_by, $args, $taxonomies )
	{
		if( '' == $order_by ) { return ''; }

		$taxonomies_to_sort = array(
			'cylinders',
			'model_year',
		);
		foreach( $taxonomies_to_sort as $taxonomy_to_sort )
		{
			if( in_array( $taxonomy_to_sort, $taxonomies ) )
			{
				$order_by .=  '+0';
				break;
			}
		}
		return $order_by;
	}