setup(); } return self::$instance; } private function setup() { register_activation_hook( __FILE__, [$this, 'auto_deactivate'] ); if ( ! $this->is_supported_php() ) { return; } if ( ! $this->is_directorist_active() ) { add_action( 'admin_notices', [$this, 'directorist_required_notice'] ); return; } if ( ! defined( 'ATBDP_VERSION' ) || ATBDP_VERSION < '8.0.0' ) { add_action( 'admin_notices', [$this, 'directorist_required_version_notice'] ); return; } $this->define_constants(); $this->includes(); $this->app = \AddonskitForElementor\App::initialize(); do_action( 'addonskit_for_elementor_loaded' ); } public function is_directorist_active(): bool { if ( ! function_exists( 'is_plugin_active' ) ) { include_once ABSPATH . '/wp-admin/includes/plugin.php'; } return is_plugin_active( 'directorist/directorist-base.php' ); } public function directorist_required_notice() { $message = sprintf( // translators: %1$s: opening strong tag, %2$s: closing strong tag esc_html__('%1$sDirectorist Addons Kit for Elementor%2$s requires %1$sDirectorist%2$s plugin to be installed and activated.', 'addonskit-for-elementor'), '', '' ); printf( '

%s

', wp_kses($message, [ 'strong' => [] ]) ); } public function directorist_required_version_notice() { $message = sprintf( // translators: %1$s: opening strong tag, %2$s: closing strong tag esc_html__('The current version of your %1$sDirectorist is not compatible with Directorist Addons Kit for Elementor%2$s. To ensure compatibility and access new features, %1$s update Directorist to version 8.0 or later%2$s.', 'addonskit-for-elementor'), '', '' ); printf( '

%s

', wp_kses($message, [ 'strong' => [], 'nbsp' => [] ]) ); } public function is_supported_php(): bool { if ( version_compare( PHP_VERSION, $this->min_php, '<' ) ) { return false; } return true; } public function auto_deactivate(): void { if ( $this->is_supported_php() ) { return; } deactivate_plugins( basename( __FILE__ ) ); $error = '

' . esc_html__( 'An Error Occurred', 'addonskit-for-elementor' ) . '

'; // translators: %s: PHP version number $error .= sprintf( '%s%s%s', esc_html__( '

Your installed PHP Version is: ', 'addonskit-for-elementor' ), esc_html(PHP_VERSION), '

' ); $error .= sprintf( // translators: %s: minimum required PHP version '

' . esc_html__( 'The Addonskit For Elementor plugin requires PHP version %s or greater.', 'addonskit-for-elementor' ) . '

', '' . esc_html( $this->min_php ) . '' ); $error .= sprintf( '

' . // translators: %s: link to PHP supported versions esc_html__( 'The version of your PHP is %s. You should update your PHP software or contact your host regarding this matter.', 'addonskit-for-elementor' ) . '

', '' . esc_html__( 'unsupported and old', 'addonskit-for-elementor' ) . '' ); wp_die( wp_kses_post($error), esc_html__( 'Plugin Activation Error', 'addonskit-for-elementor' ), [ 'response' => 200, 'back_link' => true, ] ); } public function is_plugin_installed( $basename ) { if ( ! function_exists( 'get_plugins' ) ) { include_once ABSPATH . '/wp-admin/includes/plugin.php'; } $installed_plugins = get_plugins(); return isset( $installed_plugins[$basename] ); } /** * Define the constants * * @return void */ private function define_constants(): void { define( 'AKFE_VERSION', $this->version ); define( 'AKFE_FILE', __FILE__ ); define( 'AKFE_PATH', dirname( AKFE_FILE ) ); define( 'AKFE_ELEMENTS', AKFE_PATH . 'app/Elements' ); define( 'AKFE_URL', plugins_url( '', AKFE_FILE ) ); define( 'AKFE_ASSETS', AKFE_URL . '/assets' ); } /** * Include the required files * * @return void */ private function includes() { include __DIR__ . '/vendor/autoload.php'; } } /** * Init the AddonskitForElementor plugin * * @return AddonskitForElementor the plugin object */ function AddonskitForElementor(): void { add_action( 'plugins_loaded', ['AddonskitForElementor', 'init'] ); } // kick it off AddonskitForElementor();