Skip to content

Commit dbfb271

Browse files
committed
fix: only register when content gate active
1 parent acfc48e commit dbfb271

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

includes/class-blocks.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public static function enqueue_block_editor_assets() {
6060
'has_recaptcha' => Recaptcha::can_use_captcha(),
6161
'recaptcha_url' => admin_url( 'admin.php?page=newspack-settings' ),
6262
'corrections_enabled' => wp_is_block_theme() && class_exists( 'Newspack\Corrections' ),
63+
'has_content_gate' => Memberships::is_active() && Memberships::has_gate(),
6364
]
6465
);
6566
\wp_enqueue_style(

src/blocks/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export const blocks = [ readerRegistration, correctionBox, correctionItem, avata
2323

2424
const readerActivationBlocks = [ 'newspack/reader-registration' ];
2525
const correctionBlocks = [ 'newspack/correction-box', 'newspack/correction-item' ];
26+
const contentGateBlocks = [ 'newspack/content-gate-countdown' ];
2627

2728
/**
2829
* Function to register an individual block.
@@ -46,6 +47,11 @@ const registerBlock = block => {
4647
return;
4748
}
4849

50+
/** Do not register content gate blocks if there is no gate. */
51+
if ( contentGateBlocks.includes( name ) && ! newspack_blocks.has_content_gate ) {
52+
return;
53+
}
54+
4955
registerBlockType( { name, ...metadata }, settings );
5056
};
5157

0 commit comments

Comments
 (0)