| @@ -8,11 +8,10 @@ | ||
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | 10 | namespace RadiusTheme\SB\Helpers; |
| 11 | 11 | |
| 12 | +use RadiusTheme\SB\Traits\SingletonTrait; | |
| 12 | 13 | use W3TC\Dispatcher; |
| 13 | -use RadiusTheme\SB\Traits\SingletonTrait; | |
| 14 | -use RadiusTheme\SB\Controllers\AssetRegistry; | |
| 15 | 14 | |
| 16 | 15 | // Do not allow directly accessing this file. |
| 17 | 16 | if ( ! defined( 'ABSPATH' ) ) { |
| 18 | 17 | exit( 'This script cannot be accessed directly.' ); |
| @@ -32,9 +31,8 @@ | ||
| 32 | 31 | self::clear_data_cache(); |
| 33 | 32 | self::clear_template_cache(); |
| 34 | 33 | self::clear_plugins_cache(); |
| 35 | 34 | self::clear_transient_cache(); |
| 36 | - self::clear_asset_cache(); | |
| 37 | 35 | } |
| 38 | 36 | /** |
| 39 | 37 | * Clear the template cache. |
| 40 | 38 | * |
| @@ -55,11 +53,8 @@ | ||
| 55 | 53 | } |
| 56 | 54 | if ( method_exists( 'LiteSpeed_Cache_API', 'purge_all' ) ) { |
| 57 | 55 | \LiteSpeed_Cache_API::purge_all(); |
| 58 | 56 | } |
| 59 | - if ( class_exists( '\LiteSpeed\Purge' ) ) { | |
| 60 | - \LiteSpeed\Purge::purge_all(); | |
| 61 | - } | |
| 62 | 57 | if ( class_exists( 'Endurance_Page_Cache' ) ) { |
| 63 | 58 | $epc = new \Endurance_Page_Cache(); |
| 64 | 59 | $epc->purge_all(); |
| 65 | 60 | } |
| @@ -159,12 +154,10 @@ | ||
| 159 | 154 | * Purge GoDaddy Managed WordPress Hosting (Varnish) |
| 160 | 155 | * |
| 161 | 156 | * Source: https://github.com/wp-media/wp-rocket/blob/master/inc/3rd-party/hosting/godaddy.php |
| 162 | 157 | * |
| 163 | - * @param string $method The request method. | |
| 164 | - * @param string $url The request URL. | |
| 165 | - * | |
| 166 | - * @return void | |
| 158 | + * @param String $method | |
| 159 | + * @param String|Null $url | |
| 167 | 160 | */ |
| 168 | 161 | public static function godaddy_request( $method, $url = null ) { |
| 169 | 162 | $url = empty( $url ) ? home_url() : $url; |
| 170 | 163 | $host = wp_parse_url( $url, PHP_URL_HOST ); |
| @@ -216,10 +209,9 @@ | ||
| 216 | 209 | * Added data cache. |
| 217 | 210 | * |
| 218 | 211 | * @since 4.3.0 |
| 219 | 212 | * @param string $cache_key Object cache key. |
| 220 | - * | |
| 221 | - * @return void | |
| 213 | + * @param string $data Located template. | |
| 222 | 214 | */ |
| 223 | 215 | public static function set_data_cache_key( $cache_key ) { |
| 224 | 216 | $cached_data = wp_cache_get( 'shopbuilder_cached_data', 'shopbuilder' ); |
| 225 | 217 | if ( is_array( $cached_data ) ) { |
| @@ -243,72 +235,10 @@ | ||
| 243 | 235 | wp_cache_delete( 'shopbuilder_cached_data', 'shopbuilder' ); |
| 244 | 236 | } |
| 245 | 237 | } |
| 246 | 238 | |
| 247 | - /** | |
| 248 | - * Clear asset cache. | |
| 249 | - * | |
| 250 | - * @return void | |
| 251 | - */ | |
| 252 | - public static function clear_asset_cache() { | |
| 253 | - if ( ! Fns::is_optimization_enabled() ) { | |
| 254 | - return; | |
| 255 | - } | |
| 256 | 239 | |
| 257 | - $upload_dir = wp_upload_dir(); | |
| 258 | - $asset_dir = trailingslashit( $upload_dir['basedir'] ) . 'shopbuilder_uploads/cache/'; | |
| 259 | - | |
| 260 | - // Delete old assets. | |
| 261 | - if ( is_dir( $asset_dir ) ) { | |
| 262 | - self::delete_dir_contents( $asset_dir ); | |
| 263 | - } | |
| 264 | - | |
| 265 | - // Re-generate assets. | |
| 266 | - AssetRegistry::instance()->regenerate_bundles(); | |
| 267 | - } | |
| 268 | - | |
| 269 | 240 | /** |
| 270 | - * Recursively delete directory contents. | |
| 271 | - * | |
| 272 | - * @param string $dir Directory path. | |
| 273 | - * @return void | |
| 274 | - */ | |
| 275 | - public static function delete_dir_contents( $dir ) { | |
| 276 | - global $wp_filesystem; | |
| 277 | - | |
| 278 | - if ( ! function_exists( 'WP_Filesystem' ) ) { | |
| 279 | - require_once ABSPATH . 'wp-admin/includes/file.php'; | |
| 280 | - } | |
| 281 | - | |
| 282 | - if ( ! $wp_filesystem ) { | |
| 283 | - WP_Filesystem(); | |
| 284 | - } | |
| 285 | - | |
| 286 | - if ( ! $wp_filesystem->is_dir( $dir ) ) { | |
| 287 | - return; | |
| 288 | - } | |
| 289 | - | |
| 290 | - $contents = $wp_filesystem->dirlist( $dir ); | |
| 291 | - | |
| 292 | - if ( ! is_array( $contents ) ) { | |
| 293 | - return; | |
| 294 | - } | |
| 295 | - | |
| 296 | - foreach ( $contents as $item ) { | |
| 297 | - $path = trailingslashit( $dir ) . $item['name']; | |
| 298 | - | |
| 299 | - if ( 'f' === $item['type'] ) { | |
| 300 | - $wp_filesystem->delete( $path, false ); | |
| 301 | - } elseif ( 'd' === $item['type'] ) { | |
| 302 | - self::delete_dir_contents( $path ); | |
| 303 | - | |
| 304 | - $wp_filesystem->delete( $path, true ); | |
| 305 | - } | |
| 306 | - } | |
| 307 | - } | |
| 308 | - | |
| 309 | - | |
| 310 | - /** | |
| 311 | 241 | * Added data cache. |
| 312 | 242 | * |
| 313 | 243 | * @since 4.3.0 |
| 314 | 244 | * @param string $cache_key Transient cache key. |
| @@ -335,35 +265,7 @@ | ||
| 335 | 265 | foreach ( $cached_templates as $cache_key ) { |
| 336 | 266 | delete_transient( $cache_key ); |
| 337 | 267 | } |
| 338 | 268 | delete_transient( 'shopbuilder_transient_cached_data' ); |
| 339 | - } | |
| 340 | - | |
| 341 | - self::delete_all_theme_css_handle_transients(); | |
| 342 | - } | |
| 343 | - | |
| 344 | - /** | |
| 345 | - * Clear all theme css handle transients. | |
| 346 | - * | |
| 347 | - * @return void | |
| 348 | - */ | |
| 349 | - public static function delete_all_theme_css_handle_transients() { | |
| 350 | - global $wpdb; | |
| 351 | - | |
| 352 | - $prefix = '_transient_'; | |
| 353 | - $transient_ns = 'rtsb_theme_css_handle_'; | |
| 354 | - | |
| 355 | - // Fetch all matching transient option names. | |
| 356 | - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching | |
| 357 | - $transients = $wpdb->get_col( | |
| 358 | - $wpdb->prepare( | |
| 359 | - "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE %s", | |
| 360 | - $wpdb->esc_like( $prefix . $transient_ns ) . '%' | |
| 361 | - ) | |
| 362 | - ); | |
| 363 | - | |
| 364 | - foreach ( $transients as $option_name ) { | |
| 365 | - $key = str_replace( '_transient_', '', $option_name ); | |
| 366 | - delete_transient( $key ); | |
| 367 | 269 | } |
| 368 | 270 | } |
| 369 | 271 | } |