'https://manage.spider-themes.net/wp-json/noticepilot/v1/content/forumax', // How often to pull campaigns, and who may see them. 'schedule' => 'daily', // hourly | twicedaily | daily 'capability' => 'manage_options', // Audience targeting: campaigns can target by version rule + free/Pro. 'plugin_version' => FORUMAX_VERSION, 'is_pro' => ( forumax_is_premium() || forumax_is_promax() ), // Frequency / dismissal behaviour (keeps notices tasteful — wp.org guideline 11). 'max_notices' => 2, // never stack more than 2 at once 'dismiss_duration' => WEEK_IN_SECONDS, // a dismissal sticks for a week 'snooze_duration' => WEEK_IN_SECONDS, // "Remind me later" cooldown // Analytics consent (wp.org guideline 7): keep beacons OFF until the user // opts in. We reuse Forumax' existing Freemius tracking opt-in as the // consent signal (synced just below), so there is no second consent prompt. 'require_consent' => true, // Deactivation feedback is intentionally left OFF: Freemius already shows // its own deactivation survey for Forumax, so enabling the SDK prompt too // would give the user a duplicate modal on deactivate. // 'deactivation_feedback' => true, // 'plugin_file' => 'bbp-core/bbp-core.php', ] ); } ); /** * Keep NoticePilot analytics consent in sync with the user's Freemius * tracking choice. Because init() runs with require_consent => true, no * impression/click/dismissal/goal beacon fires until this grants consent. */ add_action( 'admin_init', function () { // A sibling plugin may have loaded an older copy of the shared SDK class // first; guard the newer method so we never fatal on an outdated class. if ( ! function_exists( 'bc_fs' ) || ! method_exists( 'Noticepilot_Remote_Notice_Client', 'grant_consent' ) ) { return; } // is_tracking_allowed() is true once the user opts in to Freemius tracking. if ( method_exists( bc_fs(), 'is_tracking_allowed' ) && bc_fs()->is_tracking_allowed() ) { Noticepilot_Remote_Notice_Client::grant_consent( 'Forumax' ); } else { Noticepilot_Remote_Notice_Client::revoke_consent( 'Forumax' ); } } ); /** * Conversion goal: report the Pro upgrade once, attributed to the campaign / * variant that most recently drove it. This is what lets the hub measure real * conversion rate (and pick A/B winners), not just clicks. */ add_action( 'admin_init', function () { if ( ! function_exists( 'forumax_is_premium' ) || ! method_exists( 'Noticepilot_Remote_Notice_Client', 'track_goal' ) ) { return; } if ( forumax_is_premium() && ! get_option( 'forumax_np_goal_upgraded' ) ) { // track_goal() returns true only when the beacon actually fired (consent // granted + a campaign was seen). Mark it recorded only then, so a user // who opts in later still gets the conversion attributed. if ( Noticepilot_Remote_Notice_Client::track_goal( 'Forumax', 'upgraded_to_pro' ) ) { update_option( 'forumax_np_goal_upgraded', 1, false ); } } } ); /** * Smart-trigger metric: report the live number of published forum topics. * NoticePilot only stores the number — WE do the counting. On the hub you can * then trigger a campaign at a milestone (e.g. nudge for Pro once a community * has "topics_created" >= 25). * * Fires wherever a topic is saved (front-end or admin). Reporting the current * total is idempotent, so edits and re-saves simply re-report the same count. */ add_action( 'save_post_topic', function ( $post_id, $post ) { if ( ! method_exists( 'Noticepilot_Remote_Notice_Client', 'set_metric' ) ) { return; } if ( wp_is_post_revision( $post_id ) || wp_is_post_autosave( $post_id ) ) { return; } if ( 'publish' !== $post->post_status ) { return; } $count = (int) wp_count_posts( 'topic' )->publish; Noticepilot_Remote_Notice_Client::set_metric( 'Forumax', 'topics_created', $count ); }, 10, 2 );