Flexi Pages Widget - Version 1.4.1

Version Description

Download this release

Release Info

Developer SriniG
Plugin Icon wp plugin Flexi Pages Widget
Version 1.4.1
Comparing to
See all releases

Code changes from version 1.3 to 1.4.1

Files changed (3) hide show
  1. flexi-pages-widget.php +63 -39
  2. readme.txt +13 -9
  3. screenshot-1.png +0 -0
flexi-pages-widget.php CHANGED
@@ -3,7 +3,7 @@
3
Plugin Name: Flexi Pages Widget
4
Plugin URI: http://srinig.com/wordpress/plugins/flexi-pages/
5
Description: A highly configurable WordPress sidebar widget to list pages and sub-pages. User friendly widget control comes with various options.
6
- Version: 1.3
7
Author: Srini G
8
Author URI: http://srinig.com/
9
*/
@@ -27,16 +27,26 @@ Author URI: http://srinig.com/
27
28
function flexipages_options_default()
29
{
30
- return array('title' => __('Pages'), 'sort_column' => 'menu_order', 'sort_order' => 'ASC', 'exinclude' => 'exclude', 'exinclude_values' => '', 'depth' => -2, 'depth_value' => 2, 'home_link' => 'on', 'home_link_text' => __('Home'));
31
}
32
33
function flexipages_currpage_hierarchy()
34
{
35
if( !is_page() )
36
return array();
37
38
- global $post;
39
- $curr_page = $post;
40
// get parents, grandparents of the current page
41
$hierarchy[] = $curr_page->ID;
42
while($curr_page->post_parent) {
@@ -61,6 +71,12 @@ function flexipages_get_subpages()
61
else return array();
62
}
63
64
65
//function adapted from wp-admin/admin-functions.php/function parent_dropdown()
66
function flexipages_exinclude_options(
@@ -104,7 +120,7 @@ function flexipages($options = '')
104
$exclude = array();
105
106
107
- if( $options['depth'] == -2 || !$options['depth']) { // display subpages only in related pages
108
109
$hierarchy = flexipages_currpage_hierarchy();
110
@@ -137,9 +153,21 @@ function flexipages($options = '')
137
$options['depth'] = 0;
138
}
139
140
if($exclude)
141
$options['exclude'] = implode(',', $exclude);
142
-
143
if($options['title_li']) {
144
$title_li = $options['title_li'];
145
$options['title_li'] = "";
@@ -160,7 +188,7 @@ function flexipages($options = '')
160
161
$display .= wp_list_pages('echo=0&'.$opts);
162
163
- if($title_li)
164
$display = "<li class=\"pagenav\">".$title_li."<ul>\n".$display."</ul></li>";
165
if(isset($options['echo']) && $options['echo'] == 0)
166
return $display;
@@ -178,16 +206,17 @@ function flexipages_init()
178
if(!$options[$number]) {
179
$options[$number] = flexipages_options_default();
180
}
181
extract($options[$number]);
182
if($exinclude == 'include')
183
$include = $exinclude_values;
184
else
185
$exclude = $exinclude_values;
186
- if($home_link == 'on')
187
- $home_link = $home_link_text?$home_link_text:__('Home');
188
- else
189
$home_link = "";
190
-
191
if($depth == 'custom') {
192
if(is_numeric($depth_value))
193
$depth = $depth_value;
@@ -195,19 +224,19 @@ function flexipages_init()
195
$depth = 2;
196
}
197
198
- if( ($depth == -2 || $depth == -3) && !is_page() ) $depth = 1;
199
-
200
extract($args);
201
202
- echo $before_widget;
203
- if($title)
204
- echo $before_title . $title . $after_title;
205
- echo "<ul>\n";
206
207
- flexipages('title_li=&sort_column='.$sort_column.'&sort_order='.$sort_order.'&exclude='.$exclude.'&include='.$include.'&depth='.$depth.'&home_link='.$home_link);
208
-
209
- echo "</ul>\n" . $after_widget;
210
211
}
212
213
function flexipages_widget_control($number)
@@ -234,10 +263,7 @@ function flexipages_init()
234
$newoptions[$number]['depth_value'] = strip_tags(stripslashes($_REQUEST["flexipages_depth_value-{$number}"]));
235
if($newoptions[$number]['depth'] != 'custom' || !is_numeric($newoptions[$number]['depth_value']))
236
$newoptions[$number]['depth_value'] = 2;
237
- $newoptions[$number]['home_link'] = ($_REQUEST["flexipages_home_link-{$number}"] == 'on')?'on':'off';
238
- if( !($newoptions[$number]['home_link_text'] = strip_tags( stripslashes($_REQUEST["flexipages_home_link_text-{$number}"]) ) ) ){
239
- $newoptions[$number]['home_link_text'] = __('Home');
240
- }
241
}
242
if ( $options != $newoptions ) {
243
$options = $newoptions;
@@ -250,17 +276,20 @@ function flexipages_init()
250
$exinclude_select[$options[$number]['exinclude']]
251
=' selected="selected"';
252
$depth_check[$options[$number]['depth']] = ' checked="checked"';
253
- $home_link_check = ($options[$number]['home_link'] == 'on')?' checked="checked"':'';
254
// Display widget options menu
255
?>
256
<table cellpadding="5px">
257
<tr>
258
<td valign="top"><label for="flexipages_title-<?php echo $number; ?>">Title</label></td>
259
- <td><input type="text" id="flexipages_title-<?php echo $number; ?>" name="flexipages_title-<?php echo $number; ?>" value="<?php echo htmlspecialchars($options[$number]['title'], ENT_QUOTES) ?>" /></td>
260
</tr>
261
<tr>
262
<td valign="top" width="40%"><label for="flexipages_sort_column-<?php echo $number; ?>">Sort by</label></td>
263
- <td valign="top" width="60%"><select name="flexipages_sort_column-<?php echo $number; ?>" id="flexipages_sort_column-<?php echo $number; ?>">
264
<option value="post_title"<?php echo $sort_column_select['post_title']; ?>>Page title</option>
265
<option value="menu_order"<?php echo $sort_column_select['menu_order']; ?>>Menu order</option>
266
<option value="post_date"<?php echo $sort_column_select['post_date']; ?>>Date created</option>
@@ -269,7 +298,7 @@ function flexipages_init()
269
<option value="post_author"<?php echo $sort_column_select['post_author']; ?>>Page author ID</option>
270
<option value="post_name"<?php echo $sort_column_select['post_name']; ?>>Page slug</option>
271
</select>
272
- <select name="flexipages_sort_order-<?php echo $number; ?>" id="flexipages_sort_order-<?php echo $number; ?>">
273
<option<?php echo $sort_order_select['ASC']; ?>>ASC</option>
274
<option<?php echo $sort_order_select['DESC']; ?>>DESC</option>
275
</select>
@@ -279,25 +308,20 @@ function flexipages_init()
279
280
<tr>
281
<td valign="top">
282
- <select name="flexipages_exinclude-<?php echo $number; ?>" id="flexipages_exinclude-<?php echo $number; ?>">
283
<option value="exclude"<?php echo $exinclude_select['exclude']; ?>>Exclude</option>
284
<option value="include"<?php echo $exinclude_select['include']; ?>>Include</option>
285
- </select> pages
286
</td>
287
- <td><select name="flexipages_exinclude_values-<?php echo $number; ?>[]" id="flexipages_exinclude_values-<?php echo $number; ?>" multiple="multiple" size="4">
288
<?php flexipages_exinclude_options($options[$number]['sort_column'], $options[$number]['sort_order'], explode(',', $options[$number]['exinclude_values']),0,0); ?>
289
</select>
290
- <br /><small>(use &lt;Ctrl&gt; key to select multiple pages)</small></td>
291
- </tr>
292
-
293
- <tr>
294
- <td><label for="flexipages_home_link-<?php echo $number; ?>">Link to home page?</label></td>
295
- <td><input type="checkbox" id="flexipages_home_link-<?php echo $number; ?>" name="flexipages_home_link-<?php echo $number; ?>"<?php echo $home_link_check; ?> /></td>
296
</tr>
297
298
<tr>
299
- <td><label for="flexipages_home_link_text-<?php echo $number; ?>">Home page link text</label></td>
300
- <td><input type="text" name="flexipages_home_link_text-<?php echo $number; ?>" id ="flexipages_home_link_text-<?php echo $number; ?>" value="<?php echo htmlspecialchars($options[$number]['home_link_text'], ENT_QUOTES); ?>" /></td>
301
</tr>
302
303
<tr>
3
Plugin Name: Flexi Pages Widget
4
Plugin URI: http://srinig.com/wordpress/plugins/flexi-pages/
5
Description: A highly configurable WordPress sidebar widget to list pages and sub-pages. User friendly widget control comes with various options.
6
+ Version: 1.4.1
7
Author: Srini G
8
Author URI: http://srinig.com/
9
*/
27
28
function flexipages_options_default()
29
{
30
+ return array('title' => __('Pages'), 'sort_column' => 'menu_order', 'sort_order' => 'ASC', 'exinclude' => 'exclude', 'exinclude_values' => '', 'depth' => -2, 'depth_value' => 2, 'home_link' => __('Home'));
31
}
32
33
+ function flexipages_wp_head()
34
+ {
35
+ global $post;
36
+ global $flexipages_post;
37
+ $flexipages_post = $post;
38
+ }
39
+
40
+ add_action('wp_head', 'flexipages_wp_head');
41
+
42
function flexipages_currpage_hierarchy()
43
{
44
if( !is_page() )
45
return array();
46
47
+ global $flexipages_post;
48
+ $curr_page = $flexipages_post;
49
+
50
// get parents, grandparents of the current page
51
$hierarchy[] = $curr_page->ID;
52
while($curr_page->post_parent) {
71
else return array();
72
}
73
74
+ function flexipages_pageids()
75
+ {
76
+ global $wpdb;
77
+ $page_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_type = 'page' AND post_status = 'publish'" );
78
+ return $page_ids;
79
+ }
80
81
//function adapted from wp-admin/admin-functions.php/function parent_dropdown()
82
function flexipages_exinclude_options(
120
$exclude = array();
121
122
123
+ if( $options['depth'] == -2 || !isset($options['depth'])) { // display subpages only in related pages
124
125
$hierarchy = flexipages_currpage_hierarchy();
126
153
$options['depth'] = 0;
154
}
155
156
+
157
+
158
+ if($options['include']) {
159
+ $include = explode(',', $options['include']);
160
+ $page_ids = flexipages_pageids();
161
+ foreach($page_ids as $page_id) {
162
+ if(!in_array($page_id, $include) && !in_array($page_id, $exclude))
163
+ $exclude[] = $page_id;
164
+ }
165
+ $options['include'] = '';
166
+ }
167
+
168
if($exclude)
169
$options['exclude'] = implode(',', $exclude);
170
+
171
if($options['title_li']) {
172
$title_li = $options['title_li'];
173
$options['title_li'] = "";
188
189
$display .= wp_list_pages('echo=0&'.$opts);
190
191
+ if($title_li && $display)
192
$display = "<li class=\"pagenav\">".$title_li."<ul>\n".$display."</ul></li>";
193
if(isset($options['echo']) && $options['echo'] == 0)
194
return $display;
206
if(!$options[$number]) {
207
$options[$number] = flexipages_options_default();
208
}
209
+
210
extract($options[$number]);
211
if($exinclude == 'include')
212
$include = $exinclude_values;
213
else
214
$exclude = $exinclude_values;
215
+ if(!$home_link || $home_link == 'off')
216
$home_link = "";
217
+ else if($home_link == 'on')
218
+ $home_link = $home_link_text?$home_link_text:__('Home');
219
+
220
if($depth == 'custom') {
221
if(is_numeric($depth_value))
222
$depth = $depth_value;
224
$depth = 2;
225
}
226
227
extract($args);
228
229
+ if($pagelist = flexipages('echo=0&title_li=&sort_column='.$sort_column.'&sort_order='.$sort_order.'&include='.$include.'&exclude='.$exclude.'&depth='.$depth.'&home_link='.$home_link)) {
230
231
+ echo $before_widget;
232
+ if($title)
233
+ echo $before_title . $title . $after_title;
234
+ echo "<ul>\n";
235
+
236
+ echo $pagelist;
237
238
+ echo "</ul>\n" . $after_widget;
239
+ }
240
}
241
242
function flexipages_widget_control($number)
263
$newoptions[$number]['depth_value'] = strip_tags(stripslashes($_REQUEST["flexipages_depth_value-{$number}"]));
264
if($newoptions[$number]['depth'] != 'custom' || !is_numeric($newoptions[$number]['depth_value']))
265
$newoptions[$number]['depth_value'] = 2;
266
+ $newoptions[$number]['home_link'] = strip_tags( stripslashes($_REQUEST["flexipages_home_link-{$number}"]) );
267
}
268
if ( $options != $newoptions ) {
269
$options = $newoptions;
276
$exinclude_select[$options[$number]['exinclude']]
277
=' selected="selected"';
278
$depth_check[$options[$number]['depth']] = ' checked="checked"';
279
+ if($options[$number]['home_link'] == 'on')
280
+ $options[$number]['home_link'] = $options[$number]['home_link_text']?$options[$number]['home_link_text']:__('Home');
281
+ else if($options[$number]['home_link'] == 'off')
282
+ $options[$number]['home_link'] = "";
283
// Display widget options menu
284
?>
285
<table cellpadding="5px">
286
<tr>
287
<td valign="top"><label for="flexipages_title-<?php echo $number; ?>">Title</label></td>
288
+ <td><input class="widefat" type="text" id="flexipages_title-<?php echo $number; ?>" name="flexipages_title-<?php echo $number; ?>" value="<?php echo htmlspecialchars($options[$number]['title'], ENT_QUOTES) ?>" /></td>
289
</tr>
290
<tr>
291
<td valign="top" width="40%"><label for="flexipages_sort_column-<?php echo $number; ?>">Sort by</label></td>
292
+ <td valign="top" width="60%"><select class="widefat" style="display:inline;width:auto;" name="flexipages_sort_column-<?php echo $number; ?>" id="flexipages_sort_column-<?php echo $number; ?>">
293
<option value="post_title"<?php echo $sort_column_select['post_title']; ?>>Page title</option>
294
<option value="menu_order"<?php echo $sort_column_select['menu_order']; ?>>Menu order</option>
295
<option value="post_date"<?php echo $sort_column_select['post_date']; ?>>Date created</option>
298
<option value="post_author"<?php echo $sort_column_select['post_author']; ?>>Page author ID</option>
299
<option value="post_name"<?php echo $sort_column_select['post_name']; ?>>Page slug</option>
300
</select>
301
+ <select class="widefat" style="display:inline;width:auto;" name="flexipages_sort_order-<?php echo $number; ?>" id="flexipages_sort_order-<?php echo $number; ?>">
302
<option<?php echo $sort_order_select['ASC']; ?>>ASC</option>
303
<option<?php echo $sort_order_select['DESC']; ?>>DESC</option>
304
</select>
308
309
<tr>
310
<td valign="top">
311
+ <select class="widefat" style="display:inline;width:auto;" name="flexipages_exinclude-<?php echo $number; ?>" id="flexipages_exinclude-<?php echo $number; ?>">
312
<option value="exclude"<?php echo $exinclude_select['exclude']; ?>>Exclude</option>
313
<option value="include"<?php echo $exinclude_select['include']; ?>>Include</option>
314
+ </select> <label for="flexipages_exinclude_values-<?php echo $number; ?>">pages</label>
315
</td>
316
+ <td><select class="widefat" style="height:auto;max-height:6em" name="flexipages_exinclude_values-<?php echo $number; ?>[]" id="flexipages_exinclude_values-<?php echo $number; ?>" multiple="multiple" size="4">
317
<?php flexipages_exinclude_options($options[$number]['sort_column'], $options[$number]['sort_order'], explode(',', $options[$number]['exinclude_values']),0,0); ?>
318
</select>
319
+ <small>use &lt;Ctrl&gt; key to select multiple pages</small></td>
320
</tr>
321
322
<tr>
323
+ <td valign="top"><label for="flexipages_home_link-<?php echo $number; ?>">Home page link text</label></td>
324
+ <td><input class="widefat" type="text" name="flexipages_home_link-<?php echo $number; ?>" id ="flexipages_home_link-<?php echo $number; ?>" value="<?php echo htmlspecialchars($options[$number]['home_link'], ENT_QUOTES); ?>" /><small>leave this blank to hide home page link</small></td>
325
</tr>
326
327
<tr>
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: SriniG
3
Donate link: http://srinig.com/wordpress/plugins/flexi-pages/#donate
4
Tags: pages, subpages, menu, hierarchy, sidebar, widget, navigation
5
Requires at least: 2.1
6
- Tested up to: 2.3.3
7
Stable tag: trunk
8
9
A highly configurable WordPress sidebar widget to list pages and sub-pages. User friendly widget control comes with various options.
@@ -14,12 +14,12 @@ Flexi Pages Widget is a highly configurable WordPress sidebar widget to list pag
14
15
Features:
16
17
- * Includes a link to the home page (if this option is selected).
18
* Option to display sub-pages only in parent page and related pages.
19
* Option to select and exclude certain pages from getting displayed in the list. Alternatively, only certain pages can be displayed by using the 'include' option.
20
- * Other options include title, sort column/order, text to be displayed for home page link, display and depth options
21
- * Multiple instances of the widget -- you can have upto nine instances of the widget
22
- * Instead of using the widget, the function flexipages() can be called from anywhere in the template (see [other notes](http://wordpress.org/extend/plugins/flexi-pages-widget/other-notes/) for information on parameters that can be passed into this function).
23
24
If you are using WordPress version 2.1 series, you will have to download and activate [Sidebar Widgets plugin](http://wordpress.org/extend/plugins/widgets/), and use a widget compatible theme before you can use the Flexi Pages *Widget*.
25
@@ -50,10 +50,8 @@ Leave your questions, suggestions, bug reports, etc., as a comment at the [plugi
50
51
== Screenshots ==
52
53
- 1. Controls for the Flexi Pages Widget
54
2. Upto nine instances of the Flexi Pages widget can be added to the sidebar
55
- 3. Screenshot of the pages listed on the *home page* when *List sub-pages only in parent and related pages in the hierarchy* option is selected.
56
- 4. Screenshot of the pages listed on a *page having sub pages*. You can see the sub-pages expand here while only top level pages are listed in the home page. Same settings as screenshot 2.
57
58
== The flexipages() template function ==
59
@@ -77,6 +75,12 @@ If a value is specified for this parameter, a link to the home page of the blog
77
In addition to the above two, [all other parameters](http://codex.wordpress.org/wp_list_pages#Parameters) used with `wp_list_pages()` can also be used with flexipages(). Refer [WordPress documentation](http://codex.wordpress.org/wp_list_pages) for more details about the `wp_list_pages()` function and to know about how to pass the parameters into the function.
78
79
== Changelog ==
80
* 2008-02-19: Version 1.3
81
* Multiple instances of the widget
82
* Added 'Include pages' option
@@ -88,7 +92,7 @@ In addition to the above two, [all other parameters](http://codex.wordpress.org/
88
* Few other improvements and some optimization.
89
* Tested with WordPress 2.3-beta1.
90
* 2007-08-22: Version 1.1.2
91
- * Fixed the missing `&lt;/li&gt;` tag for home link
92
* Added class name (`page_item`, `current_page_item`) for home link
93
* 2007-08-17: Version 1.1.1
94
* bug fix
3
Donate link: http://srinig.com/wordpress/plugins/flexi-pages/#donate
4
Tags: pages, subpages, menu, hierarchy, sidebar, widget, navigation
5
Requires at least: 2.1
6
+ Tested up to: 2.5.1
7
Stable tag: trunk
8
9
A highly configurable WordPress sidebar widget to list pages and sub-pages. User friendly widget control comes with various options.
14
15
Features:
16
17
* Option to display sub-pages only in parent page and related pages.
18
* Option to select and exclude certain pages from getting displayed in the list. Alternatively, only certain pages can be displayed by using the 'include' option.
19
+ * Option to include a link to the home page.
20
+ * Other options include title, sort column/order, display and depth options.
21
+ * Multiple instances of the widget. Upto nine instances of the widget can be added to the sidebar.
22
+ * Instead of using the widget, the function flexipages() can be called from anywhere in the template (see [other notes](http://wordpress.org/extend/plugins/flexi-pages-widget/other_notes/) for information on parameters that can be passed into this function).
23
24
If you are using WordPress version 2.1 series, you will have to download and activate [Sidebar Widgets plugin](http://wordpress.org/extend/plugins/widgets/), and use a widget compatible theme before you can use the Flexi Pages *Widget*.
25
50
51
== Screenshots ==
52
53
+ 1. Controls for the Flexi Pages Widget (in WP 2.5)
54
2. Upto nine instances of the Flexi Pages widget can be added to the sidebar
55
56
== The flexipages() template function ==
57
75
In addition to the above two, [all other parameters](http://codex.wordpress.org/wp_list_pages#Parameters) used with `wp_list_pages()` can also be used with flexipages(). Refer [WordPress documentation](http://codex.wordpress.org/wp_list_pages) for more details about the `wp_list_pages()` function and to know about how to pass the parameters into the function.
76
77
== Changelog ==
78
+ * 2008-05-21: Version 1.4.1
79
+ * Bug fixes (issues regarding include/exclude sub-pages only with 'List sub-pages only in parent and related pages in hierarchy' option selected.)
80
+ * 2008-04-06: Version 1.4
81
+ * Fixed the odd behaviour when the widget is placed below the recent posts widget.
82
+ * Removed the redundant check box for home page link in widget controls
83
+ * Tested with WordPress 2.5; widget control box styling compatible with WP 2.5
84
* 2008-02-19: Version 1.3
85
* Multiple instances of the widget
86
* Added 'Include pages' option
92
* Few other improvements and some optimization.
93
* Tested with WordPress 2.3-beta1.
94
* 2007-08-22: Version 1.1.2
95
+ * Fixed the missing `</li>` tag for home link
96
* Added class name (`page_item`, `current_page_item`) for home link
97
* 2007-08-17: Version 1.1.1
98
* bug fix
screenshot-1.png CHANGED
Binary file