AmazonSES
1 year ago
ElasticEmail
1 year ago
Gmail
1 year ago
Mail
1 year ago
Mailgun
1 year ago
Mailjet
1 year ago
Outlook
1 year ago
Pepipost
1 year ago
PepipostAPI
1 year ago
Postmark
1 year ago
SMTP
1 year ago
SMTP2GO
1 year ago
SMTPcom
1 year ago
Sendgrid
1 year ago
Sendinblue
1 year ago
Sendlayer
1 year ago
SparkPost
1 year ago
Zoho
1 year ago
AuthAbstract.php
1 year ago
AuthInterface.php
1 year ago
Loader.php
1 year ago
MailerAbstract.php
1 year ago
MailerInterface.php
1 year ago
OptionsAbstract.php
1 year ago
OptionsInterface.php
1 year ago
OptionsAbstract.php
564 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WPMailSMTP\Providers; |
| 4 | |
| 5 | use WPMailSMTP\ConnectionInterface; |
| 6 | use WPMailSMTP\Helpers\UI; |
| 7 | use WPMailSMTP\Options; |
| 8 | |
| 9 | /** |
| 10 | * Abstract Class ProviderAbstract to contain common providers functionality. |
| 11 | * |
| 12 | * @since 1.0.0 |
| 13 | */ |
| 14 | abstract class OptionsAbstract implements OptionsInterface { |
| 15 | |
| 16 | /** |
| 17 | * @var string |
| 18 | */ |
| 19 | private $logo_url = ''; |
| 20 | /** |
| 21 | * @var string |
| 22 | */ |
| 23 | private $slug = ''; |
| 24 | /** |
| 25 | * @var string |
| 26 | */ |
| 27 | private $title = ''; |
| 28 | /** |
| 29 | * @var string |
| 30 | */ |
| 31 | private $description = ''; |
| 32 | /** |
| 33 | * @since 1.6.0 |
| 34 | * |
| 35 | * @var array |
| 36 | */ |
| 37 | private $notices = array(); |
| 38 | /** |
| 39 | * @since 1.6.0 |
| 40 | * |
| 41 | * @var bool |
| 42 | */ |
| 43 | private $recommended = false; |
| 44 | /** |
| 45 | * @since 1.7.0 |
| 46 | * |
| 47 | * @var bool |
| 48 | */ |
| 49 | private $disabled = false; |
| 50 | /** |
| 51 | * @var string |
| 52 | */ |
| 53 | private $php = WPMS_PHP_VER; |
| 54 | /** |
| 55 | * @var Options |
| 56 | */ |
| 57 | protected $options; |
| 58 | |
| 59 | /** |
| 60 | * An array with mailer supported setting fields. |
| 61 | * |
| 62 | * @since 2.3.0 |
| 63 | * |
| 64 | * @var array |
| 65 | */ |
| 66 | protected $supports; |
| 67 | |
| 68 | /** |
| 69 | * The Connection object. |
| 70 | * |
| 71 | * @since 3.7.0 |
| 72 | * |
| 73 | * @var ConnectionInterface |
| 74 | */ |
| 75 | protected $connection; |
| 76 | |
| 77 | /** |
| 78 | * The connection options object. |
| 79 | * |
| 80 | * @since 3.7.0 |
| 81 | * |
| 82 | * @var Options |
| 83 | */ |
| 84 | protected $connection_options; |
| 85 | |
| 86 | /** |
| 87 | * ProviderAbstract constructor. |
| 88 | * |
| 89 | * @since 1.0.0 |
| 90 | * @since 2.3.0 Added supports parameter. |
| 91 | * |
| 92 | * @param array $params The mailer options parameters. |
| 93 | * @param ConnectionInterface $connection The Connection object. |
| 94 | */ |
| 95 | public function __construct( $params, $connection = null ) { // phpcs:ignore Generic.Metrics.CyclomaticComplexity.MaxExceeded |
| 96 | |
| 97 | if ( ! is_null( $connection ) ) { |
| 98 | $this->connection = $connection; |
| 99 | } else { |
| 100 | $this->connection = wp_mail_smtp()->get_connections_manager()->get_primary_connection(); |
| 101 | } |
| 102 | |
| 103 | $this->connection_options = $this->connection->get_options(); |
| 104 | |
| 105 | if ( |
| 106 | empty( $params['slug'] ) || |
| 107 | empty( $params['title'] ) |
| 108 | ) { |
| 109 | return; |
| 110 | } |
| 111 | |
| 112 | $this->slug = sanitize_key( $params['slug'] ); |
| 113 | $this->title = sanitize_text_field( $params['title'] ); |
| 114 | |
| 115 | if ( ! empty( $params['description'] ) ) { |
| 116 | $this->description = wp_kses_post( $params['description'] ); |
| 117 | } |
| 118 | |
| 119 | if ( ! empty( $params['notices'] ) ) { |
| 120 | foreach ( (array) $params['notices'] as $key => $notice ) { |
| 121 | $key = sanitize_key( $key ); |
| 122 | if ( empty( $key ) ) { |
| 123 | continue; |
| 124 | } |
| 125 | |
| 126 | $notice = wp_kses( |
| 127 | $notice, |
| 128 | array( |
| 129 | 'br' => true, |
| 130 | 'strong' => true, |
| 131 | 'em' => true, |
| 132 | 'a' => array( |
| 133 | 'href' => true, |
| 134 | 'rel' => true, |
| 135 | 'target' => true, |
| 136 | ), |
| 137 | ) |
| 138 | ); |
| 139 | if ( empty( $notice ) ) { |
| 140 | continue; |
| 141 | } |
| 142 | |
| 143 | $this->notices[ $key ] = $notice; |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | if ( isset( $params['recommended'] ) ) { |
| 148 | $this->recommended = (bool) $params['recommended']; |
| 149 | } |
| 150 | if ( isset( $params['disabled'] ) ) { |
| 151 | $this->disabled = (bool) $params['disabled']; |
| 152 | } |
| 153 | |
| 154 | if ( ! empty( $params['php'] ) ) { |
| 155 | $this->php = sanitize_text_field( $params['php'] ); |
| 156 | } |
| 157 | |
| 158 | if ( ! empty( $params['logo_url'] ) ) { |
| 159 | $this->logo_url = esc_url_raw( $params['logo_url'] ); |
| 160 | } |
| 161 | |
| 162 | $this->supports = ( ! empty( $params['supports'] ) ) ? $params['supports'] : $this->get_supports_defaults(); |
| 163 | |
| 164 | $this->options = Options::init(); |
| 165 | } |
| 166 | |
| 167 | /** |
| 168 | * @inheritdoc |
| 169 | */ |
| 170 | public function get_logo_url() { |
| 171 | return apply_filters( 'wp_mail_smtp_providers_provider_get_logo_url', $this->logo_url, $this ); |
| 172 | } |
| 173 | |
| 174 | /** |
| 175 | * @inheritdoc |
| 176 | */ |
| 177 | public function get_slug() { |
| 178 | return apply_filters( 'wp_mail_smtp_providers_provider_get_slug', $this->slug, $this ); |
| 179 | } |
| 180 | |
| 181 | /** |
| 182 | * @inheritdoc |
| 183 | */ |
| 184 | public function get_title() { |
| 185 | return apply_filters( 'wp_mail_smtp_providers_provider_get_title', $this->title, $this ); |
| 186 | } |
| 187 | |
| 188 | /** |
| 189 | * @inheritdoc |
| 190 | */ |
| 191 | public function get_description() { |
| 192 | return apply_filters( 'wp_mail_smtp_providers_provider_get_description', $this->description, $this ); |
| 193 | } |
| 194 | |
| 195 | /** |
| 196 | * Get the mailer provider notices. |
| 197 | * |
| 198 | * @since 4.3.0 |
| 199 | * |
| 200 | * @return array |
| 201 | */ |
| 202 | public function get_notices() { |
| 203 | |
| 204 | return apply_filters( 'wp_mail_smtp_providers_provider_get_notices', $this->notices, $this ); |
| 205 | } |
| 206 | |
| 207 | /** |
| 208 | * Some mailers may display a notice above its options. |
| 209 | * |
| 210 | * @since 1.6.0 |
| 211 | * |
| 212 | * @param string $type |
| 213 | * |
| 214 | * @return string |
| 215 | */ |
| 216 | public function get_notice( $type ) { |
| 217 | |
| 218 | $type = sanitize_key( $type ); |
| 219 | |
| 220 | return apply_filters( 'wp_mail_smtp_providers_provider_get_notice', isset( $this->notices[ $type ] ) ? $this->notices[ $type ] : '', $this ); |
| 221 | } |
| 222 | |
| 223 | /** |
| 224 | * @inheritdoc |
| 225 | */ |
| 226 | public function get_php_version() { |
| 227 | return apply_filters( 'wp_mail_smtp_providers_provider_get_php_version', $this->php, $this ); |
| 228 | } |
| 229 | |
| 230 | /** |
| 231 | * @inheritdoc |
| 232 | */ |
| 233 | public function display_options() { |
| 234 | ?> |
| 235 | |
| 236 | <!-- SMTP Host --> |
| 237 | <div id="wp-mail-smtp-setting-row-<?php echo esc_attr( $this->get_slug() ); ?>-host" class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-text wp-mail-smtp-clear"> |
| 238 | <div class="wp-mail-smtp-setting-label"> |
| 239 | <label for="wp-mail-smtp-setting-<?php echo esc_attr( $this->get_slug() ); ?>-host"><?php esc_html_e( 'SMTP Host', 'wp-mail-smtp' ); ?></label> |
| 240 | </div> |
| 241 | <div class="wp-mail-smtp-setting-field"> |
| 242 | <input name="wp-mail-smtp[<?php echo esc_attr( $this->get_slug() ); ?>][host]" type="text" |
| 243 | value="<?php echo esc_attr( $this->connection_options->get( $this->get_slug(), 'host' ) ); ?>" |
| 244 | <?php echo $this->connection_options->is_const_defined( $this->get_slug(), 'host' ) ? 'disabled' : ''; ?> |
| 245 | id="wp-mail-smtp-setting-<?php echo esc_attr( $this->get_slug() ); ?>-host" spellcheck="false" |
| 246 | /> |
| 247 | </div> |
| 248 | </div> |
| 249 | |
| 250 | <!-- SMTP Encryption --> |
| 251 | <div id="wp-mail-smtp-setting-row-<?php echo esc_attr( $this->get_slug() ); ?>-encryption" class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-radio wp-mail-smtp-clear"> |
| 252 | <div class="wp-mail-smtp-setting-label"> |
| 253 | <label><?php esc_html_e( 'Encryption', 'wp-mail-smtp' ); ?></label> |
| 254 | </div> |
| 255 | <div class="wp-mail-smtp-setting-field"> |
| 256 | |
| 257 | <label for="wp-mail-smtp-setting-<?php echo esc_attr( $this->get_slug() ); ?>-enc-none"> |
| 258 | <input type="radio" id="wp-mail-smtp-setting-<?php echo esc_attr( $this->get_slug() ); ?>-enc-none" |
| 259 | name="wp-mail-smtp[<?php echo esc_attr( $this->get_slug() ); ?>][encryption]" value="none" |
| 260 | <?php echo $this->connection_options->is_const_defined( $this->get_slug(), 'encryption' ) ? 'disabled' : ''; ?> |
| 261 | <?php checked( 'none', $this->connection_options->get( $this->get_slug(), 'encryption' ) ); ?> |
| 262 | /> |
| 263 | <?php esc_html_e( 'None', 'wp-mail-smtp' ); ?> |
| 264 | </label> |
| 265 | |
| 266 | <label for="wp-mail-smtp-setting-<?php echo esc_attr( $this->get_slug() ); ?>-enc-ssl"> |
| 267 | <input type="radio" id="wp-mail-smtp-setting-<?php echo esc_attr( $this->get_slug() ); ?>-enc-ssl" |
| 268 | name="wp-mail-smtp[<?php echo esc_attr( $this->get_slug() ); ?>][encryption]" value="ssl" |
| 269 | <?php echo $this->connection_options->is_const_defined( $this->get_slug(), 'encryption' ) ? 'disabled' : ''; ?> |
| 270 | <?php checked( 'ssl', $this->connection_options->get( $this->get_slug(), 'encryption' ) ); ?> |
| 271 | /> |
| 272 | <?php esc_html_e( 'SSL', 'wp-mail-smtp' ); ?> |
| 273 | </label> |
| 274 | |
| 275 | <label for="wp-mail-smtp-setting-<?php echo esc_attr( $this->get_slug() ); ?>-enc-tls"> |
| 276 | <input type="radio" id="wp-mail-smtp-setting-<?php echo esc_attr( $this->get_slug() ); ?>-enc-tls" |
| 277 | name="wp-mail-smtp[<?php echo esc_attr( $this->get_slug() ); ?>][encryption]" value="tls" |
| 278 | <?php echo $this->connection_options->is_const_defined( $this->get_slug(), 'encryption' ) ? 'disabled' : ''; ?> |
| 279 | <?php checked( 'tls', $this->connection_options->get( $this->get_slug(), 'encryption' ) ); ?> |
| 280 | /> |
| 281 | <?php esc_html_e( 'TLS', 'wp-mail-smtp' ); ?> |
| 282 | </label> |
| 283 | |
| 284 | <p class="desc"> |
| 285 | <?php esc_html_e( 'For most servers TLS is the recommended option. If your SMTP provider offers both SSL and TLS options, we recommend using TLS.', 'wp-mail-smtp' ); ?> |
| 286 | </p> |
| 287 | </div> |
| 288 | </div> |
| 289 | |
| 290 | <!-- SMTP Port --> |
| 291 | <div id="wp-mail-smtp-setting-row-<?php echo esc_attr( $this->get_slug() ); ?>-port" class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-number wp-mail-smtp-clear"> |
| 292 | <div class="wp-mail-smtp-setting-label"> |
| 293 | <label for="wp-mail-smtp-setting-<?php echo esc_attr( $this->get_slug() ); ?>-port"><?php esc_html_e( 'SMTP Port', 'wp-mail-smtp' ); ?></label> |
| 294 | </div> |
| 295 | <div class="wp-mail-smtp-setting-field"> |
| 296 | <input name="wp-mail-smtp[<?php echo esc_attr( $this->get_slug() ); ?>][port]" type="number" |
| 297 | value="<?php echo esc_attr( $this->connection_options->get( $this->get_slug(), 'port' ) ); ?>" |
| 298 | <?php echo $this->connection_options->is_const_defined( $this->get_slug(), 'port' ) ? 'disabled' : ''; ?> |
| 299 | id="wp-mail-smtp-setting-<?php echo esc_attr( $this->get_slug() ); ?>-port" class="small-text" spellcheck="false" |
| 300 | /> |
| 301 | </div> |
| 302 | </div> |
| 303 | |
| 304 | <!-- PHPMailer SMTPAutoTLS --> |
| 305 | <div id="wp-mail-smtp-setting-row-<?php echo esc_attr( $this->get_slug() ); ?>-autotls" class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-checkbox-toggle wp-mail-smtp-clear <?php echo $this->connection_options->is_const_defined( $this->get_slug(), 'encryption' ) || 'tls' === $this->connection_options->get( $this->get_slug(), 'encryption' ) ? 'inactive' : ''; ?>"> |
| 306 | <div class="wp-mail-smtp-setting-label"> |
| 307 | <label for="wp-mail-smtp-setting-<?php echo esc_attr( $this->get_slug() ); ?>-autotls"><?php esc_html_e( 'Auto TLS', 'wp-mail-smtp' ); ?></label> |
| 308 | </div> |
| 309 | <div class="wp-mail-smtp-setting-field"> |
| 310 | <?php |
| 311 | UI::toggle( |
| 312 | [ |
| 313 | 'name' => 'wp-mail-smtp[' . $this->get_slug() . '][autotls]', |
| 314 | 'id' => 'wp-mail-smtp-setting-' . $this->get_slug() . '-autotls', |
| 315 | 'checked' => (bool) $this->connection_options->get( $this->get_slug(), 'autotls' ), |
| 316 | 'disabled' => $this->connection_options->is_const_defined( $this->get_slug(), 'autotls' ), |
| 317 | ] |
| 318 | ); |
| 319 | ?> |
| 320 | <p class="desc"> |
| 321 | <?php esc_html_e( 'By default, TLS encryption is automatically used if the server supports it (recommended). In some cases, due to server misconfigurations, this can cause issues and may need to be disabled.', 'wp-mail-smtp' ); ?> |
| 322 | </p> |
| 323 | </div> |
| 324 | </div> |
| 325 | |
| 326 | <!-- SMTP Authentication --> |
| 327 | <div id="wp-mail-smtp-setting-row-<?php echo esc_attr( $this->get_slug() ); ?>-auth" class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-checkbox-toggle wp-mail-smtp-clear"> |
| 328 | <div class="wp-mail-smtp-setting-label"> |
| 329 | <label for="wp-mail-smtp-setting-<?php echo esc_attr( $this->get_slug() ); ?>-auth"><?php esc_html_e( 'Authentication', 'wp-mail-smtp' ); ?></label> |
| 330 | </div> |
| 331 | <div class="wp-mail-smtp-setting-field"> |
| 332 | <?php |
| 333 | UI::toggle( |
| 334 | [ |
| 335 | 'name' => 'wp-mail-smtp[' . $this->get_slug() . '][auth]', |
| 336 | 'id' => 'wp-mail-smtp-setting-' . $this->get_slug() . '-auth', |
| 337 | 'checked' => (bool) $this->connection_options->get( $this->get_slug(), 'auth' ), |
| 338 | 'disabled' => $this->connection_options->is_const_defined( $this->get_slug(), 'auth' ), |
| 339 | ] |
| 340 | ); |
| 341 | ?> |
| 342 | </div> |
| 343 | </div> |
| 344 | |
| 345 | <!-- SMTP Username --> |
| 346 | <div id="wp-mail-smtp-setting-row-<?php echo esc_attr( $this->get_slug() ); ?>-user" class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-text wp-mail-smtp-clear <?php echo ! $this->connection_options->get( $this->get_slug(), 'auth' ) ? 'inactive' : ''; ?>"> |
| 347 | <div class="wp-mail-smtp-setting-label"> |
| 348 | <label for="wp-mail-smtp-setting-<?php echo esc_attr( $this->get_slug() ); ?>-user"><?php esc_html_e( 'SMTP Username', 'wp-mail-smtp' ); ?></label> |
| 349 | </div> |
| 350 | <div class="wp-mail-smtp-setting-field"> |
| 351 | <input name="wp-mail-smtp[<?php echo esc_attr( $this->get_slug() ); ?>][user]" type="text" |
| 352 | value="<?php echo esc_attr( $this->connection_options->get( $this->get_slug(), 'user' ) ); ?>" |
| 353 | <?php echo $this->connection_options->is_const_defined( $this->get_slug(), 'user' ) ? 'disabled' : ''; ?> |
| 354 | id="wp-mail-smtp-setting-<?php echo esc_attr( $this->get_slug() ); ?>-user" spellcheck="false" autocomplete="new-password" |
| 355 | /> |
| 356 | </div> |
| 357 | </div> |
| 358 | |
| 359 | <!-- SMTP Password --> |
| 360 | <div id="wp-mail-smtp-setting-row-<?php echo esc_attr( $this->get_slug() ); ?>-pass" class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-password wp-mail-smtp-clear <?php echo ! $this->connection_options->get( $this->get_slug(), 'auth' ) ? 'inactive' : ''; ?>"> |
| 361 | <div class="wp-mail-smtp-setting-label"> |
| 362 | <label for="wp-mail-smtp-setting-<?php echo esc_attr( $this->get_slug() ); ?>-pass"><?php esc_html_e( 'SMTP Password', 'wp-mail-smtp' ); ?></label> |
| 363 | </div> |
| 364 | <div class="wp-mail-smtp-setting-field"> |
| 365 | <?php if ( $this->connection_options->is_const_defined( $this->get_slug(), 'pass' ) ) : ?> |
| 366 | <input type="text" value="*************" disabled id="wp-mail-smtp-setting-<?php echo esc_attr( $this->get_slug() ); ?>-pass"/> |
| 367 | |
| 368 | <?php $this->display_const_set_message( 'WPMS_SMTP_PASS' ); ?> |
| 369 | |
| 370 | <p class="desc"> |
| 371 | <?php |
| 372 | printf( |
| 373 | /* translators: %s - constant name: WPMS_SMTP_PASS. */ |
| 374 | esc_html__( 'To change the password you need to change the value of the constant there: %s', 'wp-mail-smtp' ), |
| 375 | '<code>define( \'WPMS_SMTP_PASS\', \'your_old_password\' );</code>' |
| 376 | ); |
| 377 | ?> |
| 378 | <br> |
| 379 | <?php |
| 380 | printf( |
| 381 | /* translators: %1$s - wp-config.php file, %2$s - WPMS_ON constant name. */ |
| 382 | esc_html__( 'If you want to disable the use of constants, find in %1$s file the constant %2$s and turn if off:', 'wp-mail-smtp' ), |
| 383 | '<code>wp-config.php</code>', |
| 384 | '<code>WPMS_ON</code>' |
| 385 | ); |
| 386 | ?> |
| 387 | </p> |
| 388 | <pre> |
| 389 | define( 'WPMS_ON', false ); |
| 390 | </pre> |
| 391 | <p class="desc"> |
| 392 | <?php esc_html_e( 'All the defined constants will stop working and you will be able to change all the values on this page.', 'wp-mail-smtp' ); ?> |
| 393 | </p> |
| 394 | <?php else : ?> |
| 395 | |
| 396 | <?php |
| 397 | $slug = $this->get_slug(); |
| 398 | $value = $this->connection_options->get( $slug, 'pass' ); |
| 399 | |
| 400 | UI::hidden_password_field( |
| 401 | [ |
| 402 | 'name' => "wp-mail-smtp[{$slug}][pass]", |
| 403 | 'id' => "wp-mail-smtp-setting-{$slug}-pass", |
| 404 | 'value' => $value, |
| 405 | 'clear_text' => esc_html__( 'Remove Password', 'wp-mail-smtp' ), |
| 406 | ] |
| 407 | ); |
| 408 | ?> |
| 409 | |
| 410 | <p class="desc"> |
| 411 | <?php esc_html_e( 'The password is encrypted in the database, but for improved security we recommend using your site\'s WordPress configuration file to set your password.', 'wp-mail-smtp' ); ?> |
| 412 | <br> |
| 413 | <?php |
| 414 | printf( |
| 415 | '<a href="%1$s" target="_blank" rel="noopener noreferrer"><strong>%2$s</strong></a>', |
| 416 | esc_url( wp_mail_smtp()->get_utm_url( 'https://wpmailsmtp.com/docs/how-to-secure-smtp-settings-by-using-constants/', 'SMTP Password - Learn More' ) ), |
| 417 | esc_html__( 'Learn More', 'wp-mail-smtp' ) |
| 418 | ) |
| 419 | ?> |
| 420 | </p> |
| 421 | <?php endif; ?> |
| 422 | </div> |
| 423 | </div> |
| 424 | |
| 425 | <?php |
| 426 | } |
| 427 | |
| 428 | /** |
| 429 | * Whether this mailer is recommended or not. |
| 430 | * |
| 431 | * @since 1.6.0 |
| 432 | * |
| 433 | * @return bool |
| 434 | */ |
| 435 | public function is_recommended() { |
| 436 | |
| 437 | return (bool) apply_filters( 'wp_mail_smtp_providers_provider_is_recommended', $this->recommended, $this ); |
| 438 | } |
| 439 | |
| 440 | /** |
| 441 | * Whether this mailer is disabled or not. |
| 442 | * Used for displaying Pro mailers inside Lite plugin. |
| 443 | * |
| 444 | * @since 1.7.0 |
| 445 | * |
| 446 | * @return bool |
| 447 | */ |
| 448 | public function is_disabled() { |
| 449 | |
| 450 | return (bool) apply_filters( 'wp_mail_smtp_providers_provider_is_disabled', $this->disabled, $this ); |
| 451 | } |
| 452 | |
| 453 | /** |
| 454 | * Check whether we can use this provider based on the PHP version. |
| 455 | * Valid for those, that use SDK. |
| 456 | * |
| 457 | * @since 1.0.0 |
| 458 | * |
| 459 | * @return bool |
| 460 | */ |
| 461 | public function is_php_correct() { |
| 462 | return version_compare( phpversion(), $this->php, '>=' ); |
| 463 | } |
| 464 | |
| 465 | /** |
| 466 | * Display a helpful message to those users, that are using an outdated version of PHP, |
| 467 | * which is not supported by the currently selected Provider. |
| 468 | * |
| 469 | * @since 1.0.0 |
| 470 | */ |
| 471 | protected function display_php_warning() { |
| 472 | ?> |
| 473 | |
| 474 | <blockquote> |
| 475 | <?php |
| 476 | printf( |
| 477 | /* translators: %1$s - Provider name; %2$s - PHP version required by Provider; %3$s - current PHP version. */ |
| 478 | esc_html__( '%1$s requires PHP %2$s to work and does not support your current PHP version %3$s. Please contact your host and request a PHP upgrade to the latest one.', 'wp-mail-smtp' ), |
| 479 | esc_html( $this->get_title() ), |
| 480 | esc_html( $this->php ), |
| 481 | esc_html( phpversion() ) |
| 482 | ); |
| 483 | ?> |
| 484 | <br> |
| 485 | <?php esc_html_e( 'Meanwhile you can switch to some other mailers.', 'wp-mail-smtp' ); ?> |
| 486 | </blockquote> |
| 487 | |
| 488 | <?php |
| 489 | } |
| 490 | |
| 491 | /** |
| 492 | * Display a helpful message to those users, that are using an outdated version of PHP, |
| 493 | * which is not supported by the currently selected Provider. |
| 494 | * |
| 495 | * @since 1.5.0 |
| 496 | */ |
| 497 | protected function display_ssl_warning() { |
| 498 | ?> |
| 499 | |
| 500 | <blockquote> |
| 501 | <?php |
| 502 | printf( |
| 503 | wp_kses( /* translators: %s - Provider name */ |
| 504 | __( '%s requires an SSL certificate, and so is not currently compatible with your site. Please contact your host to request a SSL certificate, or check out <a href="https://www.wpbeginner.com/wp-tutorials/how-to-add-ssl-and-https-in-wordpress/" target="_blank">WPBeginner\'s tutorial on how to set up SSL</a>.', 'wp-mail-smtp' ), |
| 505 | [ |
| 506 | 'a' => [ |
| 507 | 'href' => [], |
| 508 | 'target' => [], |
| 509 | ], |
| 510 | ] |
| 511 | ), |
| 512 | esc_html( $this->get_title() ) |
| 513 | ); |
| 514 | ?> |
| 515 | <br> |
| 516 | <br> |
| 517 | <?php esc_html_e( 'If you\'d prefer not to set up SSL, or need an SMTP solution in the meantime, please select a different mailer option.', 'wp-mail-smtp' ); ?> |
| 518 | </blockquote> |
| 519 | |
| 520 | <?php |
| 521 | } |
| 522 | |
| 523 | /** |
| 524 | * Display a message of a constant that was set inside wp-config.php file. |
| 525 | * |
| 526 | * @since 1.5.0 |
| 527 | * |
| 528 | * @param string $constant Constant name. |
| 529 | */ |
| 530 | protected function display_const_set_message( $constant ) { |
| 531 | |
| 532 | printf( '<p class="desc">%s</p>', $this->options->get_const_set_message( $constant ) ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 533 | } |
| 534 | |
| 535 | /** |
| 536 | * Return the defaults for the mailer supported settings. |
| 537 | * |
| 538 | * @since 2.3.0 |
| 539 | * |
| 540 | * @return array |
| 541 | */ |
| 542 | public function get_supports_defaults() { |
| 543 | |
| 544 | return [ |
| 545 | 'from_email' => true, |
| 546 | 'from_name' => true, |
| 547 | 'return_path' => true, |
| 548 | 'from_email_force' => true, |
| 549 | 'from_name_force' => true, |
| 550 | ]; |
| 551 | } |
| 552 | |
| 553 | /** |
| 554 | * Get the mailer supported settings. |
| 555 | * |
| 556 | * @since 2.3.0 |
| 557 | * |
| 558 | * @return array |
| 559 | */ |
| 560 | public function get_supports() { |
| 561 | return apply_filters( 'wp_mail_smtp_providers_provider_get_supports', $this->supports, $this ); |
| 562 | } |
| 563 | } |
| 564 |