From d7c87c12899e8c2eb74c493cee15b208aa90e6fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Fri, 4 Dec 2020 07:57:55 +0100 Subject: [PATCH 1/3] Some descriptive text :) I just woke up and saw the new release. --- src/DetectSitemapsURLs.php | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/DetectSitemapsURLs.php b/src/DetectSitemapsURLs.php index 9a90f60cb..449732876 100644 --- a/src/DetectSitemapsURLs.php +++ b/src/DetectSitemapsURLs.php @@ -20,7 +20,7 @@ public static function detect( string $wp_site_url ) : array { $parser = new SitemapParser( 'WP2Static.com', [ 'strict' => false ] ); $request = new Request(); $response = $request->getResponseCode( $wp_site_url . 'robots.txt' ); - $robots_exits = $response === 200 ? true : false; + $robots_exits = $response === 200; try { $sitemaps = []; @@ -32,7 +32,7 @@ public static function detect( string $wp_site_url ) : array { } // if no sitemaps add known sitemaps - if ( count( $sitemaps ) === 0 ) { + if ( $sitemaps === [] ) { $sitemaps = [ // we're assigning empty arrays to match sitemaps library $wp_site_url . 'sitemap.xml' => [], // normal sitemap @@ -42,7 +42,7 @@ public static function detect( string $wp_site_url ) : array { } // TODO: a more elegant mapping - foreach ( $sitemaps as $sitemap => $unused ) { + foreach ( array_keys( $sitemaps ) as $sitemap ) { if ( ! is_string( $sitemap ) ) { continue; } @@ -61,20 +61,16 @@ public static function detect( string $wp_site_url ) : array { $extract_sitemaps = $parser->getSitemaps(); foreach ( $extract_sitemaps as $url => $tags ) { - $sitemap_url = str_replace( + $sitemaps_urls[] = '/' . str_replace( $wp_site_url, '', $url ); - - $sitemaps_urls[] = '/' . $sitemap_url; } } } } catch ( SitemapParserException $e ) { - WsLog::l( - $e->getMessage() - ); + WsLog::l( $e->getMessage() ); throw new WP2StaticException( $e->getMessage(), 0, $e ); } From 524e04324d73fbce6e3fde68d20a39e8a4672eab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Fri, 4 Dec 2020 08:11:39 +0100 Subject: [PATCH 2/3] Allow minor PHP upgrades in CI --- .github/workflows/codequality.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/codequality.yml b/.github/workflows/codequality.yml index ec4cd55ce..88360a34d 100644 --- a/.github/workflows/codequality.yml +++ b/.github/workflows/codequality.yml @@ -15,7 +15,7 @@ jobs: strategy: matrix: - php: [7.3.25, 7.4.13] + php: ["7.3", "7.4"] name: PHP-${{ matrix.php }} @@ -43,4 +43,4 @@ jobs: run: composer install --no-interaction - name: Run our Linter and PHPStan - run: composer test + run: composer run-script test From 2d078cf64ca6ab6407ff7d7fc697766ae96da746 Mon Sep 17 00:00:00 2001 From: Leon Date: Fri, 4 Dec 2020 22:51:40 +1100 Subject: [PATCH 3/3] improve version checking --- CHANGELOG.md | 4 ++++ src/ViewRenderer.php | 2 +- wp2static.php | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f4848485..44c4f3a97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## WP2Static 7.1.6 + + - code quality improvements (thanks @szepeviktor) + ## WP2Static 7.1.5 - fix PHP version check to 7.3>= diff --git a/src/ViewRenderer.php b/src/ViewRenderer.php index 251c529cd..7294bf7c5 100644 --- a/src/ViewRenderer.php +++ b/src/ViewRenderer.php @@ -32,7 +32,7 @@ public static function renderDiagnosticsPage() : void { $view['memoryLimit'] = ini_get( 'memory_limit' ); $view['coreOptions'] = CoreOptions::getAll(); $view['site_info'] = SiteInfo::getAllInfo(); - $view['phpOutOfDate'] = PHP_VERSION < 7.3; + $view['phpOutOfDate'] = version_compare( PHP_VERSION, '7.3', '<' ); $view['uploadsWritable'] = SiteInfo::isUploadsWritable(); $view['maxExecutionTime'] = ini_get( 'max_execution_time' ); $view['curlSupported'] = SiteInfo::hasCURLSupport(); diff --git a/wp2static.php b/wp2static.php index d15efe321..b9d8525e6 100755 --- a/wp2static.php +++ b/wp2static.php @@ -3,7 +3,7 @@ * Plugin Name: WP2Static * Plugin URI: https://wp2static.com * Description: Static site generator functionality for WordPress. - * Version: 7.1.5-dev + * Version: 7.1.6-dev * Author: WP2Static * Author URI: https://wp2static.com * Text Domain: wp2static @@ -15,7 +15,7 @@ die; } -define( 'WP2STATIC_VERSION', '7.1.5-dev' ); +define( 'WP2STATIC_VERSION', '7.1.6-dev' ); define( 'WP2STATIC_PATH', plugin_dir_path( __FILE__ ) ); if ( file_exists( WP2STATIC_PATH . 'vendor/autoload.php' ) ) {