From 9c6b74a2c3cc43cbc0c9193862a8aaac719360b4 Mon Sep 17 00:00:00 2001 From: Fahim Murshed Date: Mon, 20 Jul 2026 20:41:25 +0600 Subject: [PATCH] Updated WordPress 7.0 * Fix: Ensure standard translation checks (I18N) are not bypassed when Polylang functions are present in the same file. * Fix: Target the theme's main style.css file for header checks rather than parsing combined CSS text. * Update: Verified compatibility with PHP 8.5+. * Tested with WordPress 7.0.2 --- changelog.txt | 6 +++++ checks/class-i18n-check.php | 8 ++++--- checks/class-style-css-header-check.php | 31 ++++++++++++++++++++++++- readme.txt | 6 ++--- theme-check.php | 2 +- 5 files changed, 45 insertions(+), 8 deletions(-) diff --git a/changelog.txt b/changelog.txt index ab0be913..11551c30 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,9 @@ += 20260720 = + * Fix: Ensure standard translation checks (I18N) are not bypassed when Polylang functions are present in the same file. + * Fix: Target the theme's main style.css file for header checks rather than parsing combined CSS text. + * Update: Verified compatibility with PHP 8.5+. + * Tested with WordPress 7.0.2 + = 20260508 = * Tested with WordPress 6.9 diff --git a/checks/class-i18n-check.php b/checks/class-i18n-check.php index 158deed3..52725faf 100644 --- a/checks/class-i18n-check.php +++ b/checks/class-i18n-check.php @@ -36,9 +36,11 @@ public function check( $php_files, $css_files, $other_files ) { $stmts = array(); foreach ( array( '_e(', '__(', '_e (', '__ (' ) as $finder ) { $search = $phpfile; - while ( ( $pos = strpos( $search, $finder ) ) !== false && - strpos( $search, 'pll__' ) === false && - strpos( $search, 'pll_e' ) === false ) { + while ( ( $pos = strpos( $search, $finder ) ) !== false ) { + if ( $pos >= 3 && substr( $search, $pos - 3, 3 ) === 'pll' ) { + $search = substr( $search, $pos + strlen( $finder ) ); + continue; + } $search = substr( $search, $pos ); $open = 1; $i = strpos( $search, '(' ) + 1; diff --git a/checks/class-style-css-header-check.php b/checks/class-style-css-header-check.php index e112a797..a551ea86 100644 --- a/checks/class-style-css-header-check.php +++ b/checks/class-style-css-header-check.php @@ -25,7 +25,36 @@ class Style_CSS_Header_Check implements themecheck { */ public function check( $php_files, $css_files, $other_files ) { - $css = implode( ' ', $css_files ); + $css = ''; + global $theme_check_current_theme; + if ( $theme_check_current_theme ) { + $style_css_path = function_exists( 'wp_normalize_path' ) + ? wp_normalize_path( $theme_check_current_theme->get_stylesheet_directory() . '/style.css' ) + : $theme_check_current_theme->get_stylesheet_directory() . '/style.css'; + + foreach ( $css_files as $path => $content ) { + $normalized_path = function_exists( 'wp_normalize_path' ) ? wp_normalize_path( $path ) : $path; + if ( $normalized_path === $style_css_path ) { + $css = $content; + break; + } + } + } + + if ( empty( $css ) ) { + // Fallback: look for a file named style.css. + foreach ( $css_files as $path => $content ) { + if ( basename( $path ) === 'style.css' ) { + $css = $content; + break; + } + } + } + + if ( empty( $css ) ) { + // Ultimate fallback: implode all CSS files. + $css = implode( ' ', $css_files ); + } $ret = true; $checks = array( diff --git a/readme.txt b/readme.txt index 2b667141..4c2be57f 100644 --- a/readme.txt +++ b/readme.txt @@ -1,9 +1,9 @@ === Theme Check === -Contributors: Otto42, pross, poena, dingo-d, acosmin, kafleg, joyously +Contributors: Otto42, pross, poena, dingo-d, acosmin, kafleg, joyously, fahimmurshed Requires at Least: 3.7 -Tested Up To: 7.0 +Tested Up To: 7.0.2 Tags: themes, guidelines, wordpress.org -Stable tag: 20260508 +Stable tag: 20260720 A simple and easy way to test your theme for all the latest WordPress standards and practices. A great theme development tool! diff --git a/theme-check.php b/theme-check.php index 293e1aee..6ae0d482 100644 --- a/theme-check.php +++ b/theme-check.php @@ -4,7 +4,7 @@ * Plugin URI: https://github.com/WordPress/theme-check/ * Description: A simple and easy way to test your theme for all the latest WordPress standards and practices. A great theme development tool! * Author: Themes Team - * Version: 20260508 + * Version: 20260720 * Text Domain: theme-check * License: GPLv2 * License URI: https://www.gnu.org/licenses/gpl-2.0.html