HTML Page Sitemap - Version 1.3

Version Description

  • Released on 11/24/2015
  • Added ordered_list_type option to use an ordered list rather than unordered. (Thanks Allie for the feature suggestion!)
  • Tested with WordPress 4.4 beta 4
Download this release

Release Info

Developer amandato
Plugin Icon wp plugin HTML Page Sitemap
Version 1.3
Comparing to
See all releases

Code changes from version 1.2 to 1.3

Files changed (2) hide show
  1. html-sitemap.php +48 -13
  2. readme.txt +29 -8
html-sitemap.php CHANGED
@@ -3,12 +3,12 @@
3
  Plugin Name: HTML Page Sitemap
4
  Plugin URI: http://www.pluginspodcast.com/plugins/html-page-sitemap/
5
  Description: <a href="http://www.pluginspodcast.com/plugins/html-page-sitemap/" target="_blank">HTML Page Sitemap</a> Adds an HTML (Not XML) sitemap of your blog pages (not posts) by entering the shortcode [html_sitemap]. A plugin from <a href="http://www.pluginspodcast.com/" target="_blank">Plugins: The WordPress Plugins Podcast</a>.
6
- Version: 1.2
7
  Contributors: Angelo Mandato, CIO RawVoice and host of the PluginsPodcast.com
8
  Author URI: http://www.pluginspodcast.com/
9
 
10
  Requires at least: 3.7
11
- Tested up to: 4.1
12
  Text Domain: html-sitemap
13
  Change Log: See readme.txt for complete change log
14
  Contributors: Angelo Mandato, CIO RawVoice and host of the PluginsPodcast.com
@@ -30,25 +30,40 @@ function html_sitemap_shortcode_handler( $args, $content = null )
30
  return '';
31
 
32
  $class_tag = '';
33
- if( !empty($args['class']) ) {
34
- $class_tag = $args['class'];
 
35
  unset($args['class']);
36
  }
37
 
38
  $id_tag = '';
39
- if( !empty($args['id']) ) {
40
- $id_tag = $args['id'];
 
41
  unset($args['id']);
42
  }
43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  $args['echo'] = 0;
45
  $args['title_li'] = '';
46
  unset($args['link_before']);
47
  unset($args['link_after']);
48
- if( isset($args['child_of']) && $args['child_of'] == 'CURRENT' )
49
  $args['child_of'] = get_the_ID();
50
- else if( isset($args['child_of']) && $args['child_of'] == 'PARENT' )
51
- {
52
  $post = &get_post( get_the_ID() );
53
  if( $post->post_parent )
54
  $args['child_of'] = $post->post_parent;
@@ -61,15 +76,35 @@ function html_sitemap_shortcode_handler( $args, $content = null )
61
  // Remove the classes added by WordPress
62
  $html = preg_replace('/( class="[^"]+")/is', '', $html);
63
 
64
- $prefix = '<ul';
65
- if( !empty($id_tag) )
 
 
 
 
 
 
 
 
 
 
 
66
  $prefix .= ' id="'. esc_attr($id_tag) .'"';
 
67
 
68
- if( !empty($class_tag) )
69
  $prefix .= ' class="'. esc_attr($class_tag) .'"';
 
70
  $prefix .= '>';
71
 
72
- return $prefix . $html .'</ul>';
 
 
 
 
 
 
 
73
  }
74
 
75
  add_shortcode('html-sitemap', 'html_sitemap_shortcode_handler'); // This is no longer recommended as any plugin that creates their own shortcode starting with 'html' will also get the handler call
3
  Plugin Name: HTML Page Sitemap
4
  Plugin URI: http://www.pluginspodcast.com/plugins/html-page-sitemap/
5
  Description: <a href="http://www.pluginspodcast.com/plugins/html-page-sitemap/" target="_blank">HTML Page Sitemap</a> Adds an HTML (Not XML) sitemap of your blog pages (not posts) by entering the shortcode [html_sitemap]. A plugin from <a href="http://www.pluginspodcast.com/" target="_blank">Plugins: The WordPress Plugins Podcast</a>.
6
+ Version: 1.3
7
  Contributors: Angelo Mandato, CIO RawVoice and host of the PluginsPodcast.com
8
  Author URI: http://www.pluginspodcast.com/
9
 
10
  Requires at least: 3.7
11
+ Tested up to: 4.4
12
  Text Domain: html-sitemap
13
  Change Log: See readme.txt for complete change log
14
  Contributors: Angelo Mandato, CIO RawVoice and host of the PluginsPodcast.com
30
  return '';
31
 
32
  $class_tag = '';
33
+ if( isset($args['class']) ) {
34
+ if( !empty($args['class']) )
35
+ $class_tag = $args['class'];
36
  unset($args['class']);
37
  }
38
 
39
  $id_tag = '';
40
+ if( isset($args['id']) ) {
41
+ if( !empty($args['id']) )
42
+ $id_tag = $args['id'];
43
  unset($args['id']);
44
  }
45
 
