Google XML Sitemap Generator - Version 1.1

Version Description

Release Date: July 27nd, 2015

  • Fix : RSS sitemap date format issue
  • Fix : XML sitemap date issue
  • Fix : Pagination counting pages
  • Fix : Logging null value error
  • Fix : Ping issues
Download this release

Release Info

Developer XmlSitemapGenerator
Plugin Icon 128x128 Google XML Sitemap Generator
Version 1.1
Comparing to
See all releases

Version 1.1

XmlSitemap.xsl ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <xsl:stylesheet version="1.0" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
3
+ <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes" />
4
+ <xsl:template match="/">
5
+ <html xmlns="http://www.w3.org/1999/xhtml">
6
+ <head>
7
+ <title>Wordpress XML Sitemap Generator Plugin</title>
8
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
9
+ <meta name="robots" content="index,follow" />
10
+ <style type="text/css">
11
+ body {font-family:Tahoma, Verdana, Arial, sans-serif;font-size:12px; }
12
+ #header { padding:0px; margin-top:10px; margin-bottom:20px;}
13
+ a {text-decoration:none; color:blue;}
14
+ table {margin-bottom:50px;}
15
+ tr:nth-child(odd) { background-color:#eeeeee; }
16
+ th {font-size:12px; padding:5px;text-align:left; vertical-align:bottom;}
17
+ td {font-size:12px; padding:5px; }
18
+ </style>
19
+ </head>
20
+ <body>
21
+ <xsl:apply-templates></xsl:apply-templates>
22
+ </body>
23
+ </html>
24
+ </xsl:template>
25
+
26
+
27
+ <xsl:template match="sitemap:urlset">
28
+ <h1>Wordpress XML Sitemap</h1>
29
+
30
+ <div id="header">
31
+ <p>
32
+ This is an XML Sitemap comaptible with major search engines such as Google, Bing, Baidu and Yandex.<br />
33
+ For more information and support go to <a href="https://xmlsitemapgenerator.org/sitemap-generator.aspx">Wordpress Sitemap Generator Plugin</a> homepage. <br />
34
+ You can find more information about XML sitemaps on <a href="http://sitemaps.org">sitemaps.org</a>
35
+ </p>
36
+ </div>
37
+
38
+
39
+
40
+ <table cellspacing="0">
41
+ <tr>
42
+ <th>Page url</th>
43
+ <th style="width:80px;">Relative<br />priority</th>
44
+ <th style="width:80px;">Change<br />frequency</th>
45
+ <th style="width:130px;">Modified<br />date</th>
46
+ </tr>
47
+ <xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/>
48
+ <xsl:variable name="upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
49
+ <xsl:for-each select="./sitemap:url">
50
+ <tr>
51
+ <xsl:if test="position() mod 2 != 1">
52
+ <xsl:attribute name="class">high</xsl:attribute>
53
+ </xsl:if>
54
+ <td>
55
+ <xsl:variable name="page">
56
+ <xsl:value-of select="sitemap:loc"/>
57
+ </xsl:variable>
58
+ <a target="_blank" href="{$page}">
59
+ <xsl:value-of select="sitemap:loc"/>
60
+ </a>
61
+ </td>
62
+ <td>
63
+ <xsl:value-of select="sitemap:priority"/>
64
+ </td>
65
+ <td>
66
+ <xsl:value-of select="sitemap:changefreq"/>
67
+ </td>
68
+ <td>
69
+ <xsl:value-of select="sitemap:lastmod"/>
70
+ </td>
71
+ </tr>
72
+ </xsl:for-each>
73
+ </table>
74
+
75
+ <div id="xsgFooter">Generated by XmlSitemapGenerator.org -
76
+ <a href="https://xmlsitemapgenerator.org/sitemap-generator.aspx" title="WordPress XML Sitemap Generator Plugin">WordPress XML Sitemap Generator Plugin</a></div>
77
+ </div>
78
+
79
+ </xsl:template>
80
+
81
+
82
+
83
+ </xsl:stylesheet>
code/categoryMetaData.php ADDED
@@ -0,0 +1,169 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace xmlSitemapGenerator;
3
+
4
+ include_once 'dataAccess.php';
5
+
6
+ class categoryMetaData
7
+ {
8
+
9
+ public static function addHooks()
10
+ {
11
+ $taxonomy = ( isset( $_REQUEST['taxonomy'] ) ? $_REQUEST['taxonomy'] : '0' );
12
+ add_action($taxonomy . '_edit_form', array( __CLASS__, 'renderEdit' ) );
13
+ add_action($taxonomy . '_add_form_fields', array( __CLASS__, 'renderAdd' ) );
14
+ add_action( 'created_' . $taxonomy, array( __CLASS__, 'save_metaData' ), 10, 2);
15
+ add_action( 'edited_' . $taxonomy , array( __CLASS__, 'save_metaData' ), 10, 2);
16
+
17
+ }
18
+
19
+
20
+ static function save_metaData( $term_id, $ttId ) {
21
+
22
+ /* Verify the nonce before proceeding. */
23
+ if ( !isset( $_POST['wpXSG_meta_nonce'] ) || !wp_verify_nonce( $_POST['wpXSG_meta_nonce'], basename( __FILE__ ) ) )
24
+ return ;
25
+
26
+
27
+ /* Check if the current user has permission to edit the post. */
28
+ if ( !current_user_can( 'manage_categories') )
29
+ return $term_id;
30
+
31
+
32
+ $settings = new metaSettings();
33
+
34
+ $settings->id = ( isset( $_POST['wpXSG-metaId'] ) ? $_POST['wpXSG-metaId'] : '0' );
35
+ $settings->itemId = $term_id ;
36
+ $settings->itemType = "taxonomy";
37
+ $settings->exclude = ( isset( $_POST['wpXSG-Exclude'] ) ? $_POST['wpXSG-Exclude'] : '0' );
38
+ $settings->priority = ( isset( $_POST['wpXSG-Priority'] ) ? $_POST['wpXSG-Priority'] : 'default' );
39
+ $settings->frequency = ( isset( $_POST['wpXSG-Frequency'] ) ? $_POST['wpXSG-Frequency'] : 'default' );
40
+ $settings->inherit = ( isset( $_POST['wpXSG-Inherit'] ) ? $_POST['wpXSG-Inherit'] : 0 );
41
+
42
+ dataAccess::saveMetaItem($settings );
43
+
44
+
45
+
46
+ }
47
+
48
+
49
+
50
+ static function renderAdd($term_id )
51
+ {
52
+ self::addHooks();
53
+
54
+ $settings = new metaSettings(1,1,1);
55
+
56
+ wp_nonce_field( basename( __FILE__ ), 'wpXSG_meta_nonce' );
57
+ ?>
58
+
59
+ <h3>Sitemap settings</h3>
60
+
61
+ <p>Sitemap settings can be setup for individual categories/tags overriding the global settings. Category/tag settings will be inherited by related posts.<br /><br /></p>
62
+
63
+ <div class="form-field term-description-wrap">
64
+
65
+ <label for="wpXSG-Exclude">Sitemap inclusion</label>
66
+ <select name="wpXSG-Exclude" id="wpXSG-Exclude" ></select>
67
+
68
+ <p>Exclude this category/tag from your sitemap.</p>
69
+ </div>
70
+
71
+ <div class="form-field term-description-wrap">
72
+ <label for="wpXSG-Priority">Relative priority</label>
73
+ <select name="wpXSG-Priority" id="wpXSG-Priority" ></select>
74
+ <p>Relative priority for this category/tag.</p>
75
+ </div>
76
+
77
+ <div class="form-field term-description-wrap">
78
+ <label for="wpXSG-Frequency">Update frequency</label>
79
+ <select name="wpXSG-Frequency" id="wpXSG-Frequency" ></select>
80
+ <p>Sitemap update frequency for this category/tag .</p>
81
+ </div>
82
+
83
+ <div class="form-field term-description-wrap">
84
+ <label for="wpXSG-Inherit">Posts inheritance</label>
85
+ <select name="wpXSG-Inherit" id="wpXSG-Inherit" ></select>
86
+ <p>Immediate child posts/pages inherit these settings.</p>
87
+ </div>
88
+
89
+ <script type="text/javascript" src="<?php echo myPluginPath(); ?>scripts.js"></script>
90
+ <script>
91
+ populate("wpXSG-Exclude" ,excludeSelect, <?php echo $settings->exclude ?>);
92
+ populate("wpXSG-Priority" ,prioritySelect, <?php echo $settings->priority ?>);
93
+ populate("wpXSG-Frequency" ,frequencySelect, <?php echo $settings->frequency ?>);
94
+ populate("wpXSG-Inherit" ,inheritSelect, <?php echo $settings->inherit ?>);
95
+ </script>
96
+
97
+ <?php
98
+
99
+ }
100
+
101
+ static function renderEdit($tag )
102
+ {
103
+ $term_id = $tag->term_id;
104
+ self::addHooks();
105
+
106
+ $settings = dataAccess::getMetaItem($term_id , "taxonomy");
107
+
108
+
109
+ wp_nonce_field( basename( __FILE__ ), 'wpXSG_meta_nonce' );
110
+ ?>
111
+
112
+
113
+ <h3>Sitemap settings : </h3>
114
+
115
+
116
+
117
+
118
+ <table class="form-table">
119
+ <tbody><tr class="form-field form-required term-name-wrap">
120
+ <th scope="row"><label for="name">Sitemap inclusion</label></th>
121
+ <td>
122
+ <select name="wpXSG-Exclude" id="wpXSG-Exclude" ></select>
123
+ <p> Exclude this category/tag from your sitemap.</p>
124
+ </td>
125
+ </tr>
126
+ <tr class="form-field term-slug-wrap">
127
+ <th scope="row"><label for="slug">Relative priority</label></th>
128
+ <td>
129
+ <select name="wpXSG-Priority" id="wpXSG-Priority" ></select>
130
+ <p>Relative priority for this category/tag and related posts.</p>
131
+ </td>
132
+ </tr>
133
+ <tr class="form-field term-description-wrap">
134
+ <th scope="row"><label for="description">Update frequency</label></th>
135
+ <td>
136
+ <select name="wpXSG-Frequency" id="wpXSG-Frequency" ></select>
137
+ <p>Sitemap update frequency for this category/tag.</p>
138
+ </td>
139
+ </tr>
140
+ <tr class="form-field term-description-wrap">
141
+ <th scope="row"><label for="description">Post inheritance</label></th>
142
+ <td>
143
+ <select name="wpXSG-Inherit" id="wpXSG-Inherit" ></select>
144
+ <p>Immediate child posts/pages inherit these settings.</p>
145
+ </td>
146
+ </tr>
147
+ </tbody></table>
148
+
149
+ <script type="text/javascript" src="<?php echo myPluginPath(); ?>scripts.js"></script>
150
+ <script>
151
+ populate("wpXSG-Exclude" ,excludeSelect, <?php echo $settings->exclude ?>);
152
+ populate("wpXSG-Priority" ,prioritySelect, <?php echo $settings->priority ?>);
153
+ populate("wpXSG-Frequency" ,frequencySelect, <?php echo $settings->frequency ?>);
154
+ populate("wpXSG-Inherit" ,inheritSelect, <?php echo $settings->inherit ?>);
155
+ </script>
156
+
157
+
158
+ <?php
159
+
160
+ }
161
+
162
+
163
+
164
+
165
+
166
+
167
+ }
168
+
169
+ ?>
code/core.php ADDED
@@ -0,0 +1,300 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace xmlSitemapGenerator;
4
+
5
+ include_once 'settingsModels.php';
6
+
7
+
8
+ define ( "PLUGIN_NAME" , "www-xml-sitemap-generator-org");
9
+ define ( "RULES_VERSION" , "0003"); // increment this if the rewrite rules ever change.
10
+ define ( "RULES_OPTION_NAME" , "wpXSG_rewrite_done");
11
+
12
+ // settings for general operation and rendering
13
+
14
+
15
+
16
+ class core {
17
+
18
+ public static function pluginFilename() {
19
+ return plugin_basename(myPluginFile());
20
+ }
21
+
22
+ public static function pluginVersion() {
23
+ if(!isset($GLOBALS["xmsg_version"]))
24
+ {
25
+ try
26
+ {
27
+ if(!function_exists('get_plugin_data')) {
28
+ if(file_exists(ABSPATH . 'wp-admin/includes/plugin.php')) {
29
+ require_once(ABSPATH . 'wp-admin/includes/plugin.php');
30
+ }
31
+ else return "0.ERROR";
32
+ }
33
+ $pluginData = get_plugin_data(myPluginFile(), false, false);
34
+ $GLOBALS["xmsg_version"] = $data['Version'];
35
+ }
36
+ catch (Exception $e)
37
+ {
38
+ $GLOBALS["xmsg_version"] = "0.ERROR";
39
+ }
40
+
41
+
42
+
43
+ }
44
+ return $GLOBALS["xmsg_version"];
45
+ }
46
+
47
+
48
+
49
+ public static function activatePlugin(){
50
+ self::upgradeDatabase();
51
+ self::addRewriteHooks();
52
+ self::activateRewriteRules();
53
+ flush_rewrite_rules();
54
+
55
+ add_option( "wpXSG_MapId", uniqid("",true) );
56
+ update_option( "xmsg_LastPing", 0 );
57
+
58
+ self::updateStatistics("Plugin","Activate", "");
59
+
60
+ core::doPing();
61
+ }
62
+
63
+ public static function deactivatePlugin() {
64
+ delete_option("wpXMSG_rewrite_done");
65
+ self::updateStatistics("Plugin","Deactivate","");
66
+ }
67
+ public static function initialisePlugin() {
68
+
69
+ // 2 is required for $file to be populated
70
+
71
+ add_filter('plugin_row_meta', array(__CLASS__, 'filter_plugin_row_meta'),10,2);
72
+ add_action('do_robots', array(__CLASS__, 'addRobotLinks'), 100, 0);
73
+ add_action('wp_head', array(__CLASS__, 'addRssLink'),100);
74
+
75
+
76
+ // only include admin files when necessary.
77
+ if (is_admin())
78
+ {
79
+ include_once 'settings.php';
80
+ include_once 'postMetaData.php';
81
+ include_once 'categoryMetaData.php';
82
+ settings::addHooks();
83
+ categoryMetaData::addHooks();
84
+ postMetaData::addHooks();
85
+
86
+ }
87
+
88
+
89
+
90
+ if (!wp_get_schedule('xmsg_ping'))
91
+ {
92
+ // ping in 2 hours from when setup.
93
+ wp_schedule_event(time() + 60*60*2 , 'daily', 'xmsg_ping');
94
+ }
95
+
96
+ add_action('xmsg_ping', array(__CLASS__, 'doPing'));
97
+
98
+ // NB Network activation will not have set up the rules for the site.
99
+ // Check if they exist and then reactivate.
100
+ if (get_option(RULES_OPTION_NAME, null) != RULES_VERSION)
101
+ {
102
+ add_action('wp_loaded', array(__CLASS__, 'activateRewriteRules'), 99999, 1);
103
+ }
104
+ }
105
+
106
+ function doPing()
107
+ {
108
+ include_once 'pinger.php';
109
+ $globalSettings = get_option( "wpXSG_global" , new globalSettings() );
110
+
111
+ if ($globalSettings->pingSitemap == true)
112
+ {
113
+ $sitemapDefaults = get_option( "wpXSG_sitemapDefaults" , new sitemapDefaults() );
114
+ pinger::doAutoPings($sitemapDefaults->dateField);
115
+ }
116
+
117
+ }
118
+
119
+ function upgradeDatabase()
120
+ {
121
+ try
122
+ {
123
+ include_once 'dataAccess.php';
124
+ dataAccess::createMetaTable();
125
+ update_option( "wpXSG_databaseUpgraded" , 1 , false);
126
+ }
127
+ catch (Exception $e)
128
+ {
129
+
130
+ }
131
+ }
132
+ public static function addQueryVariableHooks(){
133
+ add_filter('query_vars', array(__CLASS__, 'addQueryVariables'), 1, 1);
134
+ add_filter('template_redirect', array(__CLASS__, 'templateRedirect'), 1, 0);
135
+ }
136
+ public static function addQueryVariables($vars) {
137
+ array_push($vars, 'xml-sitemap');
138
+ return $vars;
139
+ }
140
+ public static function templateRedirect() {
141
+ global $wp_query;
142
+ if(!empty($wp_query->query_vars["xml-sitemap"])) {
143
+
144
+ $wp_query->is_404 = false;
145
+ $wp_query->is_feed = false;
146
+ include_once 'sitemapBuilder.php';
147
+ $builder = new sitemapBuilder();
148
+ $builder->render($wp_query->query_vars["xml-sitemap"]); //$wp_query->query_vars["xml-sitemap"]
149
+ }
150
+ }
151
+
152
+ public function addRobotLinks()
153
+ {
154
+ $globalSettings = get_option( "wpXSG_global" , new globalSettings() );
155
+ if($globalSettings->addToRobots == true)
156
+ {
157
+ $base = trailingslashit( get_bloginfo( 'url' ) );
158
+ echo "\nSitemap: " . $base . "xmlsitemap.xml\n";
159
+ echo "\nAllow: /rsssitemap.xml";
160
+ echo "\nAllow: /htmlsitemap.htm";
161
+ }
162
+ }
163
+ public function addRssLink()
164
+ {
165
+ $globalSettings = get_option( "wpXSG_global" , new globalSettings() );
166
+ if($globalSettings->addRssToHead == true)
167
+ {
168
+ $base = trailingslashit( get_bloginfo( 'url' ) );
169
+ $url = $base . "rsslatest.xml";
170
+ $link = '<link rel="alternate" type="application/rss+xml" title="RSS" href="' . $url . '" />';
171
+ echo $link;
172
+ }
173
+ }
174
+ public static function addRewriteHooks() {
175
+ add_filter('rewrite_rules_array', array(__CLASS__, 'getRewriteRules'), 1, 1);
176
+ }
177
+
178
+ public static function getRewriteRules($originalRules) {
179
+
180
+ $newRules = array();
181
+ $newRules['xmlsitemap\.xml$'] = 'index.php?xml-sitemap=xml';
182
+ $newRules['rsssitemap\.xml$'] = 'index.php?xml-sitemap=rss';
183
+ $newRules['rsslatest\.xml$'] = 'index.php?xml-sitemap=rssnew';
184
+ $newRules['htmlsitemap\.htm$'] = 'index.php?xml-sitemap=html';
185
+ $newRules['xmlsitemap\.xsl$'] = 'index.php?xml-sitemap=xsl';
186
+ return array_merge($newRules,$originalRules);
187
+ }
188
+
189
+
190
+ public static function activateRewriteRules() {
191
+ /** @var $wp_rewrite WP_Rewrite */
192
+ global $wp_rewrite;
193
+ $wp_rewrite->flush_rules(false);
194
+ update_option(RULES_OPTION_NAME, RULES_VERSION);
195
+ }
196
+
197
+ static function filter_plugin_row_meta($links, $file) {
198
+ $plugin = self::pluginFilename();
199
+ if ($file == $plugin)
200
+ {
201
+ $new_links = array(
202
+ '<a href="options-general.php?page=' . PLUGIN_NAME . '">Settings</a>'
203
+ );
204
+
205
+ $links = array_merge( $links, $new_links );
206
+ }
207
+ return $links;
208
+ }
209
+
210
+ static function getStatusHtml()
211
+ {
212
+ $array = get_option('xmsg_Log',"");
213
+
214
+ if (is_array($array))
215
+ {
216
+ return implode("<br />", $array);
217
+ }
218
+ else
219
+ { return "Log empty";}
220
+ }
221
+ function statusUpdate( $statusMessage)
222
+ {
223
+
224
+ $statusMessage = strip_tags($statusMessage);
225
+
226
+ $array = get_option('xmsg_Log',"");
227
+ if (!is_array($array)) {$array = array();}
228
+ $array = array_slice($array, 0, 19);
229
+ $newLine = gmdate("M d Y H:i:s", time()) . " - <strong>" . $statusMessage . "</strong>" ;
230
+ array_unshift($array , $newLine);
231
+
232
+ update_option('xmsg_Log', $array);
233
+ }
234
+ function doRequest($url) {
235
+
236
+ $response = wp_remote_get($url );
237
+
238
+ if(is_wp_error($response)) {
239
+ $error = $response->get_error_messages();
240
+ $error = substr(htmlspecialchars(implode('; ', $error)),0,150);
241
+ return $error;
242
+ }
243
+ return substr($response['body'],0,200);
244
+ }
245
+
246
+ public static function getTimeBand($startTime)
247
+ {
248
+ $time = microtime(true) - $startTime;
249
+ $timeLabel = round($time) . "s";
250
+ return $timeLabel;
251
+ }
252
+ public static function updateStatistics($eventCategory, $eventAction, $timeBand) {
253
+
254
+ $globalSettings = get_option( "wpXSG_global" , new globalSettings() );
255
+
256
+ if ($globalSettings->sendStats)
257
+ {
258
+ global $wp_version;
259
+ $postCountLabel = dataAccess::getPostCountBand();
260
+
261
+ $postData = array(
262
+ 'v' => 1,
263
+ 'tid' => 'UA-679276-7',
264
+ 'cid' => get_option('wpXSG_MapId'),
265
+ 't' => 'event',
266
+ 'ec' => $eventCategory,
267
+ 'ea' => $eventAction,
268
+ 'ev' => 1,
269
+ 'cd1' => get_bloginfo( 'url' ),
270
+ 'cd2' => $wp_version,
271
+ 'cd3' => self::pluginVersion(),
272
+ 'cd4' => PHP_VERSION,
273
+ 'cd5' => $postCountLabel,
274
+ 'cd6' => $timeBand
275
+ );
276
+
277
+ $url = 'https://ssl.google-analytics.com/collect';
278
+
279
+ try
280
+ {
281
+ $response = wp_remote_post($url,
282
+ array(
283
+ 'method' => 'POST',
284
+ 'body' => $postData
285
+ ));
286
+ }
287
+ catch (Exception $e)
288
+ {
289
+ statusUpdate("sendStats : " . $e->getMessage());
290
+ }
291
+
292
+
293
+ }
294
+ }
295
+ }
296
+
297
+
298
+
299
+
300
+ ?>
code/dataAccess.php ADDED
@@ -0,0 +1,265 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace xmlSitemapGenerator;
4
+
5
+
6
+
7
+
8
+
9
+ class dataAccess {
10
+
11
+
12
+
13
+ function __construct()
14
+ {
15
+
16
+ }
17
+
18
+ static function execute($cmd)
19
+ {
20
+ global $wpdb;
21
+ $results = $wpdb->get_results($cmd, OBJECT );
22
+
23
+ return $results;
24
+ }
25
+
26
+ static function getDateField($name)
27
+ {
28
+ if ($name == "created")
29
+ {
30
+ return "post_date";
31
+ }
32
+ else
33
+ {
34
+ return "post_modified";
35
+ }
36
+ }
37
+
38
+
39
+
40
+ public static function createMetaTable()
41
+ {
42
+ global $wpdb;
43
+ $tablemeta = $wpdb->prefix . 'xsg_sitemap_meta';
44
+ $cmd = "CREATE TABLE IF NOT EXISTS `{$tablemeta}` (
45
+ `itemId` int(11) DEFAULT '0',
46
+ `inherit` int(11) DEFAULT '0',
47
+ `itemType` varchar(8) DEFAULT '',
48
+ `exclude` int(11) DEFAULT '0',
49
+ `priority` int(11) DEFAULT '0',
50
+ `frequency` int(11) DEFAULT '0',
51
+ UNIQUE KEY `idx_xsg_sitemap_meta_ItemId_ItemType` (`itemId`,`itemType`)
52
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='generatated by XmlSitemapGenerator.org';";
53
+
54
+
55
+ $wpdb->query($cmd);
56
+
57
+ }
58
+ public static function getMetaItem($id, $type)
59
+ {
60
+ global $wpdb;
61
+ $tablemeta = $wpdb->prefix . 'xsg_sitemap_meta';
62
+ $cmd = " SELECT * FROM {$tablemeta}
63
+ WHERE itemId = %d AND itemType = %s ";
64
+
65
+ $cmd = $wpdb->prepare($cmd, $id, $type);
66
+
67
+ $settings = $wpdb->get_row($cmd);
68
+
69
+ if (!$settings) {return new metaSettings(); }
70
+
71
+ return $settings ;
72
+ }
73
+
74
+
75
+ public static function saveMetaItem($metaItem)
76
+ {
77
+ global $wpdb;
78
+ $tablemeta = $wpdb->prefix . 'xsg_sitemap_meta';
79
+ $cmd = " INSERT INTO {$tablemeta} (itemId, itemType, exclude, priority, frequency, inherit)
80
+ VALUES(%d, %s, %d, %d, %d, %d)
81
+ ON DUPLICATE KEY UPDATE
82
+ exclude=VALUES(exclude), priority=VALUES(priority), frequency=VALUES(frequency), inherit=VALUES(inherit) ";
83
+
84
+
85
+
86
+ $itemId = $metaItem->itemId;
87
+ $itemType = $metaItem->itemType;
88
+ $exclude = $metaItem->exclude;
89
+ $priority = $metaItem->priority;
90
+ $frequency = $metaItem->frequency;
91
+ $inherit = $metaItem->inherit;
92
+
93
+ $cmd = $wpdb->prepare($cmd, $itemId, $itemType, $exclude, $priority , $frequency,$inherit);
94
+
95
+ $settings = $wpdb->query($cmd);
96
+
97
+ }
98
+
99
+ // type = "post" or "page" , date = "created" or "updated"
100
+ //$limit = 0 for no limit.)
101
+ public static function getPages($date , $limit)
102
+ {
103
+ global $wpdb;
104
+ $date = self::getDateField($date);
105
+
106
+ $tablemeta = $wpdb->prefix . 'xsg_sitemap_meta';
107
+
108
+ $cmd = "SELECT
109
+ posts.*,
110
+ postmeta.*, Tag_meta.* , UNIX_TIMESTAMP({$date}) as sitemapDate
111
+ FROM {$wpdb->posts} as posts
112
+ LEFT JOIN {$tablemeta} as postmeta ON posts.Id = postmeta.ItemId AND postmeta.itemId
113
+ LEFT JOIN
114
+ (SELECT
115
+ terms.object_id as Post_id,
116
+ Max(meta.exclude) as tagExclude,
117
+ Max(meta.priority) as tagPriority,
118
+ Max(meta.frequency) as tagFrequency
119
+ FROM {$tablemeta} as meta
120
+ INNER JOIN {$wpdb->term_relationships} as terms
121
+ ON meta.itemId = terms.term_taxonomy_id
122
+ WHERE meta.itemType = 'taxonomy' AND meta.inherit = 1
123
+
124
+ GROUP BY terms.object_id
125
+ ) as Tag_meta
126
+ ON posts.Id = Tag_meta.Post_id
127
+ WHERE post_status = 'publish' AND (post_type = 'page' OR post_type = 'post')
128
+ AND posts.post_password = ''
129
+ ORDER BY {$date} DESC ";
130
+
131
+
132
+ if ($limit > 0 )
133
+ {
134
+ $cmd .= " LIMIT {$limit} " ;
135
+ }
136
+
137
+
138
+ $results = self::execute($cmd);
139
+
140
+ return $results;
141
+ }
142
+
143
+ public static function getTaxonomy($date = "updated"){
144
+
145
+ global $wpdb;
146
+ $date = self::getDateField($date);
147
+ $tablemeta = $wpdb->prefix . 'xsg_sitemap_meta';
148
+ $cmd = "SELECT terms.term_id, terms.name, terms.slug, terms.term_group,
149
+ tax.term_taxonomy_id, tax.taxonomy, tax.description, tax.description,
150
+ meta.exclude, meta.priority, meta.frequency,
151
+ UNIX_TIMESTAMP(Max(posts.{$date})) as sitemapDate, Count(posts.ID) as posts
152
+
153
+ FROM {$wpdb->terms} as terms
154
+ INNER JOIN {$wpdb->term_relationships} as Relationships ON terms.Term_id = Relationships.term_taxonomy_id
155
+ INNER JOIN {$wpdb->posts} as posts ON Relationships.object_id = posts.Id
156
+ AND posts.post_status = 'publish' AND posts.post_password = ''
157
+ INNER JOIN {$wpdb->term_taxonomy} as tax ON terms.term_id = tax.term_id
158
+ LEFT JOIN {$tablemeta} as meta ON terms.term_Id = meta.ItemId AND meta.itemType = 'taxonomy'
159
+ WHERE tax.taxonomy IN ('post_tag','category')
160
+ GROUP BY terms.term_id, terms.name, terms.slug, terms.term_group, tax.description, tax.term_taxonomy_id, tax.taxonomy, tax.description, meta.exclude, meta.priority, meta.frequency";
161
+
162
+ $results = self::execute($cmd);
163
+
164
+ return $results;
165
+
166
+
167
+
168
+ }
169
+
170
+ public static function getAuthors($date = "updated") {
171
+
172
+ global $wpdb;
173
+ $date = self::getDateField($date);
174
+ $tablemeta = $wpdb->prefix . 'xsg_sitemap_meta';
175
+
176
+ $cmd = "SELECT users.user_nicename, users.user_login, users.display_name ,
177
+ UNIX_TIMESTAMP(MAX(posts.{$date})) AS sitemapDate, Count(posts.ID) as posts
178
+ FROM {$wpdb->users} users LEFT JOIN {$wpdb->posts} as posts ON users.Id = posts.post_author
179
+ AND posts.post_type = 'post' AND posts.post_status = 'publish' AND posts.post_password = ''
180
+ GROUP BY users.user_nicename, users.user_login, users.display_name ";
181
+
182
+ $results = self::execute($cmd);
183
+
184
+ return $results;
185
+
186
+ }
187
+
188
+
189
+
190
+ public static function getArchives($date = "updated"){
191
+
192
+ global $wpdb;
193
+
194
+ $date = self::getDateField($date);
195
+
196
+ $cmd = "SELECT DISTINCT YEAR({$date}) AS year,MONTH({$date}) AS month,
197
+ UNIX_TIMESTAMP(MAX(posts.{$date})) AS sitemapDate, Count(posts.ID) as posts
198
+ FROM {$wpdb->posts} as posts
199
+ WHERE post_status = 'publish' AND post_type = 'post' AND posts.post_password = ''
200
+ GROUP BY YEAR({$date}), MONTH({$date})
201
+ ORDER BY {$date} DESC";
202
+
203
+ $results = self::execute($cmd);
204
+
205
+ return $results;
206
+
207
+ }
208
+
209
+
210
+ public static function getLastModified($date = "updated")
211
+ {
212
+
213
+
214
+ global $wpdb;
215
+
216
+ $date = self::getDateField($date);
217
+
218
+ $cmd = "SELECT UNIX_TIMESTAMP(MAX({$date}))
219
+ FROM {$wpdb->posts} as posts
220
+ WHERE post_status = 'publish'";
221
+
222
+ $date = $wpdb->get_var($cmd);
223
+
224
+ return $date;
225
+ }
226
+
227
+
228
+ public static function getPostCountBand()
229
+ {
230
+
231
+ global $wpdb;
232
+
233
+
234
+ $cmd = "SELECT COUNT(*)
235
+ FROM {$wpdb->posts} as posts
236
+ WHERE post_status = 'publish'";
237
+
238
+ $postCount = $wpdb->get_var($cmd);
239
+
240
+ if( $postCount = 0) {$postCountLabel = "0";}
241
+ else if( $postCount <= 10) {$postCountLabel = "1 to 10";}
242
+ else if( $postCount <= 25) {$postCountLabel = "11 to 25";}
243
+ else if ($postCount <= 50) {$postCountLabel = "26 to 50";}
244
+ else if ($postCount <= 100) {$postCountLabel = "51 to 100";}
245
+ else if ($postCount <= 500) {$postCountLabel = "101 to 500";}
246
+ else if ($postCount <= 500) {$postCountLabel = "501 to 1000";}
247
+ else if($postCount < 10000) {$postCountLabel = round($postCount / 1000) * 1000;}
248
+ else if($postCount < 100000) {$postCountLabel = round($postCount / 10000) * 10000;}
249
+ else {$postCountLabel = round($postCount / 100000) * 100000;}
250
+
251
+ return $postCountLabel;
252
+
253
+ }
254
+
255
+
256
+
257
+
258
+
259
+
260
+ }
261
+
262
+
263
+
264
+
265
+ ?>
code/pinger.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace xmlSitemapGenerator;
4
+
5
+ include_once 'dataAccess.php';
6
+
7
+ class pinger
8
+ {
9
+
10
+ public function doPing($tag = "manual")
11
+ {
12
+ $sitemapUrl = urlencode( get_bloginfo( 'url' ) . '/xmlsitemap.xml');
13
+ $url = "http://www.google.com/webmasters/sitemaps/ping?sitemap=" . $sitemapUrl;
14
+ $response = core::doRequest($url);
15
+ core::statusUpdate("Google {$tag} ping - {$response}");
16
+
17
+ $url = "http://www.bing.com/ping?sitemap=" . $sitemapUrl;
18
+ $response = core::doRequest($url);
19
+ core::statusUpdate("Bing {$tag} ping - {$response}");
20
+
21
+ update_option('xmsg_LastPing', time());
22
+ }
23
+
24
+ public function doManualPing()
25
+ {
26
+ $startTime = microtime(true) ;
27
+ self::doPing("Manual");
28
+ $time = core::getTimeBand($startTime);
29
+ core::updateStatistics("Ping", "Manual", $time);
30
+
31
+ }
32
+ public function doAutoPings($date)
33
+ {
34
+ $startTime = microtime(true) ;
35
+ $lasModified = dataAccess::getLastModified($date);
36
+ $lastPing = get_option('xmsg_LastPing',0);
37
+ // using UNIX times
38
+ if ($lastPing < $lasModified )
39
+ {
40
+ self::doPing("Auto");
41
+ update_option('xmsg_LastPing', $lasModified);
42
+ }
43
+ else
44
+ {
45
+ core::statusUpdate("Auto ping skipped. No modified posts");
46
+ }
47
+ $time = core::getTimeBand($startTime);
48
+ core::updateStatistics("Ping", "AutoPing", $time);
49
+ }
50
+
51
+
52
+
53
+ }
54
+ ?>
code/postMetaData.php ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace xmlSitemapGenerator;
3
+
4
+ include_once 'dataAccess.php';
5
+
6
+ class postMetaData
7
+ {
8
+
9
+ function __construct() {
10
+
11
+
12
+
13
+ }
14
+
15
+ public static function addHooks() {
16
+
17
+ // add_action('load-post.php', array( __CLASS__, 'add_post_hooks' ) );
18
+ // add_action('load-post-new.php', array( __CLASS__, 'add_post_hooks' ) );
19
+ add_action('save_post', array(__CLASS__, 'handlePostBack' ) , 10, 2 );
20
+ add_action( 'add_meta_boxes', array(__CLASS__, 'addMetaBoxMenu' ) );
21
+
22
+ }
23
+
24
+ static function addMetaBoxMenu() {
25
+
26
+
27
+ add_meta_box(
28
+ 'wpXSG-meta', // Unique ID
29
+ 'XML Sitemap', // Title
30
+ array(__CLASS__, 'render' ), // Callback function
31
+ null, // Screen
32
+ 'side', // Context - note side requires 2.7
33
+ 'core' // Priority
34
+ );
35
+ }
36
+
37
+ static function handlePostBack( $post_id, $post ) {
38
+
39
+
40
+ /* Verify the nonce before proceeding. */
41
+ if ( !isset( $_POST['wpXSG_meta_nonce'] ) || !wp_verify_nonce( $_POST['wpXSG_meta_nonce'], basename( __FILE__ ) ) )
42
+ return ;
43
+
44
+
45
+ /* Get the post type object. */
46
+ $post_type = get_post_type_object( $post->post_type );
47
+ /* Check if the current user has permission to edit the post. */
48
+ if ( !current_user_can( $post_type->cap->edit_post, $post_id ) )
49
+ return $post_id;
50
+
51
+ if ( $parent_id = wp_is_post_revision( $post_id ) )
52
+ $post_id = $parent_id;
53
+
54
+ $settings = new metaSettings();
55
+ $settings->itemId = $post_id;
56
+ $settings->itemType = "post";
57
+ $settings->exclude = ( isset( $_POST['wpXSG-Exclude'] ) ? $_POST['wpXSG-Exclude'] : '0' );
58
+ $settings->priority = ( isset( $_POST['wpXSG-Priority'] ) ? $_POST['wpXSG-Priority'] : 'default' );
59
+ $settings->frequency = ( isset( $_POST['wpXSG-Frequency'] ) ? $_POST['wpXSG-Frequency'] : 'default' );
60
+
61
+
62
+ dataAccess::saveMetaItem($settings);
63
+
64
+ }
65
+
66
+
67
+ static function render( $post )
68
+ {
69
+
70
+
71
+ $settings = dataAccess::getMetaItem($post->ID , "post");
72
+
73
+ wp_nonce_field( basename( __FILE__ ), 'wpXSG_meta_nonce' );
74
+
75
+ ?>
76
+
77
+ <p><strong>Sitemap inclusion</strong></p>
78
+ <select name="wpXSG-Exclude" id="wpXSG-Exclude" ></select>
79
+ <label for="wpXSG-Exclude"></label>
80
+
81
+ <p><strong>Relative priority</strong></p>
82
+ <select name="wpXSG-Priority" id="wpXSG-Priority" ></select>
83
+
84
+ <p><strong>Update frequency</strong></p>
85
+ <select name="wpXSG-Frequency" id="wpXSG-Frequency" ></select>
86
+
87
+
88
+
89
+ <script type="text/javascript" src="<?php echo myPluginPath(); ?>scripts.js"></script>
90
+ <script>
91
+ populate("wpXSG-Exclude" ,excludeSelect, <?php echo $settings->exclude ?>);
92
+ populate("wpXSG-Priority" ,prioritySelect, <?php echo $settings->priority ?>);
93
+ populate("wpXSG-Frequency" ,frequencySelect, <?php echo $settings->frequency ?>);
94
+
95
+ </script>
96
+ <?php
97
+
98
+
99
+ }
100
+
101
+
102
+
103
+
104
+
105
+
106
+ }
107
+
108
+ ?>
code/renderers.php ADDED
@@ -0,0 +1,430 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace xmlSitemapGenerator;
4
+
5
+ interface iSitemapRenderer
6
+ {
7
+ public function render($urls);
8
+ }
9
+
10
+ class sitemapRenderer
11
+ {
12
+
13
+ static function getInstance($type)
14
+ {
15
+ switch ($type)
16
+ {
17
+ case 'html':
18
+ return new htmlRenderer();
19
+ case 'rss':
20
+ return new rssRenderer();
21
+ case 'xml':
22
+ return new xmlRenderer();
23
+ case 'xsl':
24
+ return new xslRenderer();
25
+ default:
26
+ return null;
27
+ }
28
+ }
29
+ }
30
+
31
+ class rssRenderer implements iSitemapRenderer
32
+ {
33
+
34
+ function renderItem( $url)
35
+ {
36
+
37
+ echo '<item>' ;
38
+ echo '<guid>' . $url->location . '</guid>';
39
+ echo '<title>' . $url->title . '</title>';
40
+ echo '<link>' . $url->location . '</link>';
41
+ echo '<description>' . $url->description . '</description>';
42
+ echo '<pubDate>' . date(DATE_RSS, $url->modified) . '</pubDate>';
43
+ echo "</item>\n" ;
44
+ }
45
+
46
+ function render($urls){
47
+
48
+ ob_get_clean();
49
+ ob_start();
50
+ header('Content-Type: text/xml; charset=utf-8');
51
+
52
+ echo '<?xml version="1.0" encoding="UTF-8" ?>';
53
+ echo "\n";
54
+ sitemapBuilder::renderComment();
55
+ echo "\n";
56
+ echo '<rss version="2.0">';
57
+ echo "\n";
58
+ echo '<channel>';
59
+ echo "\n";
60
+
61
+
62
+
63
+ echo '<title>' . get_option('blogname') . '</title>';
64
+ echo '<link>' . get_bloginfo( 'url' ) . '</link>';
65
+ echo '<description>' . get_option( 'blogdescription'). '</description>';
66
+
67
+ echo "\n";
68
+ foreach( $urls as $url )
69
+ {
70
+
71
+ $this->renderItem($url);
72
+ }
73
+ echo "\n";
74
+ echo '</channel>';
75
+ echo "\n";
76
+ echo '</rss>';
77
+ echo "\n";
78
+ sitemapBuilder::renderComment();
79
+ echo "\n";
80
+ ob_end_flush();
81
+
82
+ }
83
+
84
+
85
+ }
86
+
87
+ class xmlRenderer implements iSitemapRenderer
88
+ {
89
+
90
+ // $writer;// = new XMLWriter();
91
+
92
+ function getFrequency($value)
93
+ {
94
+ switch ($value) {
95
+ case 0:
96
+ return "default";
97
+ break;
98
+ case 2:
99
+ return "never";
100
+ break;
101
+ case 3:
102
+ return "yearly";
103
+ break;
104
+ case 4:
105
+ return "monthly";
106
+ break;
107
+ case 5:
108
+ return "weekly";
109
+ break;
110
+ case 6:
111
+ return "daily";
112
+ break;
113
+ case 7:
114
+ return "always";
115
+ break;
116
+ }
117
+ }
118
+
119
+ function getPriority($value)
120
+ {
121
+ switch ($value) {
122
+ case 0:
123
+ return "none";
124
+ break;
125
+ case 1:
126
+ return "default";
127
+ break;
128
+ case 2:
129
+ return "0.0";
130
+ break;
131
+ case 3:
132
+ return "0.1";
133
+ break;
134
+ case 4:
135
+ return "0.2";
136
+ break;
137
+ case 5:
138
+ return "0.3";
139
+ break;
140
+ case 6:
141
+ return "0.4";
142
+ break;
143
+ case 7:
144
+ return "0.5";
145
+ break;
146
+ case 8:
147
+ return "0.6";
148
+ break;
149
+ case 9:
150
+ return "0.7";
151
+ break;
152
+ case 10:
153
+ return "0.8";
154
+ break;
155
+ case 11:
156
+ return "0.9";
157
+ break;
158
+ case 12:
159
+ return "1.0";
160
+ break;
161
+ default:
162
+ return "xxx";
163
+ }
164
+ }
165
+
166
+ function renderItem( $url)
167
+ {
168
+
169
+ echo '<url>' ;
170
+ echo '<loc>' . $url->location . '</loc>';
171
+ echo '<lastmod>' . date('Y-m-d\TH:i:s+00:00', $url->modified) . '</lastmod>';
172
+
173
+ if (!$url->frequency==0) {
174
+ echo '<changefreq>' . $this->getFrequency($url->frequency) . '</changefreq>';
175
+ }
176
+
177
+ if (!$url->priority==0) {
178
+ echo "<priority>" . $this->getPriority($url->priority) . "</priority>";
179
+ }
180
+
181
+ echo "</url>\n" ;
182
+ }
183
+
184
+ function render($urls){
185
+
186
+ ob_get_clean();
187
+ $url = get_bloginfo( 'url' ) . '/xmlsitemap.xsl';
188
+
189
+ ob_start();
190
+ header('Content-Type: text/xml; charset=utf-8');
191
+
192
+ echo '<?xml version="1.0" encoding="UTF-8" ?>';
193
+ echo "\n";
194
+ echo '<?xml-stylesheet type="text/xsl" href="' . $url . '"?>';
195
+ echo "\n";
196
+ sitemapBuilder::renderComment();
197
+ echo "\n";
198
+ echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
199
+ echo "\n";
200
+ foreach( $urls as $url )
201
+ {
202
+ $this->renderItem($url);
203
+ }
204
+ echo "\n";
205
+ echo '</urlset>';
206
+ echo "\n";
207
+ sitemapBuilder::renderComment();
208
+ echo "\n";
209
+ ob_end_flush();
210
+
211
+ }
212
+
213
+
214
+ }
215
+
216
+
217
+ class htmlRenderer implements iSitemapRenderer
218
+ {
219
+
220
+
221
+ function renderItem( $url)
222
+ {
223
+
224
+ echo '<li>' ;
225
+ echo '<a href="' . $url->location . '">';
226
+ echo $url->title;
227
+ echo '</a>';
228
+ echo "</li>\n" ;
229
+ }
230
+
231
+ function render($urls){
232
+
233
+ ob_get_clean();
234
+ header('Content-Type: text/html; charset=utf-8');
235
+ ob_start();
236
+
237
+
238
+ self::renderHeader();
239
+
240
+ echo "<ul>\n";
241
+ foreach( $urls as $url )
242
+ {
243
+
244
+ $this->renderItem($url);
245
+ }
246
+ echo "</ul>\n";
247
+ sitemapBuilder::renderCredit();
248
+ self::renderFooter();
249
+ echo "\n";
250
+ sitemapBuilder::renderComment();
251
+ echo "\n";
252
+ ob_end_flush();
253
+
254
+ }
255
+
256
+ function renderHeader()
257
+ {
258
+ ?>
259
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
260
+ <html xmlns="http://www.w3.org/1999/xhtml">
261
+ <!--Created using XmlSitemapGenerator.org WordPress Plugin - Free HTML, RSS and XML sitemap generator -->
262
+ <head>
263
+ <title>WordPress Sitemap Generator</title>
264
+ <meta id="MetaDescription" name="description" content="WordPress Sitemap created using XmlSitemapGenerator.org - the free online Google XML sitemap generator" />
265
+ <meta id="MetaKeywords" name="keywords" content="XML, HTML, Sitemap Generator, Wordpress" />
266
+ <meta content="Xml Sitemap Generator .org" name="Author" />
267
+ <style>
268
+ body, head, #xsg {margin:0px 0px 0px 0px; line-height:22px; color:#666666; width:100%; padding:0px 0px 0px 0px;
269
+ font-family : Tahoma, Verdana, Arial, sans-serif; font-size:13px;}
270
+
271
+ #xsg ul li a {font-weight:bold; }
272
+ #xsg ul ul li a {font-weight:normal; }
273
+ #xsg a {text-decoration:none; }
274
+ #xsg p {margin:10px 0px 10px 0px;}
275
+ #xsg ul {list-style:square; }
276
+ #xsg li {}
277
+ #xsg th { text-align:left;font-size: 0.9em;padding:2px 10px 2px 2px; border-bottom:1px solid #CCCCCC; border-collapse:collapse;}
278
+ #xsg td { text-align:left;font-size: 0.9em; padding:2px 10px 2px 2px; border-bottom:1px solid #CCCCCC; border-collapse:collapse;}
279
+
280
+ #xsg .title {font-size: 0.9em; color:#132687; display:inline;}
281
+ #xsg .url {font-size: 0.7em; color:#999999;}
282
+
283
+ #xsgHeader { width:100%; float:left; margin:0px 0px 5px 0px; border-bottom:2px solid #132687; }
284
+ #xsgHeader h1 { padding:0px 0px 0px 20px ; float:left;}
285
+ #xsgHeader h1 a {color:#132687; font-size:14px; text-decoration:none;cursor:default;}
286
+ #xsgBody {padding:10px;float:left;}
287
+ #xsgFooter { color:#999999; width:100%; float:left; margin:20px 0px 15px 0px; border-top:1px solid #999999;padding: 10px 0px 10px 0px; }
288
+ #xsgFooter a {color:#999999; font-size:11px; text-decoration:none; }
289
+ #xsgFooter span {color:#999999; font-size:11px; text-decoration:none; margin-left:20px; }
290
+ </style>
291
+ </head>
292
+ <body>
293
+ <div id="xsg">
294
+ <div id="xsgHeader">
295
+ <h1><a href="#" title="Wordpress">Wordpress Sitemap</a></h1>
296
+ </div>
297
+ <div id="xsgBody">
298
+
299
+ <?php
300
+ }
301
+
302
+
303
+ static function renderFooter()
304
+ {
305
+ ?>
306
+
307
+ </div>
308
+
309
+
310
+
311
+ </body>
312
+ </html>
313
+
314
+ <?php
315
+ }
316
+
317
+ }
318
+
319
+ class xslRenderer implements iSitemapRenderer
320
+ {
321
+ public function render($urls){
322
+
323
+ ob_get_clean();
324
+ header('Content-Type: text/xsl; charset=utf-8');
325
+ ob_start();
326
+
327
+
328
+ self::output();
329
+
330
+
331
+
332
+ echo "\n";
333
+ ob_end_flush();
334
+
335
+ }
336
+
337
+ function output()
338
+ {
339
+ echo '<?xml version="1.0" encoding="UTF-8"?>';
340
+ ?>
341
+ <xsl:stylesheet version="1.0" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
342
+ <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes" />
343
+
344
+ <xsl:template match="/">
345
+ <html xmlns="http://www.w3.org/1999/xhtml">
346
+ <head>
347
+ <title>Wordpress XML Sitemap Generator Plugin</title>
348
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
349
+ <meta name="robots" content="index,follow" />
350
+ <style type="text/css">
351
+ body {font-family:Tahoma, Verdana, Arial, sans-serif;font-size:12px; }
352
+ #header { padding:0px; margin-top:10px; margin-bottom:20px;}
353
+ a {text-decoration:none; color:blue;}
354
+ table {margin-bottom:50px;}
355
+ tr:nth-child(odd) { background-color:#eeeeee; }
356
+ th {font-size:12px; padding:5px;text-align:left; vertical-align:bottom;}
357
+ td {font-size:12px; padding:5px; }
358
+ </style>
359
+ </head>
360
+ <body>
361
+ <xsl:apply-templates></xsl:apply-templates>
362
+ </body>
363
+ </html>
364
+ </xsl:template>
365
+
366
+
367
+ <xsl:template match="sitemap:urlset">
368
+ <h1>Wordpress XML Sitemap</h1>
369
+
370
+ <div id="header">
371
+ <p>
372
+ This is an XML Sitemap comaptible with major search engines such as Google, Bing, Baidu and Yandex.<br />
373
+ For more information and support go to <a href="https://xmlsitemapgenerator.org/sitemap-generator.aspx">Wordpress Sitemap Generator Plugin</a> homepage. <br />
374
+ You can find more information about XML sitemaps on <a href="http://sitemaps.org">sitemaps.org</a>
375
+ </p>
376
+ </div>
377
+
378
+
379
+
380
+ <table cellspacing="0">
381
+ <tr>
382
+ <th>Page url</th>
383
+ <th style="width:80px;">Relative<br />priority</th>
384
+ <th style="width:80px;">Change<br />frequency</th>
385
+ <th style="width:130px;">Modified<br />date</th>
386
+ </tr>
387
+ <xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/>
388
+ <xsl:variable name="upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
389
+ <xsl:for-each select="./sitemap:url">
390
+ <tr>
391
+ <xsl:if test="position() mod 2 != 1">
392
+ <xsl:attribute name="class">high</xsl:attribute>
393
+ </xsl:if>
394
+ <td>
395
+ <xsl:variable name="page">
396
+ <xsl:value-of select="sitemap:loc"/>
397
+ </xsl:variable>
398
+ <a target="_blank" href="{$page}">
399
+ <xsl:value-of select="sitemap:loc"/>
400
+ </a>
401
+ </td>
402
+ <td>
403
+ <xsl:value-of select="sitemap:priority"/>
404
+ </td>
405
+ <td>
406
+ <xsl:value-of select="sitemap:changefreq"/>
407
+ </td>
408
+ <td>
409
+ <xsl:value-of select="sitemap:lastmod"/>
410
+ </td>
411
+ </tr>
412
+ </xsl:for-each>
413
+ </table>
414
+
415
+ <?php sitemapBuilder::renderCredit(); ?>
416
+
417
+ </xsl:template>
418
+
419
+
420
+
421
+ </xsl:stylesheet>
422
+
423
+ <?php
424
+ }
425
+
426
+ }
427
+
428
+
429
+
430
+ ?>
code/settings.php ADDED
@@ -0,0 +1,358 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace xmlSitemapGenerator;
4
+
5
+ // settings for generating a map
6
+
7
+
8
+ class settings
9
+ {
10
+
11
+ public static function addHooks()
12
+ {
13
+ add_action('admin_menu', array( __CLASS__, 'admin_menu' ) );
14
+ add_action('admin_init', array( __CLASS__, 'register_settings' ) );
15
+ }
16
+
17
+ public static function admin_menu()
18
+ {
19
+ add_options_page( 'XML Sitemap Settings','XML Sitemap','manage_options', PLUGIN_NAME , array( __CLASS__ , 'render' ) );
20
+ }
21
+
22
+ public static function register_settings()
23
+ {
24
+ register_setting( PLUGIN_NAME, PLUGIN_NAME );
25
+ }
26
+
27
+ static function getDefaults($name){
28
+
29
+ $settings = new metaSettings();
30
+
31
+ $settings->exclude = ( isset( $_POST[$name . 'Exclude'] ) ? $_POST[$name . 'Exclude'] : 0 );
32
+ $settings->priority = ( isset( $_POST[$name . 'Priority'] ) ? $_POST[$name . 'Priority'] : 0 );
33
+ $settings->frequency = ( isset( $_POST[$name . 'Frequency'] ) ? $_POST[$name . 'Frequency'] : 0 );
34
+
35
+
36
+ return $settings;
37
+ }
38
+
39
+ static function handlePostBack(){
40
+
41
+ if (!(strtoupper($_SERVER['REQUEST_METHOD']) == 'POST')){ return; }
42
+
43
+ /* Verify the nonce before proceeding. */
44
+ if ( !isset( $_POST['wpXSG_meta_nonce'] ) || !wp_verify_nonce( $_POST['wpXSG_meta_nonce'], basename( __FILE__ ) ) )
45
+ return ;
46
+
47
+
48
+ if ( !current_user_can( 'manage_options') ) {return;}
49
+
50
+
51
+ $globalSettings = new globalSettings();
52
+
53
+
54
+
55
+ $globalSettings->addRssToHead = ( isset( $_POST['addRssToHead'] ) ? $_POST['addRssToHead'] : 0 );
56
+ $globalSettings->pingSitemap = ( isset( $_POST['pingSitemap'] ) ? $_POST['pingSitemap'] : 0 );
57
+ $globalSettings->addToRobots = ( isset( $_POST['addToRobots'] ) ? $_POST['addToRobots'] : 0 );
58
+ $globalSettings->sendStats = ( isset( $_POST['sendStats'] ) ? $_POST['sendStats'] : 0 );
59
+ $globalSettings->smallCredit = ( isset( $_POST['smallCredit'] ) ? $_POST['smallCredit'] : 0 );
60
+
61
+ update_option( "wpXSG_global" , $globalSettings , true);
62
+
63
+ $sitemapDefaults = new sitemapDefaults();
64
+
65
+ $sitemapDefaults->dateField = ( isset( $_POST['dateField'] ) ? $_POST['dateField'] : $sitemapDefaults->dateField );
66
+ $sitemapDefaults->homepage = self::getDefaults("homepage");
67
+ $sitemapDefaults->pages = self::getDefaults("pages");
68
+ $sitemapDefaults->posts = self::getDefaults("posts");
69
+ $sitemapDefaults->taxonomyCategories = self::getDefaults("taxonomyCategories");
70
+ $sitemapDefaults->taxonomyTags = self::getDefaults("taxonomyTags");
71
+
72
+ $sitemapDefaults->recentArchive = self::getDefaults("recentArchive");
73
+ $sitemapDefaults->oldArchive = self::getDefaults("oldArchive");
74
+ $sitemapDefaults->authors = self::getDefaults("authors");
75
+
76
+ $sitemapDefaults->excludeRules = ( isset( $_POST['excludeRules'] ) ? $_POST['excludeRules'] : "" );
77
+
78
+ update_option( "wpXSG_sitemapDefaults" , $sitemapDefaults , false);
79
+
80
+ core::updateStatistics("Admin", "SaveSettings",0);
81
+
82
+
83
+ }
84
+
85
+ static function RenderDefaultSection($title,$name,$defaults){
86
+
87
+ ?>
88
+
89
+ <tr>
90
+ <td scope="col"><?php echo $title; ?></td>
91
+ <td scope="col"><select name="<?php echo $name; ?>Exclude" id="<?php echo $name; ?>Exclude" ></select> </td>
92
+ <td scope="col"><select name="<?php echo $name; ?>Priority" id="<?php echo $name; ?>Priority" ></select> </td>
93
+ <td scope="col"><select name="<?php echo $name; ?>Frequency" id="<?php echo $name; ?>Frequency" ></select> </td>
94
+ </tr>
95
+ <script>
96
+ populate("<?php echo $name; ?>Exclude" ,excludeDefaults, <?php echo $defaults->exclude ?>);
97
+ populate("<?php echo $name; ?>Priority" ,priorityDefaults, <?php echo $defaults->priority ?>);
98
+ populate("<?php echo $name; ?>Frequency" ,frequencyDefaults, <?php echo $defaults->frequency ?>);
99
+
100
+ </script>
101
+
102
+ <?php
103
+
104
+ }
105
+
106
+
107
+
108
+
109
+ public static function render()
110
+ {
111
+
112
+ self::handlePostBack();
113
+
114
+ $globalSettings = get_option( "wpXSG_global" , new globalSettings() );
115
+ $sitemapDefaults = get_option( "wpXSG_sitemapDefaults" , new sitemapDefaults() );
116
+
117
+ core::updateStatistics("Admin", "ViewSettings",0);
118
+
119
+ ?>
120
+
121
+
122
+
123
+
124
+ <form method="post" >
125
+
126
+ <?php wp_nonce_field( basename( __FILE__ ), 'wpXSG_meta_nonce' ); ?>
127
+
128
+
129
+ <div class="wrap" >
130
+
131
+ <h2>Google XML Sitemap Generator</h2>
132
+
133
+
134
+ <p style="color:#B80000"><strong>This is the initial release of this plugin and recommend you use it with
135
+ caution, especially with important live production websites.
136
+ As always you should regularly backup your website.</p> <p style="color:#B80000">Please
137
+ <a target="_blank" href="https://xmlsitemapgenerator.org/contact.aspx">contact us</a> with any comments,
138
+ questions, suggestions and bugs.</strong></p>
139
+
140
+ <p>Here you can edit your admin settings and defaults.</p>
141
+ <p>You can override categories, tags, pages and posts when adding and editing them.</p>
142
+
143
+
144
+
145
+ <div id="poststuff" class="metabox-holder has-right-sidebar">
146
+
147
+ <div class="inner-sidebar">
148
+ <div class="meta-box-sortabless ui-sortable" style="position:relative;">
149
+
150
+ <div class="postbox">
151
+ <h3 class="hndle"><span>Sitemap related urls</span></h3>
152
+ <div class="inside">
153
+ <p>Pages that are created or modified by Xml Sitemap Generator</p>
154
+ <ul>
155
+ <?php
156
+ $url = get_bloginfo( 'url' ) ;
157
+
158
+ echo '<li><a target="_blank" href="' . $url .'/xmlsitemap.xml">XML Sitemap</a></li>';
159
+ echo '<li><a target="_blank" href="' . $url .'/rsssitemap.xml">RSS Sitemap</a></li>';
160
+ echo '<li><a target="_blank" href="' . $url .'/rsslatest.xml">New Pages RSS</a></li>';
161
+ echo '<li><a target="_blank" href="' . $url .'/robots.txt">Robots.txt</a></li>';
162
+
163
+ ?>
164
+
165
+ </ul>
166
+
167
+ </div>
168
+ </div>
169
+
170
+
171
+ <div class="postbox">
172
+ <h3 class="hndle"><span>Webmaster tools</span></h3>
173
+ <div class="inside">
174
+ <p>It is highly recommended you register your sitemap
175
+ with webmaster tools to obtain performance insights.</p>
176
+ <ul>
177
+ <li><a href="https://www.google.com/webmasters/tools/">Google Webmaster tools</a></li>
178
+ <li><a href="http://www.bing.com/toolbox/webmaster">Bing Webmaster tools</a></li>
179
+ <li><a href="http://zhanzhang.baidu.com/">Baidu Webmaster tools</a></li>
180
+ <li><a href="https://webmaster.yandex.com/">Yandex Webmaster tools</a></li>
181
+
182
+ </ul>
183
+
184
+ </div>
185
+ </div>
186
+
187
+
188
+ <div class="postbox">
189
+ <h3 class="hndle"><span>Useful links</span></h3>
190
+ <div class="inside">
191
+ <ul>
192
+ <li><a href="https://xmlsitemapgenerator.org/Wordpress-sitemap-plugin.aspx">Help and support</a></li>
193
+ <li><a href="http://blog.xmlsitemapgenerator.org/">blog.XmlSitemapGenerator.org</a></li>
194
+ <li><a href="https://twitter.com/createsitemaps">twitter : @CreateSitemaps</a></li>
195
+ <li><a href="https://www.facebook.com/XmlSitemapGenerator">facebook XmlSitemapGenerator</a></li>
196
+
197
+ </ul>
198
+
199
+ </div>
200
+ </div>
201
+
202
+
203
+ <div class="postbox">
204
+ <h3 class="hndle"><span>Please support us</span></h3>
205
+ <div class="inside">
206
+ <p>We take time out of our personal lives to develop and support our sitemap tools and cover costs out of our own pockets.
207
+ </p>
208
+ <p>Please help with costs by making a small contribution..</p>
209
+
210
+ <p><a target="_blank" href="https://xmlsitemapgenerator.org/donate.aspx">Make a small donation</a></p>
211
+ </div>
212
+ </div>
213
+
214
+ </div>
215
+ </div>
216
+
217
+
218
+
219
+ <div class="has-sidebar">
220
+
221
+
222
+
223
+ <div id="post-body-content" class="has-sidebar-content">
224
+
225
+ <div class="meta-box-sortabless">
226
+
227
+ <script type="text/javascript" src="<?php echo myPluginPath(); ?>scripts.js"></script>
228
+ <div class="postbox">
229
+ <h3 class="hndle"><span>General settings</span></h3>
230
+ <div class="inside">
231
+
232
+
233
+ <p>General options for your sitemap.
234
+ We recommend you enable all of these.</p>
235
+
236
+ <ul>
237
+ <li>
238
+ <input type="checkbox" name="pingSitemap" id="pingSitemap" value="1" <?php checked($globalSettings->pingSitemap, '1'); ?> />
239
+ <label for="sm_b_ping">Automatically ping Google / Bing (MSN & Yahoo) daily</label><br>
240
+ </li>
241
+ <li>
242
+ <input type="checkbox" name="addRssToHead" id=""addRssToHead" value="1" <?php checked($globalSettings->addRssToHead, '1'); ?> />
243
+ <label for="sm_b_ping">Add latest pages / post RSS feed to head tag</label><br>
244
+ </li>
245
+ <li>
246
+ <input type="checkbox" name="addToRobots" id="addToRobots" value="1" <?php checked($globalSettings->addToRobots, '1'); ?> />
247
+ <label for="sm_b_ping">Add sitemap links to your robots.txt file</label><br>
248
+ </li>
249
+ <li>
250
+ <input type="checkbox" name="sendStats" id="sendStats" value="1" <?php checked($globalSettings->sendStats, '1'); ?> />
251
+ <label for="sm_b_ping">Help us improve by allowing basic usage stats (Page count, PHP Version, feature usage, etc.)</label><br>
252
+ </li>
253
+ <li>
254
+ <input type="checkbox" name="smallCredit" id="smallCredit" value="1" <?php checked($globalSettings->smallCredit, '1'); ?> />
255
+ <label for="sm_b_ping">Support us by allowing a small credit in the sitemap file footer (Does not appear on your website)</label><br>
256
+ </li>
257
+ </ul>
258
+ </div>
259
+ </div>
260
+
261
+ <div class="postbox">
262
+ <h3 class="hndle"><span>Sitemap defaults</span></h3>
263
+ <div class="inside">
264
+
265
+
266
+ <p>Set the defaults for your sitemap here.</p>
267
+
268
+ <ul>
269
+ <li>
270
+ <select name="dateField" id="dateField">
271
+ <option <?php if ($sitemapDefaults->dateField == "created") {echo 'selected="selected"';} ?>>created</option>
272
+ <option <?php if ($sitemapDefaults->dateField == "updated") {echo 'selected="selected"';} ?>>updated</option>
273
+ </select>
274
+ <label for="sm_b_ping"> date field to use for modified date / recently updated.</label><br>
275
+ </li>
276
+ </ul>
277
+
278
+ <p>You can override the sitemap default settings for taxonomy items (categories, tags, etc), pages and posts when adding and editing them.</p>
279
+
280
+ <table class="wp-list-table widefat fixed striped tags" style="clear:none;">
281
+ <thead>
282
+ <tr>
283
+ <th scope="col">Page / area</th>
284
+ <th scope="col">Exclude</th>
285
+ <th scope="col">Relative priority</th>
286
+ <th scope="col">Update frequency</th>
287
+ </tr>
288
+ </thead>
289
+ <tbody id="the-list" >
290
+
291
+
292
+ <?php
293
+
294
+ self::RenderDefaultSection("Home page","homepage",$sitemapDefaults->homepage);
295
+ self::RenderDefaultSection("Regular page","pages",$sitemapDefaults->pages);
296
+ self::RenderDefaultSection("Post page","posts",$sitemapDefaults->posts);
297
+ self::RenderDefaultSection("Taxonomy - categories","taxonomyCategories",$sitemapDefaults->taxonomyCategories);
298
+ self::RenderDefaultSection("Taxonomy - tags","taxonomyTags",$sitemapDefaults->taxonomyTags);
299
+
300
+ self::RenderDefaultSection("Archive - recent","recentArchive",$sitemapDefaults->recentArchive);
301
+ self::RenderDefaultSection("Archive - old","oldArchive",$sitemapDefaults->oldArchive);
302
+ self::RenderDefaultSection("Authors","authors",$sitemapDefaults->authors);
303
+
304
+
305
+ ?>
306
+
307
+
308
+
309
+
310
+ </tbody></table>
311
+
312
+ </div>
313
+ </div>
314
+
315
+ <div class="postbox">
316
+ <h3 class="hndle"><span>Log</span></h3>
317
+ <div class="inside">
318
+
319
+ <?php echo core::getStatusHtml();?>
320
+ </div>
321
+ </div>
322
+
323
+
324
+
325
+ </div>
326
+
327
+ </div>
328
+
329
+ <?php submit_button(); ?>
330
+
331
+ </div>
332
+
333
+
334
+
335
+
336
+ </div>
337
+ </div>
338
+
339
+
340
+ </form>
341
+
342
+
343
+
344
+
345
+
346
+
347
+ <?php
348
+
349
+ }
350
+
351
+
352
+
353
+ }
354
+
355
+
356
+
357
+
358
+ ?>
code/settingsModels.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace xmlSitemapGenerator;
4
+
5
+ // settings for generating a map
6
+
7
+
8
+
9
+ class sitemapDefaults {
10
+
11
+ function __construct() {
12
+ //($exclude1 = 1,$priority1 = 1,$frequency1 = 1, $inherit = 0)
13
+ $this->homepage = new metaSettings(3,12,6,0);
14
+ $this->pages = new metaSettings(3,8,4,0);
15
+ $this->posts = new metaSettings(3,8,4,0);
16
+ $this->taxonomyCategories = new metaSettings(3,5,5,0);
17
+ $this->taxonomyTags = new metaSettings(3,5,5,0);
18
+
19
+ $this->recentArchive = new metaSettings(3,8,7,0);
20
+ $this->oldArchive = new metaSettings(3,5,3,0);
21
+ $this->authors = new metaSettings(3,5,5,0);
22
+
23
+ }
24
+
25
+ public $homepage ;
26
+ public $pages;
27
+ public $posts ;
28
+ public $taxonomyCategories;
29
+ public $taxonomyTags;
30
+
31
+ public $recentArchive ;
32
+ public $oldArchive ;
33
+ public $authors ;
34
+
35
+ public $dateField = "updated"; // date field for sitemap can be updated or created date.
36
+ public $excludeRules = "";
37
+
38
+ }
39
+
40
+ class globalSettings {
41
+
42
+ public $addRssToHead = true; // add recent files to Rss header
43
+ public $pingSitemap = true; // daily sitemap ping
44
+ public $addToRobots = true; // add files to robots
45
+ public $sendStats = true; // send stats
46
+ public $smallCredit = true; //allow a credit in the sitemap footer
47
+ }
48
+
49
+ class metaSettings
50
+ {
51
+ function __construct($exclude1 = 1,$priority1 = 1,$frequency1 = 1, $inherit = 0) {
52
+ $this->exclude = $exclude1;
53
+ $this->priority = $priority1;
54
+ $this->frequency = $frequency1;
55
+ }
56
+
57
+ public $id = 0;
58
+ public $itemId = 0;
59
+ public $itemType = "";
60
+ public $exclude = 1;
61
+ public $priority = 1;
62
+ public $frequency = 1;
63
+ public $inherit = 0;
64
+
65
+
66
+ }
67
+
68
+
69
+ ?>
code/sitemapBuilder.php ADDED
@@ -0,0 +1,472 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace xmlSitemapGenerator;
4
+
5
+ include_once 'dataAccess.php';
6
+ include_once 'renderers.php';
7
+
8
+ class mapItem
9
+ {
10
+
11
+ function __construct()
12
+ {}
13
+
14
+ public $location ;
15
+ public $title ;
16
+ public $description ;
17
+ public $modified ;
18
+ public $priority ;
19
+ public $frequency ;
20
+
21
+ }
22
+
23
+ class sitemapBuilder
24
+ {
25
+
26
+
27
+ private $pageSize ;
28
+ private $urlsList = array();
29
+ private $isExecuting = false;
30
+ private $siteName = "";
31
+
32
+ private $instance;
33
+
34
+ public function __construct() {
35
+
36
+ $this->pageSize = get_option('posts_per_page');
37
+ $this->urlsList = array();
38
+ $siteName = get_option('blogname');
39
+
40
+ }
41
+ /*
42
+ public static function getInstance();
43
+ {
44
+ if ($this->instance === null) {
45
+ $this->instance = new self();
46
+ }
47
+ return $this->instance;
48
+ }
49
+ */
50
+ function getValue($value, $default)
51
+ {
52
+ if (isset($value))
53
+ {
54
+ if ($value == 'default') return $default;
55
+ return $value;
56
+ }
57
+ else
58
+ {
59
+ return $default;
60
+ }
61
+ }
62
+
63
+
64
+
65
+
66
+ function isIncluded($url, $rules)
67
+ {
68
+ //todo
69
+
70
+ return true;
71
+
72
+ }
73
+
74
+ public static function renderComment()
75
+ {
76
+ echo "<!-- Created using XmlSitemapGenerator.org WordPress Plugin - Free HTML, RSS and XML sitemap generator -->";
77
+ }
78
+
79
+
80
+ function getPageLink($url, $pagenum = 1, $escape = true ) {
81
+ global $wp_rewrite;
82
+
83
+ $pagenum = (int) $pagenum;
84
+
85
+ $home_root = preg_quote( home_url(), '|' );
86
+ $request = $url;
87
+
88
+
89
+ $request = preg_replace('|^'. $home_root . '|i', '', $request);
90
+ $request = preg_replace('|^/+|', '', $request);
91
+
92
+
93
+ if ( !$wp_rewrite->using_permalinks() || is_admin() ) {
94
+ $base = trailingslashit( get_bloginfo( 'url' ) );
95
+
96
+ if ( $pagenum > 1 ) {
97
+ $result = add_query_arg( 'paged', $pagenum, $base . $request );
98
+ } else {
99
+ $result = $base . $request;
100
+ }
101
+ } else {
102
+ $qs_regex = '|\?.*?$|';
103
+ preg_match( $qs_regex, $request, $qs_match );
104
+
105
+ if ( !empty( $qs_match[0] ) ) {
106
+ $query_string = $qs_match[0];
107
+ $request = preg_replace( $qs_regex, '', $request );
108
+ } else {
109
+ $query_string = '';
110
+ }
111
+
112
+ $request = preg_replace( "|$wp_rewrite->pagination_base/\d+/?$|", '', $request);
113
+ $request = preg_replace( '|^' . preg_quote( $wp_rewrite->index, '|' ) . '|i', '', $request);
114
+ $request = ltrim($request, '/');
115
+
116
+ $base = trailingslashit( get_bloginfo( 'url' ) );
117
+
118
+ if ( $wp_rewrite->using_index_permalinks() && ( $pagenum > 1 || '' != $request ) )
119
+ $base .= $wp_rewrite->index . '/';
120
+
121
+ if ( $pagenum > 1 ) {
122
+ $request = ( ( !empty( $request ) ) ? trailingslashit( $request ) : $request ) . user_trailingslashit( $wp_rewrite->pagination_base . "/" . $pagenum, 'paged' );
123
+ }
124
+
125
+ $result = $base . $request . $query_string;
126
+ }
127
+
128
+ /**
129
+ * Filter the page number link for the current request.
130
+ *
131
+ * @since 2.5.0
132
+ *
133
+ * @param string $result The page number link.
134
+ */
135
+ $result = apply_filters( 'get_pagenum_link', $result );
136
+
137
+ if ( $escape )
138
+ return esc_url( $result );
139
+ else
140
+ return esc_url_raw( $result );
141
+ }
142
+
143
+ function getMetaValue($postValue,$tagValue,$default)
144
+ {
145
+
146
+ if (isset($postValue))
147
+ {
148
+
149
+ if ( $postValue !== 1) { return $postValue; }
150
+ }
151
+ elseif (isset($tagValue))
152
+ {
153
+ if ( $tagValue !== 1) {return $tagValue; }
154
+ }
155
+ else
156
+ {
157
+ return $default;
158
+ }
159
+
160
+ }
161
+
162
+
163
+ function addUrls($postCount, $mapItem)
164
+ {
165
+ $pages = 1;
166
+
167
+ if ($postCount > $this->pageSize)
168
+ {
169
+ $pages = ceil($postCount / $this->pageSize);
170
+ }
171
+
172
+ $siteName = get_option('blogname');
173
+ $mapItem->title = $mapItem->title . " | " . $siteName ;
174
+ array_push($this->urlsList, $mapItem); // first page
175
+ for ($x = 2; $x <= $pages; $x++)
176
+ {
177
+ $new = clone $mapItem;
178
+ $new->title = $new->title . " | Page " . $x;
179
+ $new->location = $this->getPageLink($mapItem->location,$x);
180
+ array_push($this->urlsList, $new);
181
+ }
182
+
183
+ }
184
+
185
+ function getPosts( $sitemapDefaults, $limit = 0){
186
+
187
+
188
+ $results = dataAccess::getPages( $sitemapDefaults->dateField , $limit);
189
+
190
+ if ($results ) {
191
+
192
+ foreach( $results as $result ) {
193
+
194
+
195
+ // wp_cache_add($result ->ID, $result , 'posts');
196
+
197
+ if ($result->post_type == 'page')
198
+ {
199
+ $defaults = $sitemapDefaults->pages;
200
+ }
201
+ else
202
+ {
203
+ $defaults = $sitemapDefaults->posts;
204
+ }
205
+
206
+ $exlcude = $this->getMetaValue($result->exclude, $result->tagExclude, $defaults->exclude) ;
207
+
208
+ if ($exlcude != 2)
209
+ {
210
+ $pageUrl = get_permalink($result);
211
+
212
+ if ($this->isIncluded($pageUrl,$sitemapDefaults->excludeRules ))
213
+ {
214
+
215
+ $url = new mapItem();
216
+ $url->location = $pageUrl ;
217
+ $url->title = get_the_title( $result ); //$result->post_title;
218
+ $url->description = $result->post_excerpt;
219
+ $url->modified = $result->sitemapDate ;
220
+
221
+ $url->priority = $this->getMetaValue($result->priority,$result->tagPriority, $defaults->priority) ;
222
+ $url->frequency = $this->getMetaValue($result->frequency,$result->tagFrequency,$defaults->frequency) ;
223
+
224
+ $this->addUrls(0, $url);
225
+
226
+ }
227
+ }
228
+ }
229
+ }
230
+
231
+ }
232
+
233
+ function getTaxonomy($sitemapDefaults)
234
+ {
235
+
236
+ $results = dataAccess::getTaxonomy( $sitemapDefaults->dateField );
237
+
238
+
239
+
240
+ $urls = array();
241
+
242
+ if ($results ) {
243
+
244
+ foreach( $results as $result ) {
245
+
246
+
247
+ // wp_cache_add($result ->ID, $result , 'posts');
248
+ if ($result->taxonomy == 'category')
249
+ {$defaults = $sitemapDefaults->taxonomyCategories;}
250
+ else
251
+ {$defaults = $sitemapDefaults->taxonomyTags;}
252
+
253
+ $exlcude = $this->getMetaValue(null, $result->exclude, $defaults->exclude) ;
254
+
255
+ if ($exlcude != 2)
256
+ {
257
+ $pageUrl = get_category_link($result);
258
+
259
+ if ($this->isIncluded($pageUrl,$sitemapDefaults->excludeRules ))
260
+ {
261
+
262
+ $url = new mapItem();
263
+ $url->location = $pageUrl;
264
+ $url->title = $result->name;
265
+ $url->description = $result->description;
266
+ $url->modified = $result->sitemapDate ;
267
+ $url->priority = $this->getMetaValue(null,$result->priority,$defaults->priority) ;
268
+ $url->frequency = $this->getMetaValue(null,$result->frequency,$defaults->frequency) ;
269
+
270
+ $this->addUrls($result->posts, $url);
271
+
272
+ }
273
+ }
274
+ }
275
+ }
276
+
277
+ }
278
+
279
+ function getAuthors($sitemapDefaults)
280
+ {
281
+
282
+ $results = dataAccess::getAuthors($sitemapDefaults->dateField );
283
+
284
+
285
+ if ($results ) {
286
+
287
+
288
+
289
+ foreach( $results as $result ) {
290
+
291
+
292
+ // wp_cache_add($result ->ID, $result , 'posts');
293
+
294
+ $defaults = $sitemapDefaults->authors;
295
+
296
+ $exlcude = $this->getMetaValue(null, $result->exclude, $defaults->exclude) ;
297
+
298
+ if ($exlcude != 2)
299
+ {
300
+ $pageUrl = get_author_posts_url($result->ID, $result->user_nicename);
301
+
302
+ if ($this->isIncluded($pageUrl,$settings->excludeRules ))
303
+ {
304
+
305
+ $url = new mapItem();
306
+ $url->location = $pageUrl;
307
+ $url->title = $result->display_name ;
308
+ $url->description = $result->description;
309
+ $url->modified = $result->sitemapDate ;
310
+ $url->priority = $this->getMetaValue(null,$result->priority,$defaults->priority) ;
311
+ $url->frequency = $this->getMetaValue(null,$result->frequency,$defaults->frequency) ;
312
+
313
+ $this->addUrls($result->posts, $url);
314
+ }
315
+ }
316
+ }
317
+ }
318
+ }
319
+
320
+ function getArchive($sitemapDefaults)
321
+ {
322
+
323
+ $results = dataAccess::getArchives($sitemapDefaults->dateField );
324
+
325
+ if ($results ) {
326
+
327
+
328
+ foreach( $results as $result ) {
329
+
330
+ $now = getdate();
331
+
332
+ if($result->month == date("n") && $result->year == date("Y"))
333
+ {
334
+ $defaults = $sitemapDefaults->recentArchive;
335
+ }
336
+ else
337
+ {
338
+ $defaults = $sitemapDefaults->oldArchive;
339
+ }
340
+
341
+ $exlcude = $this->getMetaValue(null, $result->exclude, $defaults->exclude) ;
342
+ $posts = $result->posts;
343
+
344
+ $pageUrl = get_month_link( $result->year , $result->month) ;
345
+
346
+
347
+ if ($exlcude != 2)
348
+ {
349
+
350
+ if ($this->isIncluded($pageUrl,$settings->excludeRules ))
351
+ {
352
+
353
+ $url = new mapItem();
354
+ $url->location = $pageUrl;
355
+ $url->title = date('F', strtotime("2012-$result->month-01")) . " | " . $result->year ;
356
+ $url->description = $result->description;
357
+ $url->modified = $result->sitemapDate ;
358
+ $url->priority = $this->getMetaValue($result->priority,$result->tagPriority, $defaults->priority) ;
359
+ $url->frequency = $this->getMetaValue($result->frequency,$result->tagFrequency,$defaults->frequency) ;
360
+
361
+ $this->addUrls($result->posts, $url);
362
+
363
+ }
364
+ }
365
+
366
+ }
367
+ }
368
+
369
+
370
+ }
371
+ function addHomePage($sitemapDefaults)
372
+ {
373
+
374
+ $defaults = $sitemapDefaults->homepage;
375
+ $pageUrl = get_bloginfo( 'url' );
376
+
377
+ if ($exlcude != 2)
378
+ {
379
+
380
+ if ($this->isIncluded($pageUrl,$settings->excludeRules ))
381
+ {
382
+
383
+ $url = new mapItem();
384
+ $url->location = $pageUrl;
385
+ $url->title = "Home page" ;
386
+ $url->description = get_option( 'blogdescription');;
387
+ $url->modified = dataAccess::getLastModified() ;
388
+ $url->priority = $defaults->priority ;
389
+ $url->frequency = $defaults->frequency ;
390
+
391
+ $this->addUrls($result->posts, $url);
392
+
393
+ }
394
+ }
395
+ }
396
+
397
+ function getAllUrls()
398
+ {
399
+ $settings = get_option( "wpXSG_sitemapDefaults" , new sitemapDefaults() );
400
+
401
+ $this->addHomePage($settings);
402
+ $this->getPosts($settings, 0);
403
+ $this->getTaxonomy($settings);
404
+ $this->getAuthors($settings);
405
+ $this->getArchive($settings);
406
+ }
407
+
408
+ function getNewUrls()
409
+ {
410
+ $settings = get_option( "wpXSG_sitemapDefaults" , new sitemapDefaults() );
411
+ $this->getPosts($settings, 20);
412
+
413
+ }
414
+
415
+ function render($sitemapType)
416
+ {
417
+ $startTime = microtime(true) ;
418
+ $siteName = get_option('blogname');
419
+
420
+ $limit = 0;
421
+ if ($sitemapType == 'rssnew')
422
+ {
423
+ $sitemapType = "rss";
424
+ $this->getNewUrls();
425
+ }
426
+ elseif ($sitemapType == 'xsl')
427
+ {
428
+ // don't load urls for xsl
429
+ }
430
+ else
431
+ {
432
+ $this->getAllUrls();
433
+ }
434
+
435
+ $renderer = sitemapRenderer::getInstance($sitemapType);
436
+
437
+
438
+ $renderer->render($this->urlsList);
439
+
440
+ $time = core::getTimeBand($startTime);
441
+ core::updateStatistics("Render", "Render" . $sitemapType, $time);
442
+
443
+ exit;
444
+
445
+
446
+ }
447
+
448
+ public static function renderCredit()
449
+ {
450
+ $globalSettings = get_option( "wpXSG_global" , new globalSettings() );
451
+
452
+ if ($globalSettings->smallCredit)
453
+ {
454
+ echo '<div id="xsgFooter">Generated by XmlSitemapGenerator.org -
455
+ <a href="https://xmlsitemapgenerator.org/wordpress-sitemap-generator-plugin.aspx"
456
+ title="WordPress XML Sitemap Generator Plugin">
457
+ WordPress XML Sitemap Generator Plugin</a>
458
+ </div>';
459
+
460
+ }
461
+
462
+
463
+
464
+
465
+ }
466
+
467
+
468
+ }
469
+
470
+
471
+
472
+ ?>
readme.txt ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Google XML Sitemap Generator ===
2
+ Contributors: XmlSitemapGenerator
3
+ Tags: title, xml, rss, sitemap, yandex, metaboxes, google, bing, yahoo, baidu
4
+ Donate link: https://XmlSitemapGenerator.org/donate.aspx
5
+ Requires at least: 4.0
6
+ Tested up to: 4.3
7
+ Stable tag: 1.1
8
+
9
+
10
+ Easy to use, highly configurable WordPress RSS and Google XML Sitemap generator plugin. Compatible with Google, Bing, Baidu, Yandex and more.
11
+
12
+ == Description ==
13
+
14
+ [Google XML Sitemap Generator](https://xmlsitemapgenerator.org/wordpress-sitemap-generator-plugin.aspx) adds powerful and configurable RSS and Google XML sitemap features to WordPress. It enables you to set global sitemap defaults to get up and running quickly which can then be customised at the category, tag, post and page level.
15
+
16
+ **Features include:**
17
+
18
+ * HTML, RSS and Google XML Sitemap formats.
19
+ * List all your WordPress Pages, Posts, Archives, Authors, Categories and Tags.
20
+ * Includes paged links for posts for Archives, Authors, Categories and Tags.
21
+ * Set global sitemap default values for priorty and update frequencies.
22
+ * Set sitemap value for priority and frequency at the category, tag, post and page level.
23
+ * Automatic daily auto ping when you have updated pages / posts in WordPress.
24
+ * Add latest pages / posts RSS feed to page header.
25
+ * Updates your Robots.txt file with sitemap entries.
26
+
27
+
28
+ **New features**
29
+
30
+ We're always seeking to improve and update.
31
+ Stay in touch via [facebook](https://www.facebook.com/XmlSitemapGenerator) and [Twitter](https://twitter.com/createsitemaps)
32
+
33
+
34
+ == Installation ==
35
+
36
+ 1. We recommend you install Google XML Sitemap Generator via the WordPress.org plugin directory.
37
+ 2. After activating it just works!
38
+ 3. Click the "settings" link to edit global settings.
39
+ 4. Configure tag, category, post and page level settings when adding / editing them.
40
+ 5. It's that easy!
41
+
42
+
43
+ == Screenshots ==
44
+
45
+ 1. Global sitemap settings
46
+ 2. Post / page sitemap settings
47
+ 3. Category / tag settings
48
+ 4. XML Sitemap page
49
+ 5. Sitemap entries in Robots.txt
50
+
51
+
52
+ == Changelog ==
53
+
54
+ = 1.1 =
55
+ Release Date: July 27nd, 2015
56
+
57
+ * Fix : RSS sitemap date format issue
58
+ * Fix : XML sitemap date issue
59
+ * Fix : Pagination counting pages
60
+ * Fix : Logging null value error
61
+ * Fix : Ping issues
62
+
63
+ = 1.0 =
64
+ Release Date: July 23rd, 2015
65
+ Release Post: http://blog.xmlsitemapgenerator.org/2015/07/wordpress-xml-sitemap-generator.html
66
+
67
+ * Initial release
68
+
scripts.js ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function populate(id, options, selected)
2
+ {
3
+ var select = document.getElementById(id);
4
+
5
+ for ( var i = 0; i < options.length; i++)
6
+ {
7
+ var opt = options[i];
8
+ var el = document.createElement("option");
9
+ el.textContent = opt[1];
10
+ el.value = opt[0];
11
+ select.appendChild(el);
12
+ if (opt[0] == selected) {
13
+ select.selectedIndex = i;
14
+ }
15
+ }
16
+
17
+ }
18
+
19
+
20
+ var excludeDefaults = [[2,"exclude"] , [3,"include"] ];
21
+ var priorityDefaults = [[0,"none"], [2,"0.0"], [3,"0.1"], [4,"0.2"], [5,"0.3"], [6,"0.4"] , [7,"0.5"] , [8,"0.6"] , [9,"0.7"] , [10,"0.8"] , [11,"0.9"], [12,"1.0"] ];
22
+ var frequencyDefaults = [[0,"none"], [7,"always"], [6,"daily"], [5,"weekly"], [4,"monthly"], [3,"yearly"] , [2,"never"] ];
23
+
24
+ var inheritSelect = [ [0,"Don't inherit"], [1,"Inherit"] ];
25
+ var excludeSelect = [ [1,"default"], [2,"exclude"] , [3,"include"] ];
26
+ var prioritySelect = [[0,"none"],[1, "default"], [2,"0.0"], [3,"0.1"], [4,"0.2"], [5,"0.3"], [6,"0.4"] , [7,"0.5"] , [8,"0.6"] , [9,"0.7"] , [10,"0.8"] , [11,"0.9"], [12,"1.0"] ];
27
+ var frequencySelect = [[0,"none"],[1, "default"], [7,"always"], [6,"daily"], [5,"weekly"], [4,"monthly"], [3,"yearly"] , [2,"never"] ];
28
+
www-xml-sitemap-generator-org.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace xmlSitemapGenerator;
3
+ /*
4
+ Plugin Name: Google XML Sitemap Generator
5
+ Plugin URI: https://XmlSitemapGenerator.org
6
+ Description: HTML, RSS and Google XML Sitemap generator compatible with Google, Bing, Baidu, Yandex and more.
7
+ Version: 1.1
8
+ Author: XmlSitemapGenerator.org
9
+ Author URI: https://XmlSitemapGenerator.org
10
+ License: GPL2
11
+ */
12
+
13
+ include 'code/core.php';
14
+
15
+
16
+ function myPluginFile() {
17
+
18
+ return __FILE__;
19
+ }
20
+ function myPluginPath() {
21
+ return plugins_url() . "/" . PLUGIN_NAME . "/";
22
+
23
+ }
24
+
25
+
26
+ if(defined('ABSPATH') && defined('WPINC')) {
27
+ add_action("init", 'xmlSitemapGenerator\core::initialisePlugin');
28
+ register_activation_hook(__FILE__, 'xmlSitemapGenerator\core::activatePlugin');
29
+
30
+ // call this here because other plugins in the init might flush.
31
+ core::addQueryVariableHooks();
32
+ core::addRewriteHooks();
33
+ }
34
+
35
+
36
+
37
+ ?>