Dynamic Widgets - Version 1.5.9

Version Description

= 1.5.8 = When you upgrade manually, remove the dynamic-widgets directory first.

This version has 1 feature added, 1 language added and 3 bugs fixed.

Download this release

Release Info

Developer qurl
Plugin Icon wp plugin Dynamic Widgets
Version 1.5.9
Comparing to
See all releases

Code changes from version 1.5.8 to 1.5.9

classes/dynwid_class.php CHANGED
@@ -13,6 +13,7 @@
13
  public $dynwid_list;
14
  public $enabled;
15
  private $firstmessage = TRUE;
 
16
  public $listmade = FALSE;
17
  public $overrule_maintype = array();
18
  private $registered_sidebars;
@@ -44,6 +45,7 @@
44
  $this->registered_widgets = &$GLOBALS['wp_registered_widgets'];
45
  $this->sidebars = wp_get_sidebars_widgets();
46
  $this->useragent = $this->getBrowser();
 
47
 
48
  // DB init
49
  $this->wpdb = $GLOBALS['wpdb'];
@@ -128,6 +130,30 @@
128
  }
129
  }
130
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
  /**
132
  * dynWid::addUrls() Saves url options
133
  *
@@ -446,6 +472,13 @@
446
  $results = new DWOpts($this->wpdb->get_results($query), $maintype);
447
  return $results;
448
  }
 
 
 
 
 
 
 
449
 
450
  /**
451
  * dynWid::getModuleName() Full registration of the modules
@@ -461,6 +494,7 @@
461
  DWModule::registerOption(DW_bbPress::$option);
462
  DWModule::registerOption(DW_BP::$option);
463
  DWModule::registerOption(DW_Browser::$option);
 
464
  DWModule::registerOption(DW_Category::$option);
465
  DW_CustomPost::registerOption(NULL);
466
  DWModule::registerOption(DW_Date::$option);
@@ -683,6 +717,79 @@
683
  }
684
  }
685
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
686
  /**
687
  * dynWid::loadModules() Full load of all modules
688
  *
@@ -735,6 +842,7 @@
735
  include_once(DW_MODULES . 'tpl_module.php');
736
  include_once(DW_MODULES . 'url_module.php');
737
  include_once(DW_MODULES . 'device_module.php');
 
738
  DW_Browser::checkOverrule('DW_Browser');
739
  DW_Date::checkOverrule('DW_Date');
740
  DW_Day::checkOverrule('DW_Day');
@@ -743,6 +851,7 @@
743
  DW_Tpl::checkOverrule('DW_Tpl');
744
  DW_URL::checkOverrule('DW_URL');
745
  DW_URL::checkOverrule('DW_Device');
 
746
 
747
  // WPML Plugin Support
748
  include_once(DW_MODULES . 'wpml_module.php');
13
  public $dynwid_list;
14
  public $enabled;
15
  private $firstmessage = TRUE;
16
+ public $ip_address;
17
  public $listmade = FALSE;
18
  public $overrule_maintype = array();
19
  private $registered_sidebars;
45
  $this->registered_widgets = &$GLOBALS['wp_registered_widgets'];
46
  $this->sidebars = wp_get_sidebars_widgets();
47
  $this->useragent = $this->getBrowser();
48
+ $this->ip_address = $this->getIP();
49
 
50
  // DB init
51
  $this->wpdb = $GLOBALS['wpdb'];
130
  }
131
  }
132
 
133
+ /**
134
+ * dynWid::addIPs() Saves IP options
135
+ *
136
+ * @param string $widget_id ID of the widget
137
+ * @param array $default Default setting
138
+ * @param string $ips IPs
139
+ */
140
+ public function addIPs($widget_id, $default, $ips) {
141
+ $value = serialize($ips);
142
+ if ( $default == 'no' ) {
143
+ $query = "INSERT INTO " . $this->dbtable . "
144
+ (widget_id, maintype, name, value)
145
+ VALUES
146
+ ('" . esc_sql($widget_id) . "', 'ip', 'default', '0')";
147
+ $this->wpdb->query($query);
148
+ }
149
+
150
+ $query = "INSERT INTO " . $this->dbtable . "
151
+ (widget_id, maintype, name, value)
152
+ VALUES
153
+ ('" . esc_sql($widget_id) . "', 'ip', 'ip', '" . $value . "')";
154
+ $this->wpdb->query($query);
155
+ }
156
+
157
  /**
158
  * dynWid::addUrls() Saves url options
159
  *
472
  $results = new DWOpts($this->wpdb->get_results($query), $maintype);
473
  return $results;
474
  }
475
+
476
+ private function getIP() {
477
+ $ip = $_SERVER['REMOTE_ADDR'];
478
+ $this->message( 'Raw IP: ' . $ip );
479
+
480
+ return ( strstr($ip, '.') !== FALSE ) ? $ip : NULL;
481
+ }
482
 
483
  /**
484
  * dynWid::getModuleName() Full registration of the modules
494
  DWModule::registerOption(DW_bbPress::$option);
495
  DWModule::registerOption(DW_BP::$option);
496
  DWModule::registerOption(DW_Browser::$option);
497
+ DWModule::registerOption(DW_IP::$option);
498
  DWModule::registerOption(DW_Category::$option);
499
  DW_CustomPost::registerOption(NULL);
500
  DWModule::registerOption(DW_Date::$option);
717
  }
718
  }
719
 
720
+ /**
721
+ * dynWid::IPinRange() IP address in range
722
+ *
723
+ * @param $ip string IP address
724
+ * @param $range string IP range
725
+ * @return boolean
726
+ */
727
+ public function IPinRange($ip, $range) {
728
+ /* Copyright 2008: Paul Gregg <pgregg@pgregg.com>
729
+ * 10 January 2008
730
+ * Version: 1.2
731
+ *
732
+ * Source website: http://www.pgregg.com/projects/php/ip_in_range/
733
+ * Version 1.2
734
+ */
735
+
736
+ if ( strpos($range, '/') !== FALSE ) {
737
+ // $range is in IP/NETMASK format
738
+ list($range, $netmask) = explode('/', $range, 2);
739
+
740
+ if ( strpos($netmask, '.') !== FALSE ) {
741
+ // $netmask is a 255.255.0.0 format
742
+ $netmask = str_replace('*', '0', $netmask);
743
+ $netmask_dec = ip2long($netmask);
744
+
745
+ return ( (ip2long($ip) & $netmask_dec) == (ip2long($range) & $netmask_dec) );
746
+ } else {
747
+ // $netmask is a CIDR size block
748
+ // fix the range argument
749
+ $x = explode('.', $range);
750
+ while ( count($x) < 4 ) {
751
+ $x[ ] = '0';
752
+ }
753
+
754
+ list( $a, $b, $c, $d ) = $x;
755
+ $range = sprintf( "%u.%u.%u.%u", empty($a) ? '0' : $a, empty($b) ? '0' : $b, empty($c) ? '0' : $c, empty($d) ? '0' : $d );
756
+ $range_dec = ip2long($range);
757
+ $ip_dec = ip2long($ip);
758
+
759
+ // Use math to create it
760
+ $wildcard_dec = pow( 2, (32-$netmask) ) - 1;
761
+ $netmask_dec = ~ $wildcard_dec;
762
+
763
+ return ( ($ip_dec & $netmask_dec) == ($range_dec & $netmask_dec) );
764
+ }
765
+ } else {
766
+ // range might be 255.255.*.* or 1.2.3.0-1.2.3.255
767
+ if ( strpos($range, '*') !== FALSE ) { // a.b.*.* format
768
+ // Just convert to A-B format by setting * to 0 for A and 255 for B
769
+ $lower = str_replace('*', '0', $range);
770
+ $upper = str_replace('*', '255', $range);
771
+ $range = "$lower-$upper";
772
+ }
773
+
774
+ if ( strpos($range, '-') !== FALSE ) { // A-B format
775
+ list( $lower, $upper ) = explode('-', $range, 2);
776
+ $lower_dec = (float) sprintf( "%u", ip2long($lower) );
777
+ $upper_dec = (float) sprintf( "%u", ip2long($upper) );
778
+ $ip_dec = (float) sprintf( "%u",ip2long($ip) );
779
+ return ( ($ip_dec >= $lower_dec) && ($ip_dec <= $upper_dec) );
780
+ }
781
+
782
+ // last resort
783
+ if ( substr($range, -3) != '/32' ) {
784
+ $range .= '/32';
785
+ return $this->IPinRange($ip, $range);
786
+ }
787
+
788
+ $this->message('Range argument is not in 1.2.3.4/24 or 1.2.3.4/255.255.255.0 format');
789
+ return FALSE;
790
+ }
791
+
792
+ }
793
  /**
794
  * dynWid::loadModules() Full load of all modules
795
  *
842
  include_once(DW_MODULES . 'tpl_module.php');
843
  include_once(DW_MODULES . 'url_module.php');
844
  include_once(DW_MODULES . 'device_module.php');
845
+ include_once(DW_MODULES . 'ip_module.php');
846
  DW_Browser::checkOverrule('DW_Browser');
847
  DW_Date::checkOverrule('DW_Date');
848
  DW_Day::checkOverrule('DW_Day');
851
  DW_Tpl::checkOverrule('DW_Tpl');
852
  DW_URL::checkOverrule('DW_URL');
853
  DW_URL::checkOverrule('DW_Device');
854
+ DW_URL::checkOverrule('DW_IP');
855
 
856
  // WPML Plugin Support
857
  include_once(DW_MODULES . 'wpml_module.php');
dynamic-widgets.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin URI: http://dynamic-widgets.com/
5
  * Description: Dynamic Widgets gives you full control on which pages your widgets will appear. It lets you dynamicly show or hide widgets on WordPress pages.
6
  * Author: Qurl
7
- * Version: 1.5.8
8
  * Author URI: http://www.qurl.nl/
9
  * Tags: widget, widgets, dynamic, sidebar, custom, rules, logic, admin, condition, conditional tags, hide, show, wpml, qtranslate, wpec, buddypress, pods
10
  *
@@ -15,7 +15,7 @@
15
  *
16
  * Released under the GPL v.2, http://www.gnu.org/copyleft/gpl.html
17
  *
18
- * @version $Id: dynamic-widgets.php 937227 2014-06-23 15:10:15Z qurl $
19
  * @copyright 2014 Jacco Drabbe
20
  *
21
  * Thanks to Alexis Nomine for the contribution of the French (fr_FR) language files, several L10N fixes and change of the edit options UI.
@@ -77,7 +77,7 @@
77
  define('DW_PLUGIN', dirname(__FILE__) . '/' . 'plugin/');
78
  define('DW_TIME_LIMIT', 86400); // 1 day
79
  define('DW_URL_AUTHOR', 'http://www.qurl.nl');
80
- define('DW_VERSION', '1.5.8');
81
  define('DW_WPML_API', '/inc/wpml-api.php'); // WPML Plugin support - API file relative to ICL_PLUGIN_PATH
82
  define('DW_WPML_ICON', 'img/wpml_icon.png'); // WPML Plugin support - WPML icon
83
 
4
  * Plugin URI: http://dynamic-widgets.com/
5
  * Description: Dynamic Widgets gives you full control on which pages your widgets will appear. It lets you dynamicly show or hide widgets on WordPress pages.
6
  * Author: Qurl
7
+ * Version: 1.5.9
8
  * Author URI: http://www.qurl.nl/
9
  * Tags: widget, widgets, dynamic, sidebar, custom, rules, logic, admin, condition, conditional tags, hide, show, wpml, qtranslate, wpec, buddypress, pods
10
  *
15
  *
16
  * Released under the GPL v.2, http://www.gnu.org/copyleft/gpl.html
17
  *
18
+ * @version $Id: dynamic-widgets.php 949624 2014-07-16 12:56:39Z qurl $
19
  * @copyright 2014 Jacco Drabbe
20
  *
21
  * Thanks to Alexis Nomine for the contribution of the French (fr_FR) language files, several L10N fixes and change of the edit options UI.
77
  define('DW_PLUGIN', dirname(__FILE__) . '/' . 'plugin/');
78
  define('DW_TIME_LIMIT', 86400); // 1 day
79
  define('DW_URL_AUTHOR', 'http://www.qurl.nl');
80
+ define('DW_VERSION', '1.5.9');
81
  define('DW_WPML_API', '/inc/wpml-api.php'); // WPML Plugin support - API file relative to ICL_PLUGIN_PATH
82
  define('DW_WPML_ICON', 'img/wpml_icon.png'); // WPML Plugin support - WPML icon
83
 
dynwid_admin_edit.php CHANGED
@@ -2,7 +2,7 @@
2
  /**
3
  * dynwid_admin_edit.php - Options settings
4
  *
5
- * @version $Id: dynwid_admin_edit.php 872198 2014-03-09 12:51:52Z qurl $
6
  * @copyright 2011 Jacco Drabbe
7
  */
