@@ -15,6 +15,15 @@ class BlockEditor {
15
15
function __construct () {
16
16
// Enqueue block editor scripts
17
17
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
+ }
18
27
}
19
28
20
29
/**
@@ -30,20 +39,6 @@ public function enqueue_editor_scripts() {
30
39
return ;
31
40
}
32
41
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
-
47
42
wp_enqueue_script (
48
43
CHBE_NAMESPACE ,
49
44
CHBE_URL . '/build/block-editor.js ' ,
@@ -64,6 +59,32 @@ public function enqueue_editor_scripts() {
64
59
65
60
wp_set_script_translations ( CHBE_NAMESPACE , CHBE_NAMESPACE );
66
61
}
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
+ }
67
88
}
68
89
69
90
new BlockEditor ();
0 commit comments