Page-list - Version 1.2.0

Version Description

  • Added [subpages] and [siblings] shortcodes;
Download this release

Release Info

Developer webvitaly
Plugin Icon wp plugin Page-list
Version 1.2.0
Comparing to
See all releases

Code changes from version 1.0.0 to 1.2.0

Files changed (2) hide show
  1. page-list.php +177 -35
  2. readme.txt +36 -7
page-list.php CHANGED
@@ -2,47 +2,189 @@
2
  /*
3
  Plugin Name: Page-list
4
  Plugin URI: http://web-profile.com.ua/wordpress/plugins/page-list/
5
- Description: Show pagelist with [pagelist] shortcode.
6
- Version: 1.0.0
7
  Author: webvitaly
8
  Author Email: webvitaly(at)gmail.com
9
  Author URI: http://web-profile.com.ua/
 
 
 
 
10
  */
11
 
12
- function pagelist_shortcode( $atts ) {
13
- extract( shortcode_atts( array(
14
- 'depth' => '0',
15
- 'child_of' => '0',
16
- 'exclude' => '0'
17
- ), $atts ) );
18
- global $post;
19
- $return = '';
20
- if( $child_of == 'current' || $child_of == 'this' ){
21
- $child_of = $post->ID;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  }
23
- $list_pages_args = array(
24
- 'depth' => $depth,
25
- 'show_date' => '',
26
- 'date_format' => get_option('date_format'),
27
- 'child_of' => $child_of,
28
- 'exclude' => $exclude,
29
- 'include' => '',
30
- 'title_li' => '',
31
- 'echo' => 0,
32
- 'authors' => '',
33
- 'sort_column' => 'menu_order, post_title',
34
- 'link_before' => '',
35
- 'link_after' => '',
36
- 'walker' => '' );
37
-
38
- $list_pages = wp_list_pages( $list_pages_args );
39
-
40
- if ($list_pages) {
41
- $return = '<ul>'.$list_pages.'</ul>';
42
- }else{
43
  $return = '';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  }
45
-
46
- return $return;
47
  }
48
- add_shortcode( 'pagelist', 'pagelist_shortcode' );
2
  /*
3
  Plugin Name: Page-list
4
  Plugin URI: http://web-profile.com.ua/wordpress/plugins/page-list/
5
+ Description: Show list of pages with [pagelist], [subpages] and [siblings] shortcodes.
6
+ Version: 1.2.0
7
  Author: webvitaly
8
  Author Email: webvitaly(at)gmail.com
9
  Author URI: http://web-profile.com.ua/
10
+
11
+ Future features:
12
+ - exclude_by_alias;
13
+ - [parents];
14
  */
15
 
