Skip to content

Commit 286376a

Browse files
authored
Release
1 parent dbe725f commit 286376a

File tree

5 files changed

+36
-42
lines changed

5 files changed

+36
-42
lines changed

CHANGELOG.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
44
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
55

66
## [Unreleased]
7+
8+
## [1.6.0] - 2025-08-10
79
### Added
810
- **Performance Optimization**: Implemented conditional admin asset loading - admin scripts and styles now only load on the plugin settings page
911
- **Option Caching System**: Added `es_optimizer_get_options()` function with static caching to reduce database queries throughout the plugin
1012
- **DNS Prefetch Security Enhancement**: Enhanced DNS prefetch validation to reject file paths, query parameters, and fragments - only clean domains are now accepted
1113
- **Documentation Enhancement**: Added @since version tags to all PHPDoc blocks for better change tracking
1214
- **Developer Guidelines**: Created comprehensive CONTRIBUTING.md file with development standards, security requirements, and contribution workflow
13-
- **Comprehensive Unit Testing**: Implemented complete testing infrastructure with PHPUnit, WP_Mock, and 80% coverage requirement
14-
- **Test Coverage**: 18 core functions with comprehensive unit and integration tests
15-
- **Security Testing**: XSS prevention, DNS validation, CSRF protection, and input sanitization validation
16-
- **Performance Testing**: Caching mechanisms, optimization effects, and conditional loading verification
17-
- **CI/CD Integration**: GitHub Actions workflow with multi-PHP version testing (7.4-8.4) and automated quality checks
1815

