is_int( $count ) ) { return $count; } global $wpdb; $count = 0; $entry_handler = wpforms()->get( 'entry' ); $entry_meta_handler = wpforms()->get( 'entry_meta' ); if ( ! $entry_handler || ! $entry_meta_handler ) { return $count; } $query = "SELECT COUNT( $entry_handler->primary_key ) FROM $entry_handler->table_name WHERE $entry_handler->primary_key NOT IN ( SELECT entry_id FROM $entry_meta_handler->table_name WHERE type = 'backup_id' );"; // phpcs:ignore WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared $count = (int) $wpdb->get_var( $query ); return $count; } /** * Retrieve forms. * * @since 1.7.5 * * @param int $posts_per_page Number of form to return. * * @return array */ private function get_forms( $posts_per_page ) { $forms = wpforms()->get( 'form' )->get( '', [ 'posts_per_page' => (int) $posts_per_page, 'nopaging' => false, 'update_post_meta_cache' => false, 'update_post_term_cache' => false, 'cap' => false, ] ); return ! empty( $forms ) ? (array) $forms : []; } /** * Determine if the user has at least 1 form. * * @since 1.7.5 * * @return bool */ private function has_form() { return ! empty( $this->get_forms( 1 ) ); } /** * Determine if it is a new user. * * @since 1.7.5 * * @return bool */ private function is_new_user() { // Check if this is an update or first install. return ! get_option( 'wpforms_version_upgraded_from' ); } /** * Determine if it's an English site. * * @since 1.7.5 * * @return bool */ private function is_english_site() { static $result; if ( is_bool( $result ) ) { return $result; } $locales = array_unique( array_map( [ $this, 'language_to_iso' ], [ get_locale(), get_user_locale() ] ) ); $result = count( $locales ) === 1 && $locales[0] === 'en'; return $result; } /** * Convert language to ISO. * * @since 1.7.5 * * @param string $lang Language value. * * @return string */ private function language_to_iso( $lang ) { return $lang === '' ? $lang : explode( '_', $lang )[0]; } /** * Retrieve a modified URL query string. * * @since 1.7.5 * * @param array $args An associative array of query variables. * @param string $url A URL to act upon. * * @return string */ private function add_query_arg( $args, $url ) { return add_query_arg( array_merge( $this->get_utm_params(), array_map( 'rawurlencode', $args ) ), $url ); } /** * Retrieve UTM parameters for Event Driven notifications links. * * @since 1.7.5 * * @return array */ private function get_utm_params() { static $utm_params; if ( ! $utm_params ) { $utm_params = [ 'utm_source' => self::UTM_PARAMS['utm_source'], 'utm_medium' => rawurlencode( self::UTM_PARAMS['utm_medium'] ), 'utm_campaign' => wpforms()->is_pro() ? 'plugin' : 'liteplugin', ]; } return $utm_params; } /** * Retrieve Event Driven notifications. * * @since 1.7.5 * * @return array */ private function get_notifications() { return [ 'welcome-message' => [ 'id' => 'welcome-message', 'title' => esc_html__( 'Welcome to WPForms!', 'wpforms-lite' ), 'content' => sprintf( /* translators: %s - number of templates. */ esc_html__( 'We’re grateful that you chose WPForms for your website! Now that you’ve installed the plugin, you’re less than 5 minutes away from publishing your first form. To make it easy, we’ve got %s form templates to get you started!', 'wpforms-lite' ), '1100+' ), 'btns' => [ 'main' => [ 'url' => admin_url( 'admin.php?page=wpforms-builder' ), 'text' => esc_html__( 'Start Building', 'wpforms-lite' ), ], 'alt' => [ 'url' => $this->add_query_arg( [ 'utm_content' => 'Welcome Read the Guide' ], 'https://wpforms.com/docs/creating-first-form/' ), 'text' => esc_html__( 'Read the Guide', 'wpforms-lite' ), ], ], 'type' => [ 'lite', 'basic', 'plus', 'pro', 'agency', 'elite', 'ultimate', ], // Immediately after activation (new users only, not upgrades). 'condition' => $this->is_new_user(), ], 'wp-mail-smtp-education' => [ 'id' => 'wp-mail-smtp-education', 'title' => esc_html__( 'Don’t Miss Your Form Notification Emails!', 'wpforms-lite' ), 'content' => esc_html__( 'Did you know that many WordPress sites are not properly configured to send emails? With the free WP Mail SMTP plugin, you can easily optimize your site to send emails, avoid the spam folder, and make sure your emails land in the recipient’s inbox every time.', 'wpforms-lite' ), 'btns' => [ 'main' => [ 'url' => admin_url( 'admin.php?page=wpforms-smtp' ), 'text' => esc_html__( 'Install Now', 'wpforms-lite' ), ], 'alt' => [ 'url' => $this->add_query_arg( [ 'utm_content' => 'WP Mail SMTP Learn More' ], 'https://wpforms.com/docs/how-to-set-up-smtp-using-the-wp-mail-smtp-plugin/' ), 'text' => esc_html__( 'Learn More', 'wpforms-lite' ), ], ], // 3 days after activation/upgrade. 'offset' => 3 * DAY_IN_SECONDS, 'condition' => ! function_exists( 'wp_mail_smtp' ), ], 'join-vip-circle' => [ 'id' => 'join-vip-circle', 'title' => esc_html__( 'Want to Be a VIP? Join Now!', 'wpforms-lite' ), 'content' => esc_html__( 'Running a WordPress site can be challenging. But help is just around the corner! Our Facebook group contains tons of tips and help to get your business growing! When you join our VIP Circle, you’ll get instant access to tips, tricks, and answers from a community of loyal WPForms users. Best of all, membership is 100% free!', 'wpforms-lite' ), 'btns' => [ 'main' => [ 'url' => 'https://www.facebook.com/groups/wpformsvip/', 'text' => esc_html__( 'Join Now', 'wpforms-lite' ), ], ], // 30 days after activation/upgrade. 'offset' => 30 * DAY_IN_SECONDS, ], 'survey-reports' => [ 'id' => 'survey-reports', 'title' => esc_html__( 'Want to Know What Your Customers Really Think?', 'wpforms-lite' ), 'content' => esc_html__( 'Nothing beats real feedback from your customers and visitors. That’s why many small businesses love our awesome Surveys and Polls addon. Instantly unlock full survey reporting right in your WordPress dashboard. And don’t forget: building a survey is easy with our pre-made templates, so you could get started within a few minutes!', 'wpforms-lite' ), 'btns' => [ 'main' => [ 'license' => [ 'lite' => [ 'url' => $this->add_query_arg( [ 'utm_content' => 'Surveys and Polls Upgrade Lite', 'utm_locale' => wpforms_sanitize_key( get_locale() ), ], 'https://wpforms.com/lite-upgrade/' ), 'text' => esc_html__( 'Upgrade Now', 'wpforms-lite' ), ], 'basic' => [ 'url' => $this->add_query_arg( [ 'utm_content' => 'Surveys and Polls Upgrade Basic' ], 'https://wpforms.com/account/licenses/' ), 'text' => esc_html__( 'Upgrade Now', 'wpforms-lite' ), ], 'plus' => [ 'url' => $this->add_query_arg( [ 'utm_content' => 'Surveys and Polls Upgrade Basic' ], 'https://wpforms.com/account/licenses/' ), 'text' => esc_html__( 'Upgrade Now', 'wpforms-lite' ), ], 'pro' => [ 'url' => admin_url( 'admin.php?page=wpforms-addons' ), 'text' => esc_html__( 'Install Now', 'wpforms-lite' ), ], 'elite' => [ 'url' => admin_url( 'admin.php?page=wpforms-addons' ), 'text' => esc_html__( 'Install Now', 'wpforms-lite' ), ], ], ], 'alt' => [ 'url' => $this->add_query_arg( [ 'utm_content' => 'Surveys and Polls Learn More' ], 'https://wpforms.com/docs/how-to-install-and-use-the-surveys-and-polls-addon/' ), 'text' => esc_html__( 'Learn More', 'wpforms-lite' ), ], ], // 45 days after activation/upgrade. 'offset' => 45 * DAY_IN_SECONDS, 'condition' => ! defined( 'WPFORMS_SURVEYS_POLLS_VERSION' ), ], 'form-abandonment' => [ 'id' => 'form-abandonment', 'title' => esc_html__( 'Get More Leads From Your Forms!', 'wpforms-lite' ), 'content' => esc_html__( 'Are your forms converting fewer visitors than you hoped? Often, visitors quit forms partway through. That can prevent you from getting all the leads you deserve to capture. With our Form Abandonment addon, you can capture partial entries even if your visitor didn’t hit Submit! From there, it’s easy to follow up with leads and turn them into loyal customers.', 'wpforms-lite' ), 'btns' => [ 'main' => [ 'license' => [ 'lite' => [ 'url' => $this->add_query_arg( [ 'utm_content' => 'Form Abandonment Upgrade Lite', 'utm_locale' => wpforms_sanitize_key( get_locale() ), ], 'https://wpforms.com/lite-upgrade/' ), 'text' => esc_html__( 'Upgrade Now', 'wpforms-lite' ), ], 'basic' => [ 'url' => $this->add_query_arg( [ 'utm_content' => 'Form Abandonment Upgrade Basic' ], 'https://wpforms.com/account/licenses/' ), 'text' => esc_html__( 'Upgrade Now', 'wpforms-lite' ), ], 'plus' => [ 'url' => $this->add_query_arg( [ 'utm_content' => 'Form Abandonment Upgrade Basic' ], 'https://wpforms.com/account/licenses/' ), 'text' => esc_html__( 'Upgrade Now', 'wpforms-lite' ), ], 'pro' => [ 'url' => admin_url( 'admin.php?page=wpforms-addons' ), 'text' => esc_html__( 'Install Now', 'wpforms-lite' ), ], 'elite' => [ 'url' => admin_url( 'admin.php?page=wpforms-addons' ), 'text' => esc_html__( 'Install Now', 'wpforms-lite' ), ], ], ], 'alt' => [ 'url' => $this->add_query_arg( [ 'utm_content' => 'Form Abandonment Learn More' ], 'https://wpforms.com/docs/how-to-install-and-use-form-abandonment-with-wpforms/' ), 'text' => esc_html__( 'Learn More', 'wpforms-lite' ), ], ], // 60 days after activation/upgrade. 'offset' => 60 * DAY_IN_SECONDS, 'condition' => ! defined( 'WPFORMS_FORM_ABANDONMENT_VERSION' ), ], 'ideas' => [ 'id' => 'ideas', 'title' => esc_html__( 'What’s Your Dream WPForms Feature?', 'wpforms-lite' ), 'content' => esc_html__( 'If you could add just one feature to WPForms, what would it be? We want to know! Our team is busy surveying valued customers like you as we plan the year ahead. We’d love to know which features would take your business to the next level! Do you have a second to share your idea with us?', 'wpforms-lite' ), 'btns' => [ 'main' => [ 'url' => 'https://wpforms.com/share-your-idea/', 'text' => esc_html__( 'Share Your Idea', 'wpforms-lite' ), ], ], // 120 days after activation/upgrade. 'offset' => 120 * DAY_IN_SECONDS, 'condition' => $this->has_form(), ], 'user-insights' => [ 'id' => 'user-insights', 'title' => esc_html__( 'Congratulations! You Just Got Your 100th Form Entry!', 'wpforms-lite' ), 'content' => esc_html__( 'You just hit 100 entries… and this is just the beginning! Now it’s time to dig into the data and figure out what makes your visitors tick. The User Journey addon shows you what your visitors looked at before submitting your form. Now you can easily find which areas of your site are triggering form conversions.', 'wpforms-lite' ), 'btns' => [ 'main' => [ 'license' => [ 'lite' => [ 'url' => $this->add_query_arg( [ 'utm_content' => 'User Journey Upgrade Lite', 'utm_locale' => wpforms_sanitize_key( get_locale() ), ], 'https://wpforms.com/lite-upgrade/' ), 'text' => esc_html__( 'Upgrade Now', 'wpforms-lite' ), ], 'basic' => [ 'url' => $this->add_query_arg( [ 'utm_content' => 'User Journey Upgrade Basic' ], 'https://wpforms.com/account/licenses/' ), 'text' => esc_html__( 'Upgrade Now', 'wpforms-lite' ), ], 'plus' => [ 'url' => $this->add_query_arg( [ 'utm_content' => 'User Journey Upgrade Basic' ], 'https://wpforms.com/account/licenses/' ), 'text' => esc_html__( 'Upgrade Now', 'wpforms-lite' ), ], 'pro' => [ 'url' => admin_url( 'admin.php?page=wpforms-addons' ), 'text' => esc_html__( 'Install Now', 'wpforms-lite' ), ], 'elite' => [ 'url' => admin_url( 'admin.php?page=wpforms-addons' ), 'text' => esc_html__( 'Install Now', 'wpforms-lite' ), ], ], ], ], 'condition' => ! defined( 'WPFORMS_USER_JOURNEY_VERSION' ) && $this->get_entry_count() >= 100, ], ]; } }