Widget Logic - Version 5.10.2

Version Description

  • The plugin's security has been improved, big thanks to Paul Dannewitz for his excellent security audit!
  • The widget_content filter option has been removed from the settings block, but kept in the code for backward compatibility. The plan is to remove it completely and make the plugin simpler (let us know what you think).
  • Code cleanup.
Download this release

Release Info

Developer wpchefgadget
Plugin Icon 128x128 Widget Logic
Version 5.10.2
Comparing to
See all releases

Code changes from version 5.9.0 to 5.10.2

Files changed (4) hide show
  1. readme.txt +14 -67
  2. screenshot-1.png +0 -0
  3. screenshot-2.png +0 -0
  4. widget_logic.php +19 -145
readme.txt CHANGED
@@ -1,37 +1,23 @@
1
  === Widget Logic ===
2
- Contributors: wpchefgadget, alanft
3
- Donate link: http://www.justgiving.com/widgetlogic_cancerresearchuk
4
- Tags: widget, admin, conditional tags, filter, context
5
  Requires at least: 3.0
6
- Tested up to: 4.9
7
- Stable tag: 5.9.0
8
- License: GPLv2 or later
9
 
10
- Widget Logic lets you control on which pages widgets appear using WP's conditional tags. It also adds a 'widget_content' filter.
11
 
12
  == Description ==
13
  This plugin gives every widget an extra control field called "Widget logic" that lets you control the pages that the widget will appear on. The text field lets you use WP's [Conditional Tags](http://codex.wordpress.org/Conditional_Tags), or any general PHP code.
14
 
15
  PLEASE NOTE The widget logic you introduce is EVAL'd directly. Anyone who has access to edit widget appearance will have the right to add any code, including malicious and possibly destructive functions. There is an optional filter 'widget_logic_eval_override' which you can use to bypass the EVAL with your own code if needed. (See [Other Notes](other_notes/)).
16
 
