From f2f96d6a430f74777bbd20c7f37e3c75e8ef5cd4 Mon Sep 17 00:00:00 2001 From: Erick Hitter <git-contrib@ethitter.com> Date: Sat, 11 Jun 2022 12:14:27 -0700 Subject: [PATCH] Prevent block-editor script from loading on widgets block editor Loading the block-editor script on the widgets block editor produces a `_doing_it_wrong()` notice because the `wp-editor` script should not be loaded for the widgets block editor, but it is a dependency for this plugin's block-editor script. Fixes #22 --- README.md | 8 +++++++- inc/class-block-editor.php | 6 ++++++ languages/wp-revisions-control.pot | 4 ++-- readme.txt | 8 +++++++- wp-revisions-control.php | 2 +- 5 files changed, 23 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9f19be0..8f05c2e 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ **Tags:** revision, revisions, admin **Requires at least:** 3.6 **Tested up to:** 6.0 -**Stable tag:** 1.4.1 +**Stable tag:** 1.4.2 **License:** GPLv2 or later **License URI:** http://www.gnu.org/licenses/gpl-2.0.html @@ -35,6 +35,9 @@ Navigate to **Settings > Writing** in your WordPress Dashboard, and look for the ## Changelog ## +### 1.4.2 ### +* Fix notice appearing on Widgets Block Editor. + ### 1.4.1 ### * Update translation text domain to `wp-revisions-control`, conforming to WordPress standards. * Add Polish translation thanks to [Maciej Gryniuk](https://github.com/odie2). @@ -58,6 +61,9 @@ Navigate to **Settings > Writing** in your WordPress Dashboard, and look for the ## Upgrade Notice ## +### 1.4.2 ### +Fixes notice appearing on Widgets Block Editor. + ### 1.4.1 ### Updates translation text domain to `wp-revisions-control`, conforming to WordPress standards. diff --git a/inc/class-block-editor.php b/inc/class-block-editor.php index b68b3e6..f2d5f93 100644 --- a/inc/class-block-editor.php +++ b/inc/class-block-editor.php @@ -149,6 +149,12 @@ class Block_Editor { * Register Gutenberg script. */ public function action_enqueue_block_editor_assets() { + global $pagenow; + + if ( 'widgets.php' === $pagenow ) { + return; + } + $handle = 'wp-revisions-control-block-editor'; $asset_data = require_once dirname( __DIR__ ) . '/assets/build/gutenberg.asset.php'; diff --git a/languages/wp-revisions-control.pot b/languages/wp-revisions-control.pot index 5fa80ac..fa1a05e 100644 --- a/languages/wp-revisions-control.pot +++ b/languages/wp-revisions-control.pot @@ -2,10 +2,10 @@ # This file is distributed under the same license as the WP Revisions Control package. msgid "" msgstr "" -"Project-Id-Version: WP Revisions Control 1.4.1\n" +"Project-Id-Version: WP Revisions Control 1.4.2\n" "Report-Msgid-Bugs-To: " "https://wordpress.org/support/plugin/wp-revisions-control\n" -"POT-Creation-Date: 2022-06-06 04:01:11+00:00\n" +"POT-Creation-Date: 2022-06-11 19:34:09+00:00\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/readme.txt b/readme.txt index 6890bf5..27a30cf 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Donate link: https://ethitter.com/donate/ Tags: revision, revisions, admin Requires at least: 3.6 Tested up to: 6.0 -Stable tag: 1.4.1 +Stable tag: 1.4.2 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -35,6 +35,9 @@ Navigate to **Settings > Writing** in your WordPress Dashboard, and look for the == Changelog == += 1.4.2 = +* Fix notice appearing on Widgets Block Editor. + = 1.4.1 = * Update translation text domain to `wp-revisions-control`, conforming to WordPress standards. * Add Polish translation thanks to [Maciej Gryniuk](https://github.com/odie2). @@ -58,6 +61,9 @@ Navigate to **Settings > Writing** in your WordPress Dashboard, and look for the == Upgrade Notice == += 1.4.2 = +Fixes notice appearing on Widgets Block Editor. + = 1.4.1 = Updates translation text domain to `wp-revisions-control`, conforming to WordPress standards. diff --git a/wp-revisions-control.php b/wp-revisions-control.php index d70ec66..272d2bf 100644 --- a/wp-revisions-control.php +++ b/wp-revisions-control.php @@ -4,7 +4,7 @@ * Plugin URI: https://ethitter.com/plugins/wp-revisions-control/ * Description: Control how many revisions are stored for each post type * Author: Erick Hitter - * Version: 1.4.1 + * Version: 1.4.2 * Author URI: https://ethitter.com/ * Text Domain: wp-revisions-control * Domain Path: /languages/ -- GitLab