16
+ if ( !function_exists('pagelist_shortcode') ) {
17
+ function pagelist_shortcode( $atts ) {
18
+ global $post;
19
+ $return = '';
20
+ extract( shortcode_atts( array(
21
+ 'depth' => '0',
22
+ 'child_of' => '0',
23
+ 'exclude' => '0',
24
+ 'exclude_tree' => '',
25
+ 'include' => '0',
26
+ 'title_li' => '',
27
+ 'number' => '',
28
+ 'offset' => '',
29
+ 'meta_key' => '',
30
+ 'meta_value' => '',
31
+ 'show_date' => '',
32
+ 'sort_column' => 'menu_order, post_title',
33
+ 'sort_order' => 'ASC',
34
+ 'link_before' => '',
35
+ 'link_after' => '',
36
+ ), $atts ) );
37
+
38
+ if( $child_of == 'current' || $child_of == 'this' ){
39
+ $child_of = $post->ID;
40
+ }
41
+ if( $child_of == 'parent' ){
42
+ $child_of = $post->post_parent;
43
+ }
44
+
45
+ $page_list_args = array(
46
+ 'depth' => $depth,
47
+ 'child_of' => $child_of,
48
+ 'exclude' => $exclude,
49
+ 'exclude_tree' => $exclude_tree,
50
+ 'include' => $include,
51
+ 'title_li' => $title_li,
52
+ 'number' => $number,
53
+ 'offset' => $offset,
54
+ 'meta_key' => $meta_key,
55
+ 'meta_value' => $meta_value,
56
+ 'show_date' => $show_date,
57
+ 'date_format' => get_option('date_format'),
58
+ 'echo' => 0,
59
+ 'authors' => '',
60
+ 'sort_column' => $sort_column,
61
+ 'sort_order' => $sort_order,
62
+ 'link_before' => $link_before,
63
+ 'link_after' => $link_after,
64
+ 'walker' => ''
65
+ );
66
+ $list_pages = wp_list_pages( $page_list_args );
67
+
68
+ if ($list_pages) {
69
+ $return = '<ul>'.$list_pages.'</ul>';
70
+ }else{
71
+ $return = '';
72
+ }
73
+ return $return;
74
+ }
75
+ add_shortcode( 'pagelist', 'pagelist_shortcode' );
76
+ add_shortcode( 'page-list', 'pagelist_shortcode' );
77
+ add_shortcode( 'sitemap', 'pagelist_shortcode' );
78
+ }
79
+
80
+ if ( !function_exists('subpages_shortcode') ) {
81
+ function subpages_shortcode( $atts ) {
82
+ global $post;
83
+ $return = '';
84
+ extract( shortcode_atts( array(
85
+ 'depth' => '0',
86
+ //'child_of' => '0',
87
+ 'exclude' => '0',
88
+ 'exclude_tree' => '',
89
+ 'include' => '0',
90
+ 'title_li' => '',
91
+ 'number' => '',
92
+ 'offset' => '',
93
+ 'meta_key' => '',
94
+ 'meta_value' => '',
95
+ 'show_date' => '',
96
+ 'sort_column' => 'menu_order, post_title',
97
+ 'sort_order' => 'ASC',
98
+ 'link_before' => '',
99
+ 'link_after' => '',
100
+ ), $atts ) );
101
+
102
+ $page_list_args = array(
103
+ 'depth' => $depth,
104
+ 'child_of' => $post->ID,
105
+ 'exclude' => $exclude,
106
+ 'exclude_tree' => $exclude_tree,
107
+ 'include' => $include,
108
+ 'title_li' => $title_li,
109
+ 'number' => $number,
110
+ 'offset' => $offset,
111
+ 'meta_key' => $meta_key,
112
+ 'meta_value' => $meta_value,
113
+ 'show_date' => $show_date,
114
+ 'date_format' => get_option('date_format'),
115
+ 'echo' => 0,
116
+ 'authors' => '',
117
+ 'sort_column' => $sort_column,
118
+ 'sort_order' => $sort_order,
119
+ 'link_before' => $link_before,
120
+ 'link_after' => $link_after,
121
+ 'walker' => ''
122
+ );
123
+ $list_pages = wp_list_pages( $page_list_args );
124
+
125
+ if ($list_pages) {
126
+ $return = '<ul>'.$list_pages.'</ul>';
127
+ }else{
128
+ $return = '';
129
+ }
130
+ return $return;
131
  }
132
+ add_shortcode( 'subpages', 'subpages_shortcode' );
133
+ add_shortcode( 'sub-pages', 'subpages_shortcode' );
134
+ add_shortcode( 'children', 'subpages_shortcode' );
135
+ }
136
+
137
+ if ( !function_exists('siblings_shortcode') ) {
138
+ function siblings_shortcode( $atts ) {
139
+ global $post;
 
 
 
 
 
 
 
 
 
 
 
 
140
  $return = '';
141
+ extract( shortcode_atts( array(
142
+ 'depth' => '0',
143
+ //'child_of' => '0',
144
+ 'exclude' => '0',
145
+ 'exclude_tree' => '',
146
+ 'include' => '0',
147
+ 'title_li' => '',
148
+ 'number' => '',
149
+ 'offset' => '',
150
+ 'meta_key' => '',
151
+ 'meta_value' => '',
152
+ 'show_date' => '',
153
+ 'sort_column' => 'menu_order, post_title',
154
+ 'sort_order' => 'ASC',
155
+ 'link_before' => '',
156
+ 'link_after' => '',
157
+ ), $atts ) );
158
+
159
+ $page_list_args = array(
160
+ 'depth' => $depth,
161
+ 'child_of' => $post->post_parent,
162
+ 'exclude' => $exclude,
163
+ 'exclude_tree' => $exclude_tree,
164
+ 'include' => $include,
165
+ 'title_li' => $title_li,
166
+ 'number' => $number,
167
+ 'offset' => $offset,
168
+ 'meta_key' => $meta_key,
169
+ 'meta_value' => $meta_value,
170
+ 'show_date' => $show_date,
171
+ 'date_format' => get_option('date_format'),
172
+ 'echo' => 0,
173
+ 'authors' => '',
174
+ 'sort_column' => $sort_column,
175
+ 'sort_order' => $sort_order,
176
+ 'link_before' => $link_before,
177
+ 'link_after' => $link_after,
178
+ 'walker' => ''
179
+ );
180
+ $list_pages = wp_list_pages( $page_list_args );
181
+
182
+ if ($list_pages) {
183
+ $return = '<ul>'.$list_pages.'</ul>';
184
+ }else{
185
+ $return = '';
186
+ }
187
+ return $return;
188
  }
189
+ add_shortcode( 'siblings', 'siblings_shortcode' );
 
190
  }
 
