Fix WC10: replace removed wc_get_catalog_ordering_args() with woocommerce_catalog_orderby filter
This commit is contained in:
@@ -85,7 +85,15 @@ $orderby = isset($_GET['orderby']) ? sanitize_text_field($_GET['orderby']) : 'me
|
||||
</button>
|
||||
<div class="rar-sort-menu" id="rar-sort-menu">
|
||||
<?php
|
||||
foreach (wc_get_catalog_ordering_args() as $val => $opt) {
|
||||
$ordering_options = apply_filters('woocommerce_catalog_orderby', [
|
||||
'menu_order' => __('Default sorting', 'woocommerce'),
|
||||
'popularity' => __('Sort by popularity', 'woocommerce'),
|
||||
'rating' => __('Sort by average rating', 'woocommerce'),
|
||||
'date' => __('Sort by latest', 'woocommerce'),
|
||||
'price' => __('Sort by price: low to high', 'woocommerce'),
|
||||
'price-desc' => __('Sort by price: high to low', 'woocommerce'),
|
||||
]);
|
||||
foreach ($ordering_options as $val => $opt) {
|
||||
$current = (isset($_GET['orderby']) ? $_GET['orderby'] : get_option('woocommerce_default_catalog_orderby')) === $val;
|
||||
$url = add_query_arg('orderby', $val);
|
||||
echo '<a href="' . esc_url($url) . '" class="' . ($current ? 'active' : '') . '" onclick="document.getElementById(\'rar-sort-label\').textContent=this.textContent;document.getElementById(\'rar-sort-menu\').classList.remove(\'open\');">' . esc_html($opt) . '</a>';
|
||||
|
||||
Reference in New Issue
Block a user