*/ private const PLUGINS = [ 'wp-mail-smtp/wp_mail_smtp.php' => 'WP Mail SMTP', 'post-smtp/postman-smtp.php' => 'Post SMTP', 'easy-wp-smtp/easy-wp-smtp.php' => 'Easy WP SMTP', 'fluent-smtp/fluent-smtp.php' => 'FluentSMTP', 'mailgun/mailgun.php' => 'Mailgun', 'smtp-mailer/main.php' => 'SMTP Mailer', 'gmail-smtp/main.php' => 'Gmail SMTP', ]; /** * Label of an active SMTP plugin, if any. */ public function active_label(): ?string { $active = $this->active_plugin_files(); foreach ( self::PLUGINS as $file => $label ) { if ( in_array( $file, $active, true ) ) { return $label; } } return null; } /** * Active plugin basenames. * * @return list */ private function active_plugin_files(): array { if ( ! function_exists( 'get_option' ) ) { return []; } $raw = get_option( 'active_plugins', [] ); $out = []; if ( is_array( $raw ) ) { foreach ( $raw as $file ) { if ( is_string( $file ) && '' !== $file ) { $out[] = $file; } } } if ( function_exists( 'get_site_option' ) ) { $network = get_site_option( 'active_sitewide_plugins', [] ); if ( is_array( $network ) ) { foreach ( array_keys( $network ) as $file ) { if ( is_string( $file ) && '' !== $file ) { $out[] = $file; } } } } return array_values( array_unique( $out ) ); } }