This commit is contained in:
2026-07-02 15:54:39 -06:00
commit 9883323161
17470 changed files with 4470592 additions and 0 deletions
@@ -0,0 +1,37 @@
<?php
namespace Automattic\Jetpack_Boost\Modules\Optimizations\Page_Cache\Data_Sync_Actions;
use Automattic\Jetpack\WP_JS_Data_Sync\Contracts\Data_Sync_Action;
use Automattic\Jetpack_Boost\Modules\Optimizations\Page_Cache\Pre_WordPress\Boost_Cache;
/**
* Page Cache: Clear page cache
*/
class Clear_Page_Cache implements Data_Sync_Action {
/**
* Handles the action logic.
*
* @param mixed $_data JSON Data passed to the action.
* @param \WP_REST_Request $_request The request object.
*/
public function handle( $_data, $_request ) {
$cache = new Boost_Cache();
$delete = $cache->delete_recursive( home_url() );
if ( $delete === null || is_wp_error( $delete ) ) {
return array(
'message' => __( 'Cache already cleared.', 'jetpack-boost' ),
);
}
if ( $delete ) {
return array(
'message' => __( 'Cache cleared.', 'jetpack-boost' ),
);
}
return new \WP_Error( 'unable-to-clear-cache', __( 'Unable to clear cache.', 'jetpack-boost' ) );
}
}
@@ -0,0 +1,37 @@
<?php
namespace Automattic\Jetpack_Boost\Modules\Optimizations\Page_Cache\Data_Sync_Actions;
use Automattic\Jetpack\WP_JS_Data_Sync\Contracts\Data_Sync_Action;
/**
* Cache Action: Disable Super Cache
*/
class Deactivate_WPSC implements Data_Sync_Action {
/**
* Handles the action logic.
*
* @param mixed $_data JSON Data passed to the action.
* @param null|\WP_REST_Request $_request The request object.
*/
public function handle( $_data = null, $_request = null ) {
// Super Cache will define WPCACHEHOME if it's active.
if ( ! defined( 'WPCACHEHOME' ) ) {
return true;
}
// Find the plugin base path for super cache.
$super_cache_dir = basename( WPCACHEHOME );
$plugin = $super_cache_dir . '/wp-cache.php';
// Load the necessary files to deactivate the plugin.
require_once ABSPATH . 'wp-admin/includes/misc.php';
require_once ABSPATH . 'wp-admin/includes/file.php';
deactivate_plugins( $plugin );
$success = ! is_plugin_active( $plugin );
return $success;
}
}
@@ -0,0 +1,36 @@
<?php
namespace Automattic\Jetpack_Boost\Modules\Optimizations\Page_Cache\Data_Sync_Actions;
use Automattic\Jetpack\WP_JS_Data_Sync\Contracts\Data_Sync_Action;
use Automattic\Jetpack_Boost\Modules\Optimizations\Page_Cache\Garbage_Collection;
use Automattic\Jetpack_Boost\Modules\Optimizations\Page_Cache\Page_Cache_Setup;
use Automattic\Jetpack_Boost\Modules\Optimizations\Page_Cache\Pre_WordPress\Boost_Cache_Settings;
/**
* Critical CSS Action: request regeneration.
*/
class Run_Setup implements Data_Sync_Action {
/**
* Handles the action logic.
*
* @param mixed $_data JSON Data passed to the action.
* @param \WP_REST_Request $_request The request object.
*/
public function handle( $_data, $_request ) {
$setup_result = Page_Cache_Setup::run_setup();
if ( is_wp_error( $setup_result ) ) {
return $setup_result;
}
Garbage_Collection::activate();
Boost_Cache_Settings::get_instance()->set( array( 'enabled' => true ) );
return array(
'success' => true,
'notices' => Page_Cache_Setup::get_notices(),
);
}
}