';
printf(
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 see our tutorial.', 'wpforms' ),
[
'a' => [
'href' => [],
'rel' => [],
'target' => [],
],
]
),
esc_url( wpforms_utm_link( 'https://wpforms.com/docs/setup-form-notification-wpforms/', 'Builder Notifications', 'Form Notifications Documentation' ) )
);
echo '
';
echo '
';
printf(
wp_kses( /* translators: 1$s, %2$s - Links to the WPForms.com doc articles. */
__( 'After saving these settings, be sure to test a form submission. This lets you see how emails will look, and to ensure that they are delivered successfully.', 'wpforms' ),
[
'a' => [
'href' => [],
'rel' => [],
'target' => [],
],
'br' => [],
]
),
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' ) )
);
echo '
';
echo '
';
}
wpforms_panel_field(
'toggle',
'settings',
'notification_enable',
$settings->form_data,
esc_html__( 'Enable Notifications', 'wpforms' ),
[
'value' => empty( $form_settings['notification_enable'] ) ? 0 : 1,
]
);
foreach ( $notifications as $id => $notification ) {
$name = ! empty( $notification['notification_name'] ) ? $notification['notification_name'] : esc_html__( 'Default Notification', 'wpforms' );
$closed_state = '';
$toggle_state = '';
$block_classes = 'wpforms-notification wpforms-builder-settings-block';
// phpcs:disable WPForms.PHP.ValidateHooks.InvalidHookName
/**
* Allow filtering of text after the `From Name` field.
*
* @since 1.2.3
* @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, $id );
/**
* Allow filtering of text after the `From Email` field.
*
* @since 1.2.3
* @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, $id );
// phpcs:enable WPForms.PHP.ValidateHooks.InvalidHookName
if ( ! empty( $settings->form_data['id'] ) && 'closed' === wpforms_builder_settings_block_get_state( $settings->form_data['id'], $id, 'notification' ) ) {
$closed_state = 'style="display:none"';
$toggle_state = '';
}
if ( $default_notifications_key === $id ) {
$block_classes .= ' wpforms-builder-settings-block-default';
}
do_action( 'wpforms_form_settings_notifications_single_before', $settings, $id );
?>
form_builder_strings( $strings, $form );
}
/**
* Modify javascript `wpforms_settings` properties on site front end.
*
* @since 1.4.6
*
* @param array $strings Array wpforms_setting properties.
*
* @return array
*/
public function frontend_strings( $strings ) {
// If the user has GDPR enhancements enabled and has disabled UUID,
// disable the setting, otherwise enable it.
$strings['uuid_cookie'] = ! wpforms_setting( 'gdpr-disable-uuid', false );
$strings['val_requiredpayment'] = wpforms_setting( 'validation-requiredpayment', esc_html__( 'Payment is required.', 'wpforms' ) );
$strings['val_creditcard'] = wpforms_setting( 'validation-creditcard', esc_html__( 'Please enter a valid credit card number.', 'wpforms' ) );
$strings['val_post_max_size'] = wpforms_setting(
'validation-post_max_size',
sprintf( /* translators: %1$s - total size of the selected files in megabytes, %2$s - allowed file upload limit in megabytes. */
esc_html__( 'The total size of the selected files %1$s MB exceeds the allowed limit %2$s MB.', 'wpforms' ),
'{totalSize}',
'{maxSize}'
)
);
// Date/time.
$strings['val_time12h'] = wpforms_setting( 'validation-time12h', esc_html__( 'Please enter time in 12-hour AM/PM format (eg 8:45 AM).', 'wpforms' ) );
$strings['val_time24h'] = wpforms_setting( 'validation-time24h', esc_html__( 'Please enter time in 24-hour format (eg 22:45).', 'wpforms' ) );
$strings['val_time_limit'] = wpforms_setting( 'validation-time-limit', esc_html__( 'Please enter time between {minTime} and {maxTime}.', 'wpforms' ) );
// URL.
$strings['val_url'] = wpforms_setting( 'validation-url', esc_html__( 'Please enter a valid URL.', 'wpforms' ) );
// File upload.
$strings['val_fileextension'] = wpforms_setting( 'validation-fileextension', esc_html__( 'File type is not allowed.', 'wpforms' ) );
$strings['val_filesize'] = wpforms_setting( 'validation-filesize', esc_html__( 'File exceeds max size allowed. File was not uploaded.', 'wpforms' ) );
$strings['post_max_size'] = wpforms_size_to_bytes( ini_get( 'post_max_size' ) );
return $strings;
}
/**
* Check to see if the Conditional Logic addon is installed, if so notify
* the user that it can be removed.
*
* @since 1.3.8
*/
public function conditional_logic_addon_notice() {
if ( file_exists( WP_PLUGIN_DIR . '/wpforms-conditional-logic/wpforms-conditional-logic.php' ) && ! defined( 'WPFORMS_DEBUG' ) ) {
$notice = sprintf(
wp_kses( /* translators: %s - WPForms.com announcement page URL. */
__( 'Conditional logic functionality is now included in the core WPForms plugin! The WPForms Conditional Logic addon can be removed without affecting your forms. For more details read our announcement.', 'wpforms' ),
[
'a' => [
'href' => [],
'target' => [],
'rel' => [],
],
]
),
'https://wpforms.com/announcing-wpforms-1-3-8/'
);
\WPForms\Admin\Notice::info( $notice );
}
}
/**
* Used to register the templates for setting blocks inside form builder.
*
* @since 1.4.8
* @deprecated 1.7.6
*/
public function builder_templates() {
_deprecated_function( __METHOD__, '1.7.6 of the WPForms plugin', 'WPForms\Pro\Admin\Builder\Builder::builder_templates()' );
( new WPForms\Pro\Admin\Builder\Builder() )->builder_templates();
}
/**
* Expired license notification in form notification email footer.
*
* @since 1.5.0
*
* @param string $text Footer text.
*
* @return string
*/
public function form_notification_footer( $text ) {
$license = get_option( 'wpforms_license', array() );
if (
empty( $license['is_expired'] ) &&
empty( $license['is_disabled'] ) &&
empty( $license['is_invalid'] )
) {
return $text;
}
$notice = sprintf(
wp_kses(
/* translators: %s - WPForms.com Account dashboard URL. */
__( 'Your WPForms license key has expired. In order to continue receiving support and plugin updates you must renew your license key. Please log in to your WPForms.com account to renew your license.', 'wpforms' ),
array(
'a' => array(
'href' => array(),
'target' => array(),
'rel' => array(),
),
)
),
'https://wpforms.com/account/'
);
return $notice . '
' . $text;
}
/**
* Get the list of all custom tables starting with `wpforms_*`.
*
* @since 1.5.9
*
* @return array List of table names.
*/
public function get_existing_custom_tables() {
_deprecated_function( __METHOD__, '1.6.3 of the WPForms plugin', 'wpforms()->get_existing_custom_tables()' );
return wpforms()->get_existing_custom_tables();
}
/**
* Check if all custom tables exist.
*
* @since 1.5.9
*
* @return bool True if all custom tables exist. False if any is missing.
*/
public function custom_tables_exist() {
global $wpdb;
$custom_tables = array(
'wpforms_entries',
'wpforms_entry_fields',
'wpforms_entry_meta',
);
$tables = wpforms()->get_existing_custom_tables();
foreach ( $custom_tables as $table ) {
if ( ! in_array( $wpdb->prefix . $table, $tables, true ) ) {
return false;
}
}
return true;
}
/**
* Create all Pro plugin custom DB tables.
*
* @since 1.5.9
*
* @param stdClass|bool $wpforms_install WPForms install object.
*/
public function create_custom_tables( $wpforms_install = false ) {
if ( empty( $wpforms_install ) ) {
$wpforms_install = new stdClass();
$wpforms_install->entry = new WPForms_Entry_Handler();
$wpforms_install->entry_fields = new WPForms_Entry_Fields_Handler();
$wpforms_install->entry_meta = new WPForms_Entry_Meta_Handler();
}
// Entry tables.
$wpforms_install->entry->create_table();
$wpforms_install->entry_fields->create_table();
$wpforms_install->entry_meta->create_table();
}
/**
* Re-create plugin custom tables if don't exist.
*
* @since 1.5.9
*
* @param \WPForms_Settings $wpforms_settings WPForms settings object.
*/
public function reinstall_custom_tables( $wpforms_settings ) {
if ( empty( $wpforms_settings->view ) ) {
return;
}
// Proceed on Settings plugin admin area page only.
if ( $wpforms_settings->view !== 'general' ) {
return;
}
// Proceed when no custom Pro tables exist.
if ( $this->custom_tables_exist() ) {
return;
}
// Install on a current site only.
$this->create_custom_tables();
}
/**
* Allow the WordPress 5.5+ 'auto-updates' feature.
*
* 1) auto-updates for Lite should work as-is, no changes to the default logic
* for a plugin that is hosted on WP.org
* 2) auto-updates for Pro should be controlled using the default WP "Enable auto-updates" link.
* But when it's clicked - we enable it not only for Pro plugin (and updates are retrieved from our API
* as it currently works), but for all of our addons too.
* 3) auto-updates for addons can not be changed per addon. Instead of a link, we should display a plain text
* "Addon auto-updates controlled by WPForms".
* This way toggling auto-update for Pro will toggle that for ALL addons at once too.
*
* @since 1.6.4
*/
private function allow_wp_auto_update_plugins() {
// If license wasn't found. Is it the Lite version?
if ( ! wpforms_get_license_type() ) {
return;
}
add_filter( 'plugin_auto_update_setting_html', array( $this, 'auto_update_setting_html' ), 100, 3 );
add_filter( 'pre_update_site_option_auto_update_plugins', array( $this, 'update_auto_update_plugins_option' ), 100, 4 );
}
/**
* Filter the HTML of the auto-updates setting for WPForms addons.
*
* @since 1.6.2.2
* @since 1.6.4 Changed the HTML for WPForms addons only.
*
* @param string $html The HTML of the plugin's auto-update column content, including
* toggle auto-update action links and time to next update.
* @param string $plugin_file Path to the plugin file relative to the plugins directory.
* @param array $plugin_data An array of plugin data.
*
* @return string
*/
public function auto_update_setting_html( $html, $plugin_file, $plugin_data ) {
if ( empty( $plugin_data['Author'] ) ) {
return $html;
}
if ( $plugin_data['Author'] !== 'WPForms' ) {
return $html;
}
if ( 0 !== strpos( $plugin_file, 'wpforms' ) ) {
return $html;
}
$lite_pro_files = [
'wpforms-lite/wpforms.php',
'wpforms/wpforms.php',
];
if ( in_array( $plugin_file, $lite_pro_files, true ) ) {
return $html;
}
return esc_html__( 'Addon auto-updates controlled by WPForms', 'wpforms' );
}
/**
* Filter value, which is prepared for `auto_update_plugins` option before it's saved into DB.
* We need to include OR exclude all WPForms addons, depends on what status has main WPForms plugin.
*
* @since 1.6.2.2
* @since 1.6.4 Added dependency from the main WPForms plugin.
*
* @param mixed $plugins New plugins of the network option.
* @param mixed $old_plugins Old plugins of the network option.
* @param string $option Option name.
* @param int $network_id ID of the network.
*
* @return array
*/
public function update_auto_update_plugins_option( $plugins, $old_plugins, $option, $network_id ) {
// No need to filter out our plugins if none were saved.
if ( empty( $plugins ) ) {
return $plugins;
}
// Protection from a malformed data.
if ( ! is_array( $plugins ) ) {
return $plugins;
}
// Check whether auto-updates for plugins are supported and enabled. If not, return early.
if (
! function_exists( 'wp_is_auto_update_enabled_for_type' ) ||
! wp_is_auto_update_enabled_for_type( 'plugin' )
) {
return $plugins;
}
// Check whether auto-updates for main WPForms plugin is enabled.
// If so, enabled it for all WPForms plugins. Otherwise - disable for all WPForms plugins.
if ( in_array( 'wpforms/wpforms.php', $plugins, true ) ) {
$new_plugins = array_unique( array_merge( $plugins, $this->get_wpforms_plugins() ) );
} else {
$new_plugins = array_diff( $plugins, $this->get_wpforms_plugins() );
}
return $new_plugins;
}
/**
* Enqueue builder's assets.
*
* @since 1.7.5
* @deprecated 1.7.6
*
* @param string $view Current view.
*/
public function builder_enqueues( $view ) {
_deprecated_function( __METHOD__, '1.7.6 of the WPForms plugin', 'WPForms\Pro\Admin\Builder\Builder::builder_enqueues()' );
( new WPForms\Pro\Admin\Builder\Builder() )->builder_enqueues( $view );
}
/**
* Retrieve collection with WPForms plugins file paths.
*
* @since 1.6.2.2
*
* @return array
*/
protected function get_wpforms_plugins() {
$plugins = [];
$license = wpforms()->license;
if ( empty( $license ) ) {
return $plugins;
}
$addons_data = $license->addons();
if ( empty( $addons_data ) ) {
return $plugins;
}
$plugins = array_map(
static function( $slug ) {
return "{$slug}/{$slug}.php";
},
wp_list_pluck( $addons_data, 'slug' )
);
$plugins[] = 'wpforms/wpforms.php';
return $plugins;
}
}
return new WPForms_Pro();