1916
### Enhanced
2017
- **DNS Prefetch Optimization**: Improved DNS prefetch function with static caching, duplicate removal, AJAX detection, and enhanced domain validation

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[![PHP Compatible](https://img.shields.io/badge/PHP-7.4%2B-purple.svg?logo=php)](https://www.php.net/)
77

88
## Current Version
9-
[![Version](https://img.shields.io/badge/Version-1.5.12-orange.svg?logo=github)](https://github.com/EngineScript/simple-wp-optimizer/releases/download/v1.5.12/simple-wp-optimizer-1.5.12.zip)
9+
[![Version](https://img.shields.io/badge/Version-1.6.0-orange.svg?logo=github)](https://github.com/EngineScript/simple-wp-optimizer/releases/download/v1.6.0/simple-wp-optimizer-1.6.0.zip)
1010

1111
## Description
1212

languages/simple-wp-optimizer.pot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# This file is distributed under the same license as the Simple WP Optimizer plugin.
33
msgid ""
44
msgstr ""
5-
"Project-Id-Version: Simple WP Optimizer 1.5.11\n"
5+
"Project-Id-Version: Simple WP Optimizer 1.6.0\n"
66
"Report-Msgid-Bugs-To: https://github.com/EngineScript/simple-wp-optimizer/issues\n"
77
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
88
"Language-Team: LANGUAGE <LL@li.org>\n"

readme.txt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Contributors: enginescript
33
Tags: optimization, performance, cleanup
44
Requires at least: 6.5
55
Tested up to: 6.8
6-
Stable tag: 1.5.12
6+
Stable tag: 1.6.0
77
Requires PHP: 7.4
88
License: GPLv2 or later
99
License URI: https://www.gnu.org/licenses/gpl-2.0.html
@@ -43,16 +43,12 @@ No, the plugin has a simple interface where you can toggle features on and off.
4343

4444
== Changelog ==
4545

46-
= Unreleased =
46+
= 1.6.0 =
4747
* **PERFORMANCE**: Implemented conditional admin asset loading - admin scripts and styles now only load on plugin settings page
4848
* **PERFORMANCE**: Added option caching system with `es_optimizer_get_options()` function to reduce database queries
4949
* **PERFORMANCE**: Enhanced DNS prefetch function with static caching, duplicate removal, and AJAX detection
5050
* **SECURITY**: Enhanced DNS prefetch validation to reject file paths, query parameters, and fragments - only clean domains accepted
5151
* **SECURITY**: Strengthened domain validation to prevent file path injection (e.g., `https://google.com/file.php` now rejected)
52-
* **TESTING**: Implemented comprehensive unit testing infrastructure with PHPUnit and WP_Mock
53-
* **TESTING**: Added 18 core function tests with 80% coverage requirement and security validation
54-
* **TESTING**: Created CI/CD pipeline with GitHub Actions for multi-PHP version testing (7.4-8.4)
55-
* **TESTING**: Integrated automated code quality checks with PHPCS, PHPMD, and PHPStan
5652
* **DOCUMENTATION**: Added @since version tags to all PHPDoc blocks for better change tracking
5753
* **DEVELOPER EXPERIENCE**: Created comprehensive CONTRIBUTING.md file with development standards and security requirements
5854
* **USER EXPERIENCE**: Updated DNS prefetch textarea description to clearly explain clean domain requirements

simple-wp-optimizer.php

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: Simple WP Optimizer
44
* Plugin URI: https://github.com/EngineScript/simple-wp-optimizer
55
* Description: Optimizes WordPress by removing unnecessary features and scripts to improve performance
6-
* Version: 1.5.12
6+
* Version: 1.6.0
77
* Author: EngineScript
88
* License: GPL v2 or later
99
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
@@ -53,7 +53,7 @@
5353

5454
// Define plugin version.
5555
if ( ! defined( 'ES_WP_OPTIMIZER_VERSION' ) ) {
56-
define( 'ES_WP_OPTIMIZER_VERSION', '1.5.12' );
56+
define( 'ES_WP_OPTIMIZER_VERSION', '1.6.0' );
5757
}
5858

5959
/**
@@ -132,8 +132,8 @@ function es_optimizer_get_options() {
132132
* @since 1.5.13
133133
*/
134134
function es_optimizer_clear_options_cache() {
135-
// Clear the static cache by accessing the static variable
136-
$clear_cache = function() {
135+
// Clear the static cache by accessing the static variable.
136+
$clear_cache = function () {
137137
static $cached_options = null;
138138
$cached_options = null;
139139
};
@@ -153,11 +153,12 @@ function es_optimizer_add_settings_page() {
153153
'es-optimizer-settings',
154154
'es_optimizer_settings_page'
155155
);
156-
157-
// Only load admin scripts/styles on our settings page
158-
if ( $hook ) {
159-
add_action( "load-{$hook}", 'es_optimizer_load_admin_assets' );
156+
157+
// Only load admin scripts/styles on our settings page.
158+
if ( ! is_admin() ) {
159+
return;
160160
}
161+
// Only enqueue scripts/styles if we're on the plugin settings page.
161162
}
162163
add_action( 'admin_menu', 'es_optimizer_add_settings_page' );
163164

@@ -167,7 +168,7 @@ function es_optimizer_add_settings_page() {
167168
* @since 1.5.13
168169
*/
169170
function es_optimizer_load_admin_assets() {
170-
// Only enqueue scripts/styles if we're on the plugin settings page
171+
// Only enqueue scripts/styles if we're on the plugin settings page.
171172
add_action( 'admin_enqueue_scripts', 'es_optimizer_enqueue_admin_scripts' );
172173
}
173174

@@ -177,8 +178,8 @@ function es_optimizer_load_admin_assets() {
177178
* @since 1.5.13
178179
*/
179180
function es_optimizer_enqueue_admin_scripts() {
180-
// Add any future admin CSS/JS here - currently none needed
181-
// This function is prepared for future admin styling if needed
181+
// Add any future admin CSS/JS here - currently none needed.
182+
// This function is prepared for future admin styling if needed.
182183
}
183184

184185
/**
@@ -587,9 +588,9 @@ function es_optimizer_validate_single_domain( $domain ) {
587588
);
588589
}
589590

590-
// Security: DNS prefetch should only use clean domains, not file paths
591-
// Reject URLs with paths, query parameters, or fragments
592-
if ( isset( $parsed_url['path'] ) && $parsed_url['path'] !== '/' && $parsed_url['path'] !== '' ) {
591+
// Security: DNS prefetch should only use clean domains, not file paths.
592+
// Reject URLs with paths, query parameters, or fragments.
593+
if ( isset( $parsed_url['path'] ) && '/' !== $parsed_url['path'] && '' !== $parsed_url['path'] ) {
593594
return array(
594595
'valid' => false,
595596
'error' => $domain . ' (file paths not allowed for DNS prefetch - use domain only)',
@@ -616,10 +617,10 @@ function es_optimizer_validate_single_domain( $domain ) {
616617
);
617618
}
618619

619-
// Return clean domain URL with only scheme and host (no paths)
620+
// Return clean domain URL with only scheme and host (no paths).
620621
$clean_domain = $parsed_url['scheme'] . '://' . $parsed_url['host'];
621622

622-
// Add port if specified and not default HTTPS port
623+
// Add port if specified and not default HTTPS port.
623624
if ( isset( $parsed_url['port'] ) && 443 !== $parsed_url['port'] ) {
624625
$clean_domain .= ':' . $parsed_url['port'];
625626
}
@@ -838,38 +839,38 @@ function remove_recent_comments_style() {
838839
* @since 1.4.1
839840
*/
840841
function add_dns_prefetch() {
841-
// Only add if not admin and not doing AJAX
842+
// Only add if not admin and not doing AJAX.
842843
if ( is_admin() || wp_doing_ajax() ) {
843844
return;
844845
}
845846

846-
// Use static caching to avoid repeated option retrieval
847-
static $domains_cache = null;
848-
static $options_checked = false;
847+
// Use static caching to avoid repeated option retrieval.
848+
static $domains_cache = null;
849+
static $options_checked = false;
849850

850851
if ( ! $options_checked ) {
851-
$options = get_option( 'es_optimizer_options' );
852+
$options = get_option( 'es_optimizer_options' );
852853
$options_checked = true;
853854

854-
// Only proceed if the option is enabled
855+
// Only proceed if the option is enabled.
855856
if ( ! isset( $options['enable_dns_prefetch'] ) || ! $options['enable_dns_prefetch'] ) {
856-
$domains_cache = array(); // Cache empty array to avoid re-checking
857+
$domains_cache = array(); // Cache empty array to avoid re-checking.
857858
return;
858859
}
859860

860-
// Get and process domains from settings
861+
// Get and process domains from settings.
861862
if ( isset( $options['dns_prefetch_domains'] ) && ! empty( $options['dns_prefetch_domains'] ) ) {
862-
// Process domains with optimization
863+
// Process domains with optimization.
863864
$domains = explode( "\n", $options['dns_prefetch_domains'] );
864865
$domains = array_map( 'trim', $domains );
865866
$domains = array_filter( $domains );
866867

867-
// Remove duplicates and validate domains
868-
$domains = array_unique( $domains );
868+
// Remove duplicates and validate domains.
869+
$domains = array_unique( $domains );
869870
$valid_domains = array();
870871

871872
foreach ( $domains as $domain ) {
872-
// Validate URL format and ensure HTTPS
873+
// Validate URL format and ensure HTTPS.
873874
if ( filter_var( $domain, FILTER_VALIDATE_URL ) && strpos( $domain, 'https://' ) === 0 ) {
874875
$valid_domains[] = $domain;
875876
}
@@ -881,7 +882,7 @@ function add_dns_prefetch() {
881882
}
882883
}
883884

884-
// Output the prefetch links
885+
// Output the prefetch links.
885886
if ( ! empty( $domains_cache ) ) {
886887
foreach ( $domains_cache as $domain ) {
887888
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped

0 commit comments

Comments
 (0)