Skip to content

Commit

Permalink
SEO tools suite loading even if the site is not active and not in dev…
Browse files Browse the repository at this point in the history
…elopment mode. (#7900)

* Added seo tools suite loading even if the site is not active and not in development mode.

This is required because with some recent changes in the code SEO tool class constants are required by the code even when Jetpack is not active, for example in multisite environment.

Fixes #7898.

* Improved condition readability and clarified a filter comment.
  • Loading branch information
zinigor authored and dereksmart committed Sep 29, 2017
1 parent 84b19b1 commit 635bc6f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
16 changes: 10 additions & 6 deletions class.jetpack.php
Original file line number Diff line number Diff line change
Expand Up @@ -1654,10 +1654,15 @@ function user_role_change( $user_id ) {
* Loads the currently active modules.
*/
public static function load_modules() {
if ( ! self::is_active() && !self::is_development_mode() ) {
if ( ! is_multisite() || ! get_site_option( 'jetpack_protect_active' ) ) {
return;
}
if (
! self::is_active()
&& ! self::is_development_mode()
&& (
! is_multisite()
|| ! get_site_option( 'jetpack_protect_active' )
)
) {
return;
}

$version = Jetpack_Options::get_option( 'version' );
Expand Down Expand Up @@ -1734,8 +1739,7 @@ public static function load_modules() {
do_action( 'jetpack_modules_loaded' );

// Load module-specific code that is needed even when a module isn't active. Loaded here because code contained therein may need actions such as setup_theme.
if ( Jetpack::is_active() || Jetpack::is_development_mode() )
require_once( JETPACK__PLUGIN_DIR . 'modules/module-extras.php' );
require_once( JETPACK__PLUGIN_DIR . 'modules/module-extras.php' );
}

/**
Expand Down
10 changes: 10 additions & 0 deletions modules/module-extras.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,20 @@
'verification-tools/verification-tools-utils.php',
);

// Not every tool needs to be included if Jetpack is inactive and not in development mode
if ( ! Jetpack::is_active() && ! Jetpack::is_development_mode() ) {
$tools = array(
'seo-tools/jetpack-seo-utils.php',
'seo-tools/jetpack-seo-titles.php',
'seo-tools/jetpack-seo-posts.php',
);
}

/**
* Filter extra tools (not modules) to include.
*
* @since 2.4.0
* @since 5.4.0 can be used in multisite when Jetpack is not connected to WordPress.com and not in development mode.
*
* @param array $tools Array of extra tools to include.
*/
Expand Down

0 comments on commit 635bc6f

Please sign in to comment.