banner_id = 'no_funnel_48h'; $this->dismiss_option_key = '_wpfnl_dismiss_no_funnel_banner'; $this->hours_delay = 48; // Register hooks - actual condition check happens in display_banner add_action('admin_notices', [$this, 'display_banner']); add_action('admin_head', [$this, 'add_styles']); // Register AJAX handler for dismissing the banner $validations = [ 'logged_in' => true, 'user_can' => 'wpf_manage_funnels', ]; wp_ajax_helper()->handle('dismiss_first_funnel_setup_reminder_banner') ->with_callback([$this, 'dismiss_banner']) ->with_validation($validations); } /** * Check if the banner should be displayed. * * Conditions: * 1. Banner has not been dismissed * 2. At least 48 hours have passed since installation * 3. No funnels have been created * * @return bool * @since 3.9.3 */ private function should_show_banner(){ // Check if banner was dismissed if ('yes' === get_option($this->dismiss_option_key, 'no')) { return false; } // Check if 48 hours have passed since installation $installed_time = get_option('wpfunnels_installed_time', 0); if (!$installed_time) { return false; } $hours_since_install = (time() - $installed_time) / 3600; if ($hours_since_install < $this->hours_delay) { return false; } // Check if any funnels exist $funnel_count = $this->get_funnel_count(); if ($funnel_count > 0) { return false; } return true; } /** * Get the total count of funnels. * * @return int * @since 3.9.3 */ private function get_funnel_count() { $counts = wp_count_posts('wpfunnels'); return (int) $counts->publish + (int) $counts->draft; } /** * Displays the setup reminder banner. * * @since 3.9.3 */ public function display_banner(){ // Check conditions before displaying if (!$this->should_show_banner()) { return; } $screen = get_current_screen(); // Pages where the banner should NOT be displayed $disabled_notice_pages = array( 'toplevel_page_wpfunnels', 'wpfunnels_page_wpfnl_settings', 'wpfunnels_page_wp_funnels', 'wpfunnels_page_wpf_templates', 'wpfunnels_page_trash_funnels', ); if (in_array($screen->id, $disabled_notice_pages)) { return; } // Get the URL to create a new funnel $create_funnel_url = admin_url('admin.php?page=wp_funnels'); $learn_more_url = 'https://getwpfunnels.com/docs/getting-started-with-wpfunnels/create-your-first-sales-funnel/'; $dismiss_nonce = wp_create_nonce('dismiss_first_funnel_setup_reminder_banner'); if (!\WPFunnels\Wpfnl_functions::is_wc_active()) { $banner_title = esc_html__('Let’s launch your first lead funnel in 5 minutes!', 'wpfnl'); $banner_description = esc_html__('Finish setting up your first lead funnel and start collecting more leads with better conversions.', 'wpfnl'); } else { $banner_title = esc_html__('Let’s launch your first WooCommerce funnel in 5 minutes!', 'wpfnl'); $banner_description = esc_html__('Finish setting up your first funnel and start increasing your WooCommerce revenue with upsells, order bumps & better conversions.', 'wpfnl'); } ?>

should_show_banner()) { return; } ?> dismiss_option_key, 'yes'); return [ 'success' => true, ]; } }