diff --git a/includes/sixtenpress-shortcodes/README.md b/includes/sixtenpress-shortcodes/README.md index 889069b..f3cfa42 100644 --- a/includes/sixtenpress-shortcodes/README.md +++ b/includes/sixtenpress-shortcodes/README.md @@ -102,6 +102,9 @@ If an image ID is required, Six/Ten Press image fields in a group will work, as ### Changelog +#### 0.7.0 +* changed: moved all actions past a block editor/Gutenberg check to prevent media button scripts/modals loading when they shouldn't + #### 0.6.0 * added: custom enqueue hook `sixtenpress_shortcodes_enqueue` to allow loading dependent scripts without having to check if we're on a block editor page * changed: enqueue scripts/styles for shortcode button only if not in the block editor diff --git a/includes/sixtenpress-shortcodes/includes/class-sixtenpress-shortcodes.php b/includes/sixtenpress-shortcodes/includes/class-sixtenpress-shortcodes.php index 68258b6..636d85c 100644 --- a/includes/sixtenpress-shortcodes/includes/class-sixtenpress-shortcodes.php +++ b/includes/sixtenpress-shortcodes/includes/class-sixtenpress-shortcodes.php @@ -130,10 +130,7 @@ class SixTenPressShortcodes { * Load all needful functions for the editor. */ public function start_editor() { - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) ); - add_action( 'media_buttons', array( $this, 'media_buttons' ), 98 ); - add_action( 'admin_footer', array( $this, 'widget_builder_modal' ) ); - add_filter( 'sixtenpress_admin_color_picker', '__return_true' ); + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ), 4 ); do_action( 'sixtenpress_shortcode_load' ); } @@ -141,9 +138,12 @@ class SixTenPressShortcodes { * Do not enqueue scripts if we're on a block editor page. */ public function enqueue() { - if ( ( function_exists( 'is_gutenberg_page' ) && is_gutenberg_page() ) || ( function_exists( 'is_block_editor' ) && is_block_editor() ) ) { + if ( $this->quit() ) { return; } + add_action( 'media_buttons', array( $this, 'media_buttons' ), 98 ); + add_action( 'admin_footer', array( $this, 'widget_builder_modal' ) ); + add_filter( 'sixtenpress_admin_color_picker', '__return_true' ); do_action( 'sixtenpress_shortcode_enqueue' ); add_filter( 'sixtenpress_shortcode_localization', array( $this, 'localization_args' ) ); $this->enqueue_script(); @@ -258,4 +258,22 @@ class SixTenPressShortcodes { $this->loaded = true; include plugin_dir_path( __FILE__ ) . 'modal.php'; } + + /** + * Check if we are on a Gutenberg/block editor screen. + * @since 0.7.0 + * + * @return bool + */ + private function quit() { + if ( ( function_exists( 'is_gutenberg_page' ) && is_gutenberg_page() ) ) { + return true; + } + $screen = get_current_screen(); + if ( method_exists( $screen, 'is_block_editor' ) && $screen->is_block_editor() ) { + return true; + } + + return false; + } } diff --git a/includes/sixtenpress-shortcodes/sixtenpress-shortcodes.php b/includes/sixtenpress-shortcodes/sixtenpress-shortcodes.php index 8c3d996..0e78050 100644 --- a/includes/sixtenpress-shortcodes/sixtenpress-shortcodes.php +++ b/includes/sixtenpress-shortcodes/sixtenpress-shortcodes.php @@ -10,7 +10,7 @@ * @author Robin Cornett * @copyright 2017-2018 Robin Cornett * @license GPL-2.0+ - * @version 0.6.0 + * @version 0.7.0 * @link https://gitlab.com/robincornett/sixtenpress-shortcodes * @since 0.1.0 */ @@ -37,7 +37,7 @@ * Loader versioning: http://jtsternberg.github.io/wp-lib-loader/ */ -if ( ! class_exists( 'SixTenPressShortcodes_060', false ) ) { +if ( ! class_exists( 'SixTenPressShortcodes_070', false ) ) { /** * Versioned loader class-name @@ -48,18 +48,18 @@ if ( ! class_exists( 'SixTenPressShortcodes_060', false ) ) { * @package SixTenPressShortcodes * @author Robin Cornett * @license GPL-2.0+ - * @version 0.6.0 + * @version 0.7.0 * @link https://gitlab.com/robincornett/sixtenpress-shortcodes * @since 0.1.0 */ - class SixTenPressShortcodes_060 { + class SixTenPressShortcodes_070 { /** * SixTenPressShortcodes version number * @var string * @since 0.1.0 */ - const VERSION = '0.6.0'; + const VERSION = '0.7.0'; /** * Current version hook priority. @@ -68,7 +68,7 @@ if ( ! class_exists( 'SixTenPressShortcodes_060', false ) ) { * @var int * @since 0.1.0 */ - const PRIORITY = 9981; + const PRIORITY = 9980; /** * Starts the version checking process. @@ -156,5 +156,5 @@ if ( ! class_exists( 'SixTenPressShortcodes_060', false ) ) { } // Kick it off. - new SixTenPressShortcodes_060(); + new SixTenPressShortcodes_070(); }