Skip to content

Commit 34a0187

Browse files
committed
Fix: Browser warning error in WordPress 6.3
1 parent 20376f1 commit 34a0187

File tree

1 file changed

+35
-14
lines changed

1 file changed

+35
-14
lines changed

classes/class-block-editor.php

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@ class BlockEditor {
1515
function __construct() {
1616
// Enqueue block editor scripts
1717
add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_editor_scripts' ) );
18+
19+
// Enqueue block editor styles
20+
// TODO: Remove this conditional statement and unify it with `enqueue_block_assets` hook
21+
// when the supported minimum WordPress version is 6.3 or higher.
22+
if ( is_wp_version_compatible( '6.3' ) && is_admin() ) {
23+
add_action( 'enqueue_block_assets', array( $this, 'enqueue_editor_styles' ) );
24+
} else {
25+
add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_editor_styles' ) );
26+
}
1827
}
1928

2029
/**
@@ -30,20 +39,6 @@ public function enqueue_editor_scripts() {
3039
return;
3140
}
3241

33-
wp_enqueue_style(
34-
CHBE_NAMESPACE,
35-
CHBE_URL . '/build/style-block-editor.css',
36-
array(),
37-
filemtime( CHBE_PATH . '/build/style-block-editor.css' )
38-
);
39-
40-
wp_enqueue_style(
41-
CHBE_NAMESPACE . '-font',
42-
CHBE_URL . '/assets/css/fira-code.css',
43-
array(),
44-
filemtime( CHBE_PATH . '/assets/css/fira-code.css' )
45-
);
46-
4742
wp_enqueue_script(
4843
CHBE_NAMESPACE,
4944
CHBE_URL . '/build/block-editor.js',
@@ -64,6 +59,32 @@ public function enqueue_editor_scripts() {
6459

6560
wp_set_script_translations( CHBE_NAMESPACE, CHBE_NAMESPACE );
6661
}
62+
63+
/**
64+
* Enqueue block editor styles
65+
*/
66+
public function enqueue_editor_styles() {
67+
// Abort the process if permission is disabled.
68+
$options = Settings::get_options();
69+
70+
if ( ! $options['permissionBlockEditor'] || ! Settings::is_allowed_user() ) {
71+
return;
72+
}
73+
74+
wp_enqueue_style(
75+
CHBE_NAMESPACE,
76+
CHBE_URL . '/build/style-block-editor.css',
77+
array(),
78+
filemtime( CHBE_PATH . '/build/style-block-editor.css' )
79+
);
80+
81+
wp_enqueue_style(
82+
CHBE_NAMESPACE . '-font',
83+
CHBE_URL . '/assets/css/fira-code.css',
84+
array(),
85+
filemtime( CHBE_PATH . '/assets/css/fira-code.css' )
86+
);
87+
}
6788
}
6889

6990
new BlockEditor();

0 commit comments

Comments
 (0)