8
 
@@ -30,7 +30,7 @@ label {
30
  }
31
 
32
  .condition-select {
33
- width : 300px;
34
  -moz-border-radius-topleft : 6px;
35
  -moz-border-radius-topright : 6px;
36
  -moz-border-radius-bottomleft : 6px;
@@ -102,11 +102,12 @@ div.settingbox {
102
  add = false;
103
  }
104
 
105
- var value = jQuery( '#' + prefix + '_act' ).val();
 
106
  var a = value.split(',');
107
 
108
  if ( child ) {
109
- var value_child = jQuery( '#' + prefix + '_childs_act' ).val();
110
  var a_child = value_child.split(',');
111
  }
112
 
@@ -147,8 +148,10 @@ div.settingbox {
147
  add = true;
148
  }
149
 
150
- var value = jQuery( '#' + prefix + '_act' ).val();
151
- var value_child = jQuery( '#' + prefix + '_childs_act' ).val();
 
 
152
  var a = value.split(',');
153
  var a_child = value_child.split(',');
154
 
@@ -376,6 +379,11 @@ div.settingbox {
376
  $DW_Browser = new DW_Browser();
377
  $DW_Browser->admin();
378
  }
 
 
 
 
 
379
 
380
  if ( array_key_exists('device', $DW->dwoptions) ) {
381
  $DW_Device = new DW_Device();
2
  /**
3
  * dynwid_admin_edit.php - Options settings
4
  *
5
+ * @version $Id: dynwid_admin_edit.php 939272 2014-06-26 19:44:38Z qurl $
6
  * @copyright 2011 Jacco Drabbe
7
  */
8
 
30
  }
31
 
32
  .condition-select {
33
+ width : 450px;
34
  -moz-border-radius-topleft : 6px;
35
  -moz-border-radius-topright : 6px;
36
  -moz-border-radius-bottomleft : 6px;
102
  add = false;
103
  }
104
 
105
+ var value = jQuery( 'input[name^="' + prefix + '_act"]' ).val();
106
+ console.log( 'prefix: ' + prefix + ', value: ' + value );
107
  var a = value.split(',');
108
 
109
  if ( child ) {
110
+ var value_child = jQuery( 'input[name^="' + prefix + '_childs_act"]' ).val();
111
  var a_child = value_child.split(',');
112
  }
113
 
148
  add = true;
149
  }
