Options.php
133 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WPMailSMTP\Providers\ElasticEmail; |
| 4 | |
| 5 | use WPMailSMTP\Helpers\UI; |
| 6 | use WPMailSMTP\Providers\OptionsAbstract; |
| 7 | |
| 8 | /** |
| 9 | * Class Options. |
| 10 | * |
| 11 | * @since 4.3.0 |
| 12 | */ |
| 13 | class Options extends OptionsAbstract { |
| 14 | |
| 15 | /** |
| 16 | * Mailer slug. |
| 17 | * |
| 18 | * @since 4.3.0 |
| 19 | */ |
| 20 | const SLUG = 'elasticemail'; |
| 21 | |
| 22 | /** |
| 23 | * Options constructor. |
| 24 | * |
| 25 | * @since 4.3.0 |
| 26 | * |
| 27 | * @param ConnectionInterface $connection The Connection object. |
| 28 | */ |
| 29 | public function __construct( $connection = null ) { |
| 30 | |
| 31 | if ( is_null( $connection ) ) { |
| 32 | $connection = wp_mail_smtp()->get_connections_manager()->get_primary_connection(); |
| 33 | } |
| 34 | |
| 35 | $description = sprintf( |
| 36 | wp_kses( /* translators: %1$s - URL to ElasticEmail.com site. */ |
| 37 | __( '<a href="%1$s" target="_blank" rel="noopener noreferrer">Elastic Email</a> is a cloud-based email marketing platform offering tools for email campaigns, automation, transactional emails, and analytics, designed for businesses of all sizes.<br><br>If you\'re just starting out, you can use Elastic Email\'s free plan to send emails to your account address from one of your verified email addresses. You don\'t need to use a credit card to try it out. When you\'re ready, you can upgrade to a higher plan.', 'wp-mail-smtp' ) . |
| 38 | '<br><br>' . |
| 39 | /* translators: %2$s - URL to wpmailsmtp.com doc. */ |
| 40 | __( 'To get started, read our <a href="%2$s" target="_blank" rel="noopener noreferrer">Elastic Email documentation</a>.', 'wp-mail-smtp' ), |
| 41 | [ |
| 42 | 'strong' => true, |
| 43 | 'br' => true, |
| 44 | 'a' => [ |
| 45 | 'href' => true, |
| 46 | 'rel' => true, |
| 47 | 'target' => true, |
| 48 | ], |
| 49 | ] |
| 50 | ), |
| 51 | 'https://www.elasticemail.com/', |
| 52 | esc_url( wp_mail_smtp()->get_utm_url( 'https://wpmailsmtp.com/docs/how-to-set-up-the-elastic-email-mailer-in-wp-mail-smtp/', 'Elastic Email documentation' ) ) |
| 53 | ); |
| 54 | |
| 55 | parent::__construct( |
| 56 | [ |
| 57 | 'logo_url' => wp_mail_smtp()->assets_url . '/images/providers/elasticemail.svg', |
| 58 | 'slug' => self::SLUG, |
| 59 | 'title' => esc_html__( 'Elastic Email', 'wp-mail-smtp' ), |
| 60 | 'php' => '5.6', |
| 61 | 'description' => $description, |
| 62 | 'supports' => [ |
| 63 | 'from_email' => true, |
| 64 | 'from_name' => true, |
| 65 | 'return_path' => false, |
| 66 | 'from_email_force' => true, |
| 67 | 'from_name_force' => true, |
| 68 | ], |
| 69 | ], |
| 70 | $connection |
| 71 | ); |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * Output the mailer provider options. |
| 76 | * |
| 77 | * @since 4.3.0 |
| 78 | */ |
| 79 | public function display_options() { |
| 80 | |
| 81 | // Do not display options if PHP version is not correct. |
| 82 | if ( ! $this->is_php_correct() ) { |
| 83 | $this->display_php_warning(); |
| 84 | |
| 85 | return; |
| 86 | } |
| 87 | ?> |
| 88 | |
| 89 | <!-- API Key --> |
| 90 | <div id="wp-mail-smtp-setting-row-<?php echo esc_attr( $this->get_slug() ); ?>-api_key" |
| 91 | class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-text wp-mail-smtp-clear"> |
| 92 | <div class="wp-mail-smtp-setting-label"> |
| 93 | <label for="wp-mail-smtp-setting-<?php echo esc_attr( $this->get_slug() ); ?>-api_key"><?php esc_html_e( 'API Key', 'wp-mail-smtp' ); ?></label> |
| 94 | </div> |
| 95 | <div class="wp-mail-smtp-setting-field"> |
| 96 | <?php if ( $this->connection_options->is_const_defined( $this->get_slug(), 'api_key' ) ) : ?> |
| 97 | <input type="text" disabled value="****************************************" |
| 98 | id="wp-mail-smtp-setting-<?php echo esc_attr( $this->get_slug() ); ?>-api_key" |
| 99 | /> |
| 100 | <?php $this->display_const_set_message( 'WPMS_ELASTICEMAIL_API_KEY' ); ?> |
| 101 | <?php else : ?> |
| 102 | <?php |
| 103 | $slug = $this->get_slug(); |
| 104 | $value = $this->connection_options->get( $this->get_slug(), 'api_key' ); |
| 105 | |
| 106 | UI::hidden_password_field( |
| 107 | [ |
| 108 | 'name' => "wp-mail-smtp[{$slug}][api_key]", |
| 109 | 'id' => "wp-mail-smtp-setting-{$slug}-api_key", |
| 110 | 'value' => $value, |
| 111 | 'clear_text' => esc_html__( 'Remove API Key', 'wp-mail-smtp' ), |
| 112 | ] |
| 113 | ); |
| 114 | ?> |
| 115 | <?php endif; ?> |
| 116 | |
| 117 | <p class="desc"> |
| 118 | <?php |
| 119 | printf( /* translators: %s - link to get an API Key. */ |
| 120 | esc_html__( 'Follow this link to get an API Key from Elastic Email: %s.', 'wp-mail-smtp' ), |
| 121 | '<a href="https://app.elasticemail.com/api/settings/manage-api" target="_blank" rel="noopener noreferrer">' . |
| 122 | esc_html__( 'Get API Key', 'wp-mail-smtp' ) . |
| 123 | '</a>' |
| 124 | ); |
| 125 | ?> |
| 126 | </p> |
| 127 | </div> |
| 128 | </div> |
| 129 | |
| 130 | <?php |
| 131 | } |
| 132 | } |
| 133 |