inject_dependency_notice(); return; } add_action( 'elementor/init', [ $this, 'init' ] ); if (defined('APTFE_PRO_DIR_FILE')) { if (!class_exists(APTFEPRO\Classes\APTFEWidgetPro::class)) { require_once(APTFE_PRO_DIR_PATH.'Classes/APTFEWidgetPro.php'); } } } /** * Init Plugin */ public function init() { if ( is_admin() ) { $this->adminHooks(); } /** * Register Widgets */ add_action( 'elementor/widgets/register', [ $this, 'init_widgets' ] ); /** * Frontend Styles */ add_action( 'elementor/frontend/after_enqueue_styles', function () { wp_enqueue_style( 'aptfe-pricing-table', APTFE_PLUGIN_URL . 'assets/css/aptfe-pricing-table.css', [], APTFE_PLUGIN_VERSION ); }); /** * Editor Styles */ add_action( 'elementor/editor/after_enqueue_styles', function () { wp_enqueue_style( 'aptfe-editor-css', APTFE_PLUGIN_URL . 'assets/css/aptfe-editor.css', [], APTFE_PLUGIN_VERSION ); }); } public function adminHooks() { if (defined('APTFE_PRO')) { $licenseController = new APTFEPRO\Classes\LicenseController(); $licenseController->register(); } $setupController = new APTFE\Classes\SetupController(); $setupController->register(); if (defined('ELEMENTOR_VERSION')) { add_action('admin_init', [new APTFE\Classes\AdminPageHandler(), 'initialLoad']); } add_action( 'admin_notices', [$this, 'aptfe_admin_notice'] ); add_action( 'admin_init', [$this, 'aptfe_notice_dismissed'] ); } public function aptfe_admin_notice() { $screen = get_current_screen(); $user_id = get_current_user_id(); $nonce = wp_create_nonce('aptfe_dismiss_notice_nonce'); // Ensure user meta exists if (!get_user_meta($user_id, 'aptfe-notice-dismissed', true)) { add_user_meta($user_id, 'aptfe-notice-dismissed', 'active'); } // Show notice only on specific screens if ($screen && in_array($screen->id, ['dashboard', 'plugins'], true)) { if (get_user_meta($user_id, 'aptfe-notice-dismissed', true) === 'active') { ?>

register( new APTFE\Widgets\AdvancedPricingWidget() ); } /** * Elementor Dependency Notice */ protected function inject_dependency_notice() { add_action( 'admin_notices', function () { $plugin_info = $this->get_installation_details(); $class = 'notice notice-error'; $button_text = esc_html__( 'Install Elementor', 'advanced-pricing-table-for-elementor' ); if ( 'activate' === $plugin_info->action ) { $button_text = esc_html__( 'Activate Elementor', 'advanced-pricing-table-for-elementor' ); } $message = sprintf( '%1$s %3$s', esc_html__( 'Advanced Pricing Table For Elementor requires Elementor plugin.', 'advanced-pricing-table-for-elementor' ), esc_url( $plugin_info->url ), esc_html( $button_text ) ); printf( '

%2$s

', esc_attr( $class ), wp_kses_post( $message ) ); } ); } /** * Get Elementor Installation Details * * @return object */ protected function get_installation_details() { $activation = (object) [ 'action' => 'install', 'url' => '', ]; $all_plugins = get_plugins(); if ( isset( $all_plugins['elementor/elementor.php'] ) ) { $url = wp_nonce_url( self_admin_url( 'plugins.php?action=activate&plugin=elementor/elementor.php' ), 'activate-plugin_elementor/elementor.php' ); $activation->action = 'activate'; } else { $url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=elementor' ), 'install-plugin_elementor' ); } $activation->url = $url; return $activation; } } /** * Init Plugin */ APTFE_Pricing_Table_Lite::instance(); function APTFE_DeactivatePlugin() { $user_id = get_current_user_id(); update_user_meta($user_id, 'aptfe-notice-dismissed', 'active'); } register_deactivation_hook( __FILE__, 'APTFE_DeactivatePlugin' );