| @@ -152,9 +152,12 @@ | ||
| 152 | 152 | if ( ! $content || $this->is_skip_inner_block ) { |
| 153 | 153 | // When called from the editor's ServerSideRender (REST API), RenderContainer (JS) already |
| 154 | 154 | // provides the outer ablocks-block-{blockId} wrapper via useBlockProps. Including it here |
| 155 | 155 | // too causes the Advanced-settings CSS selector to match two elements → double border/padding. |
| 156 | - if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) { | |
| 156 | + // Only that preview render (it always sends context=edit): front-end REST endpoints such as the | |
| 157 | + // loop filter re-render blocks into the page, where the wrapper and its scoped styles are needed. | |
| 158 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended | |
| 159 | + if ( defined( 'REST_REQUEST' ) && REST_REQUEST && 'edit' === ( $_REQUEST['context'] ?? '' ) ) { | |
| 157 | 160 | ob_start(); |
| 158 | 161 | echo $this->render_block_content( $attributes, $content, $block_instance ); |
| 159 | 162 | $content = ob_get_clean(); |
| 160 | 163 | } else { |