17
- There is also an option to add a wordpress 'widget_content' filter -- this lets you tweak any widget's HTML to suit your theme without editing plugins and core code.
18
-
19
- = Donations =
20
-
21
- If you like and use Widget Logic you could consider a small donation to Cancer Research UK. I have a [JustGiving.com donation link](http://www.justgiving.com/widgetlogic_cancerresearchuk). As of February 2017 we have raised 1,048.50 UKP.
22
-
23
- == Installation ==
24
-
25
- 1. Upload `widget-logic.php` to the `/wp-content/plugins/` directory
26
- 2. Activate the plugin through the 'Plugins' menu in WordPress
27
- 3. That's it. The configuring and options are in the usual widget admin interface.
28
 
29
  = Configuration =
30
 
31
  Aside from logic against your widgets, there are three options added to the foot of the widget admin page (see screenshots).
32
 
33
- * Add 'widget_content' filter -- This allows you to modify the text output in all widgets. You need to know how to write a WP filter, though some basics are covered in [Other Notes](../other_notes/).
34
-
35
  * Use 'wp_reset_query' fix -- Many features of WP, as well as the many themes and plugins out there, can mess with the conditional tags, such that is_home is NOT true on the home page. This can often be fixed with a quick wp_reset_query() statement just before the widgets are called, and this option puts that in for you rather than having to resort to code editing
36
 
37
  * Load logic -- This option allows you to set the point in the page load at which your widget logic if first checked. Pre v.50 it was when the 'wp_head' trigger happened, ie during the creation of the HTML's HEAD block. Many themes didn't call wp_head, which was a problem. From v.50 it happens, by default, as early as possible, which is as soon as the plugin loads. You can now specify these 'late load' points (in chronological order):
@@ -46,10 +32,6 @@ Aside from logic against your widgets, there are three options added to the foot
46
 
47
  == Frequently Asked Questions ==
48
 
49
- = I upgraded to Version 5.7.0 and my site's widgets now behave differently =
50
-
51
- There was an important change to how your Widget Logic code is evaluated. There is a new default 'Load logic' point of 'after query variables set'. For most people this should be better, but you could try reverting to the old default 'when plugin starts'.
52
-
53
  = What can I try if it's not working? =
54
 
55
  * Switch to the default theme. If the problem goes away, your theme may be interfering with the WP conditional tags or how widgets work
@@ -115,10 +97,16 @@ Tighten up your definitions with PHPs 'logical AND' &&, for example:
115
  == Screenshots ==
116
 
117
  1. The 'Widget logic' field at work in standard widgets.
118
- 2. The plugin options are at the foot of the usual widget admin page… `widget_content` filter, `wp_reset_query` option, 'load logic point' and 'evaluate more than once'. You can also export and import your site's WL options as a plain text file for a quick backup/restore and to help troubleshoot issues.
119
 
120
  == Changelog ==
121
 
 
 
 
 
 
 
122
  = 5.9.0 =
123
 
124
  wp_reset_query works better under certain conditions.
@@ -270,45 +258,4 @@ There are lots of great code examples on the WP forums, and on WP sites across t
270
  Note the extra ';' on the end where there is an explicit 'return'.
271
 
272
  == The 'widget_logic_eval_override' filter ==
273
- Before the Widget Logic code is evaluated for each widget, the text of the Widget Logic code is passed through this filter. If the filter returns a BOOLEAN result, this is used instead to determine if the widget is visible. Return TRUE for visible.
274
-
275
- == The 'widget_content' filter ==
276
-
277
- When this option is active (tick the option tickbox at the foot of the widget admin page) you can modify the text displayed by ANY widget from your own theme's functions.php file. Hook into the filter with:
278
-
279
- `add_filter('widget_content', 'your_filter_function', [priority], 2);`
280
-
281
- where `[priority]` is the optional priority parameter for the [add_filter](http://codex.wordpress.org/Function_Reference/add_filter) function. The filter function can take a second parameter (if you provde that last parameter '2') like this:
282
-
283
- `function your_filter_function($content='', $widget_id='')`
284
-
285
- The second parameter ($widget_id) can be used to target specific widgets if needed.
286
-
287
- A [Wordpress filter function](http://codex.wordpress.org/Plugin_API#Filters) 'takes as input the unmodified data, and returns modified data' which means that widget_content filters are provided with the raw HTML output by the widget, and you are then free to return something else entirely:
288
-
289
- = Example filters =
290
-
291
- `add_filter('widget_content', 'basic_widget_content_filter');
292
- function basic_widget_content_filter($content='')
293
- { return $content."<PRE>THIS APPEARS AFTER EVERY WIDGET</PRE>";
294
- }`
295
-
296
- I was motivated to make this filter in order to render all widget titles with the excellent [ttftitles plugin](http://templature.com/2007/10/18/ttftitles-wordpress-plugin/) like this:
297
-
298
- `add_filter('widget_content', 'ttftext_widget_title');
299
- function ttftext_widget_title($content='')
300
- { preg_match("/<h2[^>]*>([^<]+)/",$content, $matches);
301
- $heading=$matches[1];
302
- $insert_img=the_ttftext( $heading, false );
303
- $content=preg_replace("/(<h2[^>]*>)[^<]+/","$1$insert_img",$content,1);
304
- return $content;
305
- }`
306
-
307
- People often ask for a way to give widgets alternating styles. This filter inserts widget_style_a/widget_style_b into the class="widget ..." text usually found in a widget's main definition:
308
-
309
- `add_filter('widget_content', 'make_alternating_widget_styles');
310
- function make_alternating_widget_styles($content='')
311
- { global $wl_make_alt_ws;
312
- $wl_make_alt_ws=($wl_make_alt_ws=="style_a")?"style_b":"style_a";
313
- return preg_replace('/(class="widget )/', "$1 widget_${wl_make_alt_ws} ", $content);
314
- }`
1
  === Widget Logic ===
2
+ Contributors: wpchefgadget
3
+ Tags: widget, sidebar, content, conditional tags, toggle
 
4
  Requires at least: 3.0
5
+ Tested up to: 5.2.2
6
+ Stable tag: 5.10.2
 
7
 
8
+ Widget Logic lets you control on which pages widgets appear using WP's conditional tags.
9
 
10
  == Description ==
11
  This plugin gives every widget an extra control field called "Widget logic" that lets you control the pages that the widget will appear on. The text field lets you use WP's [Conditional Tags](http://codex.wordpress.org/Conditional_Tags), or any general PHP code.
12
 
13
  PLEASE NOTE The widget logic you introduce is EVAL'd directly. Anyone who has access to edit widget appearance will have the right to add any code, including malicious and possibly destructive functions. There is an optional filter 'widget_logic_eval_override' which you can use to bypass the EVAL with your own code if needed. (See [Other Notes](other_notes/)).
14
 
15
+ The configuring and options are in the usual widget admin interface.
 
 
 
 
 
 
 
 
 
 
16
 
17
  = Configuration =
18
 
19
  Aside from logic against your widgets, there are three options added to the foot of the widget admin page (see screenshots).
20
 
 
 
21
  * Use 'wp_reset_query' fix -- Many features of WP, as well as the many themes and plugins out there, can mess with the conditional tags, such that is_home is NOT true on the home page. This can often be fixed with a quick wp_reset_query() statement just before the widgets are called, and this option puts that in for you rather than having to resort to code editing
22
 
23
  * Load logic -- This option allows you to set the point in the page load at which your widget logic if first checked. Pre v.50 it was when the 'wp_head' trigger happened, ie during the creation of the HTML's HEAD block. Many themes didn't call wp_head, which was a problem. From v.50 it happens, by default, as early as possible, which is as soon as the plugin loads. You can now specify these 'late load' points (in chronological order):
32
 
33
  == Frequently Asked Questions ==
34
 
 
 
 
 
35
  = What can I try if it's not working? =
36
 
37
  * Switch to the default theme. If the problem goes away, your theme may be interfering with the WP conditional tags or how widgets work
97
  == Screenshots ==
98
 
99
  1. The 'Widget logic' field at work in standard widgets.
100
+ 2. The plugin options are at the foot of the usual widget admin page… `wp_reset_query` option, 'load logic point' and 'evaluate more than once'. You can also export and import your site's WL options as a plain text file for a quick backup/restore and to help troubleshoot issues.
101
 
102
  == Changelog ==
103
 
104
+ = 5.10.2 =
105
+
106
+ * The plugin's security has been improved, big thanks to [Paul Dannewitz](https://dannewitz.ninja/) for his excellent security audit!
107
+ * The widget_content filter option has been removed from the settings block, but kept in the code for backward compatibility. The plan is to remove it completely and make the plugin simpler (let us know what you think).
108
+ * Code cleanup.
109
+
110
  = 5.9.0 =
111
 
112
  wp_reset_query works better under certain conditions.
258
  Note the extra ';' on the end where there is an explicit 'return'.
259
 
260
  == The 'widget_logic_eval_override' filter ==
261
+ Before the Widget Logic code is evaluated for each widget, the text of the Widget Logic code is passed through this filter. If the filter returns a BOOLEAN result, this is used instead to determine if the widget is visible. Return TRUE for visible.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
screenshot-1.png DELETED
Binary file
screenshot-2.png DELETED
Binary file
widget_logic.php CHANGED
@@ -1,32 +1,13 @@
1
  <?php
2
  /*
3
- Plugin Name: Widget Logic
4
- Plugin URI: http://wordpress.org/extend/plugins/widget-logic/
5
- Description: Control widgets with WP's conditional tags is_home etc
6
- Version: 5.9.0
7
- Author: wpchefgadget, alanft
8
-
9
- Text Domain: widget-logic
10
- Domain Path: /languages/
11
  */
12
 
13
- DEFINE( 'WIDGET_LOGIC_VERSION', '5.7.0' );
14
-
15
- register_activation_hook( __FILE__, 'widget_logic_activate' );
16
-
17
- function widget_logic_activate()
18
- {
19
- $alert = (array)get_option( 'wpchefgadget_alert', array() );
20
- if ( get_option('widget_logic_version') != WIDGET_LOGIC_VERSION && !empty( $alert['limit-login-attempts'] ) )
21
- {
22
- unset( $alert['limit-login-attempts'] );
23
- add_option( 'wpchefgadget_alert', $alert, '', 'no' );
24
- update_option( 'wpchefgadget_alert', $alert );
25
- }
26
- add_option( 'widget_logic_version', WIDGET_LOGIC_VERSION, '', 'no' );
27
- update_option( 'widget_logic_version', WIDGET_LOGIC_VERSION );
28
- }
29
-
30
  $plugin_dir = basename(dirname(__FILE__));
31
  global $wl_options, $wl_in_customizer;
32
 
@@ -36,28 +17,6 @@ add_action( 'init', 'widget_logic_init' );
36
  function widget_logic_init()
37
  {
38
  load_plugin_textdomain( 'widget-logic', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
39
-
40
- /*
41
- if ( is_admin() )
42
- {
43
- if ( get_option('widget_logic_version') != WIDGET_LOGIC_VERSION )
44
- widget_logic_activate();
45
-
46
- global $wp_version;
47
- if ( version_compare( $wp_version, '4.2', '>=' ) && !file_exists(WP_PLUGIN_DIR.'/limit-login-attempts-reloaded') && current_user_can('install_plugins') )
48
- {
49
- $alert = (array)get_option( 'wpchefgadget_alert', array() );
50
- if ( empty( $alert['limit-login-attempts'] ) )
51
- {
52
- add_action( 'admin_notices', 'widget_logic_alert');
53
- add_action( 'network_admin_notices', 'widget_logic_alert');
54
- add_action( 'wp_ajax_wpchefgadget_dismiss_alert', 'widget_logic_dismiss_alert' );
55
- add_action( 'admin_enqueue_scripts', 'widget_logic_alert_scripts' );
56
- }
57
- //enqueue admin/js/updates.js
58
- }
59
- }
60
- */
61
  }
62
 
63
  if((!$wl_options = get_option('widget_logic')) || !is_array($wl_options) )
@@ -71,8 +30,6 @@ if (is_admin())
71
  add_action( 'sidebar_admin_setup', 'widget_logic_expand_control');
72
  // before any HTML output save widget changes and add controls to each widget on the widget admin page
73
  add_action( 'sidebar_admin_page', 'widget_logic_options_control');
74
- // add Widget Logic specific options on the widget admin page
75
- add_filter( 'plugin_action_links', 'wl_charity', 10, 2);// add my justgiving page link to the plugin admin page
76
 
77
  add_action( 'widgets_init', 'widget_logic_add_controls', 999 );
78
  }
@@ -173,7 +130,10 @@ function widget_logic_expand_control()
173
  // must update this to use http://codex.wordpress.org/Settings_API
174
  if ( isset($_POST['widget_logic-options-submit']) )
175
  {
176
- $wl_options['widget_logic-options-filter'] = !empty($_POST['widget_logic-options-filter']);
 
 
 
177
  $wl_options['widget_logic-options-wp_reset_query'] = !empty($_POST['widget_logic-options-wp_reset_query']);
178
  $wl_options['widget_logic-options-show_errors'] = !empty($_POST['widget_logic-options-show_errors']);
179
  $wl_options['widget_logic-options-load_point']=$_POST['widget_logic-options-load_point'];
@@ -209,11 +169,13 @@ function widget_logic_options_control()
209
  <h2><?php _e('Widget Logic options', 'widget-logic'); ?></h2>
210
  <form method="POST" style="float:left; width:45%">
211
  <ul>
 
212
  <li><label for="widget_logic-options-filter" title="<?php _e('Adds a new WP filter you can use in your own code. Not needed for main Widget Logic functionality.', 'widget-logic'); ?>">
213
  <input id="widget_logic-options-filter" name="widget_logic-options-filter" type="checkbox" value="checked" class="checkbox" <?php if (!empty($wl_options['widget_logic-options-filter'])) echo "checked" ?>/>
214
  <?php _e('Add \'widget_content\' filter', 'widget-logic'); ?>
215
  </label>
216
  </li>
 
217
  <li><label for="widget_logic-options-wp_reset_query" title="<?php _e('Resets a theme\'s custom queries before your Widget Logic is checked', 'widget-logic'); ?>">
218
  <input id="widget_logic-options-wp_reset_query" name="widget_logic-options-wp_reset_query" type="checkbox" value="checked" class="checkbox" <?php if (!empty($wl_options['widget_logic-options-wp_reset_query'])) echo "checked" ?> />
219
  <?php _e('Use \'wp_reset_query\' fix', 'widget-logic'); ?>
@@ -335,20 +297,12 @@ function widget_logic_extra_control()
335
  <?php else: ?>
336
  <textarea class="widefat" name="<?php echo $input_name ?>" id="<?php echo $input_id ?>"><?php echo esc_textarea( $logic ) ?></textarea>
337
  <?php endif ?>
 
338
  </p>
339
  <?php
340
  return true;
341
  }
342
 
343
- // CALLED ON 'plugin_action_links' ACTION
344
- function wl_charity($links, $file)
345
- { if ($file == plugin_basename(__FILE__))
346
- array_push($links, '<a href="http://www.justgiving.com/widgetlogic_cancerresearchuk/">'.esc_html__('Charity Donation', 'widget-logic').'</a>');
347
- return $links;
348
- }
349
-
350
-
351
-
352
  // FRONT END FUNCTIONS...
353
 
354
  function widget_logic_by_id( $widget_id )
@@ -403,12 +357,12 @@ function widget_logic_save( $widget_id, $logic )
403
  $info[ $widget_i ]['widget_logic'] = $logic;
404
  update_option( 'widget_'.$widget_class, $info );
405
  }
406
- else
407
- {
408
- $info = (array)get_option( 'widget_'.$widget_id, array() );
409
- $info['widget_logic'] = $logic;
410
- update_option( 'widget_'.$widget_id, $info );
411
- }
412
  }
413
 
414
  // CALLED ON 'sidebars_widgets' FILTER
@@ -540,84 +494,4 @@ function widget_logic_redirected_callback()
540
  }
541
  }
