From b961f043625c20180519b7659a0fbdc6c3d68661 Mon Sep 17 00:00:00 2001 From: Nicola Peluchetti Date: Tue, 1 Oct 2024 12:45:31 +0200 Subject: [PATCH] rename --- includes/utils.php | 31 +++++++++++-------- .../classes/elementor/elementor-helper.php | 26 ---------------- .../classes/rest/onboarding-settings.php | 6 ++-- modules/admin/classes/rest/promotions.php | 6 ++-- ...rest-controller.php => api-controller.php} | 2 +- modules/admin/module.php | 2 +- 6 files changed, 26 insertions(+), 47 deletions(-) delete mode 100644 modules/admin/classes/elementor/elementor-helper.php rename modules/admin/components/{rest-controller.php => api-controller.php} (96%) diff --git a/includes/utils.php b/includes/utils.php index 78208757..1cc1874d 100644 --- a/includes/utils.php +++ b/includes/utils.php @@ -9,23 +9,28 @@ * class Utils **/ class Utils { - /** - * @static - * @access public - * - * @return \Elementor\Plugin - */ + + private static $elementor_installed = null; + + private static $elementor_active = null; + public static function elementor(): \Elementor\Plugin { return \Elementor\Plugin::$instance; } - /** - * @static - * @access public - * - * @return bool - */ public static function is_elementor_active(): bool { - return defined( 'ELEMENTOR_VERSION' ); + if ( null === self::$elementor_active ) { + self::$elementor_active = defined( 'ELEMENTOR_VERSION' ); + } + + return self::$elementor_active; + } + + public static function is_elementor_installed() { + if ( null === self::$elementor_installed ) { + self::$elementor_installed = file_exists( WP_PLUGIN_DIR . '/elementor/elementor.php' ); + } + + return self::$elementor_installed; } } diff --git a/modules/admin/classes/elementor/elementor-helper.php b/modules/admin/classes/elementor/elementor-helper.php deleted file mode 100644 index d193b738..00000000 --- a/modules/admin/classes/elementor/elementor-helper.php +++ /dev/null @@ -1,26 +0,0 @@ - [ 'nonce' => $nonce, - 'elementorInstalled' => Elementor_Helper::is_elementor_installed(), - 'elementorActive' => Elementor_Helper::is_elementor_active(), + 'elementorInstalled' => Utils::is_elementor_installed(), + 'elementorActive' => Utils::is_elementor_active(), ], ] ); diff --git a/modules/admin/classes/rest/promotions.php b/modules/admin/classes/rest/promotions.php index 1f78f04c..09a7e29e 100644 --- a/modules/admin/classes/rest/promotions.php +++ b/modules/admin/classes/rest/promotions.php @@ -2,7 +2,7 @@ namespace HelloPlus\Modules\Admin\Classes\Rest; -use HelloPlus\Modules\Admin\Classes\Elementor\Elementor_Helper; +use HelloPlus\Includes\Utils; use WP_REST_Server; if ( ! defined( 'ABSPATH' ) ) { @@ -33,7 +33,7 @@ function () { } public function get_promotions() { - if ( ! Elementor_Helper::is_elementor_installed() ) { + if ( ! Utils::is_elementor_installed() ) { $action_links_data[] = [ 'type' => 'install-elementor', 'url' => wp_nonce_url( @@ -54,7 +54,7 @@ public function get_promotions() { ]; } - if ( ! Elementor_Helper::is_elementor_active() ) { + if ( ! Utils::is_elementor_active() ) { $action_links_data[] = [ 'type' => 'activate-elementor', 'image' => HELLO_PLUS_URL . '/assets/images/elementor.svg', diff --git a/modules/admin/components/rest-controller.php b/modules/admin/components/api-controller.php similarity index 96% rename from modules/admin/components/rest-controller.php rename to modules/admin/components/api-controller.php index e6a0b0f5..d9aac8b2 100644 --- a/modules/admin/components/rest-controller.php +++ b/modules/admin/components/api-controller.php @@ -8,7 +8,7 @@ use HelloPlus\Modules\Admin\Classes\Rest\Promotions; -class Rest_Controller { +class Api_Controller { protected $endpoints = []; diff --git a/modules/admin/module.php b/modules/admin/module.php index 18279ffa..08f8fdac 100644 --- a/modules/admin/module.php +++ b/modules/admin/module.php @@ -28,7 +28,7 @@ public static function get_name(): string { protected function get_component_ids(): array { return [ 'Plugin_Notice', - 'Rest_Controller', + 'Api_Controller', 'Admin_Menu_Controller', 'Admin_Top_Bar', 'Scripts_Controller',