readme.txt CHANGED
@@ -6,31 +6,60 @@ Tags: page, page-list, pagelist
6
  Author URI: http://web-profile.com.ua/wordpress/
7
  Requires at least: 3.0
8
  Tested up to: 3.1.1
9
- Stable tag: 1.0.0
10
 
11
- "Page-list" plugin helps you to show list of pages of your web-site (hierarchical tree of pages) with [pagelist] shortcode.
12
 
13
  == Description ==
14
 
15
  You can use aditional parameters: **`[pagelist depth="2" child_of="4" exclude="6,7,8"]`**.
16
 
17
  Plugin is based on [wp_list_pages('title_li=')](http://codex.wordpress.org/Template_Tags/wp_list_pages) function;
18
- = Usage: =
19
- * the depth (how many levels in the hierarchy of pages are to be included in the list) by default is unlimited, but you can specify it like this: `[pagelist depth="3"]`;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  * if you want to show flat list of pages (not hierarchical tree) you can use this shortcode: `[pagelist depth="-1"]`;
21
  * if you want to show subpages of the specific page you can use this shortcode: `[pagelist child_of="4"]` where `4` is the ID of the specific page;
22
- * if you want to show subpages of the current page you can use this shortcode: `[pagelist child_of="current"]` or `[pagelist child_of="this"]`;
 
23
  * if you want to exclude some pages from the list you can use this shortcode: `[pagelist exclude="6,7,8"]` where `exclude` parameter accepts comma-separated list of Page IDs;
 
 
 
 
 
 
 
 
 
 
 
24
 
25
- [WordPress stuff](http://web-profile.com.ua/wordpress/)
26
 
27
  == Changelog ==
28
 
 
 
 
29
  = 1.0.0 =
30
  * Initial release;
31
 
32
  == Installation ==
33
 
34
  1. Install plugin and activate it on the Plugins page;
35
- 2. Add shortcode **`[pagelist]`** to page content;
36
 
6
  Author URI: http://web-profile.com.ua/wordpress/
7
  Requires at least: 3.0
8
  Tested up to: 3.1.1
9
+ Stable tag: 1.2.0
10
 
11
+ "Page-list" plugin helps you to show list of pages with [pagelist], [subpages] and [siblings] shortcodes.
12
 
13
  == Description ==
14
 
15
  You can use aditional parameters: **`[pagelist depth="2" child_of="4" exclude="6,7,8"]`**.
16
 
17
  Plugin is based on [wp_list_pages('title_li=')](http://codex.wordpress.org/Template_Tags/wp_list_pages) function;
18
+ = Examples: =
19
+ * show hierarchical tree of pages: `[pagelist]`;
20
+ * show hierarchical tree of subpages: `[subpages]`;
21
+ * show hierarchical tree of sibling pages: `[siblings]`;
22
+
23
+ [WordPress stuff](http://web-profile.com.ua/wordpress/)
24
+
25
+ == Other Notes ==
26
+
27
+ = Documentation =
28
+
29
+ Plugin is based on [wp_list_pages('title_li=')](http://codex.wordpress.org/Template_Tags/wp_list_pages) function;
30
+ You can use aditional parameters: **`[pagelist depth="2" child_of="4" exclude="6,7,8"]`**.
31
+ Shortcodes [pagelist], [subpages] and [siblings] accept the same parameters. The only difference is that [subpages] and [siblings] not accept `child_of` parameter, because [subpages] shows subpages to the current page and [siblings] shows subpages to the parent page.
32
+
33
+ = Parameters: =
34
+ * depth - means how many levels in the hierarchy of pages are to be included in the list, by default depth is unlimited (depth=0), but you can specify it like this: `[pagelist depth="3"]`;
35
  * if you want to show flat list of pages (not hierarchical tree) you can use this shortcode: `[pagelist depth="-1"]`;
36
  * if you want to show subpages of the specific page you can use this shortcode: `[pagelist child_of="4"]` where `4` is the ID of the specific page;
37
+ * if you want to show subpages of the current page you can use this shortcodes: `[subpages]` or `[pagelist child_of="current"]` or `[pagelist child_of="this"]`;
38
+ * if you want to show sibling pages of the current page you can use this shortcodes: `[siblings]` or `[pagelist child_of="parent"]`;
39
  * if you want to exclude some pages from the list you can use this shortcode: `[pagelist exclude="6,7,8"]` where `exclude` parameter accepts comma-separated list of Page IDs;
40
+ * if you want to exclude the tree of pages from the list you can use this shortcode: `[pagelist exclude_tree="7,10"]` where `exclude_tree` parameter accepts comma-separated list of Page IDs (all this pages and their subpages will be excluded);
41
+ * if you want to include certain pages into the list of pages you can use this shortcode: `[pagelist include="6,7,8"]` where `include` parameter accepts comma-separated list of Page IDs;
42
+ * if you want to specify the title of the list of pages you can use this shortcode: `[pagelist title_li="<h2>List of pages</h2>"]`; by default there is no title (title_li="");
43
+ * if you want to specify the number of pages to be included into list of pages you can use this shortcode: `[pagelist number="10"]`; by default the number is unlimited (number="");
44
+ * if you want to pass over (or displace) some pages you can use this shortcode: `[pagelist offset="5"]`; by default there is no offset (offset="");
45
+ * if you want to include the pages that have this Custom Field Key you can use this shortcode: `[pagelist meta_key="metakey" meta_value="metaval"]`;
46
+ * if you want to show the date of the page you can use this shortcode: `[pagelist show_date="created"]`; you can use this values for `show_date` parameter: created, modified, updated;
47
+ * if you want to specify the column by what to sort you can use this shortcode: `[pagelist sort_column="menu_order"]`; by default order columns are `menu_order` and `post_title` (sort_column="menu_order, post_title"); you can use this values for `sort_column` parameter: post_title, menu_order, post_date (sort by creation time), post_modified (sort by last modified time), ID, post_author (sort by the page author's numeric ID), post_name (sort by page slug);
48
+ * if you want to change the sort order of the list of pages (either ascending or descending) you can use this shortcode: `[pagelist sort_order="desc"]`; by default sort_order is `asc` (sort_order="asc"); you can use this values for `sort_order` parameter: asc, desc;
49
+ * if you want to specify the text or html that precedes the link text inside the link tag you can use this shortcode: `[pagelist link_before="<span>"]`; you may specify html tags only in the `HTML` tab in your Rich-text editor;
50
+ * if you want to specify the text or html that follows the link text inside the link tag you can use this shortcode: `[pagelist link_after="</span>"]`; you may specify html tags only in the `HTML` tab in your Rich-text editor;
51
 
 
52
 
53
  == Changelog ==
54
 
55
+ = 1.2.0 =
56
+ * Added [subpages] and [siblings] shortcodes;
57
+
58
  = 1.0.0 =
59
  * Initial release;
60
 
61
  == Installation ==
62
 
63
  1. Install plugin and activate it on the Plugins page;
64
+ 2. Add shortcode **`[pagelist]`**, **`[subpages]`** or **`[siblings]`** to page content;
65