Skip to content

Commit 80892a6

Browse files
Prevent Customizer CSS from Loading on the frontend
- Updated enqueue block editor to only add the custom css for block editor by adding is_admin() - Added condition if option `loadCustomizerCSSFrontend` is false then remove wp_custom_css_cb where it add the custom css via frontend it also include in preview.
1 parent 087dab0 commit 80892a6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

php/Admin.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ public function run() {
5858
if ( (bool) $options['loadCustomizerCSSBlockEditor'] ) {
5959
add_action( 'enqueue_block_assets', array( $this, 'enqueue_customizer_css_block_editor' ), PHP_INT_MAX );
6060
}
61+
// Since by default wp_custom_css_cb is add_action wp_head, just remove_action.
62+
if ( ! (bool) $options['loadCustomizerCSSFrontend'] ) {
63+
remove_action('wp_head', 'wp_custom_css_cb', 101);
64+
}
6165
}
6266

6367

@@ -568,7 +572,7 @@ public function admin_page() {
568572
*/
569573
public function enqueue_customizer_css_block_editor() {
570574
$custom_css = wp_get_custom_css();
571-
if ( ! empty( $custom_css ) ) {
575+
if ( ! empty( $custom_css ) && is_admin() ) {
572576
wp_register_style(
573577
'dlx-pw-customizer-css-block-editor',
574578
false

0 commit comments

Comments
 (0)