Skip to content

Commit f2223c1

Browse files
committed
Fix: User role settings are not applied to all editors
1 parent 7c00c61 commit f2223c1

File tree

3 files changed

+34
-12
lines changed

3 files changed

+34
-12
lines changed

classes/class-block-editor.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ class BlockEditor {
1313
* Constructor
1414
*/
1515
function __construct() {
16+
// Abort the process if the editor isn't allowed to use this extension.
17+
$options = Settings::get_options();
18+
if ( ! $options['permissionBlockEditor'] ) {
19+
return;
20+
}
21+
1622
// Enqueue block editor scripts
1723
add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_editor_scripts' ) );
1824

@@ -32,10 +38,8 @@ function __construct() {
3238
public function enqueue_editor_scripts() {
3339
$asset_file = include( CHBE_PATH . '/build/block-editor.asset.php' );
3440

35-
// Abort the process if permission is disabled.
36-
$options = Settings::get_options();
37-
38-
if ( ! $options['permissionBlockEditor'] || ! Settings::is_allowed_user() ) {
41+
// Abort the process if the user role isn't allowed to use this extension.
42+
if ( ! Settings::is_allowed_user() ) {
3943
return;
4044
}
4145

@@ -64,10 +68,8 @@ public function enqueue_editor_scripts() {
6468
* Enqueue block editor styles
6569
*/
6670
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+
// Abort the process if the user role permission is disabled.
72+
if ( ! Settings::is_allowed_user() ) {
7173
return;
7274
}
7375

classes/class-classic-editor.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class ClassicEditor {
1313
* Constructor
1414
*/
1515
public function __construct() {
16-
// Abort the process if permission is disabled.
16+
// Abort the process if the editor isn't allowed to use this extenson.
1717
$options = Settings::get_options();
1818
if ( ! $options['permissionClassicEditor'] ) {
1919
return;
@@ -42,14 +42,19 @@ public function admin_enqueue_scripts( $hook_suffix ) {
4242
return;
4343
}
4444

45-
// Abort the process if block editor is enabled.
45+
// Abort the process if the block editor is enabled.
4646
if ( ! function_exists( 'get_current_screen' ) ) {
4747
return;
4848
}
4949
if ( get_current_screen()->is_block_editor ) {
5050
return;
5151
}
5252

53+
// Abort the process if the user role isn't allowed to use this extension.
54+
if ( ! Settings::is_allowed_user() ) {
55+
return;
56+
}
57+
5358
wp_enqueue_style(
5459
CHBE_NAMESPACE,
5560
CHBE_URL . '/build/style-classic-editor.css',
@@ -106,6 +111,11 @@ public function media_buttons( $editor_id ) {
106111
return;
107112
}
108113

114+
// Abort the process if the user role isn't allowed to use this extension.
115+
if ( ! Settings::is_allowed_user() ) {
116+
return;
117+
}
118+
109119
printf(
110120
'<button type="button" class="button chbe-replace-indent" id="chbe-replace-indent-button">' . Settings::ICON . ' %s' . '</button>',
111121
__( 'Change Indentation', 'custom-html-block-extension' )
@@ -116,7 +126,7 @@ public function media_buttons( $editor_id ) {
116126
* Add dialog
117127
*/
118128
public function admin_footer() {
119-
// Abort the process if block editor is enabled.
129+
// Abort the process if the block editor is enabled.
120130
if ( ! function_exists( 'get_current_screen' ) ) {
121131
return;
122132
}
@@ -129,6 +139,11 @@ public function admin_footer() {
129139
return;
130140
}
131141

142+
// Abort the process if the user role isn't allowed to use this extension.
143+
if ( ! Settings::is_allowed_user() ) {
144+
return;
145+
}
146+
132147
$settings = Settings::get_editor_settings();
133148
// phpcs:disable Generic.ControlStructures.InlineControlStructure
134149
?>

classes/class-theme-plugin-editor.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class ThemePluginEditor {
1313
* Constructor
1414
*/
1515
public function __construct() {
16-
// Abort the process if permission is disabled.
16+
// Abort the process if the editor isn't allowed to use this extenson.
1717
$options = Settings::get_options();
1818
if ( ! $options['permissionThemePluginEditor'] ) {
1919
return;
@@ -32,6 +32,11 @@ public function admin_enqueue_scripts( $hook_suffix ) {
3232
return;
3333
}
3434

35+
// Abort the process if the user role isn't allowed to use this extension.
36+
if ( ! Settings::is_allowed_user() ) {
37+
return;
38+
}
39+
3540
// Correspondence between the file extension and the language specified in the Monaco Editor
3641
$map_to_lang = array(
3742
'css' => 'css',

0 commit comments

Comments
 (0)