Version Description
Download this release
Release Info
Developer | SriniG |
Plugin | Flexi Pages Widget |
Version | 1.2 |
Comparing to | |
See all releases |
Code changes from version 1.1.2 to 1.2
- flexi-pages-widget.php +86 -32
- readme.txt +18 -8
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.
|
7 |
Author: Srini G
|
8 |
Author URI: http://srinig.com/
|
9 |
*/
|
@@ -38,52 +38,64 @@ function flexipages_init()
|
|
38 |
$exclude = isset($options['exclude'])?explode(',',$options['exclude']):array();
|
39 |
$depth = $options['depth'];
|
40 |
$home_link = isset($options['home_link'])?$options['home_link']:'on';
|
|
|
|
|
41 |
if($depth == 'custom') {
|
42 |
if(is_numeric($options['depth_value']))
|
43 |
$depth = $options['depth_value'];
|
44 |
else
|
45 |
$depth = 2;
|
46 |
}
|
47 |
-
|
48 |
-
|
|
|
|
|
49 |
|
50 |
-
|
51 |
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
|
|
|
|
57 |
}
|
58 |
-
|
59 |
-
|
|
|
60 |
|
61 |
-
$
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
$exclude[] = $subpage['ID'];
|
73 |
}
|
74 |
}
|
75 |
-
$depth = "";
|
76 |
}
|
77 |
-
else $
|
|
|
78 |
if($exclude = implode(',', $exclude)) $exclude = "&exclude=".$exclude;
|
|
|
79 |
extract($args);
|
|
|
80 |
echo $before_widget . $before_title . $title . $after_title . "<ul>\n";
|
|
|
81 |
if($home_link == 'on') {
|
82 |
-
?><li class="page_item<?php if(is_home()) echo " current_page_item"; ?>"><a href="<?php bloginfo('home') ?>" title="<?php echo wp_specialchars(get_bloginfo('name'), 1) ?>"><?php
|
83 |
<?php
|
84 |
}
|
85 |
-
|
|
|
|
|
86 |
echo "</ul>\n" . $after_widget;
|
|
|
87 |
}
|
88 |
|
89 |
function flexipages_widget_control()
|
@@ -91,7 +103,7 @@ function flexipages_init()
|
|
91 |
global $wpdb;
|
92 |
|
93 |
// default options
|
94 |
-
$options = array('title' => 'Pages', 'sort_column' => 'post_title', 'sort_order' => 'ASC', 'exclude' => '', 'depth' => -2, 'depth_value' => 2, 'home_link' => 'on');
|
95 |
|
96 |
$saved_options = get_option('flexipages');
|
97 |
if(is_array($saved_options))
|
@@ -108,6 +120,9 @@ function flexipages_init()
|
|
108 |
if($options['depth'] != 'custom' || !is_numeric($options['depth_value']))
|
109 |
$options['depth_value'] = 2;
|
110 |
$options['home_link'] = ($_REQUEST['flexipages_home_link'] == 'on')?'on':'off';
|
|
|
|
|
|
|
111 |
update_option('flexipages', $options);
|
112 |
}
|
113 |
$sort_column_select[$options['sort_column']]
|
@@ -151,17 +166,22 @@ function flexipages_init()
|
|
151 |
</tr>
|
152 |
|
153 |
<tr>
|
154 |
-
<td
|
155 |
<td><input type="checkbox" id="flexipages_home_link" name="flexipages_home_link"<?php echo $home_link_check; ?> /></td>
|
156 |
</tr>
|
157 |
|
|
|
|
|
|
|
|
|
|
|
158 |
<tr>
|
159 |
<td colspan="2"><table cellpadding="2px">
|
160 |
<tr><td><input type="radio" name="flexipages_depth" id="flexipages_depth0" value="0"<?php echo $depth_check[0]; ?> /></td><td><label for="flexipages_depth0">List all pages and sub-pages in hierarchical (indented) form.</label></td></tr>
|
161 |
<tr><td><input type="radio" name="flexipages_depth" id="flexipages_depth-1" value="-1"<?php echo $depth_check[-1]; ?> /></td><td><label for="flexipages_depth-1">List all pages and sub-pages in flat (no-indent) form.</label></td></tr>
|
162 |
<tr><td><input type="radio" name="flexipages_depth" id="flexipages_depth1" value="1"<?php echo $depth_check[1]; ?> /></td><td><label for="flexipages_depth1">List top level pages only. Don't list subpages.</label></td></tr>
|
163 |
<tr><td><input type="radio" name="flexipages_depth" id="flexipages_depth-2" value="-2"<?php echo $depth_check[-2]; ?> /></td><td><label for="flexipages_depth-2">List sub-pages only in parent and related pages in hierarchy.</label></td></tr>
|
164 |
-
<tr><td><input type="radio" name="flexipages_depth" id="flexipages_depth_custom" value="custom"<?php echo $depth_check['custom']; ?> /></td><td><label for="flexipages_depth_custom">Custom depth level</label> (number) <input type="text" name="flexipages_depth_value" id="flexipages_depth_value" value="<?php echo $options['depth_value'] ?>" size="
|
165 |
</table>
|
166 |
</td>
|
167 |
</tr>
|
@@ -169,9 +189,43 @@ function flexipages_init()
|
|
169 |
|
170 |
</table>
|
171 |
<input type="hidden" name="flexipages_submit" value="1" />
|
172 |
-
|
173 |
<?php
|
174 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
|
176 |
//function adapted from wp-admin/admin-functions.php/function parent_dropdown()
|
177 |
function flexipages_exclude_options(
|
@@ -201,7 +255,7 @@ function flexipages_init()
|
|
201 |
}
|
202 |
|
203 |
register_sidebar_widget(array('Flexi Pages', 'widgets'), 'flexipages_widget');
|
204 |
-
register_widget_control('Flexi Pages', 'flexipages_widget_control', 400,
|
205 |
}
|
206 |
|
207 |
add_action('plugins_loaded', 'flexipages_init');
|
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.2
|
7 |
Author: Srini G
|
8 |
Author URI: http://srinig.com/
|
9 |
*/
|
38 |
$exclude = isset($options['exclude'])?explode(',',$options['exclude']):array();
|
39 |
$depth = $options['depth'];
|
40 |
$home_link = isset($options['home_link'])?$options['home_link']:'on';
|
41 |
+
$home_link_text = $options['home_link_text']?$options['home_link_text']:__('Home');
|
42 |
+
|
43 |
if($depth == 'custom') {
|
44 |
if(is_numeric($options['depth_value']))
|
45 |
$depth = $options['depth_value'];
|
46 |
else
|
47 |
$depth = 2;
|
48 |
}
|
49 |
+
|
50 |
+
if( ($depth == -2 || $depth == -3) && !is_page() ) $depth = 1;
|
51 |
+
|
52 |
+
if( $depth == -2 ) { // display subpages only in related pages
|
53 |
|
54 |
+
$hierarchy = flexipages_currpage_hierarchy();
|
55 |
|
56 |
+
$subpages = flexipages_get_subpages();
|
57 |
+
|
58 |
+
foreach ($subpages as $subpage) { //loop through the sub pages
|
59 |
+
// if the parent of any of the subpage is not in our hierarchy,
|
60 |
+
// add it to the exclusion list
|
61 |
+
if ( !in_array ($subpage['post_parent'], $hierarchy) )
|
62 |
+
$exclude[] = $subpage['ID'];
|
63 |
}
|
64 |
+
}
|
65 |
+
else if( $depth == -3 ) { // display subpages only in related pages
|
66 |
+
// depth = -3 gets rid of parents' siblings
|
67 |
|
68 |
+
$hierarchy = flexipages_currpage_hierarchy();
|
69 |
+
|
70 |
+
$subpages = flexipages_get_subpages();
|
71 |
+
|
72 |
+
foreach ($subpages as $subpage) { //loop through the sub pages
|
73 |
+
if (
|
74 |
+
( $subpage['post_parent'] != $hierarchy[0] ) &&
|
75 |
+
( $subpage['post_parent'] != $hierarchy[1] ) &&
|
76 |
+
( !in_array ($subpage['ID'], $hierarchy) )
|
77 |
+
) {
|
78 |
+
$exclude[] = $subpage['ID'];
|
|
|
79 |
}
|
80 |
}
|
|
|
81 |
}
|
82 |
+
else $depth_option = "&depth=".$depth;
|
83 |
+
|
84 |
if($exclude = implode(',', $exclude)) $exclude = "&exclude=".$exclude;
|
85 |
+
|
86 |
extract($args);
|
87 |
+
|
88 |
echo $before_widget . $before_title . $title . $after_title . "<ul>\n";
|
89 |
+
|
90 |
if($home_link == 'on') {
|
91 |
+
?><li class="page_item<?php if(is_home()) echo " current_page_item"; ?>"><a href="<?php bloginfo('home') ?>" title="<?php echo wp_specialchars(get_bloginfo('name'), 1) ?>"><?php echo $home_link_text; ?></a></li>
|
92 |
<?php
|
93 |
}
|
94 |
+
|
95 |
+
wp_list_pages('title_li=&sort_column='.$sort_column.'&sort_order='.$sort_order.$exclude.$depth_option);
|
96 |
+
|
97 |
echo "</ul>\n" . $after_widget;
|
98 |
+
|
99 |
}
|
100 |
|
101 |
function flexipages_widget_control()
|
103 |
global $wpdb;
|
104 |
|
105 |
// default options
|
106 |
+
$options = array('title' => __('Pages'), 'sort_column' => 'post_title', 'sort_order' => 'ASC', 'exclude' => '', 'depth' => -2, 'depth_value' => 2, 'home_link' => 'on', 'home_link_text' => __('Home'));
|
107 |
|
108 |
$saved_options = get_option('flexipages');
|
109 |
if(is_array($saved_options))
|
120 |
if($options['depth'] != 'custom' || !is_numeric($options['depth_value']))
|
121 |
$options['depth_value'] = 2;
|
122 |
$options['home_link'] = ($_REQUEST['flexipages_home_link'] == 'on')?'on':'off';
|
123 |
+
if( !($options['home_link_text'] = strip_tags( stripslashes($_REQUEST['flexipages_home_link_text']) ) ) ){
|
124 |
+
$options['home_link_text'] = __('Home');
|
125 |
+
}
|
126 |
update_option('flexipages', $options);
|
127 |
}
|
128 |
$sort_column_select[$options['sort_column']]
|
166 |
</tr>
|
167 |
|
168 |
<tr>
|
169 |
+
<td><label for="flexipages_home_link">Link to home page?</label></td>
|
170 |
<td><input type="checkbox" id="flexipages_home_link" name="flexipages_home_link"<?php echo $home_link_check; ?> /></td>
|
171 |
</tr>
|
172 |
|
173 |
+
<tr>
|
174 |
+
<td><label for="flexipages_home_link_text">Home page link text</label></td>
|
175 |
+
<td><input type="text" name="flexipages_home_link_text" id ="flexipages_home_link_text" value="<?php echo htmlspecialchars($options['home_link_text'], ENT_QUOTES); ?>" /></td>
|
176 |
+
</tr>
|
177 |
+
|
178 |
<tr>
|
179 |
<td colspan="2"><table cellpadding="2px">
|
180 |
<tr><td><input type="radio" name="flexipages_depth" id="flexipages_depth0" value="0"<?php echo $depth_check[0]; ?> /></td><td><label for="flexipages_depth0">List all pages and sub-pages in hierarchical (indented) form.</label></td></tr>
|
181 |
<tr><td><input type="radio" name="flexipages_depth" id="flexipages_depth-1" value="-1"<?php echo $depth_check[-1]; ?> /></td><td><label for="flexipages_depth-1">List all pages and sub-pages in flat (no-indent) form.</label></td></tr>
|
182 |
<tr><td><input type="radio" name="flexipages_depth" id="flexipages_depth1" value="1"<?php echo $depth_check[1]; ?> /></td><td><label for="flexipages_depth1">List top level pages only. Don't list subpages.</label></td></tr>
|
183 |
<tr><td><input type="radio" name="flexipages_depth" id="flexipages_depth-2" value="-2"<?php echo $depth_check[-2]; ?> /></td><td><label for="flexipages_depth-2">List sub-pages only in parent and related pages in hierarchy.</label></td></tr>
|
184 |
+
<tr><td><input type="radio" name="flexipages_depth" id="flexipages_depth_custom" value="custom"<?php echo $depth_check['custom']; ?> /></td><td><label for="flexipages_depth_custom">Custom depth level</label> (number) <input type="text" name="flexipages_depth_value" id="flexipages_depth_value" value="<?php echo $options['depth_value'] ?>" size="2" maxlength="2" onclick="document.getElementById('flexipages_depth_custom').checked = true;" /></td></tr>
|
185 |
</table>
|
186 |
</td>
|
187 |
</tr>
|
189 |
|
190 |
</table>
|
191 |
<input type="hidden" name="flexipages_submit" value="1" />
|
192 |
+
|
193 |
<?php
|
194 |
}
|
195 |
+
|
196 |
+
function flexipages_currpage_hierarchy()
|
197 |
+
{
|
198 |
+
if( !is_page() )
|
199 |
+
return array();
|
200 |
+
|
201 |
+
global $post;
|
202 |
+
|
203 |
+
$curr_page = $post;
|
204 |
+
|
205 |
+
// get parents, grandparents of the current page
|
206 |
+
$hierarchy[] = $curr_page->ID;
|
207 |
+
while($curr_page->post_parent) {
|
208 |
+
$curr_page = &get_post($curr_page->post_parent);
|
209 |
+
$hierarchy[] = $curr_page->ID;
|
210 |
+
}
|
211 |
+
return $hierarchy;
|
212 |
+
}
|
213 |
+
|
214 |
+
function flexipages_get_subpages()
|
215 |
+
{
|
216 |
+
global $wpdb;
|
217 |
+
$sql = "SELECT ID, post_title, post_parent FROM ".$wpdb->posts;
|
218 |
+
$sql .= " WHERE
|
219 |
+
post_type = 'page'
|
220 |
+
AND post_status = 'publish'
|
221 |
+
AND post_parent <> 0 ";
|
222 |
+
|
223 |
+
if($subpages = $wpdb->get_results($sql, ARRAY_A))
|
224 |
+
return $subpages;
|
225 |
+
|
226 |
+
else return array();
|
227 |
+
}
|
228 |
+
|
229 |
|
230 |
//function adapted from wp-admin/admin-functions.php/function parent_dropdown()
|
231 |
function flexipages_exclude_options(
|
255 |
}
|
256 |
|
257 |
register_sidebar_widget(array('Flexi Pages', 'widgets'), 'flexipages_widget');
|
258 |
+
register_widget_control('Flexi Pages', 'flexipages_widget_control', 400, 430);
|
259 |
}
|
260 |
|
261 |
add_action('plugins_loaded', 'flexipages_init');
|
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.
|
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,10 +14,12 @@ Flexi Pages Widget is a highly configurable WordPress sidebar widget to list pag
|
|
14 |
|
15 |
Features:
|
16 |
|
17 |
-
*
|
18 |
-
* Option to
|
19 |
-
*
|
20 |
-
*
|
|
|
|
|
21 |
|
22 |
== Installation ==
|
23 |
|
@@ -27,13 +29,21 @@ Features:
|
|
27 |
|
28 |
== Frequently Asked Questions ==
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
= Where do I ask a question about the plugin? =
|
31 |
|
32 |
-
|
33 |
|
34 |
== Screenshots ==
|
35 |
|
36 |
1. Controls for the Flexi Pages Widget
|
37 |
-
2. Screenshot of the pages listed on the home page when
|
38 |
-
3. Screenshot of the pages listed on a page having sub pages
|
39 |
|
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-beta1
|
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 |
+
* 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.
|
20 |
+
* Other options include title, sort column/order, text to be displayed for home page link, display and depth options
|
21 |
+
|
22 |
+
Visit the ['Flexi Pages Widget' plugin page](http://srinig.com/wordpress-plugins/flexi-pages/ "'Flexi Pages Widget' for WordPress") for more details.
|
23 |
|
24 |
== Installation ==
|
25 |
|
29 |
|
30 |
== Frequently Asked Questions ==
|
31 |
|
32 |
+
= After selecting a few pages for exclusion, isn't it possible to deselect all pages? There is always one page selected for exclusion. =
|
33 |
+
|
34 |
+
It is possible to deselect all pages. Hold the 'Ctrl' key in your keyboard and click on the name of the page that's not getting deselected.
|
35 |
+
|
36 |
+
= When the option "List sub-pages only in parent and related pages in hierarchy" is selected, top level pages, children and siblings of the current page, and siblings of the parent page get listed. Is it possible to get rid of siblings of parent page on a subpage while using this option? =
|
37 |
+
|
38 |
+
Yes. But you have to select the 'Custom depth level' option to achieve this. Enter the number '-3' for custom depth. This way only top level pages and pages in the hierarchy will show up.
|
39 |
+
|
40 |
= Where do I ask a question about the plugin? =
|
41 |
|
42 |
+
Leave your questions, suggestions, bug reports, etc., as a comment at the [plugin page](http://srinig.com/wordpress-plugins/flexi-pages/ "Flexi Pages Widget") or through [contact form](http://srinig.com/contact/) at the author's website. Questions frequently asked will be incorporated into the FAQ section in future versions of the plugin.
|
43 |
|
44 |
== Screenshots ==
|
45 |
|
46 |
1. Controls for the Flexi Pages Widget
|
47 |
+
2. 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.
|
48 |
+
3. 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.
|
49 |
|