Version Description
Be sure to deactivate Dynamic Widgets Plugin before installing the new version following steps 1 and 2 in the installation procedure. After the install you can reactivate the plugin.
Download this release
Release Info
Developer | qurl |
Plugin | Dynamic Widgets |
Version | 1.3.3 |
Comparing to | |
See all releases |
Code changes from version 1.3.1 to 1.3.3
- dynamic-widgets.php +80 -43
- dynwid_admin_edit.php +70 -4
- dynwid_admin_save.php +36 -1
- dynwid_class.php +36 -2
- dynwid_class_php4.php +36 -2
- dynwid_worker.php +180 -103
- img/wpml_icon.png +0 -0
- readme.txt +20 -4
dynamic-widgets.php
CHANGED
@@ -2,9 +2,9 @@
|
|
2 |
/**
|
3 |
* Plugin Name: Dynamic Widgets
|
4 |
* Plugin URI: http://www.qurl.nl/dynamic-widgets/
|
5 |
-
* Description: Dynamic Widgets gives you more control over your widgets. It lets you dynamicly place widgets on pages by excluding or including rules by roles, dates, for the homepage, single posts, pages, authors, categories, archives, error and
|
6 |
* Author: Jacco
|
7 |
-
* Version: 1.3.
|
8 |
* Author URI: http://www.qurl.nl/
|
9 |
* Tags: widget, widgets, dynamic, sidebar, custom, rules, admin, conditional tags
|
10 |
*
|
@@ -15,18 +15,27 @@
|
|
15 |
*
|
16 |
* Released under the GPL v.2, http://www.gnu.org/copyleft/gpl.html
|
17 |
*
|
18 |
-
* @version $Id: dynamic-widgets.php
|
19 |
*/
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
// Constants
|
22 |
define('DW_DEBUG', FALSE);
|
23 |
define('DW_DB_TABLE', 'dynamic_widgets');
|
24 |
define('DW_LIST_LIMIT', 20);
|
25 |
define('DW_LIST_STYLE', 'style="overflow:auto;height:240px;"');
|
26 |
-
define('DW_VERSION', '1.3.
|
27 |
define('DW_VERSION_URL_CHECK', 'http://www.qurl.nl/wp-content/uploads/php/dw_version.php?v=' . DW_VERSION . '&n=');
|
|
|
|
|
28 |
|
29 |
-
|
30 |
if ( version_compare(PHP_VERSION, '5.0.0', '<') ) {
|
31 |
define('DW_CLASSFILE', 'dynwid_class_php4.php');
|
32 |
} else {
|
@@ -35,6 +44,46 @@
|
|
35 |
require_once(dirname(__FILE__) . '/' . DW_CLASSFILE);
|
36 |
|
37 |
// Functions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
function dynwid_add_admin_menu() {
|
39 |
$DW = &$GLOBALS['DW'];
|
40 |
|
@@ -242,43 +291,16 @@
|
|
242 |
}
|
243 |
|
244 |
function dynwid_install() {
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
KEY widget_id (widget_id,maintype)
|
256 |
-
);";
|
257 |
-
$wpdb->query($query);
|
258 |
-
|
259 |
-
// Version check
|
260 |
-
$version = get_option('dynwid_version');
|
261 |
-
if ( $version !== FALSE ) {
|
262 |
-
/* 1.2 > Added support for widget display setting options for Author Pages.
|
263 |
-
Need to apply archive rule to author also to keep same behavior. */
|
264 |
-
if ( version_compare($version, '1.2', '<') ) {
|
265 |
-
$query = "SELECT widget_id FROM " . $dbtable . " WHERE maintype = 'archive'";
|
266 |
-
$results = $wpdb->get_results($query);
|
267 |
-
foreach ( $results as $myrow ) {
|
268 |
-
$query = "INSERT INTO " .$dbtable . "(widget_id, maintype, value) VALUES ('" . $myrow->widget_id . "', 'author', '0')";
|
269 |
-
$wpdb->query($query);
|
270 |
-
}
|
271 |
-
}
|
272 |
-
|
273 |
-
/* 1.3 > Added Date (range) support.
|
274 |
-
Need to change DB `value` to a LONGTEXT type
|
275 |
-
(not for the date of course, but for supporting next features which might need a lot of space) */
|
276 |
-
if ( version_compare($version, '1.3', '<') ) {
|
277 |
-
$query = "ALTER TABLE " . $dbtable . " CHANGE `value` `value` LONGTEXT NOT NULL";
|
278 |
-
$wpdb->query($query);
|
279 |
-
}
|
280 |
-
}
|
281 |
-
update_option('dynwid_version', DW_VERSION);
|
282 |
}
|
283 |
|
284 |
function dynwid_save_postdata($post_id) {
|
@@ -401,6 +423,19 @@
|
|
401 |
'e404' => 'Error Page',
|
402 |
'search' => 'Search page'
|
403 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
404 |
$opt = $DW->getOptions($widget_id, NULL);
|
405 |
foreach ( $opt as $widget ) {
|
406 |
$type = $widget['maintype'];
|
@@ -418,7 +453,9 @@
|
|
418 |
$last = count($s) - 1;
|
419 |
for ( $i = 0; $i < $last; $i++ ) {
|
420 |
$type = $s[$i];
|
421 |
-
|
|
|
|
|
422 |
$string .= ( ($last - 1) == $i ) ? ' and ' : ', ';
|
423 |
}
|
424 |
$type = $s[$last];
|
2 |
/**
|
3 |
* Plugin Name: Dynamic Widgets
|
4 |
* Plugin URI: http://www.qurl.nl/dynamic-widgets/
|
5 |
+
* Description: Dynamic Widgets gives you more control over your widgets. It lets you dynamicly place widgets on pages by excluding or including rules by roles, dates, for the homepage, single posts, pages, authors, categories, archives, error page, search page and custom post types.
|
6 |
* Author: Jacco
|
7 |
+
* Version: 1.3.3
|
8 |
* Author URI: http://www.qurl.nl/
|
9 |
* Tags: widget, widgets, dynamic, sidebar, custom, rules, admin, conditional tags
|
10 |
*
|
15 |
*
|
16 |
* Released under the GPL v.2, http://www.gnu.org/copyleft/gpl.html
|
17 |
*
|
18 |
+
* @version $Id: dynamic-widgets.php 265306 2010-07-21 18:31:33Z qurl $
|
19 |
*/
|
20 |
|
21 |
+
/*
|
22 |
+
WPML Plugin support via API
|
23 |
+
Using functions wpml_get_default_language() > dynwid_worker.php
|
24 |
+
wpml_get_current_language() > dynwid_worker.php, dynwid_class.php, dynwid_class_php4.php
|
25 |
+
wpml_get_content_translation() > dynwid_class.php, dynwid_class_php4.php
|
26 |
+
*/
|
27 |
+
|
28 |
// Constants
|
29 |
define('DW_DEBUG', FALSE);
|
30 |
define('DW_DB_TABLE', 'dynamic_widgets');
|
31 |
define('DW_LIST_LIMIT', 20);
|
32 |
define('DW_LIST_STYLE', 'style="overflow:auto;height:240px;"');
|
33 |
+
define('DW_VERSION', '1.3.3');
|
34 |
define('DW_VERSION_URL_CHECK', 'http://www.qurl.nl/wp-content/uploads/php/dw_version.php?v=' . DW_VERSION . '&n=');
|
35 |
+
define('DW_WPML_API', '/inc/wpml-api.php'); // WPML Plugin support - API file relative to ICL_PLUGIN_PATH
|
36 |
+
define('DW_WPML_ICON', 'img/wpml_icon.png'); // WPML Plugin support - WPML icon
|
37 |
|
38 |
+
// Class version to use
|
39 |
if ( version_compare(PHP_VERSION, '5.0.0', '<') ) {
|
40 |
define('DW_CLASSFILE', 'dynwid_class_php4.php');
|
41 |
} else {
|
44 |
require_once(dirname(__FILE__) . '/' . DW_CLASSFILE);
|
45 |
|
46 |
// Functions
|
47 |
+
function dynwid_activate() {
|
48 |
+
$wpdb = $GLOBALS['wpdb'];
|
49 |
+
$dbtable = $wpdb->prefix . DW_DB_TABLE;
|
50 |
+
|
51 |
+
$query = "CREATE TABLE IF NOT EXISTS " . $dbtable . " (
|
52 |
+
id int(11) NOT NULL auto_increment,
|
53 |
+
widget_id varchar(40) NOT NULL,
|
54 |
+
maintype varchar(20) NOT NULL,
|
55 |
+
`name` varchar(40) NOT NULL,
|
56 |
+
`value` longtext NOT NULL,
|
57 |
+
PRIMARY KEY (id),
|
58 |
+
KEY widget_id (widget_id,maintype)
|
59 |
+
);";
|
60 |
+
$wpdb->query($query);
|
61 |
+
|
62 |
+
// Version check
|
63 |
+
$version = get_option('dynwid_version');
|
64 |
+
if ( $version !== FALSE ) {
|
65 |
+
/* 1.2 > Added support for widget display setting options for Author Pages.
|
66 |
+
Need to apply archive rule to author also to keep same behavior. */
|
67 |
+
if ( version_compare($version, '1.2', '<') ) {
|
68 |
+
$query = "SELECT widget_id FROM " . $dbtable . " WHERE maintype = 'archive'";
|
69 |
+
$results = $wpdb->get_results($query);
|
70 |
+
foreach ( $results as $myrow ) {
|
71 |
+
$query = "INSERT INTO " .$dbtable . "(widget_id, maintype, value) VALUES ('" . $myrow->widget_id . "', 'author', '0')";
|
72 |
+
$wpdb->query($query);
|
73 |
+
}
|
74 |
+
}
|
75 |
+
|
76 |
+
/* 1.3 > Added Date (range) support.
|
77 |
+
Need to change DB `value` to a LONGTEXT type
|
78 |
+
(not for the date of course, but for supporting next features which might need a lot of space) */
|
79 |
+
if ( version_compare($version, '1.3', '<') ) {
|
80 |
+
$query = "ALTER TABLE " . $dbtable . " CHANGE `value` `value` LONGTEXT NOT NULL";
|
81 |
+
$wpdb->query($query);
|
82 |
+
}
|
83 |
+
}
|
84 |
+
update_option('dynwid_version', DW_VERSION);
|
85 |
+
}
|
86 |
+
|
87 |
function dynwid_add_admin_menu() {
|
88 |
$DW = &$GLOBALS['DW'];
|
89 |
|
291 |
}
|
292 |
|
293 |
function dynwid_install() {
|
294 |
+
if ( function_exists('is_multisite') ) {
|
295 |
+
if ( is_multisite() && $_GET['networkwide'] == '1' ) {
|
296 |
+
$plugin = plugin_basename(__FILE__);
|
297 |
+
deactivate_plugins($plugin);
|
298 |
+
} else {
|
299 |
+
dynwid_activate();
|
300 |
+
}
|
301 |
+
} else {
|
302 |
+
dynwid_activate();
|
303 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
304 |
}
|
305 |
|
306 |
function dynwid_save_postdata($post_id) {
|
423 |
'e404' => 'Error Page',
|
424 |
'search' => 'Search page'
|
425 |
);
|
426 |
+
|
427 |
+
// Adding Custom Post Types to $buffer
|
428 |
+
if ( version_compare($GLOBALS['wp_version'], '3.0', '>=') ) {
|
429 |
+
$args = array(
|
430 |
+
'public' => TRUE,
|
431 |
+
'_builtin' => FALSE
|
432 |
+
);
|
433 |
+
$post_types = get_post_types($args, 'objects', 'and');
|
434 |
+
foreach ( $post_types as $ctid ) {
|
435 |
+
$buffer[key($post_types)] = $ctid->label;
|
436 |
+
}
|
437 |
+
}
|
438 |
+
|
439 |
$opt = $DW->getOptions($widget_id, NULL);
|
440 |
foreach ( $opt as $widget ) {
|
441 |
$type = $widget['maintype'];
|
453 |
$last = count($s) - 1;
|
454 |
for ( $i = 0; $i < $last; $i++ ) {
|
455 |
$type = $s[$i];
|
456 |
+
if (! empty($buffer[$type]) ) {
|
457 |
+
$string .= $buffer[$type];
|
458 |
+
}
|
459 |
$string .= ( ($last - 1) == $i ) ? ' and ' : ', ';
|
460 |
}
|
461 |
$type = $s[$last];
|
dynwid_admin_edit.php
CHANGED
@@ -2,9 +2,15 @@
|
|
2 |
/**
|
3 |
* dynwid_admin_edit.php - Options settings
|
4 |
*
|
5 |
-
* @version $Id: dynwid_admin_edit.php
|
6 |
*/
|
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
// Roles
|
9 |
$wp_roles = $GLOBALS['wp_roles'];
|
10 |
$roles = array_merge($wp_roles->role_names, array('anonymous' => 'Anonymous|User role'));
|
@@ -416,7 +422,7 @@ Show widget default on single posts?<br />
|
|
416 |
</td>
|
417 |
<td style="width:10px"></td>
|
418 |
<td valign="top">
|
419 |
-
Except the posts in category:
|
420 |
<?php $DW->dumpOpt($opt_single_category); ?>
|
421 |
<div id="single-category-select" class="condition-select" <?php echo $category_condition_select_style; ?>>
|
422 |
<?php foreach ( $category as $cat ) { ?>
|
@@ -430,7 +436,7 @@ Show widget default on single posts?<br />
|
|
430 |
|
431 |
<br /><br />
|
432 |
|
433 |
-
<b>Pages</b
|
434 |
Show widget default on static pages?<br />
|
435 |
<?php $DW->dumpOpt($opt_page); ?>
|
436 |
<input type="radio" name="page" value="yes" id="page-yes" <?php echo $page_yes_selected; ?> /> <label for="page-yes">Yes</label>
|
@@ -457,7 +463,7 @@ Except the author(s):<br />
|
|
457 |
|
458 |
<br /><br />
|
459 |
|
460 |
-
<b>Category Pages</b
|
461 |
Show widget default on category pages?<br />
|
462 |
<?php $DW->dumpOpt($opt_category); ?>
|
463 |
<input type="radio" name="category" value="yes" id="category-yes" <?php echo $category_yes_selected; ?> /> <label for="category-yes">Yes</label>
|
@@ -500,6 +506,65 @@ Show widget on the search page?<br />
|
|
500 |
|
501 |
<br /><br />
|
502 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
503 |
<input class="button-primary" type="submit" value="Save" />
|
504 |
</form>
|
505 |
|
@@ -522,6 +587,7 @@ Show widget on the search page?<br />
|
|
522 |
if ( confirm('Are you sure you want to enable the exception rule for individual posts and tags?\nThis will remove the exceptions set for Author and/or Category on single posts for this widget.\nOk = Yes; No = Cancel') ) {
|
523 |
swChb(cAuthors, true);
|
524 |
swChb(cCat, true);
|
|
|
525 |
} else {
|
526 |
document.getElementById('individual').checked = false;
|
527 |
}
|
2 |
/**
|
3 |
* dynwid_admin_edit.php - Options settings
|
4 |
*
|
5 |
+
* @version $Id: dynwid_admin_edit.php 265306 2010-07-21 18:31:33Z qurl $
|
6 |
*/
|
7 |
|
8 |
+
// WPML Plugin support
|
9 |
+
if ( defined('ICL_PLUGIN_PATH') && file_exists(ICL_PLUGIN_PATH . DW_WPML_API) ) {
|
10 |
+
$DW->wpml = TRUE;
|
11 |
+
$wpml_icon = '<img src="' . $DW->plugin_url . DW_WPML_ICON . '" alt="WMPL" title="Dynamic Widgets syncs with other languages of these pages via WPML" />';
|
12 |
+
}
|
13 |
+
|
14 |
// Roles
|
15 |
$wp_roles = $GLOBALS['wp_roles'];
|
16 |
$roles = array_merge($wp_roles->role_names, array('anonymous' => 'Anonymous|User role'));
|
422 |
</td>
|
423 |
<td style="width:10px"></td>
|
424 |
<td valign="top">
|
425 |
+
Except the posts in category: <?php echo ( $DW->wpml ? $wpml_icon : '' ); ?>
|
426 |
<?php $DW->dumpOpt($opt_single_category); ?>
|
427 |
<div id="single-category-select" class="condition-select" <?php echo $category_condition_select_style; ?>>
|
428 |
<?php foreach ( $category as $cat ) { ?>
|
436 |
|
437 |
<br /><br />
|
438 |
|
439 |
+
<b>Pages</b> <?php echo ( $DW->wpml ? $wpml_icon : '' ); ?><br />
|
440 |
Show widget default on static pages?<br />
|
441 |
<?php $DW->dumpOpt($opt_page); ?>
|
442 |
<input type="radio" name="page" value="yes" id="page-yes" <?php echo $page_yes_selected; ?> /> <label for="page-yes">Yes</label>
|
463 |
|
464 |
<br /><br />
|
465 |
|
466 |
+
<b>Category Pages</b> <?php echo ( $DW->wpml ? $wpml_icon : '' ); ?><br />
|
467 |
Show widget default on category pages?<br />
|
468 |
<?php $DW->dumpOpt($opt_category); ?>
|
469 |
<input type="radio" name="category" value="yes" id="category-yes" <?php echo $category_yes_selected; ?> /> <label for="category-yes">Yes</label>
|
506 |
|
507 |
<br /><br />
|
508 |
|
509 |
+
<?php
|
510 |
+
/* WordPress 3.0 and higher: Custom Post Types */
|
511 |
+
if ( version_compare($GLOBALS['wp_version'], '3.0', '>=') ) {
|
512 |
+
$args = array(
|
513 |
+
'public' => TRUE,
|
514 |
+
'_builtin' => FALSE
|
515 |
+
);
|
516 |
+
$post_types = get_post_types($args, 'objects', 'and');
|
517 |
+
|
518 |
+
foreach ( $post_types as $ctid ) {
|
519 |
+
// Prepare
|
520 |
+
$custom_yes_selected = 'checked="checked"';
|
521 |
+
$opt_custom = $DW->getOptions($_GET['id'], key($post_types));
|
522 |
+
if ( count($opt_custom) > 0 ) {
|
523 |
+
$custom_act = array();
|
524 |
+
foreach ( $opt_custom as $custom_condition ) {
|
525 |
+
if ( $custom_condition['name'] == 'default' || empty($custom_condition['name']) ) {
|
526 |
+
$custom_default = $custom_condition['value'];
|
527 |
+
} else {
|
528 |
+
$custom_act[ ] = $custom_condition['name'];
|
529 |
+
}
|
530 |
+
}
|
531 |
+
|
532 |
+
if ( $custom_default == '0' ) {
|
533 |
+
$custom_no_selected = $custom_yes_selected;
|
534 |
+
unset($custom_yes_selected);
|
535 |
+
}
|
536 |
+
}
|
537 |
+
|
538 |
+
$loop = new WP_Query( array('post_type' => key($post_types)) );
|
539 |
+
if ( $loop->post_count > DW_LIST_LIMIT ) {
|
540 |
+
$custom_condition_select_style = DW_LIST_STYLE;
|
541 |
+
}
|
542 |
+
|
543 |
+
// Output
|
544 |
+
echo '<input type="hidden" name="post_types[]" value="' . key($post_types) . '" />';
|
545 |
+
echo '<b>Custom Post Type <em>' . $ctid->label . '</em></b> ' . ( $DW->wpml ? $wpml_icon : '' ) . '<br />';
|
546 |
+
echo 'Show widget on ' . $ctid->label . '?<br />';
|
547 |
+
$DW->dumpOpt($opt_custom);
|
548 |
+
echo '<input type="radio" name="' . key($post_types) . '" value="yes" id="' . key($post_types) . '-yes" ' . $custom_yes_selected . ' /> <label for="' . key($post_types) . '-yes">Yes</label> ';
|
549 |
+
echo '<input type="radio" name="' . key($post_types) . '" value="no" id="' . key($post_types) . '-no" ' . $custom_no_selected . ' /> <label for="' . key($post_types) . '-no">No</label><br />';
|
550 |
+
|
551 |
+
echo 'Except for:<br />';
|
552 |
+
echo '<div id="' . key($post_types) . '-select" class="condition-select" ' . $custom_condition_select_style . '>';
|
553 |
+
|
554 |
+
while ( $loop->have_posts() ) : $loop->the_post();
|
555 |
+
echo '<input type="checkbox" id="' . key($post_types) . '_act_' . $loop->post->ID . '" name="' . key($post_types) . '_act[]" value="' . $loop->post->ID . '" ';
|
556 |
+
echo ( count($custom_act) > 0 && in_array($loop->post->ID,$custom_act) ) ? 'checked="checked"' : '';
|
557 |
+
echo ' /> <label for="' . key($post_types) . '_act_' . $loop->post->ID . '">';
|
558 |
+
the_title();
|
559 |
+
echo '</label><br />';
|
560 |
+
endwhile;
|
561 |
+
echo '</div>';
|
562 |
+
|
563 |
+
echo '<br /><br />';
|
564 |
+
}
|
565 |
+
} // end version compare >= WP 3.0
|
566 |
+
?>
|
567 |
+
|
568 |
<input class="button-primary" type="submit" value="Save" />
|
569 |
</form>
|
570 |
|
587 |
if ( confirm('Are you sure you want to enable the exception rule for individual posts and tags?\nThis will remove the exceptions set for Author and/or Category on single posts for this widget.\nOk = Yes; No = Cancel') ) {
|
588 |
swChb(cAuthors, true);
|
589 |
swChb(cCat, true);
|
590 |
+
icount = 0;
|
591 |
} else {
|
592 |
document.getElementById('individual').checked = false;
|
593 |
}
|
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
|
6 |
*/
|
7 |
|
8 |
// Security - nonce
|
@@ -74,6 +74,29 @@
|
|
74 |
$work = TRUE;
|
75 |
}
|
76 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
if (! $work ) {
|
78 |
wp_redirect( get_option('siteurl') . $_SERVER['REQUEST_URI'] . '&work=none' );
|
79 |
die();
|
@@ -175,6 +198,18 @@
|
|
175 |
$DW->addSingleOption($_POST['widget_id'], 'search');
|
176 |
}
|
177 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
// Redirect to ReturnURL
|
179 |
if (! empty($_POST['returnurl']) ) {
|
180 |
$q = array();
|
2 |
/**
|
3 |
* dynwid_admin_save.php - Saving options to the database
|
4 |
*
|
5 |
+
* @version $Id: dynwid_admin_save.php 265306 2010-07-21 18:31:33Z qurl $
|
6 |
*/
|
7 |
|
8 |
// Security - nonce
|
74 |
$work = TRUE;
|
75 |
}
|
76 |
}
|
77 |
+
|
78 |
+
// Custom Types (WP >= 3.0)
|
79 |
+
if ( version_compare($GLOBALS['wp_version'], '3.0', '>=') ) {
|
80 |
+
if (! $work ) {
|
81 |
+
foreach ( $_POST['post_types'] as $type ) {
|
82 |
+
if ( $_POST[$type] == 'yes' ) {
|
83 |
+
$work = TRUE;
|
84 |
+
break;
|
85 |
+
}
|
86 |
+
}
|
87 |
+
}
|
88 |
+
|
89 |
+
if (! $work ) {
|
90 |
+
foreach ( $_POST['post_types'] as $type ) {
|
91 |
+
$field = $type . '_act';
|
92 |
+
if ( count($_POST[$field]) > 0 ) {
|
93 |
+
$work = TRUE;
|
94 |
+
break;
|
95 |
+
}
|
96 |
+
}
|
97 |
+
}
|
98 |
+
}
|
99 |
+
|
100 |
if (! $work ) {
|
101 |
wp_redirect( get_option('siteurl') . $_SERVER['REQUEST_URI'] . '&work=none' );
|
102 |
die();
|
198 |
$DW->addSingleOption($_POST['widget_id'], 'search');
|
199 |
}
|
200 |
|
201 |
+
// Custom Types (WP >= 3.0)
|
202 |
+
if ( version_compare($GLOBALS['wp_version'], '3.0', '>=') ) {
|
203 |
+
foreach ( $_POST['post_types'] as $type ) {
|
204 |
+
$act_field = $type . '_act';
|
205 |
+
if ( count($_POST[$act_field]) > 0 ) {
|
206 |
+
$DW->addMultiOption($_POST['widget_id'], $type, $_POST[$type], $_POST[$act_field]);
|
207 |
+
} else if ( $_POST[$type] == 'no' ) {
|
208 |
+
$DW->addSingleOption($_POST['widget_id'], $type);
|
209 |
+
}
|
210 |
+
}
|
211 |
+
}
|
212 |
+
|
213 |
// Redirect to ReturnURL
|
214 |
if (! empty($_POST['returnurl']) ) {
|
215 |
$q = array();
|
dynwid_class.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* dynwid_class.php - Dynamic Widgets Class (PHP5)
|
4 |
*
|
5 |
-
* @version $Id: dynwid_class.php
|
6 |
*/
|
7 |
|
8 |
class dynWid {
|
@@ -16,6 +16,7 @@
|
|
16 |
public $plugin_url;
|
17 |
public $userrole;
|
18 |
private $wpdb;
|
|
|
19 |
|
20 |
public function __construct() {
|
21 |
if ( is_user_logged_in() ) {
|
@@ -34,7 +35,10 @@
|
|
34 |
$this->wpdb = $GLOBALS['wpdb'];
|
35 |
$this->dbtable = $this->wpdb->prefix . DW_DB_TABLE;
|
36 |
|
37 |
-
|
|
|
|
|
|
|
38 |
}
|
39 |
|
40 |
public function addDate($widget_id, $dates) {
|
@@ -163,6 +167,7 @@
|
|
163 |
echo "\n";
|
164 |
echo "list: \n";
|
165 |
$list = array();
|
|
|
166 |
foreach ( $this->dynwid_list as $widget_id ) {
|
167 |
$list[$widget_id] = strip_tags($this->getName($widget_id));
|
168 |
}
|
@@ -186,6 +191,21 @@
|
|
186 |
}
|
187 |
}
|
188 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
public function getName($id, $type = 'W') {
|
190 |
switch ( $type ) {
|
191 |
case 'S':
|
@@ -271,5 +291,19 @@
|
|
271 |
$query = "DELETE FROM " . $this->dbtable . " WHERE widget_id = '" . $widget_id . "'";
|
272 |
$this->wpdb->query($query);
|
273 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
274 |
}
|
275 |
?>
|
2 |
/**
|
3 |
* dynwid_class.php - Dynamic Widgets Class (PHP5)
|
4 |
*
|
5 |
+
* @version $Id: dynwid_class.php 265306 2010-07-21 18:31:33Z qurl $
|
6 |
*/
|
7 |
|
8 |
class dynWid {
|
16 |
public $plugin_url;
|
17 |
public $userrole;
|
18 |
private $wpdb;
|
19 |
+
public $wpml; // WPML Plugin support
|
20 |
|
21 |
public function __construct() {
|
22 |
if ( is_user_logged_in() ) {
|
35 |
$this->wpdb = $GLOBALS['wpdb'];
|
36 |
$this->dbtable = $this->wpdb->prefix . DW_DB_TABLE;
|
37 |
|
38 |
+
// WPML Plugin support
|
39 |
+
$this->wpml = FALSE;
|
40 |
+
|
41 |
+
// $this->createList();
|
42 |
}
|
43 |
|
44 |
public function addDate($widget_id, $dates) {
|
167 |
echo "\n";
|
168 |
echo "list: \n";
|
169 |
$list = array();
|
170 |
+
$this->createList();
|
171 |
foreach ( $this->dynwid_list as $widget_id ) {
|
172 |
$list[$widget_id] = strip_tags($this->getName($widget_id));
|
173 |
}
|
191 |
}
|
192 |
}
|
193 |
|
194 |
+
// replacement for createList() to make the worker faster
|
195 |
+
public function dwList($whereami) {
|
196 |
+
$this->dynwid_list = array();
|
197 |
+
if ( $whereami == 'home' ) {
|
198 |
+
$whereami = 'page';
|
199 |
+
}
|
200 |
+
|
201 |
+
$query = "SELECT widget_id FROM " . $this->dbtable . "
|
202 |
+
WHERE maintype LIKE '" . $whereami . "%' OR maintype = 'role' OR maintype = 'date'";
|
203 |
+
$results = $this->wpdb->get_results($query);
|
204 |
+
foreach ( $results as $myrow ) {
|
205 |
+
$this->dynwid_list[ ] = $myrow->widget_id;
|
206 |
+
}
|
207 |
+
}
|
208 |
+
|
209 |
public function getName($id, $type = 'W') {
|
210 |
switch ( $type ) {
|
211 |
case 'S':
|
291 |
$query = "DELETE FROM " . $this->dbtable . " WHERE widget_id = '" . $widget_id . "'";
|
292 |
$this->wpdb->query($query);
|
293 |
}
|
294 |
+
|
295 |
+
// WPML Plugin support
|
296 |
+
public function wpml_get_id($content_id, $content_type = 'post_page') {
|
297 |
+
$language_code = wpml_get_default_language();
|
298 |
+
$lang = wpml_get_content_translation($content_type, $content_id, $language_code);
|
299 |
+
|
300 |
+
if ( is_array($lang) ) {
|
301 |
+
$id = $lang[$language_code];
|
302 |
+
} else {
|
303 |
+
$id = 0;
|
304 |
+
}
|
305 |
+
|
306 |
+
return $id;
|
307 |
+
}
|
308 |
}
|
309 |
?>
|
dynwid_class_php4.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* dynwid_class_php4.php - Dynamic Widgets Class for PHP4
|
4 |
* Needs at least PHP 4.1.0
|
5 |
*
|
6 |
-
* @version $Id: dynwid_class_php4.php
|
7 |
*/
|
8 |
|
9 |
class dynWid {
|
@@ -17,6 +17,7 @@
|
|
17 |
var $plugin_url;
|
18 |
var $userrole;
|
19 |
var $wpdb; /* private */
|
|
|
20 |
|
21 |
/* Old constructor redirect to new constructor */
|
22 |
function dynWid() {
|
@@ -40,7 +41,10 @@
|
|
40 |
$this->wpdb = $GLOBALS['wpdb'];
|
41 |
$this->dbtable = $this->wpdb->prefix . DW_DB_TABLE;
|
42 |
|
43 |
-
|
|
|
|
|
|
|
44 |
}
|
45 |
|
46 |
function addDate($widget_id, $dates) {
|
@@ -170,6 +174,7 @@
|
|
170 |
echo "\n";
|
171 |
echo "list: \n";
|
172 |
$list = array();
|
|
|
173 |
foreach ( $this->dynwid_list as $widget_id ) {
|
174 |
$list[$widget_id] = strip_tags($this->getName($widget_id));
|
175 |
}
|
@@ -193,6 +198,21 @@
|
|
193 |
}
|
194 |
}
|
195 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
function getName($id, $type = 'W') {
|
197 |
switch ( $type ) {
|
198 |
case 'S':
|
@@ -278,5 +298,19 @@
|
|
278 |
$query = "DELETE FROM " . $this->dbtable . " WHERE widget_id = '" . $widget_id . "'";
|
279 |
$this->wpdb->query($query);
|
280 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
281 |
}
|
282 |
?>
|
3 |
* dynwid_class_php4.php - Dynamic Widgets Class for PHP4
|
4 |
* Needs at least PHP 4.1.0
|
5 |
*
|
6 |
+
* @version $Id: dynwid_class_php4.php 265306 2010-07-21 18:31:33Z qurl $
|
7 |
*/
|
8 |
|
9 |
class dynWid {
|
17 |
var $plugin_url;
|
18 |
var $userrole;
|
19 |
var $wpdb; /* private */
|
20 |
+
var $wpml; /* WPML Plugin support */
|
21 |
|
22 |
/* Old constructor redirect to new constructor */
|
23 |
function dynWid() {
|
41 |
$this->wpdb = $GLOBALS['wpdb'];
|
42 |
$this->dbtable = $this->wpdb->prefix . DW_DB_TABLE;
|
43 |
|
44 |
+
// WPML Plugin support
|
45 |
+
$this->wpml = FALSE;
|
46 |
+
|
47 |
+
// $this->createList();
|
48 |
}
|
49 |
|
50 |
function addDate($widget_id, $dates) {
|
174 |
echo "\n";
|
175 |
echo "list: \n";
|
176 |
$list = array();
|
177 |
+
$this->createList();
|
178 |
foreach ( $this->dynwid_list as $widget_id ) {
|
179 |
$list[$widget_id] = strip_tags($this->getName($widget_id));
|
180 |
}
|
198 |
}
|
199 |
}
|
200 |
|
201 |
+
// replacement for createList() to make the worker faster
|
202 |
+
function dwList($whereami) {
|
203 |
+
$this->dynwid_list = array();
|
204 |
+
if ( $whereami == 'home' ) {
|
205 |
+
$whereami = 'page';
|
206 |
+
}
|
207 |
+
|
208 |
+
$query = "SELECT widget_id FROM " . $this->dbtable . "
|
209 |
+
WHERE maintype LIKE '" . $whereami . "%' OR maintype = 'role' OR maintype = 'date'";
|
210 |
+
$results = $this->wpdb->get_results($query);
|
211 |
+
foreach ( $results as $myrow ) {
|
212 |
+
$this->dynwid_list[ ] = $myrow->widget_id;
|
213 |
+
}
|
214 |
+
}
|
215 |
+
|
216 |
function getName($id, $type = 'W') {
|
217 |
switch ( $type ) {
|
218 |
case 'S':
|
298 |
$query = "DELETE FROM " . $this->dbtable . " WHERE widget_id = '" . $widget_id . "'";
|
299 |
$this->wpdb->query($query);
|
300 |
}
|
301 |
+
|
302 |
+
// WPML Plugin support
|
303 |
+
function wpml_get_id($content_id, $content_type = 'post_page') {
|
304 |
+
$language_code = wpml_get_default_language();
|
305 |
+
$lang = wpml_get_content_translation($content_type, $content_id, $language_code);
|
306 |
+
|
307 |
+
if ( is_array($lang) ) {
|
308 |
+
$id = $lang[$language_code];
|
309 |
+
} else {
|
310 |
+
$id = 0;
|
311 |
+
}
|
312 |
+
|
313 |
+
return $id;
|
314 |
+
}
|
315 |
}
|
316 |
?>
|
dynwid_worker.php
CHANGED
@@ -2,18 +2,49 @@
|
|
2 |
/**
|
3 |
* dynwid_worker.php - The worker does the actual work.
|
4 |
*
|
5 |
-
* @version $Id: dynwid_worker.php
|
6 |
*/
|
7 |
|
8 |
$DW->message('Dynamic Widgets INIT');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
$DW->message('User has role(s): ' . implode(', ', $DW->userrole));
|
10 |
|
|
|
11 |
$whereami = $DW->detectPage();
|
12 |
$DW->message('Page is ' . $whereami);
|
13 |
if ( $whereami == 'single' ) {
|
14 |
$post = $GLOBALS['post'];
|
15 |
$DW->message('post_id = ' . $post->ID);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
}
|
|
|
17 |
|
18 |
foreach ( $DW->sidebars as $sidebar_id => $widgets ) {
|
19 |
// Only processing active sidebars with widgets
|
@@ -23,7 +54,7 @@
|
|
23 |
if ( in_array($widget_id, $DW->dynwid_list) ) {
|
24 |
$act = array();
|
25 |
$opt = $DW->getOptions($widget_id, $whereami, FALSE);
|
26 |
-
$DW->message('Number of rules to check for widget '
|
27 |
$display = TRUE;
|
28 |
$role = TRUE;
|
29 |
$date = TRUE;
|
@@ -109,124 +140,170 @@
|
|
109 |
// For debug messages
|
110 |
$e = ( $other ) ? 'TRUE' : 'FALSE';
|
111 |
|
112 |
-
// Display exceptions
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
$
|
117 |
-
$
|
118 |
-
$
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
// Get the categories from the post
|
123 |
-
$categories = get_the_category();
|
124 |
-
foreach ( $categories as $category ) {
|
125 |
-
$post_category[ ] = $category->cat_ID;
|
126 |
}
|
127 |
|
128 |
-
|
129 |
-
|
130 |
-
$
|
131 |
-
foreach ( $tags as $tag ) {
|
132 |
-
$post_tag[ ] = $tag->term_id;
|
133 |
-
}
|
134 |
-
} else {
|
135 |
-
$tags = array();
|
136 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
case 'single-category':
|
147 |
-
$act_category[ ] = $condition['name'];
|
148 |
-
break;
|
149 |
-
|
150 |
-
case 'single-tag':
|
151 |
-
$act_tag[ ] = $condition['name'];
|
152 |
-
break;
|
153 |
-
|
154 |
-
case 'single-post':
|
155 |
-
$act_post[ ] = $condition['name'];
|
156 |
-
break;
|
157 |
-
} // END switch
|
158 |
}
|
159 |
-
}
|
160 |
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
|
|
|
|
167 |
}
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
$
|
172 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
}
|
174 |
-
|
175 |
-
|
176 |
-
if ( (
|
177 |
-
|
178 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
}
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
if ( count($
|
184 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
185 |
$display = $other;
|
186 |
-
$DW->message('Exception triggered for ' . $widget_id . ' sets display to ' . $e . ' (rule
|
187 |
}
|
188 |
}
|
189 |
-
|
190 |
-
|
191 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
192 |
$display = $other;
|
193 |
-
$DW->message('Exception triggered for ' . $widget_id . ' sets display to ' . $e . ' (rule
|
194 |
}
|
195 |
}
|
196 |
-
|
197 |
-
break;
|
198 |
-
|
199 |
-
case 'home':
|
200 |
-
if ( count($act) > 0 ) {
|
201 |
-
$home_id = get_option('page_for_posts');
|
202 |
-
if ( in_array($home_id, $act) ) {
|
203 |
-
$display = $other;
|
204 |
-
$DW->message('Exception triggered for ' . $widget_id . ' sets display to ' . $e . ' (rule EH1)');
|
205 |
-
}
|
206 |
-
}
|
207 |
-
break;
|
208 |
-
|
209 |
-
case 'page':
|
210 |
-
if ( count($act) > 0 && is_page($act) ) {
|
211 |
-
$display = $other;
|
212 |
-
$DW->message('Exception triggered for ' . $widget_id . ' sets display to ' . $e . ' (rule EP1)');
|
213 |
-
}
|
214 |
-
break;
|
215 |
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
230 |
} /* END if ( count($opt) > 0 ) */
|
231 |
|
232 |
if (! $display || ! $role || ! $date ) {
|
2 |
/**
|
3 |
* dynwid_worker.php - The worker does the actual work.
|
4 |
*
|
5 |
+
* @version $Id: dynwid_worker.php 265306 2010-07-21 18:31:33Z qurl $
|
6 |
*/
|
7 |
|
8 |
$DW->message('Dynamic Widgets INIT');
|
9 |
+
|
10 |
+
// WPML Plugin Support
|
11 |
+
if ( defined('ICL_PLUGIN_PATH') ) {
|
12 |
+
$wpml_api = ICL_PLUGIN_PATH . DW_WPML_API;
|
13 |
+
|
14 |
+
if ( file_exists($wpml_api) ) {
|
15 |
+
require_once($wpml_api);
|
16 |
+
|
17 |
+
$wpmlang = wpml_get_default_language();
|
18 |
+
$curlang = wpml_get_current_language();
|
19 |
+
|
20 |
+
if ( $wpmlang != $curlang ) {
|
21 |
+
$DW->wpml = TRUE;
|
22 |
+
$DW->message('WPML enabled, default language: ' . $wpmlang);
|
23 |
+
}
|
24 |
+
}
|
25 |
+
}
|
26 |
+
|
27 |
$DW->message('User has role(s): ' . implode(', ', $DW->userrole));
|
28 |
|
29 |
+
$custom_post_type = FALSE;
|
30 |
$whereami = $DW->detectPage();
|
31 |
$DW->message('Page is ' . $whereami);
|
32 |
if ( $whereami == 'single' ) {
|
33 |
$post = $GLOBALS['post'];
|
34 |
$DW->message('post_id = ' . $post->ID);
|
35 |
+
|
36 |
+
/* WordPress 3.0 and higher: Custom Post Types */
|
37 |
+
if ( version_compare($GLOBALS['wp_version'], '3.0', '>=') ) {
|
38 |
+
$post_type = get_post_type($post);
|
39 |
+
$DW->message('Post Type = ' . $post_type);
|
40 |
+
if ( $post_type != 'post' ) {
|
41 |
+
$custom_post_type = TRUE;
|
42 |
+
$whereami = $post_type;
|
43 |
+
$DW->message('Custom Post Type detected, page changed to ' . $whereami);
|
44 |
+
}
|
45 |
+
}
|
46 |
}
|
47 |
+
$DW->dwList($whereami);
|
48 |
|
49 |
foreach ( $DW->sidebars as $sidebar_id => $widgets ) {
|
50 |
// Only processing active sidebars with widgets
|
54 |
if ( in_array($widget_id, $DW->dynwid_list) ) {
|
55 |
$act = array();
|
56 |
$opt = $DW->getOptions($widget_id, $whereami, FALSE);
|
57 |
+
$DW->message('Number of rules to check for widget ' . $widget_id . ': ' . count($opt));
|
58 |
$display = TRUE;
|
59 |
$role = TRUE;
|
60 |
$date = TRUE;
|
140 |
// For debug messages
|
141 |
$e = ( $other ) ? 'TRUE' : 'FALSE';
|
142 |
|
143 |
+
// Display exceptions (custom post type)
|
144 |
+
if ( $custom_post_type ) {
|
145 |
+
// Custom Post Type behaves the same as a single post
|
146 |
+
if ( count($act) > 0 ) {
|
147 |
+
$id = $post->ID;
|
148 |
+
$DW->message('PostID: ' . $id);
|
149 |
+
if ( $DW->wpml ) {
|
150 |
+
$id = $DW->wpml_get_id($id, 'post_' . $post_type);
|
151 |
+
$DW->message('WPML ObjectID: ' . $id);
|
|
|
|
|
|
|
|
|
|
|
152 |
}
|
153 |
|
154 |
+
if ( in_array($id, $act) ) {
|
155 |
+
$display = $other;
|
156 |
+
$DW->message('Exception triggered for ' . $widget_id . ' sets display to ' . $e . ' (rule ECP1)');
|
|
|
|
|
|
|
|
|
|
|
157 |
}
|
158 |
+
}
|
159 |
+
} else {
|
160 |
+
// no custom post type
|
161 |
+
switch ( $whereami ) {
|
162 |
+
case 'single':
|
163 |
+
$act_author = array();
|
164 |
+
$act_category = array();
|
165 |
+
$act_post = array();
|
166 |
+
$act_tag = array();
|
167 |
+
$post_category = array();
|
168 |
+
$post_tag = array();
|
169 |
|
170 |
+
// Get the categories from the post
|
171 |
+
$categories = get_the_category();
|
172 |
+
foreach ( $categories as $category ) {
|
173 |
+
$id = $category->cat_ID;
|
174 |
+
if ( $DW->wpml ) {
|
175 |
+
$id = $DW->wpml_get_id($id, 'tax_category');
|
176 |
+
}
|
177 |
+
$post_category[ ] = $id;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
}
|
|
|
179 |
|
180 |
+
// Get the tags form the post
|
181 |
+
if ( has_tag() ) {
|
182 |
+
$tags = get_the_tags();
|
183 |
+
foreach ( $tags as $tag ) {
|
184 |
+
$post_tag[ ] = $tag->term_id;
|
185 |
+
}
|
186 |
+
} else {
|
187 |
+
$tags = array();
|
188 |
}
|
189 |
+
|
190 |
+
// Split out the conditions
|
191 |
+
foreach ( $opt as $condition ) {
|
192 |
+
if ( $condition['name'] != 'default' ) {
|
193 |
+
switch ( $condition['maintype'] ) {
|
194 |
+
case 'single-author':
|
195 |
+
$act_author[ ] = $condition['name'];
|
196 |
+
break;
|
197 |
+
|
198 |
+
case 'single-category':
|
199 |
+
$act_category[ ] = $condition['name'];
|
200 |
+
break;
|
201 |
+
|
202 |
+
case 'single-tag':
|
203 |
+
$act_tag[ ] = $condition['name'];
|
204 |
+
break;
|
205 |
+
|
206 |
+
case 'single-post':
|
207 |
+
$act_post[ ] = $condition['name'];
|
208 |
+
break;
|
209 |
+
} // END switch
|
210 |
+
}
|
211 |
}
|
212 |
+
|
213 |
+
/* Author AND Category */
|
214 |
+
if ( count($act_author) > 0 && count($act_category) > 0 ) {
|
215 |
+
// Use of array_intersect to be sure one value in both arrays returns true
|
216 |
+
if ( in_array($post->post_author, $act_author) && (bool) array_intersect($post_category, $act_category) ) {
|
217 |
+
$display = $other;
|
218 |
+
$DW->message('Exception triggered for ' . $widget_id . ' sets display to ' . $e . ' (rule ES1)');
|
219 |
+
}
|
220 |
+
/* Only Author */
|
221 |
+
} else if ( count($act_author) > 0 && count($act_category == 0) ) {
|
222 |
+
if ( in_array($post->post_author, $act_author) ) {
|
223 |
+
$display = $other;
|
224 |
+
$DW->message('Exception triggered for ' . $widget_id . ' sets display to ' . $e . ' (rule ES2)');
|
225 |
+
}
|
226 |
+
/* Only Category */
|
227 |
+
} else if ( count($act_author) == 0 && count($act_category) > 0 ) {
|
228 |
+
if ( (bool) array_intersect($post_category, $act_category) ) {
|
229 |
+
$display = $other;
|
230 |
+
$DW->message('Exception triggered for ' . $widget_id . ' sets display to ' . $e . ' (rule ES3)');
|
231 |
+
}
|
232 |
+
/* None or individual checked - individual is not included in the $opt */
|
233 |
+
} else {
|
234 |
+
/* Tags */
|
235 |
+
if ( count($act_tag) > 0 ) {
|
236 |
+
if ( (bool) array_intersect($post_tag, $act_tag) ) {
|
237 |
+
$display = $other;
|
238 |
+
$DW->message('Exception triggered for ' . $widget_id . ' sets display to ' . $e . ' (rule ES4)');
|
239 |
+
}
|
240 |
+
}
|
241 |
+
/* Posts */
|
242 |
+
if ( count($act_post) > 0 ) {
|
243 |
+
if ( in_array($post->ID, $act_post) ) {
|
244 |
+
$display = $other;
|
245 |
+
$DW->message('Exception triggered for ' . $widget_id . ' sets display to ' . $e . ' (rule ES5)');
|
246 |
+
}
|
247 |
+
}
|
248 |
}
|
249 |
+
break;
|
250 |
+
|
251 |
+
case 'home':
|
252 |
+
if ( count($act) > 0 ) {
|
253 |
+
$home_id = get_option('page_for_posts');
|
254 |
+
if ( $DW->wpml ) {
|
255 |
+
$home_id = $DW->wpml_get_id($home_id);
|
256 |
+
$DW->message('WPML ObjectID: ' . $home_id);
|
257 |
+
}
|
258 |
+
|
259 |
+
if ( in_array($home_id, $act) ) {
|
260 |
$display = $other;
|
261 |
+
$DW->message('Exception triggered for ' . $widget_id . ' sets display to ' . $e . ' (rule EH1)');
|
262 |
}
|
263 |
}
|
264 |
+
break;
|
265 |
+
|
266 |
+
case 'page':
|
267 |
+
if ( count($act) > 0 ) {
|
268 |
+
$post = $GLOBALS['post'];
|
269 |
+
$id = $post->ID;
|
270 |
+
if ( $DW->wpml ) {
|
271 |
+
$id = $DW->wpml_get_id($id);
|
272 |
+
$DW->message('WPML ObjectID: ' . $id);
|
273 |
+
}
|
274 |
+
|
275 |
+
if ( in_array($id, $act) ) {
|
276 |
$display = $other;
|
277 |
+
$DW->message('Exception triggered for ' . $widget_id . ' sets display to ' . $e . ' (rule EP1)');
|
278 |
}
|
279 |
}
|
280 |
+
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
281 |
|
282 |
+
case 'author':
|
283 |
+
if ( count($act) > 0 && is_author($act) ) {
|
284 |
+
$display = $other;
|
285 |
+
$DW->message('Exception triggered for ' . $widget_id . ' sets display to ' . $e . ' (rule EA1)');
|
286 |
+
}
|
287 |
+
break;
|
288 |
|
289 |
+
case 'category':
|
290 |
+
if ( count($act) > 0 ) {
|
291 |
+
$category = get_the_category();
|
292 |
+
$id = $category[0]->cat_ID;
|
293 |
+
$DW->message('CatID: ' . $id);
|
294 |
+
if ( $DW->wpml ) {
|
295 |
+
$id = $DW->wpml_get_id($id, 'tax_category');
|
296 |
+
$DW->message('WPML ObjectID: ' . $id);
|
297 |
+
}
|
298 |
+
|
299 |
+
if ( in_array($id, $act) ) {
|
300 |
+
$display = $other;
|
301 |
+
$DW->message('Exception triggered for ' . $widget_id . ' sets display to ' . $e . ' (rule EC1)');
|
302 |
+
}
|
303 |
+
}
|
304 |
+
break;
|
305 |
+
} // END switch ( $whereami )
|
306 |
+
} // END if/else ( $custom_post_type )
|
307 |
} /* END if ( count($opt) > 0 ) */
|
308 |
|
309 |
if (! $display || ! $role || ! $date ) {
|
img/wpml_icon.png
ADDED
Binary file
|
readme.txt
CHANGED
@@ -4,13 +4,13 @@ Donate link:
|
|
4 |
Tags: widget, widgets, dynamic, sidebar, custom, rules, admin, conditional tags
|
5 |
Requires at least: 2.9.1
|
6 |
Tested up to: 3.0
|
7 |
-
Stable tag: 1.3.
|
8 |
|
9 |
Dynamic Widgets gives you more control over your widgets. It lets you dynamicly place widgets on WordPress pages.
|
10 |
|
11 |
== Description ==
|
12 |
|
13 |
-
Dynamic Widgets gives you more control over your widgets. It lets you dynamicly place widgets on WordPress pages by excluding or including rules by role, dates, for the homepage, single posts, pages, authors, categories, archives, error and
|
14 |
|
15 |
* Default widget display setting is supported for:
|
16 |
- User roles
|
@@ -23,6 +23,7 @@ Dynamic Widgets gives you more control over your widgets. It lets you dynamicly
|
|
23 |
- Archive pages
|
24 |
- Error Page
|
25 |
- Search Page
|
|
|
26 |
* Exceptions can be created for:
|
27 |
- User roles on role, including not logged in (anonymous) users
|
28 |
- Dates on from, to or range
|
@@ -30,6 +31,7 @@ Dynamic Widgets gives you more control over your widgets. It lets you dynamicly
|
|
30 |
- Pages on Page Title
|
31 |
- Author pages on Author
|
32 |
- Category pages on Category name
|
|
|
33 |
|
34 |
== Installation ==
|
35 |
|
@@ -56,6 +58,10 @@ For the latest FAQ, please visit the [online FAQ](http://www.qurl.nl/faq/).
|
|
56 |
|
57 |
Start immediately looking for another hoster. YES, immediately! NOW! Pronto! PHP4 was introduced in the year 2000 and is [not supported](http://en.wikipedia.org/wiki/PHP#Release_history) anymore. As I don't have PHP4 anymore, I can only be sure for about 80% the plugin will work. Please let me know if it doesn't. I'll try to work out a solution.
|
58 |
|
|
|
|
|
|
|
|
|
59 |
= I checked the "Make exception rule available to individual posts and tags" option, but nothing happens. =
|
60 |
|
61 |
Did you save the options? If you did, you may try to hit the (i) icon a bit to the right and read the text which appears below.
|
@@ -82,7 +88,17 @@ Please file a [bugreport](http://www.qurl.nl/bugreport/). Please note the proced
|
|
82 |
|
83 |
== Changelog ==
|
84 |
|
85 |
-
= Version 1.3.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
|
87 |
* Maintenance release for WordPress 3.0 support.
|
88 |
|
@@ -92,7 +108,7 @@ Please file a [bugreport](http://www.qurl.nl/bugreport/). Please note the proced
|
|
92 |
|
93 |
= Version 1.2.6 =
|
94 |
|
95 |
-
* Another bugfix try for nasty PHP warning "Cannot use a scalar value as an array"
|
96 |
|
97 |
= Version 1.2.5 =
|
98 |
|
4 |
Tags: widget, widgets, dynamic, sidebar, custom, rules, admin, conditional tags
|
5 |
Requires at least: 2.9.1
|
6 |
Tested up to: 3.0
|
7 |
+
Stable tag: 1.3.3
|
8 |
|
9 |
Dynamic Widgets gives you more control over your widgets. It lets you dynamicly place widgets on WordPress pages.
|
10 |
|
11 |
== Description ==
|
12 |
|
13 |
+
Dynamic Widgets gives you more control over your widgets. It lets you dynamicly place widgets on WordPress pages by excluding or including rules by role, dates, for the homepage, single posts, pages, authors, categories, archives, error page, search page and custom post types.
|
14 |
|
15 |
* Default widget display setting is supported for:
|
16 |
- User roles
|
23 |
- Archive pages
|
24 |
- Error Page
|
25 |
- Search Page
|
26 |
+
- Custom Post Types (since WordPress 3.0)
|
27 |
* Exceptions can be created for:
|
28 |
- User roles on role, including not logged in (anonymous) users
|
29 |
- Dates on from, to or range
|
31 |
- Pages on Page Title
|
32 |
- Author pages on Author
|
33 |
- Category pages on Category name
|
34 |
+
- Custom Posts Type on Custom post name (since WordPress 3.0)
|
35 |
|
36 |
== Installation ==
|
37 |
|
58 |
|
59 |
Start immediately looking for another hoster. YES, immediately! NOW! Pronto! PHP4 was introduced in the year 2000 and is [not supported](http://en.wikipedia.org/wiki/PHP#Release_history) anymore. As I don't have PHP4 anymore, I can only be sure for about 80% the plugin will work. Please let me know if it doesn't. I'll try to work out a solution.
|
60 |
|
61 |
+
= Does the plugin work on WordPress 3.0 MU? =
|
62 |
+
|
63 |
+
Yes, but only if you activate the plugin on a per site base. Network Activation is not supported.
|
64 |
+
|
65 |
= I checked the "Make exception rule available to individual posts and tags" option, but nothing happens. =
|
66 |
|
67 |
Did you save the options? If you did, you may try to hit the (i) icon a bit to the right and read the text which appears below.
|
88 |
|
89 |
== Changelog ==
|
90 |
|
91 |
+
= Version 1.3.3 =
|
92 |
+
|
93 |
+
* Added Custom Post Types support for WordPress 3.0.
|
94 |
+
* Added WPML support for static pages, category pages, category in single posts and custom post types.
|
95 |
+
* Bugfix for not resetting checked count when enabling individual posts with authors and/or category set.
|
96 |
+
|
97 |
+
= Version 1.3.2 =
|
98 |
+
|
99 |
+
* Added an internal filter when checking for widget options to make the plugin faster.
|
100 |
+
|
101 |
+
= Version 1.3.1 =
|
102 |
|
103 |
* Maintenance release for WordPress 3.0 support.
|
104 |
|
108 |
|
109 |
= Version 1.2.6 =
|
110 |
|
111 |
+
* Another bugfix try for nasty PHP warning "Cannot use a scalar value as an array".
|
112 |
|
113 |
= Version 1.2.5 =
|
114 |
|