Changeset 3301019
- Timestamp:
- 05/26/2025 10:18:16 PM (10 months ago)
- Location:
- b2bking-wholesale-for-woocommerce/trunk
- Files:
-
- 3 edited
-
b2bking.php (modified) (3 diffs)
-
includes/class-b2bking-global-helper.php (modified) (1 diff)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
b2bking-wholesale-for-woocommerce/trunk/b2bking.php
r3137054 r3301019 5 5 * Plugin URI: https://codecanyon.net/item/b2bking-the-ultimate-woocommerce-b2b-plugin/26689576 6 6 * Description: B2BKing is the complete solution for turning WooCommerce into an enterprise-level B2B e-commerce platform. Core Plugin. 7 * Version: 4. 7.107 * Version: 4.8.00 8 8 * Author: WebWizards 9 9 * Author URI: webwizards.dev … … 11 11 * Domain Path: /languages 12 12 * WC requires at least: 5.0.0 13 * WC tested up to: 9. 1.413 * WC tested up to: 9.8.4 14 14 */ 15 15 … … 21 21 define( 'B2BKINGCORE_DIR', plugin_dir_path( __FILE__ ) ); 22 22 if ( ! defined( 'B2BKINGCORE_VERSION' ) ) { 23 define( 'B2BKINGCORE_VERSION', 'v4. 7.10');23 define( 'B2BKINGCORE_VERSION', 'v4.8.00'); 24 24 } 25 25 -
b2bking-wholesale-for-woocommerce/trunk/includes/class-b2bking-global-helper.php
r3124512 r3301019 233 233 234 234 return false; 235 } 236 237 public static function safe_get_queried_object_id() { 238 global $wp_query; 239 if ($wp_query !== null && is_object($wp_query) && method_exists($wp_query, 'get_queried_object_id')) { 240 return get_queried_object_id(); 241 } 242 return 0; 243 } 244 245 public static function force_purge_caches(){ 246 // Try common actions 247 do_action('wp_cache_clear_cache'); 248 do_action('cache_cleared'); 249 do_action('wp_cache_flush'); 250 do_action( 'litespeed_purge_all' ); 251 252 // Try specific plugins 253 if (function_exists('rocket_clean_domain')) { 254 rocket_clean_domain(); 255 } 256 257 if (function_exists('w3tc_pgcache_flush')) { 258 w3tc_pgcache_flush(); 259 } 260 261 if (function_exists('wp_cache_clear_cache')) { 262 wp_cache_clear_cache(); 263 } 264 265 if (class_exists('LiteSpeed_Cache_API')) { 266 LiteSpeed_Cache_API::purge_all(); 267 } 268 269 270 // WP Fastest Cache 271 if (class_exists('WpFastestCache')) { 272 $cache = new WpFastestCache(); 273 $cache->deleteCache(true); 274 } 275 } 276 277 // Check function - validates against highest number in log 278 public static function check_visibility_cache_integrity($cache_product_ids) { 279 280 // disable for now 281 return $cache_product_ids; 282 283 284 if (!$cache_product_ids) { 285 // cache is false, will regenerate, nothing to do here 286 return $cache_product_ids; 287 } 288 289 $use_cache_integrity_checks = get_option('b2bking_use_cache_integrity_checks', 0); 290 if (intval($use_cache_integrity_checks) === 0) { 291 return $cache_product_ids; 292 } 293 294 // proceed with cache checks 295 296 // get current user 297 $currentuserid = get_current_user_id(); 298 $account_type = get_user_meta($currentuserid, 'b2bking_account_type', true); 299 if ($account_type === 'subaccount') { 300 // for all intents and purposes set current user as the subaccount parent 301 $parent_user_id = get_user_meta($currentuserid, 'b2bking_account_parent', true); 302 $currentuserid = $parent_user_id; 303 } 304 // get current count 305 $product_ids_count = count($cache_product_ids); 306 307 // if current page shows nothing found, clear site cache, but do not invalidate current ajax visibility cache 308 if (is_shop() || is_product_category()) { 309 global $wp_query; 310 if ($wp_query->post_count === 0) { 311 b2bking()->force_purge_caches(); 312 313 $cache_product_ids = false; 314 } 315 } 316 317 // get current ajax visibility cache 318 $visibility_cache_db = get_transient('b2bking_user_'.$currentuserid.'_ajax_visibility'); 319 $user_cache_integrity_log = get_option('b2bking_cache_integrity_log' . $currentuserid, false); 320 321 // If no log exists yet, assume cache is valid 322 if (!is_array($user_cache_integrity_log) || empty($user_cache_integrity_log)) { 323 return $cache_product_ids; 324 } 325 326 // get the highest recorded log 327 $highest_count = max($user_cache_integrity_log); 328 $current_count_db = count($visibility_cache_db); 329 330 // if current visibility in DB is more than 100 less than highest ever recorded, invalidate DB cache 331 if (abs($current_count_db - $highest_count) > 100) { 332 delete_transient('b2bking_user_'.$currentuserid.'_ajax_visibility'); 333 334 if (apply_filters('b2bking_flush_cache_wp', true)){ 335 wp_cache_flush(); 336 } 337 } 338 339 340 return $cache_product_ids; 341 } 342 343 // Update function - only called when generating fresh values 344 public static function update_visibility_integrity_log($product_ids) { 345 $use_cache_integrity_checks = get_option('b2bking_use_cache_integrity_checks', 0); 346 if (intval($use_cache_integrity_checks) === 0) { 347 return; 348 } 349 350 // Proceed only if we have products (avoid logging zero values from corrupt generations) 351 $product_ids_count = count($product_ids); 352 $min_expected_products = intval(get_option('b2bking_min_expected_products', 100)); 353 if ($product_ids_count < $min_expected_products) { 354 return; // Don't log potentially corrupted values 355 } 356 357 // get current user id 358 $currentuserid = get_current_user_id(); 359 $account_type = get_user_meta($currentuserid, 'b2bking_account_type', true); 360 if ($account_type === 'subaccount') { 361 // for all intents and purposes set current user as the subaccount parent 362 $parent_user_id = get_user_meta($currentuserid, 'b2bking_account_parent', true); 363 $currentuserid = $parent_user_id; 364 } 365 366 // get current products count 367 $user_cache_integrity_log = get_option('b2bking_cache_integrity_log' . $currentuserid, false); 368 369 // if no log exists, create it 370 if (!is_array($user_cache_integrity_log)) { 371 $user_cache_integrity_log = array($product_ids_count); 372 } else { 373 // if log exists, add latest number to log and if log is higher than 10000 items, cut out the first (oldest) numbers 374 $user_cache_integrity_log[] = $product_ids_count; 375 while (count($user_cache_integrity_log) > 50000) { 376 array_shift($user_cache_integrity_log); 377 } 378 } 379 380 // save log 381 update_option('b2bking_cache_integrity_log' . $currentuserid, $user_cache_integrity_log); 235 382 } 236 383 -
b2bking-wholesale-for-woocommerce/trunk/readme.txt
r3269157 r3301019 9 9 Tested up to: 6.8 10 10 Requires PHP: 5.6.20 11 Stable tag: 4. 7.1012 Version: 4. 7.1011 Stable tag: 4.8.00 12 Version: 4.8.00 13 13 License: GPLv2 or later 14 14 License URI: http://www.gnu.org/licenses/gpl-2.0.html
Note: See TracChangeset
for help on using the changeset viewer.