542
 
543
-
544
- function widget_logic_alert()
545
- {
546
- if ( $old = get_option('wpchefgadget_promo') )
547
- {
548
- delete_option('wpchefgadget_promo');
549
- if ( $old['limit-login-attempts'] )
550
- {
551
- $alert = (array)get_option( 'wpchefgadget_alert', array() );
552
- $alert['limit-login-attempts'] = $old['limit-login-attempts'];
553
- update_option( 'wpchefgadget_alert', $alert );
554
- return;
555
- }
556
- }
557
-
558
- $screen = get_current_screen();
559
-
560
- ?>
561
- <div class="notice notice-info is-dismissible" id="wpchefgadget_alert_lla">
562
- <p class="plugin-card-limit-login-attempts-reloaded"<?php if ( $screen->id != 'plugin-install' ) echo ' id="plugin-filter"' ?>>
563
- <b>Widget Logic team security recommendation only!</b> If your site is currently not protected (check with your admin) against login attacks (the most common reason admin login gets compromised) we highly recommend installing <a href="<?php echo network_admin_url('plugin-install.php?tab=plugin-information')?>&amp;plugin=limit-login-attempts-reloaded&amp;TB_iframe=true&amp;width=600&amp;height=550" class="thickbox open-plugin-details-modal" aria-label="More information about Limit Login Attempts Reloaded" data-title="Limit Login Attempts Reloaded">Limit Login Attempts Reloaded</a> plugin to immediately have the protection in place.
564
- <a href="<?php echo network_admin_url('plugin-install.php?tab=plugin-information')?>&amp;plugin=limit-login-attempts-reloaded&amp;TB_iframe=true&amp;width=600&amp;height=550" class="thickbox open-plugin-details-modal button" aria-label="More information about Limit Login Attempts Reloaded" data-title="Limit Login Attempts Reloaded" id="wpchef_alert_install_button">Install</a>
565
- <a class="install-now button" data-slug="limit-login-attempts-reloaded" href="<?php echo network_admin_url('update.php?action=install-plugin')?>&amp;plugin=limit-login-attempts-reloaded&amp;_wpnonce=<?php echo wp_create_nonce('install-plugin_limit-login-attempts-reloaded') ?>" aria-label="Install Limit Login Attempts Reloaded now" data-name="Limit Login Attempts Reloaded" style="display:none">Install Now</a>
566
- </p>
567
- </div>
568
- <script>
569
- jQuery('#wpchefgadget_alert_lla .open-plugin-details-modal').on('click', function(){
570
- jQuery('#wpchef_alert_install_button').hide().next().show();
571
- return true;
572
- });
573
- jQuery(function($){
574
- var alert = $('#wpchefgadget_alert_lla');
575
- alert.on('click', '.notice-dismiss', function(e){
576
- //e.preventDefault
577
- $.post( ajaxurl, {
578
- action: 'wpchefgadget_dismiss_alert',
579
- alert: 'limit-login-attempts',
580
- sec: <?php echo json_encode( wp_create_nonce('wpchefgadget_dissmiss_alert') ) ?>
581
- } );
582
- });
583
-
584
- <?php if ( $screen->id == 'plugin-install' ): ?>
585
- $('#plugin-filter').prepend( alert.css('margin-bottom','10px').addClass('inline') );
586
- <?php endif ?>
587
-
588
- $(document).on('tb_unload', function(){
589
- if ( jQuery('#wpchef_alert_install_button').next().hasClass('updating-message') )
590
- return;
591
-
592
- jQuery('#wpchef_alert_install_button').show().next().hide();
593
- });
594
- $(document).on('credential-modal-cancel', function(){
595
- jQuery('#wpchef_alert_install_button').show().next().hide();
596
- });
597
- });
598
- </script>
599
- <?php
600
- wp_print_request_filesystem_credentials_modal();
601
- }
602
-
603
- function widget_logic_dismiss_alert()
604
- {
605
- check_ajax_referer( 'wpchefgadget_dissmiss_alert', 'sec' );
606
-
607
- $alert = (array)get_option( 'wpchefgadget_alert', array() );
608
- $alert[ $_POST['alert'] ] = 1;
609
-
610
- add_option( 'wpchefgadget_alert', $alert, '', 'no' );
611
- update_option( 'wpchefgadget_alert', $alert );
612
-
613
- exit;
614
- }
615
-
616
- function widget_logic_alert_scripts()
617
- {
618
- wp_enqueue_script( 'plugin-install' );
619
- add_thickbox();
620
- wp_enqueue_script( 'updates' );
621
- }
622
-
623
  ?>
