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", 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/src/WidgetContext.php b/src/WidgetContext.php index 96c9e77..376a4dc 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,33 @@ 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' ) + ); + + $links[] = sprintf( + '%s', + esc_url( $this->customize_widgets_admin_url() ), + esc_html__( 'Configure Widgets', 'widget-context' ) + ); + + if ( $this->pro_nag_enabled() ) { + $links[] = sprintf( + 'PRO 🚀', + esc_url( 'https://widgetcontext.com/pro' ) + ); + } + + return $links; + } function set_widget_contexts_frontend() { // Hide/show widgets for is_active_sidebar() to work @@ -680,7 +713,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' ) ); 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', 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