PluginProbe
Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution / trunk
Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution vtrunk
2.0.1 trunk 1.0.0 1.1.0 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.5.0 1.6.0 1.6.1 1.7.0 1.7.1 1.8.0 1.9.0 2.0.0
solid-performance / src / views / cache / advanced-cache.php

advanced-cache.php in Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution trunk, at src/views/cache/advanced-cache.php

95 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Kadence Performance Advanced Cache Drop-In
4 * Plugin URI: https://kadencewp.com
5 * Description: A Kadence Performance drop-in that enhances site performance by caching responses, reducing server load, and minimizing response times.
6 * Version: {{swpsp-advanced-cache-version}}
7 * Author: Kadence
8 * Author URI: https://kadencewp.com
9 * License: GPLv2 or later
10 *
11 * This file is automatically generated. Do Not Modify.
12 *
13 * @package SolidWP\Performance
14 */
15
16 use SolidWP\Performance\Page_Cache\Buffer;
17 use SolidWP\Performance\Page_Cache\Cache;
18
19 if ( ! defined( 'ABSPATH' ) ) {
20 exit;
21 }
22
23 define( 'SWPSP_ADVANCED_CACHE', (bool) realpath( WP_CONTENT_DIR . '/{{swpsp-plugin-dir}}/solid-performance.php' ) );
24 define( 'SWPSP_ADVANCED_CACHE_VERSION', '{{swpsp-advanced-cache-version}}' );
25
26 if ( SWPSP_ADVANCED_CACHE ) {
27 // 1. Initialize Required Dependencies.
28 require_once WP_CONTENT_DIR . '/{{swpsp-plugin-dir}}/vendor/vendor-prefixed/autoload.php';
29 require_once WP_CONTENT_DIR . '/{{swpsp-plugin-dir}}/src/functions/app.php';
30 require_once WP_CONTENT_DIR . '/{{swpsp-plugin-dir}}/src/functions/filesystem.php';
31 require_once WP_CONTENT_DIR . '/{{swpsp-plugin-dir}}/src/functions/config.php';
32
33 spl_autoload_register(
34 static function ( $path ): void {
35 // Return if not loading a Kadence Performance class.
36 if ( strpos( $path, '\\SolidWP\\Performance' ) !== false ) {
37 return;
38 }
39
40 $path = str_replace( 'SolidWP\\Performance\\', 'src/Performance/', $path );
41 $path = str_replace( '\\', DIRECTORY_SEPARATOR, $path );
42 $file = WP_CONTENT_DIR . "/{{swpsp-plugin-dir}}/{$path}.php";
43
44 if ( file_exists( $file ) ) {
45 include_once $file;
46 }
47 }
48 );
49
50 // If the plugin is not activated, but this file remains, delete it.
51 add_action(
52 'init',
53 static function (): void {
54 if ( did_action( 'solidwp/performance/bootstrap_file_loaded' ) ) {
55 return;
56 }
57
58 if ( __DIR__ !== WP_CONTENT_DIR ) {
59 return;
60 }
61
62 // Skip this check if WordPress is installing/updating, as the actions won't fire.
63 if ( wp_installing() ) {
64 return;
65 }
66
67 unlink( __FILE__ );
68 }
69 );
70
71 // Boot our plugin instance early.
72 $container = swpsp_plugin()->container();
73
74 // Don't do anything if page caching is disabled.
75 // NOTE: You should not put any other code above this section, as the updater stops here.
76 if ( ! swpsp_config_get( 'page_cache.enabled' ) ) {
77 return;
78 }
79
80 try {
81 // 1. If cached file exists, serve it.
82 $cache = $container->get( Cache::class );
83 $cache->serve_cached_file();
84
85 // 2. If no cached file exists, try to save a cached version.
86 $buffer = $container->get( Buffer::class );
87 $buffer->register();
88 } catch ( Throwable $e ) {
89 swpsp_log( 'Kadence Performance - A critical error occurred: ' . $e->getMessage() );
90 }
91 } elseif ( __DIR__ === WP_CONTENT_DIR ) {
92 // If the plugin was deleted without deactivation, clean up after ourselves.
93 @unlink( __FILE__ );
94 }
95