PluginProbe
NotificationX – FOMO, Live Sales Notification, WooCommerce Sales Popup, GDPR, Social Proof, Announcement Banner & Floating Notification Bar / trunk
NotificationX – FOMO, Live Sales Notification, WooCommerce Sales Popup, GDPR, Social Proof, Announcement Banner & Floating Notification Bar vtrunk
3.3.1 3.3.0 3.2.14 3.2.13 3.2.12 3.2.11 3.2.10 3.2.9 3.2.8 3.2.7 trunk 0.2.5.5 0.2.5.6 0.2.5.7 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.2.0 1.2.1 All 156 releases
← All changes | includes/NotificationX.php +57 -6 3.2.12trunk View file →
@@ -17,8 +17,9 @@
17 17 use NotificationX\Core\PostType;
18 18 use NotificationX\Core\QuickBuild;
19 19 use NotificationX\Core\REST;
20 20 use NotificationX\Core\ShortcodeInline;
21 +use NotificationX\Core\Targeting;
21 22 use NotificationX\Core\Upgrader;
22 23 use NotificationX\Extensions\GlobalFields;
23 24 use NotificationX\FrontEnd\FrontEnd;
24 25 use NotificationX\Types\TypeFactory;
@@ -38,8 +39,18 @@
38 39 * @var NotificationX
39 40 */
40 41 use GetInstance;
41 42 /**
43 + * Option flag recording that NotificationX has already gone through its
44 + * initial (first-ever) activation on this site.
45 + *
46 + * Set on the first activation and seeded for pre-existing installs by
47 + * Upgrader, so a re-activation is never mistaken for a first run.
48 + *
49 + * @since 3.3.0
50 + */
51 + const FIRST_ACTIVATION_OPTION = 'nx_first_activation';
52 + /**
42 53 * Settings
43 54 * @var Settings
44 55 */
45 56 public $settings;
@@ -77,8 +88,10 @@
77 88 /**
78 89 * Register all REST Endpoint
79 90 */
80 91 REST::get_instance();
92 + // Country/user-role targeting for ALL notification types (decoupled from the bar module).
93 + Targeting::get_instance();
81 94 Cron::get_instance();
82 95 QuickBuild::get_instance();
83 96 ShortcodeInline::get_instance();
84 97 Blocks::get_instance();
@@ -93,8 +106,12 @@
93 106 } else {
94 107 add_action( 'elementor/loaded', [ ElementorManager::class, 'get_instance' ] );
95 108 }
96 109 EntriesMailReceiver::get_instance();
110 +
111 + // MCP server (AI-assistant integration). Progressive enhancement:
112 + // loads only on a capable PHP runtime and stays off until enabled.
113 + \NotificationX\MCP\Bootstrap::init();
97 114 }
98 115 /**
99 116 * The Plugin Activator
100 117 * @return void
@@ -101,20 +118,51 @@
101 118 */
102 119 public function activator(){
103 120 // nx_activated
104 121 Database::get_instance()->Create_DB();
122 +
123 + // A first-ever activation is the only moment the onboarding wizard may
124 + // be auto-launched; an abandoned wizard still counts as "already
125 + // activated", so re-activations never force it again.
126 + $is_first_activation = ! self::has_activated_before();
127 + if ( $is_first_activation ) {
128 + update_option( self::FIRST_ACTIVATION_OPTION, time(), 'no' );
129 + }
130 +
105 131 if( ! static::$WP_CLI && current_user_can( 'delete_users' ) ) {
106 - set_transient( 'nx_activated', true, 30 );
132 + set_transient( 'nx_activated', $is_first_activation ? 'first' : 'again', 30 );
107 133 }
134 +
135 + // Usage insights are normally wired up on `init`, which WordPress has
136 + // already fired by the time it activates a plugin — so the
137 + // register_activation_hook() callback registered inside the insights
138 + // constructor never runs and the tracking event is left unscheduled.
139 + // Build the instance and run its activation routine explicitly here so
140 + // data collection is live from activation onwards.
141 + Admin::get_instance()->plugin_usage_insights()->activate_this_plugin();
142 +
108 143 Upgrader::get_instance()->clear_transient();
109 144 }
110 145
146 + /**
147 + * Whether NotificationX has already gone through its initial activation on
148 + * this site — i.e. it has been activated before, regardless of whether the
149 + * Setup Wizard was ever opened or completed.
150 + *
151 + * @since 3.3.0
152 + * @return bool
153 + */
154 + public static function has_activated_before() {
155 + return (bool) get_option( self::FIRST_ACTIVATION_OPTION, false );
156 + }
157 +
111 158 public function maybe_redirect(){
112 159 if( static::$WP_CLI || wp_doing_ajax() ) {
113 160 return;
114 161 }
115 162 // Bail if no activation transient is set.
116 - if ( ! get_transient( 'nx_activated' ) ) {
163 + $activation = get_transient( 'nx_activated' );
164 + if ( ! $activation ) {
117 165 return;
118 166 }
119 167 // Delete the activation transient.
120 168 delete_transient( 'nx_activated' );
@@ -119,12 +167,15 @@
119 167 // Delete the activation transient.
120 168 delete_transient( 'nx_activated' );
121 169
122 170 if ( ! is_multisite() ) {
123 - // First activation: launch the onboarding Setup Wizard, otherwise
124 - // fall back to the dashboard. The wizard marks itself completed on
125 - // finish/skip so this only fires once.
126 - $page = \NotificationX\Core\SetupWizard::is_completed() ? 'nx-dashboard' : 'nx-setup-wizard';
171 + // Only a genuine first-ever activation may launch the onboarding
172 + // Setup Wizard (and only while it has not been completed/skipped).
173 + // Every returning activation lands on the dashboard, as before.
174 + // Transients written by an older version hold `true`, which is
175 + // treated as a returning activation.
176 + $is_first_activation = ( 'first' === $activation );
177 + $page = ( $is_first_activation && ! \NotificationX\Core\SetupWizard::is_completed() ) ? 'nx-setup-wizard' : 'nx-dashboard';
127 178 wp_safe_redirect( add_query_arg( array(
128 179 'page' => $page
129 180 ), admin_url( 'admin.php' ) ) );
130 181 }