| @@ -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 | |
| @@ -62,8 +65,10 @@ | ||
| 62 | 65 | RatingEmail::get_instance(); |
| 63 | 66 | ImportExport::get_instance(); |
| 64 | 67 | XSS::get_instance(); |
| 65 | 68 | InfoTooltipManager::get_instance(); |
| 69 | + UsageTracker::get_instance(); | |
| 70 | + Maintenance::get_instance(); | |
| 66 | 71 | add_action('init', [$this, 'init'], 5); |
| 67 | 72 | add_filter('nx_rest_miscellaneous', [$this, 'handle_miscellaneous_actions'], 10, 2); |
| 68 | 73 | add_filter('nx_builder_configs', [$this, 'add_popup_status_to_context'], 10, 1); |
| 69 | 74 | } |
| @@ -74,10 +79,14 @@ | ||
| 74 | 79 | * |
| 75 | 80 | * @return void |
| 76 | 81 | */ |
| 77 | 82 | public function init(){ |
| 83 | + // Usage insights/tracking must initialize regardless of Pro being | |
| 84 | + // active: Pro ships no insights of its own, so gating this behind | |
| 85 | + // !is_pro() left the put_do_weekly_action cron with no listener and | |
| 86 | + // disabled tracking (incl. the UsageTracker payload) on every Pro site. | |
| 87 | + $this->plugin_usage_insights(); | |
| 78 | 88 | if( ! NotificationX::is_pro() ){ |
| 79 | - $this->plugin_usage_insights(); | |
| 80 | 89 | $this->admin_notices(); |
| 81 | 90 | $is_embedpress_milestone_showing = get_option('is_embedpress_milestone_showing', false); |
| 82 | 91 | if (!$is_embedpress_milestone_showing) { |
| 83 | 92 | MilestoneNotification::get_instance(); |
| @@ -85,8 +94,9 @@ | ||
| 85 | 94 | } |
| 86 | 95 | add_action('admin_init', [$this, 'admin_init']); |
| 87 | 96 | add_action('admin_menu', [$this, 'menu'], 10); |
| 88 | 97 | Dashboard::get_instance(); |
| 98 | + SetupWizard::get_instance(); | |
| 89 | 99 | PostType::get_instance(); |
| 90 | 100 | Settings::get_instance()->init(); |
| 91 | 101 | Entries::get_instance(); |
| 92 | 102 | Scanner::get_instance(); |
| @@ -409,8 +419,11 @@ | ||
| 409 | 419 | self::$cache_bank->calculate_deposits( $notices ); |
| 410 | 420 | } |
| 411 | 421 | |
| 412 | 422 | public function plugin_usage_insights(){ |
| 423 | + if ( null !== $this->insights ) { | |
| 424 | + return $this->insights; | |
| 425 | + } | |
| 413 | 426 | $this->insights = PluginInsights::get_instance( NOTIFICATIONX_FILE, [ |
| 414 | 427 | 'opt_in' => true, |
| 415 | 428 | 'goodbye_form' => true, |
| 416 | 429 | 'item_id' => '6ba8d30bc0beaddb2540' |
| @@ -422,8 +435,10 @@ | ||
| 422 | 435 | discount coupon. This data lets us make sure this plugin always stays compatible with the most |
| 423 | 436 | popular plugins and themes. No spam, I promise.', 'notificationx' ), |
| 424 | 437 | )); |
| 425 | 438 | $this->insights->init(); |
| 439 | + | |
| 440 | + return $this->insights; | |
| 426 | 441 | } |
| 427 | 442 | |
| 428 | 443 | /** |
| 429 | 444 | * Handle miscellaneous REST API actions |
| @@ -469,8 +484,20 @@ | ||
| 469 | 484 | } |
| 470 | 485 | |
| 471 | 486 | // Don't show for non-admin users |
| 472 | 487 | if (!current_user_can('manage_options')) { |
| 488 | + return false; | |
| 489 | + } | |
| 490 | + | |
| 491 | + // Delay the popup until 1 day after installation. Quick Setup already | |
| 492 | + // handles onboarding, so this stays out of the way on the first day. | |
| 493 | + $install_time = get_option('nx_initial_popup_install_time', false); | |
| 494 | + if (!$install_time) { | |
| 495 | + $install_time = time(); | |
| 496 | + update_option('nx_initial_popup_install_time', $install_time); | |
| 497 | + } | |
| 498 | + | |
| 499 | + if ((time() - (int) $install_time) < DAY_IN_SECONDS) { | |
| 473 | 500 | return false; |
| 474 | 501 | } |
| 475 | 502 | |
| 476 | 503 | return true; |