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

87 lines 2.5 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', (bool) realpath( WP_CONTENT_DIR . '/{{swpsp-plugin-dir}}/solid-performance.php' ) );
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 // Skip this check if WordPress is installing/updating, as the actions won't fire.
55 if ( wp_installing() ) {
56 return;
57 }
58
59 unlink( __FILE__ );
60 }
61 );
62
63 // Boot our plugin instance early.
64 $container = swpsp_plugin()->container();
65
66 // Don't do anything if page caching is disabled.
67 // NOTE: You should not put any other code above this section, as the updater stops here.
68 if ( ! swpsp_config_get( 'page_cache.enabled' ) ) {
69 return;
70 }
71
72 try {
73 // 1. If cached file exists, serve it.
74 $cache = $container->get( Cache::class );
75 $cache->serve_cached_file();
76
77 // 2. If no cached file exists, try to save a cached version.
78 $buffer = $container->get( Buffer::class );
79 $buffer->register();
80 } catch ( Throwable $e ) {
81 swpsp_log( 'Solid Performance - A critical error occurred: ' . $e->getMessage() );
82 }
83 } elseif ( __DIR__ === WP_CONTENT_DIR ) {
84 // If the plugin was deleted without deactivation, clean up after ourselves.
85 @unlink( __FILE__ );
86 }
87