HUSKY - Product Filter for WooCommerce

woof_counter_method

用于开发人员关于动态重新计数中内存过载的实验。

  • 此钩子在此文件中使用: wp-content\plugins\woocommerce-products-filter\classes\counter.php
  • __constructor of class WP_QueryWoofCounter
  • When this hook returns TRUE in WP_Query attributes is added: nopaging=false 和 posts_per_page=1 – 在某些情况下,这有助于减少内存消耗,但并非对所有网站都有效。

从 v.1.1.8/2.1.8 开始

 

参数

$saving_memory (bool) — 默认为 false

源文件

classes/counter.php

代码示例


add_filter('woof_counter_method', function($saving_memory) {
    // Enable memory-saving counter mode (may be less accurate but faster)
    return true;
});

使用说明

  • 将此代码添加到您的主题的 functions.php 文件或自定义插件中。
  • 此 hook 在过滤过程中应用 — 更改立即生效。
  • 始终从回调函数返回预期值类型。