Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

Newspack blocks: Load feature on agency sites
29 changes: 20 additions & 9 deletions projects/packages/jetpack-mu-wpcom/src/class-jetpack-mu-wpcom.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public static function init() {
add_action( 'plugins_loaded', array( __CLASS__, 'load_launchpad' ), 0 );
add_action( 'plugins_loaded', array( __CLASS__, 'load_coming_soon' ) );
add_action( 'plugins_loaded', array( __CLASS__, 'load_wpcom_rest_api_endpoints' ) );
add_action( 'plugins_loaded', array( __CLASS__, 'load_newspack_blocks' ) );

// These features run only on simple sites.
if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
Expand Down Expand Up @@ -369,7 +370,6 @@ public static function load_etk_features_flags() {
define( 'MU_WPCOM_HOMEPAGE_TITLE_HIDDEN', true );
define( 'MU_WPCOM_JETPACK_GLOBAL_STYLES', true );
define( 'A8C_USE_FONT_SMOOTHING_ANTIALIASED', false );
define( 'MU_WPCOM_NEWSPACK_BLOCKS', true );
define( 'MU_WPCOM_MAILERLITE_WIDGET', true );
define( 'MU_WPCOM_OVERRIDE_PREVIEW_BUTTON_URL', true );
define( 'MU_WPCOM_PARAGRAPH_BLOCK', true );
Expand Down Expand Up @@ -409,21 +409,13 @@ public static function load_etk_features() {

/**
* Load features for the editor and the frontend pages.
*
* This also avoid redeclaring the `Newspack_Blocks` class as follows
Copy link
Contributor

@fushar fushar Aug 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we delete

if ( ! class_exists( '\Newspack_Blocks', false ) ) {
	require_once __DIR__ . '/features/newspack-blocks/index.php';
}

given that we already load it in load_features()?

* - The `Newspack_Blocks` class is declared by jetpack-mu-wpcom plugin by the `plugin_loaded` hook.
* - When people try to activate the newspack blocks plugin, it will try to declare it again.
*/
global $pagenow;
$allowed_pages = array( 'post.php', 'post-new.php', 'site-editor.php' );
if ( ( isset( $pagenow ) && in_array( $pagenow, $allowed_pages, true ) ) || ! is_admin() ) {
require_once __DIR__ . '/features/block-editor/custom-line-height.php';
require_once __DIR__ . '/features/block-inserter-modifications/block-inserter-modifications.php';
require_once __DIR__ . '/features/hide-homepage-title/hide-homepage-title.php';
// To avoid potential collisions with newspack-blocks plugin.
if ( ! class_exists( '\Newspack_Blocks', false ) ) {
require_once __DIR__ . '/features/newspack-blocks/index.php';
}
require_once __DIR__ . '/features/override-preview-button-url/override-preview-button-url.php';
require_once __DIR__ . '/features/paragraph-block-placeholder/paragraph-block-placeholder.php';
require_once __DIR__ . '/features/tags-education/tags-education.php';
Expand All @@ -438,6 +430,25 @@ public static function load_etk_features() {
}
}

/**
* Load the newspack blocks feature for the editor and the frontend pages.
*/
public static function load_newspack_blocks() {
/**
* Avoid potential collisions with newspack-blocks plugin.
*/
if ( class_exists( '\Newspack_Blocks', false ) ) {
return;
}

global $pagenow;
$allowed_pages = array( 'post.php', 'post-new.php', 'site-editor.php' );
if ( ( isset( $pagenow ) && in_array( $pagenow, $allowed_pages, true ) ) || ! is_admin() ) {
define( 'MU_WPCOM_NEWSPACK_BLOCKS', true );
require_once __DIR__ . '/features/newspack-blocks/index.php';
}
}

/**
* Load the Coming Soon feature.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

Newspack blocks: Load feature on agency sites
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

Newspack blocks: Load feature on agency sites