plugin_usage_insights(); if( ! NotificationX::is_pro() ){ $this->admin_notices(); $is_embedpress_milestone_showing = get_option('is_embedpress_milestone_showing', false); if (!$is_embedpress_milestone_showing) { MilestoneNotification::get_instance(); } } add_action('admin_init', [$this, 'admin_init']); add_action('admin_menu', [$this, 'menu'], 10); Dashboard::get_instance(); SetupWizard::get_instance(); PostType::get_instance(); Settings::get_instance()->init(); Entries::get_instance(); Scanner::get_instance(); } /** * This method is responsible for Admin Menu of * NotificationX * * @return void */ public function admin_init(){ DashboardWidget::get_instance(); add_action('in_admin_header', [ $this, 'hide_others_plugin_admin_notice' ], 99); } /** * This method is reponsible for Admin Menu of * NotificationX * * @return void */ public function menu(){ add_menu_page( 'NotificationX', 'NotificationX', 'read_notificationx', // User Permision. 'nx-admin', array( $this, 'views' ), self::ASSET_URL . 'images/logo-icon.svg', 80 ); add_submenu_page( 'nx-admin', __('All NotificationX', 'notificationx'), __('All NotificationX', 'notificationx'), 'read_notificationx', 'nx-admin', null, 1 ); } /** * Admin Views * * @return void */ public function views() { // react script included in PostType::admin_enqueue_scripts(); include_once Admin::VIEWS_PATH . 'main.views.php'; } /** * Get File Modification Time or URL * * @param string $file File relative path for Admin * @param boolean $url true for URL return * @return void|string|integer */ public function file( $file, $url = false ){ if( $url ) { return self::ASSET_URL . $file; } return filemtime( self::ASSET_PATH . $file ); } /** * This method is responsible for re generating notification for single type. * @param string $current_url * @since 1.4.0 */ public function regenerate_notifications($params) { $post_id = intval($params['nx_id']); // @todo should not query the settings here. source and other two should be passed in param. $post = PostType::get_instance()->get_post($post_id); $source = isset($post['source']) ? $post['source'] : false; $extension = ExtensionFactory::get_instance()->get($source); if (!empty($extension) && method_exists($extension, 'get_notification_ready') && $extension->is_active()) { Entries::get_instance()->delete_entries($post_id); $result = $extension->get_notification_ready($post, $post_id); return true; } return false; } /** * This method is responsible for re generating notification for single type. * @param string $current_url * @since 1.4.0 */ public function reset_notifications($params) { $nx_id = null; if (!empty($entry_key)) { $nx_id = $params['entry_key']; } if (!empty($params['nx_id'])) { $nx_id = $params['nx_id']; } if (!empty($nx_id)) { return Analytics::get_instance()->delete_analytics($nx_id); } } public function admin_notices(){ self::$cache_bank = CacheBank::get_instance(); try { $this->notices(); } catch ( \Exception $e ) { unset( $e ); } // Remove OLD notice from 1.0.0 (if other WPDeveloper plugin has notice) NoticeRemover::get_instance( '1.0.0' ); } public function hide_others_plugin_admin_notice() { $current_screen = get_current_screen(); $hide_on = ['toplevel_page_nx-admin', 'notificationx_page_nx-dashboard', 'notificationx_page_nx-edit','notificationx_page_nx-settings','notificationx_page_nx-analytics','notificationx_page_nx-builder', 'notificationx_page_nx-feedback-entries']; if ( $current_screen && isset( $current_screen->base ) && in_array($current_screen->base, $hide_on) ) { remove_all_actions('user_admin_notices'); remove_all_actions('admin_notices'); } } public function notices() { $notices = new Notices([ 'id' => 'notificationx', 'store' => 'options', 'storage_key' => 'notices', 'version' => '1.0.0', 'lifetime' => 3, 'stylesheet_url' => '', 'styles' => self::ASSET_URL . 'css/wpdeveloper-review-notice.css', 'priority' => 5, // 'dev_mode' => true ]); $_review_notice = [ 'thumbnail' => self::ASSET_URL . 'images/nx-icon.svg', 'html' => '

'. __( 'We hope you\'re enjoying NotificationX! Could you please do us a BIG favor and give it a 5-star rating on WordPress to help us spread the word and boost our motivation?', 'notificationx' ) .'

', 'links' => [ 'later' => array( 'link' => 'https://wpdeveloper.com/review-notificationx', 'target' => '_blank', 'label' => __( 'Ok, you deserve it!', 'notificationx' ), 'icon_class' => 'dashicons dashicons-external', ), 'allready' => array( 'label' => __( 'I already did', 'notificationx' ), 'icon_class' => 'dashicons dashicons-smiley', 'attributes' => [ 'data-dismiss' => true ], ), 'maybe_later' => array( 'label' => __( 'Maybe Later', 'notificationx' ), 'icon_class' => 'dashicons dashicons-calendar-alt', 'attributes' => [ 'data-later' => true ], ), 'support' => array( 'link' => 'https://wpdeveloper.com/support', 'label' => __( 'I need help', 'notificationx' ), 'icon_class' => 'dashicons dashicons-sos', ), 'never_show_again' => array( 'label' => __( 'Never show again', 'notificationx' ), 'icon_class' => 'dashicons dashicons-dismiss', 'attributes' => [ 'data-dismiss' => true ], ) ] ]; $notices->add( 'review', $_review_notice, [ 'start' => $notices->strtotime( '+7 day' ), 'recurrence' => 30, 'dismissible' => true, 'refresh' => NOTIFICATIONX_VERSION, ] ); $notices->add( 'opt_in', [ $this->insights, 'notice' ], [ 'classes' => 'updated put-dismiss-notice', 'start' => $notices->strtotime( '+30 days' ), 'dismissible' => true, 'refresh' => NOTIFICATIONX_VERSION, 'do_action' => 'wpdeveloper_notice_clicked_for_notificationx', 'display_if' => ! is_array( $notices->is_installed( 'notificationx-pro/notificationx-pro.php' ) ) ] ); $notice_text = sprintf('
%s %s
', __( '

Black Friday Exclusive: SAVE up to 40% & access to NotificationX Pro features.

', 'notificationx' ), esc_url( 'https://notificationx.com/#pricing' ), __('Grab The Offer', 'notificationx') ); $_black_friday = [ 'thumbnail' => self::ASSET_URL . 'images/nx-icon.svg', 'html' => $notice_text, ]; $notices->add( 'black_friday', $_black_friday, [ 'start' => $notices->time(), 'recurrence' => false, 'dismissible' => true, 'expire' => strtotime( 'Wed, 30 Nov 2022 23:59:59 GMT' ), 'display_if' => ! is_array( $notices->is_installed( 'notificationx-pro/notificationx-pro.php' ) ) ] ); // New Notice $b_message = '

6th Anniversary Sale: Unlock premium features with up to 25% discounts & skyrocket your conversions 🚀

Upgrade to PRO'; $_black_friday_notice = [ 'thumbnail' => self::ASSET_URL . 'images/full-logo.svg', 'html' => $b_message, ]; $notices->add( '6th_anniversary', $_black_friday_notice, [ 'start' => $notices->time(), 'recurrence' => false, 'dismissible' => true, 'refresh' => NOTIFICATIONX_VERSION, "expire" => strtotime( '11:59:59pm 20th September, 2024' ), // 'display_if' => ! is_plugin_active( 'notificationx-pro/notificationx-pro.php' ) ] ); $crown = self::ASSET_URL . 'images/crown.svg'; // February Deal $_february_deal = "

Boost trust & conversions with real-time social proof notification alerts – now Flat 20% OFF! 🎁

Upgrade To PRO I’ll Grab It Later
"; $_february_deal_html = [ 'thumbnail' => self::ASSET_URL . 'images/full-logo.svg', 'html' => $_february_deal, ]; $notices->add( 'nx_february_deal', $_february_deal_html, [ 'start' => strtotime('11:59:59pm 9th February, 2026'), 'recurrence' => false, 'dismissible' => true, 'refresh' => NOTIFICATIONX_VERSION, 'screens' => [ 'dashboard' ], "expire" => strtotime('11:59:59pm 7th March, 2026'), 'display_if' => !is_array( $notices->is_installed( 'notificationx-pro/notificationx-pro.php' ) ) ] ); // Spring Campaign 2026 $_spring_deal = "

🌸 Spring Savings: Boost conversions with real-time social proof & AI-powered notification alerts – now Flat 25% OFF! ⚡️

Upgrade To Pro Now Maybe Later
"; $_spring_deal_html = [ 'thumbnail' => self::ASSET_URL . 'images/full-logo.svg', 'html' => $_spring_deal, ]; $notices->add( 'nx_spring_deal_2026', $_spring_deal_html, [ 'start' => strtotime('12:00:00am 8th April, 2026'), 'recurrence' => false, 'dismissible' => true, 'refresh' => NOTIFICATIONX_VERSION, 'screens' => [ 'dashboard' ], "expire" => strtotime('11:59:59pm 10th May, 2026'), 'display_if' => !is_array( $notices->is_installed( 'notificationx-pro/notificationx-pro.php' ) ) ] ); // nx_summer_deal_2026 notice $_nx_summer_deal_2026_text = "

🏖️ Turn visitors into buyers — faster. Launch real-time social proof & AI-powered alerts that drive conversions - up to \$150 OFF!

Upgrade To Pro Now I Don't Want Any Discount
"; $_nx_summer_deal_2026 = [ 'thumbnail' => self::ASSET_URL . 'images/full-logo.svg', 'html' => $_nx_summer_deal_2026_text, ]; $notices->add( 'nx_summer_deal_2026', $_nx_summer_deal_2026, [ 'start' => $notices->time(), 'recurrence' => false, 'dismissible' => true, 'refresh' => NOTIFICATIONX_VERSION, 'screens' => [ 'dashboard' ], "expire" => strtotime( '11:59:59pm 25th June, 2026' ), 'display_if' => !is_array( $notices->is_installed( 'notificationx-pro/notificationx-pro.php' ) ) ] ); // $notices->init(); self::$cache_bank->create_account( $notices ); self::$cache_bank->calculate_deposits( $notices ); } public function plugin_usage_insights(){ if ( null !== $this->insights ) { return $this->insights; } $this->insights = PluginInsights::get_instance( NOTIFICATIONX_FILE, [ 'opt_in' => true, 'goodbye_form' => true, 'item_id' => '6ba8d30bc0beaddb2540' ] ); $this->insights->set_notice_options(array( 'notice' => __( 'Want to help make NotificationX even more awesome? You can get a 10% discount coupon for Premium extensions if you allow us to track the usage.', 'notificationx' ), 'extra_notice' => __( 'We collect non-sensitive diagnostic data and plugin usage information. Your site URL, WordPress & PHP version, plugins & themes and email address to send you the discount coupon. This data lets us make sure this plugin always stays compatible with the most popular plugins and themes. No spam, I promise.', 'notificationx' ), )); $this->insights->init(); return $this->insights; } /** * Handle miscellaneous REST API actions * * @param mixed $result * @param array $params * @return mixed */ public function handle_miscellaneous_actions($result, $params) { if (isset($params['action']) && $params['action'] === 'dismiss_initial_popup') { return $this->dismiss_initial_popup(); } return $result; } /** * Dismiss the initial popup * * @return bool */ public function dismiss_initial_popup() { // Check user permissions if (!current_user_can('manage_options')) { return false; } // Update the option to mark popup as dismissed update_option('nx_force_popup_dismissed', '1'); $result = update_option('nx_initial_popup_dismissed', true); return $result; } /** * Check if popup should be shown * * @return bool */ public function should_show_initial_popup() { // Don't show if already dismissed if (get_option('nx_initial_popup_dismissed', false)) { return false; } // Don't show for non-admin users if (!current_user_can('manage_options')) { return false; } // Delay the popup until 1 day after installation. Quick Setup already // handles onboarding, so this stays out of the way on the first day. $install_time = get_option('nx_initial_popup_install_time', false); if (!$install_time) { $install_time = time(); update_option('nx_initial_popup_install_time', $install_time); } if ((time() - (int) $install_time) < DAY_IN_SECONDS) { return false; } return true; } /** * Add popup status to admin context * * @param array $data * @return array */ public function add_popup_status_to_context($data) { $data['show_initial_popup'] = $this->should_show_initial_popup(); $data['nx_admin_notice_close'] = get_option('nx_admin_notice_close', false); return $data; } }