@@ -20,7 +20,7 @@ public static function detect( string $wp_site_url ) : array {
2020 $ parser = new SitemapParser ( 'WP2Static.com ' , [ 'strict ' => false ] );
2121 $ request = new Request ();
2222 $ response = $ request ->getResponseCode ( $ wp_site_url . 'robots.txt ' );
23- $ robots_exits = $ response === 200 ? true : false ;
23+ $ robots_exits = $ response === 200 ;
2424
2525 try {
2626 $ sitemaps = [];
@@ -32,7 +32,7 @@ public static function detect( string $wp_site_url ) : array {
3232 }
3333
3434 // if no sitemaps add known sitemaps
35- if ( count ( $ sitemaps ) === 0 ) {
35+ if ( $ sitemaps === [] ) {
3636 $ sitemaps = [
3737 // we're assigning empty arrays to match sitemaps library
3838 $ wp_site_url . 'sitemap.xml ' => [], // normal sitemap
@@ -42,7 +42,7 @@ public static function detect( string $wp_site_url ) : array {
4242 }
4343
4444 // TODO: a more elegant mapping
45- foreach ( $ sitemaps as $ sitemap => $ unused ) {
45+ foreach ( array_keys ( $ sitemaps ) as $ sitemap ) {
4646 if ( ! is_string ( $ sitemap ) ) {
4747 continue ;
4848 }
@@ -61,20 +61,16 @@ public static function detect( string $wp_site_url ) : array {
6161 $ extract_sitemaps = $ parser ->getSitemaps ();
6262
6363 foreach ( $ extract_sitemaps as $ url => $ tags ) {
64- $ sitemap_url = str_replace (
64+ $ sitemaps_urls [] = ' / ' . str_replace (
6565 $ wp_site_url ,
6666 '' ,
6767 $ url
6868 );
69-
70- $ sitemaps_urls [] = '/ ' . $ sitemap_url ;
7169 }
7270 }
7371 }
7472 } catch ( SitemapParserException $ e ) {
75- WsLog::l (
76- $ e ->getMessage ()
77- );
73+ WsLog::l ( $ e ->getMessage () );
7874 throw new WP2StaticException ( $ e ->getMessage (), 0 , $ e );
7975 }
8076
0 commit comments