From 26a0fab0dd16ac250a0ba3a8c2663bbd9e03e1ee Mon Sep 17 00:00:00 2001 From: Erick Hitter <git-contrib@ethitter.com> Date: Sat, 11 Jun 2022 17:50:31 -0700 Subject: [PATCH] PHPCS --- README.md | 8 ++- external-permalinks-redux.php | 33 ++++++++++-- ...external-permalinks-redux-block-editor.php | 54 ++++++++++++++++++- ...ss-external-permalinks-redux-singleton.php | 41 -------------- languages/external-permalinks-redux.pot | 28 +++++----- readme.txt | 8 ++- 6 files changed, 108 insertions(+), 64 deletions(-) delete mode 100644 inc/class-external-permalinks-redux-singleton.php diff --git a/README.md b/README.md index e8395b6..8c49161 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ **Tags:** link, redirect, external link, permalink **Requires at least:** 3.0 **Tested up to:** 6.0 -**Stable tag:** 1.2 +**Stable tag:** 1.3 **License:** GPLv2 or later **License URI:** http://www.gnu.org/licenses/gpl-2.0.html @@ -37,6 +37,9 @@ Using the `epr_post_types` filter, one can modify the default array of object ty ## Changelog ## +### 1.3 ### +* Introduce block-editor (Gutenberg) sidebar component for supported post types.. + ### 1.2 ### * Introduce `get_redirect_data()` method to look up a post ID's redirect. * Introduce PHPUnit tests @@ -67,6 +70,9 @@ Using the `epr_post_types` filter, one can modify the default array of object ty ## Upgrade Notice ## +### 1.3 ### +Introduces block-editor (Gutenberg) sidebar component for supported post types. + ### 1.2 ### Introduces `get_redirect_data()` method along with unit tests and PHPCS cleanup. diff --git a/external-permalinks-redux.php b/external-permalinks-redux.php index b6d0aa4..d057658 100644 --- a/external-permalinks-redux.php +++ b/external-permalinks-redux.php @@ -3,7 +3,7 @@ * Plugin Name: External Permalinks Redux * Plugin URI: http://www.thinkoomph.com/plugins-modules/external-permalinks-redux/ * Description: Allows users to point WordPress objects (posts, pages, custom post types) to a URL of your choosing. Inspired by and backwards-compatible with <a href="http://txfx.net/wordpress-plugins/page-links-to/">Page Links To</a> by Mark Jaquith. Written for use on WordPress.com VIP. - * Version: 1.2 + * Version: 1.3 * Author: Erick Hitter & Oomph, Inc. * Author URI: http://www.thinkoomph.com/ * @@ -24,9 +24,6 @@ * @package External_Permalinks_Redux */ -// Include singleton trait used by all classes. -require_once dirname( __FILE__ ) . '/inc/class-external-permalinks-redux-singleton.php'; - // Include block-editor class. require_once dirname( __FILE__ ) . '/inc/class-external-permalinks-redux-block-editor.php'; @@ -34,7 +31,14 @@ require_once dirname( __FILE__ ) . '/inc/class-external-permalinks-redux-block-e * Class external_permalinks_redux. */ // phpcs:ignore PEAR.NamingConventions.ValidClassName, Squiz.Commenting.ClassComment.Missing -class external_permalinks_redux extends External_Permalinks_Redux_Singleton{ +class external_permalinks_redux { + /** + * Singleton! + * + * @var self + */ + protected static $instance; + /** * Redirect URL meta key. * @@ -65,6 +69,25 @@ class external_permalinks_redux extends External_Permalinks_Redux_Singleton{ */ private $post_types; + /** + * Instantiate class as a singleton. + * + * @return object + */ + public static function get_instance() { + if ( empty( self::$instance ) ) { + self::$instance = new self(); + self::$instance->_setup(); + } + + return self::$instance; + } + + /** + * Unused constructor. + */ + final private function __construct() {} + /** * Allow access to certain private properties. * diff --git a/inc/class-external-permalinks-redux-block-editor.php b/inc/class-external-permalinks-redux-block-editor.php index 095db2d..93a9f25 100644 --- a/inc/class-external-permalinks-redux-block-editor.php +++ b/inc/class-external-permalinks-redux-block-editor.php @@ -8,13 +8,63 @@ /** * Class Block_Editor. */ -class External_Permalinks_Redux_Block_Editor extends External_Permalinks_Redux_Singleton { +class External_Permalinks_Redux_Block_Editor { + /** + * Singleton! + * + * @var self + */ + protected static $instance; + + /** + * Instantiate class as a singleton. + * + * @return object + */ + public static function get_instance() { + if ( empty( self::$instance ) ) { + self::$instance = new self(); + self::$instance->_setup(); + } + + return self::$instance; + } + + /** + * Unused constructor. + */ + final private function __construct() {} + /** * Set up class. * * @return void */ protected function _setup() { - // TODO: Implement _setup() method. + add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue' ) ); + } + + /** + * Enqueue block-editor script. + * + * @return void + */ + public function enqueue() { + global $pagenow; + + if ( 'widgets.php' === $pagenow ) { + return; + } + + $asset_data = require_once dirname( dirname( __FILE__ ) ) . '/assets/build/index.asset.php'; + $asset_handle = 'external-permalinks-redux'; + + wp_enqueue_script( + $asset_handle, + plugins_url( 'assets/build/index.js', dirname( __FILE__ ) ), + $asset_data['dependencies'], + $asset_data['version'], + true + ); } } diff --git a/inc/class-external-permalinks-redux-singleton.php b/inc/class-external-permalinks-redux-singleton.php deleted file mode 100644 index be98620..0000000 --- a/inc/class-external-permalinks-redux-singleton.php +++ /dev/null @@ -1,41 +0,0 @@ -<?php -/** - * Singleton base class. - * - * @package External_Permalinks_Redux - */ - -abstract class External_Permalinks_Redux_Singleton { - /** - * Singleton! - * - * @var self - */ - protected static $instance; - - /** - * Instantiate class as a singleton. - * - * @return object - */ - public static function get_instance() { - if ( ! isset( static::$instance ) ) { - static::$instance = new static(); - static::$instance->_setup(); - } - - return static::$instance; - } - - /** - * Unused constructor. - */ - final private function __construct() {} - - /** - * Set up class. - * - * @return void - */ - abstract protected function _setup(); -} diff --git a/languages/external-permalinks-redux.pot b/languages/external-permalinks-redux.pot index 0ee1dab..da09829 100644 --- a/languages/external-permalinks-redux.pot +++ b/languages/external-permalinks-redux.pot @@ -1,35 +1,35 @@ -# Copyright (C) 2021 Erick Hitter & Oomph, Inc. +# Copyright (C) 2022 Erick Hitter & Oomph, Inc. # This file is distributed under the same license as the External Permalinks Redux package. msgid "" msgstr "" -"Project-Id-Version: External Permalinks Redux 1.2\n" +"Project-Id-Version: External Permalinks Redux 1.3\n" "Report-Msgid-Bugs-To: " "https://wordpress.org/support/plugin/external-permalinks-redux\n" -"POT-Creation-Date: 2021-03-27 20:16:07+00:00\n" +"POT-Creation-Date: 2022-06-12 00:49:47+00:00\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"PO-Revision-Date: 2021-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: 2022-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" -"X-Generator: grunt-wp-i18n 0.5.4\n" -"X-Poedit-KeywordsList: " -"__;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;_nx_noop:1,2,3c;esc_" -"attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;esc_html_x:1,2c;\n" "Language: en\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" "X-Poedit-Country: United States\n" "X-Poedit-SourceCharset: UTF-8\n" +"X-Poedit-KeywordsList: " +"__;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;_nx_noop:1,2,3c;esc_" +"attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;esc_html_x:1,2c;\n" "X-Poedit-Basepath: ../\n" "X-Poedit-SearchPath-0: .\n" "X-Poedit-Bookmarks: \n" "X-Textdomain-Support: yes\n" +"X-Generator: grunt-wp-i18n 1.0.3\n" -#: external-permalinks-redux.php:97 +#: external-permalinks-redux.php:167 msgid "Temporary (302)" msgstr "" -#: external-permalinks-redux.php:98 +#: external-permalinks-redux.php:168 msgid "Permanent (301)" msgstr "" @@ -37,19 +37,19 @@ msgstr "" msgid "External Permalinks Redux" msgstr "" -#: external-permalinks-redux.php:136 +#: external-permalinks-redux.php:213 msgid "Destination Address:" msgstr "" -#: external-permalinks-redux.php:140 +#: external-permalinks-redux.php:217 msgid "To restore the original permalink, remove the link entered above." msgstr "" -#: external-permalinks-redux.php:145 +#: external-permalinks-redux.php:222 msgid "Redirect Type:" msgstr "" -#: external-permalinks-redux.php:147 +#: external-permalinks-redux.php:224 msgid "-- Select --" msgstr "" diff --git a/readme.txt b/readme.txt index 6f55005..9cfbb1b 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Donate link: http://www.thinkoomph.com/plugins-modules/external-permalinks-redux Tags: link, redirect, external link, permalink Requires at least: 3.0 Tested up to: 6.0 -Stable tag: 1.2 +Stable tag: 1.3 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -37,6 +37,9 @@ Using the `epr_post_types` filter, one can modify the default array of object ty == Changelog == += 1.3 = +* Introduce block-editor (Gutenberg) sidebar component for supported post types.. + = 1.2 = * Introduce `get_redirect_data()` method to look up a post ID's redirect. * Introduce PHPUnit tests @@ -67,6 +70,9 @@ Using the `epr_post_types` filter, one can modify the default array of object ty == Upgrade Notice == += 1.3 = +Introduces block-editor (Gutenberg) sidebar component for supported post types. + = 1.2 = Introduces `get_redirect_data()` method along with unit tests and PHPCS cleanup. -- GitLab