| Server IP : 38.190.208.107 / Your IP : 216.73.217.46 Web Server : nginx/1.28.1 System : Linux ht2026040333114 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.37-1 (2023-07-03) x86_64 User : root ( 0) PHP Version : 8.2.28 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv,eval,assert,passthru,system,exec,shell_exec,popen,proc_open MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/wp.3/wp-content/plugins/wpforms-lite/src/Integrations/WPMailSMTP/ |
Upload File : |
<?php
namespace WPForms\Integrations\WPMailSMTP;
use WPMailSMTP\Options;
use WPForms\Integrations\IntegrationInterface;
/**
* WP Mail SMTP hints inside form builder notifications.
*
* @since 1.4.8
*/
class Notifications implements IntegrationInterface {
/**
* WP Mail SMTP options.
*
* @since 1.4.8
*
* @var Options
*/
public $options;
/**
* Indicate if current integration is allowed to load.
*
* @since 1.4.8
*
* @return bool
*/
public function allow_load() {
return wpforms_is_admin_page( 'builder' ) && function_exists( 'wp_mail_smtp' );
}
/**
* Load an integration.
*
* @since 1.4.8
*/
public function load() {
$this->options = new Options();
$this->hooks();
}
/**
* Integration filters.
*
* @since 1.4.8
*/
protected function hooks() {
add_filter( 'wpforms_builder_notifications_from_name_after', [ $this, 'from_name_after' ] );
add_filter( 'wpforms_builder_notifications_from_email_after', [ $this, 'from_email_after' ] );
add_filter( 'wpforms_builder_notifications_sender_name_settings', [ $this, 'change_from_name_settings' ], 10, 3 );
add_filter( 'wpforms_builder_notifications_sender_address_settings', [ $this, 'change_from_email_settings' ], 10, 3 );
add_action( 'wpforms_form_settings_notifications_single_after', [ $this, 'add_hidden_from_name_field' ], 10, 2 );
add_action( 'wpforms_form_settings_notifications_single_after', [ $this, 'add_hidden_from_email_field' ], 10, 2 );
}
/**
* Redefine From Name settings with data from WP Mail SMTP.
*
* @since 1.7.6
*
* @param array $args Field settings.
* @param array $form_data Form data.
* @param int $id Notification ID.
*
* @return array
*/
public function change_from_name_settings( $args, $form_data, $id ) {
if ( ! $this->options->get( 'mail', 'from_name_force' ) ) {
return $args;
}
$args['value'] = $this->options->get( 'mail', 'from_name' );
unset( $args['smarttags'] );
return $args;
}
/**
* Redefine From Email settings with data from WP Mail SMTP.
*
* @since 1.7.6
*
* @param array $args Field settings.
* @param array $form_data Form data.
* @param int $id Notification ID.
*
* @return array
*/
public function change_from_email_settings( $args, $form_data, $id ) {
if ( ! $this->options->get( 'mail', 'from_email_force' ) ) {
return $args;
}
$args['value'] = $this->options->get( 'mail', 'from_email' );
unset( $args['smarttags'] );
return $args;
}
/**
* Add hidden From Name field to overwrite value from WP Mail SMTP.
*
* @since 1.7.6
*
* @param array $settings Form settings.
* @param int $id Notification id.
*/
public function add_hidden_from_name_field( $settings, $id ) {
if ( empty( $settings->form_data['settings']['notifications'][ $id ]['sender_name'] ) || ! $this->options->get( 'mail', 'from_name_force' ) ) {
return;
}
wpforms_panel_field(
'text',
'notifications',
'sender_name',
$settings->form_data,
'',
[
'parent' => 'settings',
'subsection' => $id,
'readonly' => true,
'class' => 'wpforms-hidden',
'value' => $settings->form_data['settings']['notifications'][ $id ]['sender_name'],
]
);
}
/**
* Add hidden From Email field to overwrite value from WP Mail SMTP.
*
* @since 1.7.6
*
* @param array $settings Form settings.
* @param int $id Notification id.
*/
public function add_hidden_from_email_field( $settings, $id ) {
if ( empty( $settings->form_data['settings']['notifications'][ $id ]['sender_address'] ) || ! $this->options->get( 'mail', 'from_email_force' ) ) {
return;
}
wpforms_panel_field(
'text',
'notifications',
'sender_address',
$settings->form_data,
'',
[
'parent' => 'settings',
'subsection' => $id,
'readonly' => true,
'class' => 'wpforms-hidden',
'value' => $settings->form_data['settings']['notifications'][ $id ]['sender_address'],
]
);
}
/**
* Display hint if WP Mail SMTP is forcing from name.
*
* @since 1.4.8
*
* @param string $after Text displayed after setting.
*
* @return string
*/
public function from_name_after( $after ) {
if ( ! $this->options->get( 'mail', 'from_name_force' ) ) {
return $after;
}
return sprintf(
wp_kses( /* translators: %s - URL WP Mail SMTP settings. */
__( 'This setting is disabled because you have the "Force From Name" setting enabled in the <a href="%s" target="_blank">WP Mail SMTP</a> plugin.', 'wpforms-lite' ),
[
'a' => [
'href' => [],
'target' => [],
],
]
),
esc_url( admin_url( 'options-general.php?page=wp-mail-smtp#wp-mail-smtp-setting-row-from_name' ) )
);
}
/**
* Display hint if WP Mail SMTP is forcing from email.
*
* @since 1.4.8
*
* @param string $after Text displayed after setting.
*
* @return string
*/
public function from_email_after( $after ) {
if ( ! $this->options->get( 'mail', 'from_email_force' ) ) {
return $after;
}
return sprintf(
wp_kses( /* translators: %s - URL WP Mail SMTP settings. */
__( 'This setting is disabled because you have the "Force From Email" setting enabled in the <a href="%s" target="_blank">WP Mail SMTP</a> plugin.', 'wpforms-lite' ),
[
'a' => [
'href' => [],
'target' => [],
],
]
),
esc_url( admin_url( 'options-general.php?page=wp-mail-smtp#wp-mail-smtp-setting-row-from_email' ) )
);
}
}