Skip to content

Commit

Permalink
Merge 9242557 into b4943bc
Browse files Browse the repository at this point in the history
  • Loading branch information
kasparsd committed Apr 27, 2020
2 parents b4943bc + 9242557 commit 978fd67
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 6 additions & 0 deletions readme.txt.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
37 changes: 35 additions & 2 deletions src/WidgetContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' )
);
}


Expand Down Expand Up @@ -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(
'<a href="%s">%s</a>',
esc_url( $this->plugin_settings_admin_url() ),
esc_html__( 'Settings', 'widget-context' )
);

$links[] = sprintf(
'<a href="%s">%s</a>',
esc_url( $this->customize_widgets_admin_url() ),
esc_html__( 'Configure Widgets', 'widget-context' )
);

if ( $this->pro_nag_enabled() ) {
$links[] = sprintf(
'<a href="%s" target="_blank">PRO 🚀</a>',
esc_url( 'https://widgetcontext.com/pro' )
);
}

return $links;
}

function set_widget_contexts_frontend() {
// Hide/show widgets for is_active_sidebar() to work
Expand Down Expand Up @@ -680,7 +713,7 @@ function display_widget_context( $widget_id = null ) {
if ( current_user_can( 'edit_theme_options' ) ) {
$settings_link[] = sprintf(
'<a href="%s" title="%s" target="_blank">%s</a>',
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' )
);
Expand Down
14 changes: 14 additions & 0 deletions tests/php/WidgetContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion widget-context.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 978fd67

Please sign in to comment.