PluginProbe
NotificationX – FOMO, Live Sales Notification, WooCommerce Sales Popup, GDPR, Social Proof, Announcement Banner & Floating Notification Bar / 3.3.3
NotificationX – FOMO, Live Sales Notification, WooCommerce Sales Popup, GDPR, Social Proof, Announcement Banner & Floating Notification Bar v3.3.3
3.3.3 3.3.2 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 All 158 releases
← All changes | includes/Admin/Admin.php +86 -1 3.2.8 → 3.3.3 View file →
@@ -14,8 +14,11 @@
14 14 use NotificationX\Core\Analytics;
15 15 use NotificationX\Core\Dashboard;
16 16 use NotificationX\Core\Database;
17 17 use NotificationX\Core\PostType;
18 +use NotificationX\Core\SetupWizard;
19 +use NotificationX\Core\UsageTracker;
20 +use NotificationX\Core\Maintenance;
18 21 use NotificationX\Core\Upgrader;
19 22 use NotificationX\GetInstance;
20 23 use NotificationX\Extensions\ExtensionFactory;
21 24
@@ -40,8 +43,18 @@
40 43 const ASSET_URL = NOTIFICATIONX_ASSETS . 'admin/';
41 44 const ASSET_PATH = NOTIFICATIONX_ASSETS_PATH . 'admin/';
42 45 const VIEWS_PATH = NOTIFICATIONX_INCLUDES . 'Admin/views/';
43 46
47 + /**
48 + * Oldest NotificationX Pro that ships its own copy of the Pro features the
49 + * free plugin is removing (Flashing Tab, Cart Peek, Inline). Older Pro keeps
50 + * working with this release, but loses those features once the free copies
51 + * are deleted. See docs/api/frontend-js-hooks.md.
52 + *
53 + * @since 3.3.3
54 + */
55 + const MIN_PRO_VERSION = '3.2.3';
56 +
44 57 private $insights = null;
45 58
46 59 /**
47 60 * @var CacheBank
@@ -62,8 +75,10 @@
62 75 RatingEmail::get_instance();
63 76 ImportExport::get_instance();
64 77 XSS::get_instance();
65 78 InfoTooltipManager::get_instance();
79 + UsageTracker::get_instance();
80 + Maintenance::get_instance();
66 81 add_action('init', [$this, 'init'], 5);
67 82 add_filter('nx_rest_miscellaneous', [$this, 'handle_miscellaneous_actions'], 10, 2);
68 83 add_filter('nx_builder_configs', [$this, 'add_popup_status_to_context'], 10, 1);
69 84 }
@@ -74,10 +89,14 @@
74 89 *
75 90 * @return void
76 91 */
77 92 public function init(){
93 + // Usage insights/tracking must initialize regardless of Pro being
94 + // active: Pro ships no insights of its own, so gating this behind
95 + // !is_pro() left the put_do_weekly_action cron with no listener and
96 + // disabled tracking (incl. the UsageTracker payload) on every Pro site.
97 + $this->plugin_usage_insights();
78 98 if( ! NotificationX::is_pro() ){
79 - $this->plugin_usage_insights();
80 99 $this->admin_notices();
81 100 $is_embedpress_milestone_showing = get_option('is_embedpress_milestone_showing', false);
82 101 if (!$is_embedpress_milestone_showing) {
83 102 MilestoneNotification::get_instance();
@@ -84,9 +103,14 @@
84 103 }
85 104 }
86 105 add_action('admin_init', [$this, 'admin_init']);
87 106 add_action('admin_menu', [$this, 'menu'], 10);
107 + // all_admin_notices, not admin_notices: hide_others_plugin_admin_notice()
108 + // clears admin_notices on NotificationX screens, and this notice must
109 + // show there too.
110 + add_action('all_admin_notices', [$this, 'pro_version_notice']);
88 111 Dashboard::get_instance();
112 + SetupWizard::get_instance();
89 113 PostType::get_instance();
90 114 Settings::get_instance()->init();
91 115 Entries::get_instance();
92 116 Scanner::get_instance();
@@ -195,8 +219,52 @@
195 219 NoticeRemover::get_instance( '1.0.0' );
196 220 }
197 221
198 222
223 + /**
224 + * Whether the active NotificationX Pro is older than MIN_PRO_VERSION.
225 + *
226 + * @since 3.3.3
227 + * @param string|null $pro_version Pro version; defaults to NOTIFICATIONX_PRO_VERSION.
228 + * @return bool False when Pro is not active or its version is unknown.
229 + */
230 + public static function pro_needs_update( $pro_version = null ) {
231 + if ( null === $pro_version ) {
232 + if ( ! NotificationX::is_pro() || ! defined( 'NOTIFICATIONX_PRO_VERSION' ) ) {
233 + return false;
234 + }
235 + $pro_version = NOTIFICATIONX_PRO_VERSION;
236 + }
237 + if ( ! is_string( $pro_version ) || '' === $pro_version ) {
238 + return false;
239 + }
240 + return version_compare( $pro_version, self::MIN_PRO_VERSION, '<' );
241 + }
242 +
243 + /**
244 + * Non-dismissible notice asking to update an outdated NotificationX Pro.
245 + *
246 + * @since 3.3.3
247 + * @return void
248 + */
249 + public function pro_version_notice() {
250 + if ( ! current_user_can( 'update_plugins' ) || ! self::pro_needs_update() ) {
251 + return;
252 + }
253 + $message = sprintf(
254 + /* translators: 1: installed NotificationX Pro version, 2: required NotificationX Pro version. */
255 + __( 'You are using NotificationX Pro %1$s. Please update NotificationX Pro to version %2$s or later. Upcoming NotificationX releases move Flashing Tab, Cart Peek and Inline notifications fully into NotificationX Pro, and older Pro versions will stop showing them.', 'notificationx' ),
256 + '<strong>' . esc_html( NOTIFICATIONX_PRO_VERSION ) . '</strong>',
257 + '<strong>' . esc_html( self::MIN_PRO_VERSION ) . '</strong>'
258 + );
259 + printf(
260 + '<div class="notice notice-warning nx-pro-version-notice"><p>%1$s <a href="%2$s">%3$s</a></p></div>',
261 + wp_kses_post( $message ),
262 + esc_url( self_admin_url( 'plugins.php?plugin_status=upgrade' ) ),
263 + esc_html__( 'Go to plugin updates', 'notificationx' )
264 + );
265 + }
266 +
199 267 public function hide_others_plugin_admin_notice()
200 268 {
201 269 $current_screen = get_current_screen();
202 270 $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'];
@@ -409,8 +477,11 @@
409 477 self::$cache_bank->calculate_deposits( $notices );
410 478 }
411 479
412 480 public function plugin_usage_insights(){
481 + if ( null !== $this->insights ) {
482 + return $this->insights;
483 + }
413 484 $this->insights = PluginInsights::get_instance( NOTIFICATIONX_FILE, [
414 485 'opt_in' => true,
415 486 'goodbye_form' => true,
416 487 'item_id' => '6ba8d30bc0beaddb2540'
@@ -422,8 +493,10 @@
422 493 discount coupon. This data lets us make sure this plugin always stays compatible with the most
423 494 popular plugins and themes. No spam, I promise.', 'notificationx' ),
424 495 ));
425 496 $this->insights->init();
497 +
498 + return $this->insights;
426 499 }
427 500
428 501 /**
429 502 * Handle miscellaneous REST API actions
@@ -469,8 +542,20 @@
469 542 }
470 543
471 544 // Don't show for non-admin users
472 545 if (!current_user_can('manage_options')) {
546 + return false;
547 + }
548 +
549 + // Delay the popup until 1 day after installation. Quick Setup already
550 + // handles onboarding, so this stays out of the way on the first day.
551 + $install_time = get_option('nx_initial_popup_install_time', false);
552 + if (!$install_time) {
553 + $install_time = time();
554 + update_option('nx_initial_popup_install_time', $install_time);
555 + }
556 +
557 + if ((time() - (int) $install_time) < DAY_IN_SECONDS) {
473 558 return false;
474 559 }
475 560
476 561 return true;