ajax_load_action(), array( $tve_ult_frontend, 'ajax_load' ) ); add_action( 'wp_ajax_nopriv_' . $tve_ult_frontend->ajax_load_action(), array( $tve_ult_frontend, 'ajax_load' ) ); add_action( 'wp_ajax_' . $tve_ult_frontend->conversion_events_action(), array( $tve_ult_frontend, 'ajax_conversion_event_check' ) ); add_action( 'wp_ajax_nopriv_' . $tve_ult_frontend->conversion_events_action(), array( $tve_ult_frontend, 'ajax_conversion_event_check' ) ); add_filter( 'tve_dash_main_ajax_tu_lazy_load', array( $tve_ult_frontend, 'ajax_load' ), 10, 2 ); add_filter( 'tve_dash_main_ajax_tu_conversion_events', array( $tve_ult_frontend, 'ajax_conversion_event_check' ), 10, 2 ); /** * register an impression for a campaign */ add_action( 'tve_ult_action_impression', 'tve_ult_register_impression' ); } /** * Starting point for frontend logic: * * we use the wp_enqueue_scripts hook to check if a campaign should be displayed */ if ( ! is_admin() ) { //TODO: remove THIS add_filter( 'tcb_editor_javascript_params', 'tve_ult_append_shortcode_campaigns' ); add_action( 'wp_enqueue_scripts', array( $tve_ult_frontend, 'hook_enqueue_scripts' ) ); add_action( 'wp_footer', array( $tve_ult_frontend, 'hook_print_footer_scripts' ), 100 ); /** * Before template redirect check if we have a cookie set for a campaign that should be displayed */ add_action( 'template_redirect', 'tve_ult_check_email_cookies', 1 ); add_action( 'template_redirect', array( $tve_ult_frontend, 'hook_template_redirect' ), 2 ); } register_activation_hook( TVE_ULT_PLUGIN__FILE__, 'tve_ult_activation_hook' ); add_action( 'thrive_prepare_migrations', 'tve_ult_prepare_db_migrations' ); /** * This allows TU shortcodes to work while placed inside thrive leads forms loaded via ajax */ add_action( 'tve_leads_ajax_load_prepare_variation', static function ( $thrive_leads_variation ) { $content = isset( $thrive_leads_variation['content'] ) ? $thrive_leads_variation['content'] : ''; if ( strpos( $content, '[tu_countdown' ) !== false ) { do_shortcode( $content ); } } ); /** * Search thrive leads design variations if they have a specific string in their architect content */ add_filter( 'tcb_architect_content_has_string', static function ( $has_string, $string, $post_id ) { if ( ! $has_string ) { global $tve_ult_db; if ( $tve_ult_db->search_string_in_designs( $string ) ) { $has_string = true; } } return $has_string; }, 13, 3 ); /** * Trigger campaign start from api webhook */ add_filter( 'tve_dash_webhook_trigger', 'tu_webhook_trigger_campaign', 10, 3 ); add_action( 'fluentcrm_contact_added_to_tags', 'tu_fluentcrm_trigger_campaign', 10, 2 ); /** * Add info article url for Ultimatum Countdown element */ add_filter( 'thrive_kb_articles', static function ( $articles ) { $articles['ultimatum_countdown'] = 'https://api.intercom.io/articles/4426118'; return $articles; } ); /** * Dont display metrics ribbon if we don't have any license */ add_filter( 'tve_dash_metrics_should_enqueue', static function ( $should_enqueue ) { $screen = tve_get_current_screen_key(); if ( $screen === 'thrive-dashboard_page_tve_ult_dashboard' && ! tve_ult_license_activated() ) { $should_enqueue = false; } return $should_enqueue; }, 10, 1 ); /* Hook used to clear the cache on all pages that are promotions pages on running campaigns */ add_action( 'wp', 'tve_ult_promotion_prevent_cache' );