diff --git a/.github/workflows/run-test-and-deploy.yml b/.github/workflows/run-test-and-deploy.yml index d970d2d..e4a442e 100644 --- a/.github/workflows/run-test-and-deploy.yml +++ b/.github/workflows/run-test-and-deploy.yml @@ -12,16 +12,24 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-versions: [ - '7.4', - '8.0' - ] - wp-versions: [ - 'WordPress#6.1.3', - 'WordPress#6.2.2', - 'WordPress' - ] - name: PHP ${{ matrix.php-versions }} / ${{ matrix.wp-versions }} Test + include: + - php: '7.4' + wp: WordPress + - php: '7.4' + wp: WordPress#6.2.2 + - php: '7.4' + wp: WordPress#6.1.3 + - php: '8.0' + wp: WordPress + - php: '8.0' + wp: WordPress#6.2.2 + - php: '8.0' + wp: WordPress#6.1.3 + - php: '8.2' + wp: WordPress + - php: '8.2' + wp: WordPress#6.2.2 + name: PHP ${{ matrix.php }} / ${{ matrix.wp }} Test steps: - uses: actions/checkout@v3 @@ -46,7 +54,7 @@ jobs: - name: Install WordPress run: | - WP_ENV_CORE=WordPress/${{ matrix.wp-versions }} WP_ENV_PHP_VERSION=${{ matrix.php-versions }} npm run wp-env start + WP_ENV_CORE=WordPress/${{ matrix.wp }} WP_ENV_PHP_VERSION=${{ matrix.php }} npm run wp-env start npm run wp-env run cli wp core version npm run wp-env run cli wp cli info diff --git a/.github/workflows/run-test.yml b/.github/workflows/run-test.yml index 19e04fb..4bb7e9b 100644 --- a/.github/workflows/run-test.yml +++ b/.github/workflows/run-test.yml @@ -15,16 +15,24 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-versions: [ - '7.4', - '8.0' - ] - wp-versions: [ - 'WordPress#6.1.3', - 'WordPress#6.2.2', - 'WordPress' - ] - name: PHP ${{ matrix.php-versions }} / ${{ matrix.wp-versions }} Test + include: + - php: '7.4' + wp: WordPress + - php: '7.4' + wp: WordPress#6.2.2 + - php: '7.4' + wp: WordPress#6.1.3 + - php: '8.0' + wp: WordPress + - php: '8.0' + wp: WordPress#6.2.2 + - php: '8.0' + wp: WordPress#6.1.3 + - php: '8.2' + wp: WordPress + - php: '8.2' + wp: WordPress#6.2.2 + name: PHP ${{ matrix.php }} / ${{ matrix.wp }} Test steps: - uses: actions/checkout@v3 @@ -49,7 +57,7 @@ jobs: - name: Install WordPress run: | - WP_ENV_CORE=WordPress/${{ matrix.wp-versions }} WP_ENV_PHP_VERSION=${{ matrix.php-versions }} npm run wp-env start + WP_ENV_CORE=WordPress/${{ matrix.wp }} WP_ENV_PHP_VERSION=${{ matrix.php }} npm run wp-env start npm run wp-env run cli wp core version npm run wp-env run cli wp cli info diff --git a/classes/class-block-editor.php b/classes/class-block-editor.php index eb8b380..1e4de72 100644 --- a/classes/class-block-editor.php +++ b/classes/class-block-editor.php @@ -13,8 +13,23 @@ class BlockEditor { * Constructor */ function __construct() { + // Abort the process if the editor isn't allowed to use this extension. + $options = Settings::get_options(); + if ( ! $options['permissionBlockEditor'] ) { + return; + } + // Enqueue block editor scripts add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_editor_scripts' ) ); + + // Enqueue block editor styles + // TODO: Remove this conditional statement and unify it with `enqueue_block_assets` hook + // when the supported minimum WordPress version is 6.3 or higher. + if ( is_wp_version_compatible( '6.3' ) && is_admin() ) { + add_action( 'enqueue_block_assets', array( $this, 'enqueue_editor_styles' ) ); + } else { + add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_editor_styles' ) ); + } } /** @@ -23,27 +38,11 @@ function __construct() { public function enqueue_editor_scripts() { $asset_file = include( CHBE_PATH . '/build/block-editor.asset.php' ); - // Abort the process if permission is disabled. - $options = Settings::get_options(); - - if ( ! $options['permissionBlockEditor'] || ! Settings::is_allowed_user() ) { + // Abort the process if the user role isn't allowed to use this extension. + if ( ! Settings::is_allowed_user() ) { return; } - wp_enqueue_style( - CHBE_NAMESPACE, - CHBE_URL . '/build/style-block-editor.css', - array(), - filemtime( CHBE_PATH . '/build/style-block-editor.css' ) - ); - - wp_enqueue_style( - CHBE_NAMESPACE . '-font', - CHBE_URL . '/assets/css/fira-code.css', - array(), - filemtime( CHBE_PATH . '/assets/css/fira-code.css' ) - ); - wp_enqueue_script( CHBE_NAMESPACE, CHBE_URL . '/build/block-editor.js', @@ -64,6 +63,30 @@ public function enqueue_editor_scripts() { wp_set_script_translations( CHBE_NAMESPACE, CHBE_NAMESPACE ); } + + /** + * Enqueue block editor styles + */ + public function enqueue_editor_styles() { + // Abort the process if the user role permission is disabled. + if ( ! Settings::is_allowed_user() ) { + return; + } + + wp_enqueue_style( + CHBE_NAMESPACE, + CHBE_URL . '/build/style-block-editor.css', + array(), + filemtime( CHBE_PATH . '/build/style-block-editor.css' ) + ); + + wp_enqueue_style( + CHBE_NAMESPACE . '-font', + CHBE_URL . '/assets/css/fira-code.css', + array(), + filemtime( CHBE_PATH . '/assets/css/fira-code.css' ) + ); + } } new BlockEditor(); diff --git a/classes/class-classic-editor.php b/classes/class-classic-editor.php index c4e3f57..e1b8877 100644 --- a/classes/class-classic-editor.php +++ b/classes/class-classic-editor.php @@ -13,7 +13,7 @@ class ClassicEditor { * Constructor */ public function __construct() { - // Abort the process if permission is disabled. + // Abort the process if the editor isn't allowed to use this extenson. $options = Settings::get_options(); if ( ! $options['permissionClassicEditor'] ) { return; @@ -42,7 +42,7 @@ public function admin_enqueue_scripts( $hook_suffix ) { return; } - // Abort the process if block editor is enabled. + // Abort the process if the block editor is enabled. if ( ! function_exists( 'get_current_screen' ) ) { return; } @@ -50,6 +50,11 @@ public function admin_enqueue_scripts( $hook_suffix ) { return; } + // Abort the process if the user role isn't allowed to use this extension. + if ( ! Settings::is_allowed_user() ) { + return; + } + wp_enqueue_style( CHBE_NAMESPACE, CHBE_URL . '/build/style-classic-editor.css', @@ -106,6 +111,11 @@ public function media_buttons( $editor_id ) { return; } + // Abort the process if the user role isn't allowed to use this extension. + if ( ! Settings::is_allowed_user() ) { + return; + } + printf( '', __( 'Change Indentation', 'custom-html-block-extension' ) @@ -116,7 +126,7 @@ public function media_buttons( $editor_id ) { * Add dialog */ public function admin_footer() { - // Abort the process if block editor is enabled. + // Abort the process if the block editor is enabled. if ( ! function_exists( 'get_current_screen' ) ) { return; } @@ -129,6 +139,11 @@ public function admin_footer() { return; } + // Abort the process if the user role isn't allowed to use this extension. + if ( ! Settings::is_allowed_user() ) { + return; + } + $settings = Settings::get_editor_settings(); // phpcs:disable Generic.ControlStructures.InlineControlStructure ?> diff --git a/classes/class-theme-plugin-editor.php b/classes/class-theme-plugin-editor.php index 076310e..49e9923 100644 --- a/classes/class-theme-plugin-editor.php +++ b/classes/class-theme-plugin-editor.php @@ -13,7 +13,7 @@ class ThemePluginEditor { * Constructor */ public function __construct() { - // Abort the process if permission is disabled. + // Abort the process if the editor isn't allowed to use this extenson. $options = Settings::get_options(); if ( ! $options['permissionThemePluginEditor'] ) { return; @@ -32,6 +32,11 @@ public function admin_enqueue_scripts( $hook_suffix ) { return; } + // Abort the process if the user role isn't allowed to use this extension. + if ( ! Settings::is_allowed_user() ) { + return; + } + // Correspondence between the file extension and the language specified in the Monaco Editor $map_to_lang = array( 'css' => 'css', diff --git a/custom-html-block-extension.php b/custom-html-block-extension.php index c5ecfa4..0075992 100644 --- a/custom-html-block-extension.php +++ b/custom-html-block-extension.php @@ -4,7 +4,7 @@ * Description: Extend Custom HTML block to evolve into the advanced code editor. * Requires at least: 6.1 * Requires PHP: 7.4 - * Version: 3.3.1 + * Version: 3.3.2 * Author: Aki Hamano * Author URI: https://github.com/t-hamano * License: GPL2 or later diff --git a/readme.txt b/readme.txt index bd3c3ca..f6300db 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: gutenberg, block, html, highlighting, emmet Donate link: https://www.paypal.me/thamanoJP Requires at least: 6.1 Tested up to: 6.3 -Stable tag: 3.3.1 +Stable tag: 3.3.2 Requires PHP: 7.4 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html @@ -69,6 +69,11 @@ Source: https://www.marksimonson.com/fonts/view/anonymous-pro == Changelog == += 3.3.2 = + +* Fix: Browser warning error in WordPress 6.3 +* Fix: User role settings are not applied to all editors + = 3.3.1 = * Fix: some typos