@@ -149,6 +149,16 @@ protected static function enqueue_block_editor_layout_assets( $post_type ) {
149149 wp_enqueue_style ( 'newspack-content-gate ' , Newspack::plugin_url () . '/dist/content-gate-editor.css ' , [], $ asset ['version ' ] );
150150 }
151151
152+ /**
153+ * Check if the current theme is a block theme.
154+ *
155+ * @return boolean True if the current theme is a block theme.
156+ */
157+ private static function is_block_theme () {
158+ return function_exists ( 'wp_is_block_theme ' ) && wp_is_block_theme ();
159+ }
160+
161+
152162 /**
153163 * Get the number of visible paragraphs for the gate.
154164 *
@@ -205,11 +215,17 @@ public static function get_inline_gate_content_for_post( $gate_layout_id ) {
205215
206216 // Apply inline fade.
207217 if ( $ visible_paragraphs > 0 && $ inline_fade ) {
208- $ gate_content = '<div style="pointer-events: none; height: 10em; margin-top: -10em; width: 100%; position: absolute; background: linear-gradient(180deg, rgba(255,255,255,0) 14%, rgba(255,255,255,1) 76%);"></div> ' . $ gate_content ;
218+ $ gate_content = '<div style="pointer-events: none; height: 10em; margin-top: -10em; width: 100%; position: absolute; background: linear-gradient(180deg, rgba(255,255,255,0) 14%, rgba(255,255,255,1) 76%); max-width: 100%;"></div> ' . $ gate_content ;
219+ }
220+
221+ $ gate_content_classes = [ 'newspack-content-gate__gate ' , 'newspack-content-gate__inline-gate ' ];
222+ // Add a class if the current theme is a block theme.
223+ if ( self ::is_block_theme () ) {
224+ $ gate_content_classes [] = 'is-layout-constrained ' ;
209225 }
210226
211227 // Wrap gate in a div for styling.
212- $ gate_content = '<div class="newspack-content-gate__gate newspack-content-gate__inline-gate "> ' . $ gate_content . '</div> ' ;
228+ $ gate_content = '<div class=" ' . esc_attr ( implode ( ' ' , $ gate_content_classes ) ) . ' "> ' . $ gate_content . '</div> ' ;
213229 return $ gate_content ;
214230 }
215231
0 commit comments