is_compatible() ) { add_action( 'elementor/init', [ $this, 'init' ] ); } add_action( 'admin_notices', [$this, 'aic_admin_Notice'] ); add_action( 'admin_init', [$this, 'aic_notice_dismissed'] ); } public function aic_admin_Notice() { //get the current screen $screen = get_current_screen(); //Checks if settings updated $user_id = get_current_user_id(); $nonce = wp_create_nonce('aic_dismiss_notice_nonce'); if (!get_user_meta( $user_id, 'aic-notice-dismissed', true )) { add_user_meta($user_id, 'aic-notice-dismissed', 'active'); } if ( $screen->id == 'dashboard' || $screen->id == 'plugins' ) { if ( get_user_meta( $user_id, 'aic-notice-dismissed', true ) == 'active' ) { ?>

Rating

=' ) ) { add_action( 'admin_notices', [ $this, 'admin_notice_minimum_elementor_version' ] ); return false; } // Check for required PHP version if ( version_compare( PHP_VERSION, self::MINIMUM_PHP_VERSION, '<' ) ) { add_action( 'admin_notices', [ $this, 'admin_notice_minimum_php_version' ] ); return false; } return true; } /** * Initialize the plugin * * Load the plugin only after Elementor (and other plugins) are loaded. * Load the files required to run the plugin. * * Fired by `plugins_loaded` action hook. * * @since 2.0.4 * * @access public */ public function init() { $this->loadTextDomain(); // Add Plugin actions add_action( 'elementor/widgets/register', [ $this, 'init_widgets' ] ); add_action('elementor/frontend/after_enqueue_styles', function() { wp_enqueue_style( 'aic-image-comparison', plugin_dir_url( __FILE__ ). 'assets/css/aic_image_comparison.css', array(), AIC_PLUGIN_VERSION); wp_enqueue_style( 'aic-twentytwenty', plugin_dir_url( __FILE__ ). 'assets/css/twentytwenty.css', array(), AIC_PLUGIN_VERSION); }); // after_enqueue_scripts add_action('elementor/frontend/after_enqueue_scripts', function() { wp_enqueue_script( 'aic-move-js', plugin_dir_url( __FILE__ ). 'assets/js/jquery.event.move.js', array('jquery'), AIC_PLUGIN_VERSION, true); wp_enqueue_script( 'aic-twentytwenty-js', plugin_dir_url( __FILE__ ). 'assets/js/jquery.twentytwenty.js', array('jquery'), AIC_PLUGIN_VERSION, true); wp_enqueue_script( 'aic-custom-js', plugin_dir_url( __FILE__ ). 'assets/js/custom.js', array('jquery'), AIC_PLUGIN_VERSION, true); }); } /** * Init Widgets * * Include widgets files and register them * * @since 2.0.4 * * @access public */ public function init_widgets($widgets_manager) { // Include Widget files require_once( __DIR__ . '/widgets/AICImageComparisonWidget.php' ); // Register widget $widgets_manager->register( new AIC\Classes\Widgets\AICImageComparisonWidget() ); } public function loadTextDomain() { load_plugin_textdomain('advanced-image-comparison-for-elementor', false, basename(dirname(__FILE__)) . '/languages'); } /** * Admin notice * * Warning when the site doesn't have Elementor installed or activated. * * @since 2.0.4 * * @access public */ public function admin_notice_missing_main_plugin() { if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] ); $message = sprintf( /* translators: 1: Plugin name 2: Elementor */ esc_html__( '"%1$s" requires "%2$s" to be installed and activated.', 'advanced-image-comparison-for-elementor' ), '' . esc_html__( 'Advanced Image Comparison', 'advanced-image-comparison-for-elementor' ) . '', '' . esc_html__( 'Elementor', 'advanced-image-comparison-for-elementor' ) . '' ); printf( '

%1$s

', wp_kses_post($message) ); } /** * Admin notice * * Warning when the site doesn't have a minimum required Elementor version. * * @since 2.0.4 * * @access public */ public function admin_notice_minimum_elementor_version() { if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] ); $message = sprintf( /* translators: 1: Plugin name 2: Elementor 3: Required Elementor version */ esc_html__( '"%1$s" requires "%2$s" version %3$s or greater.', 'advanced-image-comparison-for-elementor' ), '' . esc_html__( 'Advanced Image Comparison', 'advanced-image-comparison-for-elementor' ) . '', '' . esc_html__( 'Elementor', 'advanced-image-comparison-for-elementor' ) . '', self::MINIMUM_ELEMENTOR_VERSION ); printf( '

%1$s

', wp_kses_post($message) ); } /** * Admin notice * * Warning when the site doesn't have a minimum required PHP version. * * @since 2.0.4 * * @access public */ public function admin_notice_minimum_php_version() { if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] ); $message = sprintf( /* translators: 1: Plugin name 2: PHP 3: Required PHP version */ esc_html__( '"%1$s" requires "%2$s" version %3$s or greater.', 'advanced-image-comparison-for-elementor' ), '' . esc_html__( 'Advanced Image Comparison', 'advanced-image-comparison-for-elementor' ) . '', '' . esc_html__( 'PHP', 'advanced-image-comparison-for-elementor' ) . '', self::MINIMUM_PHP_VERSION ); printf( '

%1$s

', wp_kses_post($message) ); } } AdvancedImageComparison::instance(); function deactivatePlugin() { $user_id = get_current_user_id(); update_user_meta($user_id, 'aic-notice-dismissed', 'active'); } register_deactivation_hook( __FILE__, 'deactivatePlugin' );