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.5 |
Comparing to | |
See all releases |
Code changes from version 1.3.4 to 1.3.5
- dynamic-widgets.php +30 -11
- dynwid_admin.php +2 -2
- dynwid_admin_overview.php +22 -1
- dynwid_class.php +5 -4
- dynwid_class_php4.php +5 -4
- dynwid_init_worker.php +51 -0
- dynwid_worker.php +15 -51
- readme.txt +22 -3
dynamic-widgets.php
CHANGED
@@ -4,7 +4,7 @@
|
|
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.
|
8 |
* Author URI: http://www.qurl.nl/
|
9 |
* Tags: widget, widgets, dynamic, sidebar, custom, rules, admin, conditional tags
|
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
|
19 |
*/
|
20 |
|
21 |
/*
|
@@ -30,7 +30,8 @@
|
|
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('
|
|
|
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
|
@@ -269,6 +270,22 @@
|
|
269 |
}
|
270 |
}
|
271 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
272 |
function dynwid_init() {
|
273 |
$GLOBALS['DW'] = new dynWid();
|
274 |
|
@@ -279,14 +296,14 @@
|
|
279 |
}
|
280 |
|
281 |
add_action('admin_menu', 'dynwid_add_admin_menu');
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
add_action('plugin_action_links_' . plugin_basename(__FILE__), 'dynwid_add_plugin_actions');
|
286 |
-
|
287 |
-
|
288 |
} else {
|
289 |
-
add_action('wp_head', '
|
290 |
}
|
291 |
}
|
292 |
|
@@ -469,9 +486,11 @@
|
|
469 |
echo '</p>';
|
470 |
}
|
471 |
|
472 |
-
function dynwid_worker() {
|
473 |
$DW = &$GLOBALS['DW'];
|
474 |
-
|
|
|
|
|
475 |
}
|
476 |
|
477 |
// Hooks
|
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.5
|
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 280742 2010-08-25 19:51:20Z qurl $
|
19 |
*/
|
20 |
|
21 |
/*
|
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_OLD_METHOD', get_option('dynwid_old_method'));
|
34 |
+
define('DW_VERSION', '1.3.5');
|
35 |
define('DW_VERSION_URL_CHECK', 'http://www.qurl.nl/wp-content/uploads/php/dw_version.php?v=' . DW_VERSION . '&n=');
|
36 |
define('DW_WPML_API', '/inc/wpml-api.php'); // WPML Plugin support - API file relative to ICL_PLUGIN_PATH
|
37 |
define('DW_WPML_ICON', 'img/wpml_icon.png'); // WPML Plugin support - WPML icon
|
270 |
}
|
271 |
}
|
272 |
|
273 |
+
function dynwid_filter_init() {
|
274 |
+
$DW = &$GLOBALS['DW'];
|
275 |
+
require(dirname(__FILE__) . '/dynwid_init_worker.php');
|
276 |
+
}
|
277 |
+
|
278 |
+
function dynwid_filter_widgets() {
|
279 |
+
$DW = &$GLOBALS['DW'];
|
280 |
+
|
281 |
+
dynwid_filter_init();
|
282 |
+
if ( DW_OLD_METHOD ) {
|
283 |
+
dynwid_worker($DW->sidebars);
|
284 |
+
} else {
|
285 |
+
add_filter('sidebars_widgets', 'dynwid_worker');
|
286 |
+
}
|
287 |
+
}
|
288 |
+
|
289 |
function dynwid_init() {
|
290 |
$GLOBALS['DW'] = new dynWid();
|
291 |
|
296 |
}
|
297 |
|
298 |
add_action('admin_menu', 'dynwid_add_admin_menu');
|
299 |
+
add_action('edit_tag_form_fields', 'dynwid_add_tag_page');
|
300 |
+
add_action('edited_term', 'dynwid_save_tagdata');
|
301 |
+
add_action('in_plugin_update_message-' . plugin_basename(__FILE__), 'dynwid_check_version', 10, 2);
|
302 |
add_action('plugin_action_links_' . plugin_basename(__FILE__), 'dynwid_add_plugin_actions');
|
303 |
+
add_action('save_post', 'dynwid_save_postdata');
|
304 |
+
add_action('sidebar_admin_setup', 'dynwid_add_widget_control');
|
305 |
} else {
|
306 |
+
add_action('wp_head', 'dynwid_filter_widgets');
|
307 |
}
|
308 |
}
|
309 |
|
486 |
echo '</p>';
|
487 |
}
|
488 |
|
489 |
+
function dynwid_worker($sidebars) {
|
490 |
$DW = &$GLOBALS['DW'];
|
491 |
+
require(dirname(__FILE__) . '/dynwid_worker.php');
|
492 |
+
|
493 |
+
return $sidebars;
|
494 |
}
|
495 |
|
496 |
// Hooks
|
dynwid_admin.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* dynwid_admin.php - Startpage for admin
|
4 |
*
|
5 |
-
* @version $Id: dynwid_admin.php
|
6 |
*/
|
7 |
?>
|
8 |
|
@@ -24,7 +24,7 @@
|
|
24 |
<!-- Footer //-->
|
25 |
<div class="clear"><br /><br /></div>
|
26 |
<div><small>
|
27 |
-
<a href="http://www.qurl.nl/dynamic-widgets/" target="_blank">Dynamic Widgets</a> v<?php echo DW_VERSION; ?> (<?php echo DW_CLASSFILE; ?>)
|
28 |
</small></div>
|
29 |
|
30 |
</div> <!-- /wrap //-->
|
2 |
/**
|
3 |
* dynwid_admin.php - Startpage for admin
|
4 |
*
|
5 |
+
* @version $Id: dynwid_admin.php 280742 2010-08-25 19:51:20Z qurl $
|
6 |
*/
|
7 |
?>
|
8 |
|
24 |
<!-- Footer //-->
|
25 |
<div class="clear"><br /><br /></div>
|
26 |
<div><small>
|
27 |
+
<a href="http://www.qurl.nl/dynamic-widgets/" target="_blank">Dynamic Widgets</a> v<?php echo DW_VERSION; ?> (<?php echo ( DW_CLASSFILE == 'dynwid_class_php4.php' ? 'PHP4' : 'PHP5' ) . ', ' . ( DW_OLD_METHOD ? 'OLD' : 'FILTER' ); ?>)
|
28 |
</small></div>
|
29 |
|
30 |
</div> <!-- /wrap //-->
|
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 |
*/
|
7 |
|
8 |
// Special case: Reset action needs to go back to overview.
|
@@ -15,6 +15,18 @@
|
|
15 |
<strong>Widget options have been reset to default.</strong><br />
|
16 |
</p>
|
17 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
<?php
|
19 |
}
|
20 |
|
@@ -94,6 +106,15 @@
|
|
94 |
?>
|
95 |
.<br />
|
96 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
<br />
|
98 |
For debugging purposes it is possible you're asked to create a dump. Click the 'Create dump' button and save the text file.
|
99 |
<br /><br />
|
2 |
/**
|
3 |
* dynwid_admin_overview.php - Overview page
|
4 |
*
|
5 |
+
* @version $Id: dynwid_admin_overview.php 280742 2010-08-25 19:51:20Z qurl $
|
6 |
*/
|
7 |
|
8 |
// Special case: Reset action needs to go back to overview.
|
15 |
<strong>Widget options have been reset to default.</strong><br />
|
16 |
</p>
|
17 |
</div>
|
18 |
+
<?php
|
19 |
+
}
|
20 |
+
if ( $_GET['action'] == 'dynwid_set_method' ) {
|
21 |
+
if ( $_GET['oldmethod'] == 'on' ) {
|
22 |
+
update_option('dynwid_old_method', TRUE);
|
23 |
+
} else {
|
24 |
+
update_option('dynwid_old_method', FALSE);
|
25 |
+
}
|
26 |
+
?>
|
27 |
+
<div class="updated fade" id="message">
|
28 |
+
<p><strong>Method set to <?php echo ( get_option('dynwid_old_method') ? '\'OLD\'' : '\'FILTER\'' ); ?>.</strong></p>
|
29 |
+
</div>
|
30 |
<?php
|
31 |
}
|
32 |
|
106 |
?>
|
107 |
.<br />
|
108 |
|
109 |
+
<br />
|
110 |
+
<div id="method">
|
111 |
+
<form id="dynwid_method" action="" method="get">
|
112 |
+
<input type="hidden" name="page" value="dynwid-config" />
|
113 |
+
<input type="hidden" name="action" value="dynwid_set_method" />
|
114 |
+
<input type="checkbox" id="oldmethod" name="oldmethod" <?php echo ( get_option('dynwid_old_method') ? 'checked="checked"' : '' ) ?> onchange="document.getElementById('dynwid_method').submit();" /> <label for="oldmethod">Use 'OLD' method</label>
|
115 |
+
</form>
|
116 |
+
</div>
|
117 |
+
|
118 |
<br />
|
119 |
For debugging purposes it is possible you're asked to create a dump. Click the 'Create dump' button and save the text file.
|
120 |
<br /><br />
|
dynwid_class.php
CHANGED
@@ -2,10 +2,11 @@
|
|
2 |
/**
|
3 |
* dynwid_class.php - Dynamic Widgets Class (PHP5)
|
4 |
*
|
5 |
-
* @version $Id: dynwid_class.php
|
6 |
*/
|
7 |
|
8 |
class dynWid {
|
|
|
9 |
private $dbtable;
|
10 |
public $dynwid_list;
|
11 |
private $firstmessage;
|
@@ -15,6 +16,7 @@
|
|
15 |
public $sidebars;
|
16 |
public $plugin_url;
|
17 |
public $userrole;
|
|
|
18 |
private $wpdb;
|
19 |
public $wpml; // WPML Plugin support
|
20 |
|
@@ -25,6 +27,7 @@
|
|
25 |
$this->userrole = array('anonymous');
|
26 |
}
|
27 |
|
|
|
28 |
$this->firstmessage = TRUE;
|
29 |
$this->registered_sidebars = $GLOBALS['wp_registered_sidebars'];
|
30 |
$this->registered_widget_controls = &$GLOBALS['wp_registered_widget_controls'];
|
@@ -37,8 +40,6 @@
|
|
37 |
|
38 |
// WPML Plugin support
|
39 |
$this->wpml = FALSE;
|
40 |
-
|
41 |
-
// $this->createList();
|
42 |
}
|
43 |
|
44 |
public function addDate($widget_id, $dates) {
|
@@ -198,7 +199,7 @@
|
|
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 ) {
|
2 |
/**
|
3 |
* dynwid_class.php - Dynamic Widgets Class (PHP5)
|
4 |
*
|
5 |
+
* @version $Id: dynwid_class.php 280742 2010-08-25 19:51:20Z qurl $
|
6 |
*/
|
7 |
|
8 |
class dynWid {
|
9 |
+
public $custom_post_type;
|
10 |
private $dbtable;
|
11 |
public $dynwid_list;
|
12 |
private $firstmessage;
|
16 |
public $sidebars;
|
17 |
public $plugin_url;
|
18 |
public $userrole;
|
19 |
+
public $whereami;
|
20 |
private $wpdb;
|
21 |
public $wpml; // WPML Plugin support
|
22 |
|
27 |
$this->userrole = array('anonymous');
|
28 |
}
|
29 |
|
30 |
+
$this->custom_post_type = FALSE;
|
31 |
$this->firstmessage = TRUE;
|
32 |
$this->registered_sidebars = $GLOBALS['wp_registered_sidebars'];
|
33 |
$this->registered_widget_controls = &$GLOBALS['wp_registered_widget_controls'];
|
40 |
|
41 |
// WPML Plugin support
|
42 |
$this->wpml = FALSE;
|
|
|
|
|
43 |
}
|
44 |
|
45 |
public function addDate($widget_id, $dates) {
|
199 |
$whereami = 'page';
|
200 |
}
|
201 |
|
202 |
+
$query = "SELECT DISTINCT widget_id FROM " . $this->dbtable . "
|
203 |
WHERE maintype LIKE '" . $whereami . "%' OR maintype = 'role' OR maintype = 'date'";
|
204 |
$results = $this->wpdb->get_results($query);
|
205 |
foreach ( $results as $myrow ) {
|
dynwid_class_php4.php
CHANGED
@@ -3,10 +3,11 @@
|
|
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 {
|
|
|
10 |
var $dbtable; /* private */
|
11 |
var $dynwid_list;
|
12 |
var $firstmessage; /* private */
|
@@ -16,6 +17,7 @@
|
|
16 |
var $sidebars;
|
17 |
var $plugin_url;
|
18 |
var $userrole;
|
|
|
19 |
var $wpdb; /* private */
|
20 |
var $wpml; /* WPML Plugin support */
|
21 |
|
@@ -31,6 +33,7 @@
|
|
31 |
$this->userrole = array('anonymous');
|
32 |
}
|
33 |
|
|
|
34 |
$this->firstmessage = TRUE;
|
35 |
$this->registered_sidebars = $GLOBALS['wp_registered_sidebars'];
|
36 |
$this->registered_widget_controls = &$GLOBALS['wp_registered_widget_controls'];
|
@@ -43,8 +46,6 @@
|
|
43 |
|
44 |
// WPML Plugin support
|
45 |
$this->wpml = FALSE;
|
46 |
-
|
47 |
-
// $this->createList();
|
48 |
}
|
49 |
|
50 |
function addDate($widget_id, $dates) {
|
@@ -205,7 +206,7 @@
|
|
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 ) {
|
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 280742 2010-08-25 19:51:20Z qurl $
|
7 |
*/
|
8 |
|
9 |
class dynWid {
|
10 |
+
var $custom_post_type;
|
11 |
var $dbtable; /* private */
|
12 |
var $dynwid_list;
|
13 |
var $firstmessage; /* private */
|
17 |
var $sidebars;
|
18 |
var $plugin_url;
|
19 |
var $userrole;
|
20 |
+
var $whereami;
|
21 |
var $wpdb; /* private */
|
22 |
var $wpml; /* WPML Plugin support */
|
23 |
|
33 |
$this->userrole = array('anonymous');
|
34 |
}
|
35 |
|
36 |
+
$this->custom_post_type = FALSE;
|
37 |
$this->firstmessage = TRUE;
|
38 |
$this->registered_sidebars = $GLOBALS['wp_registered_sidebars'];
|
39 |
$this->registered_widget_controls = &$GLOBALS['wp_registered_widget_controls'];
|
46 |
|
47 |
// WPML Plugin support
|
48 |
$this->wpml = FALSE;
|
|
|
|
|
49 |
}
|
50 |
|
51 |
function addDate($widget_id, $dates) {
|
206 |
$whereami = 'page';
|
207 |
}
|
208 |
|
209 |
+
$query = "SELECT DISTINCT widget_id FROM " . $this->dbtable . "
|
210 |
WHERE maintype LIKE '" . $whereami . "%' OR maintype = 'role' OR maintype = 'date'";
|
211 |
$results = $this->wpdb->get_results($query);
|
212 |
foreach ( $results as $myrow ) {
|
dynwid_init_worker.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* dynwid_init_worker.php
|
5 |
+
*
|
6 |
+
* @version $Id: dynwid_init_worker.php 280742 2010-08-25 19:51:20Z qurl $
|
7 |
+
* @copyright 2010 Jacco Drabbe
|
8 |
+
*/
|
9 |
+
|
10 |
+
$DW->message('Dynamic Widgets INIT');
|
11 |
+
|
12 |
+
// WPML Plugin Support
|
13 |
+
if ( defined('ICL_PLUGIN_PATH') ) {
|
14 |
+
$wpml_api = ICL_PLUGIN_PATH . DW_WPML_API;
|
15 |
+
|
16 |
+
if ( file_exists($wpml_api) ) {
|
17 |
+
require_once($wpml_api);
|
18 |
+
|
19 |
+
$wpmlang = wpml_get_default_language();
|
20 |
+
$curlang = wpml_get_current_language();
|
21 |
+
|
22 |
+
if ( $wpmlang != $curlang ) {
|
23 |
+
$DW->wpml = TRUE;
|
24 |
+
$DW->message('WPML enabled, default language: ' . $wpmlang);
|
25 |
+
}
|
26 |
+
}
|
27 |
+
}
|
28 |
+
|
29 |
+
$DW->message('User has role(s): ' . implode(', ', $DW->userrole));
|
30 |
+
|
31 |
+
$custom_post_type = FALSE;
|
32 |
+
$DW->whereami = $DW->detectPage();
|
33 |
+
$DW->message('Page is ' . $DW->whereami);
|
34 |
+
if ( $DW->whereami == 'single' ) {
|
35 |
+
$post = $GLOBALS['post'];
|
36 |
+
$DW->message('post_id = ' . $post->ID);
|
37 |
+
|
38 |
+
/* WordPress 3.0 and higher: Custom Post Types */
|
39 |
+
if ( version_compare($GLOBALS['wp_version'], '3.0', '>=') ) {
|
40 |
+
$post_type = get_post_type($post);
|
41 |
+
$DW->message('Post Type = ' . $post_type);
|
42 |
+
if ( $post_type != 'post' ) {
|
43 |
+
$DW->custom_post_type = TRUE;
|
44 |
+
$DW->whereami = $post_type;
|
45 |
+
$DW->message('Custom Post Type detected, page changed to ' . $DW->whereami);
|
46 |
+
}
|
47 |
+
}
|
48 |
+
}
|
49 |
+
$DW->dwList($DW->whereami);
|
50 |
+
|
51 |
+
?>
|
dynwid_worker.php
CHANGED
@@ -2,58 +2,18 @@
|
|
2 |
/**
|
3 |
* dynwid_worker.php - The worker does the actual work.
|
4 |
*
|
5 |
-
* @version $Id: dynwid_worker.php
|
6 |
*/
|
7 |
|
8 |
-
|
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
|
51 |
if ( $sidebar_id != 'wp_inactive_widgets' && count($widgets) > 0 ) {
|
52 |
-
foreach ( $widgets as $widget_id ) {
|
53 |
// Check if the widget has options set
|
54 |
if ( in_array($widget_id, $DW->dynwid_list) ) {
|
55 |
$act = array();
|
56 |
-
|
|
|
57 |
$DW->message('Number of rules to check for widget ' . $widget_id . ': ' . count($opt));
|
58 |
$display = TRUE;
|
59 |
$role = TRUE;
|
@@ -141,7 +101,7 @@
|
|
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;
|
@@ -158,7 +118,7 @@
|
|
158 |
}
|
159 |
} else {
|
160 |
// no custom post type
|
161 |
-
switch ( $whereami ) {
|
162 |
case 'single':
|
163 |
$act_author = array();
|
164 |
$act_category = array();
|
@@ -302,13 +262,17 @@
|
|
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 ) {
|
310 |
-
$DW->message('Removed ' . $widget_id . ' from display');
|
311 |
-
|
|
|
|
|
|
|
|
|
312 |
}
|
313 |
} // END if ( in_array($widget_id, $DW->dynwid_list) )
|
314 |
} // END foreach ( $widgets as $widget_id )
|
2 |
/**
|
3 |
* dynwid_worker.php - The worker does the actual work.
|
4 |
*
|
5 |
+
* @version $Id: dynwid_worker.php 280742 2010-08-25 19:51:20Z qurl $
|
6 |
*/
|
7 |
|
8 |
+
foreach ( $sidebars as $sidebar_id => $widgets ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
// Only processing active sidebars with widgets
|
10 |
if ( $sidebar_id != 'wp_inactive_widgets' && count($widgets) > 0 ) {
|
11 |
+
foreach ( $widgets as $widget_key => $widget_id ) {
|
12 |
// Check if the widget has options set
|
13 |
if ( in_array($widget_id, $DW->dynwid_list) ) {
|
14 |
$act = array();
|
15 |
+
$DW->message('WhereAmI = ' . $DW->whereami);
|
16 |
+
$opt = $DW->getOptions($widget_id, $DW->whereami, FALSE);
|
17 |
$DW->message('Number of rules to check for widget ' . $widget_id . ': ' . count($opt));
|
18 |
$display = TRUE;
|
19 |
$role = TRUE;
|
101 |
$e = ( $other ) ? 'TRUE' : 'FALSE';
|
102 |
|
103 |
// Display exceptions (custom post type)
|
104 |
+
if ( $DW->custom_post_type ) {
|
105 |
// Custom Post Type behaves the same as a single post
|
106 |
if ( count($act) > 0 ) {
|
107 |
$id = $post->ID;
|
118 |
}
|
119 |
} else {
|
120 |
// no custom post type
|
121 |
+
switch ( $DW->whereami ) {
|
122 |
case 'single':
|
123 |
$act_author = array();
|
124 |
$act_category = array();
|
262 |
}
|
263 |
}
|
264 |
break;
|
265 |
+
} // END switch ( $DW->whereami )
|
266 |
+
} // END if/else ( $DW->custom_post_type )
|
267 |
} /* END if ( count($opt) > 0 ) */
|
268 |
|
269 |
if (! $display || ! $role || ! $date ) {
|
270 |
+
$DW->message('Removed ' . $widget_id . ' from display, SID = ' . $sidebar_id . ' / WID = ' . $widget_id . ' / KID = ' . $widget_key);
|
271 |
+
if ( DW_OLD_METHOD ) {
|
272 |
+
unset($DW->registered_widgets[$widget_id]);
|
273 |
+
} else {
|
274 |
+
unset($sidebars[$sidebar_id][$widget_key]);
|
275 |
+
}
|
276 |
}
|
277 |
} // END if ( in_array($widget_id, $DW->dynwid_list) )
|
278 |
} // END foreach ( $widgets as $widget_id )
|
readme.txt
CHANGED
@@ -3,14 +3,14 @@ Contributors: Qurl
|
|
3 |
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 page, search page and custom post types.
|
14 |
|
15 |
* Default widget display setting is supported for:
|
16 |
- User roles
|
@@ -66,6 +66,14 @@ Yes, but only if you activate the plugin on a per site base. Network Activation
|
|
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.
|
68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
= You asked me to create a dump. How do I do that? =
|
70 |
|
71 |
* Click at the bottom of the Widgets Overview page on the 'Advanced >' link.
|
@@ -86,8 +94,19 @@ Please file a [bugreport](http://www.qurl.nl/bugreport/). Please note the proced
|
|
86 |
* Confirm you really want to uninstall the plugin. After the cleanup, the plugin is deactivated automaticly.
|
87 |
* Remove the directory 'dynamic-widgets' underneath to the `/wp-content/plugins/` directory.
|
88 |
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
== Changelog ==
|
90 |
|
|
|
|
|
|
|
|
|
|
|
91 |
= Version 1.3.4 =
|
92 |
|
93 |
* Bugfix for minor flaw "Invalid argument supplied for foreach() in dynwid_admin_save.php on line 203"
|
3 |
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.1
|
7 |
+
Stable tag: 1.3.5
|
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 with just a few mouse clicks 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
|
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.
|
68 |
|
69 |
+
= The plugin slows down the loading of a page dramatically. Can you do something about it? =
|
70 |
+
|
71 |
+
Try setting the plugin to the 'OLD' method. You can do this by clicking on the 'Advanced >' link at the bottom of the Widgets Overview page and check the box next to 'Use OLD method'. See if that helps. Setting the plugin using the 'OLD' method comes with a downside unfortunately. It may leave you behind with a visible empty sidebar.
|
72 |
+
|
73 |
+
= I want in Page X the sidebar becomes empty, but instead several widgets are shown in that sidebar. Am I doing something wrong? =
|
74 |
+
|
75 |
+
Your theme probably uses a 'default display widgets policy'. When a sidebar becomes empty, the theme detects this and places widgets by default in it. The plugin can't do anything about that. Ask the theme creator how to fix this.
|
76 |
+
|
77 |
= You asked me to create a dump. How do I do that? =
|
78 |
|
79 |
* Click at the bottom of the Widgets Overview page on the 'Advanced >' link.
|
94 |
* Confirm you really want to uninstall the plugin. After the cleanup, the plugin is deactivated automaticly.
|
95 |
* Remove the directory 'dynamic-widgets' underneath to the `/wp-content/plugins/` directory.
|
96 |
|
97 |
+
== Release notes ==
|
98 |
+
|
99 |
+
Starting with version 1.3.5 Dynamic Widgets is using a new method for removing widgets from the sidebar(s). This new method, called FILTER, is more in line with the way WordPress provides access for plugins to it's system. However this method comes with a downside. Due to it's nature it might slow down the process of removing widgets when you have and use many sidebars. For this, there is the OLD method. The OLD method uses the previous method before version 1.3.5. Downside of that method is it may leave you behind with a visible empty sidebar. There is a way to prevent this, but for that you have to have some PHP programming knowledge. Ask me for an example script if you need it. If you are using the standard WP Twenty Ten theme, you probably want to have a look at the [Twenty Ten Weaver](http://wpweaver.info/themes/twenty-ten-weaver/) theme. Bruce from WP Weaver fixed the empty sidebar with the help of this example script. So you don't need to fix it yourself.
|
100 |
+
|
101 |
+
You can switch to the OLD method by clicking on the 'Advanced >' link in the Dynamic Widgets overview page and checking 'Use OLD method'.
|
102 |
+
|
103 |
== Changelog ==
|
104 |
|
105 |
+
= Version 1.3.5 =
|
106 |
+
|
107 |
+
* Added support for themes which use the WP function is_active_sidebar() when the method is set to FILTER (default).
|
108 |
+
* Bugfix by removing a possible unnecessary loop for dynamic widget options.
|
109 |
+
|
110 |
= Version 1.3.4 =
|
111 |
|
112 |
* Bugfix for minor flaw "Invalid argument supplied for foreach() in dynwid_admin_save.php on line 203"
|