<?php /** * Utility class to contain all transient and cache related functions used within LearnDash. * * @since 3.1.0 * @package LearnDash */ if ( ! defined( 'ABSPATH' ) ) { exit; } if ( ! class_exists( 'LDLMS_Transients' ) ) { /** * Class to create the instance. * * @since 3.1.0 */ class LDLMS_Transients { /** * Cache Group. * * @since 3.4.1 * * @var string $cache_group; */ private static $cache_group = 'learndash'; /** * Private constructor for class * * @since 3.1.0 */ private function __construct() { } /** * Get a Transient * * @since 3.1.0 * * @param string $transient_key The transient key to retrieve. * * @return mixed $transient_data the retrieved transient data or false if expired. */ public static function get( $transient_key = '' ) { $transient_data = false; if ( ! empty( $transient_key ) ) { /** * Filters whether the to bypass cache. * * @since 3.4.1 * * @param bool $bypass_cache Whether to bypass the existing cache. * @param string $transient_key Transient Key. * * @return bool true to skip cache. False to use cache. */ if ( ! apply_filters( 'learndash_bypass_cache', false, $transient_key ) ) { /** * Filters whether the object cache is enabled. * * @since 3.4.1 * * @param boolean $cache_enabled Whether the object cache is enabled. * @param string $transient_key Transient Key. */ if ( apply_filters( 'learndash_object_cache_enabled', LEARNDASH_OBJECT_CACHE_ENABLED, $transient_key ) ) { $found = false; $transient_data = wp_cache_get( $transient_key, self::$cache_group, false, $found ); if ( false === $found ) { $transient_data = false; } } elseif ( /** * Filters whether the transients are disabled or not. * * @since 2.3.3 * * @param boolean $transients_disabled Whether the transients are disabled or not. * @param string $transient_key Transient Key. */ ! apply_filters( 'learndash_transients_disabled', LEARNDASH_TRANSIENTS_DISABLED, $transient_key ) ) { $transient_data = get_transient( $transient_key ); } } } return $transient_data; } /** * Utility function to interface with WP set_transient function. This function allow for * filtering if to actually write the transient. * * @since 3.1.0 * * @param string $transient_key The transient key. * @param mixed $transient_data Data to store in transient. * @param integer $transient_expire Expiration time for transient. */ public static function set( $transient_key = '', $transient_data = '', $transient_expire = MINUTE_IN_SECONDS ) { if ( ! empty( $transient_key ) ) { $transient_expire = apply_filters( 'learndash_cache_expire', $transient_expire, $transient_key ); $transient_expire = absint( $transient_expire ); if ( ! empty( $transient_expire ) ) { /** This filter is documented in includes/class-ld-transients.php */ if ( apply_filters( 'learndash_object_cache_enabled', LEARNDASH_OBJECT_CACHE_ENABLED, $transient_key ) ) { return wp_cache_set( $transient_key, $transient_data, self::$cache_group, $transient_expire ); } elseif ( /** This filter is documented in includes/class-ld-transients.php */ ! apply_filters( 'learndash_transients_disabled', LEARNDASH_TRANSIENTS_DISABLED, $transient_key ) ) { return set_transient( $transient_key, $transient_data, $transient_expire ); } } } } /** * Delete object cache by key. * * @since 3.4.1 * * @param string $transient_key The transient key. */ public static function delete( $transient_key = '' ) { if ( ! empty( $transient_key ) ) { /** This filter is documented in includes/class-ld-transients.php */ if ( apply_filters( 'learndash_object_cache_enabled', LEARNDASH_OBJECT_CACHE_ENABLED, $transient_key ) ) { return wp_cache_delete( $transient_key, self::$cache_group ); } elseif ( /** This filter is documented in includes/class-ld-transients.php */ ! apply_filters( 'learndash_transients_disabled', LEARNDASH_TRANSIENTS_DISABLED, $transient_key ) ) { return delete_transient( $transient_key ); } } } /** * Purge all transients. * * @since 3.1.0 */ public static function purge_all() { /** This filter is documented in includes/class-ld-transients.php */ if ( apply_filters( 'learndash_object_cache_enabled', LEARNDASH_OBJECT_CACHE_ENABLED, 'learndash_all_purge' ) ) { wp_cache_flush(); } elseif ( /** This filter is documented in includes/class-ld-transients.php */ ! apply_filters( 'learndash_transients_disabled', LEARNDASH_TRANSIENTS_DISABLED, 'learndash_all_purge' ) ) { global $wpdb; $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->options} WHERE option_name LIKE %s OR option_name LIKE %s", '_transient_learndash_%', '_transient_timeout_learndash_%' ) ); } } // End of functions. } }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
admin | Folder | 0755 |
|
|
classes | Folder | 0755 |
|
|
coupon | Folder | 0755 |
|
|
course | Folder | 0755 |
|
|
deprecated | Folder | 0755 |
|
|
dto | Folder | 0755 |
|
|
exam | Folder | 0755 |
|
|
group | Folder | 0755 |
|
|
gutenberg | Folder | 0755 |
|
|
helpers | Folder | 0755 |
|
|
import | Folder | 0755 |
|
|
interfaces | Folder | 0755 |
|
|
lib | Folder | 0755 |
|
|
licensing | Folder | 0755 |
|
|
loggers | Folder | 0755 |
|
|
models | Folder | 0755 |
|
|
payments | Folder | 0755 |
|
|
quiz | Folder | 0755 |
|
|
reports | Folder | 0755 |
|
|
rest-api | Folder | 0755 |
|
|
settings | Folder | 0755 |
|
|
shortcodes | Folder | 0755 |
|
|
site-health | Folder | 0755 |
|
|
views | Folder | 0755 |
|
|
widgets | Folder | 0755 |
|
|
class-ld-addons-updater.php | File | 35.03 KB | 0644 |
|
class-ld-bitbucket-api.php | File | 59.32 KB | 0644 |
|
class-ld-course-wizard.php | File | 29.51 KB | 0644 |
|
class-ld-cpt-instance.php | File | 34.14 KB | 0644 |
|
class-ld-cpt-widget.php | File | 198 B | 0644 |
|
class-ld-cpt.php | File | 18.17 KB | 0644 |
|
class-ld-custom-label.php | File | 24.3 KB | 0644 |
|
class-ld-design-wizard.php | File | 37.05 KB | 0644 |
|
class-ld-gdpr.php | File | 48.61 KB | 0644 |
|
class-ld-lms.php | File | 224.76 KB | 0644 |
|
class-ld-permalinks.php | File | 29.92 KB | 0644 |
|
class-ld-search.php | File | 6.66 KB | 0644 |
|
class-ld-semper-fi-module.php | File | 61.88 KB | 0644 |
|
class-ld-setup-wizard.php | File | 23.09 KB | 0644 |
|
class-ld-translations.php | File | 28.85 KB | 0644 |
|
class-ldlms-db.php | File | 19.01 KB | 0644 |
|
class-ldlms-post-types.php | File | 8.64 KB | 0644 |
|
class-ldlms-transients.php | File | 5.04 KB | 0644 |
|
ld-assignment-uploads.php | File | 38.35 KB | 0644 |
|
ld-autoupdate.php | File | 241 B | 0644 |
|
ld-certificates.php | File | 26.74 KB | 0644 |
|
ld-convert-post-pdf.php | File | 31.07 KB | 0644 |
|
ld-core-functions.php | File | 857 B | 0644 |
|
ld-groups.php | File | 92.44 KB | 0644 |
|
ld-license.php | File | 12.93 KB | 0644 |
|
ld-misc-functions.php | File | 72.5 KB | 0644 |
|
ld-reports.php | File | 59.38 KB | 0644 |
|
ld-scripts.php | File | 6.89 KB | 0644 |
|
ld-users.php | File | 47.6 KB | 0644 |
|
ld-wp-editor.php | File | 3.46 KB | 0644 |
|