PluginProbe
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell / 3.13.3
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell v3.13.3
3.13.3 3.13.2 3.13.1 3.13.0 3.12.13 3.12.12 3.12.11 3.12.10 3.12.9 3.12.8 3.12.7 3.12.6 3.12.5 3.12.4 3.12.3 3.12.1 3.12.2 3.12.0 3.11.1 3.11.0 3.10.9 3.10.8 3.10.7 3.10.6 2.8.16 All 261 releases
← All changes | includes/utils/class-wpfnl-activator.php +78 -0 3.12.13 → 3.13.3 View file →
@@ -33,8 +33,18 @@
33 33 */
34 34 const BUILDER_MODE_PINNED_OPTION = 'wpfunnels_builder_mode_pinned';
35 35
36 36 /**
37 + * Flags that a fresh install still owes the revenue report its schedule.
38 + *
39 + * Set while seeding on activation and cleared once Action Scheduler is
40 + * loaded and the recurring action is queued.
41 + *
42 + * @since 3.14.0
43 + */
44 + const REVENUE_REPORT_PENDING_OPTION = 'wpfunnels_revenue_report_pending_schedule';
45 +
46 + /**
37 47 * Seconds to wait before re-queuing a DB update callback that reported
38 48 * more work to do. Throttles a misbehaving callback instead of letting it
39 49 * saturate the ActionScheduler queue runner.
40 50 *
@@ -75,8 +85,9 @@
75 85 add_action( 'init', array( __CLASS__, 'maybe_pin_legacy_builder_mode' ), 1 );
76 86 add_action( 'init', array( __CLASS__, 'update' ), 20 );
77 87 add_action('wpfunnels_run_update_callback', array( __CLASS__, 'run_update_callback' ) );
78 88 add_action( 'init', array( __CLASS__, 'maybe_schedule_runaway_purge' ), 21 );
89 + add_action( 'init', array( __CLASS__, 'maybe_schedule_seeded_revenue_report' ), 21 );
79 90 add_action( self::RUNAWAY_PURGE_HOOK, array( __CLASS__, 'purge_runaway_update_actions' ) );
80 91 }
81 92
82 93 /**
@@ -368,8 +379,9 @@
368 379 self::update_installed_time();
369 380
370 381 if ( $is_new_install ) {
371 382 self::seed_default_builder_mode();
383 + self::seed_default_notification_settings();
372 384 }
373 385
374 386 // add funnel type meta
375 387 Wpfnl_functions::add_type_meta();
@@ -431,10 +443,69 @@
431 443
432 444 update_option( self::BUILDER_MODE_PINNED_OPTION, 'yes' );
433 445 }
434 446
447 + /**
448 + * Seed the notification settings for brand-new installs.
449 + *
450 + * The store revenue report is on out of the box from 3.14.0, but only for
451 + * sites created from that version onward: the choice is written into the
452 + * database here rather than flipped in the fallback that
453 + * Wpfnl_functions::get_notification_settings() applies, so an existing site
454 + * — which has either its own saved settings or no row at all — is left
455 + * exactly as it was and never starts mailing after an update.
456 + *
457 + * A site that somehow already holds notification settings is skipped, so
458 + * this can never overwrite a stored preference.
459 + *
460 + * @since 3.14.0
461 + */
462 + private static function seed_default_notification_settings()
463 + {
464 + $stored = get_option( '_wpfunnels_notification_settings', array() );
465 + if ( ! empty( $stored ) ) {
466 + return;
467 + }
435 468
469 + update_option( '_wpfunnels_notification_settings', Wpfnl_functions::get_new_install_notification_settings() );
470 +
471 + // Action Scheduler is not dependable during activation, so the actual
472 + // queueing waits for a normal request on `init`.
473 + update_option( self::REVENUE_REPORT_PENDING_OPTION, 'yes' );
474 + }
475 +
476 +
436 477 /**
478 + * Queue the seeded revenue report once Action Scheduler is available.
479 + *
480 + * Only runs for an install that was just seeded — the flag is set nowhere
481 + * else — so no existing site's schedule is touched. If the admin saved the
482 + * settings before this ran, that save has already queued the action and this
483 + * only clears the flag.
484 + *
485 + * @since 3.14.0
486 + */
487 + public static function maybe_schedule_seeded_revenue_report()
488 + {
489 + if ( 'yes' !== get_option( self::REVENUE_REPORT_PENDING_OPTION ) ) {
490 + return;
491 + }
492 +
493 + if ( ! function_exists( 'as_schedule_recurring_action' ) || ! function_exists( 'as_next_scheduled_action' ) ) {
494 + return;
495 + }
496 +
497 + $settings = Wpfnl_functions::get_notification_settings();
498 +
499 + if ( 'yes' === $settings['enable_revenue_report'] && ! Wpfnl_functions::is_revenue_report_scheduled() ) {
500 + Wpfnl_functions::schedule_revenue_report_email( $settings );
501 + }
502 +
503 + delete_option( self::REVENUE_REPORT_PENDING_OPTION );
504 + }
505 +
506 +
507 + /**
437 508 * Keep pre-existing sites on the horizontal canvas.
438 509 *
439 510 * The default canvas layout became vertical in 3.12.13. A site that has been
440 511 * running without a stored funnel_builder_mode has been on the old horizontal
@@ -573,8 +644,15 @@
573 644 date_created datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
574 645 PRIMARY KEY (id)
575 646 ) $charset_collate;";
576 647 dbDelta( $sql );
648 +
649 + /**
650 + * Create the AI copilot conversation and message tables.
651 + *
652 + * @since 3.13.0
653 + */
654 + \WPFunnels\AI\ConversationStore::createTables();
577 655 }
578 656
579 657
580 658 /**