From e6c285aa43d356fe8a6211057eb02f9266e58c37 Mon Sep 17 00:00:00 2001 From: Robin Cornett Date: Sat, 16 Nov 2019 16:23:40 -0500 Subject: [PATCH] Update shortcodes library --- includes/sixtenpress-shortcodes/README.md | 3 +++ .../includes/class-sixtenpress-shortcodes.php | 9 ++++++--- .../sixtenpress-shortcodes.php | 16 ++++++++-------- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/includes/sixtenpress-shortcodes/README.md b/includes/sixtenpress-shortcodes/README.md index f3cfa42..b511070 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.1 +* fixed: prevent scripts/styles loading if the post type doesn't support the editor + #### 0.7.0 * changed: moved all actions past a block editor/Gutenberg check to prevent media button scripts/modals loading when they shouldn't diff --git a/includes/sixtenpress-shortcodes/includes/class-sixtenpress-shortcodes.php b/includes/sixtenpress-shortcodes/includes/class-sixtenpress-shortcodes.php index 636d85c..9942c1a 100644 --- a/includes/sixtenpress-shortcodes/includes/class-sixtenpress-shortcodes.php +++ b/includes/sixtenpress-shortcodes/includes/class-sixtenpress-shortcodes.php @@ -130,6 +130,9 @@ class SixTenPressShortcodes { * Load all needful functions for the editor. */ public function start_editor() { + if ( $this->quit() ) { + return; + } add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ), 4 ); do_action( 'sixtenpress_shortcode_load' ); } @@ -138,9 +141,6 @@ class SixTenPressShortcodes { * Do not enqueue scripts if we're on a block editor page. */ public function enqueue() { - 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' ); @@ -270,6 +270,9 @@ class SixTenPressShortcodes { return true; } $screen = get_current_screen(); + if ( ! post_type_supports( $screen->post_type, 'editor' ) ) { + return true; + } if ( method_exists( $screen, 'is_block_editor' ) && $screen->is_block_editor() ) { return true; } diff --git a/includes/sixtenpress-shortcodes/sixtenpress-shortcodes.php b/includes/sixtenpress-shortcodes/sixtenpress-shortcodes.php index 0e78050..2802f61 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.7.0 + * @version 0.7.1 * @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_070', false ) ) { +if ( ! class_exists( 'SixTenPressShortcodes_071', false ) ) { /** * Versioned loader class-name @@ -48,18 +48,18 @@ if ( ! class_exists( 'SixTenPressShortcodes_070', false ) ) { * @package SixTenPressShortcodes * @author Robin Cornett * @license GPL-2.0+ - * @version 0.7.0 + * @version 0.7.1 * @link https://gitlab.com/robincornett/sixtenpress-shortcodes * @since 0.1.0 */ - class SixTenPressShortcodes_070 { + class SixTenPressShortcodes_071 { /** * SixTenPressShortcodes version number * @var string * @since 0.1.0 */ - const VERSION = '0.7.0'; + const VERSION = '0.7.1'; /** * Current version hook priority. @@ -68,7 +68,7 @@ if ( ! class_exists( 'SixTenPressShortcodes_070', false ) ) { * @var int * @since 0.1.0 */ - const PRIORITY = 9980; + const PRIORITY = 9979; /** * Starts the version checking process. @@ -142,7 +142,7 @@ if ( ! class_exists( 'SixTenPressShortcodes_070', false ) ) { /** * Defines the directory of the currently loaded version of SixTenPressShortcodes. */ - define( 'SIXTENPRESSSHORTCODES_DIR', dirname( __FILE__ ) . '/' ); + define( 'SIXTENPRESSSHORTCODES_DIR', trailingslashit( __DIR__ ) ); } // Include and initiate SixTenPressShortcodes. @@ -156,5 +156,5 @@ if ( ! class_exists( 'SixTenPressShortcodes_070', false ) ) { } // Kick it off. - new SixTenPressShortcodes_070(); + new SixTenPressShortcodes_071(); }