PluginUs.Net - Business Tools for WooCommerce and WordPress

[realize your idea - make your dreams come true]

Support Forum

You need to log-in to create request (topic) to the support

Insert filter hook

The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday. If you have problems with registration ask help on contact us page please
If you not got email within 24~36 business hours, firstly check your spam box, and if no any email from the support there - back to the forum and read answer here. DO NOT ANSWER ON EMAILS [noreply@pluginus.net] FROM THE FORUM!! Emails are just for your info, all answers should be published only here.
The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday.

Hello,

My site has enormous number of attributes, and because of that, the WOOF admin options page often breaks and not loading due to memory leakage.

I created a simple filter to limit the number of taxonomies displayed. I would really appreciate if you could implement in your next update.

In /woocommerce-products-filter/index.php 1330. row:

return apply_filters('woof_filter_taxonomies',$taxonomies);

INSTEAD OF

return $taxonomies;

Thank you,

Hello

Thank you for cooperation, hook added into the code and after next update will be added into documentation site ...

One only moment please:

⚠️ CRITICAL WARNING: Any taxonomies you filter out using this hook will have their settings PERMANENTLY DELETED when you click Save on the WOOF settings page. Example: If you filter to show only 50 out of 1000 taxonomies and click Save, all settings for the other 950 taxonomies will be lost forever. This happens because WordPress forms only save data that is present on the page.

Be care with data please ...

 

Perfect, thank you!

Yes I experienced that all other taxonomy settings are lost when I clicked save. It is not a problem for me, because the displayed taxonomies in my case won't be filtered by number, but specifically list all that are allowed. Because all other taxonomies won't be used for filters. So in my case, the code looks like this:

add_filter('woof_filter_taxonomies', 'woof_filter_taxonomies');
function woof_filter_taxonomies( $taxonomies ) {
    $allowed_taxonomies = [ 'attribute1', 'attribute2' ];
    foreach ( $taxonomies as $slug => $taxonomy ) {
        if ( str_starts_with( $slug, 'pa_' ) ) {
            $pure_slug = substr( $slug, strlen( 'pa_' ) );
            if ( !in_array( $pure_slug, $allowed_taxonomies ) ) {
                unset($taxonomies[$slug]);
            }
        }
    }
    return $taxonomies;
}

Thanks,

Sándor

Hello Sandor

Very well! Thank you for your cooperation!