PluginProbe
Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution / 1.3.0
Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution v1.3.0
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 1.3.0, at src/views/cache/advanced-cache.php

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