Fix WC10: replace removed wc_get_catalog_ordering_args() with woocommerce_catalog_orderby filter

This commit is contained in:
2026-05-03 14:22:46 +00:00
parent 0af4efca33
commit 210a685630

View File

@@ -85,7 +85,15 @@ $orderby = isset($_GET['orderby']) ? sanitize_text_field($_GET['orderby']) : 'me
</button> </button>
<div class="rar-sort-menu" id="rar-sort-menu"> <div class="rar-sort-menu" id="rar-sort-menu">
<?php <?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; $current = (isset($_GET['orderby']) ? $_GET['orderby'] : get_option('woocommerce_default_catalog_orderby')) === $val;
$url = add_query_arg('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>'; 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>';