46
+ $ordered_type = '';
47
+ if( isset($args['ordered_list_type']) ) {
48
+ if( !empty($args['ordered_list_type'])) {
49
+ switch( $args['ordered_list_type'] ) {
50
+ case '1':
51
+ case 'i':
52
+ case 'I':
53
+ case 'a':
54
+ case 'A': { $ordered_type = $args['ordered_list_type']; }; break;
55
+ }
56
+ }
57
+ unset($args['ordered_list_type']);
58
+ }
59
+
60
  $args['echo'] = 0;
61
  $args['title_li'] = '';
62
  unset($args['link_before']);
63
  unset($args['link_after']);
64
+ if( isset($args['child_of']) && $args['child_of'] == 'CURRENT' ) {
65
  $args['child_of'] = get_the_ID();
66
+ } else if( isset($args['child_of']) && $args['child_of'] == 'PARENT' ) {
 
67
  $post = &get_post( get_the_ID() );
68
  if( $post->post_parent )
69
  $args['child_of'] = $post->post_parent;
76
  // Remove the classes added by WordPress
77
  $html = preg_replace('/( class="[^"]+")/is', '', $html);
78
 
79
+ if( !empty($ordered_type) ) {
80
+ // swap the type ul with ol and set the type="$ordered_type"
81
+ $html = preg_replace('/(<ul)/is', '<ol type="'. esc_attr($ordered_type) .'"', $html);
82
+ $html = preg_replace('/(<\/ul)/is', '</ol', $html);
83
+ }
84
+
85
+ if( empty($ordered_type) ) {
86
+ $prefix = '<ul';
87
+ } else {
88
+ $prefix = '<ol type="'. esc_attr($ordered_type) .'"';
89
+ }
90
+
91
+ if( !empty($id_tag) ) {
92
  $prefix .= ' id="'. esc_attr($id_tag) .'"';
93
+ }
94
 
95
+ if( !empty($class_tag) ) {
96
  $prefix .= ' class="'. esc_attr($class_tag) .'"';
97
+ }
98
  $prefix .= '>';
99
 
100
+ if( empty($ordered_type) ) {
101
+ return $prefix . $html .'</ul>';
102
+ }
103
+ return $prefix . $html .'</ol>';
104
+ }
105
+
106
+ function html_sitemap_something_to_translate() {
107
+ $null = __('HTML Page Sitemap', 'html-sitemap'); // We need to provide something to tranlate so the plugin can be translated at translate.wordpress.org
108
  }
109
 
110
  add_shortcode('html-sitemap', 'html_sitemap_shortcode_handler'); // This is no longer recommended as any plugin that creates their own shortcode starting with 'html' will also get the handler call
readme.txt CHANGED
@@ -3,19 +3,33 @@ Contributors: amandato, pluginspodcast
3
  Donate link: http://www.pluginspodcast.com/contact/
4
  Tags: sitemap, page, pages, shortcode, cms, static, short code, map, pagemap, site, html, html sitemap, nav, navigation
5
  Requires at least: 2.7.0
6
- Tested up to: 4.3
7
- Stable tag: 1.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
  Adds an HTML (Not XML) sitemap of your pages (not posts) by entering the shortcode [html_sitemap], perfect for those who use WordPress as a CMS.
12
 
13
  == Description ==