150
 
151
+ // var value = jQuery( '#' + prefix + '_act' ).val();
152
+ var value = jQuery( 'input[name^="' + prefix + '_act"]' ).val();
153
+ // var value_child = jQuery( '#' + prefix + '_childs_act' ).val();
154
+ var value_child = jQuery( 'input[name^="' + prefix + '_childs_act"]' ).val();
155
  var a = value.split(',');
156
  var a_child = value_child.split(',');
157
 
379
  $DW_Browser = new DW_Browser();
380
  $DW_Browser->admin();
381
  }
382
+
383
+ if ( array_key_exists('ip', $DW->dwoptions) ) {
384
+ $DW_IP = new DW_IP();
385
+ $DW_IP->admin();
386
+ }
387
 
388
  if ( array_key_exists('device', $DW->dwoptions) ) {
389
  $DW_Device = new DW_Device();
dynwid_admin_save.php CHANGED
@@ -2,7 +2,7 @@
2
  /**
3
  * dynwid_admin_save.php - Saving options to the database
4
  *
5
- * @version $Id: dynwid_admin_save.php 872198 2014-03-09 12:51:52Z qurl $
6
  * @copyright 2011 Jacco Drabbe
7
  */
8
 
@@ -68,6 +68,12 @@
68
  wp_redirect( $_SERVER['REQUEST_URI'] . '&work=none' );
69
  die();
70
  }
 
 
 
 
 
 
