Skip to content

Commit 7e48ed4

Browse files
authored
Boost: Allow control over whether a module should run or not (#44246)
1 parent 5e852db commit 7e48ed4

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

projects/plugins/boost/app/modules/class-modules-setup.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,23 @@ public function on_module_status_update( $module_slug, $is_activated ) {
292292
*/
293293
public function can_module_run( $module ) {
294294
$website_public = Config::is_website_public();
295+
$can_module_run = true;
296+
297+
// If the module requires the website to be public and it's not, don't allow it to run.
295298
if ( $module->feature instanceof Needs_Website_To_Be_Public && ! $website_public ) {
296-
return false;
299+
$can_module_run = false;
297300
}
298301

299-
return true;
302+
/**
303+
* Filter to allow modules to run even if the website is not public.
304+
* This is useful for debugging purposes.
305+
*
306+
* @since $$next-version$$
307+
*
308+
* @param bool $can_module_run Whether the module should be disabled.
309+
* @param Module $module The module to check.
310+
* @param bool $website_public Whether the website is public.
311+
*/
312+
return apply_filters( 'jetpack_boost_can_module_run', $can_module_run, $module, $website_public );
300313
}
301314
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: added
3+
4+
General: Add WP filter (jetpack_boost_can_module_run) to allow more control over which modules can run their functionality.

0 commit comments

Comments
 (0)