From 810deb31b49516f94220873ff82090f2084dd61e Mon Sep 17 00:00:00 2001 From: Slobodan Date: Fri, 10 Nov 2023 14:08:29 +0100 Subject: [PATCH 1/2] Define VERSION for dynamic data getting through the get_plugin_data --- admin/admin-init.php | 6 ++---- admin/opt/config/framework.php | 5 +++-- booster-sweeper.php | 20 ++++++++++++++------ classes/init.php | 16 ---------------- 4 files changed, 19 insertions(+), 28 deletions(-) diff --git a/admin/admin-init.php b/admin/admin-init.php index c2ac8d7..e74e9c5 100644 --- a/admin/admin-init.php +++ b/admin/admin-init.php @@ -42,15 +42,13 @@ // phpcs:ignore function booster_sweeper_admin_scripts() { - - $plugin_version = Booster_Sweeper::version(); $current_screen = get_current_screen()->base; // Load only on Booster Sweeper settings page. if ($current_screen === 'toplevel_page_booster-sweeper-settings') { - wp_enqueue_style('booster-sweeper-adminizr', plugin_dir_url(__DIR__) .'library/admin/adminizr.css', array(), $plugin_version); - wp_enqueue_script('booster-sweeper-adminizr', plugin_dir_url(__DIR__) .'library/admin/adminizr.js', array( 'jquery' ), $plugin_version, true); + wp_enqueue_style('booster-sweeper-adminizr', plugin_dir_url(__DIR__) .'library/admin/adminizr.css', array(), BOOSTER_SWEEPER_VERSION); + wp_enqueue_script('booster-sweeper-adminizr', plugin_dir_url(__DIR__) .'library/admin/adminizr.js', array( 'jquery' ), BOOSTER_SWEEPER_VERSION, true); // add local vars for translation, accesed through the JS $local_var_array = array( diff --git a/admin/opt/config/framework.php b/admin/opt/config/framework.php index 281b819..ee7d81e 100644 --- a/admin/opt/config/framework.php +++ b/admin/opt/config/framework.php @@ -13,7 +13,8 @@ * Set a unique slug-like ID. */ $prefix = '_booster_sweeper_options'; - + $BS_pro_version = defined('BOOSTER_SWEEPER_PRO_VERSION') ? BOOSTER_SWEEPER_PRO_VERSION : ''; + $print_pro_version = $BS_pro_version !== '' ? ' - Pro Version: ' .BOOSTER_SWEEPER_PRO_VERSION : ''; CSF::createOptions( $prefix, array( @@ -25,7 +26,7 @@ 'menu_slug' => 'booster-sweeper-settings', 'menu_icon' => 'dashicons-image-filter', - 'footer_credit' => 'Booster Sweeper v1.0.4', + 'footer_credit' => 'Booster Sweeper ' .BOOSTER_SWEEPER_VERSION .$print_pro_version .'', 'footer_text' => ' ', 'theme' => 'light', 'show_bar_menu' => false, diff --git a/booster-sweeper.php b/booster-sweeper.php index 48496db..4d8a60d 100644 --- a/booster-sweeper.php +++ b/booster-sweeper.php @@ -19,11 +19,19 @@ * Requires at least: 6.0 */ -if (! defined('ABSPATH')) { - exit; +if (! defined('ABSPATH')) { + exit; } - require_once 'classes/init.php'; - require_once 'classes/resources.php'; - require_once 'clean-html.php'; - require_once 'admin/admin-init.php'; +// Plugin data (getting plugin version, name, etc.) +if (! function_exists('get_plugin_data')) { + include_once ABSPATH .'wp-admin/includes/plugin.php'; +} +$plugin_data = get_plugin_data(__FILE__); +define('BOOSTER_SWEEPER', ($plugin_data && $plugin_data['Name']) ? $plugin_data['Name'] : 'Booster Sweeper'); +define('BOOSTER_SWEEPER_VERSION', ($plugin_data && $plugin_data['Version']) ? $plugin_data['Version'] : '1.0.0'); + +require_once 'classes/init.php'; +require_once 'classes/resources.php'; +require_once 'clean-html.php'; +require_once 'admin/admin-init.php'; diff --git a/classes/init.php b/classes/init.php index c9c668b..c194fca 100644 --- a/classes/init.php +++ b/classes/init.php @@ -20,22 +20,6 @@ class Booster_Sweeper { - /** - * Version. - * - * Also has to be updated in the framework settings' createOptions, - * - * @see /admin/opt/config/framework.php - */ - // phpcs:ignore - public static function version() - { - - $plugin_version = '1.0.4'; - return $plugin_version; - - } - /** * Load plugin's textdomain. * From f1d17daebee3975c2b125ebca4788f6de86a12df Mon Sep 17 00:00:00 2001 From: Slobodan Date: Sun, 12 Nov 2023 12:55:28 +0100 Subject: [PATCH 2/2] Bump a version --- booster-sweeper.php | 2 +- readme.txt | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/booster-sweeper.php b/booster-sweeper.php index 4d8a60d..bc4c26a 100644 --- a/booster-sweeper.php +++ b/booster-sweeper.php @@ -13,7 +13,7 @@ * * Author: MaxPressy * Author URI: https://maxpressy.com - * Version: 1.0.4 + * Version: 1.0.5 * Text Domain: booster_sweeper * Domain Path: /languages * Requires at least: 6.0 diff --git a/readme.txt b/readme.txt index e60d0c0..faaf9e6 100644 --- a/readme.txt +++ b/readme.txt @@ -2,8 +2,8 @@ Contributors: MaxPressy Tags: speed, performance, pagespeed, dequeue, seo, assets -Tested up to: 6.3 -Stable tag: 1.0.4 +Tested up to: 6.4 +Stable tag: 1.0.5 Requires at least: 6.0 Requires PHP: 7.3.5 License: GPLv2 or later @@ -66,6 +66,9 @@ After activating the plugin, in your WordPress Dashboard find the section "Boost == Changelog == += 1.0.5 - 2022-11-13 = +* Change the way the plugin version is retrieved and printed + = 1.0.4 - 2022-08-13 = * Update Fields framework * Compatibility with WP 6.3