71
 
72
  // Removing already set options, but keeping individual rules
73
  $dbtable = $GLOBALS['wpdb']->prefix . DW_DB_TABLE;
@@ -154,6 +160,26 @@
154
  $DW->addUrls($widget_id, $_POST['url'], $urls);
155
  }
156
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
 
158
  // Front Page
159
  DWModule::save('front-page', 'complex');
2
  /**
3
  * dynwid_admin_save.php - Saving options to the database
4
  *
5
+ * @version $Id: dynwid_admin_save.php 939272 2014-06-26 19:44:38Z qurl $
6
  * @copyright 2011 Jacco Drabbe
7
  */
8
 
68
  wp_redirect( $_SERVER['REQUEST_URI'] . '&work=none' );
69
  die();
70
  }
71
+
72
+ // IP
73
+ if ( $_POST['ip'] == 'no' && empty($_POST['ip_value']) ) {
74
+ wp_redirect( $_SERVER['REQUEST_URI'] . '&work=none' );
75
+ die();
76
+ }
77
 
78
  // Removing already set options, but keeping individual rules
79
  $dbtable = $GLOBALS['wpdb']->prefix . DW_DB_TABLE;
160
  $DW->addUrls($widget_id, $_POST['url'], $urls);
161
  }
162
  }
163
+
164
+ // IP
165
+ if (! empty($_POST['ip_value']) ) {
166
+ $ips = array();
167
+
168
+ $ip_values = trim($_POST['ip_value']);
169
+ $ip_values = str_replace("\r", "", $ip_values);
170
+ $ip_values = explode("\n", $ip_values);
171
+
172
+ foreach ( $ip_values as $ip ) {
173
+ $ip = trim($ip);
174
+ if (! empty($ip) ) {
175
+ $ips[ ] = $ip;
176
+ }
177
+ }
178
+
179
+ if ( count($ips) > 0 ) {
180
+ $DW->addIPs($widget_id, $_POST['ip'], $ips);
181
+ }
182
+ }
183
 
