Submit
Path:
~
/
/
var
/
softaculous
/
sitepad
/
editor
/
site-data
/
plugins
/
kkart-pro
/
includes
/
File Content:
class-kkart-cache-helper.php
<?php /** * KKART_Cache_Helper class. * * @package Kkart\Classes */ defined( 'ABSPATH' ) || exit; /** * KKART_Cache_Helper. */ class KKART_Cache_Helper { /** * Transients to delete on shutdown. * * @var array Array of transient keys. */ private static $delete_transients = array(); /** * Hook in methods. */ public static function init() { add_filter( 'nocache_headers', array( __CLASS__, 'additional_nocache_headers' ), 10 ); add_action( 'shutdown', array( __CLASS__, 'delete_transients_on_shutdown' ), 10 ); add_action( 'template_redirect', array( __CLASS__, 'geolocation_ajax_redirect' ) ); add_action( 'admin_notices', array( __CLASS__, 'notices' ) ); add_action( 'delete_version_transients', array( __CLASS__, 'delete_version_transients' ), 10 ); add_action( 'wp', array( __CLASS__, 'prevent_caching' ) ); add_action( 'clean_term_cache', array( __CLASS__, 'clean_term_cache' ), 10, 2 ); add_action( 'edit_terms', array( __CLASS__, 'clean_term_cache' ), 10, 2 ); } /** * Set additional nocache headers. * * @param array $headers Header names and field values. * @since 3.6.0 */ public static function additional_nocache_headers( $headers ) { $agent = isset( $_SERVER['HTTP_USER_AGENT'] ) ? wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized /** * Allow plugins to enable nocache headers. Enabled for Google weblight. * * @see https://support.google.com/webmasters/answer/1061943?hl=en * @param bool $enable_nocache_headers Flag indicating whether to add nocache headers. Default: false. */ if ( false !== strpos( $agent, 'googleweblight' ) || apply_filters( 'kkart_enable_nocache_headers', false ) ) { // no-transform: Opt-out of Google weblight. https://support.google.com/webmasters/answer/6211428?hl=en. $headers['Cache-Control'] = 'no-transform, no-cache, no-store, must-revalidate'; } return $headers; } /** * Add a transient to delete on shutdown. * * @since 3.6.0 * @param string|array $keys Transient key or keys. */ public static function queue_delete_transient( $keys ) { self::$delete_transients = array_unique( array_merge( is_array( $keys ) ? $keys : array( $keys ), self::$delete_transients ) ); } /** * Transients that don't need to be cleaned right away can be deleted on shutdown to avoid repetition. * * @since 3.6.0 */ public static function delete_transients_on_shutdown() { if ( self::$delete_transients ) { foreach ( self::$delete_transients as $key ) { delete_transient( $key ); } self::$delete_transients = array(); } } /** * Used to clear layered nav counts based on passed attribute names. * * @since 3.6.0 * @param array $attribute_keys Attribute keys. */ public static function invalidate_attribute_count( $attribute_keys ) { if ( $attribute_keys ) { foreach ( $attribute_keys as $attribute_key ) { self::queue_delete_transient( 'kkart_layered_nav_counts_' . $attribute_key ); } } } /** * Get prefix for use with wp_cache_set. Allows all cache in a group to be invalidated at once. * * @param string $group Group of cache to get. * @return string */ public static function get_cache_prefix( $group ) { // Get cache key - uses cache key kkart_orders_cache_prefix to invalidate when needed. $prefix = wp_cache_get( 'kkart_' . $group . '_cache_prefix', $group ); if ( false === $prefix ) { $prefix = microtime(); wp_cache_set( 'kkart_' . $group . '_cache_prefix', $prefix, $group ); } return 'kkart_cache_' . $prefix . '_'; } /** * Increment group cache prefix (invalidates cache). * * @param string $group Group of cache to clear. */ public static function incr_cache_prefix( $group ) { kkart_deprecated_function( 'KKART_Cache_Helper::incr_cache_prefix', '3.9.0', 'KKART_Cache_Helper::invalidate_cache_group' ); self::invalidate_cache_group( $group ); } /** * Invalidate cache group. * * @param string $group Group of cache to clear. * @since 3.9.0 */ public static function invalidate_cache_group( $group ) { wp_cache_set( 'kkart_' . $group . '_cache_prefix', microtime(), $group ); } /** * Get a hash of the customer location. * * @return string */ public static function geolocation_ajax_get_location_hash() { $customer = new KKART_Customer( 0, true ); $location = array(); $location['country'] = $customer->get_billing_country(); $location['state'] = $customer->get_billing_state(); $location['postcode'] = $customer->get_billing_postcode(); $location['city'] = $customer->get_billing_city(); return apply_filters( 'kkart_geolocation_ajax_get_location_hash', substr( md5( implode( '', $location ) ), 0, 12 ), $location, $customer ); } /** * Prevent caching on certain pages */ public static function prevent_caching() { if ( ! is_blog_installed() ) { return; } $page_ids = array_filter( array( kkart_get_page_id( 'cart' ), kkart_get_page_id( 'checkout' ), kkart_get_page_id( 'myaccount' ) ) ); if ( is_page( $page_ids ) ) { self::set_nocache_constants(); nocache_headers(); } } /** * When using geolocation via ajax, to bust cache, redirect if the location hash does not equal the querystring. * * This prevents caching of the wrong data for this request. */ public static function geolocation_ajax_redirect() { if ( 'geolocation_ajax' === get_option( 'kkart_default_customer_address' ) && ! is_checkout() && ! is_cart() && ! is_account_page() && ! is_ajax() && empty( $_POST ) ) { // WPCS: CSRF ok, input var ok. $location_hash = self::geolocation_ajax_get_location_hash(); $current_hash = isset( $_GET['v'] ) ? kkart_clean( wp_unslash( $_GET['v'] ) ) : ''; // WPCS: sanitization ok, input var ok, CSRF ok. if ( empty( $current_hash ) || $current_hash !== $location_hash ) { global $wp; $redirect_url = trailingslashit( home_url( $wp->request ) ); if ( ! empty( $_SERVER['QUERY_STRING'] ) ) { // WPCS: Input var ok. $redirect_url = add_query_arg( wp_unslash( $_SERVER['QUERY_STRING'] ), '', $redirect_url ); // WPCS: sanitization ok, Input var ok. } if ( ! get_option( 'permalink_structure' ) ) { $redirect_url = add_query_arg( $wp->query_string, '', $redirect_url ); } $redirect_url = add_query_arg( 'v', $location_hash, remove_query_arg( 'v', $redirect_url ) ); wp_safe_redirect( esc_url_raw( $redirect_url ), 307 ); exit; } } } /** * Get transient version. * * When using transients with unpredictable names, e.g. those containing an md5 * hash in the name, we need a way to invalidate them all at once. * * When using default WP transients we're able to do this with a DB query to * delete transients manually. * * With external cache however, this isn't possible. Instead, this function is used * to append a unique string (based on time()) to each transient. When transients * are invalidated, the transient version will increment and data will be regenerated. * * Raised in issue https://github.com/kkart/kkart/issues/5777. * Adapted from ideas in http://tollmanz.com/invalidation-schemes/. * * @param string $group Name for the group of transients we need to invalidate. * @param boolean $refresh true to force a new version. * @return string transient version based on time(), 10 digits. */ public static function get_transient_version( $group, $refresh = false ) { $transient_name = $group . '-transient-version'; $transient_value = get_transient( $transient_name ); if ( false === $transient_value || true === $refresh ) { $transient_value = (string) time(); set_transient( $transient_name, $transient_value ); } return $transient_value; } /** * Set constants to prevent caching by some plugins. * * @param mixed $return Value to return. Previously hooked into a filter. * @return mixed */ public static function set_nocache_constants( $return = true ) { kkart_maybe_define_constant( 'DONOTCACHEPAGE', true ); kkart_maybe_define_constant( 'DONOTCACHEOBJECT', true ); kkart_maybe_define_constant( 'DONOTCACHEDB', true ); return $return; } /** * Notices function. */ public static function notices() { if ( ! function_exists( 'w3tc_pgcache_flush' ) || ! function_exists( 'w3_instance' ) ) { return; } $config = w3_instance( 'W3_Config' ); $enabled = $config->get_integer( 'dbcache.enabled' ); $settings = array_map( 'trim', $config->get_array( 'dbcache.reject.sql' ) ); if ( $enabled && ! in_array( '_kkart_session_', $settings, true ) ) { ?> <div class="error"> <p> <?php /* translators: 1: key 2: URL */ echo wp_kses_post( sprintf( __( 'In order for <strong>database caching</strong> to work with Kkart you must add %1$s to the "Ignored Query Strings" option in <a href="%2$s">W3 Total Cache settings</a>.', 'kkart' ), '<code>_kkart_session_</code>', esc_url( admin_url( 'admin.php?page=w3tc_dbcache' ) ) ) ); ?> </p> </div> <?php } } /** * Clean term caches added by Kkart. * * @since 3.3.4 * @param array|int $ids Array of ids or single ID to clear cache for. * @param string $taxonomy Taxonomy name. */ public static function clean_term_cache( $ids, $taxonomy ) { if ( 'product_cat' === $taxonomy ) { $ids = is_array( $ids ) ? $ids : array( $ids ); $clear_ids = array( 0 ); foreach ( $ids as $id ) { $clear_ids[] = $id; $clear_ids = array_merge( $clear_ids, get_ancestors( $id, 'product_cat', 'taxonomy' ) ); } $clear_ids = array_unique( $clear_ids ); foreach ( $clear_ids as $id ) { wp_cache_delete( 'product-category-hierarchy-' . $id, 'product_cat' ); } } } /** * When the transient version increases, this is used to remove all past transients to avoid filling the DB. * * Note; this only works on transients appended with the transient version, and when object caching is not being used. * * @deprecated 3.6.0 Adjusted transient usage to include versions within the transient values, making this cleanup obsolete. * @since 2.3.10 * @param string $version Version of the transient to remove. */ public static function delete_version_transients( $version = '' ) { if ( ! wp_using_ext_object_cache() && ! empty( $version ) ) { global $wpdb; $limit = apply_filters( 'kkart_delete_version_transients_limit', 1000 ); if ( ! $limit ) { return; } $affected = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->options} WHERE option_name LIKE %s LIMIT %d;", '\_transient\_%' . $version, $limit ) ); // WPCS: cache ok, db call ok. // If affected rows is equal to limit, there are more rows to delete. Delete in 30 secs. if ( $affected === $limit ) { wp_schedule_single_event( time() + 30, 'delete_version_transients', array( $version ) ); } } } } KKART_Cache_Helper::init();
Edit
Rename
Chmod
Delete
FILE
FOLDER
Name
Size
Permission
Action
abstracts
---
0755
admin
---
0755
cli
---
0755
customizer
---
0755
data-stores
---
0755
emails
---
0755
export
---
0755
gateways
---
0755
import
---
0755
integrations
---
0755
interfaces
---
0755
legacy
---
0755
libraries
---
0755
log-handlers
---
0755
payment-tokens
---
0755
queue
---
0755
rest-api
---
0755
shipping
---
0755
shortcodes
---
0755
theme-support
---
0755
tracks
---
0755
traits
---
0755
walkers
---
0755
wccom-site
---
0755
widgets
---
0755
body-props-settings.php
8379 bytes
0644
class-kkart-ajax.php
131339 bytes
0644
class-kkart-api.php
5090 bytes
0644
class-kkart-auth.php
11939 bytes
0644
class-kkart-autoloader.php
2842 bytes
0644
class-kkart-background-emailer.php
4703 bytes
0644
class-kkart-background-updater.php
3580 bytes
0644
class-kkart-breadcrumb.php
9692 bytes
0644
class-kkart-cache-helper.php
10967 bytes
0644
class-kkart-cart-fees.php
3498 bytes
0644
class-kkart-cart-session.php
14806 bytes
0644
class-kkart-cart-totals.php
28388 bytes
0644
class-kkart-cart.php
64753 bytes
0644
class-kkart-checkout.php
45656 bytes
0644
class-kkart-cli.php
1043 bytes
0644
class-kkart-comments.php
13305 bytes
0644
class-kkart-countries.php
43222 bytes
0644
class-kkart-coupon.php
33350 bytes
0644
class-kkart-customer-download-log.php
3458 bytes
0644
class-kkart-customer-download.php
10606 bytes
0644
class-kkart-customer.php
27894 bytes
0644
class-kkart-data-exception.php
1306 bytes
0644
class-kkart-data-store.php
6022 bytes
0644
class-kkart-datetime.php
2251 bytes
0644
class-kkart-deprecated-action-hooks.php
6697 bytes
0644
class-kkart-deprecated-filter-hooks.php
6413 bytes
0644
class-kkart-discounts.php
31706 bytes
0644
class-kkart-download-handler.php
23930 bytes
0644
class-kkart-emails.php
22698 bytes
0644
class-kkart-embed.php
4284 bytes
0644
class-kkart-form-handler.php
44776 bytes
0644
class-kkart-frontend-scripts.php
26623 bytes
0644
class-kkart-geo-ip.php
31165 bytes
0644
class-kkart-geolite-integration.php
2042 bytes
0644
class-kkart-geolocation.php
10586 bytes
0644
class-kkart-https.php
4397 bytes
0644
class-kkart-install.php
55130 bytes
0644
class-kkart-integrations.php
1316 bytes
0644
class-kkart-log-levels.php
2597 bytes
0644
class-kkart-logger.php
8405 bytes
0644
class-kkart-meta-data.php
2231 bytes
0644
class-kkart-order-factory.php
3212 bytes
0644
class-kkart-order-item-coupon.php
4118 bytes
0644
class-kkart-order-item-fee.php
8909 bytes
0644
class-kkart-order-item-meta.php
5939 bytes
0644
class-kkart-order-item-product.php
13366 bytes
0644
class-kkart-order-item-shipping.php
7933 bytes
0644
class-kkart-order-item-tax.php
6593 bytes
0644
class-kkart-order-item.php
10947 bytes
0644
class-kkart-order-query.php
2578 bytes
0644
class-kkart-order-refund.php
5009 bytes
0644
class-kkart-order.php
62493 bytes
0644
class-kkart-payment-gateways.php
5367 bytes
0644
class-kkart-payment-tokens.php
6047 bytes
0644
class-kkart-post-data.php
18242 bytes
0644
class-kkart-post-types.php
27128 bytes
0644
class-kkart-privacy-background-process.php
1734 bytes
0644
class-kkart-privacy-erasers.php
13603 bytes
0644
class-kkart-privacy-exporters.php
14458 bytes
0644
class-kkart-privacy.php
15212 bytes
0644
class-kkart-product-attribute.php
7052 bytes
0644
class-kkart-product-download.php
6159 bytes
0644
class-kkart-product-external.php
4889 bytes
0644
class-kkart-product-factory.php
3683 bytes
0644
class-kkart-product-grouped.php
5319 bytes
0644
class-kkart-product-query.php
2222 bytes
0644
class-kkart-product-simple.php
1899 bytes
0644
class-kkart-product-variable.php
21983 bytes
0644
class-kkart-product-variation.php
17610 bytes
0644
class-kkart-query.php
31129 bytes
0644
class-kkart-rate-limiter.php
2133 bytes
0644
class-kkart-regenerate-images-request.php
8365 bytes
0644
class-kkart-regenerate-images.php
15607 bytes
0644
class-kkart-register-wp-admin-settings.php
4990 bytes
0644
class-kkart-rest-authentication.php
19811 bytes
0644
class-kkart-rest-exception.php
273 bytes
0644
class-kkart-session-handler.php
10821 bytes
0644
class-kkart-shipping-rate.php
5388 bytes
0644
class-kkart-shipping-zone.php
13404 bytes
0644
class-kkart-shipping-zones.php
4169 bytes
0644
class-kkart-shipping.php
11607 bytes
0644
class-kkart-shortcodes.php
17618 bytes
0644
class-kkart-structured-data.php
17614 bytes
0644
class-kkart-tax.php
36697 bytes
0644
class-kkart-template-loader.php
18878 bytes
0644
class-kkart-tracker.php
23049 bytes
0644
class-kkart-validation.php
5975 bytes
0644
class-kkart-webhook.php
30567 bytes
0644
class-kkart.php
33477 bytes
0644
kkart-account-functions.php
12995 bytes
0644
kkart-attribute-functions.php
21083 bytes
0644
kkart-cart-functions.php
17683 bytes
0644
kkart-conditional-functions.php
12079 bytes
0644
kkart-core-functions.php
84228 bytes
0644
kkart-coupon-functions.php
2711 bytes
0644
kkart-formatting-functions.php
42607 bytes
0644
kkart-notice-functions.php
7623 bytes
0644
kkart-order-functions.php
34333 bytes
0644
kkart-order-item-functions.php
5177 bytes
0644
kkart-page-functions.php
7084 bytes
0644
kkart-product-functions.php
48433 bytes
0644
kkart-rest-functions.php
10876 bytes
0644
kkart-stock-functions.php
12753 bytes
0644
kkart-template-functions.php
168595 bytes
0644
kkart-template-hooks.php
11322 bytes
0644
kkart-term-functions.php
19918 bytes
0644
kkart-update-functions.php
66440 bytes
0644
kkart-user-functions.php
27222 bytes
0644
kkart-webhook-functions.php
5713 bytes
0644
kkart-widget-functions.php
2126 bytes
0644
premium.php
943 bytes
0644
premium_functions.php
957 bytes
0644
shortcode_functions.php
72821 bytes
0644
shortcodes.php
272113 bytes
0644
template.php
2921 bytes
0644
N4ST4R_ID | Naxtarrr