Simple Sitemap – Automatically Generate a Responsive Sitemap - Version 1.0

Version Description

Download this release

Release Info

Developer dgwyer
Plugin Icon Simple Sitemap – Automatically Generate a Responsive Sitemap
Version 1.0
Comparing to
See all releases

Version 1.0

Files changed (5) hide show
  1. readme.txt +56 -0
  2. screenshot-1.png +0 -0
  3. screenshot-2.png +0 -0
  4. simple-sitemap.php +202 -0
  5. style.css +71 -0
readme.txt ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Simple Sitemap ===
2
+ Contributors: dgwyer
3
+ Tags: html, global, sort, shortcode, pages, posts
4
+ Requires at least: 2.7
5
+ Tested up to: 3.0
6
+ Stable tag: 1.0
7
+
8
+ HTML Sitemap that displays an ordered list of posts and pages. Each list can be sorted via a drop down list of options.
9
+
10
+ == Description ==
11
+
12
+ This plugin provides an easy way to display a HTML sitemap of posts and pages on your site. This gives your visitors an efficient way to view all of your available content (posts/pages) in one place. It is also good for SEO purposes and makes it easier for spiders to index your content. The sitemap generates two ordered lists, one for posts, and one for pages. Each list can be sorted individually via a drop down list of options.
13
+
14
+ Available sorting options are:
15
+
16
+ * Title
17
+ * Author
18
+ * Date
19
+ * Post/Page ID
20
+ * Date modified
21
+ * Post/Page Order
22
+
23
+ To display the shortcode on a page, or post (though I recommended you add it to a page) just add the shortcode [simple-sitemap] and you will now have a sitemap enabled on your website.
24
+
25
+ Please rate this plugin if you find it useful, thanks.
26
+
27
+ See our <a href="http://www.presscoders.com" target="_blank">WordPress development site</a> for more information.
28
+
29
+ == Installation ==
30
+
31
+ Instructions for installing Simple Sitemap Plugin.
32
+
33
+ 1. Download and extract the Plugin zip file.
34
+ 2. Upload the folder containing the Plugin files to your WordPress Plugins folder (usually ../wp-content/plugins/ folder).
35
+ 3. Activate the Plugin via the 'Plugins' menu in WordPress.
36
+ 4. Add [simple-sitemap] shortcode to a page to display the sitemap on your site.
37
+
38
+ The plugin can also be installed directly from the main WordPress plugin page.
39
+
40
+ 1. Go to the Plugins => Add New page.
41
+ 2. Enter 'Simple Sitemap' (without quotes) in the textbox and click the 'Search Plugins' button.
42
+ 3. In the list of relevant plugins click the 'Install' link for Simple Sitemap on the right hand side of the page.
43
+ 4. Click the 'Install Now' button on the popup page.
44
+ 5. Click 'Activate Plugin' to finish installation.
45
+ 6. Add [simple-sitemap] shortcode to a page to display the sitemap on your site.
46
+
47
+ Enjoy!
48
+
49
+ == Screenshots ==
50
+
51
+ 1. Simple Sitemap by default displays pages and posts side-by-side.
52
+ 2. Just activate the plugin and add [simple-sitemap] shortcode to a page to display the sitemap.
53
+
54
+ == Changelog ==
55
+
56
+ *1.0 Initial release
screenshot-1.png ADDED
Binary file
screenshot-2.png ADDED
Binary file
simple-sitemap.php ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Simple Sitemap
4
+ Plugin URI: http://www.presscoders.com/plugins/free-plugins/simple-sitemap/
5
+ Description: HTML Sitemap that displays an ordered list of posts and pages. Each list can be sorted via a drop down list of options.
6
+ Version: 1.0
7
+ Author: David Gwyer
8
+ Author URI: http://www.presscoders.com
9
+ */
10
+
11
+ /* Copyright 2009 David Gwyer (email : d.v.gwyer@presscoders.com)
12
+
13
+ This program is free software; you can redistribute it and/or modify
14
+ it under the terms of the GNU General Public License as published by
15
+ the Free Software Foundation; either version 2 of the License, or
16
+ (at your option) any later version.
17
+
18
+ This program is distributed in the hope that it will be useful,
19
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ GNU General Public License for more details.
22
+
23
+ You should have received a copy of the GNU General Public License
24
+ along with this program; if not, write to the Free Software
25
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26
+ */
27
+
28
+ // To Do:
29
+ //
30
+ // 1. Have options in admin CP to: show posts/page/both; show post/page ID.
31
+ // 2. Be able to expand collapse each individual tree of posts/pages (plus a collapse/expand all).
32
+ // 3. Option to show 'Pages', 'Posts' header text.
33
+ // 4. Have option to show the date etc. (as users may want to sort by date, and see date etc.)
34
+ // 5. Have option to show Page/Post sitemaps side by side (default) or underneath each other (for users with long titles)
35
+ // 6. Be able to sort ascending/descending in addition to the sort drop down options for each list.
36
+ // 7. Be able to exclude individual posts/pages.
37
+
38
+ // wpss_ suffix is derived from [W]ord[P]ress [s]imple [s]itemap
39
+ add_shortcode('simple-sitemap', 'wpss_gen');
40
+ add_action('init', 'wpss_init' );
41
+ add_filter('query_vars', 'parameter_queryvars' );
42
+ //add_action( 'plugins_loaded', 'wpss_generate' );
43
+ add_action('wp_print_styles', 'add_my_stylesheet');
44
+
45
+ // ***************************************
46
+ // *** START - Create Admin Options ***
47
+ // ***************************************
48
+
49
+ // Init plugin options to white list our options
50
+ function wpss_init(){
51
+ // insert plugin init code here
52
+ }
53
+
54
+ // ***************************************
55
+ // *** END - Create Admin Options ***
56
+ // ***************************************
57
+
58
+ // ---------------------------------------------------------------------------------
59
+
60
+ // ***************************************
61
+ // *** START - Plugin Core Functions ***
62
+ // ***************************************
63
+
64
+ function add_my_stylesheet() {
65
+ $styleSheet = WP_PLUGIN_URL.'/simple-sitemap/style.css';
66
+ wp_register_style('myStyleSheets', $styleSheet);
67
+ wp_enqueue_style( 'myStyleSheets');
68
+ }
69
+
70
+ function parameter_queryvars( $qvars ) {
71
+ $qvars[] = 'pagesort';
72
+ $qvars[] = 'postsort';
73
+ return $qvars;
74
+ }
75
+
76
+ function page_params() {
77
+ global $wp_query;
78
+ if (isset($wp_query->query_vars['pagesort'])) {
79
+ return $wp_query->query_vars['pagesort'];
80
+ }
81
+ }
82
+
83
+ function post_params() {
84
+ global $wp_query;
85
+ if (isset($wp_query->query_vars['postsort'])) {
86
+ return $wp_query->query_vars['postsort'];
87
+ }
88
+ }
89
+
90
+ // shortcode function
91
+ function wpss_gen() {
92
+ global $post; //wordpress post global object
93
+ $permalink_structure = get_option( 'permalink_structure' );
94
+ if(($permalink_structure == null) || (substr($permalink_structure, -1)) != '/') {
95
+ $link_url = get_permalink($post->ID).'/';
96
+ }
97
+ else {
98
+ $link_url = get_permalink($post->ID);
99
+ }
100
+
101
+ // sort by value in drop down box (make sure drop down default is title which is the default used by wp_list_pages)
102
+ $page_params = page_params();
103
+ $post_params = post_params();
104
+
105
+ if($page_params == null ) { $page_params = 'menu_order, post_title'; } // set default
106
+ $page_args=array( 'sort_column' => $page_params,
107
+ 'title_li' => '<h2 class=\'page_heading\'>Pages</h2>'
108
+ );
109
+ if($post_params == null ) { $post_params = 'title'; } // set default
110
+ $post_args=array( 'orderby' => $post_params, 'posts_per_page' => -1 );
111
+
112
+ // page drop down box
113
+ if($page_params == 'post_title') {
114
+ $pt1 = "selected='selected'";
115
+ }
116
+ else if($page_params == 'post_date') {
117
+ $pd1 = "selected='selected'";
118
+ }
119
+ else if($page_params == 'menu_order') {
120
+ $mo1 = "selected='selected'";
121
+ }
122
+ else if($page_params == 'post_modified') {
123
+ $pm1 = "selected='selected'";
124
+ }
125
+ else if($page_params == 'ID') {
126
+ $id1 = "selected='selected'";
127
+ }
128
+ else if($page_params == 'post_author') {
129
+ $pa1 = "selected='selected'";
130
+ }
131
+
132
+ // post drop down box
133
+ if($post_params == 'title') {
134
+ $pt2 = "selected='selected'";
135
+ }
136
+ else if($post_params == 'date') {
137
+ $pd2 = "selected='selected'";
138
+ }
139
+ else if($post_params == 'menu_order') {
140
+ $mo2 = "selected='selected'";
141
+ }
142
+ else if($post_params == 'modified') {
143
+ $pm2 = "selected='selected'";
144
+ }
145
+ else if($post_params == 'ID') {
146
+ $id2 = "selected='selected'";
147
+ }
148
+ else if($post_params == 'author') {
149
+ $pa2 = "selected='selected'";
150
+ }
151
+ ?>
152
+ <table id="tbl_output">
153
+ <tr>
154
+ <td id="td_left">
155
+ <div id="page_drop_down">
156
+ <span id="page_dd_label">Sort Pages by:</span>
157
+ <select>
158
+ <option onClick="location.href='<?php echo $link_url.'?pagesort=post_title'; ?>'" <?php echo $pt1; ?>>Title</option>
159
+ <option onClick="location.href='<?php echo $link_url.'?pagesort=post_date'; ?>'" <?php echo $pd1; ?>>Date</option>
160
+ <option onClick="location.href='<?php echo $link_url.'?pagesort=menu_order'; ?>'" <?php echo $mo1; ?>>Page Order</option>
161
+ <option onClick="location.href='<?php echo $link_url.'?pagesort=post_modified'; ?>'" <?php echo $pm1; ?>>Last Modified</option>
162
+ <option onClick="location.href='<?php echo $link_url.'?pagesort=ID'; ?>'" <?php echo $id1; ?>>Page ID</option>
163
+ <option onClick="location.href='<?php echo $link_url.'?pagesort=post_author'; ?>'" <?php echo $pa1; ?>>Author</option>
164
+ </select>
165
+ </div>
166
+ <?php wp_list_pages($page_args); // show the sorted pages ?>
167
+ <!--page_sitemap-->
168
+ </td>
169
+ <td id="td_right">
170
+ <div id="post_drop_down">
171
+ <span id="post_dd_label">Sort Posts by:</span>
172
+ <select>
173
+ <option onClick="location.href='<?php echo $link_url.'?postsort=title'; ?>'" <?php echo $pt2; ?>>Title</option>
174
+ <option onClick="location.href='<?php echo $link_url.'?postsort=date'; ?>'" <?php echo $pd2; ?>>Date</option>
175
+ <option onClick="location.href='<?php echo $link_url.'?postsort=menu_order'; ?>'" <?php echo $mo2; ?>>Post Order</option>
176
+ <option onClick="location.href='<?php echo $link_url.'?postsort=modified'; ?>'" <?php echo $pm2; ?>>Last Modified</option>
177
+ <option onClick="location.href='<?php echo $link_url.'?postsort=ID'; ?>'" <?php echo $id2; ?>>Post ID</option>
178
+ <option onClick="location.href='<?php echo $link_url.'?postsort=author'; ?>'" <?php echo $pa2; ?>>Author</option>
179
+ </select>
180
+ </div>
181
+ <?php query_posts($post_args); // show the sorted posts ?>
182
+ <h2 class='post_heading'>Posts</h2>
183
+ <?php if (have_posts()) :
184
+ while (have_posts()) :
185
+ the_post(); ?>
186
+ <li id="post_item">
187
+ <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
188
+ </li>
189
+ <?php endwhile;
190
+ endif;
191
+ wp_reset_query();
192
+ ?>
193
+ </td>
194
+ </tr>
195
+ </table>
196
+
197
+ <?php
198
+ }
199
+ // ***************************************
200
+ // *** END - Plugin Core Functions ***
201
+ // ***************************************
202
+ ?>
style.css ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .pagenav {
2
+ font-family:Georgia, "Times New Roman", Times, serif;`
3
+ /*font-size:14px;*/
4
+ font-style:italic;
5
+ list-style-type: none;
6
+ margin: 0px 0px 0px 10px;
7
+ }
8
+
9
+ #content .page_heading {
10
+ margin: 0px 0px 2px 0px;
11
+ font-size: 16px;
12
+ font-style: italic;
13
+ }
14
+
15
+ #content #tbl_output {
16
+ border:0px white solid;
17
+ }
18
+
19
+ /* Page Sitemap CSS */
20
+ .pagenav .page_item {
21
+ font-size: 16px;
22
+ font-weight: normal;
23
+ font-style: normal;
24
+ /*list-style-type: none;*/
25
+ }
26
+
27
+ #content #td_left {
28
+ border: 0px white solid;
29
+ border-right:1px #eee solid;
30
+ width:50%;
31
+ }
32
+
33
+ #page_dd_label {
34
+ margin-right:5px;
35
+ }
36
+
37
+ #page_drop_down {
38
+ margin: 15px 0px -10px 10px;
39
+ }
40
+
41
+ /* Post Sitemap CSS */
42
+ #post_item {
43
+ font-size: 16px;
44
+ font-weight: normal;
45
+ font-style: normal;
46
+ /*list-style-type: none;*/
47
+ }
48
+
49
+ #content #td_right {
50
+ border: 0px white solid;
51
+ width:50%;
52
+ }
53
+
54
+ #post_dd_label {
55
+ margin-right:5px;
56
+ }
57
+
58
+ #post_item {
59
+ border: 0px red solid;
60
+ margin:0px 0px 0px 20px;
61
+ }
62
+
63
+ #post_drop_down {
64
+ margin: 15px 0px -10px 0px;
65
+ }
66
+
67
+ #content .post_heading {
68
+ margin: 0px 0px 2px 0px;
69
+ font-size: 16px;
70
+ font-style: italic;
71
+ }