From 4bceb1bf72804c5d7051a9ed6ba508dbe2bc669b Mon Sep 17 00:00:00 2001 From: Kaspars Dambis Date: Mon, 27 Apr 2020 19:48:52 +0300 Subject: [PATCH 1/8] Use the new settings page helper instead --- src/WidgetContext.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/WidgetContext.php b/src/WidgetContext.php index 96c9e77..c5a973f 100644 --- a/src/WidgetContext.php +++ b/src/WidgetContext.php @@ -680,7 +680,7 @@ function display_widget_context( $widget_id = null ) { if ( current_user_can( 'edit_theme_options' ) ) { $settings_link[] = sprintf( '%s', - admin_url( 'options-general.php?page=widget_context_settings' ), + esc_url( $this->plugin_settings_admin_url() ), esc_attr__( 'Widget Context Settings', 'widget-context' ), esc_html__( 'Settings', 'widget-context' ) ); From 98eaf55ccca371009a805dedde3c6663a3fc0eec Mon Sep 17 00:00:00 2001 From: Kaspars Dambis Date: Mon, 27 Apr 2020 19:50:49 +0300 Subject: [PATCH 2/8] Always create a bundle before deploying --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 189ae7b..c433fcd 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,8 @@ "scripts": { "grunt": "grunt", "build": "composer release && grunt build", - "deploy": "grunt deploy", - "deploy-trunk": "grunt deploy-trunk", + "deploy": "composer release && grunt deploy", + "deploy-trunk": "composer release && grunt deploy-trunk", "test": "composer test", "lint": "composer lint && npm run lint-js", "lint-js": "eslint *.js assets/js", From 4f82f0ab73db20c9d0330e2f7c1194c4fcbf30ef Mon Sep 17 00:00:00 2001 From: Kaspars Dambis Date: Mon, 27 Apr 2020 20:02:57 +0300 Subject: [PATCH 3/8] Add the settings links too --- src/WidgetContext.php | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/WidgetContext.php b/src/WidgetContext.php index c5a973f..0378ace 100644 --- a/src/WidgetContext.php +++ b/src/WidgetContext.php @@ -96,8 +96,14 @@ public function init() { // Register admin settings menu add_action( 'admin_menu', array( $this, 'widget_context_settings_menu' ) ); - // Register admin settings + // Register admin settings. add_action( 'admin_init', array( $this, 'widget_context_settings_init' ) ); + + // Add quick links to the plugin list. + add_action( + 'plugin_action_links_' . $this->plugin->basename(), + array( $this, 'plugin_action_links' ) + ); } @@ -211,6 +217,25 @@ public function pro_nag_enabled() { return (bool) apply_filters( 'widget_context_pro_nag', true ); } + /** + * Add a link to the plugin settings in the plugin list. + * + * @return array List of links. + */ + public function plugin_action_links( $links ) { + $links[] = sprintf( + '%s', + esc_url( $this->plugin_settings_admin_url() ), + esc_html__( 'Settings', 'widget-context' ) + ); + + if ( $this->pro_nag_enabled() ) { + $settings_link[] = sprintf( + 'PRO 🚀', + esc_url( 'https://widgetcontext.com/pro' ) + ); + } + } function set_widget_contexts_frontend() { // Hide/show widgets for is_active_sidebar() to work From cd1f6f9114a3a6de11b0fef628f2e9d9a4344622 Mon Sep 17 00:00:00 2001 From: Kaspars Dambis Date: Mon, 27 Apr 2020 20:46:17 +0300 Subject: [PATCH 4/8] Return the actual links --- src/WidgetContext.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/WidgetContext.php b/src/WidgetContext.php index 0378ace..98836f8 100644 --- a/src/WidgetContext.php +++ b/src/WidgetContext.php @@ -230,11 +230,13 @@ public function plugin_action_links( $links ) { ); if ( $this->pro_nag_enabled() ) { - $settings_link[] = sprintf( + $links[] = sprintf( 'PRO 🚀', esc_url( 'https://widgetcontext.com/pro' ) ); } + + return $links; } function set_widget_contexts_frontend() { From 128f9347e39eb61ed0a0f704c50eb91fe1b073fd Mon Sep 17 00:00:00 2001 From: Kaspars Dambis Date: Mon, 27 Apr 2020 20:46:52 +0300 Subject: [PATCH 5/8] Keep within the same window --- src/WidgetContext.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/WidgetContext.php b/src/WidgetContext.php index 98836f8..da78c65 100644 --- a/src/WidgetContext.php +++ b/src/WidgetContext.php @@ -224,7 +224,7 @@ public function pro_nag_enabled() { */ public function plugin_action_links( $links ) { $links[] = sprintf( - '%s', + '%s', esc_url( $this->plugin_settings_admin_url() ), esc_html__( 'Settings', 'widget-context' ) ); From 4ff7821eb7bc11db309513a92c1355981b60f952 Mon Sep 17 00:00:00 2001 From: Kaspars Dambis Date: Mon, 27 Apr 2020 21:08:41 +0300 Subject: [PATCH 6/8] Add a test for the settings fetcher --- tests/php/WidgetContextTest.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/php/WidgetContextTest.php b/tests/php/WidgetContextTest.php index 8b717c8..1aa4152 100644 --- a/tests/php/WidgetContextTest.php +++ b/tests/php/WidgetContextTest.php @@ -40,6 +40,20 @@ public function testLegacyInstance() { ); } + public function testSettingsUrl() { + WP_Mock::userFunction( + 'admin_url', + array( + 'args' => array( + WP_Mock\Functions::type( 'string' ), + ), + 'times' => 1, + ) + ); + + $this->plugin->plugin_settings_admin_url(); + } + public function testRequestPathResolver() { $this->assertEquals( 'path-to-a/url.html?true=2', From 74157aaf8abac706b55e17c17d3e7c41148552a1 Mon Sep 17 00:00:00 2001 From: Kaspars Dambis Date: Mon, 27 Apr 2020 21:15:50 +0300 Subject: [PATCH 7/8] Release notes --- readme.txt.md | 6 ++++++ widget-context.php | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/readme.txt.md b/readme.txt.md index 0b5871c..405f9b3 100644 --- a/readme.txt.md +++ b/readme.txt.md @@ -65,6 +65,12 @@ Specify URLs to ignore even if they're matched by any of the other context rules ## Changelog +### 1.3.2 (April 27, 2020) + +- Bugfix: Fix the Widget Context settings link in the widget controls after moving the settings under the "Appearance" menu for usability (closer to the widget settings). +- Feature: Add a link to the plugin settings in the plugin admin list, too. + + ### 1.3.1 (April 24, 2020) - Bugfix: better support for URL rules with query parameters. diff --git a/widget-context.php b/widget-context.php index 0d0ee72..5be943a 100644 --- a/widget-context.php +++ b/widget-context.php @@ -3,7 +3,7 @@ * Plugin Name: Widget Context * Plugin URI: https://widgetcontext.com * Description: Show or hide widgets depending on the section of the site that is being viewed. Configure the widget visibility rules under the individual widget settings. - * Version: 1.3.1 + * Version: 1.3.2 * Author: Kaspars Dambis * Author URI: https://widgetcontext.com * Text Domain: widget-context From 92425573e4a4655fe6a980c14fa67fa83cb0dde2 Mon Sep 17 00:00:00 2001 From: Kaspars Dambis Date: Mon, 27 Apr 2020 21:17:55 +0300 Subject: [PATCH 8/8] Link to configure widgets, too --- src/WidgetContext.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/WidgetContext.php b/src/WidgetContext.php index da78c65..376a4dc 100644 --- a/src/WidgetContext.php +++ b/src/WidgetContext.php @@ -229,6 +229,12 @@ public function plugin_action_links( $links ) { esc_html__( 'Settings', 'widget-context' ) ); + $links[] = sprintf( + '%s', + esc_url( $this->customize_widgets_admin_url() ), + esc_html__( 'Configure Widgets', 'widget-context' ) + ); + if ( $this->pro_nag_enabled() ) { $links[] = sprintf( 'PRO 🚀',