Inventory_Presser_Taxonomies::sort_terms_as_numbers( string $order_by, array $args, string[] $taxonomies )
Makes sure that taxonomy terms that are numbers are sorted as numbers.
On This Page
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.
Return Return
(string) The changed ORDERBY clause of the terms query
Source Source
File: includes/class-taxonomies.php
public function sort_terms_as_numbers( $order_by, $args, $taxonomies ) {
if ( '' === $order_by ) {
return $order_by;
}
if ( null === $taxonomies ) {
return $order_by;
}
$taxonomies_to_sort = array(
'cylinders',
'model_year',
);
foreach ( $taxonomies_to_sort as $taxonomy_to_sort ) {
if ( in_array( $taxonomy_to_sort, $taxonomies, true ) ) {
$order_by .= '+0';
break;
}
}
return $order_by;
}
Expand full source codeCollapse full source codeView on Github