Skip to content

Commit 123bcdc

Browse files
committed
Native WP
1 parent 94bb886 commit 123bcdc

7 files changed

Lines changed: 188 additions & 16 deletions

File tree

.vscode/settings.json

Lines changed: 0 additions & 13 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
55

66
## Unreleased
77

8+
### Changed
9+
10+
- **Code Quality**: Replaced PHP-native IP validation with WordPress native IP validation for resource hint host checks
11+
812
## [2.1.0] - 2026-06-10
913

1014
### Fixed

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
"php-stubs/wordpress-stubs": "^6.9",
2727
"szepeviktor/phpstan-wordpress": "^2.0",
2828
"phpstan/phpstan": "^2.1",
29-
"phpcompatibility/phpcompatibility-wp": "^2.1"
29+
"phpcompatibility/phpcompatibility-wp": "^2.1",
30+
"automattic/vipwpcs": "^3.0.1",
31+
"z4kn4fein/php-semver": "^3.0"
3032
},
3133
"scripts": {
3234
"phpcs": "phpcs --standard=phpcs.xml",

composer.lock

Lines changed: 165 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

includes/options.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ function es_optimizer_is_disallowed_resource_hint_host( string $host ): bool {
458458
* @return bool True when the host is an IP literal.
459459
*/
460460
function es_optimizer_is_ip_literal_host( string $host ): bool {
461-
return false !== filter_var( $host, FILTER_VALIDATE_IP );
461+
return false !== rest_is_ip_address( $host );
462462
}
463463

464464
/**

readme.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ No, the plugin has a simple interface where you can toggle features on and off.
4343

4444
== Changelog ==
4545

46+
= Unreleased =
47+
* **CODE QUALITY**: Replaced PHP-native IP validation with WordPress native IP validation for resource hint host checks
48+
4649
= 2.1.0 - 2026-06-10 =
4750
* **BUG FIX**: Removed a redundant `is_array()` check in `es_optimizer_disable_emojis_tinymce()` after adding a strict `array` parameter type, resolving a PHPStan always-true warning on PHP 8.3
4851
* **BUG FIX (Critical)**: Fixed License URI pointing to GPL 2.0 instead of GPL 3.0 in plugin header and readme.txt

tests/bootstrap.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,18 @@ function wp_parse_url( string $url, ?int $component = null ): mixed {
269269
}
270270
}
271271

272+
if ( ! function_exists( 'rest_is_ip_address' ) ) {
273+
/**
274+
* Check whether a value is an IP address.
275+
*
276+
* @param string $ip IP address.
277+
* @return string|false IP address when valid; false otherwise.
278+
*/
279+
function rest_is_ip_address( string $ip ): string|false {
280+
return false !== filter_var( $ip, FILTER_VALIDATE_IP ) ? $ip : false;
281+
}
282+
}
283+
272284
if ( ! function_exists( '__' ) ) {
273285
/**
274286
* Return translated text.

0 commit comments

Comments
 (0)