| @@ -14,9 +14,8 @@ | ||
| 14 | 14 | |
| 15 | 15 | |
| 16 | 16 | use RadiusTheme\SB\Dependencies\CodesVault\Howdyqb\DB; |
| 17 | 17 | use DateTime; |
| 18 | -use WP_Query; | |
| 19 | 18 | use WP_Styles; |
| 20 | 19 | use WC_Product; |
| 21 | 20 | use Elementor\Plugin; |
| 22 | 21 | use WC_Product_Query; |
| @@ -37,45 +36,9 @@ | ||
| 37 | 36 | /** |
| 38 | 37 | * @var array |
| 39 | 38 | */ |
| 40 | 39 | private static $cache = []; |
| 41 | - | |
| 42 | 40 | /** |
| 43 | - * Whether asset bundling failed during this request. | |
| 44 | - * | |
| 45 | - * Set by AssetRegistry when AssetBundler::build() cannot produce a file, for | |
| 46 | - * example on the first request after a plugin upgrade while the autoloader | |
| 47 | - * still points at the removed files, or when the cache directory turns out | |
| 48 | - * not to be writable. Once set, is_optimization_enabled() reports false for | |
| 49 | - * the remainder of the request so the callers register and enqueue the plain | |
| 50 | - * unbundled assets instead of a stylesheet handle with an empty source. | |
| 51 | - * | |
| 52 | - * Request scoped on purpose: it must not be persisted, the next request | |
| 53 | - * retries the build. | |
| 54 | - * | |
| 55 | - * @var bool | |
| 56 | - */ | |
| 57 | - private static $optimization_unavailable = false; | |
| 58 | - | |
| 59 | - /** | |
| 60 | - * Flag that a bundle could not be produced during this request. | |
| 61 | - * | |
| 62 | - * @return void | |
| 63 | - */ | |
| 64 | - public static function mark_optimization_unavailable() { | |
| 65 | - self::$optimization_unavailable = true; | |
| 66 | - } | |
| 67 | - | |
| 68 | - /** | |
| 69 | - * Whether bundling has been marked unavailable for this request. | |
| 70 | - * | |
| 71 | - * @return bool | |
| 72 | - */ | |
| 73 | - public static function is_optimization_unavailable() { | |
| 74 | - return self::$optimization_unavailable; | |
| 75 | - } | |
| 76 | - | |
| 77 | - /** | |
| 78 | 41 | * Check if the stored license is valid. Its Only Show Pro Label. |
| 79 | 42 | * |
| 80 | 43 | * @return bool |
| 81 | 44 | */ |
| @@ -280,20 +243,10 @@ | ||
| 280 | 243 | * |
| 281 | 244 | * @return array|false|mixed |
| 282 | 245 | */ |
| 283 | 246 | public static function get_all_user_roles() { |
| 284 | - // Memoized because the settings schema asks for the role list several | |
| 285 | - // times per request, and the miss path require_once()s an admin-only | |
| 286 | - // WordPress file. The static also covers the legitimate empty-result | |
| 287 | - // case, which wp_cache_get() alone cannot distinguish from a miss. | |
| 288 | - static $memo = null; | |
| 289 | - | |
| 290 | - if ( null !== $memo ) { | |
| 291 | - return $memo; | |
| 292 | - } | |
| 293 | - | |
| 294 | 247 | $cache_key = 'rtsb_get_user_roles'; |
| 295 | - $roles = wp_cache_get( $cache_key, Cache::group() ); | |
| 248 | + $roles = wp_cache_get( $cache_key, 'shopbuilder' ); | |
| 296 | 249 | |
| 297 | 250 | if ( empty( $roles ) ) { |
| 298 | 251 | if ( ! function_exists( 'get_editable_roles' ) ) { |
| 299 | 252 | require_once ABSPATH . 'wp-admin/includes/user.php'; |
| @@ -307,18 +260,12 @@ | ||
| 307 | 260 | continue; |
| 308 | 261 | } |
| 309 | 262 | $roles[ $key ] = $role['name']; |
| 310 | 263 | } |
| 311 | - | |
| 312 | - // Only prime the object cache on a miss. Re-writing it on every hit | |
| 313 | - // also re-appended the key to the tracked data-cache index. | |
| 314 | - wp_cache_set( $cache_key, $roles, Cache::group(), 12 * HOUR_IN_SECONDS ); | |
| 315 | - Cache::set_data_cache_key( $cache_key ); | |
| 316 | 264 | } |
| 317 | - | |
| 318 | - $memo = $roles; | |
| 319 | - | |
| 320 | - return $memo; | |
| 265 | + wp_cache_set( $cache_key, $roles, 'shopbuilder' ); | |
| 266 | + Cache::set_data_cache_key( $cache_key ); | |
| 267 | + return $roles; | |
| 321 | 268 | } |
| 322 | 269 | |
| 323 | 270 | /** |
| 324 | 271 | * Stripslashes value. |
| @@ -464,9 +411,9 @@ | ||
| 464 | 411 | * @return false|string|void |
| 465 | 412 | */ |
| 466 | 413 | public static function load_template( $template_name, $args = null, $return = false, $template_path = '', $plugin_path = '' ) { |
| 467 | 414 | $cache_key = sanitize_key( implode( '-', [ 'template', $template_name, $template_path ] ) ); |
| 468 | - $located = (string) wp_cache_get( $cache_key, Cache::group() ); | |
| 415 | + $located = (string) wp_cache_get( $cache_key, 'shopbuilder' ); | |
| 469 | 416 | if ( ! $located ) { |
| 470 | 417 | $located = self::locate_template( $template_name, $template_path, $plugin_path ); |
| 471 | 418 | // Don't cache the absolute path so that it can be shared between web servers with different paths. |
| 472 | 419 | $cache_path = wc_tokenize_path( $located, wc_get_path_define_tokens() ); |
| @@ -475,14 +422,10 @@ | ||
| 475 | 422 | // Make sure that the absolute path to the template is resolved. |
| 476 | 423 | $located = wc_untokenize_path( $located, wc_get_path_define_tokens() ); |
| 477 | 424 | } |
| 478 | 425 | if ( ! file_exists( $located ) ) { |
| 479 | - // $located is empty when the template could not be found anywhere, | |
| 480 | - // so report the requested name instead of an empty path. | |
| 481 | - $reported = $located ? $located : $template_name; | |
| 482 | - | |
| 483 | 426 | // translators: %s template. |
| 484 | - self::doing_it_wrong( __FUNCTION__, sprintf( __( '%s does not exist.', 'shopbuilder' ), '<code>' . esc_html( $reported ) . '</code>' ), '1.0' ); | |
| 427 | + self::doing_it_wrong( __FUNCTION__, sprintf( __( '%s does not exist.', 'shopbuilder' ), '<code>' . $located . '</code>' ), '1.0' ); | |
| 485 | 428 | |
| 486 | 429 | return; |
| 487 | 430 | } |
| 488 | 431 | |
| @@ -611,15 +554,15 @@ | ||
| 611 | 554 | } |
| 612 | 555 | |
| 613 | 556 | global $wpdb; |
| 614 | 557 | $cache_key = 'rtsb_prepared_product_id'; |
| 615 | - $_post_id = wp_cache_get( $cache_key, Cache::group() ); | |
| 558 | + $_post_id = wp_cache_get( $cache_key, 'shopbuilder' ); | |
| 616 | 559 | if ( false === $_post_id || 'publish' !== get_post_status( $_post_id ) ) { |
| 617 | 560 | // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery |
| 618 | 561 | $_post_id = $wpdb->get_var( |
| 619 | 562 | $wpdb->prepare( "SELECT MAX(ID) FROM {$wpdb->prefix}posts WHERE post_type = %s AND post_status IN('publish', 'draft')", 'product' ) |
| 620 | 563 | ); |
| 621 | - wp_cache_set( $cache_key, $_post_id, Cache::group(), 12 * HOUR_IN_SECONDS ); | |
| 564 | + wp_cache_set( $cache_key, $_post_id, 'shopbuilder', 12 * HOUR_IN_SECONDS ); | |
| 622 | 565 | Cache::set_data_cache_key( $cache_key ); |
| 623 | 566 | } |
| 624 | 567 | |
| 625 | 568 | return $_post_id; |
| @@ -664,17 +607,8 @@ | ||
| 664 | 607 | /** |
| 665 | 608 | * @return array |
| 666 | 609 | */ |
| 667 | 610 | public static function get_pages() { |
| 668 | - // Memoized because this only feeds admin select fields, yet the settings | |
| 669 | - // schema is built on every request and asks for it several times. Each | |
| 670 | - // miss runs a full get_pages() query and hydrates every page object. | |
| 671 | - static $memo = null; | |
| 672 | - | |
| 673 | - if ( null !== $memo ) { | |
| 674 | - return $memo; | |
| 675 | - } | |
| 676 | - | |
| 677 | 611 | $pages = []; |
| 678 | 612 | $rawPages = get_pages(); |
| 679 | 613 | if ( ! empty( $rawPages ) ) { |
| 680 | 614 | foreach ( $rawPages as $page ) { |
| @@ -681,11 +615,9 @@ | ||
| 681 | 615 | $pages[ $page->ID ] = $page->post_title; |
| 682 | 616 | } |
| 683 | 617 | } |
| 684 | 618 | |
| 685 | - $memo = $pages; | |
| 686 | - | |
| 687 | - return $memo; | |
| 619 | + return $pages; | |
| 688 | 620 | } |
| 689 | 621 | |
| 690 | 622 | /** |
| 691 | 623 | * Get section items |
| @@ -1062,16 +994,8 @@ | ||
| 1062 | 994 | |
| 1063 | 995 | /** |
| 1064 | 996 | * Prints HTMl. |
| 1065 | 997 | * |
| 1066 | - * The full-markup branch is echoed as-is. It used to run stripslashes_deep(), | |
| 1067 | - * which corrupts already-rendered markup: product loop templates embed JSON in | |
| 1068 | - * attributes (e.g. the Variation Swatches `data-product_variations` payload), | |
| 1069 | - * and stripping backslashes turns `\"` into `"` and `\n` into `n`, so the JSON | |
| 1070 | - * no longer parses and every swatch renders disabled. Rendered HTML never | |
| 1071 | - * carries WordPress slashes — values that do are unslashed where they are read | |
| 1072 | - * (see stripslashes_value()), not at output time. | |
| 1073 | - * | |
| 1074 | 998 | * @param string $html HTML. |
| 1075 | 999 | * @param bool $allHtml All HTML. |
| 1076 | 1000 | * |
| 1077 | 1001 | * @return void |
| @@ -1080,9 +1004,9 @@ | ||
| 1080 | 1004 | if ( ! $html ) { |
| 1081 | 1005 | return; |
| 1082 | 1006 | } |
| 1083 | 1007 | if ( $allHtml ) { |
| 1084 | - echo $html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 1008 | + echo stripslashes_deep( $html ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 1085 | 1009 | } else { |
| 1086 | 1010 | echo wp_kses_post( stripslashes_deep( $html ) ); |
| 1087 | 1011 | } |
| 1088 | 1012 | } |
| @@ -1311,18 +1235,8 @@ | ||
| 1311 | 1235 | * |
| 1312 | 1236 | * @return array |
| 1313 | 1237 | */ |
| 1314 | 1238 | public static function get_image_sizes() { |
| 1315 | - // Memoized: called repeatedly while the settings schema is built, and each | |
| 1316 | - // call loops every registered size doing three get_option() lookups for | |
| 1317 | - // the core ones. Image sizes are registered on after_setup_theme, long | |
| 1318 | - // before anything here runs, so the list cannot change mid-request. | |
| 1319 | - static $memo = null; | |
| 1320 | - | |
| 1321 | - if ( null !== $memo ) { | |
| 1322 | - return $memo; | |
| 1323 | - } | |
| 1324 | - | |
| 1325 | 1239 | global $_wp_additional_image_sizes; |
| 1326 | 1240 | |
| 1327 | 1241 | $sizes = []; |
| 1328 | 1242 | |
| @@ -1348,11 +1262,9 @@ | ||
| 1348 | 1262 | |
| 1349 | 1263 | $imgSize['full'] = esc_html__( 'Full size', 'shopbuilder' ); |
| 1350 | 1264 | $imgSize['rtsb_custom'] = esc_html__( 'Custom image size', 'shopbuilder' ); |
| 1351 | 1265 | |
| 1352 | - $memo = $imgSize; | |
| 1353 | - | |
| 1354 | - return $memo; | |
| 1266 | + return $imgSize; | |
| 1355 | 1267 | } |
| 1356 | 1268 | |
| 1357 | 1269 | /** |
| 1358 | 1270 | * Free Layouts |
| @@ -1814,22 +1726,21 @@ | ||
| 1814 | 1726 | |
| 1815 | 1727 | /** |
| 1816 | 1728 | * Get Featured Image HTML. |
| 1817 | 1729 | * |
| 1818 | - * @param string $type Image type. | |
| 1819 | - * @param int $post_id Post ID. | |
| 1820 | - * @param string $f_img_size Image size. | |
| 1821 | - * @param null $default_img_id Default image ID. | |
| 1822 | - * @param array $custom_img_size Custom image size. | |
| 1823 | - * @param bool $lazy Lazy load check. | |
| 1824 | - * @param bool $hover Hover image. | |
| 1825 | - * @param bool $gallery Gallery image. | |
| 1826 | - * @param bool $custom_image_id Custom category image ID. | |
| 1827 | - * @param bool|string $priority Eager/priority hint: 'high', 'eager', or false (default lazy). | |
| 1730 | + * @param string $type Image type. | |
| 1731 | + * @param int $post_id Post ID. | |
| 1732 | + * @param string $f_img_size Image size. | |
| 1733 | + * @param null $default_img_id Default image ID. | |
| 1734 | + * @param array $custom_img_size Custom image size. | |
| 1735 | + * @param bool $lazy Lazy load check. | |
| 1736 | + * @param bool $hover Hover image. | |
| 1737 | + * @param bool $gallery Gallery image. | |
| 1738 | + * @param bool $custom_image_id Custom category image ID. | |
| 1828 | 1739 | * |
| 1829 | 1740 | * @return string|null |
| 1830 | 1741 | */ |
| 1831 | - public static function get_product_image_html( $type = 'product', $post_id = null, $f_img_size = 'medium', $default_img_id = null, $custom_img_size = [], $lazy = false, $hover = false, $gallery = false, $custom_image_id = 0, $priority = false ) { | |
| 1742 | + public static function get_product_image_html( $type = 'product', $post_id = null, $f_img_size = 'medium', $default_img_id = null, $custom_img_size = [], $lazy = false, $hover = false, $gallery = false, $custom_image_id = 0 ) { | |
| 1832 | 1743 | $img_html = null; |
| 1833 | 1744 | $attachment_id = null; |
| 1834 | 1745 | $c_size = false; |
| 1835 | 1746 | $hover_class = ''; |
| @@ -1868,19 +1779,8 @@ | ||
| 1868 | 1779 | 'class' => 'img-responsive rtsb-product-image' . $lazy_class . $hover_class, |
| 1869 | 1780 | 'alt' => $alt_tag, |
| 1870 | 1781 | ]; |
| 1871 | 1782 | |
| 1872 | - // Eager-load above-the-fold images so the LCP candidate is fetched | |
| 1873 | - // immediately instead of being lazy-loaded after render-blocking CSS. | |
| 1874 | - // Only the first image is marked fetchpriority=high to avoid competing hints. | |
| 1875 | - if ( $priority ) { | |
| 1876 | - $attr['loading'] = 'eager'; | |
| 1877 | - | |
| 1878 | - if ( 'high' === $priority ) { | |
| 1879 | - $attr['fetchpriority'] = 'high'; | |
| 1880 | - } | |
| 1881 | - } | |
| 1882 | - | |
| 1883 | 1783 | if ( $a_id ) { |
| 1884 | 1784 | $img_html = wp_get_attachment_image( $a_id, $f_img_size, false, $attr ); |
| 1885 | 1785 | $attachment_id = $a_id; |
| 1886 | 1786 | } |
| @@ -2058,21 +1958,9 @@ | ||
| 2058 | 1958 | public static function get_product_swatches( $type ) { |
| 2059 | 1959 | ?> |
| 2060 | 1960 | <div class="rtsb-swatches <?php echo esc_attr( $type ); ?>-layout"> |
| 2061 | 1961 | <?php |
| 2062 | - /* | |
| 2063 | - * Hand off to the Variation Swatches plugin's own archive renderer when it | |
| 2064 | - * is listening, otherwise fall back to the built-in module. | |
| 2065 | - * | |
| 2066 | - * Detected with has_action() rather than a class name on purpose: this used | |
| 2067 | - * to test `class_exists( 'Rtwpvsp' )`, but the plugin moved its classes into | |
| 2068 | - * a namespace (`Rtwpvsp\Rtwpvsp`), so that check silently started failing. | |
| 2069 | - * The else branch then fired the built-in module's action — which is never | |
| 2070 | - * hooked while the plugin is active, because the module deliberately stands | |
| 2071 | - * down — leaving this wrapper rendered but empty. Asking whether anything is | |
| 2072 | - * actually listening is both the correct question and rename-proof. | |
| 2073 | - */ | |
| 2074 | - if ( has_action( 'rtwpvs_show_archive_variation' ) ) { | |
| 1962 | + if ( class_exists( 'Rtwpvsp' ) ) { | |
| 2075 | 1963 | do_action( 'rtwpvs_show_archive_variation' ); |
| 2076 | 1964 | } else { |
| 2077 | 1965 | do_action( 'rtsb/vs/showcase/variation' ); |
| 2078 | 1966 | } |
| @@ -2201,31 +2089,18 @@ | ||
| 2201 | 2089 | |
| 2202 | 2090 | /** |
| 2203 | 2091 | * Pagination |
| 2204 | 2092 | * |
| 2205 | - * @param string $pages Pages. | |
| 2206 | - * @param integer $per_page Per-page count (unused; kept for positional compatibility). | |
| 2207 | - * @param boolean $ajax Ajax. | |
| 2208 | - * @param int|null $visible_range Page links to show on each side of the current | |
| 2209 | - * page (from the widget's "Page Number Range" | |
| 2210 | - * control). Falls back to the filter default. | |
| 2093 | + * @param string $pages Pages. | |
| 2094 | + * @param integer $range Range. | |
| 2095 | + * @param boolean $ajax Ajax. | |
| 2211 | 2096 | * |
| 2212 | 2097 | * @return string |
| 2213 | 2098 | */ |
| 2214 | - public static function custom_pagination( $pages = '', $per_page = 4, $ajax = false, $visible_range = null ) { | |
| 2215 | - $html = null; | |
| 2099 | + public static function custom_pagination( $pages = '', $range = 4, $ajax = false ) { | |
| 2100 | + $html = null; | |
| 2101 | + $visible_range = apply_filters( 'rtsb/elements/pagination/visible_range', ( $range * 2 ) + 1 ); | |
| 2216 | 2102 | |
| 2217 | - // How many page links to show on each side of the current page. Driven by | |
| 2218 | - // the widget's "Page Number Range" control; the filter is the fallback | |
| 2219 | - // default. Keeping it small truncates long paginations (« ‹ 1 2 3 › ») | |
| 2220 | - // with jump-to-first/last arrows instead of listing every page number. | |
| 2221 | - // (The 2nd argument callers pass is the per-page count, not a window). | |
| 2222 | - if ( null === $visible_range ) { | |
| 2223 | - $visible_range = apply_filters( 'rtsb/elements/pagination/visible_range', 5 ); | |
| 2224 | - } | |
| 2225 | - | |
| 2226 | - $visible_range = max( 1, (int) $visible_range ); | |
| 2227 | - | |
| 2228 | 2103 | global $paged; |
| 2229 | 2104 | |
| 2230 | 2105 | // Prefer `paged` (archive pagination), fall back to `page` (paginated singular posts). |
| 2231 | 2106 | // This handles the case where the shop/archive is set as the front page — `is_front_page()` |
| @@ -2280,9 +2155,9 @@ | ||
| 2280 | 2155 | $p = $paged + 1; |
| 2281 | 2156 | $html .= "<li><a data-paged='{$p}' href=\"" . get_pagenum_link( $paged + 1 ) . "\" aria-label='Next'>›</a></li>"; |
| 2282 | 2157 | } |
| 2283 | 2158 | |
| 2284 | - if ( $paged < $pages - 1 && $paged + $visible_range < $pages && $visible_range < $pages ) { | |
| 2159 | + if ( $paged < $pages - 1 && $paged + $range - 1 < $pages && $visible_range < $pages ) { | |
| 2285 | 2160 | $html .= "<li><a data-paged='{$pages}' href='" . get_pagenum_link( $pages ) . "' aria-label='Last'>»</a></li>"; |
| 2286 | 2161 | } |
| 2287 | 2162 | |
| 2288 | 2163 | $html .= '</ul>'; |
| @@ -2828,44 +2703,8 @@ | ||
| 2828 | 2703 | return $results; |
| 2829 | 2704 | } |
| 2830 | 2705 | |
| 2831 | 2706 | /** |
| 2832 | - * Count published products matching a tax query. | |
| 2833 | - * | |
| 2834 | - * Filter badges must agree with the number of products the same filter lists. | |
| 2835 | - * The archive (and the Ajax filter response) runs a plain WP_Query, while | |
| 2836 | - * WC_Product_Query additionally restricts results to the registered | |
| 2837 | - * `product_type` terms — so a product imported without a `product_type` term | |
| 2838 | - * is listed on the archive but silently dropped from the count, making the | |
| 2839 | - * badge read lower than the result set (e.g. "Cat1 (4)" for 10 results). | |
| 2840 | - * | |
| 2841 | - * @param array $tax_query Tax query clauses. | |
| 2842 | - * | |
| 2843 | - * @return int Number of matching products. | |
| 2844 | - */ | |
| 2845 | - public static function count_products_by_tax_query( array $tax_query ) { | |
| 2846 | - if ( empty( $tax_query ) ) { | |
| 2847 | - return 0; | |
| 2848 | - } | |
| 2849 | - | |
| 2850 | - $query = new WP_Query( | |
| 2851 | - [ | |
| 2852 | - 'post_type' => 'product', | |
| 2853 | - 'post_status' => 'publish', | |
| 2854 | - 'posts_per_page' => -1, | |
| 2855 | - 'fields' => 'ids', | |
| 2856 | - 'ignore_sticky_posts' => true, | |
| 2857 | - 'no_found_rows' => true, | |
| 2858 | - 'update_post_meta_cache' => false, | |
| 2859 | - 'update_post_term_cache' => false, | |
| 2860 | - 'tax_query' => $tax_query, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query | |
| 2861 | - ] | |
| 2862 | - ); | |
| 2863 | - | |
| 2864 | - return count( $query->posts ); | |
| 2865 | - } | |
| 2866 | - | |
| 2867 | - /** | |
| 2868 | 2707 | * Count products by taxonomies. |
| 2869 | 2708 | * |
| 2870 | 2709 | * @param array $terms Terms. |
| 2871 | 2710 | * @param string $taxonomy Taxonomy. |
| @@ -3257,9 +3096,9 @@ | ||
| 3257 | 3096 | |
| 3258 | 3097 | if ( isset( self::$cache[ $cache_key ] ) ) { |
| 3259 | 3098 | return self::$cache[ $cache_key ]; |
| 3260 | 3099 | } |
| 3261 | - $results = wp_cache_get( $cache_key, Cache::group() ); | |
| 3100 | + $results = wp_cache_get( $cache_key, 'shopbuilder' ); | |
| 3262 | 3101 | if ( ! $results ) { |
| 3263 | 3102 | global $wpdb; |
| 3264 | 3103 | $sql = "SELECT t.term_id, t.name |
| 3265 | 3104 | FROM {$wpdb->terms} t |
| @@ -3274,9 +3113,9 @@ | ||
| 3274 | 3113 | } |
| 3275 | 3114 | |
| 3276 | 3115 | $results = $wpdb->get_results( $prepared_sql ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.PreparedSQL.NotPrepared |
| 3277 | 3116 | // Cache the results in the object cache for future use. |
| 3278 | - wp_cache_set( $cache_key, $results, Cache::group(), 12 * HOUR_IN_SECONDS ); | |
| 3117 | + wp_cache_set( $cache_key, $results, 'shopbuilder' ); // Adjust the expiration time as needed. | |
| 3279 | 3118 | Cache::set_data_cache_key( $cache_key ); |
| 3280 | 3119 | } |
| 3281 | 3120 | |
| 3282 | 3121 | $cats = []; |
| @@ -3313,9 +3152,9 @@ | ||
| 3313 | 3152 | |
| 3314 | 3153 | if ( isset( self::$cache[ $cache_key ] ) ) { |
| 3315 | 3154 | return self::$cache[ $cache_key ]; |
| 3316 | 3155 | } |
| 3317 | - $results = wp_cache_get( $cache_key, Cache::group() ); | |
| 3156 | + $results = wp_cache_get( $cache_key, 'shopbuilder' ); | |
| 3318 | 3157 | if ( ! $results ) { |
| 3319 | 3158 | global $wpdb; |
| 3320 | 3159 | $sql = "SELECT t.term_id, t.name |
| 3321 | 3160 | FROM {$wpdb->terms} t |
| @@ -3330,9 +3169,9 @@ | ||
| 3330 | 3169 | } |
| 3331 | 3170 | |
| 3332 | 3171 | $results = $wpdb->get_results( $prepared_sql ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.PreparedSQL.NotPrepared |
| 3333 | 3172 | // Cache the results in the object cache for future use. |
| 3334 | - wp_cache_set( $cache_key, $results, Cache::group(), 12 * HOUR_IN_SECONDS ); | |
| 3173 | + wp_cache_set( $cache_key, $results, 'shopbuilder' ); // Adjust the expiration time as needed. | |
| 3335 | 3174 | Cache::set_data_cache_key( $cache_key ); |
| 3336 | 3175 | } |
| 3337 | 3176 | |
| 3338 | 3177 | $cats = []; |
| @@ -3869,9 +3708,9 @@ | ||
| 3869 | 3708 | * |
| 3870 | 3709 | * @return void |
| 3871 | 3710 | */ |
| 3872 | 3711 | public static function dynamic_styles( $options, $cache_key, $css_properties ) { |
| 3873 | - $cached_css = wp_cache_get( $cache_key, Cache::group() ); | |
| 3712 | + $cached_css = wp_cache_get( $cache_key, 'shopbuilder' ); | |
| 3874 | 3713 | $style_handle = self::optimized_handle( 'rtsb-frontend' ); |
| 3875 | 3714 | |
| 3876 | 3715 | if ( false !== $cached_css ) { |
| 3877 | 3716 | wp_add_inline_style( $style_handle, $cached_css ); |
| @@ -3907,9 +3746,9 @@ | ||
| 3907 | 3746 | } |
| 3908 | 3747 | |
| 3909 | 3748 | $dynamic_css = implode( ' ', $css_rules ); |
| 3910 | 3749 | |
| 3911 | - wp_cache_set( $cache_key, $dynamic_css, Cache::group(), 12 * HOUR_IN_SECONDS ); | |
| 3750 | + wp_cache_set( $cache_key, $dynamic_css, 'shopbuilder', 12 * HOUR_IN_SECONDS ); | |
| 3912 | 3751 | Cache::set_data_cache_key( $cache_key ); |
| 3913 | 3752 | |
| 3914 | 3753 | if ( ! empty( $dynamic_css ) ) { |
| 3915 | 3754 | wp_add_inline_style( $style_handle, $dynamic_css ); |
| @@ -3972,9 +3811,9 @@ | ||
| 3972 | 3811 | if ( isset( self::$cache[ $cache_key ] ) ) { |
| 3973 | 3812 | return self::$cache[ $cache_key ]; |
| 3974 | 3813 | } |
| 3975 | 3814 | |
| 3976 | - $cached_result = wp_cache_get( $cache_key, Cache::group() ); | |
| 3815 | + $cached_result = wp_cache_get( $cache_key, 'shopbuilder' ); | |
| 3977 | 3816 | |
| 3978 | 3817 | if ( false !== $cached_result ) { |
| 3979 | 3818 | self::$cache[ $cache_key ] = $cached_result; |
| 3980 | 3819 | |
| @@ -3983,9 +3822,9 @@ | ||
| 3983 | 3822 | |
| 3984 | 3823 | $gallery_ids = $product->get_gallery_image_ids(); |
| 3985 | 3824 | self::$cache[ $cache_key ] = $gallery_ids; |
| 3986 | 3825 | |
| 3987 | - wp_cache_set( $cache_key, $gallery_ids, Cache::group(), 12 * HOUR_IN_SECONDS ); | |
| 3826 | + wp_cache_set( $cache_key, $gallery_ids, 'shopbuilder', 12 * HOUR_IN_SECONDS ); | |
| 3988 | 3827 | Cache::set_data_cache_key( $cache_key ); |
| 3989 | 3828 | |
| 3990 | 3829 | return $gallery_ids; |
| 3991 | 3830 | } |
| @@ -4016,14 +3855,8 @@ | ||
| 4016 | 3855 | * |
| 4017 | 3856 | * @return bool |
| 4018 | 3857 | */ |
| 4019 | 3858 | public static function is_optimization_enabled() { |
| 4020 | - // A bundle could not be built during this request, fall back to the | |
| 4021 | - // unbundled assets rather than emitting handles with an empty source. | |
| 4022 | - if ( self::$optimization_unavailable ) { | |
| 4023 | - return false; | |
| 4024 | - } | |
| 4025 | - | |
| 4026 | 3859 | if ( ! self::is_optimization_setting_on() ) { |
| 4027 | 3860 | return false; |
| 4028 | 3861 | } |
| 4029 | 3862 | |
| @@ -4224,8 +4057,9 @@ | ||
| 4224 | 4057 | ( $src === $stylesheet_uri || strpos( $src, $theme_directory_uri ) !== false ) && |
| 4225 | 4058 | strpos( $src, 'style.css' ) !== false |
| 4226 | 4059 | ) { |
| 4227 | 4060 | set_transient( $transient_key, $handle, DAY_IN_SECONDS ); |
| 4061 | + Cache::set_transient_cache_key( $transient_key ); | |
| 4228 | 4062 | $cached_handle = $handle; |
| 4229 | 4063 | |
| 4230 | 4064 | return $handle; |
| 4231 | 4065 | } |
| @@ -4234,8 +4068,9 @@ | ||
| 4234 | 4068 | $filtered_handle = apply_filters( 'rtsb/optimizer/theme_stylesheet_handle', false ); |
| 4235 | 4069 | |
| 4236 | 4070 | if ( is_string( $filtered_handle ) && ! empty( $filtered_handle ) ) { |
| 4237 | 4071 | set_transient( $transient_key, $filtered_handle, DAY_IN_SECONDS ); |
| 4072 | + Cache::set_transient_cache_key( $transient_key ); | |
| 4238 | 4073 | $cached_handle = $filtered_handle; |
| 4239 | 4074 | |
| 4240 | 4075 | return $filtered_handle; |
| 4241 | 4076 | } |
| @@ -4240,8 +4075,9 @@ | ||
| 4240 | 4075 | return $filtered_handle; |
| 4241 | 4076 | } |
| 4242 | 4077 | |
| 4243 | 4078 | set_transient( $transient_key, false, DAY_IN_SECONDS ); |
| 4079 | + Cache::set_transient_cache_key( $transient_key ); | |
| 4244 | 4080 | $cached_handle = false; |
| 4245 | 4081 | |
| 4246 | 4082 | return false; |
| 4247 | 4083 | } |
| @@ -4407,9 +4243,9 @@ | ||
| 4407 | 4243 | return $cached_modules; |
| 4408 | 4244 | } |
| 4409 | 4245 | |
| 4410 | 4246 | $cache_key = 'rtsb_module_list'; |
| 4411 | - $cache_group = Cache::group(); | |
| 4247 | + $cache_group = 'shopbuilder'; | |
| 4412 | 4248 | |
| 4413 | 4249 | $cached = wp_cache_get( $cache_key, $cache_group ); |
| 4414 | 4250 | |
| 4415 | 4251 | if ( false !== $cached ) { |
| @@ -4440,9 +4276,9 @@ | ||
| 4440 | 4276 | return $cached_widgets; |
| 4441 | 4277 | } |
| 4442 | 4278 | |
| 4443 | 4279 | $cache_key = 'rtsb_elementor_widget_list'; |
| 4444 | - $cache_group = Cache::group(); | |
| 4280 | + $cache_group = 'shopbuilder'; | |
| 4445 | 4281 | |
| 4446 | 4282 | $cached = wp_cache_get( $cache_key, $cache_group ); |
| 4447 | 4283 | |
| 4448 | 4284 | if ( false !== $cached ) { |