Google XML Sitemaps v3 for qTranslate - Version 3.4.1

Version Description

Download this release

Release Info

Developer DSmidgy
Plugin Icon wp plugin Google XML Sitemaps v3 for qTranslate
Version 3.4.1
Comparing to
See all releases

Code changes from version 3.3.1 to 3.4.1

documentation.txt CHANGED
@@ -244,6 +244,7 @@
244
  2013-09-28 3.3 Fixed problem with file permission checking
245
  Filter out hashs (#) in URLs
246
  2013-11-24 3.4 Fixed deprecation warnings in PHP 5.4, thanks to Dion Hulse!
 
247
 
248
  Maybe Todo:
249
  ==============================================================================
244
  2013-09-28 3.3 Fixed problem with file permission checking
245
  Filter out hashs (#) in URLs
246
  2013-11-24 3.4 Fixed deprecation warnings in PHP 5.4, thanks to Dion Hulse!
247
+ 2014-04-10 3.4.1 Fixed compatibility with mysqli
248
 
249
  Maybe Todo:
250
  ==============================================================================
readme.txt CHANGED
@@ -1,16 +1,16 @@
1
  === Google XML Sitemaps v3 for qTranslate ===
2
  Contributors: arnee, NeoEGM, DSmidgy
3
  Donate link: http://www.arnebrachhold.de/redir/sitemap-paypal
4
- Tags: seo, google, sitemaps, google sitemaps, yahoo, msn, ask, live, xml sitemap, xml, qtranslate
5
  Requires at least: 2.1
6
- Tested up to: 3.8
7
- Stable tag: 3.3.1
8
 
9
  This plugin will generate a special XML sitemap which will help search engines to better index your blog. With qTranslate support.
10
 
11
  == Description ==
12
 
13
- This plugin will generate a special XML sitemap which will help search engines like Google, Bing, Yahoo and Ask.com to better index your blog. With such a sitemap, it's much easier for the crawlers to see the complete structure of your site and retrieve it more efficiently. The plugin supports all kinds of WordPress generated pages as well as custom URLs. Additionally it notifies all major search engines every time you create a post about the new content.
14
 
15
  This fork is compatible with qTranslate multilingual plugin. It can translate more types of URLs (categories, tags, etc.) than NeoEGM's plugin. More on http://blog.slo-host.com/2011/06/qtranslate-support-for-google-xml-sitemaps-plugin/
16
 
1
  === Google XML Sitemaps v3 for qTranslate ===
2
  Contributors: arnee, NeoEGM, DSmidgy
3
  Donate link: http://www.arnebrachhold.de/redir/sitemap-paypal
4
+ Tags: seo, google, sitemaps, google sitemaps, yahoo, msn, live, xml sitemap, xml, qtranslate
5
  Requires at least: 2.1
6
+ Tested up to: 3.9
7
+ Stable tag: 3.4.1
8
 
9
  This plugin will generate a special XML sitemap which will help search engines to better index your blog. With qTranslate support.
10
 
11
  == Description ==
12
 
13
+ This plugin will generate a special XML sitemap which will help search engines like Google, Bing and Yahoo to better index your blog. With such a sitemap, it's much easier for the crawlers to see the complete structure of your site and retrieve it more efficiently. The plugin supports all kinds of WordPress generated pages as well as custom URLs. Additionally it notifies all major search engines every time you create a post about the new content.
14
 
15
  This fork is compatible with qTranslate multilingual plugin. It can translate more types of URLs (categories, tags, etc.) than NeoEGM's plugin. More on http://blog.slo-host.com/2011/06/qtranslate-support-for-google-xml-sitemaps-plugin/
16
 
readme.txt.original CHANGED
@@ -1,16 +1,16 @@
1
  === Google XML Sitemaps ===
2
  Contributors: arnee
3
  Donate link: http://www.arnebrachhold.de/redir/sitemap-paypal
4
- Tags: seo, google, sitemaps, google sitemaps, yahoo, msn, ask, live, xml sitemap, xml
5
  Requires at least: 2.1
6
- Tested up to: 3.8
7
- Stable tag: 3.3
8
 
9
  This plugin will generate a special XML sitemap which will help search engines to better index your blog.
10
 
11
  == Description ==
12
 
13
- This plugin will generate a special XML sitemap which will help search engines like Google, Bing, Yahoo and Ask.com to better index your blog. With such a sitemap, it's much easier for the crawlers to see the complete structure of your site and retrieve it more efficiently. The plugin supports all kinds of WordPress generated pages as well as custom URLs. Additionally it notifies all major search engines every time you create a post about the new content.
14
 
15
  Related Links:
16
 
1
  === Google XML Sitemaps ===
2
  Contributors: arnee
3
  Donate link: http://www.arnebrachhold.de/redir/sitemap-paypal
4
+ Tags: seo, google, sitemaps, google sitemaps, yahoo, msn, live, xml sitemap, xml
5
  Requires at least: 2.1
6
+ Tested up to: 3.9
7
+ Stable tag: 3.3.1
8
 
9
  This plugin will generate a special XML sitemap which will help search engines to better index your blog.
10
 
11
  == Description ==
12
 
13
+ This plugin will generate a special XML sitemap which will help search engines like Google, Bing and Yahoo to better index your blog. With such a sitemap, it's much easier for the crawlers to see the complete structure of your site and retrieve it more efficiently. The plugin supports all kinds of WordPress generated pages as well as custom URLs. Additionally it notifies all major search engines every time you create a post about the new content.
14
 
15
  Related Links:
16
 
sitemap-core.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
 
4
- $Id: sitemap-core.php 809741 2013-11-24 18:32:07Z arnee $
5
 
6
  */
7
 
@@ -696,7 +696,7 @@ class GoogleSitemapGenerator {
696
  /**
697
  * @var Version of the generator in SVN
698
  */
699
- var $_svnVersion = '$Id: sitemap-core.php 809741 2013-11-24 18:32:07Z arnee $';
700
 
701
  /**
702
  * @var array The unserialized array with the stored options
@@ -1797,26 +1797,46 @@ class GoogleSitemapGenerator {
1797
  $this->SetOption("b_safemode",true);
1798
  }
1799
 
 
 
 
 
1800
  if($this->GetOption("b_safemode")===true) {
1801
- $postRes = mysql_query($sql,$wpdb->dbh);
1802
  if(!$postRes) {
1803
- trigger_error("MySQL query failed: " . mysql_error(),E_USER_NOTICE); //E_USER_NOTICE will be displayed on our debug mode
1804
  return;
1805
  }
1806
  } else {
1807
- $con = mysql_connect(DB_HOST,DB_USER,DB_PASSWORD,true);
 
 
 
 
1808
  if(!$con) {
1809
- trigger_error("MySQL Connection failed: " . mysql_error(),E_USER_NOTICE);
1810
  return;
1811
  }
1812
- if(!mysql_select_db(DB_NAME,$con)) {
1813
- trigger_error("MySQL DB Select failed: " . mysql_error(),E_USER_NOTICE);
 
 
 
 
 
 
 
1814
  return;
1815
  }
1816
- $postRes = mysql_unbuffered_query($sql,$con);
 
 
 
 
 
1817
 
1818
  if(!$postRes) {
1819
- trigger_error("MySQL unbuffered query failed: " . mysql_error(),E_USER_NOTICE);
1820
  return;
1821
  }
1822
  }
@@ -1850,8 +1870,9 @@ class GoogleSitemapGenerator {
1850
  $minPrio=$this->GetOption('pr_posts_min');
1851
 
1852
 
 
1853
  //Cycle through all posts and add them
1854
- while($post = mysql_fetch_object($postRes)) {
1855
 
1856
  //Fill the cache with our DB result. Since it's incomplete (no text-content for example), we will clean it later.
1857
  $cache = array(&$post);
@@ -1941,7 +1962,16 @@ class GoogleSitemapGenerator {
1941
  unset($postRes);
1942
  unset($prioProvider);
1943
 
1944
- if($this->GetOption("b_safemode")!==true && $con) mysql_close($con);
 
 
 
 
 
 
 
 
 
1945
  }
1946
  if($debug) $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: End Postings"));
1947
  }
1
  <?php
2
  /*
3
 
4
+ $Id: sitemap-core.php 890782 2014-04-10 19:16:31Z arnee $
5
 
6
  */
7
 
696
  /**
697
  * @var Version of the generator in SVN
698
  */
699
+ var $_svnVersion = '$Id: sitemap-core.php 890782 2014-04-10 19:16:31Z arnee $';
700
 
701
  /**
702
  * @var array The unserialized array with the stored options
1797
  $this->SetOption("b_safemode",true);
1798
  }
1799
 
1800
+ $useMysqli= isset($wpdb->use_mysqli) && $wpdb->use_mysqli == true;
1801
+
1802
+
1803
+
1804
  if($this->GetOption("b_safemode")===true) {
1805
+ $postRes = $useMysqli?mysqli_query($wpdb->dbh, $sql):mysql_query($sql,$wpdb->dbh);
1806
  if(!$postRes) {
1807
+ trigger_error("MySQL query failed: " . $useMysqli?mysqli_error($wpdb->dbh):mysql_error(),E_USER_NOTICE); //E_USER_NOTICE will be displayed on our debug mode
1808
  return;
1809
  }
1810
  } else {
1811
+ if($useMysqli) {
1812
+ $con = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD);
1813
+ } else {
1814
+ $con = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD, true);
1815
+ }
1816
  if(!$con) {
1817
+ trigger_error("MySQL Connection failed: " . $useMysqli?mysqli_error($con):mysql_error(),E_USER_NOTICE);
1818
  return;
1819
  }
1820
+
1821
+ if($useMysqli) {
1822
+ $select = mysqli_select_db($con, DB_NAME);
1823
+ } else {
1824
+ $select = mysql_select_db(DB_NAME,$con);
1825
+ }
1826
+
1827
+ if(!$select) {
1828
+ trigger_error("MySQL DB Select failed: " . $useMysqli?mysqli_error($con):mysql_error(),E_USER_NOTICE);
1829
  return;
1830
  }
1831
+
1832
+ if($useMysqli) {
1833
+ $postRes = mysqli_query($con, $sql, MYSQLI_USE_RESULT);
1834
+ } else {
1835
+ $postRes = mysql_unbuffered_query($sql,$con);
1836
+ }
1837
 
1838
  if(!$postRes) {
1839
+ trigger_error("MySQL unbuffered query failed: " . $useMysqli?mysqli_error($con):mysql_error(),E_USER_NOTICE);
1840
  return;
1841
  }
1842
  }
1870
  $minPrio=$this->GetOption('pr_posts_min');
1871
 
1872
 
1873
+
1874
  //Cycle through all posts and add them
1875
+ while($post = ($useMysqli?mysqli_fetch_object($postRes):mysql_fetch_object($postRes))) {
1876
 
1877
  //Fill the cache with our DB result. Since it's incomplete (no text-content for example), we will clean it later.
1878
  $cache = array(&$post);
1962
  unset($postRes);
1963
  unset($prioProvider);
1964
 
1965
+ if($this->GetOption("b_safemode")!==true && $con) {
1966
+
1967
+ if($useMysqli) {
1968
+ mysqli_close($con);
1969
+ } else {
1970
+ mysql_close($con);
1971
+ }
1972
+
1973
+
1974
+ }
1975
  }
1976
  if($debug) $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: End Postings"));
1977
  }
sitemap-core.php.original CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
 
4
- $Id: sitemap-core.php 809741 2013-11-24 18:32:07Z arnee $
5
 
6
  */
7
 
@@ -696,7 +696,7 @@ class GoogleSitemapGenerator {
696
  /**
697
  * @var Version of the generator in SVN
698
  */
699
- var $_svnVersion = '$Id: sitemap-core.php 809741 2013-11-24 18:32:07Z arnee $';
700
 
701
  /**
702
  * @var array The unserialized array with the stored options
@@ -1791,26 +1791,46 @@ class GoogleSitemapGenerator {
1791
  $this->SetOption("b_safemode",true);
1792
  }
1793
 
 
 
 
 
1794
  if($this->GetOption("b_safemode")===true) {
1795
- $postRes = mysql_query($sql,$wpdb->dbh);
1796
  if(!$postRes) {
1797
- trigger_error("MySQL query failed: " . mysql_error(),E_USER_NOTICE); //E_USER_NOTICE will be displayed on our debug mode
1798
  return;
1799
  }
1800
  } else {
1801
- $con = mysql_connect(DB_HOST,DB_USER,DB_PASSWORD,true);
 
 
 
 
1802
  if(!$con) {
1803
- trigger_error("MySQL Connection failed: " . mysql_error(),E_USER_NOTICE);
1804
  return;
1805
  }
1806
- if(!mysql_select_db(DB_NAME,$con)) {
1807
- trigger_error("MySQL DB Select failed: " . mysql_error(),E_USER_NOTICE);
 
 
 
 
 
 
 
1808
  return;
1809
  }
1810
- $postRes = mysql_unbuffered_query($sql,$con);
 
 
 
 
 
1811
 
1812
  if(!$postRes) {
1813
- trigger_error("MySQL unbuffered query failed: " . mysql_error(),E_USER_NOTICE);
1814
  return;
1815
  }
1816
  }
@@ -1844,8 +1864,9 @@ class GoogleSitemapGenerator {
1844
  $minPrio=$this->GetOption('pr_posts_min');
1845
 
1846
 
 
1847
  //Cycle through all posts and add them
1848
- while($post = mysql_fetch_object($postRes)) {
1849
 
1850
  //Fill the cache with our DB result. Since it's incomplete (no text-content for example), we will clean it later.
1851
  $cache = array(&$post);
@@ -1941,7 +1962,16 @@ class GoogleSitemapGenerator {
1941
  unset($postRes);
1942
  unset($prioProvider);
1943
 
1944
- if($this->GetOption("b_safemode")!==true && $con) mysql_close($con);
 
 
 
 
 
 
 
 
 
1945
  }
1946
  if($debug) $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: End Postings"));
1947
  }
1
  <?php
2
  /*
3
 
4
+ $Id: sitemap-core.php 890782 2014-04-10 19:16:31Z arnee $
5
 
6
  */
7
 
696
  /**
697
  * @var Version of the generator in SVN
698
  */
699
+ var $_svnVersion = '$Id: sitemap-core.php 890782 2014-04-10 19:16:31Z arnee $';
700
 
701
  /**
702
  * @var array The unserialized array with the stored options
1791
  $this->SetOption("b_safemode",true);
1792
  }
1793
 
1794
+ $useMysqli= isset($wpdb->use_mysqli) && $wpdb->use_mysqli == true;
1795
+
1796
+
1797
+
1798
  if($this->GetOption("b_safemode")===true) {
1799
+ $postRes = $useMysqli?mysqli_query($wpdb->dbh, $sql):mysql_query($sql,$wpdb->dbh);
1800
  if(!$postRes) {
1801
+ trigger_error("MySQL query failed: " . $useMysqli?mysqli_error($wpdb->dbh):mysql_error(),E_USER_NOTICE); //E_USER_NOTICE will be displayed on our debug mode
1802
  return;
1803
  }
1804
  } else {
1805
+ if($useMysqli) {
1806
+ $con = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD);
1807
+ } else {
1808
+ $con = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD, true);
1809
+ }
1810
  if(!$con) {
1811
+ trigger_error("MySQL Connection failed: " . $useMysqli?mysqli_error($con):mysql_error(),E_USER_NOTICE);
1812
  return;
1813
  }
1814
+
1815
+ if($useMysqli) {
1816
+ $select = mysqli_select_db($con, DB_NAME);
1817
+ } else {
1818
+ $select = mysql_select_db(DB_NAME,$con);
1819
+ }
1820
+
1821
+ if(!$select) {
1822
+ trigger_error("MySQL DB Select failed: " . $useMysqli?mysqli_error($con):mysql_error(),E_USER_NOTICE);
1823
  return;
1824
  }
1825
+
1826
+ if($useMysqli) {
1827
+ $postRes = mysqli_query($con, $sql, MYSQLI_USE_RESULT);
1828
+ } else {
1829
+ $postRes = mysql_unbuffered_query($sql,$con);
1830
+ }
1831
 
1832
  if(!$postRes) {
1833
+ trigger_error("MySQL unbuffered query failed: " . $useMysqli?mysqli_error($con):mysql_error(),E_USER_NOTICE);
1834
  return;
1835
  }
1836
  }
1864
  $minPrio=$this->GetOption('pr_posts_min');
1865
 
1866
 
1867
+
1868
  //Cycle through all posts and add them
1869
+ while($post = ($useMysqli?mysqli_fetch_object($postRes):mysql_fetch_object($postRes))) {
1870
 
1871
  //Fill the cache with our DB result. Since it's incomplete (no text-content for example), we will clean it later.
1872
  $cache = array(&$post);
1962
  unset($postRes);
1963
  unset($prioProvider);
1964
 
1965
+ if($this->GetOption("b_safemode")!==true && $con) {
1966
+
1967
+ if($useMysqli) {
1968
+ mysqli_close($con);
1969
+ } else {
1970
+ mysql_close($con);
1971
+ }
1972
+
1973
+
1974
+ }
1975
  }
1976
  if($debug) $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: End Postings"));
1977
  }
sitemap.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  /*
4
- $Id: sitemap.php 809744 2013-11-24 18:44:57Z arnee $
5
 
6
  Google XML Sitemaps Generator for WordPress
7
  ==============================================================================
@@ -25,7 +25,7 @@
25
  Plugin Name: Google XML Sitemaps v3 for qTranslate
26
  Plugin URI: http://wordpress.org/plugins/google-xml-sitemaps-v3-for-qtranslate/
27
  Description: This plugin will generate a special XML sitemap which will help search engines like Google, Yahoo, Bing and Ask.com to better index your blog. With qTranslate support.
28
- Version: 3.3.1
29
  Author: DSmidgy, NeoEGM, Arne Brachhold
30
  Author URI: http://blog.slo-host.com/
31
  Text Domain: sitemap
@@ -96,6 +96,55 @@ class GoogleSitemapGeneratorLoader {
96
  if(!empty($_GET["sm_ping_service"])) {
97
  GoogleSitemapGeneratorLoader::CallShowPingResult();
98
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
  }
100
 
101
  /**
1
  <?php
2
 
3
  /*
4
+ $Id: sitemap.php 890782 2014-04-10 19:16:31Z arnee $
5
 
6
  Google XML Sitemaps Generator for WordPress
7
  ==============================================================================
25
  Plugin Name: Google XML Sitemaps v3 for qTranslate
26
  Plugin URI: http://wordpress.org/plugins/google-xml-sitemaps-v3-for-qtranslate/
27
  Description: This plugin will generate a special XML sitemap which will help search engines like Google, Yahoo, Bing and Ask.com to better index your blog. With qTranslate support.
28
+ Version: 3.4.1
29
  Author: DSmidgy, NeoEGM, Arne Brachhold
30
  Author URI: http://blog.slo-host.com/
31
  Text Domain: sitemap
96
  if(!empty($_GET["sm_ping_service"])) {
97
  GoogleSitemapGeneratorLoader::CallShowPingResult();
98
  }
99
+
100
+ //If somebody had v4 installed and downgraded, delete rewrite rules and rename backup sitemaps back if available.
101
+ if (get_option("sm_rewrite_done", false)) {
102
+ add_action('wp_loaded', array(__CLASS__, 'DeleteV4Rewrite'), 9999, 1);
103
+ }
104
+ }
105
+
106
+
107
+ /**
108
+ * Returns the path to the WordPress root directory
109
+ *
110
+ * @return string
111
+ */
112
+ static function GetHomePath() {
113
+ $home = get_option( 'home' );
114
+ $siteurl = get_option( 'siteurl' );
115
+ if ( ! empty( $home ) && 0 !== strcasecmp( $home, $siteurl ) ) {
116
+ $wp_path_rel_to_home = str_ireplace( $home, '', $siteurl ); /* $siteurl - $home */
117
+ $pos = strripos( str_replace( '\\', '/', $_SERVER['SCRIPT_FILENAME'] ), trailingslashit( $wp_path_rel_to_home ) );
118
+ $home_path = substr( $_SERVER['SCRIPT_FILENAME'], 0, $pos );
119
+ $home_path = trailingslashit( $home_path );
120
+ } else {
121
+ $home_path = ABSPATH;
122
+ }
123
+
124
+ return str_replace( '\\', '/', $home_path );
125
+ }
126
+
127
+ /**
128
+ * Deleted rewrite rules of v4 plugin and tried to rename the backup sitemap files back if available.
129
+ *
130
+ * @return bool
131
+ */
132
+ public static function DeleteV4Rewrite() {
133
+ global $wp_rewrite;
134
+ $wp_rewrite->flush_rules(false);
135
+ delete_option("sm_rewrite_done");
136
+
137
+ $path = @trailingslashit(self::GetHomePath());
138
+
139
+ $res = true;
140
+
141
+ if(@file_exists($f = $path . "sitemap.backup.xml")) if(@!rename($f, $path . "sitemap.xml")) $res = false;
142
+ if(@file_exists($f = $path . "sitemap.backup.xml.gz")) if(@!rename($f, $path . "sitemap.xml.gz")) $res = false;
143
+
144
+
145
+ delete_option("sm_status");
146
+
147
+ return $res;
148
  }
149
 
150
  /**
sitemap.php.original CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  /*
4
- $Id: sitemap.php 809744 2013-11-24 18:44:57Z arnee $
5
 
6
  Google XML Sitemaps Generator for WordPress
7
  ==============================================================================
@@ -25,7 +25,7 @@
25
  Plugin Name: Google XML Sitemaps
26
  Plugin URI: http://www.arnebrachhold.de/redir/sitemap-home/
27
  Description: This plugin will generate a special XML sitemap which will help search engines like Google, Yahoo, Bing and Ask.com to better index your blog.
28
- Version: 3.4
29
  Author: Arne Brachhold
30
  Author URI: http://www.arnebrachhold.de/
31
  Text Domain: sitemap
@@ -96,6 +96,55 @@ class GoogleSitemapGeneratorLoader {
96
  if(!empty($_GET["sm_ping_service"])) {
97
  GoogleSitemapGeneratorLoader::CallShowPingResult();
98
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
  }
100
 
101
  /**
1
  <?php
2
 
3
  /*
4
+ $Id: sitemap.php 890782 2014-04-10 19:16:31Z arnee $
5
 
6
  Google XML Sitemaps Generator for WordPress
7
  ==============================================================================
25
  Plugin Name: Google XML Sitemaps
26
  Plugin URI: http://www.arnebrachhold.de/redir/sitemap-home/
27
  Description: This plugin will generate a special XML sitemap which will help search engines like Google, Yahoo, Bing and Ask.com to better index your blog.
28
+ Version: 3.4.1
29
  Author: Arne Brachhold
30
  Author URI: http://www.arnebrachhold.de/
31
  Text Domain: sitemap
96
  if(!empty($_GET["sm_ping_service"])) {
97
  GoogleSitemapGeneratorLoader::CallShowPingResult();
98
  }
99
+
100
+ //If somebody had v4 installed and downgraded, delete rewrite rules and rename backup sitemaps back if available.
101
+ if (get_option("sm_rewrite_done", false)) {
102
+ add_action('wp_loaded', array(__CLASS__, 'DeleteV4Rewrite'), 9999, 1);
103
+ }
104
+ }
105
+
106
+
107
+ /**
108
+ * Returns the path to the WordPress root directory
109
+ *
110
+ * @return string
111
+ */
112
+ static function GetHomePath() {
113
+ $home = get_option( 'home' );
114
+ $siteurl = get_option( 'siteurl' );
115
+ if ( ! empty( $home ) && 0 !== strcasecmp( $home, $siteurl ) ) {
116
+ $wp_path_rel_to_home = str_ireplace( $home, '', $siteurl ); /* $siteurl - $home */
117
+ $pos = strripos( str_replace( '\\', '/', $_SERVER['SCRIPT_FILENAME'] ), trailingslashit( $wp_path_rel_to_home ) );
118
+ $home_path = substr( $_SERVER['SCRIPT_FILENAME'], 0, $pos );
119
+ $home_path = trailingslashit( $home_path );
120
+ } else {
121
+ $home_path = ABSPATH;
122
+ }
123
+
124
+ return str_replace( '\\', '/', $home_path );
125
+ }
126
+
127
+ /**
128
+ * Deleted rewrite rules of v4 plugin and tried to rename the backup sitemap files back if available.
129
+ *
130
+ * @return bool
131
+ */
132
+ public static function DeleteV4Rewrite() {
133
+ global $wp_rewrite;
134
+ $wp_rewrite->flush_rules(false);
135
+ delete_option("sm_rewrite_done");
136
+
137
+ $path = @trailingslashit(self::GetHomePath());
138
+
139
+ $res = true;
140
+
141
+ if(@file_exists($f = $path . "sitemap.backup.xml")) if(@!rename($f, $path . "sitemap.xml")) $res = false;
142
+ if(@file_exists($f = $path . "sitemap.backup.xml.gz")) if(@!rename($f, $path . "sitemap.xml.gz")) $res = false;
143
+
144
+
145
+ delete_option("sm_status");
146
+
147
+ return $res;
148
  }
149
 
150
  /**