* WPForms_Lite class file.
// phpcs:disable Generic.Commenting.DocComment.MissingShort
/** @noinspection PhpIllegalPsrClassPathInspection */
/** @noinspection AutoloadingIssuesInspection */
// phpcs:enable Generic.Commenting.DocComment.MissingShort
if ( ! defined( 'ABSPATH' ) ) {
use WPForms\Admin\Builder\TemplatesCache;
use WPForms\Db\Payments\Meta as PaymentsMeta;
use WPForms\Db\Payments\Payment;
use WPForms\Lite\Integrations\LiteConnect\Integration as LiteConnectIntegration;
use WPForms\Lite\Integrations\LiteConnect\LiteConnect;
use WPForms\Logger\Repository;
use WPForms\Tasks\Meta as TasksMeta;
* WPForms Lite. Load Lite-specific features/functionality.
* Custom tables and their handlers.
public const CUSTOM_TABLES = [
'wpforms_payments' => Payment::class,
'wpforms_payment_meta' => PaymentsMeta::class,
'wpforms_tasks_meta' => TasksMeta::class,
'wpforms_logs' => Repository::class,
* Primary class constructor.
public function __construct() {
private function hooks() {
add_action( 'wpforms_install', [ $this, 'install' ] );
add_action( 'wpforms_form_settings_notifications', [ $this, 'form_settings_notifications' ], 8 );
add_action( 'wpforms_form_settings_confirmations', [ $this, 'form_settings_confirmations' ] );
add_action( 'wpforms_builder_enqueues_before', [ $this, 'builder_enqueues' ] );
add_action( 'wpforms_admin_page', [ $this, 'entries_page' ] );
add_action( 'wpforms_admin_settings_after', [ $this, 'settings_cta' ] );
add_action( 'wp_ajax_wpforms_lite_settings_upgrade', [ $this, 'settings_cta_dismiss' ] );
add_action( 'admin_enqueue_scripts', [ $this, 'admin_enqueues' ] );
add_filter( 'wpforms_helpers_templates_get_theme_template_paths', [ $this, 'add_templates' ] );
// Entries count logging for WPForms Lite.
add_action( 'wpforms_process_entry_saved', [ $this, 'entry_submit' ], 10, 5 );
add_action( 'wpforms_process_entry_saved', [ $this, 'update_entry_count' ], 10, 5 );
// Upgrade to Pro WPForms menu bar item.
add_action( 'admin_bar_menu', [ $this, 'upgrade_to_pro_menu' ], 1000 );
* Form notification settings, supports multiple notifications.
* @param object $settings Settings.
* @noinspection HtmlUnknownTarget
public function form_settings_notifications( $settings ) {
$cc = wpforms_setting( 'email-carbon-copy' );
$from_email = '{admin_email}';
$from_name = sanitize_text_field( get_option( 'blogname' ) );
// phpcs:disable WPForms.PHP.ValidateHooks.InvalidHookName
* Allow filtering of text after the `From Name` field.
* @since 1.7.6 Added $form_data and $id arguments.
* @param string $value Value to be filtered.
* @param array $form_data Form data.
* @param int $id Notification ID.
$from_name_after = apply_filters( 'wpforms_builder_notifications_from_name_after', '', $settings->form_data, 1 );
* Allow filtering of a text after the `From Email` field.
* @since 1.7.6 Added $form_data and $id arguments.
* @param array $value Value to be filtered.
* @param array $form_data Form data.
* @param int $id Notification ID.
$from_email_after = apply_filters( 'wpforms_builder_notifications_from_email_after', '', $settings->form_data, 1 );
// phpcs:enable WPForms.PHP.ValidateHooks.InvalidHookName
// Handle backwards compatibility.
if ( empty( $settings->form_data['settings']['notifications'] ) ) {
$settings->form_data['settings']['notifications'][1]['subject'] = ! empty( $settings->form_data['settings']['notification_subject'] ) ?
$settings->form_data['settings']['notification_subject'] :
sprintf( /* translators: %s - form name. */
esc_html__( 'New %s Entry', 'wpforms-lite' ),
$settings->form->post_title
$settings->form_data['settings']['notifications'][1]['email'] = ! empty( $settings->form_data['settings']['notification_email'] ) ? $settings->form_data['settings']['notification_email'] : '{admin_email}';
$settings->form_data['settings']['notifications'][1]['sender_name'] = ! empty( $settings->form_data['settings']['notification_fromname'] ) ? $settings->form_data['settings']['notification_fromname'] : $from_name;
$settings->form_data['settings']['notifications'][1]['sender_address'] = ! empty( $settings->form_data['settings']['notification_fromaddress'] ) ? $settings->form_data['settings']['notification_fromaddress'] : $from_email;
$settings->form_data['settings']['notifications'][1]['replyto'] = ! empty( $settings->form_data['settings']['notification_replyto'] ) ? $settings->form_data['settings']['notification_replyto'] : '';
echo '<div class="wpforms-panel-content-section-title">';
echo '<span id="wpforms-builder-settings-notifications-title">';
esc_html_e( 'Notifications', 'wpforms-lite' );
echo '<button class="wpforms-builder-settings-block-add education-modal"
data-utm-content="Multiple notifications"
data-name="' . esc_attr__( 'Multiple notifications', 'wpforms-lite' ) . '">';
esc_html_e( 'Add New Notification', 'wpforms-lite' );
$dismissed = get_user_meta( get_current_user_id(), 'wpforms_dismissed', true );
if ( empty( $dismissed['edu-builder-notifications-description'] ) ) {
echo '<div class="wpforms-panel-content-section-description wpforms-dismiss-container wpforms-dismiss-out">';
echo '<button type="button" class="wpforms-dismiss-button" title="' . esc_attr__( 'Dismiss this message.', 'wpforms-lite' ) . '" data-section="builder-notifications-description"></button>';
wp_kses( /* translators: %s - link to the WPForms.com doc article. */
__( 'Notifications are emails sent when a form is submitted. By default, these emails include entry details. For setup and customization options, including a video overview, please <a href="%s" target="_blank" rel="noopener noreferrer">see our tutorial</a>.', 'wpforms-lite' ),
esc_url( wpforms_utm_link( 'https://wpforms.com/docs/setup-form-notification-wpforms/', 'Builder Notifications', 'Form Notifications Documentation' ) )
wp_kses( /* translators: 1$s, %2$s - links to the WPForms.com doc articles. */
__( 'After saving these settings, be sure to <a href="%1$s" target="_blank" rel="noopener noreferrer">test a form submission</a>. This lets you see how emails will look, and to ensure that they <a href="%2$s" target="_blank" rel="noopener noreferrer">are delivered successfully</a>.', 'wpforms-lite' ),
esc_url( wpforms_utm_link( 'https://wpforms.com/docs/how-to-properly-test-your-wordpress-forms-before-launching-checklist/', 'Builder Notifications', 'Testing A Form Documentation' ) ),
esc_url( wpforms_utm_link( 'https://wpforms.com/docs/troubleshooting-email-notifications/', 'Builder Notifications', 'Troubleshoot Notifications Documentation' ) )
esc_html__( 'Enable Notifications', 'wpforms-lite' )
<div class="wpforms-notification wpforms-builder-settings-block">
<div class="wpforms-builder-settings-block-header">
<span><?php esc_html_e( 'Default Notification', 'wpforms-lite' ); ?></span>
<div class="wpforms-builder-settings-block-content">
esc_html__( 'Send To Email Address', 'wpforms-lite' ),
'default' => '{admin_email}',
'tooltip' => esc_html__( 'Enter the email address to receive form entry notifications. For multiple notifications, separate email addresses with a comma.', 'wpforms-lite' ),
'class' => 'email-recipient',
'input_class' => 'wpforms-smart-tags-enabled',
esc_html__( 'CC', 'wpforms-lite' ),
'input_class' => 'wpforms-smart-tags-enabled',
esc_html__( 'Email Subject Line', 'wpforms-lite' ),
'default' => sprintf( /* translators: %s - form name. */
esc_html__( 'New Entry: %s', 'wpforms-lite' ),
$settings->form->post_title
'input_class' => 'wpforms-smart-tags-enabled',
esc_html__( 'From Name', 'wpforms-lite' ),
// phpcs:disable WPForms.PHP.ValidateHooks.InvalidHookName
* Allow modifying the "From Name" field settings in the builder on Settings > Notifications panel.
* @param array $args Field settings.
* @param array $form_data Form data.
* @param int $id Notification ID.
'wpforms_builder_notifications_sender_name_settings',
'input_class' => 'wpforms-smart-tags-enabled',
// phpcs:enable WPForms.PHP.ValidateHooks.InvalidHookName
esc_html__( 'From Email', 'wpforms-lite' ),
// phpcs:disable WPForms.PHP.ValidateHooks.InvalidHookName
* Allow modifying the "From Email" field settings in the builder on the Settings > Notifications panel.
* @param array $args Field settings.
* @param array $form_data Form data.
* @param int $id Notification ID.
'wpforms_builder_notifications_sender_address_settings',
'default' => $from_email,
'input_class' => 'wpforms-smart-tags-enabled',
// phpcs:enable WPForms.PHP.ValidateHooks.InvalidHookName
esc_html__( 'Reply-To', 'wpforms-lite' ),
sprintf( /* translators: %s - <email@example.com>. */
__( 'Enter the email address or email address with recipient\'s name in "First Last %s" format.', 'wpforms-lite' ),
// ​ is a zero-width space character. Without it, Tooltipster thinks it's an HTML tag
// and closes it at the end of the string, hiding everything after this value.
'<​email@example.com​>'
'fields' => 'email,name',
'input_class' => 'wpforms-smart-tags-enabled',
esc_html__( 'Email Message', 'wpforms-lite' ),
'default' => '{all_fields}',
'input_class' => 'wpforms-smart-tags-enabled',
'after' => '<p class="note">' .
/* translators: %s - {all_fields} Smart Tag. */
esc_html__( 'To display all form fields, use the %s Smart Tag.', 'wpforms-lite' ),
'<code>{all_fields}</code>'
* Fires after notification block content on the lite version.
* @param array $settings Current confirmation data.
* @param int $id Notification id.
do_action( 'wpforms_lite_form_settings_notifications_block_content_after', $settings, $id );
* Fires after settings notification block.
* @param string $type Settings block type.
* @param array $settings Settings.
do_action( 'wpforms_builder_settings_notifications_after', 'notifications', $settings ); // phpcs:ignore WPForms.PHP.ValidateHooks.InvalidHookName
// phpcs:disable WPForms.PHP.ValidateHooks.InvalidHookName
* Fires after notification block.
* @param array $settings Current confirmation data.
* @param int $id Notification id.
do_action( 'wpforms_form_settings_notifications_single_after', $settings, 1 );
// phpcs:enable WPForms.PHP.ValidateHooks.InvalidHookName
* Lite admin scripts and styles.
public function admin_enqueues() {
if ( ! wpforms_is_admin_page() ) {
$min = wpforms_get_min_suffix();
WPFORMS_PLUGIN_URL . "assets/lite/css/admin{$min}.css",
'wpforms-admin-entry-list',
WPFORMS_PLUGIN_URL . "assets/lite/css/admin/entries/entry-list{$min}.css",
'wpforms-admin-entry-list',
WPFORMS_PLUGIN_URL . "assets/lite/js/admin/entries/entry-list{$min}.js",
'wpforms-admin-view-entry',
WPFORMS_PLUGIN_URL . "assets/lite/css/admin/entries/view-entry{$min}.css",
'wpforms-admin-view-entry',
WPFORMS_PLUGIN_URL . "assets/lite/js/admin/entries/view-entry{$min}.js",
* Form confirmation settings, supports multiple confirmations.
* @param WPForms_Builder_Panel_Settings $settings Builder panel settings.
public function form_settings_confirmations( $settings ) {
// Handle backwards compatibility.
if ( empty( $settings->form_data['settings']['confirmations'] ) ) {
$settings->form_data['settings']['confirmations'][1]['type'] = ! empty( $settings->form_data['settings']['confirmation_type'] ) ? $settings->form_data['settings']['confirmation_type'] : 'message';
$settings->form_data['settings']['confirmations'][1]['message'] = ! empty( $settings->form_data['settings']['confirmation_message'] ) ? $settings->form_data['settings']['confirmation_message'] : esc_html__( 'Thanks for contacting us! We will be in touch with you shortly.', 'wpforms-lite' );
$settings->form_data['settings']['confirmations'][1]['message_scroll'] = ! empty( $settings->form_data['settings']['confirmation_message_scroll'] ) ? $settings->form_data['settings']['confirmation_message_scroll'] : 1;
$settings->form_data['settings']['confirmations'][1]['page'] = ! empty( $settings->form_data['settings']['confirmation_page'] ) ? $settings->form_data['settings']['confirmation_page'] : '';
$settings->form_data['settings']['confirmations'][1]['redirect'] = ! empty( $settings->form_data['settings']['confirmation_redirect'] ) ? $settings->form_data['settings']['confirmation_redirect'] : '';
echo '<div class="wpforms-panel-content-section-title">';
esc_html_e( 'Confirmations', 'wpforms-lite' );
echo '<button class="wpforms-builder-settings-block-add education-modal"
data-utm-content="Multiple confirmations"
data-name="' . esc_attr__( 'Multiple confirmations', 'wpforms-lite' ) . '">';
esc_html_e( 'Add New Confirmation', 'wpforms-lite' );
<div class="wpforms-confirmation wpforms-builder-settings-block">
<div class="wpforms-builder-settings-block-header">