Sitemap - Version 1.2.0

Version Description

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

Release Info

Developer webvitaly
Plugin Icon wp plugin Sitemap
Version 1.2.0
Comparing to
See all releases

Code changes from version 1.1.0 to 1.2.0

Files changed (2) hide show
  1. readme.txt +45 -14
  2. sitemap.php +178 -36
readme.txt CHANGED
@@ -1,32 +1,62 @@
1
  === Sitemap ===
2
  Contributors: webvitaly
3
- Donate link: http://web-profile.com.ua/wordpress/plugins/sitemap/
4
- Plugin URI: http://web-profile.com.ua/wordpress/plugins/sitemap/
5
- Tags: page, sitemap
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.1.0
10
 
11
- "Sitemap" plugin helps you show sitemap of your web-site (hierarchical tree of pages) with [sitemap] shortcode.
12
 
13
  == Description ==
14
 
15
- You can use aditional parameters: **`[sitemap depth="2" child_of="4" exclude="6,7,8"]`**.
16
-
17
  Code moved to [page-list plugin](http://wordpress.org/extend/plugins/page-list/).
18
 
 
 
19
  Plugin is based on [wp_list_pages('title_li=')](http://codex.wordpress.org/Template_Tags/wp_list_pages) function;
20
- = Usage: =
21
- * 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: `[sitemap depth="3"]`;
22
- * if you want to show flat list of pages (not hierarchical tree) you can use this shortcode: `[sitemap depth="-1"]`;
23
- * if you want to show subpages of the specific page you can use this shortcode: `[sitemap child_of="4"]` where `4` is the ID of the specific page;
24
- * if you want to show subpages of the current page you can use this shortcode: `[sitemap child_of="current"]` or `[sitemap child_of="this"]`;
25
- * if you want to exclude some pages from the list you can use this shortcode: `[sitemap exclude="6,7,8"]` where `exclude` parameter accepts comma-separated list of Page IDs;
26
 
27
  [WordPress stuff](http://web-profile.com.ua/wordpress/)
28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  == Changelog ==
 
 
 
 
30
  = 1.1.0 =
31
  * Added "child_of=current" option;
32
  * Improving documentation;
@@ -37,4 +67,5 @@ Plugin is based on [wp_list_pages('title_li=')](http://codex.wordpress.org/Templ
37
  == Installation ==
38
 
39
  1. Install plugin and activate it on the Plugins page;
40
- 2. Add shortcode **`[sitemap]`** to page content;
 
1
  === Sitemap ===
2
  Contributors: webvitaly
3
+ Donate link: http://web-profile.com.ua/wordpress/plugins/page-list/
4
+ Plugin URI: http://web-profile.com.ua/wordpress/plugins/page-list/
5
+ Tags: page, page-list, pagelist, sitemap
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
+ "Sitemap" plugin helps you to show list of pages with [sitemap], [pagelist], [subpages] and [siblings] shortcodes.
12
 
13
  == Description ==
14
 
 
 
15
  Code moved to [page-list plugin](http://wordpress.org/extend/plugins/page-list/).
16
 
17
+ You can use aditional parameters: **`[pagelist depth="2" child_of="4" exclude="6,7,8"]`**.
18
+
19
  Plugin is based on [wp_list_pages('title_li=')](http://codex.wordpress.org/Template_Tags/wp_list_pages) function;
20
+ = Examples: =
21
+ * show hierarchical tree of pages: `[pagelist]`;
22
+ * show hierarchical tree of subpages: `[subpages]`;
23
+ * show hierarchical tree of sibling pages: `[siblings]`;
 
 
24
 
25
  [WordPress stuff](http://web-profile.com.ua/wordpress/)
26
 
27
+ == Other Notes ==
28
+
29
+ = Documentation =
30
+
31
+ Plugin is based on [wp_list_pages('title_li=')](http://codex.wordpress.org/Template_Tags/wp_list_pages) function;
32
+ You can use aditional parameters: **`[pagelist depth="2" child_of="4" exclude="6,7,8"]`**.
33
+ 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.
34
+
35
+ = Parameters: =
36
+ * 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"]`;
37
+ * if you want to show flat list of pages (not hierarchical tree) you can use this shortcode: `[pagelist depth="-1"]`;
38
+ * 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;
39
+ * 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"]`;
40
+ * if you want to show sibling pages of the current page you can use this shortcodes: `[siblings]` or `[pagelist child_of="parent"]`;
41
+ * 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;
42
+ * 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);
43
+ * 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;
44
+ * 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="");
45
+ * 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="");
46
+ * 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="");
47
+ * 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"]`;
48
+ * 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;
49
+ * 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);
50
+ * 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;
51
+ * 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;
52
+ * 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;
53
+
54
+
55
  == Changelog ==
56
+
57
+ = 1.2.0 =
58
+ * Added [subpages] and [siblings] shortcodes;
59
+
60
  = 1.1.0 =
61
  * Added "child_of=current" option;
62
  * Improving documentation;
67
  == Installation ==
68
 
69
  1. Install plugin and activate it on the Plugins page;
70
+ 2. Add shortcode **`[pagelist]`**, **`[subpages]`** or **`[siblings]`** to page content;
71
+
sitemap.php CHANGED
@@ -1,48 +1,190 @@
1
  <?php
2
  /*
3
  Plugin Name: Sitemap
4
- Plugin URI: http://web-profile.com.ua/wordpress/plugins/sitemap/
5
- Description: Show sitemap with [sitemap] shortcode.
6
- Version: 1.1.0
7
  Author: webvitaly
8
  Author Email: webvitaly(at)gmail.com
9
  Author URI: http://web-profile.com.ua/
 
 
 
 
10
  */
11
 
12
- function sitemap_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( 'sitemap', 'sitemap_shortcode' );
1
  <?php
2
  /*
3
  Plugin Name: Sitemap
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
  }