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 re-activate the plugin.
Download this release
Release Info
Developer | qurl |
Plugin | Dynamic Widgets |
Version | 1.1 |
Comparing to | |
See all releases |
Code changes from version 1.0 to 1.1
- dynamic-widgets.php +12 -10
- dynwid_admin.php +3 -4
- dynwid_admin_edit.php +110 -24
- dynwid_admin_save.php +13 -3
- dynwid_class.php +29 -11
- dynwid_worker.php +17 -4
- readme.txt +30 -11
- screenshot-1.jpg +0 -0
- screenshot-2.jpg +0 -0
dynamic-widgets.php
CHANGED
@@ -1,27 +1,29 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* Plugin Name: Dynamic Widgets
|
4 |
-
* Plugin URI: http://www.qurl.nl/2010/
|
5 |
-
* Description: Dynamic Widgets gives you more control over your widgets. It lets you dynamicly place widgets on pages by excluding or including rules for the homepage, single posts, pages, categories and
|
6 |
* Author: Jacco
|
7 |
-
* Version: 1.
|
8 |
* Author URI: http://www.qurl.nl/
|
9 |
-
* Tags: widget, dynamic, sidebar, custom
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
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_DB_TABLE', 'dynamic_widgets');
|
23 |
define('DW_LIST_LIMIT', 20);
|
24 |
-
define('
|
|
|
|
|
25 |
|
26 |
// Functions
|
27 |
function dynwid_add_admin_menu() {
|
@@ -80,16 +82,16 @@
|
|
80 |
} */
|
81 |
update_option('dynwid_version', DW_VERSION);
|
82 |
}
|
83 |
-
|
84 |
function dynwid_uninstall() {
|
85 |
global $wpdb;
|
86 |
$dbtable = $wpdb->prefix . DW_DB_TABLE;
|
87 |
-
|
88 |
// Housekeeping
|
89 |
delete_option('dynwid_version');
|
90 |
$query = "DROP TABLE " . $dbtable;
|
91 |
$wpdb->query($query);
|
92 |
-
|
93 |
// Redirect to plugins page for deactivation
|
94 |
wp_redirect( get_option('siteurl') . '/wp-admin/plugins.php' );
|
95 |
die();
|
1 |
<?php
|
2 |
/**
|
3 |
* Plugin Name: Dynamic Widgets
|
4 |
+
* Plugin URI: http://www.qurl.nl/2010/02/dynamic-widgets-1-1/
|
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, for the homepage, single posts, pages, categories, archives and the error 404 page.
|
6 |
* Author: Jacco
|
7 |
+
* Version: 1.1
|
8 |
* Author URI: http://www.qurl.nl/
|
9 |
+
* Tags: widget, widgets, dynamic, sidebar, custom, rules
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
+
*
|
16 |
* Released under the GPL v.2, http://www.gnu.org/copyleft/gpl.html
|
17 |
*
|
18 |
+
* @version $Id: dynamic-widgets.php 202305 2010-02-05 18:19:21Z qurl $
|
19 |
*/
|
20 |
|
21 |
// Constants
|
22 |
define('DW_DB_TABLE', 'dynamic_widgets');
|
23 |
define('DW_LIST_LIMIT', 20);
|
24 |
+
define('DW_LIST_STYLE', 'style="overflow:auto;height:240px;"');
|
25 |
+
define('DW_VERSION', '1.1');
|
26 |
+
define('DEBUG', FALSE);
|
27 |
|
28 |
// Functions
|
29 |
function dynwid_add_admin_menu() {
|
82 |
} */
|
83 |
update_option('dynwid_version', DW_VERSION);
|
84 |
}
|
85 |
+
|
86 |
function dynwid_uninstall() {
|
87 |
global $wpdb;
|
88 |
$dbtable = $wpdb->prefix . DW_DB_TABLE;
|
89 |
+
|
90 |
// Housekeeping
|
91 |
delete_option('dynwid_version');
|
92 |
$query = "DROP TABLE " . $dbtable;
|
93 |
$wpdb->query($query);
|
94 |
+
|
95 |
// Redirect to plugins page for deactivation
|
96 |
wp_redirect( get_option('siteurl') . '/wp-admin/plugins.php' );
|
97 |
die();
|
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 |
require_once('dynwid_class.php');
|
@@ -33,7 +33,6 @@ default:
|
|
33 |
</p>
|
34 |
</div>
|
35 |
<?php } ?>
|
36 |
-
|
37 |
<style type="text/css">
|
38 |
.helpbox {
|
39 |
-moz-border-radius-topleft : 6px;
|
@@ -52,7 +51,7 @@ default:
|
|
52 |
<div class="helpbox">
|
53 |
<strong>Static / Dynamic</strong><br />
|
54 |
When a widget is <em>Static</em>, the widget uses the WordPress default. In other words, it's shown everywhere.<br />
|
55 |
-
A widget is <em>Dynamic</em> when there are options set
|
56 |
<br />
|
57 |
|
58 |
<strong>Reset</strong><br />
|
@@ -126,7 +125,7 @@ For debugging purposes it is possible you're asked to create a dump. Click the '
|
|
126 |
|
127 |
If you deceide not to use this plugin anymore (sorry to hear that!). You can cleanup all settings and data related to this plugin by clicking on the 'Uninstall' button. This process is irreversible! After the cleanup, you can deactivate the plugin.
|
128 |
<br /><br />
|
129 |
-
<div id="uninstall">
|
130 |
<form action="" method="get">
|
131 |
<input type="hidden" name="action" value="dynwid_uninstall" />
|
132 |
<input class="button-primary" type="submit" value="Uninstall" onclick="if ( confirm('Are you sure you want to uninstall Dynamic Widgets?') ) { return true; } return false;" />
|
2 |
/**
|
3 |
* dynwid_admin.php - Startpage for admin
|
4 |
*
|
5 |
+
* @version $Id: dynwid_admin.php 202305 2010-02-05 18:19:21Z qurl $
|
6 |
*/
|
7 |
|
8 |
require_once('dynwid_class.php');
|
33 |
</p>
|
34 |
</div>
|
35 |
<?php } ?>
|
|
|
36 |
<style type="text/css">
|
37 |
.helpbox {
|
38 |
-moz-border-radius-topleft : 6px;
|
51 |
<div class="helpbox">
|
52 |
<strong>Static / Dynamic</strong><br />
|
53 |
When a widget is <em>Static</em>, the widget uses the WordPress default. In other words, it's shown everywhere.<br />
|
54 |
+
A widget is <em>Dynamic</em> when there are options set, i.e. not showing on the front page.<br />
|
55 |
<br />
|
56 |
|
57 |
<strong>Reset</strong><br />
|
125 |
|
126 |
If you deceide not to use this plugin anymore (sorry to hear that!). You can cleanup all settings and data related to this plugin by clicking on the 'Uninstall' button. This process is irreversible! After the cleanup, you can deactivate the plugin.
|
127 |
<br /><br />
|
128 |
+
<div id="uninstall">
|
129 |
<form action="" method="get">
|
130 |
<input type="hidden" name="action" value="dynwid_uninstall" />
|
131 |
<input class="button-primary" type="submit" value="Uninstall" onclick="if ( confirm('Are you sure you want to uninstall Dynamic Widgets?') ) { return true; } return false;" />
|
dynwid_admin_edit.php
CHANGED
@@ -2,9 +2,39 @@
|
|
2 |
/**
|
3 |
* dynwid_admin_edit.php - Options settinfs
|
4 |
*
|
5 |
-
* @version $Id: dynwid_admin_edit.php
|
6 |
*/
|
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
// Front Page
|
9 |
$frontpage_yes_selected = 'checked="true"';
|
10 |
$opt_frontpage = $DW->getOptions($_GET['id'], 'front-page');
|
@@ -38,7 +68,7 @@
|
|
38 |
|
39 |
$authors = get_users_of_blog();
|
40 |
if ( count($authors) > DW_LIST_LIMIT ) {
|
41 |
-
$single_author_condition_select_style =
|
42 |
}
|
43 |
|
44 |
// -- Category
|
@@ -71,7 +101,7 @@
|
|
71 |
|
72 |
$pages = get_pages();
|
73 |
if ( count($pages) > DW_LIST_LIMIT ) {
|
74 |
-
$page_condition_select_style =
|
75 |
}
|
76 |
|
77 |
// Categories
|
@@ -95,7 +125,7 @@
|
|
95 |
|
96 |
$category = get_categories( array('hide_empty' => FALSE) );
|
97 |
if ( count($category) > DW_LIST_LIMIT ) {
|
98 |
-
$category_condition_select_style =
|
99 |
}
|
100 |
|
101 |
// Archives
|
@@ -108,8 +138,19 @@
|
|
108 |
unset($archive_yes_selected);
|
109 |
}
|
110 |
}
|
111 |
-
?>
|
112 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
|
114 |
<div id="adv"></div>
|
115 |
|
@@ -136,24 +177,6 @@ label {
|
|
136 |
}
|
137 |
</style>
|
138 |
|
139 |
-
<script type="text/javascript">
|
140 |
-
function tglinfo(id) {
|
141 |
-
var element = document.getElementById(id);
|
142 |
-
var display = 'd_';
|
143 |
-
display = display.concat(id);
|
144 |
-
|
145 |
-
if ( window[display] ) {
|
146 |
-
element.style.display = 'none';
|
147 |
-
window[display] = false;
|
148 |
-
} else {
|
149 |
-
element.style.display = 'inline';
|
150 |
-
window[display] = true;
|
151 |
-
}
|
152 |
-
}
|
153 |
-
var d_single = false;
|
154 |
-
var d_archive = false;
|
155 |
-
</script>
|
156 |
-
|
157 |
<?php if ( $_POST['dynwid_save'] == 'yes' ) { ?>
|
158 |
<div class="updated fade" id="message">
|
159 |
<p>
|
@@ -175,6 +198,24 @@ label {
|
|
175 |
<input type="hidden" name="dynwid_save" value="yes" />
|
176 |
<input type="hidden" name="widget_id" value="<?php echo $_GET['id']; ?>" />
|
177 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
<b>Front Page</b><br />
|
179 |
Show widget on the front page?<br />
|
180 |
<input type="radio" name="front-page" value="yes" id="front-page-yes" <?php echo $frontpage_yes_selected; ?> /> <label for="front-page-yes">Yes</label>
|
@@ -254,10 +295,55 @@ Show widget on archive pages?<br />
|
|
254 |
|
255 |
<br /><br />
|
256 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
257 |
<input class="button-primary" type="submit" value="Save" />
|
258 |
</form>
|
259 |
|
260 |
<form action="themes.php" method="get">
|
261 |
<input type="hidden" name="page" value="dynwid-config" />
|
262 |
<input class="button-secondary" type="submit" value="Cancel" style="position:relative;top:-23px;left:80px;" />
|
263 |
-
</form>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
/**
|
3 |
* dynwid_admin_edit.php - Options settinfs
|
4 |
*
|
5 |
+
* @version $Id: dynwid_admin_edit.php 202305 2010-02-05 18:19:21Z qurl $
|
6 |
*/
|
7 |
|
8 |
+
// Roles
|
9 |
+
global $wp_roles;
|
10 |
+
$roles = array_merge($wp_roles->role_names, array('anonymous' => 'Anonymous|User role'));
|
11 |
+
$jsroles = array();
|
12 |
+
foreach ( $roles as $rid => $role ) {
|
13 |
+
$roles[esc_attr($rid)] = translate_user_role($role);
|
14 |
+
$jsroles[ ] = '\'role_act_' . esc_attr($rid) . '\''; // Prep for JS Array
|
15 |
+
}
|
16 |
+
if ( count($roles) > DW_LIST_LIMIT ) {
|
17 |
+
$role_condition_select_style = DW_LIST_STYLE;
|
18 |
+
}
|
19 |
+
|
20 |
+
$role_yes_selected = 'checked="true"';
|
21 |
+
$opt_role = $DW->getOptions($_GET['id'], 'role');
|
22 |
+
if ( count($opt_role) > 0 ) {
|
23 |
+
$role_act = array();
|
24 |
+
foreach ( $opt_role as $role_condition ) {
|
25 |
+
if ( $role_condition['name'] == 'default' || empty($role_condition['name']) ) {
|
26 |
+
$role_default = $role_condition['value'];
|
27 |
+
} else {
|
28 |
+
$role_act[ ] = $role_condition['name'];
|
29 |
+
}
|
30 |
+
}
|
31 |
+
|
32 |
+
if ( $role_default == '0' ) {
|
33 |
+
$role_no_selected = $role_yes_selected;
|
34 |
+
unset($role_yes_selected);
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
// Front Page
|
39 |
$frontpage_yes_selected = 'checked="true"';
|
40 |
$opt_frontpage = $DW->getOptions($_GET['id'], 'front-page');
|
68 |
|
69 |
$authors = get_users_of_blog();
|
70 |
if ( count($authors) > DW_LIST_LIMIT ) {
|
71 |
+
$single_author_condition_select_style = DW_LIST_STYLE;
|
72 |
}
|
73 |
|
74 |
// -- Category
|
101 |
|
102 |
$pages = get_pages();
|
103 |
if ( count($pages) > DW_LIST_LIMIT ) {
|
104 |
+
$page_condition_select_style = DW_LIST_STYLE;
|
105 |
}
|
106 |
|
107 |
// Categories
|
125 |
|
126 |
$category = get_categories( array('hide_empty' => FALSE) );
|
127 |
if ( count($category) > DW_LIST_LIMIT ) {
|
128 |
+
$category_condition_select_style = DW_LIST_STYLE;
|
129 |
}
|
130 |
|
131 |
// Archives
|
138 |
unset($archive_yes_selected);
|
139 |
}
|
140 |
}
|
|
|
141 |
|
142 |
+
// Error 404
|
143 |
+
$e404_yes_selected = 'checked="true"';
|
144 |
+
$opt_e404 = $DW->getOptions($_GET['id'], 'e404');
|
145 |
+
if ( count($opt_e404) > 0 ) {
|
146 |
+
$e404_condition = $opt_e404[0]['value'];
|
147 |
+
if ( $e404_condition == '0' ) {
|
148 |
+
$e404_no_selected = $e404_yes_selected;
|
149 |
+
unset($e404_yes_selected);
|
150 |
+
}
|
151 |
+
}
|
152 |
+
|
153 |
+
?>
|
154 |
|
155 |
<div id="adv"></div>
|
156 |
|
177 |
}
|
178 |
</style>
|
179 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
180 |
<?php if ( $_POST['dynwid_save'] == 'yes' ) { ?>
|
181 |
<div class="updated fade" id="message">
|
182 |
<p>
|
198 |
<input type="hidden" name="dynwid_save" value="yes" />
|
199 |
<input type="hidden" name="widget_id" value="<?php echo $_GET['id']; ?>" />
|
200 |
|
201 |
+
<b>By Role</b> <img src="<?php echo $DW->plugin_url; ?>img/info.gif" alt="info" title="Click to toggle info" onclick="tglinfo('role')"><br />
|
202 |
+
Show widget to everybody?
|
203 |
+
<div id="i_role">
|
204 |
+
<div id="role" class="infotext">
|
205 |
+
Setting options by role is very powerfull. It can override all other options!<br />
|
206 |
+
Users who are not logged in, get the <em>Anonymous</em> role.
|
207 |
+
</div>
|
208 |
+
</div>
|
209 |
+
<input type="radio" name="role" value="yes" id="role-yes" <?php echo $role_yes_selected; ?> onclick="clrRoles()" /> <label for="role-yes">Yes</label>
|
210 |
+
<input type="radio" name="role" value="no" id="role-no" <?php echo $role_no_selected; ?> onclick="swRoles(false)" /> <label for="role-no">No, only to:</label><br />
|
211 |
+
<div id="role-select" class="condition-select" <?php echo $role_condition_select_style; ?>>
|
212 |
+
<?php foreach ( $roles as $rid => $role ) { ?>
|
213 |
+
<input type="checkbox" id="role_act_<?php echo $rid; ?>" name="role_act[]" value="<?php echo $rid; ?>" <?php if ( count($role_act) > 0 && in_array($rid,$role_act) ) { echo 'checked="true"'; } ?> /> <label for="role_act_<?php echo $rid; ?>"><?php echo $role; ?></label><br />
|
214 |
+
<?php } ?>
|
215 |
+
</div>
|
216 |
+
|
217 |
+
<br /><br />
|
218 |
+
|
219 |
<b>Front Page</b><br />
|
220 |
Show widget on the front page?<br />
|
221 |
<input type="radio" name="front-page" value="yes" id="front-page-yes" <?php echo $frontpage_yes_selected; ?> /> <label for="front-page-yes">Yes</label>
|
295 |
|
296 |
<br /><br />
|
297 |
|
298 |
+
<b>'Not Found' Error (404) Page</b><br />
|
299 |
+
Show widget on error 404 page?<br />
|
300 |
+
<input type="radio" name="e404" value="yes" id="e404-yes" <?php echo $e404_yes_selected; ?> /> <label for="e404-yes">Yes</label>
|
301 |
+
<input type="radio" name="e404" value="no" id="e404-no" <?php echo $e404_no_selected; ?> /> <label for="e404-no">No</label>
|
302 |
+
|
303 |
+
<br /><br />
|
304 |
+
|
305 |
<input class="button-primary" type="submit" value="Save" />
|
306 |
</form>
|
307 |
|
308 |
<form action="themes.php" method="get">
|
309 |
<input type="hidden" name="page" value="dynwid-config" />
|
310 |
<input class="button-secondary" type="submit" value="Cancel" style="position:relative;top:-23px;left:80px;" />
|
311 |
+
</form>
|
312 |
+
|
313 |
+
<script type="text/javascript">
|
314 |
+
function clrRoles() {
|
315 |
+
for ( i = 0; i < chkbxs.length; i++ ) {
|
316 |
+
document.getElementById(chkbxs[i]).checked = false;
|
317 |
+
}
|
318 |
+
swRoles(true);
|
319 |
+
}
|
320 |
+
|
321 |
+
function swRoles(s) {
|
322 |
+
for ( i = 0; i < chkbxs.length; i++ ) {
|
323 |
+
document.getElementById(chkbxs[i]).disabled = s;
|
324 |
+
}
|
325 |
+
}
|
326 |
+
|
327 |
+
function tglinfo(id) {
|
328 |
+
var element = document.getElementById(id);
|
329 |
+
var display = 'd_';
|
330 |
+
display = display.concat(id);
|
331 |
+
|
332 |
+
if ( window[display] ) {
|
333 |
+
element.style.display = 'none';
|
334 |
+
window[display] = false;
|
335 |
+
} else {
|
336 |
+
element.style.display = 'inline';
|
337 |
+
window[display] = true;
|
338 |
+
}
|
339 |
+
}
|
340 |
+
|
341 |
+
var chkbxs = new Array(<?php echo implode(', ' , $jsroles); ?>);
|
342 |
+
if ( document.getElementById('role-yes').checked ) {
|
343 |
+
swRoles(true);
|
344 |
+
}
|
345 |
+
|
346 |
+
var d_role = false;
|
347 |
+
var d_single = false;
|
348 |
+
var d_archive = false;
|
349 |
+
</script>
|
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
|
@@ -14,7 +14,7 @@
|
|
14 |
}
|
15 |
|
16 |
// Checking basic stuff
|
17 |
-
$fields = array( 'front-page', 'single', 'page', 'category', 'archive' );
|
18 |
$work = FALSE;
|
19 |
foreach ( $fields as $field ) {
|
20 |
if ( $_POST[$field] == 'yes' ) {
|
@@ -23,7 +23,7 @@
|
|
23 |
}
|
24 |
}
|
25 |
if (! $work ) {
|
26 |
-
$fields = array( 'single_actor_act', 'single_category_act', 'page_act', 'category_act' );
|
27 |
foreach ( $fields as $field ) {
|
28 |
if ( count($_POST[$field]) > 0 ) {
|
29 |
$work = TRUE;
|
@@ -41,6 +41,11 @@
|
|
41 |
$DW->resetOptions($_POST['widget_id']);
|
42 |
}
|
43 |
|
|
|
|
|
|
|
|
|
|
|
44 |
// Front Page
|
45 |
if ( $_POST['front-page'] == 'no' ) {
|
46 |
$DW->addSingleOption($_POST['widget_id'], 'front-page');
|
@@ -85,4 +90,9 @@
|
|
85 |
if ( $_POST['archive'] == 'no' ) {
|
86 |
$DW->addSingleOption($_POST['widget_id'], 'archive');
|
87 |
}
|
|
|
|
|
|
|
|
|
|
|
88 |
?>
|
2 |
/**
|
3 |
* dynwid_admin_save.php - Saving options to the database
|
4 |
*
|
5 |
+
* @version $Id: dynwid_admin_save.php 202305 2010-02-05 18:19:21Z qurl $
|
6 |
*/
|
7 |
|
8 |
// Security - nonce
|
14 |
}
|
15 |
|
16 |
// Checking basic stuff
|
17 |
+
$fields = array('role', 'front-page', 'single', 'page', 'category', 'archive', 'e404' );
|
18 |
$work = FALSE;
|
19 |
foreach ( $fields as $field ) {
|
20 |
if ( $_POST[$field] == 'yes' ) {
|
23 |
}
|
24 |
}
|
25 |
if (! $work ) {
|
26 |
+
$fields = array('role_act', 'single_actor_act', 'single_category_act', 'page_act', 'category_act' );
|
27 |
foreach ( $fields as $field ) {
|
28 |
if ( count($_POST[$field]) > 0 ) {
|
29 |
$work = TRUE;
|
41 |
$DW->resetOptions($_POST['widget_id']);
|
42 |
}
|
43 |
|
44 |
+
// Role
|
45 |
+
if ( $_POST['role'] == 'no' && count($_POST['role_act']) > 0 ) {
|
46 |
+
$DW->addMultiOption($_POST['widget_id'], 'role', 'no', $_POST['role_act']);
|
47 |
+
}
|
48 |
+
|
49 |
// Front Page
|
50 |
if ( $_POST['front-page'] == 'no' ) {
|
51 |
$DW->addSingleOption($_POST['widget_id'], 'front-page');
|
90 |
if ( $_POST['archive'] == 'no' ) {
|
91 |
$DW->addSingleOption($_POST['widget_id'], 'archive');
|
92 |
}
|
93 |
+
|
94 |
+
// Error 404
|
95 |
+
if ( $_POST['e404'] == 'no' ) {
|
96 |
+
$DW->addSingleOption($_POST['widget_id'], 'e404');
|
97 |
+
}
|
98 |
?>
|
dynwid_class.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* dynwid_class.php - Dynamic Widgets Class
|
4 |
*
|
5 |
-
* @version $Id: dynwid_class.php
|
6 |
*/
|
7 |
|
8 |
class dynWid {
|
@@ -13,17 +13,25 @@
|
|
13 |
public $registered_widgets;
|
14 |
public $sidebars;
|
15 |
public $plugin_url;
|
|
|
16 |
private $wpdb;
|
17 |
|
18 |
public function __construct() {
|
19 |
-
global $wp_registered_sidebars, $wp_registered_widgets, $wpdb;
|
20 |
// $wp_registered_widget_controls
|
21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
$this->firstmessage = TRUE;
|
23 |
$this->registered_sidebars = $wp_registered_sidebars;
|
24 |
$this->registered_widgets = &$wp_registered_widgets;
|
25 |
$this->sidebars = wp_get_sidebars_widgets();
|
26 |
-
$this->plugin_url = WP_PLUGIN_URL . '/' . str_replace( basename(
|
27 |
|
28 |
$this->wpdb = $wpdb;
|
29 |
$this->dbtable = $this->wpdb->prefix . DW_DB_TABLE;
|
@@ -87,6 +95,8 @@
|
|
87 |
return 'category';
|
88 |
} else if ( is_archive() && ! is_category() ) {
|
89 |
return 'archive';
|
|
|
|
|
90 |
} else {
|
91 |
return 'undef';
|
92 |
}
|
@@ -94,11 +104,11 @@
|
|
94 |
|
95 |
public function dump() {
|
96 |
global $wp_version;
|
97 |
-
|
98 |
echo "wp version: " . $wp_version . "\n";
|
99 |
echo "dw version: " . DW_VERSION . "\n";
|
100 |
echo "php version: " . phpversion() . "\n";
|
101 |
-
|
102 |
echo "\n";
|
103 |
echo "list: \n";
|
104 |
print_r($this->dynwid_list);
|
@@ -140,11 +150,17 @@
|
|
140 |
$opt = array();
|
141 |
|
142 |
$query = "SELECT widget_id, maintype, name, value FROM " . $this->dbtable . "
|
143 |
-
WHERE widget_id LIKE '" . $widget_id . "'
|
|
|
|
|
144 |
$results = $this->wpdb->get_results($query);
|
145 |
|
146 |
foreach ( $results as $myrow ) {
|
147 |
-
$opt[ ] = array('widget_id' => $myrow->widget_id,
|
|
|
|
|
|
|
|
|
148 |
}
|
149 |
|
150 |
return $opt;
|
@@ -162,12 +178,14 @@
|
|
162 |
}
|
163 |
|
164 |
public function message($text) {
|
165 |
-
if (
|
|
|
|
|
|
|
|
|
|
|
166 |
echo "\n";
|
167 |
-
$this->firstmessage = FALSE;
|
168 |
}
|
169 |
-
echo '<!-- ' . $text . ' //-->';
|
170 |
-
echo "\n";
|
171 |
}
|
172 |
|
173 |
public function resetOptions($widget_id) {
|
2 |
/**
|
3 |
* dynwid_class.php - Dynamic Widgets Class
|
4 |
*
|
5 |
+
* @version $Id: dynwid_class.php 202305 2010-02-05 18:19:21Z qurl $
|
6 |
*/
|
7 |
|
8 |
class dynWid {
|
13 |
public $registered_widgets;
|
14 |
public $sidebars;
|
15 |
public $plugin_url;
|
16 |
+
public $userrole;
|
17 |
private $wpdb;
|
18 |
|
19 |
public function __construct() {
|
20 |
+
global $current_user, $wp_registered_sidebars, $wp_registered_widgets, $wpdb;
|
21 |
// $wp_registered_widget_controls
|
22 |
|
23 |
+
if ( is_user_logged_in() ) {
|
24 |
+
// @todo -c roles has type array -- are > 1 roles possible?
|
25 |
+
$this->userrole = $current_user->roles[0];
|
26 |
+
} else {
|
27 |
+
$this->userrole = 'anonymous';
|
28 |
+
}
|
29 |
+
|
30 |
$this->firstmessage = TRUE;
|
31 |
$this->registered_sidebars = $wp_registered_sidebars;
|
32 |
$this->registered_widgets = &$wp_registered_widgets;
|
33 |
$this->sidebars = wp_get_sidebars_widgets();
|
34 |
+
$this->plugin_url = WP_PLUGIN_URL . '/' . str_replace( basename(__FILE__), '', plugin_basename(__FILE__) );
|
35 |
|
36 |
$this->wpdb = $wpdb;
|
37 |
$this->dbtable = $this->wpdb->prefix . DW_DB_TABLE;
|
95 |
return 'category';
|
96 |
} else if ( is_archive() && ! is_category() ) {
|
97 |
return 'archive';
|
98 |
+
} else if ( is_404() ) {
|
99 |
+
return 'e404';
|
100 |
} else {
|
101 |
return 'undef';
|
102 |
}
|
104 |
|
105 |
public function dump() {
|
106 |
global $wp_version;
|
107 |
+
|
108 |
echo "wp version: " . $wp_version . "\n";
|
109 |
echo "dw version: " . DW_VERSION . "\n";
|
110 |
echo "php version: " . phpversion() . "\n";
|
111 |
+
|
112 |
echo "\n";
|
113 |
echo "list: \n";
|
114 |
print_r($this->dynwid_list);
|
150 |
$opt = array();
|
151 |
|
152 |
$query = "SELECT widget_id, maintype, name, value FROM " . $this->dbtable . "
|
153 |
+
WHERE widget_id LIKE '" . $widget_id . "'
|
154 |
+
AND (maintype LIKE '" . $maintype . "%' OR maintype = 'role')
|
155 |
+
ORDER BY name";
|
156 |
$results = $this->wpdb->get_results($query);
|
157 |
|
158 |
foreach ( $results as $myrow ) {
|
159 |
+
$opt[ ] = array('widget_id' => $myrow->widget_id,
|
160 |
+
'maintype' => $myrow->maintype,
|
161 |
+
'name' => $myrow->name,
|
162 |
+
'value' => $myrow->value
|
163 |
+
);
|
164 |
}
|
165 |
|
166 |
return $opt;
|
178 |
}
|
179 |
|
180 |
public function message($text) {
|
181 |
+
if ( DEBUG ) {
|
182 |
+
if ( $this->firstmessage ) {
|
183 |
+
echo "\n";
|
184 |
+
$this->firstmessage = FALSE;
|
185 |
+
}
|
186 |
+
echo '<!-- ' . $text . ' //-->';
|
187 |
echo "\n";
|
|
|
188 |
}
|
|
|
|
|
189 |
}
|
190 |
|
191 |
public function resetOptions($widget_id) {
|
dynwid_worker.php
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* dynwid_worker.php - The worker does the actual work.
|
4 |
*
|
5 |
-
* @version $Id: dynwid_worker.php
|
6 |
*/
|
7 |
|
8 |
require_once('dynwid_class.php');
|
@@ -10,6 +10,7 @@
|
|
10 |
$DW = new dynWid();
|
11 |
}
|
12 |
$DW->message('Dynamic Widgets INIT');
|
|
|
13 |
|
14 |
$whereami = $DW->detectPage();
|
15 |
|
@@ -22,13 +23,14 @@
|
|
22 |
$act = array();
|
23 |
$opt = $DW->getOptions($widget_id, $whereami);
|
24 |
$display = TRUE;
|
|
|
25 |
|
26 |
foreach ( $opt as $condition ) {
|
27 |
if ( empty($condition['name']) && $condition['value'] == '0' ) {
|
28 |
$DW->message('Default for ' . $widget_id . ' set to FALSE (rule D1)');
|
29 |
$display = FALSE;
|
30 |
break;
|
31 |
-
} else {
|
32 |
// Get default value
|
33 |
if ( $condition['name'] == 'default' ) {
|
34 |
$default = $condition['value'];
|
@@ -44,11 +46,22 @@
|
|
44 |
$DW->message('Default for ' . $widget_id . ' set to TRUE (rule D3)');
|
45 |
$other = FALSE;
|
46 |
}
|
|
|
|
|
|
|
47 |
}
|
48 |
}
|
49 |
|
50 |
// Act the condition(s) when there are options set
|
51 |
if ( count($opt) > 0 ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
switch ( $whereami ) {
|
53 |
case 'single':
|
54 |
global $post;
|
@@ -113,7 +126,7 @@
|
|
113 |
}
|
114 |
}
|
115 |
|
116 |
-
if (! $display ) {
|
117 |
$DW->message('Removed ' . $widget_id . ' from display');
|
118 |
unset($DW->registered_widgets[$widget_id]);
|
119 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* dynwid_worker.php - The worker does the actual work.
|
4 |
*
|
5 |
+
* @version $Id: dynwid_worker.php 202305 2010-02-05 18:19:21Z qurl $
|
6 |
*/
|
7 |
|
8 |
require_once('dynwid_class.php');
|
10 |
$DW = new dynWid();
|
11 |
}
|
12 |
$DW->message('Dynamic Widgets INIT');
|
13 |
+
$DW->message('User has role ' . $DW->userrole);
|
14 |
|
15 |
$whereami = $DW->detectPage();
|
16 |
|
23 |
$act = array();
|
24 |
$opt = $DW->getOptions($widget_id, $whereami);
|
25 |
$display = TRUE;
|
26 |
+
$role = TRUE;
|
27 |
|
28 |
foreach ( $opt as $condition ) {
|
29 |
if ( empty($condition['name']) && $condition['value'] == '0' ) {
|
30 |
$DW->message('Default for ' . $widget_id . ' set to FALSE (rule D1)');
|
31 |
$display = FALSE;
|
32 |
break;
|
33 |
+
} else if ( $condition['maintype'] != 'role' ) {
|
34 |
// Get default value
|
35 |
if ( $condition['name'] == 'default' ) {
|
36 |
$default = $condition['value'];
|
46 |
$DW->message('Default for ' . $widget_id . ' set to TRUE (rule D3)');
|
47 |
$other = FALSE;
|
48 |
}
|
49 |
+
} else if ( $condition['maintype'] == 'role' && $condition['name'] == 'default' ) {
|
50 |
+
$DW->message('Default for ' . $widget_id . ' set to FALSE (rule R1)');
|
51 |
+
$role = FALSE;
|
52 |
}
|
53 |
}
|
54 |
|
55 |
// Act the condition(s) when there are options set
|
56 |
if ( count($opt) > 0 ) {
|
57 |
+
// Check the role
|
58 |
+
foreach ( $opt as $condition ) {
|
59 |
+
if ( $condition['maintype'] == 'role' && $condition['name'] == $DW->userrole ) {
|
60 |
+
$DW->message('Role sets display to TRUE (rule ER1)');
|
61 |
+
$role = TRUE;
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
switch ( $whereami ) {
|
66 |
case 'single':
|
67 |
global $post;
|
126 |
}
|
127 |
}
|
128 |
|
129 |
+
if (! $display || ! $role ) {
|
130 |
$DW->message('Removed ' . $widget_id . ' from display');
|
131 |
unset($DW->registered_widgets[$widget_id]);
|
132 |
}
|
readme.txt
CHANGED
@@ -1,31 +1,30 @@
|
|
1 |
=== Plugin Name ===
|
2 |
-
Contributors:
|
3 |
-
Donate link:
|
4 |
-
Tags: widget, dynamic, sidebar, custom
|
5 |
Requires at least: 2.9.1
|
6 |
Tested up to: 2.9.1
|
7 |
-
Stable tag: 1.
|
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 for the homepage, single posts, pages, categories and
|
14 |
|
15 |
* Default widget display setting is supported for:
|
|
|
16 |
- Front page
|
17 |
- Single post pages
|
18 |
- Pages
|
19 |
- Category pages
|
20 |
- Archive pages
|
|
|
21 |
* Exceptions can be created for:
|
|
|
22 |
- Single post pages on Author and/or Category
|
23 |
- Pages on Page Title
|
24 |
-
- Category pages on Category
|
25 |
-
|
26 |
-
== Upgrade Notice ==
|
27 |
-
|
28 |
-
This is the first version. No upgrades available yet.
|
29 |
|
30 |
== Installation ==
|
31 |
|
@@ -47,6 +46,11 @@ For the latest FAQ, please visit the [online FAQ](http://www.qurl.nl/faq/).
|
|
47 |
* Now a button 'Create dump' appears a bit below.
|
48 |
* Click that button.
|
49 |
* Save the text file.
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
= How do I completely remove Dynamic Widgets? =
|
52 |
|
@@ -59,10 +63,25 @@ For the latest FAQ, please visit the [online FAQ](http://www.qurl.nl/faq/).
|
|
59 |
|
60 |
== Changelog ==
|
61 |
|
62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
|
64 |
== Release notes ==
|
65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
= Version 1.0 =
|
67 |
* This is the first stable release. However, the road ahead might be a bumpy. Fasten your seatbelt.
|
68 |
* Default widget display setting is supported for:
|
1 |
=== Plugin Name ===
|
2 |
+
Contributors: Qurl
|
3 |
+
Donate link:
|
4 |
+
Tags: widget, widgets, dynamic, sidebar, custom, rules
|
5 |
Requires at least: 2.9.1
|
6 |
Tested up to: 2.9.1
|
7 |
+
Stable tag: 1.1
|
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, for the homepage, single posts, pages, categories, archives and the error 404 page.
|
14 |
|
15 |
* Default widget display setting is supported for:
|
16 |
+
- User roles
|
17 |
- Front page
|
18 |
- Single post pages
|
19 |
- Pages
|
20 |
- Category pages
|
21 |
- Archive pages
|
22 |
+
- 'Not Found' Error (404) Page
|
23 |
* Exceptions can be created for:
|
24 |
+
- User roles on role, including not logged in (anonymous) users
|
25 |
- Single post pages on Author and/or Category
|
26 |
- Pages on Page Title
|
27 |
+
- Category pages on Category
|
|
|
|
|
|
|
|
|
28 |
|
29 |
== Installation ==
|
30 |
|
46 |
* Now a button 'Create dump' appears a bit below.
|
47 |
* Click that button.
|
48 |
* Save the text file.
|
49 |
+
* Remember where you saved it.
|
50 |
+
|
51 |
+
= I have found a bug! Now what? =
|
52 |
+
|
53 |
+
Please file a [bugreport](http://www.qurl.nl/bugreport/). Please note the procedure how to create a dump in the previous answer. After you've filed the report, I'll get back to you asap.
|
54 |
|
55 |
= How do I completely remove Dynamic Widgets? =
|
56 |
|
63 |
|
64 |
== Changelog ==
|
65 |
|
66 |
+
= Version 1.1 =
|
67 |
+
* Added support for widget display settings based on role, including not logged in (anonymous) users.
|
68 |
+
|
69 |
+
= Version 1.0.1 =
|
70 |
+
* Added default widget display setting option for 'Not Found' Error (404) Page.
|
71 |
+
|
72 |
+
== Upgrade Notice ==
|
73 |
+
|
74 |
+
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 re-activate the plugin.
|
75 |
|
76 |
== Release notes ==
|
77 |
|
78 |
+
= Version 1.1 =
|
79 |
+
This is the next official stable release. If you upgrade from a previous version, please follow the upgrade notice.
|
80 |
+
|
81 |
+
= Version 1.0.1 =
|
82 |
+
No bugs found and/or reported since version 1.0.
|
83 |
+
If you do an upgrade from version 1.0, please follow the upgrade notice.
|
84 |
+
|
85 |
= Version 1.0 =
|
86 |
* This is the first stable release. However, the road ahead might be a bumpy. Fasten your seatbelt.
|
87 |
* Default widget display setting is supported for:
|
screenshot-1.jpg
CHANGED
Binary file
|
screenshot-2.jpg
CHANGED
Binary file
|