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 | Dynamic Widgets |
Version | 1.5.11 |
Comparing to | |
See all releases |
Code changes from version 1.5.10 to 1.5.11
- classes/dynwid_class.php +154 -14
- dynamic-widgets.php +28 -26
- dynwid_admin_edit.php +10 -5
- dynwid_admin_overview.php +3 -3
- dynwid_admin_save.php +33 -15
- dynwid_worker.php +32 -7
- mods/qt_module.php +1 -1
- mods/shortcode_module.php +69 -0
- readme.txt +8 -1
classes/dynwid_class.php
CHANGED
@@ -119,18 +119,38 @@
|
|
119 |
* @param array $dates Dates
|
120 |
*/
|
121 |
public function addDate($widget_id, $dates) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
$query = "INSERT INTO " . $this->dbtable . "
|
123 |
(widget_id, maintype, name, value)
|
124 |
VALUES
|
125 |
('" . $widget_id . "', 'date', 'default', '0')";
|
126 |
$this->wpdb->query($query);
|
|
|
127 |
|
128 |
foreach ( $dates as $name => $date ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
$query = "INSERT INTO " . $this->dbtable . "
|
130 |
(widget_id, maintype, name, value)
|
131 |
VALUES
|
132 |
('" . esc_sql($widget_id) . "', 'date', '" . esc_sql($name) . "', '" . esc_sql($date) . "')";
|
133 |
$this->wpdb->query($query);
|
|
|
134 |
}
|
135 |
}
|
136 |
|
@@ -143,19 +163,79 @@
|
|
143 |
*/
|
144 |
public function addIPs($widget_id, $default, $ips) {
|
145 |
$value = serialize($ips);
|
|
|
146 |
if ( $default == 'no' ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
$query = "INSERT INTO " . $this->dbtable . "
|
148 |
(widget_id, maintype, name, value)
|
149 |
VALUES
|
150 |
('" . esc_sql($widget_id) . "', 'ip', 'default', '0')";
|
151 |
$this->wpdb->query($query);
|
|
|
152 |
}
|
153 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
154 |
$query = "INSERT INTO " . $this->dbtable . "
|
155 |
(widget_id, maintype, name, value)
|
156 |
VALUES
|
157 |
('" . esc_sql($widget_id) . "', 'ip', 'ip', '" . $value . "')";
|
158 |
$this->wpdb->query($query);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
159 |
}
|
160 |
|
161 |
/**
|
@@ -168,18 +248,38 @@
|
|
168 |
public function addUrls($widget_id, $default, $urls) {
|
169 |
$value = serialize($urls);
|
170 |
if ( $default == 'no' ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
$query = "INSERT INTO " . $this->dbtable . "
|
172 |
(widget_id, maintype, name, value)
|
173 |
VALUES
|
174 |
('" . esc_sql($widget_id) . "', 'url', 'default', '0')";
|
175 |
$this->wpdb->query($query);
|
|
|
176 |
}
|
177 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
$query = "INSERT INTO " . $this->dbtable . "
|
179 |
(widget_id, maintype, name, value)
|
180 |
VALUES
|
181 |
('" . esc_sql($widget_id) . "', 'url', 'url', '" . $value . "')";
|
182 |
$this->wpdb->query($query);
|
|
|
183 |
}
|
184 |
|
185 |
/**
|
@@ -214,7 +314,8 @@
|
|
214 |
$post_types = array_merge( $types, array('single-post', 'single-tag') );
|
215 |
|
216 |
if ( in_array($maintype, $post_types) ) {
|
217 |
-
$query = "SELECT COUNT(1) AS total FROM " . $this->dbtable . " WHERE widget_id =
|
|
|
218 |
$count = $this->wpdb->get_var($query);
|
219 |
if ( $count > 0 ) {
|
220 |
$insert = FALSE;
|
@@ -222,18 +323,38 @@
|
|
222 |
}
|
223 |
|
224 |
if ( $insert ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
225 |
$query = "INSERT INTO " . $this->dbtable . "
|
226 |
(widget_id, maintype, name, value)
|
227 |
VALUES
|
228 |
('" . esc_sql($widget_id) . "', '" . esc_sql($maintype) . "', 'default', '" . esc_sql($opt_default) . "')";
|
229 |
$this->wpdb->query($query);
|
|
|
230 |
}
|
231 |
foreach ( $act as $option ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
232 |
$query = "INSERT INTO " . $this->dbtable . "
|
233 |
(widget_id, maintype, name, value)
|
234 |
VALUES
|
235 |
('" . esc_sql($widget_id) . "', '" . esc_sql($maintype) . "', '" . esc_sql($option) . "', '" . esc_sql($opt_act) . "')";
|
236 |
$this->wpdb->query($query);
|
|
|
237 |
}
|
238 |
}
|
239 |
|
@@ -245,11 +366,20 @@
|
|
245 |
* @param integer $value Default setting
|
246 |
*/
|
247 |
public function addSingleOption($widget_id, $maintype, $value = '0') {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
248 |
$query = "INSERT INTO " . $this->dbtable . "
|
249 |
(widget_id, maintype, value)
|
250 |
VALUES
|
251 |
('" . esc_sql($widget_id) . "', '" . esc_sql($maintype) . "', '" . esc_sql($value) . "')";
|
252 |
$this->wpdb->query($query);
|
|
|
253 |
}
|
254 |
|
255 |
/**
|
@@ -301,10 +431,14 @@
|
|
301 |
* @param string $name Name of option
|
302 |
*/
|
303 |
public function deleteOption($widget_id, $maintype, $name = '') {
|
304 |
-
$query = "DELETE FROM " . $this->dbtable . " WHERE widget_id =
|
305 |
if (! empty($name) ) {
|
306 |
-
$query .= " AND name =
|
|
|
|
|
|
|
307 |
}
|
|
|
308 |
$this->wpdb->query($query);
|
309 |
}
|
310 |
|
@@ -411,7 +545,7 @@
|
|
411 |
}
|
412 |
|
413 |
$query = "SELECT DISTINCT widget_id FROM " . $this->dbtable . "
|
414 |
-
WHERE maintype LIKE '" . $whereami . "%'";
|
415 |
|
416 |
if ( count($this->overrule_maintype) > 0 ) {
|
417 |
$query .= " OR maintype IN ";
|
@@ -470,8 +604,8 @@
|
|
470 |
}
|
471 |
|
472 |
$query = "SELECT widget_id, maintype, name, value FROM " . $this->dbtable . "
|
473 |
-
WHERE widget_id LIKE '" . $widget_id . "'
|
474 |
-
AND maintype LIKE '" . $maintype . "%'
|
475 |
ORDER BY maintype, name";
|
476 |
$results = new DWOpts($this->wpdb->get_results($query), $maintype);
|
477 |
return $results;
|
@@ -511,6 +645,7 @@
|
|
511 |
DWModule::registerOption(DW_QT::$option);
|
512 |
DWModule::registerOption(DW_Role::$option);
|
513 |
DWModule::registerOption(DW_Search::$option);
|
|
|
514 |
DWModule::registerOption(DW_Single::$option);
|
515 |
DWModule::registerOption(DW_Tag::$option);
|
516 |
DWModule::registerOption(DW_Tpl::$option);
|
@@ -568,8 +703,8 @@
|
|
568 |
|
569 |
if ( $admin ) {
|
570 |
$query = "SELECT widget_id, maintype, name, value FROM " . $this->dbtable . "
|
571 |
-
WHERE widget_id LIKE '" . $widget_id . "'
|
572 |
-
AND maintype LIKE '" . $maintype . "%'
|
573 |
ORDER BY maintype, name";
|
574 |
|
575 |
} else {
|
@@ -577,14 +712,14 @@
|
|
577 |
$maintype = 'page';
|
578 |
}
|
579 |
$query = "SELECT widget_id, maintype, name, value FROM " . $this->dbtable . "
|
580 |
-
WHERE widget_id LIKE '" . $widget_id . "'
|
581 |
-
AND (maintype LIKE '" . $maintype . "%'";
|
582 |
|
583 |
if ( count($this->overrule_maintype) > 0 ) {
|
584 |
$query .= " OR maintype IN (";
|
585 |
$q = array();
|
586 |
foreach ( $this->overrule_maintype as $omt ) {
|
587 |
-
$q[ ] = "'" . $omt . "'";
|
588 |
}
|
589 |
$query .= implode(', ', $q);
|
590 |
$query .= ")";
|
@@ -694,8 +829,9 @@
|
|
694 |
*/
|
695 |
public function hasOptions($widget_id) {
|
696 |
$query = "SELECT COUNT(1) AS total FROM " . $this->dbtable . "
|
697 |
-
WHERE widget_id =
|
698 |
-
maintype !=
|
|
|
699 |
$count = $this->wpdb->get_var($query);
|
700 |
|
701 |
if ( $count > 0 ) {
|
@@ -843,15 +979,18 @@
|
|
843 |
include_once(DW_MODULES . 'day_module.php');
|
844 |
include_once(DW_MODULES . 'week_module.php');
|
845 |
include_once(DW_MODULES . 'role_module.php');
|
|
|
846 |
include_once(DW_MODULES . 'tpl_module.php');
|
847 |
include_once(DW_MODULES . 'url_module.php');
|
848 |
include_once(DW_MODULES . 'device_module.php');
|
849 |
include_once(DW_MODULES . 'ip_module.php');
|
|
|
850 |
DW_Browser::checkOverrule('DW_Browser');
|
851 |
DW_Date::checkOverrule('DW_Date');
|
852 |
DW_Day::checkOverrule('DW_Day');
|
853 |
DW_Week::checkOverrule('DW_Week');
|
854 |
DW_Role::checkOverrule('DW_Role');
|
|
|
855 |
DW_Tpl::checkOverrule('DW_Tpl');
|
856 |
DW_URL::checkOverrule('DW_URL');
|
857 |
DW_URL::checkOverrule('DW_Device');
|
@@ -872,7 +1011,8 @@
|
|
872 |
* @param string $widget_id ID of the widget
|
873 |
*/
|
874 |
public function resetOptions($widget_id) {
|
875 |
-
$query = "DELETE FROM " . $this->dbtable . " WHERE widget_id =
|
|
|
876 |
$this->wpdb->query($query);
|
877 |
}
|
878 |
}
|
119 |
* @param array $dates Dates
|
120 |
*/
|
121 |
public function addDate($widget_id, $dates) {
|
122 |
+
$fields = array(
|
123 |
+
'widget_id' => $widget_id,
|
124 |
+
'maintype' => 'date',
|
125 |
+
'name' => 'default',
|
126 |
+
'value' => '0'
|
127 |
+
);
|
128 |
+
$this->wpdb->insert($this->dbtable, $fields);
|
129 |
+
|
130 |
+
/*
|
131 |
$query = "INSERT INTO " . $this->dbtable . "
|
132 |
(widget_id, maintype, name, value)
|
133 |
VALUES
|
134 |
('" . $widget_id . "', 'date', 'default', '0')";
|
135 |
$this->wpdb->query($query);
|
136 |
+
*/
|
137 |
|
138 |
foreach ( $dates as $name => $date ) {
|
139 |
+
$fields = array(
|
140 |
+
'widget_id' => $widget_id,
|
141 |
+
'maintype' => 'date',
|
142 |
+
'name' => $name,
|
143 |
+
'value' => $date
|
144 |
+
);
|
145 |
+
$this->wpdb->insert($this->dbtable, $fields);
|
146 |
+
|
147 |
+
/*
|
148 |
$query = "INSERT INTO " . $this->dbtable . "
|
149 |
(widget_id, maintype, name, value)
|
150 |
VALUES
|
151 |
('" . esc_sql($widget_id) . "', 'date', '" . esc_sql($name) . "', '" . esc_sql($date) . "')";
|
152 |
$this->wpdb->query($query);
|
153 |
+
*/
|
154 |
}
|
155 |
}
|
156 |
|
163 |
*/
|
164 |
public function addIPs($widget_id, $default, $ips) {
|
165 |
$value = serialize($ips);
|
166 |
+
|
167 |
if ( $default == 'no' ) {
|
168 |
+
$fields = array(
|
169 |
+
'widget_id' => $widget_id,
|
170 |
+
'maintype' => 'ip',
|
171 |
+
'name' => 'default',
|
172 |
+
'value' => '0'
|
173 |
+
);
|
174 |
+
$this->wpdb->insert($this->dbtable, $fields);
|
175 |
+
|
176 |
+
/*
|
177 |
$query = "INSERT INTO " . $this->dbtable . "
|
178 |
(widget_id, maintype, name, value)
|
179 |
VALUES
|
180 |
('" . esc_sql($widget_id) . "', 'ip', 'default', '0')";
|
181 |
$this->wpdb->query($query);
|
182 |
+
*/
|
183 |
}
|
184 |
|
185 |
+
$fields = array(
|
186 |
+
'widget_id' => $widget_id,
|
187 |
+
'maintype' => 'ip',
|
188 |
+
'name' => 'ip',
|
189 |
+
'value' => $value
|
190 |
+
);
|
191 |
+
$this->wpdb->insert($this->dbtable, $fields);
|
192 |
+
|
193 |
+
/*
|
194 |
$query = "INSERT INTO " . $this->dbtable . "
|
195 |
(widget_id, maintype, name, value)
|
196 |
VALUES
|
197 |
('" . esc_sql($widget_id) . "', 'ip', 'ip', '" . $value . "')";
|
198 |
$this->wpdb->query($query);
|
199 |
+
*/
|
200 |
+
}
|
201 |
+
|
202 |
+
public function addShortcode($widget_id, $default, $value, $match, $operator) {
|
203 |
+
$value = array( 'value' => $value, 'match' => $match, 'operator' => $operator );
|
204 |
+
$value = serialize($value);
|
205 |
+
|
206 |
+
if ( $default == 'no' ) {
|
207 |
+
$fields = array(
|
208 |
+
'widget_id' => $widget_id,
|
209 |
+
'maintype' => 'shortcode',
|
210 |
+
'name' => 'default',
|
211 |
+
'value' => '0'
|
212 |
+
);
|
213 |
+
$this->wpdb->insert($this->dbtable, $fields);
|
214 |
+
|
215 |
+
/*
|
216 |
+
$query = "INSERT INTO " . $this->dbtable . "
|
217 |
+
(widget_id, maintype, name, value)
|
218 |
+
VALUES
|
219 |
+
('" . esc_sql($widget_id) . "', 'shortcode', 'default', '0')";
|
220 |
+
$this->wpdb->query($query);
|
221 |
+
*/
|
222 |
+
}
|
223 |
+
|
224 |
+
$fields = array(
|
225 |
+
'widget_id' => $widget_id,
|
226 |
+
'maintype' => 'shortcode',
|
227 |
+
'name' => 'shortcode',
|
228 |
+
'value' => $value
|
229 |
+
);
|
230 |
+
$this->wpdb->insert($this->dbtable, $fields);
|
231 |
+
|
232 |
+
/*
|
233 |
+
$query = "INSERT INTO " . $this->dbtable . "
|
234 |
+
(widget_id, maintype, name, value)
|
235 |
+
VALUES
|
236 |
+
('" . esc_sql($widget_id) . "', 'shortcode', 'shortcode', '" . $value . "')";
|
237 |
+
$this->wpdb->query($query);
|
238 |
+
*/
|
239 |
}
|
240 |
|
241 |
/**
|
248 |
public function addUrls($widget_id, $default, $urls) {
|
249 |
$value = serialize($urls);
|
250 |
if ( $default == 'no' ) {
|
251 |
+
$fields = array(
|
252 |
+
'widget_id' => $widget_id,
|
253 |
+
'maintype' => 'url',
|
254 |
+
'name' => 'default',
|
255 |
+
'value' => '0'
|
256 |
+
);
|
257 |
+
$this->wpdb->insert($this->dbtable, $fields);
|
258 |
+
|
259 |
+
/*
|
260 |
$query = "INSERT INTO " . $this->dbtable . "
|
261 |
(widget_id, maintype, name, value)
|
262 |
VALUES
|
263 |
('" . esc_sql($widget_id) . "', 'url', 'default', '0')";
|
264 |
$this->wpdb->query($query);
|
265 |
+
*/
|
266 |
}
|
267 |
|
268 |
+
$fields = array(
|
269 |
+
'widget_id' => $widget_id,
|
270 |
+
'maintype' => 'url',
|
271 |
+
'name' => 'url',
|
272 |
+
'value' => $value
|
273 |
+
);
|
274 |
+
$this->wpdb->insert($this->dbtable, $fields);
|
275 |
+
|
276 |
+
/*
|
277 |
$query = "INSERT INTO " . $this->dbtable . "
|
278 |
(widget_id, maintype, name, value)
|
279 |
VALUES
|
280 |
('" . esc_sql($widget_id) . "', 'url', 'url', '" . $value . "')";
|
281 |
$this->wpdb->query($query);
|
282 |
+
*/
|
283 |
}
|
284 |
|
285 |
/**
|
314 |
$post_types = array_merge( $types, array('single-post', 'single-tag') );
|
315 |
|
316 |
if ( in_array($maintype, $post_types) ) {
|
317 |
+
$query = "SELECT COUNT(1) AS total FROM " . $this->dbtable . " WHERE widget_id = %s AND maintype = %s AND name = %s";
|
318 |
+
$query = $this->wpdb->prepare($query, $widget_id, $maintype, 'default');
|
319 |
$count = $this->wpdb->get_var($query);
|
320 |
if ( $count > 0 ) {
|
321 |
$insert = FALSE;
|
323 |
}
|
324 |
|
325 |
if ( $insert ) {
|
326 |
+
$fields = array(
|
327 |
+
'widget_id' => $widget_id,
|
328 |
+
'maintype' => $maintype,
|
329 |
+
'name' => 'default',
|
330 |
+
'value' => $opt_default
|
331 |
+
);
|
332 |
+
$this->wpdb->insert($this->dbtable, $fields);
|
333 |
+
|
334 |
+
/*
|
335 |
$query = "INSERT INTO " . $this->dbtable . "
|
336 |
(widget_id, maintype, name, value)
|
337 |
VALUES
|
338 |
('" . esc_sql($widget_id) . "', '" . esc_sql($maintype) . "', 'default', '" . esc_sql($opt_default) . "')";
|
339 |
$this->wpdb->query($query);
|
340 |
+
*/
|
341 |
}
|
342 |
foreach ( $act as $option ) {
|
343 |
+
$fields = array(
|
344 |
+
'widget_id' => $widget_id,
|
345 |
+
'maintype' => $maintype,
|
346 |
+
'name' => $option,
|
347 |
+
'value' => $opt_act
|
348 |
+
);
|
349 |
+
$this->wpdb->insert($this->dbtable, $fields);
|
350 |
+
|
351 |
+
/*
|
352 |
$query = "INSERT INTO " . $this->dbtable . "
|
353 |
(widget_id, maintype, name, value)
|
354 |
VALUES
|
355 |
('" . esc_sql($widget_id) . "', '" . esc_sql($maintype) . "', '" . esc_sql($option) . "', '" . esc_sql($opt_act) . "')";
|
356 |
$this->wpdb->query($query);
|
357 |
+
*/
|
358 |
}
|
359 |
}
|
360 |
|
366 |
* @param integer $value Default setting
|
367 |
*/
|
368 |
public function addSingleOption($widget_id, $maintype, $value = '0') {
|
369 |
+
$fields = array(
|
370 |
+
'widget_id' => $widget_id,
|
371 |
+
'maintype' => $maintype,
|
372 |
+
'value' => $value
|
373 |
+
);
|
374 |
+
$this->wpdb->insert($this->dbtable, $fields);
|
375 |
+
|
376 |
+
/*
|
377 |
$query = "INSERT INTO " . $this->dbtable . "
|
378 |
(widget_id, maintype, value)
|
379 |
VALUES
|
380 |
('" . esc_sql($widget_id) . "', '" . esc_sql($maintype) . "', '" . esc_sql($value) . "')";
|
381 |
$this->wpdb->query($query);
|
382 |
+
*/
|
383 |
}
|
384 |
|
385 |
/**
|
431 |
* @param string $name Name of option
|
432 |
*/
|
433 |
public function deleteOption($widget_id, $maintype, $name = '') {
|
434 |
+
$query = "DELETE FROM " . $this->dbtable . " WHERE widget_id = %s AND maintype = %s";
|
435 |
if (! empty($name) ) {
|
436 |
+
$query .= " AND name = %s";
|
437 |
+
$query = $this->wpdb->prepare($query, $widget_id, $maintype, $name);
|
438 |
+
} else {
|
439 |
+
$query = $this->wpdb->prepare($query, $widget_id, $maintype);
|
440 |
}
|
441 |
+
|
442 |
$this->wpdb->query($query);
|
443 |
}
|
444 |
|
545 |
}
|
546 |
|
547 |
$query = "SELECT DISTINCT widget_id FROM " . $this->dbtable . "
|
548 |
+
WHERE maintype LIKE '" . esc_sql($whereami) . "%'";
|
549 |
|
550 |
if ( count($this->overrule_maintype) > 0 ) {
|
551 |
$query .= " OR maintype IN ";
|
604 |
}
|
605 |
|
606 |
$query = "SELECT widget_id, maintype, name, value FROM " . $this->dbtable . "
|
607 |
+
WHERE widget_id LIKE '" . esc_sql($widget_id) . "'
|
608 |
+
AND maintype LIKE '" . esc_sql($maintype) . "%'
|
609 |
ORDER BY maintype, name";
|
610 |
$results = new DWOpts($this->wpdb->get_results($query), $maintype);
|
611 |
return $results;
|
645 |
DWModule::registerOption(DW_QT::$option);
|
646 |
DWModule::registerOption(DW_Role::$option);
|
647 |
DWModule::registerOption(DW_Search::$option);
|
648 |
+
DWModule::registerOption(DW_Shortcode::$option);
|
649 |
DWModule::registerOption(DW_Single::$option);
|
650 |
DWModule::registerOption(DW_Tag::$option);
|
651 |
DWModule::registerOption(DW_Tpl::$option);
|
703 |
|
704 |
if ( $admin ) {
|
705 |
$query = "SELECT widget_id, maintype, name, value FROM " . $this->dbtable . "
|
706 |
+
WHERE widget_id LIKE '" . esc_sql($widget_id) . "'
|
707 |
+
AND maintype LIKE '" . esc_sql($maintype) . "%'
|
708 |
ORDER BY maintype, name";
|
709 |
|
710 |
} else {
|
712 |
$maintype = 'page';
|
713 |
}
|
714 |
$query = "SELECT widget_id, maintype, name, value FROM " . $this->dbtable . "
|
715 |
+
WHERE widget_id LIKE '" . esc_sql($widget_id) . "'
|
716 |
+
AND (maintype LIKE '" . esc_sql($maintype) . "%'";
|
717 |
|
718 |
if ( count($this->overrule_maintype) > 0 ) {
|
719 |
$query .= " OR maintype IN (";
|
720 |
$q = array();
|
721 |
foreach ( $this->overrule_maintype as $omt ) {
|
722 |
+
$q[ ] = "'" . esc_sql($omt) . "'";
|
723 |
}
|
724 |
$query .= implode(', ', $q);
|
725 |
$query .= ")";
|
829 |
*/
|
830 |
public function hasOptions($widget_id) {
|
831 |
$query = "SELECT COUNT(1) AS total FROM " . $this->dbtable . "
|
832 |
+
WHERE widget_id = %s AND
|
833 |
+
maintype != %s";
|
834 |
+
$query = $this->wpdb->prepare($query, $widget_id, 'individual');
|
835 |
$count = $this->wpdb->get_var($query);
|
836 |
|
837 |
if ( $count > 0 ) {
|
979 |
include_once(DW_MODULES . 'day_module.php');
|
980 |
include_once(DW_MODULES . 'week_module.php');
|
981 |
include_once(DW_MODULES . 'role_module.php');
|
982 |
+
include_once(DW_MODULES . 'shortcode_module.php');
|
983 |
include_once(DW_MODULES . 'tpl_module.php');
|
984 |
include_once(DW_MODULES . 'url_module.php');
|
985 |
include_once(DW_MODULES . 'device_module.php');
|
986 |
include_once(DW_MODULES . 'ip_module.php');
|
987 |
+
|
988 |
DW_Browser::checkOverrule('DW_Browser');
|
989 |
DW_Date::checkOverrule('DW_Date');
|
990 |
DW_Day::checkOverrule('DW_Day');
|
991 |
DW_Week::checkOverrule('DW_Week');
|
992 |
DW_Role::checkOverrule('DW_Role');
|
993 |
+
DW_Shortcode::checkOverrule('DW_Shortcode');
|
994 |
DW_Tpl::checkOverrule('DW_Tpl');
|
995 |
DW_URL::checkOverrule('DW_URL');
|
996 |
DW_URL::checkOverrule('DW_Device');
|
1011 |
* @param string $widget_id ID of the widget
|
1012 |
*/
|
1013 |
public function resetOptions($widget_id) {
|
1014 |
+
$query = "DELETE FROM " . $this->dbtable . " WHERE widget_id = %s";
|
1015 |
+
$query = $this->wpdb->prepare($query, $widget_id);
|
1016 |
$this->wpdb->query($query);
|
1017 |
}
|
1018 |
}
|
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 |
* 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,8 +15,8 @@
|
|
15 |
*
|
16 |
* Released under the GPL v.2, http://www.gnu.org/copyleft/gpl.html
|
17 |
*
|
18 |
-
* @version $Id: dynamic-widgets.php
|
19 |
-
* @copyright
|
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.
|
22 |
* Thanks to Daniel Bihler for the contribution of the German (de_DE) language files.
|
@@ -33,6 +33,8 @@
|
|
33 |
* Thanks to Advancis (http://advancis.net/) for the help and financial contribution to find and fix a WPML category bug.
|
34 |
* Thanks to Borisa Djuraskovic for the contribution of the Serbo-Croatian (sr_RS) languages files.
|
35 |
* Thanks to Leon Juranic from DefenseCode to run it's scanner over the source code and finding a few vulnerabilities.
|
|
|
|
|
36 |
*
|
37 |
*
|
38 |
* WPML Plugin support via API
|
@@ -64,31 +66,31 @@
|
|
64 |
|
65 |
defined('ABSPATH') or die("No script kiddies please!");
|
66 |
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
define('DW_WPML_API', '/inc/wpml-api.php'); // WPML Plugin support - API file relative to ICL_PLUGIN_PATH
|
84 |
define('DW_WPML_ICON', 'img/wpml_icon.png'); // WPML Plugin support - WPML icon
|
85 |
|
86 |
// Classes - only PHP5
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
|
91 |
-
|
92 |
/**
|
93 |
* dynwid_activate() Activate the plugin
|
94 |
* @since 1.3.3
|
@@ -178,9 +180,9 @@
|
|
178 |
*/
|
179 |
function dynwid_add_admin_custom_box() {
|
180 |
$args = array(
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
|
185 |
$post_types = get_post_types($args, 'objects', 'and');
|
186 |
foreach ( array_keys($post_types) as $type ) {
|
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.11
|
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 1218814 2015-08-12 06:37:21Z qurl $
|
19 |
+
* @copyright 2015 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.
|
22 |
* Thanks to Daniel Bihler for the contribution of the German (de_DE) language files.
|
33 |
* Thanks to Advancis (http://advancis.net/) for the help and financial contribution to find and fix a WPML category bug.
|
34 |
* Thanks to Borisa Djuraskovic for the contribution of the Serbo-Croatian (sr_RS) languages files.
|
35 |
* Thanks to Leon Juranic from DefenseCode to run it's scanner over the source code and finding a few vulnerabilities.
|
36 |
+
* Thanks to Nathan Wright of NW Consulting for the financial contribution to implement the shortcode filter feature.
|
37 |
+
* Thanks to Mike Epstein to find a vulnerability in the DW settings.
|
38 |
*
|
39 |
*
|
40 |
* WPML Plugin support via API
|
66 |
|
67 |
defined('ABSPATH') or die("No script kiddies please!");
|
68 |
|
69 |
+
// Constants
|
70 |
+
define('DW_CLASSES', dirname(__FILE__) . '/' . 'classes/');
|
71 |
+
define('DW_DEBUG', FALSE);
|
72 |
+
define('DW_DB_TABLE', 'dynamic_widgets');
|
73 |
+
define('DW_L10N_DOMAIN', 'dynamic-widgets');
|
74 |
+
define('DW_LIST_LIMIT', 20);
|
75 |
+
define('DW_LIST_STYLE', 'style="overflow:auto;height:240px;"');
|
76 |
+
define('DW_OLD_METHOD', get_option('dynwid_old_method'));
|
77 |
+
define('DW_PAGE_LIMIT', get_option('dynwid_page_limit', 500));
|
78 |
+
define('DW_MINIMUM_PHP', '5.2.7');
|
79 |
+
define('DW_MINIMUM_WP', '3.0');
|
80 |
+
define('DW_MODULES', dirname(__FILE__) . '/' . 'mods/');
|
81 |
+
define('DW_PLUGIN', dirname(__FILE__) . '/' . 'plugin/');
|
82 |
+
define('DW_TIME_LIMIT', 86400); // 1 day
|
83 |
+
define('DW_URL_AUTHOR', 'http://www.qurl.nl');
|
84 |
+
define('DW_VERSION', '1.5.11');
|
85 |
define('DW_WPML_API', '/inc/wpml-api.php'); // WPML Plugin support - API file relative to ICL_PLUGIN_PATH
|
86 |
define('DW_WPML_ICON', 'img/wpml_icon.png'); // WPML Plugin support - WPML icon
|
87 |
|
88 |
// Classes - only PHP5
|
89 |
+
if ( version_compare(PHP_VERSION, DW_MINIMUM_PHP, '>=') ) {
|
90 |
+
require_once(dirname(__FILE__) . '/dynwid_class.php');
|
91 |
+
}
|
92 |
|
93 |
+
// Functions
|
94 |
/**
|
95 |
* dynwid_activate() Activate the plugin
|
96 |
* @since 1.3.3
|
180 |
*/
|
181 |
function dynwid_add_admin_custom_box() {
|
182 |
$args = array(
|
183 |
+
'public' => TRUE,
|
184 |
+
'_builtin' => FALSE
|
185 |
+
);
|
186 |
|
187 |
$post_types = get_post_types($args, 'objects', 'and');
|
188 |
foreach ( array_keys($post_types) as $type ) {
|
dynwid_admin_edit.php
CHANGED
@@ -2,10 +2,10 @@
|
|
2 |
/**
|
3 |
* dynwid_admin_edit.php - Options settings
|
4 |
*
|
5 |
-
* @version $Id: dynwid_admin_edit.php
|
6 |
* @copyright 2011 Jacco Drabbe
|
7 |
*/
|
8 |
-
|
9 |
defined('ABSPATH') or die("No script kiddies please!");
|
10 |
|
11 |
// Plugins support
|
@@ -381,16 +381,16 @@ div.settingbox {
|
|
381 |
$DW_Browser = new DW_Browser();
|
382 |
$DW_Browser->admin();
|
383 |
}
|
384 |
-
|
385 |
if ( array_key_exists('ip', $DW->dwoptions) ) {
|
386 |
$DW_IP = new DW_IP();
|
387 |
$DW_IP->admin();
|
388 |
-
}
|
389 |
|
390 |
if ( array_key_exists('device', $DW->dwoptions) ) {
|
391 |
$DW_Device = new DW_Device();
|
392 |
$DW_Device->admin();
|
393 |
-
}
|
394 |
|
395 |
if ( array_key_exists('tpl', $DW->dwoptions) ) {
|
396 |
$DW_Tpl = new DW_Tpl();
|
@@ -402,6 +402,11 @@ div.settingbox {
|
|
402 |
$DW_URL->admin();
|
403 |
}
|
404 |
|
|
|
|
|
|
|
|
|
|
|
405 |
if ( array_key_exists('front-page', $DW->dwoptions) ) {
|
406 |
$DW_Front_page = new DW_Front_page();
|
407 |
$DW_Front_page->admin();
|
2 |
/**
|
3 |
* dynwid_admin_edit.php - Options settings
|
4 |
*
|
5 |
+
* @version $Id: dynwid_admin_edit.php 1218814 2015-08-12 06:37:21Z qurl $
|
6 |
* @copyright 2011 Jacco Drabbe
|
7 |
*/
|
8 |
+
|
9 |
defined('ABSPATH') or die("No script kiddies please!");
|
10 |
|
11 |
// Plugins support
|
381 |
$DW_Browser = new DW_Browser();
|
382 |
$DW_Browser->admin();
|
383 |
}
|
384 |
+
|
385 |
if ( array_key_exists('ip', $DW->dwoptions) ) {
|
386 |
$DW_IP = new DW_IP();
|
387 |
$DW_IP->admin();
|
388 |
+
}
|
389 |
|
390 |
if ( array_key_exists('device', $DW->dwoptions) ) {
|
391 |
$DW_Device = new DW_Device();
|
392 |
$DW_Device->admin();
|
393 |
+
}
|
394 |
|
395 |
if ( array_key_exists('tpl', $DW->dwoptions) ) {
|
396 |
$DW_Tpl = new DW_Tpl();
|
402 |
$DW_URL->admin();
|
403 |
}
|
404 |
|
405 |
+
if ( array_key_exists('shortcode', $DW->dwoptions) ) {
|
406 |
+
$DW_URL = new DW_Shortcode();
|
407 |
+
$DW_URL->admin();
|
408 |
+
}
|
409 |
+
|
410 |
if ( array_key_exists('front-page', $DW->dwoptions) ) {
|
411 |
$DW_Front_page = new DW_Front_page();
|
412 |
$DW_Front_page->admin();
|
dynwid_admin_overview.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* dynwid_admin_overview.php - Overview page
|
4 |
*
|
5 |
-
* @version $Id: dynwid_admin_overview.php
|
6 |
* @copyright 2011 Jacco Drabbe
|
7 |
*/
|
8 |
|
@@ -133,7 +133,7 @@
|
|
133 |
<form id="dynwid_method" action="" method="get">
|
134 |
<input type="hidden" name="page" value="dynwid-config" />
|
135 |
<input type="hidden" name="action" value="dynwid_set_method" />
|
136 |
-
<input type="checkbox" id="oldmethod" name="oldmethod" <?php echo ( get_option('dynwid_old_method') ? 'checked="checked"' : '' ) ?> onchange="jQuery('#dynwid_method').submit();" /> <label for="oldmethod"><?php _e('Use \'OLD\' method', DW_L10N_DOMAIN); ?></label>
|
137 |
</form>
|
138 |
</div>
|
139 |
<br />
|
@@ -143,7 +143,7 @@
|
|
143 |
<form action="" method="get">
|
144 |
<input type="hidden" name="page" value="dynwid-config" />
|
145 |
<input type="hidden" name="action" value="dynwid_set_page_limit" />
|
146 |
-
<b><?php _e('Page limit', DW_L10N_DOMAIN) ?></b>: <input type="text" name="page_limit" value="<?php echo ( isset($_GET['page_limit']) ) ? $_GET['page_limit'] : DW_PAGE_LIMIT; ?>" style="width:50px" maxlength="4" /> <input class="button-primary" type="submit" value="<?php _e('Save'); ?>" />
|
147 |
<br />
|
148 |
<?php _e('The page limit sets the limit of number of pages to prevent a timeout when building the hierarchical tree. When the number of pages is above this limit, a flat list will be displayed which is less time consuming.', DW_L10N_DOMAIN); ?>
|
149 |
<br />
|
2 |
/**
|
3 |
* dynwid_admin_overview.php - Overview page
|
4 |
*
|
5 |
+
* @version $Id: dynwid_admin_overview.php 1218814 2015-08-12 06:37:21Z qurl $
|
6 |
* @copyright 2011 Jacco Drabbe
|
7 |
*/
|
8 |
|
133 |
<form id="dynwid_method" action="" method="get">
|
134 |
<input type="hidden" name="page" value="dynwid-config" />
|
135 |
<input type="hidden" name="action" value="dynwid_set_method" />
|
136 |
+
<input type="checkbox" id="oldmethod" name="oldmethod" <?php echo ( get_option('dynwid_old_method') ? 'checked="checked"' : '' ); ?> onchange="jQuery('#dynwid_method').submit();" /> <label for="oldmethod"><?php _e('Use \'OLD\' method', DW_L10N_DOMAIN); ?></label>
|
137 |
</form>
|
138 |
</div>
|
139 |
<br />
|
143 |
<form action="" method="get">
|
144 |
<input type="hidden" name="page" value="dynwid-config" />
|
145 |
<input type="hidden" name="action" value="dynwid_set_page_limit" />
|
146 |
+
<b><?php _e('Page limit', DW_L10N_DOMAIN) ?></b>: <input type="text" name="page_limit" value="<?php echo ( isset($_GET['page_limit']) ) ? intval( sanitize_text_field($_GET['page_limit']) ) : DW_PAGE_LIMIT; ?>" style="width:50px" maxlength="4" /> <input class="button-primary" type="submit" value="<?php _e('Save'); ?>" />
|
147 |
<br />
|
148 |
<?php _e('The page limit sets the limit of number of pages to prevent a timeout when building the hierarchical tree. When the number of pages is above this limit, a flat list will be displayed which is less time consuming.', DW_L10N_DOMAIN); ?>
|
149 |
<br />
|
dynwid_admin_save.php
CHANGED
@@ -2,10 +2,10 @@
|
|
2 |
/**
|
3 |
* dynwid_admin_save.php - Saving options to the database
|
4 |
*
|
5 |
-
* @version $Id: dynwid_admin_save.php
|
6 |
* @copyright 2011 Jacco Drabbe
|
7 |
*/
|
8 |
-
|
9 |
defined('ABSPATH') or die("No script kiddies please!");
|
10 |
|
11 |
// Security - nonce, etc.
|
@@ -70,44 +70,44 @@
|
|
70 |
wp_redirect( $_SERVER['REQUEST_URI'] . '&work=none' );
|
71 |
die();
|
72 |
}
|
73 |
-
|
74 |
// IP
|
75 |
if ( $_POST['ip'] == 'no' && empty($_POST['ip_value']) ) {
|
76 |
wp_redirect( $_SERVER['REQUEST_URI'] . '&work=none' );
|
77 |
die();
|
78 |
-
}
|
79 |
|
80 |
// Removing already set options, but keeping individual rules
|
81 |
$dbtable = $GLOBALS['wpdb']->prefix . DW_DB_TABLE;
|
82 |
$query = "SELECT COUNT(1) AS total FROM " . $dbtable . " WHERE widget_id = '" . $widget_id . "' AND maintype = 'individual'";
|
83 |
$count = $GLOBALS['wpdb']->get_var($query);
|
84 |
-
|
85 |
if ( $count > 0 && isset($_POST['individual']) && $_POST['individual'] == '1' ) {
|
86 |
$post_types = ( is_array($_POST['post_types']) ) ? $_POST['post_types'] : array();
|
87 |
$post_types = array_merge( array('single_post', 'single_tag'), $post_types );
|
88 |
-
|
89 |
foreach ( $post_types as $t ) {
|
90 |
$maintype = (! preg_match('/^single/', $t) ) ? $t . '-post' : $t;
|
91 |
-
|
92 |
$query = "SELECT name FROM " . $dbtable . " WHERE widget_id = '" . $widget_id . "' AND maintype = '" . $maintype . "'";
|
93 |
$results = $GLOBALS['wpdb']->get_results($query);
|
94 |
-
|
95 |
foreach ( $results as $row ) {
|
96 |
if ( is_numeric($row->name) ) {
|
97 |
$a = $maintype . '_act';
|
98 |
-
|
99 |
if (! is_array($_POST[$a]) ) {
|
100 |
$_POST[$a] = array();
|
101 |
}
|
102 |
-
|
103 |
$_POST[$a][ ] = $row->name;
|
104 |
}
|
105 |
}
|
106 |
|
107 |
}
|
108 |
-
|
109 |
}
|
110 |
-
|
111 |
$DW->resetOptions($widget_id);
|
112 |
|
113 |
// Role
|
@@ -136,7 +136,7 @@
|
|
136 |
|
137 |
// Browser
|
138 |
DWModule::save('browser', 'complex');
|
139 |
-
|
140 |
// Device
|
141 |
DWModule::save('device', 'complex');
|
142 |
|
@@ -162,7 +162,7 @@
|
|
162 |
$DW->addUrls($widget_id, $_POST['url'], $urls);
|
163 |
}
|
164 |
}
|
165 |
-
|
166 |
// IP
|
167 |
if (! empty($_POST['ip_value']) ) {
|
168 |
$ips = array();
|
@@ -181,7 +181,25 @@
|
|
181 |
if ( count($ips) > 0 ) {
|
182 |
$DW->addIPs($widget_id, $_POST['ip'], $ips);
|
183 |
}
|
184 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
185 |
|
186 |
// Front Page
|
187 |
DWModule::save('front-page', 'complex');
|
2 |
/**
|
3 |
* dynwid_admin_save.php - Saving options to the database
|
4 |
*
|
5 |
+
* @version $Id: dynwid_admin_save.php 1218814 2015-08-12 06:37:21Z qurl $
|
6 |
* @copyright 2011 Jacco Drabbe
|
7 |
*/
|
8 |
+
|
9 |
defined('ABSPATH') or die("No script kiddies please!");
|
10 |
|
11 |
// Security - nonce, etc.
|
70 |
wp_redirect( $_SERVER['REQUEST_URI'] . '&work=none' );
|
71 |
die();
|
72 |
}
|
73 |
+
|
74 |
// IP
|
75 |
if ( $_POST['ip'] == 'no' && empty($_POST['ip_value']) ) {
|
76 |
wp_redirect( $_SERVER['REQUEST_URI'] . '&work=none' );
|
77 |
die();
|
78 |
+
}
|
79 |
|
80 |
// Removing already set options, but keeping individual rules
|
81 |
$dbtable = $GLOBALS['wpdb']->prefix . DW_DB_TABLE;
|
82 |
$query = "SELECT COUNT(1) AS total FROM " . $dbtable . " WHERE widget_id = '" . $widget_id . "' AND maintype = 'individual'";
|
83 |
$count = $GLOBALS['wpdb']->get_var($query);
|
84 |
+
|
85 |
if ( $count > 0 && isset($_POST['individual']) && $_POST['individual'] == '1' ) {
|
86 |
$post_types = ( is_array($_POST['post_types']) ) ? $_POST['post_types'] : array();
|
87 |
$post_types = array_merge( array('single_post', 'single_tag'), $post_types );
|
88 |
+
|
89 |
foreach ( $post_types as $t ) {
|
90 |
$maintype = (! preg_match('/^single/', $t) ) ? $t . '-post' : $t;
|
91 |
+
|
92 |
$query = "SELECT name FROM " . $dbtable . " WHERE widget_id = '" . $widget_id . "' AND maintype = '" . $maintype . "'";
|
93 |
$results = $GLOBALS['wpdb']->get_results($query);
|
94 |
+
|
95 |
foreach ( $results as $row ) {
|
96 |
if ( is_numeric($row->name) ) {
|
97 |
$a = $maintype . '_act';
|
98 |
+
|
99 |
if (! is_array($_POST[$a]) ) {
|
100 |
$_POST[$a] = array();
|
101 |
}
|
102 |
+
|
103 |
$_POST[$a][ ] = $row->name;
|
104 |
}
|
105 |
}
|
106 |
|
107 |
}
|
108 |
+
|
109 |
}
|
110 |
+
|
111 |
$DW->resetOptions($widget_id);
|
112 |
|
113 |
// Role
|
136 |
|
137 |
// Browser
|
138 |
DWModule::save('browser', 'complex');
|
139 |
+
|
140 |
// Device
|
141 |
DWModule::save('device', 'complex');
|
142 |
|
162 |
$DW->addUrls($widget_id, $_POST['url'], $urls);
|
163 |
}
|
164 |
}
|
165 |
+
|
166 |
// IP
|
167 |
if (! empty($_POST['ip_value']) ) {
|
168 |
$ips = array();
|
181 |
if ( count($ips) > 0 ) {
|
182 |
$DW->addIPs($widget_id, $_POST['ip'], $ips);
|
183 |
}
|
184 |
+
}
|
185 |
+
|
186 |
+
// Shortcode
|
187 |
+
if (! empty($_POST['shortcode_value']) ) {
|
188 |
+
$value = sanitize_text_field($_POST['shortcode_value']);
|
189 |
+
if (! empty($value) && substr($value, 0, 1) !== '[' && substr($value, strlen($value)-1) !== ']' ) {
|
190 |
+
$value = '[' . $value . ']';
|
191 |
+
}
|
192 |
+
|
193 |
+
$match = sanitize_text_field($_POST['shortcode_match']);
|
194 |
+
$operator = $_POST['shortcode_operator'];
|
195 |
+
if (! in_array($operator, array('=', '!=')) ) {
|
196 |
+
$operator = '=';
|
197 |
+
}
|
198 |
+
|
199 |
+
if (! empty($value) ) {
|
200 |
+
$DW->addShortcode($widget_id, $_POST['shortcode'], $value, $match, $operator);
|
201 |
+
}
|
202 |
+
}
|
203 |
|
204 |
// Front Page
|
205 |
DWModule::save('front-page', 'complex');
|
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
|
6 |
* @copyright 2011 Jacco Drabbe
|
7 |
*/
|
8 |
|
@@ -227,12 +227,31 @@
|
|
227 |
$other_ip = ( $ip ) ? FALSE : TRUE;
|
228 |
|
229 |
foreach ( $ips as $range ) {
|
230 |
-
|
231 |
-
|
232 |
-
|
|
|
233 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
234 |
}
|
235 |
-
}
|
236 |
}
|
237 |
|
238 |
if ( isset($browser_tmp) && $browser_tmp != $browser ) {
|
@@ -277,6 +296,12 @@
|
|
277 |
}
|
278 |
unset($ip_tmp, $other_ip);
|
279 |
|
|
|
|
|
|
|
|
|
|
|
|
|
280 |
// For debug messages
|
281 |
$e = ( isset($other) && $other ) ? 'TRUE' : 'FALSE';
|
282 |
|
@@ -494,7 +519,7 @@
|
|
494 |
$DW->message('Exception triggered for ' . $widget_id . ' sets display to ' . $e . ' (rule ES4)');
|
495 |
}
|
496 |
}
|
497 |
-
|
498 |
/* Posts */
|
499 |
if ( count($act_post) > 0 ) {
|
500 |
if ( in_array($post->ID, $act_post) ) {
|
@@ -613,7 +638,7 @@
|
|
613 |
$DW->message('Exception triggered for ' . $widget_id . ' sets display to ' . $e . ' (rule EP1)');
|
614 |
} else if ( count($act_childs) > 0 ) {
|
615 |
$parents = $DW->getParents('page', array(), $id);
|
616 |
-
|
617 |
if ( (bool) array_intersect($act_childs, $parents) ) {
|
618 |
$display = $other;
|
619 |
$DW->message('Exception triggered for ' . $widget_id . ' sets display to ' . $e . ' (rule EP2)');
|
2 |
/**
|
3 |
* dynwid_worker.php - The worker does the actual work.
|
4 |
*
|
5 |
+
* @version $Id: dynwid_worker.php 1218814 2015-08-12 06:37:21Z qurl $
|
6 |
* @copyright 2011 Jacco Drabbe
|
7 |
*/
|
8 |
|
227 |
$other_ip = ( $ip ) ? FALSE : TRUE;
|
228 |
|
229 |
foreach ( $ips as $range ) {
|
230 |
+
if ( $DW->IPinRange($DW->ip_address, $range) ) {
|
231 |
+
$ip_tmp = $other_ip;
|
232 |
+
break;
|
233 |
+
}
|
234 |
}
|
235 |
+
} else if ( $condition->maintype == 'shortcode' && $condition->name == 'shortcode' ) {
|
236 |
+
$shortcode_match = unserialize($condition->value);
|
237 |
+
$other_shortcode = ( $shortcode ) ? FALSE : TRUE;
|
238 |
+
|
239 |
+
$return = do_shortcode( $shortcode_match['value'] );
|
240 |
+
|
241 |
+
switch ( $shortcode_match['operator'] ) {
|
242 |
+
case '!=':
|
243 |
+
if ( $return != $shortcode_match['match'] ) {
|
244 |
+
$shortcode_tmp = $other_shortcode;
|
245 |
+
}
|
246 |
+
break;
|
247 |
+
|
248 |
+
default:
|
249 |
+
if ( $return == $shortcode_match['match'] ) {
|
250 |
+
$shortcode_tmp = $other_shortcode;
|
251 |
+
}
|
252 |
+
}
|
253 |
+
|
254 |
}
|
|
|
255 |
}
|
256 |
|
257 |
if ( isset($browser_tmp) && $browser_tmp != $browser ) {
|
296 |
}
|
297 |
unset($ip_tmp, $other_ip);
|
298 |
|
299 |
+
if ( isset($shortcode_tmp) && $shortcode_tmp != $shortcode ) {
|
300 |
+
$DW->message('Exception triggered for shortcode, sets display to ' . ( ($shortcode_tmp) ? 'TRUE' : 'FALSE' ) . ' (rule ESTC1)');
|
301 |
+
$shortcode = $shortcode_tmp;
|
302 |
+
}
|
303 |
+
unset($shortcode_tmp);
|
304 |
+
|
305 |
// For debug messages
|
306 |
$e = ( isset($other) && $other ) ? 'TRUE' : 'FALSE';
|
307 |
|
519 |
$DW->message('Exception triggered for ' . $widget_id . ' sets display to ' . $e . ' (rule ES4)');
|
520 |
}
|
521 |
}
|
522 |
+
|
523 |
/* Posts */
|
524 |
if ( count($act_post) > 0 ) {
|
525 |
if ( in_array($post->ID, $act_post) ) {
|
638 |
$DW->message('Exception triggered for ' . $widget_id . ' sets display to ' . $e . ' (rule EP1)');
|
639 |
} else if ( count($act_childs) > 0 ) {
|
640 |
$parents = $DW->getParents('page', array(), $id);
|
641 |
+
|
642 |
if ( (bool) array_intersect($act_childs, $parents) ) {
|
643 |
$display = $other;
|
644 |
$DW->message('Exception triggered for ' . $widget_id . ' sets display to ' . $e . ' (rule EP2)');
|
mods/qt_module.php
CHANGED
@@ -50,7 +50,7 @@
|
|
50 |
|
51 |
if ( self::detect(FALSE) ) {
|
52 |
$qtlang = get_option('qtranslate_default_language');
|
53 |
-
$curlang =
|
54 |
$DW->message('QT language: ' . $curlang);
|
55 |
|
56 |
if ( $qtlang != $curlang ) {
|
50 |
|
51 |
if ( self::detect(FALSE) ) {
|
52 |
$qtlang = get_option('qtranslate_default_language');
|
53 |
+
$curlang = qtranxf_getLanguage();
|
54 |
$DW->message('QT language: ' . $curlang);
|
55 |
|
56 |
if ( $qtlang != $curlang ) {
|
mods/shortcode_module.php
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Shortcode Module
|
4 |
+
*
|
5 |
+
* @version $Id: shortcode_module.php 1218814 2015-08-12 06:37:21Z qurl $
|
6 |
+
* @copyright 2015 Jacco Drabbe
|
7 |
+
*/
|
8 |
+
|
9 |
+
defined('ABSPATH') or die("No script kiddies please!");
|
10 |
+
|
11 |
+
class DW_Shortcode extends DWModule {
|
12 |
+
public static $option = array( 'shortcode' => 'Shortcode' );
|
13 |
+
protected static $overrule = TRUE;
|
14 |
+
protected static $type = 'custom';
|
15 |
+
|
16 |
+
public static function admin() {
|
17 |
+
$DW = $GLOBALS['DW'];
|
18 |
+
|
19 |
+
parent::admin();
|
20 |
+
|
21 |
+
$shortcode_yes_selected = 'checked="checked"';
|
22 |
+
$opt_shortcode = $DW->getOpt($GLOBALS['widget_id'], 'shortcode');
|
23 |
+
|
24 |
+
foreach ( $opt_shortcode as $opt ) {
|
25 |
+
if ( $opt->name == 'default' ) {
|
26 |
+
$shortcode_no_selected = $shortcode_yes_selected;
|
27 |
+
unset($shortcode_yes_selected);
|
28 |
+
} else {
|
29 |
+
$shortcode = unserialize($opt->value);
|
30 |
+
}
|
31 |
+
}
|
32 |
+
?>
|
33 |
+
|
34 |
+
<h4 id="shortcode" title=" Click to toggle " class="ui-accordion-header ui-helper-reset ui-state-default ui-corner-all"><b><?php _e('Shortcode'); ?></b><?php echo ( count($opt_shortcode) > 0 ) ? ' <img src="' . $DW->plugin_url . 'img/checkmark.gif" alt="Checkmark" />' : ''; ?></h4>
|
35 |
+
<div id="shortcode_conf" class="dynwid_conf ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom">
|
36 |
+
<?php _e('Show widget when the shortcode ...', 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('shortcode_info');" /><br />
|
37 |
+
<?php $DW->dumpOpt($opt_shortcode); ?>
|
38 |
+
<div>
|
39 |
+
<div id="shortcode_info" class="infotext">
|
40 |
+
The shortcode is executed on the page where the widget is configured.<br />
|
41 |
+
The match needs to be exact and is case sensative. So, "a match" is not "A match" is not "a Match".
|
42 |
+
</div>
|
43 |
+
</div>
|
44 |
+
<br />
|
45 |
+
<input type="radio" name="shortcode" value="yes" id="shortcode-yes" <?php echo ( isset($shortcode_yes_selected) ) ? $shortcode_yes_selected : ''; ?> /> <label for="shortcode-yes"><?php _e('Yes'); ?></label>
|
46 |
+
<input type="radio" name="shortcode" value="no" id="shortcode-no" <?php echo ( isset($shortcode_no_selected) ) ? $shortcode_no_selected : ''; ?> /> <label for="shortcode-no"><?php _e('No'); ?></label><br />
|
47 |
+
|
48 |
+
<?php _e('Except when the...', DW_L10N_DOMAIN); ?>:<br />
|
49 |
+
Shortcode <input type="text" name="shortcode_value" value="<?php echo ( isset($shortcode['value']) ) ? $shortcode['value'] : ''; ?>" />
|
50 |
+
|
51 |
+
<select name="shortcode_operator">
|
52 |
+
<?php
|
53 |
+
$options = array( '=' => 'matches', '!=' => 'NOT matches' );
|
54 |
+
foreach ( $options as $key => $value ) {
|
55 |
+
echo '<option value="' . $key . '"';
|
56 |
+
echo ( isset($shortcode['operator']) && $shortcode['operator'] == $key ) ? ' selected="selected"' : '';
|
57 |
+
echo '>' . $value . '</option>';
|
58 |
+
}
|
59 |
+
?>
|
60 |
+
</select>
|
61 |
+
|
62 |
+
<input type="text" name="shortcode_match" value="<?php echo ( isset($shortcode['match']) ) ? $shortcode['match'] : ''; ?>" />
|
63 |
+
|
64 |
+
</div><!-- end dynwid_conf -->
|
65 |
+
|
66 |
+
<?php
|
67 |
+
}
|
68 |
+
}
|
69 |
+
?>
|
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: 4.2.1
|
7 |
-
Stable tag: 1.5.
|
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 |
|
@@ -35,6 +35,7 @@ It is very hard to continue development and support for this plugin without cont
|
|
35 |
- Theme Templates
|
36 |
- Languages (WPML or QTranslate)
|
37 |
- URL
|
|
|
38 |
- Front page
|
39 |
- Single post pages
|
40 |
- Attachment pages
|
@@ -65,6 +66,7 @@ It is very hard to continue development and support for this plugin without cont
|
|
65 |
- Theme Templates on template name
|
66 |
- Languages (WPML or QTranslate) on language
|
67 |
- URL on starting with URL, ending on URL or exact match
|
|
|
68 |
- Front page on first page
|
69 |
- Single post pages on Author, Categories (including inheritance from hierarchical parents), Tags, Custom Taxonomies and/or Individual posts
|
70 |
- Pages on Page Title and Custom Taxonomies, including inheritance from hierarchical parents
|
@@ -186,6 +188,11 @@ Please check the [Issue Tracker](http://www.qurl.nl/dynamic-widgets/issue-tracke
|
|
186 |
|
187 |
== Changelog ==
|
188 |
|
|
|
|
|
|
|
|
|
|
|
189 |
= Version 1.5.10 =
|
190 |
|
191 |
* Added Japanese language file (locale: ja) - Arigato chacomv!
|
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: 4.2.1
|
7 |
+
Stable tag: 1.5.11
|
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 |
|
35 |
- Theme Templates
|
36 |
- Languages (WPML or QTranslate)
|
37 |
- URL
|
38 |
+
- Shortcode
|
39 |
- Front page
|
40 |
- Single post pages
|
41 |
- Attachment pages
|
66 |
- Theme Templates on template name
|
67 |
- Languages (WPML or QTranslate) on language
|
68 |
- URL on starting with URL, ending on URL or exact match
|
69 |
+
- Shortcode on value match
|
70 |
- Front page on first page
|
71 |
- Single post pages on Author, Categories (including inheritance from hierarchical parents), Tags, Custom Taxonomies and/or Individual posts
|
72 |
- Pages on Page Title and Custom Taxonomies, including inheritance from hierarchical parents
|
188 |
|
189 |
== Changelog ==
|
190 |
|
191 |
+
= Version 1.5.11 =
|
192 |
+
|
193 |
+
* Added Shortcode matching support by request of Nathan Wright of NW Consulting who made a financial contribution to make this feature possible.
|
194 |
+
* Fixed a possible vulnerability in the DW settings found by Mike Esptein
|
195 |
+
|
196 |
= Version 1.5.10 =
|
197 |
|
198 |
* Added Japanese language file (locale: ja) - Arigato chacomv!
|