/home/altere25/public_html/wp-content/plugins/formidable/classes/controllers
Edit: /home/altere25/public_html/wp-content/plugins/formidable/classes/controllers/FrmSMTPController.php (16938B)
'wp-mail-smtp/wp_mail_smtp.php',
'lite_download_url' => 'https://downloads.wordpress.org/plugin/wp-mail-smtp.zip',
'pro_plugin' => 'wp-mail-smtp-pro/wp_mail_smtp.php',
'smtp_settings' => 'admin.php?page=wp-mail-smtp',
);
/**
* Runtime data used for generating page HTML.
*
* @since 4.04.04
*
* @var array
*/
private $output_data = array();
/**
* Hooks.
*
* @since 4.04.04
*
* @return void
*/
public static function load_hooks() {
add_filter( 'wp_mail_smtp_is_white_labeled', '__return_true' );
$self = new self();
if ( wp_doing_ajax() ) {
add_action( 'wp_ajax_frm_smtp_page_check_plugin_status', array( $self, 'ajax_check_plugin_status' ) );
}
add_filter( 'wp_mail_smtp_core_get_upgrade_link', array( $self, 'link' ) );
add_action( 'admin_menu', array( $self, 'menu' ), 999 );
add_action( 'wp_mail_smtp_core_recommendations_plugins', 'FrmSMTPController::remove_wpforms_nag' );
// Only load if we are actually on the SMTP page.
if ( ! FrmAppHelper::is_admin_page( $self->slug ) ) {
return;
}
add_action( 'admin_init', array( $self, 'redirect_to_smtp_settings' ) );
// Hook for addons.
do_action( 'frm_admin_pages_smtp_hooks' );
}
/**
* Customize the upgrade link.
*
* @return string
*/
public function link( $link ) {
$new_link = 'formidableforms.com/go-wp-mail-smtp/?urllink=wpmailsmtp%2Ecom%2Flite%2Dupgrade&';
$link = str_replace( 'wpmailsmtp.com/lite-upgrade/?', $new_link, $link );
return $link;
}
/**
* Don't nag people to install WPForms
*
* @since 4.04.04
*/
public static function remove_wpforms_nag( $upsell ) {
if ( is_array( $upsell ) ) {
foreach ( $upsell as $k => $plugin ) {
if ( strpos( $plugin['slug'], 'wpforms' ) !== false ) {
unset( $upsell[ $k ] );
}
}
}
return $upsell;
}
/**
* SMTP submenu page.
*
* @return void
*/
public function menu() {
add_submenu_page( 'formidable', __( 'SMTP', 'formidable' ) . ' | Formidable', __( 'SMTP', 'formidable' ), 'activate_plugins', $this->slug, array( $this, 'output' ) );
}
/**
* Generate and output page HTML.
*
* @since 4.04.04
*
* @return void
*/
public function output() {
FrmAppHelper::include_svg();
$this->css();
echo '
';
$this->output_section_heading();
$this->output_section_screenshot();
$this->output_section_step_install();
$this->output_section_step_setup();
echo '
';
}
/**
* Generate and output heading section HTML.
*
* @since 4.04.04
*
* @return void
*/
protected function output_section_heading() {
$size = array(
'height' => 90,
'width' => 90,
);
// Heading section.
?>
'Loves',
'style' => 'width:30px;height:30px;margin:0 35px;',
'color' => '#d11c25',
)
);
$this->stmp_logo();
?>
- %3$s %4$s
- %3$s %5$s
- %3$s %6$s
- %3$s %7$s
',
esc_url( FrmAppHelper::plugin_url() . '/images/smtp-screenshot-tnail.png' ),
esc_attr__( 'WP Mail SMTP screenshot', 'formidable' ),
'
',
esc_html__( 'Over 1,000,000 websites use WP Mail SMTP.', 'formidable' ),
esc_html__( 'Send emails authenticated via trusted parties.', 'formidable' ),
esc_html__( 'Transactional Mailers: Pepipost, SendinBlue, Mailgun, SendGrid, Amazon SES.', 'formidable' ),
esc_html__( 'Web Mailers: Gmail, G Suite, Office 365, Outlook.com.', 'formidable' )
);
}
/**
* Generate and output step 'Install' section HTML.
*
* @since 4.04.04
*
* @return void
*/
protected function output_section_step_install() {
$step = $this->get_data_step_install();
if ( empty( $step ) ) {
return;
}
$icon = FrmAppHelper::icon_by_class(
'frmfont ' . $step['icon'],
array(
'aria-label' => __( 'Step 1', 'formidable' ),
'echo' => false,
'style' => 'width:50px;height:50px;',
)
);
/* translators: %s: Name of the plugin */
$label = sprintf( __( 'Install and Activate %s', 'formidable' ), 'WP Mail SMTP' );
printf(
'
',
FrmAppHelper::kses( $icon, array( 'a', 'i', 'span', 'use', 'svg' ) ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
esc_html( $label ),
esc_html__( 'Install WP Mail SMTP from the WordPress.org plugin repository.', 'formidable' ),
esc_attr( $step['plugin'] ),
esc_attr( $step['button_class'] ),
esc_attr( $step['button_action'] ),
esc_html( $step['button_text'] )
);
}
/**
* Generate and output step 'Setup' section HTML.
*
* @since 4.04.04
*
* @return void
*/
protected function output_section_step_setup() {
$step = $this->get_data_step_setup();
if ( empty( $step ) ) {
return;
}
$icon = FrmAppHelper::icon_by_class(
'frmfont ' . $step['icon'],
array(
'aria-label' => __( 'Step 2', 'formidable' ),
'echo' => false,
'style' => 'width:50px;height:50px;',
)
);
printf(
'
',
esc_attr( $step['section_class'] ),
FrmAppHelper::kses( $icon, array( 'a', 'i', 'span', 'use', 'svg' ) ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
esc_html__( 'Set Up WP Mail SMTP', 'formidable' ),
esc_html__( 'Select and configure your mailer.', 'formidable' ),
esc_url( admin_url( $this->config['smtp_settings'] ) ),
esc_attr( $step['button_class'] ),
esc_html( $step['button_text'] )
);
}
/**
* Step 'Install' data.
*
* @since 4.04.04
*
* @return array Step data.
*/
protected function get_data_step_install() {
$lite_plugin = new FrmInstallPlugin( array( 'plugin_file' => $this->config['lite_plugin'] ) );
$pro_plugin = new FrmInstallPlugin( array( 'plugin_file' => $this->config['pro_plugin'] ) );
$this->output_data['plugin_installed'] = $lite_plugin->is_installed();
$this->output_data['pro_plugin_installed'] = $pro_plugin->is_installed();
$this->output_data['plugin_activated'] = false;
$this->output_data['plugin_setup'] = false;
$step = array(
'icon' => 'frm_step1_icon',
'button_action' => '',
);
$is_installed = $this->output_data['plugin_installed'] || $this->output_data['pro_plugin_installed'];
if ( ! $is_installed ) {
// Return the download url.
$step['button_text'] = __( 'Install WP Mail SMTP', 'formidable' );
$step['button_class'] = 'frm-install-addon';
$step['button_action'] = __( 'Install', 'formidable' );
$step['plugin'] = $this->config['lite_download_url'];
return $step;
}
$this->output_data['plugin_activated'] = $this->is_smtp_activated();
$this->output_data['plugin_setup'] = $this->is_smtp_configured();
$step['plugin'] = $this->output_data['pro_plugin_installed'] ? $this->config['pro_plugin'] : $this->config['lite_plugin'];
if ( $this->output_data['plugin_activated'] ) {
$step['icon'] = 'frm_step_complete_icon';
$step['button_text'] = __( 'WP Mail SMTP Installed & Activated', 'formidable' );
$step['button_class'] = 'grey disabled';
} else {
$step['button_text'] = __( 'Activate WP Mail SMTP', 'formidable' );
$step['button_class'] = 'frm-activate-addon';
$step['button_action'] = __( 'Activate', 'formidable' );
}
return $step;
}
/**
* Step 'Setup' data.
*
* @since 4.04.04
*
* @return array Step data.
*/
protected function get_data_step_setup() {
$step = array();
$step['icon'] = 'frm_step2_icon';
$step['section_class'] = $this->output_data['plugin_activated'] ? '' : 'grey';
$step['button_text'] = esc_html__( 'Start Setup', 'formidable' );
$step['button_class'] = 'grey disabled';
if ( $this->output_data['plugin_setup'] ) {
$step['icon'] = 'frm_step_complete_icon';
$step['section_class'] = '';
$step['button_text'] = esc_html__( 'Go to SMTP settings', 'formidable' );
} elseif ( $this->output_data['plugin_activated'] ) {
$step['button_class'] = '';
}
return $step;
}
/**
* Whether WP Mail SMTP plugin configured or not.
*
* @since 4.04.04
*
* @return bool True if some mailer is selected and configured properly.
*/
protected function is_smtp_configured() {
if ( ! $this->is_smtp_activated() ) {
return false;
}
$phpmailer = $this->get_phpmailer();
$mailer = WPMailSMTP\Options::init()->get( 'mail', 'mailer' );
$is_mailer_complete = wp_mail_smtp()->get_providers()->get_mailer( $mailer, $phpmailer )->is_mailer_complete();
return 'mail' !== $mailer && $is_mailer_complete;
}
/**
* Whether WP Mail SMTP plugin active or not.
*
* @since 4.04.04
*
* @return bool True if SMTP plugin is active.
*/
protected function is_smtp_activated() {
return function_exists( 'wp_mail_smtp' ) && ( is_plugin_active( $this->config['lite_plugin'] ) || is_plugin_active( $this->config['pro_plugin'] ) );
}
/**
* Get $phpmailer instance.
*
* @since 4.04.04
*
* @return PHPMailer|\WPMailSMTP\Providers\MailCatcherInterface Instance of PHPMailer.
*/
protected function get_phpmailer() {
global $phpmailer;
if ( ! is_object( $phpmailer ) || ! is_a( $phpmailer, 'PHPMailer' ) ) {
if ( is_callable( array( wp_mail_smtp(), 'generate_mail_catcher' ) ) ) {
$phpmailer = wp_mail_smtp()->generate_mail_catcher( true ); // phpcs:ignore
} else {
require_once ABSPATH . WPINC . '/class-phpmailer.php';
$phpmailer = new PHPMailer( true ); // phpcs:ignore
}
}
return $phpmailer;
}
/**
* Redirect to SMTP settings page if it is activated..
*
* @since 4.04.04
*
* @return void
*/
public function redirect_to_smtp_settings() {
if ( $this->is_smtp_configured() ) {
wp_safe_redirect( admin_url( $this->config['smtp_settings'] ) );
exit;
}
}
/**
* @return void
*/
private function stmp_logo() {
?>