Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boost: Cleanup minify modules #41647

Open
wants to merge 4 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 20 additions & 16 deletions projects/plugins/boost/app/lib/minify/functions-helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ function jetpack_boost_minify_cache_buster() {
* @param int $file_age The age of files to purge, in seconds.
*/
function jetpack_boost_page_optimize_cache_cleanup( $cache_folder = false, $file_age = DAY_IN_SECONDS ) {

if ( $cache_folder !== Config::get_static_cache_dir_path() ) {
if ( $file_age !== 0 ) {
// Cleanup obsolete files in static cache folder
Expand Down Expand Up @@ -329,29 +328,34 @@ function jetpack_boost_minify_serve_concatenated() {
}

/**
* Handles cache service initialization, scheduling of cache cleanup, and disabling of
* Jetpack photon-cdn for static JS/CSS. Automatically ensures that we don't setup
* the cache service more than once per request.
* Run during activation of any minify module.
*
* This handles scheduling cache cleanup, and setting up the cronjob to periodically test for the 404 handler.
*
* @return void
*/
function jetpack_boost_minify_setup() {
static $setup_done = false;
if ( $setup_done ) {
return;
}
$setup_done = true;

function jetpack_boost_minify_activation() {
// Schedule cache cleanup.
add_action( 'jetpack_boost_minify_cron_cache_cleanup', 'jetpack_boost_page_optimize_cache_cleanup' );
jetpack_boost_page_optimize_schedule_cache_cleanup();

if ( ! jetpack_boost_page_optimize_bail() ) {
// Disable Jetpack Site Accelerator CDN for static JS/CSS, if we're minifying this page.
add_filter( 'jetpack_force_disable_site_accelerator', '__return_true' );
// Setup the cronjob to periodically test for the 404 handler.
jetpack_boost_404_setup();
}

/**
* Run during initialization of any minify module.
*
* Run during every page load if any minify module is active.
*/
function jetpack_boost_minify_init() {
add_action( 'jetpack_boost_minify_cron_cache_cleanup', 'jetpack_boost_page_optimize_cache_cleanup' );

if ( jetpack_boost_page_optimize_bail() ) {
return;
}

jetpack_boost_404_setup();
// Disable Jetpack Site Accelerator CDN for static JS/CSS, if we're minifying this page.
add_filter( 'jetpack_force_disable_site_accelerator', '__return_true' );
}

function jetpack_boost_page_optimize_generate_concat_path( $url_paths, $dependency_path_mapping ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function jetpack_boost_404_tester() {
/**
* Setup the 404 tester.
*
* Schedule the 404 tester in three seconds if the concatenation modules
* Schedule the 404 tester if the concatenation modules
* haven't been toggled since this feature was released.
* Only run this in wp-admin to avoid excessive updates to the option.
*/
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Minify_CSS implements Pluggable, Changes_Page_Output, Optimization, Has_Ac
public function setup() {
require_once JETPACK_BOOST_DIR_PATH . '/app/lib/minify/functions-helpers.php';

jetpack_boost_minify_setup();
jetpack_boost_minify_init();

if ( jetpack_boost_page_optimize_bail() ) {
return;
Expand Down Expand Up @@ -51,6 +51,7 @@ public function init_minify() {
}

public static function activate() {
jetpack_boost_minify_activation();
jetpack_boost_404_tester();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Minify_JS implements Pluggable, Changes_Page_Output, Optimization, Has_Act
public function setup() {
require_once JETPACK_BOOST_DIR_PATH . '/app/lib/minify/functions-helpers.php';

jetpack_boost_minify_setup();
jetpack_boost_minify_init();

if ( jetpack_boost_page_optimize_bail() ) {
return;
Expand Down Expand Up @@ -51,6 +51,7 @@ public function init_minify() {
}

public static function activate() {
jetpack_boost_minify_activation();
jetpack_boost_404_tester();
}

Expand Down
5 changes: 5 additions & 0 deletions projects/plugins/boost/changelog/update-minify-concat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Cleanup around minify features


Loading