184
  // Front Page
185
  DWModule::save('front-page', 'complex');
dynwid_init_worker.php CHANGED
@@ -2,7 +2,7 @@
2
  /**
3
  * dynwid_init_worker.php
4
  *
5
- * @version $Id: dynwid_init_worker.php 937227 2014-06-23 15:10:15Z qurl $
6
  * @copyright 2011 Jacco Drabbe
7
  */
8
 
@@ -15,6 +15,9 @@
15
 
16
  // UserAgent detection
17
  $DW->message('UserAgent: ' . $DW->useragent);
 
 
 
18
 
19
  $DW->message('Today it is ' . date('l', current_time('timestamp', 0)) . ' (' . date('N', current_time('timestamp', 0)) . '), Week: ' . date('W', current_time('timestamp', 0)));
20
 
2
  /**
3
  * dynwid_init_worker.php
4
  *
5
+ * @version $Id: dynwid_init_worker.php 939272 2014-06-26 19:44:38Z qurl $
6
  * @copyright 2011 Jacco Drabbe
7
  */
8
 
15
 
16
  // UserAgent detection
17
  $DW->message('UserAgent: ' . $DW->useragent);
18
+
19
+ //IP
20
+ $DW->message('IP: ' . $DW->ip_address);
21
 
22
  $DW->message('Today it is ' . date('l', current_time('timestamp', 0)) . ' (' . date('N', current_time('timestamp', 0)) . '), Week: ' . date('W', current_time('timestamp', 0)));
23
 
dynwid_worker.php CHANGED
@@ -2,7 +2,7 @@
2
  /**
3
  * dynwid_worker.php - The worker does the actual work.
4
  *
5
- * @version $Id: dynwid_worker.php 872198 2014-03-09 12:51:52Z qurl $
6
  * @copyright 2011 Jacco Drabbe
7
  */
8
 
@@ -170,7 +170,7 @@
170
  }
171
  unset($qt_tmp);
172
 
173
- // Browser, Device, Template, Day, Week and URL
174
  foreach ( $opt as $condition ) {
175
  if ( $condition->maintype == 'browser' && $condition->name == $DW->useragent ) {
176
  (bool) $browser_tmp = $condition->value;
@@ -220,6 +220,16 @@
220
  }
221
  }
222
  }
 
 
 
 
 
 
 
 
 
 
223
  }
224
  }
225
 
@@ -258,6 +268,12 @@
258
  }
259
  unset($url_tmp, $other_url);
260
 
 
 
 
 
 
 
261
  // For debug messages
262
  $e = ( isset($other) && $other ) ? 'TRUE' : 'FALSE';
263
 
2
  /**
3
  * dynwid_worker.php - The worker does the actual work.
4
  *
5
+ * @version $Id: dynwid_worker.php 939272 2014-06-26 19:44:38Z qurl $
6
  * @copyright 2011 Jacco Drabbe
7
  */
8
 
170
  }
171
  unset($qt_tmp);
172
 
