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 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/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 ); } 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 45dac4b33..7e0dc9cf8 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 + * Version: 7.1.6 * Author: WP2Static * Author URI: https://wp2static.com * Text Domain: wp2static @@ -15,7 +15,7 @@ die; } -define( 'WP2STATIC_VERSION', '7.1.5' ); +define( 'WP2STATIC_VERSION', '7.1.6' ); define( 'WP2STATIC_PATH', plugin_dir_path( __FILE__ ) ); if ( file_exists( WP2STATIC_PATH . 'vendor/autoload.php' ) ) {