Skip to content

Commit 7644e0b

Browse files
authored
Merge pull request #75 from t-hamano/fix/v3.3.2
v3.3.1
2 parents 20376f1 + 474af31 commit 7644e0b

File tree

7 files changed

+110
-46
lines changed

7 files changed

+110
-46
lines changed

.github/workflows/run-test-and-deploy.yml

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,24 @@ jobs:
1212
runs-on: ubuntu-latest
1313
strategy:
1414
matrix:
15-
php-versions: [
16-
'7.4',
17-
'8.0'
18-
]
19-
wp-versions: [
20-
'WordPress#6.1.3',
21-
'WordPress#6.2.2',
22-
'WordPress'
23-
]
24-
name: PHP ${{ matrix.php-versions }} / ${{ matrix.wp-versions }} Test
15+
include:
16+
- php: '7.4'
17+
wp: WordPress
18+
- php: '7.4'
19+
wp: WordPress#6.2.2
20+
- php: '7.4'
21+
wp: WordPress#6.1.3
22+
- php: '8.0'
23+
wp: WordPress
24+
- php: '8.0'
25+
wp: WordPress#6.2.2
26+
- php: '8.0'
27+
wp: WordPress#6.1.3
28+
- php: '8.2'
29+
wp: WordPress
30+
- php: '8.2'
31+
wp: WordPress#6.2.2
32+
name: PHP ${{ matrix.php }} / ${{ matrix.wp }} Test
2533

2634
steps:
2735
- uses: actions/checkout@v3
@@ -46,7 +54,7 @@ jobs:
4654

4755
- name: Install WordPress
4856
run: |
49-
WP_ENV_CORE=WordPress/${{ matrix.wp-versions }} WP_ENV_PHP_VERSION=${{ matrix.php-versions }} npm run wp-env start
57+
WP_ENV_CORE=WordPress/${{ matrix.wp }} WP_ENV_PHP_VERSION=${{ matrix.php }} npm run wp-env start
5058
npm run wp-env run cli wp core version
5159
npm run wp-env run cli wp cli info
5260

.github/workflows/run-test.yml

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,24 @@ jobs:
1515
runs-on: ubuntu-latest
1616
strategy:
1717
matrix:
18-
php-versions: [
19-
'7.4',
20-
'8.0'
21-
]
22-
wp-versions: [
23-
'WordPress#6.1.3',
24-
'WordPress#6.2.2',
25-
'WordPress'
26-
]
27-
name: PHP ${{ matrix.php-versions }} / ${{ matrix.wp-versions }} Test
18+
include:
19+
- php: '7.4'
20+
wp: WordPress
21+
- php: '7.4'
22+
wp: WordPress#6.2.2
23+
- php: '7.4'
24+
wp: WordPress#6.1.3
25+
- php: '8.0'
26+
wp: WordPress
27+
- php: '8.0'
28+
wp: WordPress#6.2.2
29+
- php: '8.0'
30+
wp: WordPress#6.1.3
31+
- php: '8.2'
32+
wp: WordPress
33+
- php: '8.2'
34+
wp: WordPress#6.2.2
35+
name: PHP ${{ matrix.php }} / ${{ matrix.wp }} Test
2836

2937
steps:
3038
- uses: actions/checkout@v3
@@ -49,7 +57,7 @@ jobs:
4957

5058
- name: Install WordPress
5159
run: |
52-
WP_ENV_CORE=WordPress/${{ matrix.wp-versions }} WP_ENV_PHP_VERSION=${{ matrix.php-versions }} npm run wp-env start
60+
WP_ENV_CORE=WordPress/${{ matrix.wp }} WP_ENV_PHP_VERSION=${{ matrix.php }} npm run wp-env start
5361
npm run wp-env run cli wp core version
5462
npm run wp-env run cli wp cli info
5563

classes/class-block-editor.php

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,23 @@ 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' ) );
24+
25+
// Enqueue block editor styles
26+
// TODO: Remove this conditional statement and unify it with `enqueue_block_assets` hook
27+
// when the supported minimum WordPress version is 6.3 or higher.
28+
if ( is_wp_version_compatible( '6.3' ) && is_admin() ) {
29+
add_action( 'enqueue_block_assets', array( $this, 'enqueue_editor_styles' ) );
30+
} else {
31+
add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_editor_styles' ) );
32+
}
1833
}
1934

2035
/**
@@ -23,27 +38,11 @@ function __construct() {
2338
public function enqueue_editor_scripts() {
2439
$asset_file = include( CHBE_PATH . '/build/block-editor.asset.php' );
2540

26-
// Abort the process if permission is disabled.
27-
$options = Settings::get_options();
28-
29-
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() ) {
3043
return;
3144
}
3245

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-
4746
wp_enqueue_script(
4847
CHBE_NAMESPACE,
4948
CHBE_URL . '/build/block-editor.js',
@@ -64,6 +63,30 @@ public function enqueue_editor_scripts() {
6463

6564
wp_set_script_translations( CHBE_NAMESPACE, CHBE_NAMESPACE );
6665
}
66+
67+
/**
68+
* Enqueue block editor styles
69+
*/
70+
public function enqueue_editor_styles() {
71+
// Abort the process if the user role permission is disabled.
72+
if ( ! Settings::is_allowed_user() ) {
73+
return;
74+
}
75+
76+
wp_enqueue_style(
77+
CHBE_NAMESPACE,
78+
CHBE_URL . '/build/style-block-editor.css',
79+
array(),
80+
filemtime( CHBE_PATH . '/build/style-block-editor.css' )
81+
);
82+
83+
wp_enqueue_style(
84+
CHBE_NAMESPACE . '-font',
85+
CHBE_URL . '/assets/css/fira-code.css',
86+
array(),
87+
filemtime( CHBE_PATH . '/assets/css/fira-code.css' )
88+
);
89+
}
6790
}
6891

6992
new BlockEditor();

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',

custom-html-block-extension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Description: Extend Custom HTML block to evolve into the advanced code editor.
55
* Requires at least: 6.1
66
* Requires PHP: 7.4
7-
* Version: 3.3.1
7+
* Version: 3.3.2
88
* Author: Aki Hamano
99
* Author URI: https://github.com/t-hamano
1010
* License: GPL2 or later

readme.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Tags: gutenberg, block, html, highlighting, emmet
44
Donate link: https://www.paypal.me/thamanoJP
55
Requires at least: 6.1
66
Tested up to: 6.3
7-
Stable tag: 3.3.1
7+
Stable tag: 3.3.2
88
Requires PHP: 7.4
99
License: GPLv2 or later
1010
License URI: https://www.gnu.org/licenses/gpl-2.0.html
@@ -69,6 +69,11 @@ Source: https://www.marksimonson.com/fonts/view/anonymous-pro
6969

7070
== Changelog ==
7171

72+
= 3.3.2 =
73+
74+
* Fix: Browser warning error in WordPress 6.3
75+
* Fix: User role settings are not applied to all editors
76+
7277
= 3.3.1 =
7378

7479
* Fix: some typos

0 commit comments

Comments
 (0)