Version Description
- Removed database code from admin_init as was being called on every admin page.
- Added post limit to show x number of posts only, currently limited to 9999.
Download this release
Release Info
Developer | Rincewind |
Plugin | WP Realtime Sitemap |
Version | 1.4.5 |
Comparing to | |
See all releases |
Code changes from version 1.4.4 to 1.4.5
- readme.txt +4 -0
- wp-realtime-sitemap.php +46 -126
readme.txt
CHANGED
@@ -96,6 +96,10 @@ Brazilian Portuguese translation kindly done by gervasioantonio.
|
|
96 |
|
97 |
== Changelog ==
|
98 |
|
|
|
|
|
|
|
|
|
99 |
= 1.4.4 =
|
100 |
* Added option to reset database settings back to defaults.
|
101 |
* Fixed code when using `[wp-realtime-sitemap show="all"]` and not correctly showing tags and/or categories as tag clouds or not.
|
96 |
|
97 |
== Changelog ==
|
98 |
|
99 |
+
= 1.4.5 =
|
100 |
+
* Removed database code from admin_init as was being called on every admin page.
|
101 |
+
* Added post limit to show x number of posts only, currently limited to 9999.
|
102 |
+
|
103 |
= 1.4.4 =
|
104 |
* Added option to reset database settings back to defaults.
|
105 |
* Fixed code when using `[wp-realtime-sitemap show="all"]` and not correctly showing tags and/or categories as tag clouds or not.
|
wp-realtime-sitemap.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
Plugin Name: WP Realtime Sitemap
|
5 |
Plugin URI: http://www.daniel-tweedy.co.uk/redir/wp-realtime-sitemap-home/
|
6 |
Description: Adds a sitemap to your Wordpress blog that is always up-to-date. Add `[wp-realtime-sitemap show="all"]` to any page or post and the site map will be added there. Use Settings->WP Realtime Sitemap to set options.
|
7 |
-
Version: 1.4.
|
8 |
Author: Daniel Tweedy
|
9 |
Author URI: http://www.daniel-tweedy.co.uk/
|
10 |
License: GPL2
|
@@ -49,17 +49,18 @@ function wprs_options_form() {
|
|
49 |
$options['show_date'] = $_POST['show_date'];
|
50 |
$options['show_pages'] = $_POST['show_pages'];
|
51 |
$options['show_posts'] = $_POST['show_posts'];
|
|
|
52 |
$options['show_archives'] = $_POST['show_archives'];
|
53 |
$options['show_categories'] = $_POST['show_categories'];
|
54 |
$options['category_tagcloud'] = $_POST['category_tagcloud'];
|
55 |
$options['show_tags'] = $_POST['show_tags'];
|
56 |
$options['tags_tagcloud'] = $_POST['tags_tagcloud'];
|
57 |
|
58 |
-
// Update settings
|
59 |
update_option('plugin_wp_realtime_sitemap_settings', $options);
|
60 |
|
61 |
-
//
|
62 |
-
extract(
|
63 |
}
|
64 |
|
65 |
// Check if we have a posted form to deal with.
|
@@ -67,27 +68,53 @@ function wprs_options_form() {
|
|
67 |
// check admin security.
|
68 |
check_admin_referer('wp-realtime-sitemap');
|
69 |
|
70 |
-
|
71 |
-
update_option('plugin_wp_realtime_sitemap_settings', array(
|
72 |
'sort_column' => 'post_date',
|
73 |
'sort_order' => 'ASC',
|
74 |
'show_count' => 'no',
|
75 |
'show_date' => 'no',
|
76 |
'show_pages' => 'yes',
|
77 |
'show_posts' => 'yes',
|
|
|
78 |
'show_archives' => 'yes',
|
79 |
'show_categories' => 'yes',
|
80 |
'category_tagcloud' => 'no',
|
81 |
'show_tags' => 'no',
|
82 |
'tags_tagcloud' => 'no',
|
83 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
|
|
|
85 |
// Get current options from the database.
|
86 |
extract(get_option('plugin_wp_realtime_sitemap_settings'));
|
87 |
}
|
88 |
-
|
89 |
-
// Get current options from the database.
|
90 |
-
extract(get_option('plugin_wp_realtime_sitemap_settings'));
|
91 |
?>
|
92 |
<div class="wrap">
|
93 |
<?php screen_icon(); ?>
|
@@ -143,6 +170,10 @@ function wprs_options_form() {
|
|
143 |
<option value="no" <?php selected('no', $show_posts); ?>><?php _e('No/Off', 'wp-realtime-sitemap'); ?></option>
|
144 |
</select></td>
|
145 |
</tr>
|
|
|
|
|
|
|
|
|
146 |
<tr valign="top">
|
147 |
<th scope="row"><label for="show_archives"><?php _e('Show archives', 'wp-realtime-sitemap'); ?></label></th>
|
148 |
<td><select name="show_archives">
|
@@ -167,8 +198,8 @@ function wprs_options_form() {
|
|
167 |
<tr valign="top">
|
168 |
<th scope="row"><label for="show_tags"><?php _e('Show tags', 'wp-realtime-sitemap'); ?></label></th>
|
169 |
<td><select name="show_tags">
|
170 |
-
<option value="yes" <?php selected('yes', $show_tags); ?>><?php _e('Yes/On
|
171 |
-
<option value="no" <?php selected('no', $show_tags); ?>><?php _e('No/Off', 'wp-realtime-sitemap'); ?></option>
|
172 |
</select></td>
|
173 |
</tr>
|
174 |
<tr valign="top">
|
@@ -211,6 +242,7 @@ function wp_realtime_sitemap($atts, $content=null, $code='') {
|
|
211 |
'sort_order' => $all_options['sort_order'],
|
212 |
'show_count' => $all_options['show_count'],
|
213 |
'show_date' => $all_options['show_date'],
|
|
|
214 |
), $atts));
|
215 |
|
216 |
if ($show == 'categories') {
|
@@ -236,7 +268,7 @@ function wp_realtime_sitemap($atts, $content=null, $code='') {
|
|
236 |
$post_args = array(
|
237 |
'orderby' => $sort_column,
|
238 |
'order' => $sort_order,
|
239 |
-
'posts_per_page' =>
|
240 |
);
|
241 |
|
242 |
// The Query
|
@@ -368,119 +400,7 @@ function wprs_admin_menu() {
|
|
368 |
}
|
369 |
add_action('admin_menu', 'wprs_admin_menu');
|
370 |
|
371 |
-
function wprs_admin_init() {
|
372 |
-
$orderby = get_option('wp_realtime_sitemap_orderby');
|
373 |
-
|
374 |
-
if ($orderby == 'datedesc' || $orderby == 'dateasc')
|
375 |
-
$sort_column = 'post_date';
|
376 |
-
|
377 |
-
if ($orderby == 'alphadesc' || $orderby == 'alphaasc')
|
378 |
-
$sort_column = 'post_title';
|
379 |
-
|
380 |
-
if ($orderby == 'datedesc' || $orderby == 'alphadesc')
|
381 |
-
$sort_order = 'DESC';
|
382 |
-
|
383 |
-
if ($orderby == 'dateasc' || $orderby == 'alphaasc')
|
384 |
-
$sort_order = 'ASC';
|
385 |
-
|
386 |
-
// show_pages
|
387 |
-
if (get_option('wp_realtime_sitemap_showpages') !== false) {
|
388 |
-
$show_pages = get_option('wp_realtime_sitemap_showpages');
|
389 |
-
} else if (get_option('wp_realtime_sitemap_pages') !== false) {
|
390 |
-
$show_pages = get_option('wp_realtime_sitemap_pages');
|
391 |
-
}
|
392 |
-
|
393 |
-
// show_posts
|
394 |
-
if (get_option('wp_realtime_sitemap_showposts') !== false) {
|
395 |
-
$show_posts = get_option('wp_realtime_sitemap_showposts');
|
396 |
-
} else if (get_option('wp_realtime_sitemap_posts') !== false) {
|
397 |
-
$show_posts = get_option('wp_realtime_sitemap_posts');
|
398 |
-
}
|
399 |
-
|
400 |
-
// show_archives
|
401 |
-
if (get_option('wp_realtime_sitemap_showarchives') !== false) {
|
402 |
-
$show_archives = get_option('wp_realtime_sitemap_showarchives');
|
403 |
-
} else if (get_option('wp_realtime_sitemap_archives') !== false) {
|
404 |
-
$show_archives = get_option('wp_realtime_sitemap_archives');
|
405 |
-
}
|
406 |
-
|
407 |
-
// show_categories
|
408 |
-
if (get_option('wp_realtime_sitemap_showcategories') !== false) {
|
409 |
-
$show_categories = get_option('wp_realtime_sitemap_showcategories');
|
410 |
-
} else if (get_option('wp_realtime_sitemap_categories') !== false) {
|
411 |
-
$show_categories = get_option('wp_realtime_sitemap_categories');
|
412 |
-
}
|
413 |
-
|
414 |
-
// category_tagcloud
|
415 |
-
if (get_option('wp_realtime_sitemap_showcategoriesastc') !== false) {
|
416 |
-
$category_tagcloud = get_option('wp_realtime_sitemap_showcategoriesastc');
|
417 |
-
}
|
418 |
-
|
419 |
-
// show_tags
|
420 |
-
if (get_option('wp_realtime_sitemap_showtags') !== false) {
|
421 |
-
$show_tags = get_option('wp_realtime_sitemap_showtags');
|
422 |
-
} else if (get_option('wp_realtime_sitemap_tags') !== false) {
|
423 |
-
$show_tags = get_option('wp_realtime_sitemap_tags');
|
424 |
-
}
|
425 |
-
|
426 |
-
// tags_tagcloud
|
427 |
-
if (get_option('wp_realtime_sitemap_showtagsastc') !== false) {
|
428 |
-
$tags_tagcloud = get_option('wp_realtime_sitemap_showtagsastc');
|
429 |
-
}
|
430 |
-
|
431 |
-
if (get_option('plugin_wp_realtime_sitemap_settings') === false) {
|
432 |
-
// Add default options if first time running - http://striderweb.com/nerdaphernalia/2008/07/consolidate-options-with-arrays/
|
433 |
-
add_option('plugin_wp_realtime_sitemap_settings', array(
|
434 |
-
'sort_column' => (!isset($sort_column)) ? 'post_date' : $sort_column,
|
435 |
-
'sort_order' => (!isset($sort_order)) ? 'ASC' : $sort_order,
|
436 |
-
'show_count' => 'no',
|
437 |
-
'show_date' => 'no',
|
438 |
-
'show_pages' => (!isset($show_pages)) ? 'yes' : $show_pages,
|
439 |
-
'show_posts' => (!isset($show_posts)) ? 'yes' : $show_posts,
|
440 |
-
'show_archives' => (!isset($show_archives)) ? 'yes' : $show_archives,
|
441 |
-
'show_categories' => (!isset($show_categories)) ? 'yes' : $show_categories,
|
442 |
-
'category_tagcloud' => (!isset($category_tagcloud)) ? 'no' : $category_tagcloud,
|
443 |
-
'show_tags' => (!isset($show_tags)) ? 'no' : $show_tags,
|
444 |
-
'tags_tagcloud' => (!isset($tags_tagcloud)) ? 'no' : $tags_tagcloud,
|
445 |
-
));
|
446 |
-
} else {
|
447 |
-
// Add default options if first time running - http://striderweb.com/nerdaphernalia/2008/07/consolidate-options-with-arrays/
|
448 |
-
update_option('plugin_wp_realtime_sitemap_settings', array(
|
449 |
-
'sort_column' => (!isset($sort_column)) ? 'post_date' : $sort_column,
|
450 |
-
'sort_order' => (!isset($sort_order)) ? 'ASC' : $sort_order,
|
451 |
-
'show_count' => 'no',
|
452 |
-
'show_date' => 'no',
|
453 |
-
'show_pages' => (!isset($show_pages)) ? 'yes' : $show_pages,
|
454 |
-
'show_posts' => (!isset($show_posts)) ? 'yes' : $show_posts,
|
455 |
-
'show_archives' => (!isset($show_archives)) ? 'yes' : $show_archives,
|
456 |
-
'show_categories' => (!isset($show_categories)) ? 'yes' : $show_categories,
|
457 |
-
'category_tagcloud' => (!isset($category_tagcloud)) ? 'no' : $category_tagcloud,
|
458 |
-
'show_tags' => (!isset($show_tags)) ? 'no' : $show_tags,
|
459 |
-
'tags_tagcloud' => (!isset($tags_tagcloud)) ? 'no' : $tags_tagcloud,
|
460 |
-
));
|
461 |
-
}
|
462 |
-
|
463 |
-
// Delete old unused database entries - v1.0
|
464 |
-
delete_option('wp_realtime_sitemap_orderby');
|
465 |
-
delete_option('wp_realtime_sitemap_private');
|
466 |
-
delete_option('wp_realtime_sitemap_pages');
|
467 |
-
delete_option('wp_realtime_sitemap_posts');
|
468 |
-
delete_option('wp_realtime_sitemap_tags');
|
469 |
-
delete_option('wp_realtime_sitemap_archives');
|
470 |
-
delete_option('wp_realtime_sitemap_displayorder');
|
471 |
-
|
472 |
-
// Delete old unused database entries - v1.1
|
473 |
-
delete_option('wp_realtime_sitemap_orderby');
|
474 |
-
delete_option('wp_realtime_sitemap_showprivate');
|
475 |
-
delete_option('wp_realtime_sitemap_showpages');
|
476 |
-
delete_option('wp_realtime_sitemap_showposts');
|
477 |
-
delete_option('wp_realtime_sitemap_showarchives');
|
478 |
-
delete_option('wp_realtime_sitemap_showcategories');
|
479 |
-
delete_option('wp_realtime_sitemap_showcategoriesastc');
|
480 |
-
delete_option('wp_realtime_sitemap_showtags');
|
481 |
-
delete_option('wp_realtime_sitemap_showtagsastc');
|
482 |
-
delete_option('wp_realtime_sitemap_displayorder');
|
483 |
-
}
|
484 |
add_action('admin_init', 'wprs_admin_init');
|
485 |
|
486 |
function wprs_contextual_help( $help, $screen ) {
|
4 |
Plugin Name: WP Realtime Sitemap
|
5 |
Plugin URI: http://www.daniel-tweedy.co.uk/redir/wp-realtime-sitemap-home/
|
6 |
Description: Adds a sitemap to your Wordpress blog that is always up-to-date. Add `[wp-realtime-sitemap show="all"]` to any page or post and the site map will be added there. Use Settings->WP Realtime Sitemap to set options.
|
7 |
+
Version: 1.4.5
|
8 |
Author: Daniel Tweedy
|
9 |
Author URI: http://www.daniel-tweedy.co.uk/
|
10 |
License: GPL2
|
49 |
$options['show_date'] = $_POST['show_date'];
|
50 |
$options['show_pages'] = $_POST['show_pages'];
|
51 |
$options['show_posts'] = $_POST['show_posts'];
|
52 |
+
$options['post_limit'] = $_POST['post_limit'];
|
53 |
$options['show_archives'] = $_POST['show_archives'];
|
54 |
$options['show_categories'] = $_POST['show_categories'];
|
55 |
$options['category_tagcloud'] = $_POST['category_tagcloud'];
|
56 |
$options['show_tags'] = $_POST['show_tags'];
|
57 |
$options['tags_tagcloud'] = $_POST['tags_tagcloud'];
|
58 |
|
59 |
+
// Update database with settings submitted via the form.
|
60 |
update_option('plugin_wp_realtime_sitemap_settings', $options);
|
61 |
|
62 |
+
// Extract submitted options into variables.
|
63 |
+
extract($options);
|
64 |
}
|
65 |
|
66 |
// Check if we have a posted form to deal with.
|
68 |
// check admin security.
|
69 |
check_admin_referer('wp-realtime-sitemap');
|
70 |
|
71 |
+
$defaultOptions = array(
|
|
|
72 |
'sort_column' => 'post_date',
|
73 |
'sort_order' => 'ASC',
|
74 |
'show_count' => 'no',
|
75 |
'show_date' => 'no',
|
76 |
'show_pages' => 'yes',
|
77 |
'show_posts' => 'yes',
|
78 |
+
'post_limit' => '-1',
|
79 |
'show_archives' => 'yes',
|
80 |
'show_categories' => 'yes',
|
81 |
'category_tagcloud' => 'no',
|
82 |
'show_tags' => 'no',
|
83 |
'tags_tagcloud' => 'no',
|
84 |
+
);
|
85 |
+
|
86 |
+
// Update database with default settings.
|
87 |
+
update_option('plugin_wp_realtime_sitemap_settings', $defaultOptions);
|
88 |
+
|
89 |
+
// Extract default options into variables.
|
90 |
+
extract($defaultOptions);
|
91 |
+
|
92 |
+
// Delete old unused database entries - v1.0
|
93 |
+
delete_option('wp_realtime_sitemap_orderby');
|
94 |
+
delete_option('wp_realtime_sitemap_private');
|
95 |
+
delete_option('wp_realtime_sitemap_pages');
|
96 |
+
delete_option('wp_realtime_sitemap_posts');
|
97 |
+
delete_option('wp_realtime_sitemap_tags');
|
98 |
+
delete_option('wp_realtime_sitemap_archives');
|
99 |
+
delete_option('wp_realtime_sitemap_displayorder');
|
100 |
+
|
101 |
+
// Delete old unused database entries - v1.1
|
102 |
+
delete_option('wp_realtime_sitemap_orderby');
|
103 |
+
delete_option('wp_realtime_sitemap_showprivate');
|
104 |
+
delete_option('wp_realtime_sitemap_showpages');
|
105 |
+
delete_option('wp_realtime_sitemap_showposts');
|
106 |
+
delete_option('wp_realtime_sitemap_showarchives');
|
107 |
+
delete_option('wp_realtime_sitemap_showcategories');
|
108 |
+
delete_option('wp_realtime_sitemap_showcategoriesastc');
|
109 |
+
delete_option('wp_realtime_sitemap_showtags');
|
110 |
+
delete_option('wp_realtime_sitemap_showtagsastc');
|
111 |
+
delete_option('wp_realtime_sitemap_displayorder');
|
112 |
+
}
|
113 |
|
114 |
+
if (!isset($_POST['info_update']) && !isset($_POST['reset_options'])) {
|
115 |
// Get current options from the database.
|
116 |
extract(get_option('plugin_wp_realtime_sitemap_settings'));
|
117 |
}
|
|
|
|
|
|
|
118 |
?>
|
119 |
<div class="wrap">
|
120 |
<?php screen_icon(); ?>
|
170 |
<option value="no" <?php selected('no', $show_posts); ?>><?php _e('No/Off', 'wp-realtime-sitemap'); ?></option>
|
171 |
</select></td>
|
172 |
</tr>
|
173 |
+
<tr valign="top">
|
174 |
+
<th scope="row"><label for="post_limit"><?php _e('Post limit', 'wp-realtime-sitemap'); ?></label></th>
|
175 |
+
<td><input value="<?php echo $post_limit; ?>" type="text" name="post_limit" size="4" /> -1 to show all posts.</td>
|
176 |
+
</tr>
|
177 |
<tr valign="top">
|
178 |
<th scope="row"><label for="show_archives"><?php _e('Show archives', 'wp-realtime-sitemap'); ?></label></th>
|
179 |
<td><select name="show_archives">
|
198 |
<tr valign="top">
|
199 |
<th scope="row"><label for="show_tags"><?php _e('Show tags', 'wp-realtime-sitemap'); ?></label></th>
|
200 |
<td><select name="show_tags">
|
201 |
+
<option value="yes" <?php selected('yes', $show_tags); ?>><?php _e('Yes/On', 'wp-realtime-sitemap'); ?></option>
|
202 |
+
<option value="no" <?php selected('no', $show_tags); ?>><?php _e('No/Off (Default)', 'wp-realtime-sitemap'); ?></option>
|
203 |
</select></td>
|
204 |
</tr>
|
205 |
<tr valign="top">
|
242 |
'sort_order' => $all_options['sort_order'],
|
243 |
'show_count' => $all_options['show_count'],
|
244 |
'show_date' => $all_options['show_date'],
|
245 |
+
'post_limit' => $all_options['post_limit'],
|
246 |
), $atts));
|
247 |
|
248 |
if ($show == 'categories') {
|
268 |
$post_args = array(
|
269 |
'orderby' => $sort_column,
|
270 |
'order' => $sort_order,
|
271 |
+
'posts_per_page' => $post_limit,
|
272 |
);
|
273 |
|
274 |
// The Query
|
400 |
}
|
401 |
add_action('admin_menu', 'wprs_admin_menu');
|
402 |
|
403 |
+
function wprs_admin_init() { }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
404 |
add_action('admin_init', 'wprs_admin_init');
|
405 |
|
406 |
function wprs_contextual_help( $help, $screen ) {
|