1
  <?php
2
  /*
3
+ Plugin Name: Widget Logic
4
+ Author URI: https://wpchef.org
5
+ Description: Control widgets with WP's conditional tags is_home etc
6
+ Version: 5.10.2
7
+ Author: WPChef
8
+ Text Domain: widget-logic
 
 
9
  */
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  $plugin_dir = basename(dirname(__FILE__));
12
  global $wl_options, $wl_in_customizer;
13
 
17
  function widget_logic_init()
18
  {
19
  load_plugin_textdomain( 'widget-logic', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  }
21
 
22
  if((!$wl_options = get_option('widget_logic')) || !is_array($wl_options) )
30
  add_action( 'sidebar_admin_setup', 'widget_logic_expand_control');
31
  // before any HTML output save widget changes and add controls to each widget on the widget admin page
32
  add_action( 'sidebar_admin_page', 'widget_logic_options_control');
 
 
33
 
34
  add_action( 'widgets_init', 'widget_logic_add_controls', 999 );
35
  }
130
  // must update this to use http://codex.wordpress.org/Settings_API
131
  if ( isset($_POST['widget_logic-options-submit']) )
132
  {
133
+ if ( !empty($_POST['widget_logic-options-filter']) )
134
+ $wl_options['widget_logic-options-filter'] = true;
135
+ else
136
+ unset( $wl_options['widget_logic-options-filter'] );
137
  $wl_options['widget_logic-options-wp_reset_query'] = !empty($_POST['widget_logic-options-wp_reset_query']);
138
  $wl_options['widget_logic-options-show_errors'] = !empty($_POST['widget_logic-options-show_errors']);
139
  $wl_options['widget_logic-options-load_point']=$_POST['widget_logic-options-load_point'];
169
  <h2><?php _e('Widget Logic options', 'widget-logic'); ?></h2>
170
  <form method="POST" style="float:left; width:45%">
171
  <ul>
172
+ <?php if ( !empty($wl_options['widget_logic-options-filter']) ): ?>
173
  <li><label for="widget_logic-options-filter" title="<?php _e('Adds a new WP filter you can use in your own code. Not needed for main Widget Logic functionality.', 'widget-logic'); ?>">
174
  <input id="widget_logic-options-filter" name="widget_logic-options-filter" type="checkbox" value="checked" class="checkbox" <?php if (!empty($wl_options['widget_logic-options-filter'])) echo "checked" ?>/>
175
  <?php _e('Add \'widget_content\' filter', 'widget-logic'); ?>
176
  </label>
177
  </li>
178
+ <?php endif ?>
179
  <li><label for="widget_logic-options-wp_reset_query" title="<?php _e('Resets a theme\'s custom queries before your Widget Logic is checked', 'widget-logic'); ?>">
180
  <input id="widget_logic-options-wp_reset_query" name="widget_logic-options-wp_reset_query" type="checkbox" value="checked" class="checkbox" <?php if (!empty($wl_options['widget_logic-options-wp_reset_query'])) echo "checked" ?> />
181
  <?php _e('Use \'wp_reset_query\' fix', 'widget-logic'); ?>
297
  <?php else: ?>
298
  <textarea class="widefat" name="<?php echo $input_name ?>" id="<?php echo $input_id ?>"><?php echo esc_textarea( $logic ) ?></textarea>
299
  <?php endif ?>
300
+ <?php wp_nonce_field( 'widget_logic_save', 'widget_logic_nonce' ); ?>
301
  </p>
302
  <?php
303
  return true;
304
  }
305
 
 
 
 
 
 
 
 
 
 
306
  // FRONT END FUNCTIONS...
307
 
308
  function widget_logic_by_id( $widget_id )
357
  $info[ $widget_i ]['widget_logic'] = $logic;
358
  update_option( 'widget_'.$widget_class, $info );
359
  }
360
+ else if( isset( $_POST['widget_logic_nonce'] ) && wp_verify_nonce( $_POST['widget_logic_nonce'], 'widget_logic_save') ) {
361
+
362
+ $info = (array)get_option( 'widget_'.$widget_id, array() );
363
+ $info['widget_logic'] = $logic;
364
+ update_option( 'widget_'.$widget_id, $info );
365
+ }
366
  }
367
 
368
  // CALLED ON 'sidebars_widgets' FILTER
494
  }
495
  }
496
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
497
  ?>