Version Description
Download this release
Release Info
Developer | SriniG |
Plugin | Flexi Pages Widget |
Version | 1.3 |
Comparing to | |
See all releases |
Code changes from version 1.2 to 1.3
- flexi-pages-widget.php +257 -151
- readme.txt +58 -8
- screenshot-1.png +0 -0
- screenshot-2.png +0 -0
- screenshot-3.png +0 -0
flexi-pages-widget.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: Flexi Pages Widget
|
4 |
-
Plugin URI: http://srinig.com/wordpress
|
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 |
*/
|
@@ -25,122 +25,242 @@ Author URI: http://srinig.com/
|
|
25 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
26 |
*/
|
27 |
|
28 |
-
function
|
29 |
{
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
$sort_order = isset($options['sort_order'])?$options['sort_order']:'ASC';
|
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 |
-
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
else
|
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 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
}
|
80 |
}
|
81 |
}
|
82 |
-
|
|
|
83 |
|
84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
|
86 |
-
|
|
|
|
|
|
|
|
|
87 |
|
88 |
-
|
|
|
|
|
|
|
|
|
|
|
89 |
|
90 |
-
|
91 |
-
|
92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
|
95 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
|
97 |
echo "</ul>\n" . $after_widget;
|
98 |
|
99 |
}
|
100 |
|
101 |
-
function flexipages_widget_control()
|
102 |
{
|
103 |
global $wpdb;
|
104 |
|
105 |
-
|
106 |
-
|
|
|
|
|
|
|
|
|
|
|
107 |
|
108 |
-
|
109 |
-
if(
|
110 |
-
$
|
111 |
-
|
112 |
-
|
113 |
-
$
|
114 |
-
|
115 |
-
$
|
116 |
-
$
|
117 |
-
$
|
118 |
-
$
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
=' selected="selected"';
|
130 |
-
$
|
131 |
=' selected="selected"';
|
132 |
-
$depth_check[$options['depth']] = ' checked="checked"';
|
133 |
-
$home_link_check = ($options['home_link'] == 'on')?' checked="checked"':'';
|
134 |
// Display widget options menu
|
135 |
?>
|
136 |
<table cellpadding="5px">
|
137 |
<tr>
|
138 |
-
<td valign="top"><label for="flexipages_title">Title</label></td>
|
139 |
-
<td><input type="text" id="flexipages_title" name="flexipages_title" value="<?php echo htmlspecialchars($options['title'], ENT_QUOTES) ?>" /></td>
|
140 |
</tr>
|
141 |
<tr>
|
142 |
-
<td valign="top" width="40%"><label for="flexipages_sort_column">Sort by</label></td>
|
143 |
-
<td valign="top" width="60%"><select name="flexipages_sort_column" id="flexipages_sort_column">
|
144 |
<option value="post_title"<?php echo $sort_column_select['post_title']; ?>>Page title</option>
|
145 |
<option value="menu_order"<?php echo $sort_column_select['menu_order']; ?>>Menu order</option>
|
146 |
<option value="post_date"<?php echo $sort_column_select['post_date']; ?>>Date created</option>
|
@@ -149,7 +269,7 @@ function flexipages_init()
|
|
149 |
<option value="post_author"<?php echo $sort_column_select['post_author']; ?>>Page author ID</option>
|
150 |
<option value="post_name"<?php echo $sort_column_select['post_name']; ?>>Page slug</option>
|
151 |
</select>
|
152 |
-
<select name="flexipages_sort_order" id="flexipages_sort_order">
|
153 |
<option<?php echo $sort_order_select['ASC']; ?>>ASC</option>
|
154 |
<option<?php echo $sort_order_select['DESC']; ?>>DESC</option>
|
155 |
</select>
|
@@ -158,104 +278,90 @@ function flexipages_init()
|
|
158 |
|
159 |
|
160 |
<tr>
|
161 |
-
<td valign="top"
|
162 |
-
<
|
163 |
-
<?php
|
164 |
-
|
|
|
165 |
</td>
|
|
|
|
|
|
|
|
|
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="
|
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="
|
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>
|
188 |
|
189 |
|
190 |
</table>
|
191 |
-
<input type="hidden" name="flexipages_submit" value="1" />
|
192 |
|
193 |
<?php
|
194 |
}
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
$
|
204 |
-
|
205 |
-
|
206 |
-
|
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 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
}
|
228 |
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
$
|
233 |
-
$
|
234 |
-
$
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
global $wpdb;
|
239 |
-
$items = $wpdb->get_results( "SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = $parent AND post_type = 'page' AND post_status = 'publish' ORDER BY {$sort_column} {$sort_order}" );
|
240 |
-
|
241 |
-
if ( $items ) {
|
242 |
-
foreach ( $items as $item ) {
|
243 |
-
$pad = str_repeat( ' ', $level * 3 );
|
244 |
-
if ( in_array($item->ID, $selected))
|
245 |
-
$current = ' selected="selected"';
|
246 |
-
else
|
247 |
-
$current = '';
|
248 |
-
|
249 |
-
echo "\n\t<option value='$item->ID'$current>$pad $item->post_title</option>";
|
250 |
-
flexipages_exclude_options( $sort_column, $sort_order, $selected, $item->ID, $level +1 );
|
251 |
-
}
|
252 |
-
} else {
|
253 |
-
return false;
|
254 |
}
|
|
|
|
|
255 |
}
|
256 |
-
|
257 |
-
|
258 |
-
register_widget_control('Flexi Pages', 'flexipages_widget_control', 400, 430);
|
259 |
}
|
260 |
|
261 |
add_action('plugins_loaded', 'flexipages_init');
|
1 |
<?php
|
2 |
/*
|
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 |
*/
|
25 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
26 |
*/
|
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) {
|
43 |
+
$curr_page = &get_post($curr_page->post_parent);
|
44 |
+
$hierarchy[] = $curr_page->ID;
|
45 |
+
}
|
46 |
+
return $hierarchy;
|
47 |
+
}
|
48 |
+
|
49 |
+
function flexipages_get_subpages()
|
50 |
+
{
|
51 |
+
global $wpdb;
|
52 |
+
$sql = "SELECT ID, post_title, post_parent FROM ".$wpdb->posts;
|
53 |
+
$sql .= " WHERE
|
54 |
+
post_type = 'page'
|
55 |
+
AND post_status = 'publish'
|
56 |
+
AND post_parent <> 0 ";
|
57 |
+
|
58 |
+
if($subpages = $wpdb->get_results($sql, ARRAY_A))
|
59 |
+
return $subpages;
|
60 |
+
|
61 |
+
else return array();
|
62 |
+
}
|
63 |
+
|
64 |
+
|
65 |
+
//function adapted from wp-admin/admin-functions.php/function parent_dropdown()
|
66 |
+
function flexipages_exinclude_options(
|
67 |
+
$sort_column = "menu_order",
|
68 |
+
$sort_order = "ASC",
|
69 |
+
$selected = array(),
|
70 |
+
$parent = 0,
|
71 |
+
$level = 0 )
|
72 |
+
{
|
73 |
+
global $wpdb;
|
74 |
+
$items = $wpdb->get_results( "SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = $parent AND post_type = 'page' AND post_status = 'publish' ORDER BY {$sort_column} {$sort_order}" );
|
75 |
+
|
76 |
+
if ( $items ) {
|
77 |
+
foreach ( $items as $item ) {
|
78 |
+
$pad = str_repeat( ' ', $level * 3 );
|
79 |
+
if ( in_array($item->ID, $selected))
|
80 |
+
$current = ' selected="selected"';
|
81 |
else
|
82 |
+
$current = '';
|
83 |
+
|
84 |
+
echo "\n\t<option value='$item->ID'$current>$pad $item->post_title</option>";
|
85 |
+
flexipages_exinclude_options( $sort_column, $sort_order, $selected, $item->ID, $level +1 );
|
86 |
}
|
87 |
+
} else {
|
88 |
+
return false;
|
89 |
+
}
|
90 |
+
}
|
91 |
|
92 |
+
function flexipages($options = '')
|
93 |
+
{
|
94 |
+
$key_value = explode('&', $options);
|
95 |
+
$options = array();
|
96 |
+
foreach($key_value as $value) {
|
97 |
+
$x = explode('=', $value);
|
98 |
+
$options[$x[0]] = $x[1]; // $options['key'] = 'value';
|
99 |
+
}
|
100 |
|
101 |
+
if($options['exclude'])
|
102 |
+
$exclude = explode(',',$options['exclude']);
|
103 |
+
else
|
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 |
|
111 |
+
$subpages = flexipages_get_subpages();
|
112 |
|
113 |
+
foreach ($subpages as $subpage) { //loop through the sub pages
|
114 |
+
// if the parent of any of the subpage is not in our hierarchy,
|
115 |
+
// add it to the exclusion list
|
116 |
+
if ( !in_array ($subpage['post_parent'], $hierarchy) )
|
117 |
+
$exclude[] = $subpage['ID'];
|
|
|
118 |
}
|
119 |
+
$options['depth'] = 0;
|
120 |
+
}
|
121 |
+
else if( $options['depth'] == -3 ) { // display subpages only in related pages
|
122 |
+
// depth = -3 gets rid of parents' siblings
|
123 |
|
124 |
+
$hierarchy = flexipages_currpage_hierarchy();
|
125 |
|
126 |
+
$subpages = flexipages_get_subpages();
|
127 |
|
128 |
+
foreach ($subpages as $subpage) { //loop through the sub pages
|
129 |
+
if (
|
130 |
+
( $subpage['post_parent'] != $hierarchy[0] ) &&
|
131 |
+
( $subpage['post_parent'] != $hierarchy[1] ) &&
|
132 |
+
( !in_array ($subpage['ID'], $hierarchy) )
|
133 |
+
) {
|
134 |
+
$exclude[] = $subpage['ID'];
|
|
|
135 |
}
|
136 |
}
|
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'] = "";
|
146 |
+
}
|
147 |
|
148 |
+
if($options['home_link']) {
|
149 |
+
$display .="<li class=\"page_item";
|
150 |
+
if(is_home()) $display .= " current_page_item";
|
151 |
+
$display .= "\"><a href=\"".get_bloginfo('home')."\" title=\"".wp_specialchars(get_bloginfo('name'), 1) ."\">".$options['home_link']."</a></li>";
|
152 |
+
}
|
153 |
|
154 |
+
foreach($options as $key => $value) {
|
155 |
+
if($key == 'home_link' || $key == 'echo')
|
156 |
+
continue;
|
157 |
+
if($opts) $opts .= '&';
|
158 |
+
$opts .= $key.'='.$value;
|
159 |
+
}
|
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;
|
167 |
+
else
|
168 |
+
echo $display;
|
169 |
+
}
|
170 |
+
|
171 |
+
function flexipages_init()
|
172 |
+
{
|
173 |
+
if ( !function_exists('register_sidebar_widget') || !function_exists('register_widget_control') )
|
174 |
+
return;
|
175 |
+
function flexipages_widget($args, $number = 1)
|
176 |
+
{
|
177 |
+
$options = get_option('flexipages_widget');
|
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;
|
194 |
+
else
|
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)
|
214 |
{
|
215 |
global $wpdb;
|
216 |
|
217 |
+
$options = $newoptions = get_option('flexipages_widget');
|
218 |
+
|
219 |
+
if ( !is_array($options) )
|
220 |
+
$options = $newoptions = array();
|
221 |
+
if(!$options[$number]) {
|
222 |
+
$options[$number] = $newoptions[$number] = flexipages_options_default();
|
223 |
+
}
|
224 |
|
225 |
+
|
226 |
+
if($_REQUEST["flexipages_submit-{$number}"]) {
|
227 |
+
$newoptions[$number]['title']
|
228 |
+
= strip_tags(stripslashes($_REQUEST["flexipages_title-{$number}"]));
|
229 |
+
$newoptions[$number]['sort_column'] = strip_tags(stripslashes($_REQUEST["flexipages_sort_column-{$number}"]));
|
230 |
+
$newoptions[$number]['sort_order'] = strip_tags(stripslashes($_REQUEST["flexipages_sort_order-{$number}"]));
|
231 |
+
$newoptions[$number]['exinclude'] = strip_tags(stripslashes($_REQUEST["flexipages_exinclude-{$number}"]));
|
232 |
+
$newoptions[$number]['exinclude_values'] = isset($_REQUEST["flexipages_exinclude_values-{$number}"])?implode(',', $_REQUEST["flexipages_exinclude_values-{$number}"]):'';
|
233 |
+
$newoptions[$number]['depth'] = strip_tags(stripslashes($_REQUEST["flexipages_depth-{$number}"]));
|
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;
|
244 |
+
update_option('flexipages_widget', $options);
|
245 |
+
}
|
246 |
+
$sort_column_select[$options[$number]['sort_column']]
|
247 |
+
=' selected="selected"';
|
248 |
+
$sort_order_select[$options[$number]['sort_order']]
|
249 |
=' selected="selected"';
|
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 |
<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>
|
278 |
|
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 <Ctrl> 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>
|
304 |
<td colspan="2"><table cellpadding="2px">
|
305 |
+
<tr><td><input type="radio" name="flexipages_depth-<?php echo $number; ?>" id="flexipages_depth0" value="0"<?php echo $depth_check[0]; ?> /></td><td><label for="flexipages_depth0-<?php echo $number; ?>">List all pages and sub-pages in hierarchical (indented) form.</label></td></tr>
|
306 |
+
<tr><td><input type="radio" name="flexipages_depth-<?php echo $number; ?>" id="flexipages_depth_1-<?php echo $number; ?>" value="-1"<?php echo $depth_check[-1]; ?> /></td><td><label for="flexipages_depth_1-<?php echo $number; ?>">List all pages and sub-pages in flat (no-indent) form.</label></td></tr>
|
307 |
+
<tr><td><input type="radio" name="flexipages_depth-<?php echo $number; ?>" id="flexipages_depth1-<?php echo $number; ?>" value="1"<?php echo $depth_check[1]; ?> /></td><td><label for="flexipages_depth1-<?php echo $number; ?>">List top level pages only. Don't list subpages.</label></td></tr>
|
308 |
+
<tr><td><input type="radio" name="flexipages_depth-<?php echo $number; ?>" id="flexipages_depth_2-<?php echo $number; ?>" value="-2"<?php echo $depth_check[-2]; ?> /></td><td><label for="flexipages_depth_2-<?php echo $number; ?>">List sub-pages only in parent and related pages in hierarchy.</label></td></tr>
|
309 |
+
<tr><td><input type="radio" name="flexipages_depth-<?php echo $number; ?>" id="flexipages_depth_custom-<?php echo $number; ?>" value="custom"<?php echo $depth_check['custom']; ?> /></td><td><label for="flexipages_depth_custom-<?php echo $number; ?>">Custom depth level</label> (number) <input type="text" name="flexipages_depth_value-<?php echo $number; ?>" id="flexipages_depth_value-<?php echo $number; ?>" value="<?php echo $options[$number]['depth_value'] ?>" size="2" maxlength="2" onclick="document.getElementById('flexipages_depth_custom-<?php echo $number; ?>').checked = true;" /></td></tr>
|
310 |
</table>
|
311 |
</td>
|
312 |
</tr>
|
313 |
|
314 |
|
315 |
</table>
|
316 |
+
<input type="hidden" name="flexipages_submit-<?php echo $number; ?>" value="1" />
|
317 |
|
318 |
<?php
|
319 |
}
|
320 |
+
function flexipages_widget_setup() {
|
321 |
+
$options = $newoptions = get_option('flexipages_widget');
|
322 |
+
if ( isset($_POST['flexipages-number-submit']) ) {
|
323 |
+
$number = (int) $_POST['flexipages-number'];
|
324 |
+
if ( $number > 9 ) $number = 9;
|
325 |
+
if ( $number < 1 ) $number = 1;
|
326 |
+
$newoptions['number'] = $number;
|
327 |
+
}
|
328 |
+
if ( $options != $newoptions ) {
|
329 |
+
$options = $newoptions;
|
330 |
+
update_option('flexipages_widget', $options);
|
331 |
+
flexipages_widget_register($options['number']);
|
|
|
|
|
|
|
332 |
}
|
|
|
333 |
}
|
334 |
+
function flexipages_widget_page() {
|
335 |
+
$options = $newoptions = get_option('flexipages_widget');
|
336 |
+
?>
|
337 |
+
<div class="wrap">
|
338 |
+
<form method="POST">
|
339 |
+
<h2>Flexi Pages Widgets</h2>
|
340 |
+
<p style="line-height: 30px;"><?php _e('How many \'Flexi Pages\' widgets would you like?', 'widgets'); ?>
|
341 |
+
<select id="flexipages-number" name="flexipages-number" value="<?php echo $options['number']; ?>">
|
342 |
+
<?php for ( $i = 1; $i < 10; ++$i ) echo "<option value='$i' ".($options['number']==$i ? "selected='selected'" : '').">$i</option>"; ?>
|
343 |
+
</select>
|
344 |
+
<span class="submit"><input type="submit" name="flexipages-number-submit" id="flexipages-number-submit" value="<?php _e('Save'); ?>" /></span></p>
|
345 |
+
</form>
|
346 |
+
</div>
|
347 |
+
<?php
|
348 |
}
|
349 |
|
350 |
+
function flexipages_widget_register() {
|
351 |
+
$options = get_option('flexipages_widget');
|
352 |
+
$number = $options['number'];
|
353 |
+
if ( $number < 1 ) $number = 1;
|
354 |
+
if ( $number > 9 ) $number = 9;
|
355 |
+
for ($i = 1; $i <= 9; $i++) {
|
356 |
+
$name = array('Flexi Pages %s', 'widgets', $i);
|
357 |
+
register_sidebar_widget($name, $i <= $number ? 'flexipages_widget' : /* unregister */ '', $i);
|
358 |
+
register_widget_control($name, $i <= $number ? 'flexipages_widget_control' : /* unregister */ '', 400, 450, $i);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
359 |
}
|
360 |
+
add_action('sidebar_admin_setup', 'flexipages_widget_setup');
|
361 |
+
add_action('sidebar_admin_page', 'flexipages_widget_page');
|
362 |
}
|
363 |
+
|
364 |
+
flexipages_widget_register();
|
|
|
365 |
}
|
366 |
|
367 |
add_action('plugins_loaded', 'flexipages_init');
|
readme.txt
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
=== Flexi Pages Widget ===
|
2 |
Contributors: SriniG
|
3 |
-
Donate link: http://srinig.com/wordpress
|
4 |
Tags: pages, subpages, menu, hierarchy, sidebar, widget, navigation
|
5 |
Requires at least: 2.1
|
6 |
-
Tested up to: 2.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.
|
@@ -16,16 +16,19 @@ 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 |
-
|
23 |
|
24 |
== Installation ==
|
25 |
|
26 |
1. Unzip the compressed file and upload the `flexi-pages-widget.php` file (or `flexi-pages-widget` directory) to the `/wp-content/plugins/` directory
|
27 |
1. Activate the plugin 'Flexi Pages' through the 'Plugins' menu in WordPress admin
|
28 |
-
1. Go to WP admin -> Presentation -> Widgets, drag 'Flexi Pages' widget into the sidebar and choose your options
|
|
|
29 |
|
30 |
== Frequently Asked Questions ==
|
31 |
|
@@ -37,6 +40,10 @@ It is possible to deselect all pages. Hold the 'Ctrl' key in your keyboard and c
|
|
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.
|
@@ -44,6 +51,49 @@ Leave your questions, suggestions, bug reports, etc., as a comment at the [plugi
|
|
44 |
== Screenshots ==
|
45 |
|
46 |
1. Controls for the Flexi Pages Widget
|
47 |
-
2.
|
48 |
-
3. Screenshot of the pages listed on
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
=== Flexi Pages Widget ===
|
2 |
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.
|
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 |
|
26 |
== Installation ==
|
27 |
|
28 |
1. Unzip the compressed file and upload the `flexi-pages-widget.php` file (or `flexi-pages-widget` directory) to the `/wp-content/plugins/` directory
|
29 |
1. Activate the plugin 'Flexi Pages' through the 'Plugins' menu in WordPress admin
|
30 |
+
1. Go to WP admin -> Presentation -> Widgets, drag 'Flexi Pages 1' widget into the sidebar and choose your options
|
31 |
+
1. An option to select multiple instances of the widget is available in the widgets page. You can have upto 9 instances of the widget
|
32 |
|
33 |
== Frequently Asked Questions ==
|
34 |
|
40 |
|
41 |
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.
|
42 |
|
43 |
+
= Is there an option to list only sub pages and hide the parent pages? =
|
44 |
+
|
45 |
+
Although such an option does not exist, the 'Include' option can be used to achieve this. Select 'Include' instead of 'Exclude' and select all the pages you want to be listed. Pages left out won't be displayed.
|
46 |
+
|
47 |
= Where do I ask a question about the plugin? =
|
48 |
|
49 |
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.
|
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 |
+
|
60 |
+
Instead of using the sidebar widget, the function `flexipages()` can be used as a template function to display the list of pages. All options available for `wp_list_pages()` can also be used for `flexipages()`. Additionally in `flexipages()`, the depth parameter has two more choices (-2 and -3), and there is an extra parameter to display a link to the blog home page.
|
61 |
+
|
62 |
+
**depth** (*integer*)
|
63 |
+
|
64 |
+
This parameter controls how many levels in the hierarchy of pages are to be included in the list generated by flexipages. The default value is -2.
|
65 |
+
|
66 |
+
* 0 - All pages and sub-pages displayed in hierarchical (indented) form.
|
67 |
+
* -1 - All pages in sub-pages displayed in flat (no indent) form.
|
68 |
+
* -2 (Default) - List sub-pages only in parent and related pages in hierarchy.
|
69 |
+
* -3 - Similar to '-2' above, but siblings of parent pages won't be displayed. Only top level pages and pages in the hierarchy will show up.
|
70 |
+
* 1 - Show only top level Pages
|
71 |
+
* 2 - Value of 2 (or greater) specifies the depth (or level) to descend in displaying Pages.
|
72 |
+
|
73 |
+
**home_link** (*string*)
|
74 |
+
|
75 |
+
If a value is specified for this parameter, a link to the home page of the blog will be displayed on top of the list of pages. The link text will be the value specified. For example, `flexipages('home_link=Home')` will display a link to the home page with link text as 'Home'.
|
76 |
+
|
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
|
83 |
+
* `flexipages()` template function
|
84 |
+
* Other minor improvements
|
85 |
+
* 2007-08-31: Version 1.2
|
86 |
+
* Added option to provide a custom text for the home page link
|
87 |
+
* Custom depth of '-3' will display only parents, siblings and children along with top level pages. Parents' siblings wont be displayed.
|
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 `</li>` 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
|
95 |
+
* tested with WordPress 2.2.2
|
96 |
+
* 2007-08-12: Version 1.1
|
97 |
+
* bug fix
|
98 |
+
* 2007-08-08: Version 1.0
|
99 |
+
* Initial release
|
screenshot-1.png
CHANGED
Binary file
|
screenshot-2.png
CHANGED
Binary file
|
screenshot-3.png
CHANGED
Binary file
|