PluginProbe ʕ •ᴥ•ʔ
WP Mail SMTP by WPForms – The Most Popular SMTP and Email Log Plugin / 4.3.0
WP Mail SMTP by WPForms – The Most Popular SMTP and Email Log Plugin v4.3.0
0.9.6 1.0.0 1.0.1 1.0.2 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.5.0 1.5.1 1.5.2 1.6.0 1.6.2 1.7.0 1.7.1 1.8.0 1.8.1 1.9.0 2.0.0 2.0.1 2.1.1 2.2.1 2.3.1 2.4.0 2.5.0 2.5.1 2.6.0 2.7.0 2.8.0 2.9.0 3.0.1 3.0.2 3.0.3 3.1.0 3.10.0 3.11.0 3.11.1 3.2.0 3.2.1 3.3.0 3.4.0 3.5.0 3.5.1 3.5.2 3.6.1 3.7.0 3.8.0 3.8.2 3.9.0 4.0.1 4.1.0 4.1.1 4.2.0 4.3.0 4.4.0 4.5.0 4.6.0 4.7.0 4.7.1 4.8.0 trunk 0.10.0 0.10.1 0.11.1 0.11.2 0.3.1 0.3.2 0.4 0.4.1 0.4.2 0.5.0 0.5.1 0.5.2 0.6 0.7 0.8 0.8.2 0.8.3 0.8.4 0.8.5 0.8.6 0.8.7 0.9.0 0.9.1 0.9.2 0.9.3 0.9.4 0.9.5
wp-mail-smtp / src / Helpers / UI.php
wp-mail-smtp / src / Helpers Last commit date
Crypto.php 1 year ago DB.php 1 year ago Helpers.php 1 year ago PluginImportDataRetriever.php 1 year ago UI.php 1 year ago
UI.php
119 lines
1 <?php
2
3 namespace WPMailSMTP\Helpers;
4
5 /**
6 * Reusable interface components.
7 *
8 * @since 3.10.0
9 */
10 class UI {
11
12 /**
13 * Toggle component.
14 *
15 * @since 3.10.0
16 *
17 * @param array $args {
18 * Toggle parameters.
19 *
20 * @type string $name Name attribute of the toggle's input element. Default ''.
21 * @type string $value Value attribute of the toggle's input element. Default 'yes'.
22 * @type string|string[] $label Single label, or a 2-elements array of on/off labels. Default ''.
23 * @type string $id ID attribute of the toggle's container element. Default ''.
24 * @type string $class Class attribute of the toggle's container element. Default ''.
25 * @type bool $checked Checked attribute of the toggle's input element. Default false.
26 * @type bool $disabled Disabled attribute of the toggle's input element. Default false.
27 * }
28 */
29 public static function toggle( $args = [] ) {
30
31 $args = wp_parse_args(
32 $args,
33 [
34 'name' => '',
35 'value' => 'yes',
36 'label' => [
37 esc_html__( 'On', 'wp-mail-smtp' ),
38 esc_html__( 'Off', 'wp-mail-smtp' ),
39 ],
40 'id' => '',
41 'class' => '',
42 'checked' => false,
43 'disabled' => false,
44 ]
45 );
46 ?>
47 <label class="wp-mail-smtp-toggle">
48 <input type="checkbox"
49 name="<?php echo esc_attr( $args['name'] ); ?>"
50 <?php echo empty( $args['class'] ) ? '' : ' class="' . esc_attr( $args['class'] ) . '"'; ?>
51 <?php echo empty( $args['id'] ) ? '' : ' id="' . esc_attr( $args['id'] ) . '"'; ?>
52 value="<?php echo esc_attr( $args['value'] ); ?>"
53 <?php checked( (bool) $args['checked'] ); ?>
54 <?php disabled( (bool) $args['disabled'] ); ?> />
55 <span class="wp-mail-smtp-toggle__switch"></span>
56 <?php if ( is_array( $args['label'] ) ) : ?>
57 <?php if ( count( $args['label'] ) > 0 ) : ?>
58 <span class="wp-mail-smtp-toggle__label wp-mail-smtp-toggle__label--checked"><?php echo esc_html( $args['label'][0] ); ?></span>
59 <?php endif; ?>
60 <?php if ( count( $args['label'] ) > 1 ) : ?>
61 <span class="wp-mail-smtp-toggle__label wp-mail-smtp-toggle__label--unchecked"><?php echo esc_html( $args['label'][1] ); ?></span>
62 <?php endif; ?>
63 <?php else : ?>
64 <span class="wp-mail-smtp-toggle__label wp-mail-smtp-toggle__label--static"><?php echo esc_html( $args['label'] ); ?></span>
65 <?php endif; ?>
66 </label>
67 <?php
68 }
69
70 /**
71 * Output an obfuscated password field.
72 *
73 * @since 4.1.0
74 *
75 * @param array $args Field attributes.
76 *
77 * @return void
78 */
79 public static function hidden_password_field( $args ) { // phpcs:ignore Generic.Metrics.CyclomaticComplexity.TooHigh
80
81 $args = wp_parse_args(
82 $args,
83 [
84 'name' => '',
85 'id' => '',
86 'value' => '',
87 'clear_text' => esc_html__( 'Remove', 'wp-mail-smtp' ),
88 ]
89 );
90
91 $value = str_repeat( '*', strlen( $args['value'] ) );
92
93 // phpcs:disable Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace
94 ?>
95
96 <div class="wp-mail-smtp-input-btn-row">
97
98 <input type="password"
99 spellcheck="false"
100 autocomplete="new-password"
101 <?php if ( ! empty( $value ) ) : ?>disabled<?php endif; ?>
102 <?php if ( ! empty( $args['name'] && empty( $value ) ) ) : ?>name="<?php echo esc_attr( $args['name'] ); ?>"<?php endif; ?>
103 <?php if ( ! empty( $args['name'] ) ) : ?>data-name="<?php echo esc_attr( $args['name'] ); ?>"<?php endif; ?>
104 <?php if ( ! empty( $args['id'] ) ) : ?>id="<?php echo esc_attr( $args['id'] ); ?>"<?php endif; ?>
105 <?php if ( ! empty( $value ) ) : ?>value="<?php echo esc_attr( $value ); ?>"<?php endif; ?>/>
106
107 <?php if ( ! empty( $value ) ) : ?>
108
109 <button type="button"
110 class="wp-mail-smtp-btn wp-mail-smtp-btn-md wp-mail-smtp-btn-grey"
111 data-clear-field="<?php echo esc_attr( $args['id'] ); ?>"><?php echo esc_html( $args['clear_text'] ); ?></button>
112
113 <?php endif; ?>
114 </div>
115 <?php
116 // phpcs:enable Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace
117 }
118 }
119