From 429e6e431a21ed1c2814a2f3b076f171364c7da5 Mon Sep 17 00:00:00 2001 From: Jonathan Bardo Date: Wed, 26 Jan 2022 16:39:06 -0500 Subject: [PATCH 1/3] Change editor asset from init to enqueue_block_editor_assets --- includes/class-coblocks-block-assets.php | 35 +++++++++--------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/includes/class-coblocks-block-assets.php b/includes/class-coblocks-block-assets.php index 6ffd30c8654..e9dae971ebe 100644 --- a/includes/class-coblocks-block-assets.php +++ b/includes/class-coblocks-block-assets.php @@ -43,7 +43,6 @@ public static function register() { */ public function __construct() { add_action( 'enqueue_block_assets', array( $this, 'block_assets' ) ); - add_action( 'init', array( $this, 'editor_assets' ) ); add_action( 'enqueue_block_editor_assets', array( $this, 'editor_scripts' ) ); add_action( 'enqueue_block_editor_assets', array( $this, 'frontend_scripts' ) ); add_action( 'wp_enqueue_scripts', array( $this, 'frontend_scripts' ) ); @@ -143,7 +142,19 @@ public function block_assets() { * * @access public */ - public function editor_assets() { + public function editor_scripts() { + // Define where the vendor asset is loaded from. + $vendors_dir = CoBlocks()->asset_source( 'js/vendors' ); + + // Required by the events block. + wp_enqueue_script( + 'coblocks-slick', + $vendors_dir . '/slick.js', + array( 'jquery' ), + COBLOCKS_VERSION, + true + ); + // Styles. $name = 'coblocks-1'; $filepath = 'dist/' . $name; @@ -519,26 +530,6 @@ public function has_coblocks_block( WP_Post $post_object ) { } - /** - * Enqueue editor scripts for blocks. - * - * @access public - * @since 1.9.5 - */ - public function editor_scripts() { - // Define where the vendor asset is loaded from. - $vendors_dir = CoBlocks()->asset_source( 'js/vendors' ); - - // Required by the events block. - wp_enqueue_script( - 'coblocks-slick', - $vendors_dir . '/slick.js', - array( 'jquery' ), - COBLOCKS_VERSION, - true - ); - } - /** * Return whether a post type should display the Block Editor. * From 44cbf389e3a17221fa268ab4c1df3b5d2b4143ea Mon Sep 17 00:00:00 2001 From: Jonathan Bardo Date: Wed, 26 Jan 2022 16:51:52 -0500 Subject: [PATCH 2/3] Use previous func name --- .dev/tests/phpunit/includes/test-coblocks-block-assets.php | 2 +- includes/class-coblocks-block-assets.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.dev/tests/phpunit/includes/test-coblocks-block-assets.php b/.dev/tests/phpunit/includes/test-coblocks-block-assets.php index a638de03bbf..b6a5a20379c 100644 --- a/.dev/tests/phpunit/includes/test-coblocks-block-assets.php +++ b/.dev/tests/phpunit/includes/test-coblocks-block-assets.php @@ -58,7 +58,7 @@ public function test_construct_actions() { $actions = [ [ 'enqueue_block_assets', 'block_assets' ], - [ 'init', 'editor_assets' ], + [ 'enqueue_block_editor_assets', 'editor_assets' ], [ 'wp_enqueue_scripts', 'frontend_scripts' ], ]; diff --git a/includes/class-coblocks-block-assets.php b/includes/class-coblocks-block-assets.php index e9dae971ebe..e113bd5bee1 100644 --- a/includes/class-coblocks-block-assets.php +++ b/includes/class-coblocks-block-assets.php @@ -43,7 +43,7 @@ public static function register() { */ public function __construct() { add_action( 'enqueue_block_assets', array( $this, 'block_assets' ) ); - add_action( 'enqueue_block_editor_assets', array( $this, 'editor_scripts' ) ); + add_action( 'enqueue_block_editor_assets', array( $this, 'editor_assets' ) ); add_action( 'enqueue_block_editor_assets', array( $this, 'frontend_scripts' ) ); add_action( 'wp_enqueue_scripts', array( $this, 'frontend_scripts' ) ); add_action( 'save_post_wp_template_part', array( $this, 'clear_template_transients' ) ); @@ -142,7 +142,7 @@ public function block_assets() { * * @access public */ - public function editor_scripts() { + public function editor_assets() { // Define where the vendor asset is loaded from. $vendors_dir = CoBlocks()->asset_source( 'js/vendors' ); From 082cc1fea00ba84e4f4db8ed58ca0e0b65778c43 Mon Sep 17 00:00:00 2001 From: Jonathan Bardo Date: Wed, 26 Jan 2022 17:02:30 -0500 Subject: [PATCH 3/3] Change hook on settings panel class too --- includes/class-coblocks-settings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/class-coblocks-settings.php b/includes/class-coblocks-settings.php index f45734a9baa..60ae5c5a53e 100644 --- a/includes/class-coblocks-settings.php +++ b/includes/class-coblocks-settings.php @@ -44,7 +44,7 @@ public static function register() { */ public function __construct() { add_action( 'init', array( $this, 'register_settings' ) ); - add_action( 'init', array( $this, 'coblocks_settings_assets' ) ); + add_action( 'enqueue_block_editor_assets', array( $this, 'coblocks_settings_assets' ), 11 ); add_action( 'wp_loaded', array( $this, 'coblocks_feature_propagation' ) ); }