Skip to content

Commit

Permalink
Check before including wpforteams lib
Browse files Browse the repository at this point in the history
  • Loading branch information
heavyweight committed Jan 23, 2024
1 parent 131396f commit e89db35
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions projects/packages/jetpack-mu-wpcom/src/class-jetpack-mu-wpcom.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ public static function init() {

add_action( 'plugins_loaded', array( __CLASS__, 'load_first_posts_stream_helpers' ) );

add_action( 'plugins_loaded', array( __CLASS__, 'load_verbum_comments' ) );
// This feature runs only on simple sites
if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
add_action( 'plugins_loaded', array( __CLASS__, 'load_verbum_comments' ) );
}

// Unified navigation fix for changes in WordPress 6.2.
add_action( 'admin_enqueue_scripts', array( __CLASS__, 'unbind_focusout_on_wp_admin_bar_menu_toggle' ) );
Expand Down Expand Up @@ -227,8 +230,13 @@ public static function load_first_posts_stream_helpers() {
* @param int $blog_id The blog ID.
* @return boolean
*/
private function should_disable_comment_experience( $blog_id ) {
require_once WP_CONTENT_DIR . '/lib/wpforteams/functions.php';
private static function should_disable_comment_experience( $blog_id ) {
$path_wp_for_teams = WP_CONTENT_DIR . '/lib/wpforteams/functions.php';

if ( file_exists( $path_wp_for_teams ) ) {
require_once $path_wp_for_teams;
}

// This covers both P2 and P2020 themes.
$is_p2 = str_contains( get_stylesheet(), 'pub/p2' ) || function_exists( '\WPForTeams\is_wpforteams_site' ) && is_wpforteams_site( $blog_id );
$is_forums = str_contains( get_stylesheet(), 'a8c/supportforums' ); // Not in /forums
Expand All @@ -251,7 +259,7 @@ public static function load_verbum_comments() {
if ( isset( $_GET['blogid'] ) ) {
$blog_id = intval( $_GET['blogid'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
}
if ( should_disable_comment_experience( $blog_id ) ) {
if ( self::should_disable_comment_experience( $blog_id ) ) {
return false;
}
require_once __DIR__ . '/build/verbum-comments/class-verbum-comments.php';
Expand Down

0 comments on commit e89db35

Please sign in to comment.