173
+ // Browser, Device, IP, Template, Day, Week and URL
174
  foreach ( $opt as $condition ) {
175
  if ( $condition->maintype == 'browser' && $condition->name == $DW->useragent ) {
176
  (bool) $browser_tmp = $condition->value;
220
  }
221
  }
222
  }
223
+ } else if ( $condition->maintype == 'ip' && $condition->name == 'ip' && ! is_null($DW->ip_address) ) {
224
+ $ips = unserialize($condition->value);
225
+ $other_ip = ( $ip ) ? FALSE : TRUE;
226
+
227
+ foreach ( $ips as $range ) {
228
+ if ( $DW->IPinRange($DW->ip_address, $range) ) {
229
+ $ip_tmp = $other_ip;
230
+ break;
231
+ }
232
+ }
233
  }
234
  }
235
 
268
  }
269
  unset($url_tmp, $other_url);
270
 
271
+ if ( isset($ip_tmp) && $ip_tmp != $ip ) {
272
+ $DW->message('Exception triggered for ip, sets display to ' . ( ($ip_tmp) ? 'TRUE' : 'FALSE' ) . ' (rule EIP1)');
273
+ $ip = $ip_tmp;
274
+ }
275
+ unset($ip_tmp, $other_ip);
276
+
277
  // For debug messages
278
  $e = ( isset($other) && $other ) ? 'TRUE' : 'FALSE';
279
 
mods/author_module.php CHANGED
@@ -2,7 +2,7 @@
2
  /**
3
  * Author Module
4
  *
5
- * @version $Id: author_module.php 937227 2014-06-23 15:10:15Z qurl $
6
  * @copyright 2011 Jacco Drabbe
7
  */
8
 
@@ -39,7 +39,7 @@
39
  return $list;
40
  }
41
 
42
- public static function mkGUI($type, $title, $question, $info = FALSE) {
43
  $DW = &$GLOBALS['DW'];
44
  $list = self::getAuthors();
45
 
2
  /**
3
  * Author Module
4
  *
5
+ * @version $Id: author_module.php 938420 2014-06-25 11:18:19Z qurl $
6
  * @copyright 2011 Jacco Drabbe
7
  */
8
 
39
  return $list;
40
  }
41
 
