diff --git a/.github/workflows/behat-test.yml b/.github/workflows/behat-test.yml
index de9b8c633..4f045338f 100644
--- a/.github/workflows/behat-test.yml
+++ b/.github/workflows/behat-test.yml
@@ -60,8 +60,6 @@ jobs:
fail-fast: true
matrix:
php:
- - '7.2'
- - '7.3'
- '7.4'
- '8.0'
- '8.1'
@@ -70,7 +68,7 @@ jobs:
- php: '8.2'
wordpress: 'latest'
coverage: true
- - php: '7.2'
+ - php: '7.4'
wordpress: '6.3'
- php: '8.3'
wordpress: 'trunk'
@@ -157,7 +155,7 @@ jobs:
- name: Upload code coverage report
if: ${{ matrix.coverage }}
- uses: codecov/codecov-action@v4.6.0
+ uses: codecov/codecov-action@v5.0.2
with:
files: ${{ steps.coverage_files.outputs.files }}
flags: feature
diff --git a/.github/workflows/php-test.yml b/.github/workflows/php-test.yml
index bb7d48eec..42aaefff9 100644
--- a/.github/workflows/php-test.yml
+++ b/.github/workflows/php-test.yml
@@ -48,13 +48,12 @@ jobs:
fail-fast: true
matrix:
php:
- - '7.3'
- '7.4'
- '8.0'
- '8.1'
wordpress: [ 'latest' ]
include:
- - php: '7.2'
+ - php: '7.4'
wordpress: '6.3'
- php: '8.2'
wordpress: 'latest'
@@ -101,7 +100,7 @@ jobs:
- name: Upload code coverage report
if: ${{ matrix.coverage }}
- uses: codecov/codecov-action@68708a9f7a6b6b5fe33673f782f93725c5eff3c6
+ uses: codecov/codecov-action@5c47607acb93fed5485fdbf7232e8a31425f672a
with:
file: build/logs/*.xml
flags: unit
@@ -115,8 +114,6 @@ jobs:
fail-fast: true
matrix:
php:
- - '7.2'
- - '7.3'
- '7.4'
- '8.0'
- '8.1'
@@ -149,7 +146,7 @@ jobs:
- name: Upload code coverage report
if: ${{ matrix.coverage }}
- uses: codecov/codecov-action@68708a9f7a6b6b5fe33673f782f93725c5eff3c6
+ uses: codecov/codecov-action@5c47607acb93fed5485fdbf7232e8a31425f672a
with:
file: build/logs/*.xml
flags: phpcs-sniffs
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 41a9bd898..f6ec40341 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -7,7 +7,7 @@ Thank you for your interest in contributing to the Plugin Check plugin!
In general, all code must follow the [WordPress Coding Standards and best practices](https://developer.wordpress.org/coding-standards/). All code in the Plugin Check plugin must follow these requirements:
- **WordPress**: The plugin's minimum WordPress version requirement is 6.3.
-- **PHP**: Always match the latest WordPress version. The minimum required version right now is 7.2.24.
+- **PHP**: The minimum required version right now is 7.4.
## Guidelines
diff --git a/composer.json b/composer.json
index e654e06db..d23f2c8a7 100644
--- a/composer.json
+++ b/composer.json
@@ -4,7 +4,7 @@
"license": "GPL-2.0-or-later",
"type": "wordpress-plugin",
"require": {
- "php": ">=7.2.24",
+ "php": ">=7.4",
"ext-json": "*",
"afragen/wordpress-plugin-readme-parser": "dev-master#67fba498d0b112acf84386b95e4905c539a33f0b",
"automattic/vipwpcs": "^3.0.0",
@@ -56,7 +56,7 @@
"phpstan/extension-installer": true
},
"platform": {
- "php": "7.2.24"
+ "php": "7.4"
}
},
"scripts": {
diff --git a/composer.lock b/composer.lock
index f90aa24b8..2a01919ba 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "e1f6b4abdc63a16d7d5a7609f6df578a",
+ "content-hash": "3aab6089bbe13e7a4c81438da8f72ad6",
"packages": [
{
"name": "afragen/wordpress-plugin-readme-parser",
@@ -6489,12 +6489,12 @@
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
- "php": ">=7.2.24",
+ "php": ">=7.4",
"ext-json": "*"
},
"platform-dev": [],
"platform-overrides": {
- "php": "7.2.24"
+ "php": "7.4"
},
"plugin-api-version": "2.6.0"
}
diff --git a/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php b/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php
index c08e955b8..cf181fa03 100644
--- a/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php
+++ b/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php
@@ -137,7 +137,8 @@ class Trademarks_Check extends Abstract_File_Check {
'wordpress',
'wordpess',
'wpress',
- 'wp-',
+ 'wp', // it's allowed, but shows a warning.
+ 'wc', // it's allowed, but shows a warning.
'wp-mail-smtp-',
'yandex-',
'yahoo-',
@@ -146,6 +147,18 @@ class Trademarks_Check extends Abstract_File_Check {
'you-tube-',
);
+ /**
+ * Lists of allowed acronyms of trademarks.
+ *
+ * @since 1.3.0
+ *
+ * @var string[]
+ */
+ const ALLOWED_ACRONYMS = array(
+ 'wp',
+ 'wc',
+ );
+
/**
* Lists of trademarks that are allowed as 'for-whatever' ONLY.
*
@@ -348,6 +361,17 @@ private function validate_name_has_no_trademarks( $plugin_name ) {
esc_html( $plugin_name ),
esc_html( trim( $check, '-' ) )
);
+ } elseif (
+ trim( $check, '-' ) === $check
+ && in_array( $check, self::ALLOWED_ACRONYMS, true )
+ ) {
+ // Trademarks that are allowed to use as an acronym.
+ $message = sprintf(
+ /* translators: 1: plugin slug, 2: found trademarked term */
+ __( 'The plugin name includes a restricted term. Your plugin name - "%1$s" - contains the restricted term "%2$s" which can be used , as long as you don\'t change it to the full name. For example: You can use WP but not WordPress.', 'plugin-check' ),
+ esc_html( $plugin_name ),
+ esc_html( trim( $check, '-' ) )
+ );
} elseif ( trim( $check, '-' ) === $check ) {
// Trademarks that do NOT end in "-" indicate slug cannot contain term at all.
$message = sprintf(
@@ -395,6 +419,17 @@ private function validate_slug_has_no_trademarks( $plugin_slug ) {
esc_html( $plugin_slug ),
esc_html( trim( $check, '-' ) )
);
+ } elseif (
+ trim( $check, '-' ) === $check
+ && in_array( $check, self::ALLOWED_ACRONYMS, true )
+ ) {
+ // Trademarks that are allowed to use with Acronym.
+ $message = sprintf(
+ /* translators: 1: plugin slug, 2: found trademarked term */
+ __( 'The plugin slug includes a restricted term. Your plugin slug - "%1$s" - contains the restricted term "%2$s" which can be used within the plugin slug, as long as you don\'t use the full name in the plugin name. For example: You can use WP but not WordPress.', 'plugin-check' ),
+ esc_html( $plugin_slug ),
+ esc_html( trim( $check, '-' ) )
+ );
} elseif ( trim( $check, '-' ) === $check ) {
// Trademarks that do NOT end in "-" indicate slug cannot contain term at all.
$message = sprintf(
diff --git a/includes/Checker/Checks/Security/Late_Escaping_Check.php b/includes/Checker/Checks/Security/Late_Escaping_Check.php
index c7a7df995..61eab021e 100644
--- a/includes/Checker/Checks/Security/Late_Escaping_Check.php
+++ b/includes/Checker/Checks/Security/Late_Escaping_Check.php
@@ -78,4 +78,41 @@ public function get_description(): string {
public function get_documentation_url(): string {
return __( 'https://developer.wordpress.org/apis/security/escaping/', 'plugin-check' );
}
+
+ /**
+ * Amends the given result with a message for the specified file, including error information.
+ *
+ * @since 1.3.0
+ *
+ * @param Check_Result $result The check result to amend, including the plugin context to check.
+ * @param bool $error Whether it is an error or notice.
+ * @param string $message Error message.
+ * @param string $code Error code.
+ * @param string $file Absolute path to the file where the issue was found.
+ * @param int $line The line on which the message occurred. Default is 0 (unknown line).
+ * @param int $column The column on which the message occurred. Default is 0 (unknown column).
+ * @param string $docs URL for further information about the message.
+ * @param int $severity Severity level. Default is 5.
+ */
+ protected function add_result_message_for_file( Check_Result $result, $error, $message, $code, $file, $line = 0, $column = 0, string $docs = '', $severity = 5 ) {
+ switch ( $code ) {
+ case 'WordPress.Security.EscapeOutput.OutputNotEscaped':
+ $docs = __( 'https://developer.wordpress.org/apis/security/escaping/#escaping-functions', 'plugin-check' );
+ break;
+
+ case 'WordPress.Security.EscapeOutput.UnsafePrintingFunction':
+ $docs = __( 'https://developer.wordpress.org/apis/security/escaping/#escaping-with-localization', 'plugin-check' );
+ break;
+
+ case 'WordPress.Security.EscapeOutput.UnsafeSearchQuery':
+ $docs = __( 'https://developer.wordpress.org/reference/functions/get_search_query/', 'plugin-check' );
+ break;
+
+ default:
+ $docs = __( 'https://developer.wordpress.org/apis/security/escaping/', 'plugin-check' );
+ break;
+ }
+
+ parent::add_result_message_for_file( $result, $error, $message, $code, $file, $line, $column, $docs, $severity );
+ }
}
diff --git a/package-lock.json b/package-lock.json
index cef620567..d32c52aa6 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -8,8 +8,8 @@
"hasInstallScript": true,
"license": "GPL-2.0-or-later",
"devDependencies": {
- "@wordpress/env": "^10.11.0",
- "@wordpress/scripts": "^30.4.0",
+ "@wordpress/env": "^10.12.0",
+ "@wordpress/scripts": "^30.5.1",
"gherkin-lint": "^4.2.4",
"patch-package": "^8.0.0"
},
@@ -4448,10 +4448,11 @@
}
},
"node_modules/@wordpress/env": {
- "version": "10.11.0",
- "resolved": "https://registry.npmjs.org/@wordpress/env/-/env-10.11.0.tgz",
- "integrity": "sha512-Sd31oiYxy9/pNMfYw7XgtCBoD4PpvcK1UQ/FVFP+DsTTuo55Ma4UAHMKfg2NhnZWqhJTgPC6XXzicGpr/lK4RQ==",
+ "version": "10.12.0",
+ "resolved": "https://registry.npmjs.org/@wordpress/env/-/env-10.12.0.tgz",
+ "integrity": "sha512-+tsdVfngQYcysxdVonXRSwuJjqoqTSv7wwrcThCYXR1OBCMQ/xT2Ywfvf9a/yItJs5uicO9Vx8B5aIuvXiGVqg==",
"dev": true,
+ "license": "GPL-2.0-or-later",
"dependencies": {
"chalk": "^4.0.0",
"copy-dir": "^1.3.0",
@@ -4639,9 +4640,9 @@
}
},
"node_modules/@wordpress/scripts": {
- "version": "30.4.0",
- "resolved": "https://registry.npmjs.org/@wordpress/scripts/-/scripts-30.4.0.tgz",
- "integrity": "sha512-hAX8XB8hWlxAyktT4KkBpGttRwSynmtkpLvbVKeKnj+BjABFs4TGb/HCF9hFpUK3huCAg8Ft/sjjczW+5tqspQ==",
+ "version": "30.5.1",
+ "resolved": "https://registry.npmjs.org/@wordpress/scripts/-/scripts-30.5.1.tgz",
+ "integrity": "sha512-VM5NViNfdQR69MWxLnptB8svvnrEV+oUVgWL8icsLdCt2CENgPwUIk/Gs0wzeAVK05cGjrCESapJnEgIXp5lzA==",
"dev": true,
"dependencies": {
"@babel/core": "7.25.7",
@@ -4686,7 +4687,6 @@
"npm-package-json-lint": "^6.4.0",
"npm-packlist": "^3.0.0",
"postcss": "^8.4.5",
- "postcss-import": "^16.1.0",
"postcss-loader": "^6.2.1",
"prettier": "npm:wp-prettier@3.0.3",
"puppeteer-core": "^23.1.0",
@@ -14777,23 +14777,6 @@
"postcss": "^8.4.31"
}
},
- "node_modules/postcss-import": {
- "version": "16.1.0",
- "resolved": "https://registry.npmjs.org/postcss-import/-/postcss-import-16.1.0.tgz",
- "integrity": "sha512-7hsAZ4xGXl4MW+OKEWCnF6T5jqBw80/EE9aXg1r2yyn1RsVEU8EtKXbijEODa+rg7iih4bKf7vlvTGYR4CnPNg==",
- "dev": true,
- "dependencies": {
- "postcss-value-parser": "^4.0.0",
- "read-cache": "^1.0.0",
- "resolve": "^1.1.7"
- },
- "engines": {
- "node": ">=18.0.0"
- },
- "peerDependencies": {
- "postcss": "^8.0.0"
- }
- },
"node_modules/postcss-loader": {
"version": "6.2.1",
"resolved": "https://registry.npmjs.org/postcss-loader/-/postcss-loader-6.2.1.tgz",
@@ -15771,24 +15754,6 @@
"node": ">=0.10.0"
}
},
- "node_modules/read-cache": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz",
- "integrity": "sha512-Owdv/Ft7IjOgm/i0xvNDZ1LrRANRfew4b2prF3OWMQLxLfu3bS8FVhCsrSCMK4lR56Y9ya+AThoTpDCTxCmpRA==",
- "dev": true,
- "dependencies": {
- "pify": "^2.3.0"
- }
- },
- "node_modules/read-cache/node_modules/pify": {
- "version": "2.3.0",
- "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
- "integrity": "sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==",
- "dev": true,
- "engines": {
- "node": ">=0.10.0"
- }
- },
"node_modules/read-pkg": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-5.2.0.tgz",
@@ -22941,9 +22906,9 @@
}
},
"@wordpress/env": {
- "version": "10.11.0",
- "resolved": "https://registry.npmjs.org/@wordpress/env/-/env-10.11.0.tgz",
- "integrity": "sha512-Sd31oiYxy9/pNMfYw7XgtCBoD4PpvcK1UQ/FVFP+DsTTuo55Ma4UAHMKfg2NhnZWqhJTgPC6XXzicGpr/lK4RQ==",
+ "version": "10.12.0",
+ "resolved": "https://registry.npmjs.org/@wordpress/env/-/env-10.12.0.tgz",
+ "integrity": "sha512-+tsdVfngQYcysxdVonXRSwuJjqoqTSv7wwrcThCYXR1OBCMQ/xT2Ywfvf9a/yItJs5uicO9Vx8B5aIuvXiGVqg==",
"dev": true,
"requires": {
"chalk": "^4.0.0",
@@ -23060,9 +23025,9 @@
"requires": {}
},
"@wordpress/scripts": {
- "version": "30.4.0",
- "resolved": "https://registry.npmjs.org/@wordpress/scripts/-/scripts-30.4.0.tgz",
- "integrity": "sha512-hAX8XB8hWlxAyktT4KkBpGttRwSynmtkpLvbVKeKnj+BjABFs4TGb/HCF9hFpUK3huCAg8Ft/sjjczW+5tqspQ==",
+ "version": "30.5.1",
+ "resolved": "https://registry.npmjs.org/@wordpress/scripts/-/scripts-30.5.1.tgz",
+ "integrity": "sha512-VM5NViNfdQR69MWxLnptB8svvnrEV+oUVgWL8icsLdCt2CENgPwUIk/Gs0wzeAVK05cGjrCESapJnEgIXp5lzA==",
"dev": true,
"requires": {
"@babel/core": "7.25.7",
@@ -23107,7 +23072,6 @@
"npm-package-json-lint": "^6.4.0",
"npm-packlist": "^3.0.0",
"postcss": "^8.4.5",
- "postcss-import": "^16.1.0",
"postcss-loader": "^6.2.1",
"prettier": "npm:wp-prettier@3.0.3",
"puppeteer-core": "^23.1.0",
@@ -30491,17 +30455,6 @@
"dev": true,
"requires": {}
},
- "postcss-import": {
- "version": "16.1.0",
- "resolved": "https://registry.npmjs.org/postcss-import/-/postcss-import-16.1.0.tgz",
- "integrity": "sha512-7hsAZ4xGXl4MW+OKEWCnF6T5jqBw80/EE9aXg1r2yyn1RsVEU8EtKXbijEODa+rg7iih4bKf7vlvTGYR4CnPNg==",
- "dev": true,
- "requires": {
- "postcss-value-parser": "^4.0.0",
- "read-cache": "^1.0.0",
- "resolve": "^1.1.7"
- }
- },
"postcss-loader": {
"version": "6.2.1",
"resolved": "https://registry.npmjs.org/postcss-loader/-/postcss-loader-6.2.1.tgz",
@@ -31158,23 +31111,6 @@
"integrity": "sha512-jCvmsr+1IUSMUyzOkRcvnVbX3ZYC6g9TDrDbFuFmRDq7PD4yaGbLKNQL6k2jnArV8hjYxh7hVhAZB6s9HDGpZA==",
"dev": true
},
- "read-cache": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz",
- "integrity": "sha512-Owdv/Ft7IjOgm/i0xvNDZ1LrRANRfew4b2prF3OWMQLxLfu3bS8FVhCsrSCMK4lR56Y9ya+AThoTpDCTxCmpRA==",
- "dev": true,
- "requires": {
- "pify": "^2.3.0"
- },
- "dependencies": {
- "pify": {
- "version": "2.3.0",
- "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
- "integrity": "sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==",
- "dev": true
- }
- }
- },
"read-pkg": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-5.2.0.tgz",
diff --git a/package.json b/package.json
index e0477b1e8..4e7460cfb 100644
--- a/package.json
+++ b/package.json
@@ -10,8 +10,8 @@
"npm": ">=10.2.3"
},
"devDependencies": {
- "@wordpress/env": "^10.11.0",
- "@wordpress/scripts": "^30.4.0",
+ "@wordpress/env": "^10.12.0",
+ "@wordpress/scripts": "^30.5.1",
"gherkin-lint": "^4.2.4",
"patch-package": "^8.0.0"
},
diff --git a/patches/@wordpress+env+10.10.0.patch b/patches/@wordpress+env+10.12.0.patch
similarity index 100%
rename from patches/@wordpress+env+10.10.0.patch
rename to patches/@wordpress+env+10.12.0.patch
diff --git a/phpcs-rulesets/plugin-review.xml b/phpcs-rulesets/plugin-review.xml
index 8a78cb564..c517bab3a 100644
--- a/phpcs-rulesets/plugin-review.xml
+++ b/phpcs-rulesets/plugin-review.xml
@@ -56,6 +56,11 @@
7
+
+
+ 7
+
+
error
diff --git a/phpcs-sniffs/composer.json b/phpcs-sniffs/composer.json
index 321eea251..7258b4dba 100644
--- a/phpcs-sniffs/composer.json
+++ b/phpcs-sniffs/composer.json
@@ -16,7 +16,7 @@
}
],
"require": {
- "php": ">=7.2.24",
+ "php": ">=7.4",
"ext-libxml": "*",
"ext-tokenizer": "*",
"ext-xmlreader": "*",
@@ -38,7 +38,7 @@
"dealerdirect/phpcodesniffer-composer-installer": true
},
"platform": {
- "php": "7.2.24"
+ "php": "7.4"
}
},
"scripts": {
@@ -67,4 +67,4 @@
"lint": "Lint PHP files against parse errors.",
"run-tests": "Run all the unit tests for the Plugin Check Coding Standards sniffs."
}
-}
\ No newline at end of file
+}
diff --git a/phpcs-sniffs/composer.lock b/phpcs-sniffs/composer.lock
index 4f32ab0cb..b76221c75 100644
--- a/phpcs-sniffs/composer.lock
+++ b/phpcs-sniffs/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "e3f2033f9c52ac5eab10852c851d3007",
+ "content-hash": "49ca6c46b9685eb474d91448a1b9444f",
"packages": [
{
"name": "dealerdirect/phpcodesniffer-composer-installer",
@@ -2050,14 +2050,14 @@
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
- "php": ">=7.2.24",
+ "php": ">=7.4",
"ext-libxml": "*",
"ext-tokenizer": "*",
"ext-xmlreader": "*"
},
"platform-dev": [],
"platform-overrides": {
- "php": "7.2.24"
+ "php": "7.4"
},
"plugin-api-version": "2.6.0"
}
diff --git a/phpcs-sniffs/phpcs.xml.dist b/phpcs-sniffs/phpcs.xml.dist
index 337d86812..9f61b589c 100644
--- a/phpcs-sniffs/phpcs.xml.dist
+++ b/phpcs-sniffs/phpcs.xml.dist
@@ -37,7 +37,7 @@
-
+
diff --git a/phpcs.xml.dist b/phpcs.xml.dist
index 178470c80..436717cd8 100644
--- a/phpcs.xml.dist
+++ b/phpcs.xml.dist
@@ -3,7 +3,7 @@
Sniffs for WordPress plugins, with minor modifications for Performance
-
+
diff --git a/plugin.php b/plugin.php
index 8de444180..a905b6c3d 100644
--- a/plugin.php
+++ b/plugin.php
@@ -4,7 +4,7 @@
* Plugin URI: https://github.com/WordPress/plugin-check
* Description: Plugin Check is a WordPress.org tool which provides checks to help plugins meet the directory requirements and follow various best practices.
* Requires at least: 6.3
- * Requires PHP: 7.2.24
+ * Requires PHP: 7.4
* Version: 1.2.0
* Author: WordPress Performance Team and Plugin Review Team
* License: GPLv2 or later
@@ -17,7 +17,7 @@
use WordPress\Plugin_Check\Plugin_Main;
define( 'WP_PLUGIN_CHECK_VERSION', '1.2.0' );
-define( 'WP_PLUGIN_CHECK_MINIMUM_PHP', '7.2.24' );
+define( 'WP_PLUGIN_CHECK_MINIMUM_PHP', '7.4' );
define( 'WP_PLUGIN_CHECK_MAIN_FILE', __FILE__ );
define( 'WP_PLUGIN_CHECK_PLUGIN_DIR_PATH', plugin_dir_path( WP_PLUGIN_CHECK_MAIN_FILE ) );
define( 'WP_PLUGIN_CHECK_PLUGIN_DIR_URL', plugin_dir_url( WP_PLUGIN_CHECK_MAIN_FILE ) );
diff --git a/tests/phpunit/testdata/plugins/test-plugin-review-phpcs-errors/load.php b/tests/phpunit/testdata/plugins/test-plugin-review-phpcs-errors/load.php
index d069d1b81..32e42dc30 100644
--- a/tests/phpunit/testdata/plugins/test-plugin-review-phpcs-errors/load.php
+++ b/tests/phpunit/testdata/plugins/test-plugin-review-phpcs-errors/load.php
@@ -26,3 +26,10 @@
wp_reset_query();
parse_str( 'first=value&arr[]=foo+bar&arr[]=baz' );
+
+$str = <<assertArrayHasKey( 'code', $errors['load.php'][6][1][0] );
$this->assertEquals( 'Generic.PHP.DisallowShortOpenTag.Found', $errors['load.php'][6][1][0]['code'] );
+ // Check for Squiz.PHP.Heredoc.NotAllowed error on Line no 28 and column no at 8.
+ $this->assertEquals( 'Squiz.PHP.Heredoc.NotAllowed', $errors['load.php'][28][8][0]['code'] );
+
// Check for WordPress.WP.DeprecatedFunctions.the_author_emailFound error on Line no 12 and column no at 5.
$this->assertArrayHasKey( 12, $errors['load.php'] );
$this->assertArrayHasKey( 5, $errors['load.php'][12] );
diff --git a/tests/phpunit/tests/Checker/Checks/Trademarks_Check_Tests.php b/tests/phpunit/tests/Checker/Checks/Trademarks_Check_Tests.php
index 0f0a95a64..1470b2d3b 100644
--- a/tests/phpunit/tests/Checker/Checks/Trademarks_Check_Tests.php
+++ b/tests/phpunit/tests/Checker/Checks/Trademarks_Check_Tests.php
@@ -75,6 +75,12 @@ public function data_trademarks_check() {
'load.php',
'The plugin name includes a restricted term. Your chosen plugin name - "WooCommerce Example String" - contains the restricted term "woocommerce" which cannot be used within in your plugin name, unless your plugin name ends with "for woocommerce". The term must still not appear anywhere else in your name.',
),
+ 'Plugin headers - WP Example String' => array(
+ Trademarks_Check::TYPE_NAME,
+ 'test-trademarks-plugin-header-acronym/load.php',
+ 'load.php',
+ 'The plugin name includes a restricted term. Your plugin name - "WP Example String" - contains the restricted term "wp" which can be used , as long as you don\'t change it to the full name. For example: You can use WP but not WordPress.',
+ ),
'Plugin headers - WooCommerce String for WooCommerce' => array(
Trademarks_Check::TYPE_NAME,
'test-trademarks-plugin-header-woocommerce-string-for-woocommerce/load.php',
diff --git a/tests/phpunit/tests/Checker/Preparations/Universal_Runtime_Preparation_Tests.php b/tests/phpunit/tests/Checker/Preparations/Universal_Runtime_Preparation_Tests.php
index c805b0e21..0cd416c96 100644
--- a/tests/phpunit/tests/Checker/Preparations/Universal_Runtime_Preparation_Tests.php
+++ b/tests/phpunit/tests/Checker/Preparations/Universal_Runtime_Preparation_Tests.php
@@ -9,16 +9,43 @@
use WordPress\Plugin_Check\Checker\Check_Context;
use WordPress\Plugin_Check\Checker\Preparations\Universal_Runtime_Preparation;
+use WordPress\Plugin_Check\Checker\Runtime_Environment_Setup;
use WP_UnitTestCase;
class Universal_Runtime_Preparation_Tests extends WP_UnitTestCase {
+ /**
+ * Storage for preparation cleanups that need to be run after a test.
+ *
+ * @var array
+ */
+ private $cleanups = array();
+
+ public function tear_down() {
+ if ( count( $this->cleanups ) > 0 ) {
+ $this->cleanups = array_reverse( $this->cleanups );
+ foreach ( $this->cleanups as $cleanup ) {
+ $cleanup();
+ }
+ $this->cleanups = array();
+ }
+ parent::tear_down();
+ }
+
public function test_prepare() {
$check_context = new Check_Context( plugin_basename( WP_PLUGIN_CHECK_MAIN_FILE ) );
+ // The runtime environment must be prepared manually before regular runtime preparations.
+ $runtime = new Runtime_Environment_Setup();
+ $runtime->set_up();
+ $this->cleanups[] = function () use ( $runtime ) {
+ $runtime->clean_up();
+ };
+
$universal_runtime_preparation = new Universal_Runtime_Preparation( $check_context );
- $cleanup = $universal_runtime_preparation->prepare();
+ $cleanup = $universal_runtime_preparation->prepare();
+ $this->cleanups[] = $cleanup;
$this->assertTrue( has_filter( 'option_active_plugins' ) );
$this->assertTrue( has_filter( 'default_option_active_plugins' ) );
@@ -32,6 +59,9 @@ public function test_prepare() {
$cleanup();
+ // If this is reached, the universal runtime preparation cleanup was already done, so we can remove it again.
+ array_pop( $this->cleanups );
+
$this->assertFalse( has_filter( 'option_active_plugins' ) );
$this->assertFalse( has_filter( 'default_option_active_plugins' ) );
$this->assertFalse( has_filter( 'stylesheet' ) );
diff --git a/tests/phpunit/tests/Utilities/Plugin_Request_Utility_Tests.php b/tests/phpunit/tests/Utilities/Plugin_Request_Utility_Tests.php
index fc760ca26..80a36513d 100644
--- a/tests/phpunit/tests/Utilities/Plugin_Request_Utility_Tests.php
+++ b/tests/phpunit/tests/Utilities/Plugin_Request_Utility_Tests.php
@@ -11,6 +11,7 @@
use WordPress\Plugin_Check\Checker\Checks;
use WordPress\Plugin_Check\Checker\Checks\General\I18n_Usage_Check;
use WordPress\Plugin_Check\Checker\CLI_Runner;
+use WordPress\Plugin_Check\Checker\Runtime_Environment_Setup;
use WordPress\Plugin_Check\Test_Data\Runtime_Check;
use WordPress\Plugin_Check\Test_Utils\Traits\With_Mock_Filesystem;
use WordPress\Plugin_Check\Utilities\Plugin_Request_Utility;
@@ -90,6 +91,16 @@ public function test_initialize_runner_with_ajax() {
$_REQUEST['action'] = 'plugin_check_run_checks';
$_REQUEST['plugin'] = 'plugin-check';
+ /*
+ * The runtime environment must be prepared manually before regular runtime preparations.
+ * This is necessary because in reality it happens in a separate AJAX request before.
+ */
+ $runtime = new Runtime_Environment_Setup();
+ $runtime->set_up();
+ $this->cleanups[] = function () use ( $runtime ) {
+ $runtime->clean_up();
+ };
+
Plugin_Request_Utility::initialize_runner();
$this->cleanups[] = function () {
Plugin_Request_Utility::destroy_runner();
@@ -109,7 +120,7 @@ public function test_initialize_runner_with_ajax() {
public function test_destroy_runner_with_cli() {
define( 'WP_CLI', true );
- global $wpdb, $table_prefix, $wp_actions;
+ global $wp_actions;
$this->set_up_mock_filesystem();
@@ -151,7 +162,6 @@ function ( $checks ) {
unset( $_SERVER['argv'] );
$wp_actions['muplugins_loaded'] = $muplugins_loaded;
- $wpdb->set_prefix( $table_prefix );
$this->assertTrue( $prepared );
$this->assertTrue( $cleanup );
@@ -159,7 +169,7 @@ function ( $checks ) {
}
public function test_destroy_runner_with_ajax() {
- global $wpdb, $table_prefix, $wp_actions;
+ global $wp_actions;
$this->set_up_mock_filesystem();
@@ -168,6 +178,16 @@ public function test_destroy_runner_with_ajax() {
$_REQUEST['plugin'] = 'plugin-check';
$_REQUEST['checks'] = array( 'runtime_check' );
+ /*
+ * The runtime environment must be prepared manually before regular runtime preparations.
+ * This is necessary because in reality it happens in a separate AJAX request before.
+ */
+ $runtime = new Runtime_Environment_Setup();
+ $runtime->set_up();
+ $this->cleanups[] = function () use ( $runtime ) {
+ $runtime->clean_up();
+ };
+
add_filter(
'wp_plugin_check_checks',
function ( $checks ) {
@@ -196,7 +216,6 @@ function ( $checks ) {
$cleanup = ! has_filter( 'option_active_plugins' );
$runner = Plugin_Request_Utility::get_runner();
- $wpdb->set_prefix( $table_prefix );
$wp_actions['muplugins_loaded'] = $muplugins_loaded;
$this->assertTrue( $prepared );