14
- This simple plugin adds an HTML (Not XML) sitemap of your pages (not posts) by entering the shortcode [html_sitemap] in the page content. This simple plugin is configured with the `[html_sitemap]` shortcode. This plugin can display a sitemap with specific depths, from a specific parent page and include/exclude specific children. Shortcode attributes include `sort_column`, `sort_order`, `exclude`, `include`, `depth`, `child_of`, `meta_key`, `meta_value`, `authors`, `number`, `offset`, `post_type`, `post_status`, `class` and `id`. You can essentially configure everything the [`wp_list_pages`](https://codex.wordpress.org/Function_Reference/wp_list_pages) function accepts.
 
 
 
 
 
 
 
 
15
 
16
  The `child_of` attribute value can be a numeric page ID (integer), or use the custom value CURRENT or PARENT. The value "CURRENT" will use the current page's ID. The value "PARENT" will uses the curent page's parent ID.
17
 
18
- This plugin is perfect for those who use WordPress as a CMS.
 
 
 
 
 
 
19
 
20
  Note: This plugin only works with Hierarchical Custom Post Types. This plugin will not work if your post type is not heirarchical.
21
 
@@ -42,7 +56,7 @@ Example shortcode will add a sitemap displaying the page modified date with the
42
 
43
  Example shortcode excluding multiple pages with ids 708, 1024 and 42.
44
 
45
- `[html_sitemap class="your-custom-class"]`
46
 
47
  Example shortcode will add a class attribute to the `<ul>` tag.
48
 
@@ -52,9 +66,9 @@ Example shortcode will add an id attribute to the `<ul>` tag.
52
 
53
  `[html_sitemap id="custom-element-id"]`
54
 
55
- Please see the [Template Documentation for the wp _ list _ pages function](http://codex.wordpress.org/Template_Tags/wp_list_pages) for detailed documentation of the available attributes and their values.
56
 
57
- Anything you can do with the `wp_list_pages` function you should be able to do with this shortcode.
58
 
59
  For the latest information visit the website.
60
 
@@ -76,7 +90,8 @@ Install using the [built-in plugin installer](https://codex.wordpress.org/Admini
76
  2. Type in "HTML Page Sitemap" in *Search* Plugins box.
77
  3. Find "HTML Page Sitemap" in the search results.
78
  4. Click *Install Now* to install the WordPress Plugin.
79
-
 
80
 
81
  = Manual Plugin Installation =
82
 
@@ -92,6 +107,12 @@ Install using the [built-in plugin installer](https://codex.wordpress.org/Admini
92
 
93
  == Changelog ==
94
 
 
 
 
 
 
 
95
  = 1.2 =
96
  * Released on 9/15/2015
97
  * Tested with WordPress 4.3.
3
  Donate link: http://www.pluginspodcast.com/contact/
4
  Tags: sitemap, page, pages, shortcode, cms, static, short code, map, pagemap, site, html, html sitemap, nav, navigation
5
  Requires at least: 2.7.0
6
+ Tested up to: 4.4
7
+ Stable tag: 1.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
  Adds an HTML (Not XML) sitemap of your pages (not posts) by entering the shortcode [html_sitemap], perfect for those who use WordPress as a CMS.
12
 
13
  == Description ==
14
+ This simple plugin adds an HTML (Not XML) sitemap of your pages (not posts) by entering the shortcode [html_sitemap] in the page content. This simple plugin is configured with the `[html_sitemap]` shortcode. This plugin can display a sitemap with specific depths, from a specific parent page and include/exclude specific children. Shortcode attributes include `sort_column`, `sort_order`, `exclude`, `include`, `depth`, `child_of`, `meta_key`, `meta_value`, `authors`, `number`, `offset`, `post_type`, and `post_status`, everything the [`wp_list_pages`](https://codex.wordpress.org/Function_Reference/wp_list_pages) function accepts. In addition to the `wp_list_pages` options you can also set `class`, `id`, and `ordered_list_type` options.
15
+
16
+ **This plugin is perfect for those who use WordPress as a CMS.**
17
+
18
+ Please see documentation for the [`wp_list_pages`](https://codex.wordpress.org/Function_Reference/wp_list_pages) for a complete list of options.
19
+
20
+ The following options may be configured in addition to options documented in [`wp_list_pages`](https://codex.wordpress.org/Function_Reference/wp_list_pages):
21
+
22
+ The `class` and `id` attributes may specified set class or id values for the initial HTML Page Sitemap `<ul>` list tag.
23
 
24
  The `child_of` attribute value can be a numeric page ID (integer), or use the custom value CURRENT or PARENT. The value "CURRENT" will use the current page's ID. The value "PARENT" will uses the curent page's parent ID.
25
 
26
+ The `ordered_list_type` attribute is an HTML Page Sitemap plugin exclusive option for specfiying an ordered list type. Not setting a ordered_list_type will use an unordered list (default).
27
+
28
+ * `ordered_list_type="1"` - The list items will be numbered with numbers
29
+ * `ordered_list_type="A"` - The list items will be numbered with uppercase letters
30
+ * `ordered_list_type="a"` - The list items will be numbered with lowercase letters
31
+ * `ordered_list_type="I"` - The list items will be numbered with uppercase roman numbers
32
+ * `ordered_list_type="i"` - The list items will be numbered with lowercase roman numbers
33
 
34
  Note: This plugin only works with Hierarchical Custom Post Types. This plugin will not work if your post type is not heirarchical.
35
 
56
 
57
  Example shortcode excluding multiple pages with ids 708, 1024 and 42.
58
 
59
+ `[html_sitemap exclude="708,1024,42"]`
60
 
61
  Example shortcode will add a class attribute to the `<ul>` tag.
62
 
66
 
67
  `[html_sitemap id="custom-element-id"]`
68
 
69
+ Example shortcode will display an ordered list using lowercase letters with a depth of 1.
70
 
71
+ `[html_sitemap ordered_list_type="a" depth=1]`
72
 
73
  For the latest information visit the website.
74
 
90
  2. Type in "HTML Page Sitemap" in *Search* Plugins box.
91
  3. Find "HTML Page Sitemap" in the search results.
92
  4. Click *Install Now* to install the WordPress Plugin.
93
+ 5. Click Activate to activate it.
94
+ 6. Add the shortcode [html_sitemap] to the page(s) of your choice.
95
 
96
  = Manual Plugin Installation =
97
 
107
 
108
  == Changelog ==
109
 
110
+ = 1.3 =
111
+ * Released on 11/24/2015
112
+ * Added `ordered_list_type` option to use an ordered list rather than unordered. (Thanks Allie for the feature suggestion!)
113
+ * Tested with WordPress 4.4 beta 4
114
+
115
+
116
  = 1.2 =
117
  * Released on 9/15/2015
118
  * Tested with WordPress 4.3.