42
+ public static function mkGUI($type, $title, $question, $info = FALSE, $except = FALSE, $list = FALSE, $name = NULL) {
43
  $DW = &$GLOBALS['DW'];
44
  $list = self::getAuthors();
45
 
mods/category_module.php CHANGED
@@ -2,7 +2,7 @@
2
  /**
3
  * Category Module
4
  *
5
- * @version $Id: category_module.php 937227 2014-06-23 15:10:15Z qurl $
6
  * @copyright 2011 Jacco Drabbe
7
  */
8
 
@@ -46,7 +46,7 @@
46
  $list = get_categories( array('hide_empty' => FALSE) );
47
  $catmap = self::getCatChilds(array(), 0, array());
48
 
49
- if (! is_null($opt) ) {
50
  self::$opt = $name;
51
  }
52
  if ( self::$opt->count > 0 ) {
@@ -66,7 +66,7 @@
66
  _e(self::$except, DW_L10N_DOMAIN);
67
  echo '<br />';
68
  echo '<div id="' . self::$name . '-select" class="condition-select" ' . ( (isset($select_style)) ? $select_style : '' ) . ' />';
69
- self::prtCat($catmap, self::$opt->act, $childs, $single);
70
  echo '</div>' . "\n";
71
  }
72
 
2
  /**
3
  * Category Module
4
  *
5
+ * @version $Id: category_module.php 938226 2014-06-25 05:16:47Z qurl $
6
  * @copyright 2011 Jacco Drabbe
7
  */
8
 
46
  $list = get_categories( array('hide_empty' => FALSE) );
47
  $catmap = self::getCatChilds(array(), 0, array());
48
 
49
+ if (! is_null($name) ) {
50
  self::$opt = $name;
51
  }
52
  if ( self::$opt->count > 0 ) {
66
  _e(self::$except, DW_L10N_DOMAIN);
67
  echo '<br />';
68
  echo '<div id="' . self::$name . '-select" class="condition-select" ' . ( (isset($select_style)) ? $select_style : '' ) . ' />';
69
+ self::prtCat($catmap, self::$opt->act, $childs, $extra);
70
  echo '</div>' . "\n";
71
  }
72
 
mods/ip_module.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * IP Module
4
+ * Can't use DWOpts object because value = the serialized values
5
+ *
6
+ * @version $Id$
7
+ * @copyright 2014 Jacco Drabbe
8
+ */
9
+
10
+ class DW_IP extends DWModule {
11
+ public static $option = array( 'ip' => 'IP Address' );
12
+ protected static $overrule = TRUE;
13
+ protected static $type = 'custom';
14
+
15
+ public static function admin() {
16
+ $DW = $GLOBALS['DW'];
17
+
18
+ parent::admin();
19
+
20
+ $ip_yes_selected = 'checked="checked"';
21
+ $opt_ip = $DW->getOpt($GLOBALS['widget_id'], 'ip');
22
+
23
+ foreach ( $opt_ip as $opt ) {
24
+ if ( $opt->name == 'default' ) {
25
+ $ip_no_selected = $ip_yes_selected;
26
+ unset($ip_yes_selected);
27
+ } else {
28
+ $ips = unserialize($opt->value);
29
+ }
30
+ }
31
+ ?>
32
+ <h4 id="ip" title=" Click to toggle " class="ui-accordion-header ui-helper-reset ui-state-default ui-corner-all"><b><?php _e('IP Address'); ?></b><?php echo ( count($opt_ip) > 0 ) ? ' <img src="' . $DW->plugin_url . 'img/checkmark.gif" alt="Checkmark" />' : ''; ?></h4>
33
+ <div id="ip_conf" class="dynwid_conf ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom">
34
+ <?php _e('Show widget for this IP (range)?', DW_L10N_DOMAIN); ?> <img src="<?php echo $DW->plugin_url; ?>img/info.gif" alt="info" title="<?php _e('Click to toggle info', DW_L10N_DOMAIN) ?>" onclick="divToggle('ip_info');" /><br />
35
+ <?php $DW->dumpOpt($opt_ip); ?>
36
+ <div>
37
+ <div id="ip_info" class="infotext">
38
+ Works only with IPv4, not IPv6! No checks are performed for overlapping addresses, invalid ranges, etc.<br />
39
+ Separate IP (ranges) on each line.<br />
40
+ <br />
41
+ IP format notation can be...
42
+ <div style="position:relative;left:20px;">
43
+ <ul>
44
+ <li>single IP: 192.168.1.1</li>
45
+ <li>in <a href="http://en.wikipedia.org/wiki/Cidr" target="_blank">CIDR</a><sup> [WARNING: techie!]</sup> (recommended): 192.168.1.1/32, 192.168.1.0/24 or 192.168.1.0/255.255.255.0</li>
46
+ <li>in wildcard: 192.168.1.*</li>
47
+ <li>in range: 192.168.1.1-192.168.1.254</li>
48
+ </ul>
49
+ </div>
50
+ </div>
51
+ </div>
52
+ <br />
53
+ <input type="radio" name="ip" value="yes" id="ip-yes" <?php echo ( isset($ip_yes_selected) ) ? $ip_yes_selected : ''; ?> /> <label for="ip-yes"><?php _e('Yes'); ?></label>
54
+ <input type="radio" name="ip" value="no" id="ip-no" <?php echo ( isset($ip_no_selected) ) ? $ip_no_selected : ''; ?> /> <label for="ip-no"><?php _e('No'); ?></label><br />
55
+ <?php _e('Except the IP (ranges)', DW_L10N_DOMAIN); ?>:<br />
56
+ <div id="ip-select" class="condition-select">
57
+ <textarea name="ip_value" style="width:300px;height:150px;"><?php echo ( isset($ips) ) ? implode("\n", $ips) : ''; ?></textarea>
58
+ </div>
59
+
60
+ </div><!-- end dynwid_conf -->
61
+ <?php
62
+ }
63
+ }
64
+ ?>
mods/pages_module.php CHANGED
@@ -2,7 +2,7 @@
2
  /**
3
  * Pages Module
4
  *
5
- * @version $Id: pages_module.php 937227 2014-06-23 15:10:15Z qurl $
6
  * @copyright 2011 Jacco Drabbe
7
  */
8
 
@@ -21,10 +21,10 @@
21
 
22
  parent::admin();
23
 
24
- self::$opt = $DW->getDWOpt($_GET['id'], 'page');
25
  self::$opt_page = self::$opt;
26
  if ( self::$opt->count > 0 ) {
27
- self::$opt_page_childs = $DW->getDWOpt($_GLOBALS['widget_id'], 'page-childs');
28
  }
29
 
30
  $pages = get_pages( array('post_status' => 'publish,private') );
2
  /**
3
  * Pages Module
4
  *
5
+ * @version $Id: pages_module.php 938061 2014-06-24 21:17:14Z qurl $
6
  * @copyright 2011 Jacco Drabbe
7
  */
8
 
21
 
22
  parent::admin();
23
 
24
+ self::$opt = $DW->getDWOpt($GLOBALS['widget_id'], 'page');
25
  self::$opt_page = self::$opt;
26
  if ( self::$opt->count > 0 ) {
27
+ self::$opt_page_childs = $DW->getDWOpt($GLOBALS['widget_id'], 'page-childs');
28
  }
29
 
30
  $pages = get_pages( array('post_status' => 'publish,private') );
mods/url_module.php CHANGED
@@ -18,7 +18,7 @@
18
  parent::admin();
19
 
20
  $url_yes_selected = 'checked="checked"';
21
- $opt_url = $DW->getOpt($_GLOBALS['widget_id'], 'url');
22
  $prefix = $DW->getURLPrefix();
23
 
24
  foreach ( $opt_url as $opt ) {
18
  parent::admin();
19
 
20
  $url_yes_selected = 'checked="checked"';
21
+ $opt_url = $DW->getOpt($GLOBALS['widget_id'], 'url');
22
  $prefix = $DW->getURLPrefix();
23
 
24
  foreach ( $opt_url as $opt ) {
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.qurl.nl/dynamic-widgets/donate/
4
  Tags: widget, widgets, dynamic, sidebar, custom, rules, logic, display, admin, condition, conditional tags, hide, show, wpml, qtranslate, wpec, buddypress, pods, bbpress
5
  Requires at least: 3.0.0
6
  Tested up to: 3.9.1
7
- Stable tag: 1.5.8
8
 
9
  Dynamic Widgets gives you full control on which pages a widget will display. It lets you dynamicly show or hide widgets on WordPress pages.
10
 
@@ -30,6 +30,7 @@ It is very hard to continue development and support for this plugin without cont
30
  - Day of week
31
  - Weeknumbers
32
  - Browsers
 
33
  - Devices (mobile, desktop)
34
  - Theme Templates
35
  - Languages (WPML or QTranslate)
@@ -59,6 +60,7 @@ It is very hard to continue development and support for this plugin without cont
59
  - Day of week on day
60
  - Weeknumer on number
61
  - Browsers on browser name
 
62
  - Devices on type
63
  - Theme Templates on template name
64
  - Languages (WPML or QTranslate) on language
@@ -183,6 +185,13 @@ Please check the [Issue Tracker](http://www.qurl.nl/dynamic-widgets/issue-tracke
183
 
184
  == Changelog ==
185
 
 
 
 
 
 
 
 
186
  = Version 1.5.8 =
187
 
188
  * Renamed Mobile Device to Device for more expansion. WARNING: When you upgrade manually, remove the dynamic-widgets directory first!
4
  Tags: widget, widgets, dynamic, sidebar, custom, rules, logic, display, admin, condition, conditional tags, hide, show, wpml, qtranslate, wpec, buddypress, pods, bbpress
5
  Requires at least: 3.0.0
6
  Tested up to: 3.9.1
7
+ Stable tag: 1.5.9
8
 
9
  Dynamic Widgets gives you full control on which pages a widget will display. It lets you dynamicly show or hide widgets on WordPress pages.
10
 
30
  - Day of week
31
  - Weeknumbers
32
  - Browsers
33
+ - IP ranges
34
  - Devices (mobile, desktop)
35
  - Theme Templates
36
  - Languages (WPML or QTranslate)
60
  - Day of week on day
61
  - Weeknumer on number
62
  - Browsers on browser name
63
+ - IP on ranges
64
  - Devices on type
65
  - Theme Templates on template name
66
  - Languages (WPML or QTranslate) on language
185
 
186
  == Changelog ==
187
 
188
+ = Version 1.5.9 =
189
+
190
+ * Added support for IP range
191
+ * Bugfix for URL and Pages module does not show the green checkmark and not showing the settings made
192
+ * Bugfix for Single Post Catregory is saved wrong
193
+ * Bugfix for Strict warning notice in author_module.php at line 42
194
+
195
  = Version 1.5.8 =
196
 
197
  * Renamed Mobile Device to Device for more expansion. WARNING: When you upgrade manually, remove the dynamic-widgets directory first!