diff --git a/README.md b/README.md index 7692f71..463dd10 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -[![CS](https://github.com/emilia-capital/aaa-option-optimizer/actions/workflows/cs.yml/badge.svg)](https://github.com/emilia-capital/aaa-option-optimizer/actions/workflows/cs.yml) -[![PHPStan](https://github.com/Emilia-Capital/aaa-option-optimizer/actions/workflows/phpstan.yml/badge.svg)](https://github.com/Emilia-Capital/aaa-option-optimizer/actions/workflows/phpstan.yml) -[![Lint](https://github.com/emilia-capital/aaa-option-optimizer/actions/workflows/lint.yml/badge.svg)](https://github.com/emilia-capital/aaa-option-optimizer/actions/workflows/lint.yml) -[![Security](https://github.com/emilia-capital/aaa-option-optimizer/actions/workflows/security.yml/badge.svg)](https://github.com/emilia-capital/aaa-option-optimizer/actions/workflows/security.yml) +[![CS](https://github.com/ProgressPlanner/aaa-option-optimizer/actions/workflows/cs.yml/badge.svg)](https://github.com/ProgressPlanner/aaa-option-optimizer/actions/workflows/cs.yml) +[![PHPStan](https://github.com/ProgressPlanner/aaa-option-optimizer/actions/workflows/phpstan.yml/badge.svg)](https://github.com/ProgressPlanner/aaa-option-optimizer/actions/workflows/phpstan.yml) +[![Lint](https://github.com/ProgressPlanner/aaa-option-optimizer/actions/workflows/lint.yml/badge.svg)](https://github.com/ProgressPlanner/aaa-option-optimizer/actions/workflows/lint.yml) +[![Security](https://github.com/ProgressPlanner/aaa-option-optimizer/actions/workflows/security.yml/badge.svg)](https://github.com/ProgressPlanner/aaa-option-optimizer/actions/workflows/security.yml) [![WordPress Plugin Version](https://img.shields.io/wordpress/plugin/v/aaa-option-optimizer.svg)](https://wordpress.org/plugins/aaa-option-optimizer/) ![WordPress Plugin: Tested WP Version](https://img.shields.io/wordpress/plugin/tested/aaa-option-optimizer.svg) @@ -10,7 +10,7 @@ [![WordPress Plugin Rating](https://img.shields.io/wordpress/plugin/stars/aaa-option-optimizer.svg)](https://wordpress.org/support/plugin/aaa-option-optimizer/reviews/) [![GitHub](https://img.shields.io/github/license/ProgressPlanner/aaa-option-optimizer.svg)](https://github.com/ProgressPlanner/aaa-option-optimizer/blob/main/LICENSE) -[![Try this plugin on the WordPress playground](https://img.shields.io/badge/Try%20this%20plugin%20on%20the%20WordPress%20Playground-%23117AC9.svg?style=for-the-badge&logo=WordPress&logoColor=ddd)](https://playground.wordpress.net/#%7B%22landingPage%22:%22/wp-admin/tools.php?page=aaa-option-optimizer%22,%22features%22:%7B%22networking%22:true%7D,%22steps%22:%5B%7B%22step%22:%22defineWpConfigConsts%22,%22consts%22:%7B%22IS_PLAYGROUND_PREVIEW%22:true%7D%7D,%7B%22step%22:%22login%22,%22username%22:%22admin%22,%22password%22:%22password%22%7D,%7B%22step%22:%22installPlugin%22,%22pluginZipFile%22:%7B%22resource%22:%22url%22,%22url%22:%22https://bypass-cors.altha.workers.dev/https://github.com/Emilia-Capital/aaa-option-optimizer/archive/refs/heads/develop.zip%22%7D,%22options%22:%7B%22activate%22:true%7D%7D%5D%7D) +[![Try this plugin on the WordPress playground](https://img.shields.io/badge/Try%20this%20plugin%20on%20the%20WordPress%20Playground-%23117AC9.svg?style=for-the-badge&logo=WordPress&logoColor=ddd)](https://playground.wordpress.net/#%7B%22landingPage%22:%22/wp-admin/tools.php?page=aaa-option-optimizer%22,%22features%22:%7B%22networking%22:true%7D,%22steps%22:%5B%7B%22step%22:%22defineWpConfigConsts%22,%22consts%22:%7B%22IS_PLAYGROUND_PREVIEW%22:true%7D%7D,%7B%22step%22:%22login%22,%22username%22:%22admin%22,%22password%22:%22password%22%7D,%7B%22step%22:%22installPlugin%22,%22pluginZipFile%22:%7B%22resource%22:%22url%22,%22url%22:%22https://bypass-cors.altha.workers.dev/https://github.com/ProgressPlanner/aaa-option-optimizer/archive/refs/heads/develop.zip%22%7D,%22options%22:%7B%22activate%22:true%7D%7D%5D%7D) ![GitHub banner](/.wordpress-org/github_banner_aaaoo_pp.png) @@ -26,7 +26,7 @@ Install this plugin, and go through your entire site. Best is to use it normally ### Why the AAA prefix in the plugin name? -Because the plugin needs to measure options being loaded, it benefits from being loaded itself first. As WordPress loads plugins alphabetically, +Because the plugin needs to measure options being loaded, it benefits from being loaded itself first. As WordPress loads plugins alphabetically, starting the name with AAA made sense. ### Do I need to take precautions? @@ -35,7 +35,7 @@ Yes!! Backup your database. ### How can I add recognized plugins? -Please do a pull request via GitHub on [this file](https://github.com/Emilia-Capital/aaa-option-optimizer/blob/develop/known-plugins/known-plugins.json) in the plugin. +Please do a pull request via GitHub on [this file](https://github.com/ProgressPlanner/aaa-option-optimizer/blob/develop/known-plugins/known-plugins.json) in the plugin. ### How can I report security bugs? diff --git a/aaa-option-optimizer.php b/aaa-option-optimizer.php index c568fa6..e2b59fc 100644 --- a/aaa-option-optimizer.php +++ b/aaa-option-optimizer.php @@ -2,7 +2,7 @@ /** * Plugin that tracks autoloaded options usage and allows the user to optimize them. * - * @package Emilia\OptionOptimizer + * @package Progress_Planner\OptionOptimizer * * Plugin Name: AAA Option Optimizer * Plugin URI: https://progressplanner.com/plugins/aaa-option-optimizer/ @@ -27,12 +27,19 @@ register_deactivation_hook( __FILE__, 'aaa_option_optimizer_deactivation' ); /** - * Activation hooked function to store start stats. + * Activation hooked function to store start stats and create table. * * @return void */ function aaa_option_optimizer_activation() { global $wpdb; + + // Create the custom table. + Progress_Planner\OptionOptimizer\Database::create_table(); + + // Migrate existing data if present. + Progress_Planner\OptionOptimizer\Database::maybe_migrate(); + $autoload_values = \wp_autoload_values_to_autoload(); $placeholders = implode( ',', array_fill( 0, count( $autoload_values ), '%s' ) ); @@ -42,19 +49,22 @@ function aaa_option_optimizer_activation() { ); // phpcs:enable WordPress.DB - update_option( - 'option_optimizer', - [ - 'starting_point_kb' => ( $result->autoload_size / 1024 ), - 'starting_point_num' => $result->count, - 'starting_point_date' => current_time( 'mysql' ), - 'used_options' => [], - 'settings' => [ - 'option_tracking' => 'pre_option', + // Only set starting point if not already set (preserve existing data). + $existing = get_option( 'option_optimizer' ); + if ( empty( $existing['starting_point_date'] ) ) { + update_option( + 'option_optimizer', + [ + 'starting_point_kb' => ( $result->autoload_size / 1024 ), + 'starting_point_num' => $result->count, + 'starting_point_date' => current_time( 'mysql' ), + 'settings' => [ + 'option_tracking' => 'pre_option', + ], ], - ], - false - ); + false + ); + } } /** @@ -67,13 +77,30 @@ function aaa_option_optimizer_deactivation() { update_option( 'option_optimizer', $aaa_option_value, false ); } +/** + * Ensure database table exists and migrate data if needed. + * Runs on plugins_loaded to handle existing installs that don't trigger activation. + * + * @return void + */ +function aaa_option_optimizer_maybe_upgrade() { + // Check if table exists, create if not. + if ( ! Progress_Planner\OptionOptimizer\Database::table_exists() ) { + Progress_Planner\OptionOptimizer\Database::create_table(); + } + + // Migrate existing data if present. + Progress_Planner\OptionOptimizer\Database::maybe_migrate(); +} +add_action( 'plugins_loaded', 'aaa_option_optimizer_maybe_upgrade' ); + /** * Initializes the plugin. * * @return void */ function aaa_option_optimizer_init() { - $optimizer = new Emilia\OptionOptimizer\Plugin(); + $optimizer = new Progress_Planner\OptionOptimizer\Plugin(); $optimizer->register_hooks(); } diff --git a/composer.json b/composer.json index bf3741c..8ee7555 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "emilia/aaa-option-optimizer", + "name": "progress-planner/aaa-option-optimizer", "description": "Plugin that tracks autoloaded options usage and allows the user to optimize them.", "type": "wordpress-plugin", "license": "GPL-3.0-or-later", @@ -16,7 +16,7 @@ "phpstan/phpstan": "^1.10", "szepeviktor/phpstan-wordpress": "^1.3", "phpstan/extension-installer": "^1.3", - "phpcompatibility/php-compatibility": "dev-develop as 9.99.99" + "phpcompatibility/php-compatibility": "^9.3" }, "config": { "allow-plugins": { diff --git a/composer.lock b/composer.lock index caaaa3c..d186fc9 100644 --- a/composer.lock +++ b/composer.lock @@ -4,34 +4,34 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "fd7786df413fbfa0ec1e1564845fe06c", + "content-hash": "68e73cf23844dd66f4d8b3b14eef46cd", "packages": [], "packages-dev": [ { "name": "dealerdirect/phpcodesniffer-composer-installer", - "version": "v1.0.0", + "version": "v1.2.0", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/composer-installer.git", - "reference": "4be43904336affa5c2f70744a348312336afd0da" + "reference": "845eb62303d2ca9b289ef216356568ccc075ffd1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/composer-installer/zipball/4be43904336affa5c2f70744a348312336afd0da", - "reference": "4be43904336affa5c2f70744a348312336afd0da", + "url": "https://api.github.com/repos/PHPCSStandards/composer-installer/zipball/845eb62303d2ca9b289ef216356568ccc075ffd1", + "reference": "845eb62303d2ca9b289ef216356568ccc075ffd1", "shasum": "" }, "require": { - "composer-plugin-api": "^1.0 || ^2.0", + "composer-plugin-api": "^2.2", "php": ">=5.4", - "squizlabs/php_codesniffer": "^2.0 || ^3.1.0 || ^4.0" + "squizlabs/php_codesniffer": "^3.1.0 || ^4.0" }, "require-dev": { - "composer/composer": "*", + "composer/composer": "^2.2", "ext-json": "*", "ext-zip": "*", - "php-parallel-lint/php-parallel-lint": "^1.3.1", - "phpcompatibility/php-compatibility": "^9.0", + "php-parallel-lint/php-parallel-lint": "^1.4.0", + "phpcompatibility/php-compatibility": "^9.0 || ^10.0.0@dev", "yoast/phpunit-polyfills": "^1.0" }, "type": "composer-plugin", @@ -50,9 +50,9 @@ "authors": [ { "name": "Franck Nijhof", - "email": "franck.nijhof@dealerdirect.com", - "homepage": "http://www.frenck.nl", - "role": "Developer / IT Manager" + "email": "opensource@frenck.dev", + "homepage": "https://frenck.dev", + "role": "Open source developer" }, { "name": "Contributors", @@ -60,7 +60,6 @@ } ], "description": "PHP_CodeSniffer Standards Composer Installer Plugin", - "homepage": "http://www.dealerdirect.com", "keywords": [ "PHPCodeSniffer", "PHP_CodeSniffer", @@ -81,9 +80,28 @@ ], "support": { "issues": "https://github.com/PHPCSStandards/composer-installer/issues", + "security": "https://github.com/PHPCSStandards/composer-installer/security/policy", "source": "https://github.com/PHPCSStandards/composer-installer" }, - "time": "2023-01-05T11:28:13+00:00" + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + }, + { + "url": "https://thanks.dev/u/gh/phpcsstandards", + "type": "thanks_dev" + } + ], + "time": "2025-11-11T04:32:07+00:00" }, { "name": "php-parallel-lint/php-parallel-lint", @@ -148,27 +166,30 @@ }, { "name": "php-stubs/wordpress-stubs", - "version": "v6.6.0", + "version": "v6.9.0", "source": { "type": "git", "url": "https://github.com/php-stubs/wordpress-stubs.git", - "reference": "86e8753e89d59849276dcdd91b9a7dd78bb4abe2" + "reference": "5171cb6650e6c583a96943fd6ea0dfa3e1089a8a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-stubs/wordpress-stubs/zipball/86e8753e89d59849276dcdd91b9a7dd78bb4abe2", - "reference": "86e8753e89d59849276dcdd91b9a7dd78bb4abe2", + "url": "https://api.github.com/repos/php-stubs/wordpress-stubs/zipball/5171cb6650e6c583a96943fd6ea0dfa3e1089a8a", + "reference": "5171cb6650e6c583a96943fd6ea0dfa3e1089a8a", "shasum": "" }, + "conflict": { + "phpdocumentor/reflection-docblock": "5.6.1" + }, "require-dev": { "dealerdirect/phpcodesniffer-composer-installer": "^1.0", - "nikic/php-parser": "^4.13", + "nikic/php-parser": "^5.5", "php": "^7.4 || ^8.0", "php-stubs/generator": "^0.8.3", "phpdocumentor/reflection-docblock": "^5.4.1", - "phpstan/phpstan": "^1.10.49", + "phpstan/phpstan": "^2.1", "phpunit/phpunit": "^9.5", - "szepeviktor/phpcs-psr-12-neutron-hybrid-ruleset": "^1.0", + "szepeviktor/phpcs-psr-12-neutron-hybrid-ruleset": "^1.1.1", "wp-coding-standards/wpcs": "3.1.0 as 2.3.0" }, "suggest": { @@ -190,51 +211,39 @@ ], "support": { "issues": "https://github.com/php-stubs/wordpress-stubs/issues", - "source": "https://github.com/php-stubs/wordpress-stubs/tree/v6.6.0" + "source": "https://github.com/php-stubs/wordpress-stubs/tree/v6.9.0" }, - "time": "2024-07-17T08:50:38+00:00" + "time": "2025-12-03T23:06:24+00:00" }, { "name": "phpcompatibility/php-compatibility", - "version": "dev-develop", + "version": "9.3.5", "source": { "type": "git", "url": "https://github.com/PHPCompatibility/PHPCompatibility.git", - "reference": "d9ae4b030f174c8f01d400244107e28ad65ec5e1" + "reference": "9fb324479acf6f39452e0655d2429cc0d3914243" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/d9ae4b030f174c8f01d400244107e28ad65ec5e1", - "reference": "d9ae4b030f174c8f01d400244107e28ad65ec5e1", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/9fb324479acf6f39452e0655d2429cc0d3914243", + "reference": "9fb324479acf6f39452e0655d2429cc0d3914243", "shasum": "" }, "require": { - "php": ">=5.4", - "phpcsstandards/phpcsutils": "^1.0.12", - "squizlabs/php_codesniffer": "^3.10.0" + "php": ">=5.3", + "squizlabs/php_codesniffer": "^2.3 || ^3.0.2" }, - "replace": { - "wimg/php-compatibility": "*" + "conflict": { + "squizlabs/php_codesniffer": "2.6.2" }, "require-dev": { - "php-parallel-lint/php-console-highlighter": "^1.0.0", - "php-parallel-lint/php-parallel-lint": "^1.3.2", - "phpcsstandards/phpcsdevcs": "^1.1.3", - "phpcsstandards/phpcsdevtools": "^1.2.0", - "phpunit/phpunit": "^4.8.36 || ^5.7.21 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4 || ^10.1.0", - "yoast/phpunit-polyfills": "^1.0.5 || ^2.0.0" + "phpunit/phpunit": "~4.5 || ^5.0 || ^6.0 || ^7.0" }, "suggest": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.5 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically.", "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." }, - "default-branch": true, "type": "phpcodesniffer-standard", - "extra": { - "branch-alias": { - "dev-master": "9.x-dev", - "dev-develop": "10.x-dev" - } - }, "notification-url": "https://packagist.org/downloads/", "license": [ "LGPL-3.0-or-later" @@ -260,54 +269,38 @@ "keywords": [ "compatibility", "phpcs", - "standards", - "static analysis" + "standards" ], "support": { "issues": "https://github.com/PHPCompatibility/PHPCompatibility/issues", - "security": "https://github.com/PHPCompatibility/PHPCompatibility/security/policy", "source": "https://github.com/PHPCompatibility/PHPCompatibility" }, - "funding": [ - { - "url": "https://github.com/PHPCompatibility", - "type": "github" - }, - { - "url": "https://github.com/jrfnl", - "type": "github" - }, - { - "url": "https://opencollective.com/php_codesniffer", - "type": "open_collective" - } - ], - "time": "2024-08-31T21:55:43+00:00" + "time": "2019-12-27T09:44:58+00:00" }, { "name": "phpcompatibility/phpcompatibility-paragonie", - "version": "1.3.2", + "version": "1.3.4", "source": { "type": "git", "url": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie.git", - "reference": "bba5a9dfec7fcfbd679cfaf611d86b4d3759da26" + "reference": "244d7b04fc4bc2117c15f5abe23eb933b5f02bbf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityParagonie/zipball/bba5a9dfec7fcfbd679cfaf611d86b4d3759da26", - "reference": "bba5a9dfec7fcfbd679cfaf611d86b4d3759da26", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityParagonie/zipball/244d7b04fc4bc2117c15f5abe23eb933b5f02bbf", + "reference": "244d7b04fc4bc2117c15f5abe23eb933b5f02bbf", "shasum": "" }, "require": { "phpcompatibility/php-compatibility": "^9.0" }, "require-dev": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.7", + "dealerdirect/phpcodesniffer-composer-installer": "^1.0", "paragonie/random_compat": "dev-master", "paragonie/sodium_compat": "dev-master" }, "suggest": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.7 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.", + "dealerdirect/phpcodesniffer-composer-installer": "^1.0 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.", "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." }, "type": "phpcodesniffer-standard", @@ -337,27 +330,47 @@ ], "support": { "issues": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie/issues", + "security": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie/security/policy", "source": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie" }, - "time": "2022-10-25T01:46:02+00:00" + "funding": [ + { + "url": "https://github.com/PHPCompatibility", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + }, + { + "url": "https://thanks.dev/u/gh/phpcompatibility", + "type": "thanks_dev" + } + ], + "time": "2025-09-19T17:43:28+00:00" }, { "name": "phpcompatibility/phpcompatibility-wp", - "version": "2.1.5", + "version": "2.1.8", "source": { "type": "git", "url": "https://github.com/PHPCompatibility/PHPCompatibilityWP.git", - "reference": "01c1ff2704a58e46f0cb1ca9d06aee07b3589082" + "reference": "7c8d18b4d90dac9e86b0869a608fa09158e168fa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityWP/zipball/01c1ff2704a58e46f0cb1ca9d06aee07b3589082", - "reference": "01c1ff2704a58e46f0cb1ca9d06aee07b3589082", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityWP/zipball/7c8d18b4d90dac9e86b0869a608fa09158e168fa", + "reference": "7c8d18b4d90dac9e86b0869a608fa09158e168fa", "shasum": "" }, "require": { "phpcompatibility/php-compatibility": "^9.0", - "phpcompatibility/phpcompatibility-paragonie": "^1.0" + "phpcompatibility/phpcompatibility-paragonie": "^1.0", + "squizlabs/php_codesniffer": "^3.3" }, "require-dev": { "dealerdirect/phpcodesniffer-composer-installer": "^1.0" @@ -407,35 +420,39 @@ { "url": "https://opencollective.com/php_codesniffer", "type": "open_collective" + }, + { + "url": "https://thanks.dev/u/gh/phpcompatibility", + "type": "thanks_dev" } ], - "time": "2024-04-24T21:37:59+00:00" + "time": "2025-10-18T00:05:59+00:00" }, { "name": "phpcsstandards/phpcsextra", - "version": "1.2.1", + "version": "1.5.0", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHPCSExtra.git", - "reference": "11d387c6642b6e4acaf0bd9bf5203b8cca1ec489" + "reference": "b598aa890815b8df16363271b659d73280129101" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHPCSExtra/zipball/11d387c6642b6e4acaf0bd9bf5203b8cca1ec489", - "reference": "11d387c6642b6e4acaf0bd9bf5203b8cca1ec489", + "url": "https://api.github.com/repos/PHPCSStandards/PHPCSExtra/zipball/b598aa890815b8df16363271b659d73280129101", + "reference": "b598aa890815b8df16363271b659d73280129101", "shasum": "" }, "require": { "php": ">=5.4", - "phpcsstandards/phpcsutils": "^1.0.9", - "squizlabs/php_codesniffer": "^3.8.0" + "phpcsstandards/phpcsutils": "^1.2.0", + "squizlabs/php_codesniffer": "^3.13.5 || ^4.0.1" }, "require-dev": { "php-parallel-lint/php-console-highlighter": "^1.0", - "php-parallel-lint/php-parallel-lint": "^1.3.2", - "phpcsstandards/phpcsdevcs": "^1.1.6", + "php-parallel-lint/php-parallel-lint": "^1.4.0", + "phpcsstandards/phpcsdevcs": "^1.2.0", "phpcsstandards/phpcsdevtools": "^1.2.1", - "phpunit/phpunit": "^4.5 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0" + "phpunit/phpunit": "^4.5 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4" }, "type": "phpcodesniffer-standard", "extra": { @@ -485,35 +502,39 @@ { "url": "https://opencollective.com/php_codesniffer", "type": "open_collective" + }, + { + "url": "https://thanks.dev/u/gh/phpcsstandards", + "type": "thanks_dev" } ], - "time": "2023-12-08T16:49:07+00:00" + "time": "2025-11-12T23:06:57+00:00" }, { "name": "phpcsstandards/phpcsutils", - "version": "1.0.12", + "version": "1.2.2", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHPCSUtils.git", - "reference": "87b233b00daf83fb70f40c9a28692be017ea7c6c" + "reference": "c216317e96c8b3f5932808f9b0f1f7a14e3bbf55" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/87b233b00daf83fb70f40c9a28692be017ea7c6c", - "reference": "87b233b00daf83fb70f40c9a28692be017ea7c6c", + "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/c216317e96c8b3f5932808f9b0f1f7a14e3bbf55", + "reference": "c216317e96c8b3f5932808f9b0f1f7a14e3bbf55", "shasum": "" }, "require": { "dealerdirect/phpcodesniffer-composer-installer": "^0.4.1 || ^0.5 || ^0.6.2 || ^0.7 || ^1.0", "php": ">=5.4", - "squizlabs/php_codesniffer": "^3.10.0 || 4.0.x-dev@dev" + "squizlabs/php_codesniffer": "^3.13.5 || ^4.0.1" }, "require-dev": { "ext-filter": "*", "php-parallel-lint/php-console-highlighter": "^1.0", - "php-parallel-lint/php-parallel-lint": "^1.3.2", - "phpcsstandards/phpcsdevcs": "^1.1.6", - "yoast/phpunit-polyfills": "^1.1.0 || ^2.0.0" + "php-parallel-lint/php-parallel-lint": "^1.4.0", + "phpcsstandards/phpcsdevcs": "^1.2.0", + "yoast/phpunit-polyfills": "^1.1.0 || ^2.0.0 || ^3.0.0" }, "type": "phpcodesniffer-standard", "extra": { @@ -550,6 +571,7 @@ "phpcodesniffer-standard", "phpcs", "phpcs3", + "phpcs4", "standards", "static analysis", "tokens", @@ -573,9 +595,13 @@ { "url": "https://opencollective.com/php_codesniffer", "type": "open_collective" + }, + { + "url": "https://thanks.dev/u/gh/phpcsstandards", + "type": "thanks_dev" } ], - "time": "2024-05-20T13:34:27+00:00" + "time": "2025-12-08T14:27:58+00:00" }, { "name": "phpstan/extension-installer", @@ -627,16 +653,11 @@ }, { "name": "phpstan/phpstan", - "version": "1.12.2", - "source": { - "type": "git", - "url": "https://github.com/phpstan/phpstan.git", - "reference": "0ca1c7bb55fca8fe6448f16fff0f311ccec960a1" - }, + "version": "1.12.32", "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/0ca1c7bb55fca8fe6448f16fff0f311ccec960a1", - "reference": "0ca1c7bb55fca8fe6448f16fff0f311ccec960a1", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/2770dcdf5078d0b0d53f94317e06affe88419aa8", + "reference": "2770dcdf5078d0b0d53f94317e06affe88419aa8", "shasum": "" }, "require": { @@ -681,20 +702,20 @@ "type": "github" } ], - "time": "2024-09-05T16:09:28+00:00" + "time": "2025-09-30T10:16:31+00:00" }, { "name": "squizlabs/php_codesniffer", - "version": "3.10.2", + "version": "3.13.5", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "86e5f5dd9a840c46810ebe5ff1885581c42a3017" + "reference": "0ca86845ce43291e8f5692c7356fccf3bcf02bf4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/86e5f5dd9a840c46810ebe5ff1885581c42a3017", - "reference": "86e5f5dd9a840c46810ebe5ff1885581c42a3017", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/0ca86845ce43291e8f5692c7356fccf3bcf02bf4", + "reference": "0ca86845ce43291e8f5692c7356fccf3bcf02bf4", "shasum": "" }, "require": { @@ -711,11 +732,6 @@ "bin/phpcs" ], "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.x-dev" - } - }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" @@ -759,32 +775,36 @@ { "url": "https://opencollective.com/php_codesniffer", "type": "open_collective" + }, + { + "url": "https://thanks.dev/u/gh/phpcsstandards", + "type": "thanks_dev" } ], - "time": "2024-07-21T23:26:44+00:00" + "time": "2025-11-04T16:30:35+00:00" }, { "name": "symfony/polyfill-php73", - "version": "v1.29.0", + "version": "v1.33.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "21bd091060673a1177ae842c0ef8fe30893114d2" + "reference": "0f68c03565dcaaf25a890667542e8bd75fe7e5bb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/21bd091060673a1177ae842c0ef8fe30893114d2", - "reference": "21bd091060673a1177ae842c0ef8fe30893114d2", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/0f68c03565dcaaf25a890667542e8bd75fe7e5bb", + "reference": "0f68c03565dcaaf25a890667542e8bd75fe7e5bb", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=7.2" }, "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -821,7 +841,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/v1.29.0" + "source": "https://github.com/symfony/polyfill-php73/tree/v1.33.0" }, "funding": [ { @@ -832,12 +852,16 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2024-01-29T20:11:03+00:00" + "time": "2024-09-09T11:45:10+00:00" }, { "name": "szepeviktor/phpstan-wordpress", @@ -904,16 +928,16 @@ }, { "name": "wp-coding-standards/wpcs", - "version": "3.1.0", + "version": "3.3.0", "source": { "type": "git", "url": "https://github.com/WordPress/WordPress-Coding-Standards.git", - "reference": "9333efcbff231f10dfd9c56bb7b65818b4733ca7" + "reference": "7795ec6fa05663d716a549d0b44e47ffc8b0d4a6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/9333efcbff231f10dfd9c56bb7b65818b4733ca7", - "reference": "9333efcbff231f10dfd9c56bb7b65818b4733ca7", + "url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/7795ec6fa05663d716a549d0b44e47ffc8b0d4a6", + "reference": "7795ec6fa05663d716a549d0b44e47ffc8b0d4a6", "shasum": "" }, "require": { @@ -921,17 +945,17 @@ "ext-libxml": "*", "ext-tokenizer": "*", "ext-xmlreader": "*", - "php": ">=5.4", - "phpcsstandards/phpcsextra": "^1.2.1", - "phpcsstandards/phpcsutils": "^1.0.10", - "squizlabs/php_codesniffer": "^3.9.0" + "php": ">=7.2", + "phpcsstandards/phpcsextra": "^1.5.0", + "phpcsstandards/phpcsutils": "^1.1.0", + "squizlabs/php_codesniffer": "^3.13.4" }, "require-dev": { "php-parallel-lint/php-console-highlighter": "^1.0.0", - "php-parallel-lint/php-parallel-lint": "^1.3.2", - "phpcompatibility/php-compatibility": "^9.0", + "php-parallel-lint/php-parallel-lint": "^1.4.0", + "phpcompatibility/php-compatibility": "^10.0.0@dev", "phpcsstandards/phpcsdevtools": "^1.2.0", - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0" + "phpunit/phpunit": "^8.0 || ^9.0" }, "suggest": { "ext-iconv": "For improved results", @@ -966,24 +990,15 @@ "type": "custom" } ], - "time": "2024-03-25T16:39:00+00:00" - } - ], - "aliases": [ - { - "package": "phpcompatibility/php-compatibility", - "version": "dev-develop", - "alias": "9.99.99", - "alias_normalized": "9.99.99.0" + "time": "2025-11-25T12:08:04+00:00" } ], + "aliases": [], "minimum-stability": "stable", - "stability-flags": { - "phpcompatibility/php-compatibility": 20 - }, + "stability-flags": {}, "prefer-stable": false, "prefer-lowest": false, - "platform": [], - "platform-dev": [], - "plugin-api-version": "2.6.0" + "platform": {}, + "platform-dev": {}, + "plugin-api-version": "2.9.0" } diff --git a/phpcs.xml.dist b/phpcs.xml.dist index fffbfd5..5b1a264 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -108,12 +108,17 @@ - - + + + + + 0 + + diff --git a/readme.txt b/readme.txt index a070888..da538c8 100644 --- a/readme.txt +++ b/readme.txt @@ -29,7 +29,7 @@ Yes!! Backup your database. = Where can I report bugs? = -Please use [our GitHub](https://github.com/emilia-Capital/aaa-option-optimizer/) for reporting bugs or making code suggestions. Feel free to use the forums for asking questions too, of course. +Please use [our GitHub](https://github.com/ProgressPlanner/aaa-option-optimizer/) for reporting bugs or making code suggestions. Feel free to use the forums for asking questions too, of course. For security issues, please see the next question. @@ -39,7 +39,7 @@ You can report security bugs through the Patchstack Vulnerability Disclosure Pro = How can I add recognized plugins? = -Please do a pull request via GitHub on [this file](https://github.com/Emilia-Capital/aaa-option-optimizer/blob/develop/known-plugins/known-plugins.json) in the plugin. +Please do a pull request via GitHub on [this file](https://github.com/ProgressPlanner/aaa-option-optimizer/blob/develop/known-plugins/known-plugins.json) in the plugin. == Installation == 1. Search for AAA Option Optimizer on the repository. @@ -113,7 +113,7 @@ Implement the missing functionality to create an option with value `false` when = 1.1 = The plugin now recognizes plugins from which the options came (thanks to a great pull by [Rogier Lankhorst](https://profiles.wordpress.org/rogierlankhorst/)). If you're a plugin developer and want your plugin's options -properly recognized, please do a pull request [on this file](https://github.com/Emilia-Capital/aaa-option-optimizer/blob/main/known-plugins/known-plugins.json). +properly recognized, please do a pull request [on this file](https://github.com/ProgressPlanner/aaa-option-optimizer/blob/main/known-plugins/known-plugins.json). Small enhancements: diff --git a/src/autoload.php b/src/autoload.php index 502fda2..4f04541 100644 --- a/src/autoload.php +++ b/src/autoload.php @@ -2,12 +2,12 @@ /** * Autoload PHP classes for the plugin. * - * @package Emilia\OptionOptimizer + * @package Progress_Planner\OptionOptimizer */ spl_autoload_register( function ( $class_name ) { - $prefix = 'Emilia\\OptionOptimizer\\'; + $prefix = 'Progress_Planner\\OptionOptimizer\\'; if ( 0 !== \strpos( $class_name, $prefix ) ) { return; diff --git a/src/class-admin-page.php b/src/class-admin-page.php index 4e7d6dd..05833c3 100644 --- a/src/class-admin-page.php +++ b/src/class-admin-page.php @@ -2,10 +2,10 @@ /** * Admin page functionality for AAA Option Optimizer. * - * @package Emilia\OptionOptimizer + * @package Progress_Planner\OptionOptimizer */ -namespace Emilia\OptionOptimizer; +namespace Progress_Planner\OptionOptimizer; /** * Admin page functionality for AAA Option Optimizer. diff --git a/src/class-database.php b/src/class-database.php new file mode 100644 index 0000000..7244047 --- /dev/null +++ b/src/class-database.php @@ -0,0 +1,200 @@ +prefix . self::TABLE_NAME; + } + + /** + * Create the custom table. + * + * @return void + */ + public static function create_table() { + global $wpdb; + + $table_name = self::get_table_name(); + $charset_collate = $wpdb->get_charset_collate(); + + $sql = "CREATE TABLE {$table_name} ( + option_name VARCHAR(191) NOT NULL, + access_count BIGINT UNSIGNED DEFAULT 1, + created_at DATETIME DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (option_name) + ) {$charset_collate};"; + + require_once ABSPATH . 'wp-admin/includes/upgrade.php'; + \dbDelta( $sql ); + } + + /** + * Drop the custom table. + * + * @return void + */ + public static function drop_table() { + global $wpdb; + + $table_name = self::get_table_name(); + + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Table name is safe (from constant). + $wpdb->query( "DROP TABLE IF EXISTS {$table_name}" ); + } + + /** + * Check if the table exists. + * + * @return bool + */ + public static function table_exists() { + global $wpdb; + + $table_name = self::get_table_name(); + + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching + return $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $table_name ) ) === $table_name; + } + + /** + * Migrate data from the old option format to the custom table. + * + * @return void + */ + public static function maybe_migrate() { + $option_data = \get_option( 'option_optimizer' ); + + // No data or already migrated (no used_options key). + if ( ! \is_array( $option_data ) || ! isset( $option_data['used_options'] ) ) { + return; + } + + // Ensure table exists. + if ( ! self::table_exists() ) { + self::create_table(); + } + + // Batch insert old data to custom table. + if ( ! empty( $option_data['used_options'] ) ) { + self::batch_insert( $option_data['used_options'] ); + } + + // Remove used_options from the option, keep metadata. + unset( $option_data['used_options'] ); + \update_option( 'option_optimizer', $option_data, false ); + } + + /** + * Batch insert or update option counts. + * + * @param array $options Array of option_name => count. + * + * @return void + */ + public static function batch_insert( $options ) { + global $wpdb; + + if ( empty( $options ) ) { + return; + } + + $table_name = self::get_table_name(); + $values = []; + $placeholders = []; + + foreach ( $options as $option_name => $count ) { + $placeholders[] = '(%s, %d, NOW())'; + $values[] = $option_name; + $values[] = (int) $count; + } + + $sql = "INSERT INTO {$table_name} (option_name, access_count, created_at) + VALUES " . implode( ', ', $placeholders ) . ' + ON DUPLICATE KEY UPDATE access_count = access_count + VALUES(access_count)'; + + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared + $wpdb->query( $wpdb->prepare( $sql, ...$values ) ); + } + + /** + * Get all tracked options as an associative array. + * + * @return array Array of option_name => access_count. + */ + public static function get_tracked_options() { + global $wpdb; + + $table_name = self::get_table_name(); + + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Table name is safe (from constant). + $results = $wpdb->get_results( "SELECT option_name, access_count FROM {$table_name}", ARRAY_A ); + + if ( empty( $results ) ) { + return []; + } + + $options = []; + foreach ( $results as $row ) { + $options[ $row['option_name'] ] = (int) $row['access_count']; + } + + return $options; + } + + /** + * Get tracked option names as a keyed array for efficient lookups. + * + * @return array Array of option_name => true. + */ + public static function get_tracked_option_keys() { + global $wpdb; + + $table_name = self::get_table_name(); + + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Table name is safe (from constant). + $option_names = $wpdb->get_col( "SELECT option_name FROM {$table_name}" ); + + if ( empty( $option_names ) ) { + return []; + } + + return array_fill_keys( $option_names, true ); + } + + /** + * Clear all tracked options from the table. + * + * @return void + */ + public static function clear_tracked_options() { + global $wpdb; + + $table_name = self::get_table_name(); + + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Table name is safe (from constant). + $wpdb->query( "TRUNCATE TABLE {$table_name}" ); + } +} diff --git a/src/class-map-plugin-to-options.php b/src/class-map-plugin-to-options.php index 2732f9a..799d8fe 100644 --- a/src/class-map-plugin-to-options.php +++ b/src/class-map-plugin-to-options.php @@ -2,15 +2,15 @@ /** * Functionality to map options to plugins. * - * @package Emilia\OptionOptimizer + * @package Progress_Planner\OptionOptimizer */ -namespace Emilia\OptionOptimizer; +namespace Progress_Planner\OptionOptimizer; /** * Class Map_Plugin_To_Options * - * @package Emilia\OptionOptimizer + * @package Progress_Planner\OptionOptimizer */ class Map_Plugin_To_Options { /** diff --git a/src/class-plugin.php b/src/class-plugin.php index 88b0f36..cd7b7e8 100644 --- a/src/class-plugin.php +++ b/src/class-plugin.php @@ -2,10 +2,10 @@ /** * Plugin functionality for AAA Option Optimizer. * - * @package Emilia\OptionOptimizer + * @package Progress_Planner\OptionOptimizer */ -namespace Emilia\OptionOptimizer; +namespace Progress_Planner\OptionOptimizer; /** * Core functionality of AAA Option Optimizer. @@ -60,8 +60,6 @@ public static function get_instance() { * @return void */ public function register_hooks() { - $this->accessed_options = \get_option( 'option_optimizer', [ 'used_options' => [] ] )['used_options']; - if ( Admin_Page::get_option_tracking() === 'pre_option' ) { \add_filter( 'pre_option', [ $this, 'monitor_option_accesses_pre_option' ], PHP_INT_MAX, 2 ); } else { @@ -144,7 +142,10 @@ protected function add_option_usage( $option_name ) { } /** - * Update the 'option_optimizer' option with the list of used options at the end of the page load. + * Update the tracked options at the end of the page load. + * + * Uses transient batching to reduce database writes - only flushes to the custom table + * every 5 minutes instead of on every request. * * @return void */ @@ -153,16 +154,67 @@ public function update_tracked_options() { if ( isset( $_GET['page'] ) && $_GET['page'] === 'aaa-option-optimizer' ) { return; } - // Retrieve the existing option_optimizer data. - $option_optimizer = get_option( 'option_optimizer', [ 'used_options' => [] ] ); - - $option_optimizer['used_options'] = $this->accessed_options; + // Handle reset: clear batch and custom table. if ( $this->should_reset ) { - $option_optimizer['used_options'] = []; + \delete_transient( 'option_optimizer_batch' ); + Database::clear_tracked_options(); + return; + } + + // Get the batch data. + $batch_data = $this->get_batch_data(); + + // Add current request's options to the batch. + foreach ( $this->accessed_options as $option_name => $count ) { + if ( ! isset( $batch_data['options'][ $option_name ] ) ) { + $batch_data['options'][ $option_name ] = 0; + } + $batch_data['options'][ $option_name ] += $count; + } + + // Check if it's time to flush the batch. + $should_flush = ( \time() - $batch_data['last_flush'] ) >= $this->get_flush_interval(); + + // Flush batch to custom table every 5 minutes. + if ( ! empty( $batch_data['options'] ) && $should_flush ) { + Database::batch_insert( $batch_data['options'] ); + + // Reset the batch data. + $batch_data = [ + 'options' => [], + 'last_flush' => \time(), + ]; } - // Update the 'option_optimizer' option with the new list. - update_option( 'option_optimizer', $option_optimizer, false ); + // No expiry - batch is explicitly deleted on flush, expiry would only cause data loss. + \set_transient( 'option_optimizer_batch', $batch_data, 0 ); + } + + /** + * Get the batch data. + * + * @return array + */ + protected function get_batch_data() { + // Get existing batch (stores both data and flush timestamp in one transient). + $batch_data = \get_transient( 'option_optimizer_batch' ); + if ( ! \is_array( $batch_data ) || ! isset( $batch_data['options'], $batch_data['last_flush'] ) ) { + $batch_data = [ + 'options' => [], + 'last_flush' => \time(), + ]; + } + + return $batch_data; + } + + /** + * Get the flush interval. + * + * @return int + */ + protected function get_flush_interval() { + return (int) \apply_filters( 'aaa_option_optimizer_flush_interval', 5 * MINUTE_IN_SECONDS ); } } diff --git a/src/class-rest.php b/src/class-rest.php index 9310487..f1a550a 100644 --- a/src/class-rest.php +++ b/src/class-rest.php @@ -2,10 +2,10 @@ /** * REST functionality for AAA Option Optimizer. * - * @package Emilia\OptionOptimizer + * @package Progress_Planner\OptionOptimizer */ -namespace Emilia\OptionOptimizer; +namespace Progress_Planner\OptionOptimizer; use WP_Error; use WP_REST_Request; @@ -229,9 +229,8 @@ public function get_unused_options() { global $wpdb; - // Load used options from option_optimizer. - $option_optimizer = get_option( 'option_optimizer', [ 'used_options' => [] ] ); - $used_options = $option_optimizer['used_options']; + // Load used options from custom table. + $used_options = Database::get_tracked_option_keys(); $query = " SELECT option_name @@ -335,9 +334,8 @@ public function get_used_not_autoloaded_options() { global $wpdb; - // Load used options from option_optimizer. - $option_optimizer = get_option( 'option_optimizer', [ 'used_options' => [] ] ); - $used_options = $option_optimizer['used_options']; + // Load used options from custom table (with counts). + $used_options = Database::get_tracked_options(); if ( empty( $used_options ) ) { return new \WP_REST_Response( @@ -460,9 +458,8 @@ public function get_options_that_do_not_exist() { global $wpdb; - // Load used options. - $option_optimizer = get_option( 'option_optimizer', [ 'used_options' => [] ] ); - $used_options = $option_optimizer['used_options']; + // Load used options from custom table (with counts). + $used_options = Database::get_tracked_options(); if ( empty( $used_options ) ) { return new \WP_REST_Response( diff --git a/uninstall.php b/uninstall.php index 4fa17e2..05bf9fe 100644 --- a/uninstall.php +++ b/uninstall.php @@ -2,9 +2,9 @@ /** * Uninstall the plugin. * - * Delete the plugin option. + * Delete the plugin option and custom table. * - * @package Progress_Planner + * @package Progress_Planner\OptionOptimizer */ // If uninstall not called from WordPress, then exit. @@ -12,5 +12,15 @@ exit; } +global $wpdb; + +// Drop the custom table. +$aaa_option_optimizer_table = $wpdb->prefix . 'option_optimizer_tracked'; +// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Table name is safe (from constant prefix). +$wpdb->query( "DROP TABLE IF EXISTS {$aaa_option_optimizer_table}" ); + +// Delete the batch transient. +delete_transient( 'option_optimizer_batch' ); + // Delete the plugin option. delete_option( 'option_optimizer' );