PluginProbe ʕ •ᴥ•ʔ
WP 2FA – Two-factor authentication for WordPress / 4.0.0
WP 2FA – Two-factor authentication for WordPress v4.0.0
4.0.0 1.7.1 2.0.0 2.0.1 2.1.0 2.2.0 2.2.1 2.3.0 2.4.0 2.4.1 2.4.2 2.5.0 2.6.0 2.6.1 2.6.2 2.6.3 2.6.4 2.7.0 2.8.0 2.9.0 2.9.1 2.9.2 2.9.3 3.0.0 3.0.1 3.1.0 3.1.1 3.1.1.2 trunk 1.2.0 1.3.0 1.4.0 1.4.1 1.4.2 1.5.0 1.5.1 1.5.2 1.6.0 1.6.1 1.6.2 1.7.0
wp-2fa / includes / classes / Admin / Settings / templates / customize-code-page.php
wp-2fa / includes / classes / Admin / Settings / templates Last commit date
about-us 1 day ago partials 1 day ago passkeys 1 day ago policies 1 day ago reports 1 day ago support 1 day ago customize-code-page.php 1 day ago customize-setup-wizard.php 1 day ago customize-user-profile.php 1 day ago customize-user-prompts.php 1 day ago email-settings.php 1 day ago general-settings.php 1 day ago generic-settings.php 1 day ago import-export.php 1 day ago index.php 1 day ago plugins-integrations.php 1 day ago providers-integrations.php 1 day ago sidebar.php 1 day ago white-labeling.php 1 day ago
customize-code-page.php
336 lines
1 <?php
2 /**
3 * Settings Template
4 *
5 * @package wp-2fa
6 */
7
8 use WP2FA\WP2FA;
9 use WP2FA\Admin\Settings_Builder;
10 use WP2FA\Licensing\Licensing_Factory;
11
12 ?>
13 <div class="settings-page" id="customize-code-page-wrap">
14
15 <?php
16 Settings_Builder::build_option(
17 array(
18 'parent' => \esc_html__( 'White labeling', 'wp-2fa' ),
19 'type' => 'breadcrumb',
20 'custom_class' => 'back-policies-settings-main-wrapper',
21 'default' => \esc_html__( 'Customize 2FA code page', 'wp-2fa' ),
22 )
23 );
24
25 Settings_Builder::build_option(
26 array(
27 'title' => esc_html__( 'Customize 2FA code page', 'wp-2fa' ),
28 'id' => 'wp-2fa-code-page-settings-tab',
29 'type' => 'tab-title',
30 )
31 );
32
33 Settings_Builder::build_option(
34 array(
35 'text' => \wp_sprintf(
36 // translators: 1. Link to documentation, 2. Link to support.
37 \esc_html__( 'Customize the messages and styling of the 2FA code page. %1$s.', 'wp-2fa' ),
38 \wp_sprintf( '<a href="%s" target="_blank">%s</a>', 'https://melapress.com/support/?utm_source=plugin&utm_medium=wp2fa&utm_campaign=code_page_settings_doc', \esc_html__( 'Learn more', 'wp-2fa' ) )
39 ),
40 'class' => 'description-settings-card',
41 'id' => 'wp-2fa-code-page-settings-tab',
42 'type' => 'description',
43 )
44 );
45
46
47 $code_page_tabs = array(
48 array(
49 'id' => 'content',
50 'title' => esc_html__( 'Edit content', 'wp-2fa' ),
51 ),
52 );
53
54 // @free:start
55 $code_page_tabs[] = array(
56 'id' => 'styles',
57 'title' => esc_html__( 'Edit styles', 'wp-2fa' ),
58 'locked' => true,
59 'premium_context' => 'wp-2fa-white-labeling:customize-code-page-design',
60 );
61 // @free:end
62
63
64 Settings_Builder::build_option(
65 array(
66 'class' => 'description-settings-card',
67 'id' => 'wp-2fa-code-page-settings-tab',
68 'type' => 'tabbed-navigation',
69 'option_name' => 'wp-2fa-code-page-settings-tabs',
70 'values' => $code_page_tabs,
71 )
72 );
73 ?>
74
75
76 <!-- ══════════════════════════════════════════════════════
77 TAB 1 2FA Content
78 ══════════════════════════════════════════════════════════ -->
79 <div class="tab-panel tab-panel-content">
80 <?php
81 $is_enterprise = Licensing_Factory::has_active_valid_license() && ( Licensing_Factory::provider_call( 'is_plan_or_trial__premium_only', 'business', true ) || Licensing_Factory::provider_call( 'is_plan_or_trial__premium_only', 'ent', true ) || Licensing_Factory::provider_call( 'is_plan_or_trial__premium_only', 'enterprise', true ) );
82 $enterprise_plan_url = 'https://melapress.com/wordpress-2fa/pricing/#utm_source=plugin&utm_medium=wp2fa&utm_campaign=white-labeling-page';
83 if ( ! $is_enterprise ) :
84 ?>
85 <div class="wp2fa-enterprise-upsell-banner" role="region" aria-label="<?php echo \esc_attr__( 'Enterprise upgrade banner', 'wp-2fa' ); ?>">
86 <div class="wp2fa-enterprise-upsell-banner__content">
87 <span class="wp2fa-enterprise-upsell-banner__icon" aria-hidden="true">
88 <svg xmlns="http://www.w3.org/2000/svg" width="33" height="49" viewBox="0 0 33 49" fill="none">
89 <path d="M10.7607 16.2846L18.7944 8.17949L26.9017 0H13.414H0V8.17949V16.2846L2.65332 13.6077L5.38035 10.8564L8.03367 13.6077L10.7607 16.2846Z" fill="#99FFFF"/>
90 <path d="M32.2094 48.9278V37.997V27.1406L21.5224 37.997L10.7617 48.7791L21.5224 48.8534L32.2094 48.9278Z" fill="#3E6BFF"/>
91 <path d="M10.7607 27.1406L8.03367 24.3893L5.38035 21.7124L2.65332 18.9611L0 16.2841V27.1406V37.997L2.65332 35.2457L5.38035 32.5688L8.03367 35.2457L10.7607 37.997L18.7944 29.8175L26.9017 21.7124L29.555 24.3893L32.2084 27.1406V16.2841V5.42773L21.5214 16.2841L10.7607 27.1406Z" fill="#40D3F0"/>
92 </svg>
93 </span>
94 <div class="wp2fa-enterprise-upsell-banner__text">
95 <h3 class="wp2fa-enterprise-upsell-banner__title">
96 <?php echo \esc_html__( 'Unlock more settings with the', 'wp-2fa' ); ?>
97 <span class="wp2fa-enterprise-upsell-banner__highlight"><?php echo \esc_html__( 'Enterprise version', 'wp-2fa' ); ?></span>
98 </h3>
99 <p class="wp2fa-enterprise-upsell-banner__desc"><?php echo \esc_html__( 'Get access to even more features with Enterprise version of WP2FA', 'wp-2fa' ); ?></p>
100 </div>
101 </div>
102 <a class="wp2fa-enterprise-upsell-banner__button" href="<?php echo \esc_url( $enterprise_plan_url ); ?>" target="_blank" rel="noopener noreferrer">
103 <?php echo \esc_html__( 'View Enterprise plan', 'wp-2fa' ); ?>
104 </a>
105 </div>
106 <?php endif; ?>
107
108 <div class="settings-card">
109 <?php
110 Settings_Builder::build_option(
111 array(
112 'title' => esc_html__( 'Customize content', 'wp-2fa' ),
113 'id' => 'general-settings-tab',
114 'type' => 'section-title',
115 )
116 );
117
118 Settings_Builder::build_option(
119 array(
120 'text' => \wp_sprintf(
121 // translators: 1. Link to documentation, 2. Link to support.
122 \esc_html__( 'Use these settings to customize messages shown to users upon login when a 2FA verification code is requested', 'wp-2fa' ),
123 ),
124 'class' => 'description-settings-card',
125 'id' => 'general-settings-tab',
126 'type' => 'description',
127 )
128 );
129
130 $customized_content_dialogs = array(
131 'default-text-code-page' => array(
132 'label' => \esc_html__( '2FA code page text', 'wp-2fa' ),
133 'description' => \esc_html__( 'The main message shown on the 2FA login screen, prompting the user to enter their verification code.', 'wp-2fa' ),
134 'note' => \esc_html__( 'Only plain text is allowed.', 'wp-2fa' ),
135 ),
136 );
137
138 $section_open = true;
139 foreach ( $customized_content_dialogs as $setting_key => $setting_options ) {
140 if ( isset( $setting_options['section'] ) ) {
141 if ( $section_open ) {
142 echo '</div>'; // Close previous settings-card.
143 }
144 $section_open = true;
145 ?>
146 <div class="settings-card">
147 <?php
148 Settings_Builder::build_option(
149 array(
150 'title' => $setting_options['section'],
151 'id' => \esc_attr( $setting_key ),
152 'type' => 'section-title',
153 )
154 );
155 ?>
156 <?php
157 continue;
158 }
159 ?>
160 <div class="form-group settings-row">
161 <div class="settings-label-group">
162 <?php
163 Settings_Builder::build_option(
164 array(
165 'text' => $setting_options['label'],
166 'id' => 'general-settings-tab',
167 'type' => 'settings-label',
168 )
169 );
170
171 if ( isset( $setting_options['description'] ) ) {
172 Settings_Builder::build_option(
173 array(
174 'text' => $setting_options['description'],
175 'class' => 'description-settings-card',
176 'id' => 'general-settings-tab',
177 'type' => 'description',
178 )
179 );
180 }
181 ?>
182 </div>
183 <div class="settings-control">
184 <?php
185 $setting = array(
186 'id' => $setting_key,
187 'type' => ( isset( $setting_options['type'] ) && trim( $setting_options['type'] ) ) ? $setting_options['type'] : 'editor',
188 'placeholder' => \esc_html__( 'Enter custom message', 'wp-2fa' ),
189 'class' => 'form-input',
190 'option_name' => 'wp_2fa_white_label[' . $setting_key . ']',
191 'default' => WP2FA::get_wp2fa_white_label_setting( sanitize_key( $setting_key ), true ),
192 );
193 if ( isset( $setting_options['note'] ) ) {
194 $setting['hint'] = $setting_options['note'];
195 }
196
197 Settings_Builder::build_option(
198 $setting
199 );
200 ?>
201 </div>
202 </div>
203 <?php
204 }
205 ?>
206
207 <?php
208 $customized_content_dialogs = array(
209 'default-backup-code-page' => array(
210 'label' => \esc_html__( 'Backup code page text', 'wp-2fa' ),
211 'description' => \esc_html__( 'Shown on the backup-code screen, asking the user to enter one of their backup codes.', 'wp-2fa' ),
212 'note' => \esc_html__( 'Only plain text is allowed.', 'wp-2fa' ),
213 ),
214 'login-to-view-area' => array(
215 'label' => \esc_html__( 'Text for logged out users trying to access the 2FA configuration page', 'wp-2fa' ),
216 'description' => \esc_html__( 'Shown to logged-out users who open the 2FA setup page, prompting them to log in.', 'wp-2fa' ),
217 ),
218 );
219
220 if ( $is_enterprise ) {
221 $customized_content_dialogs = array_merge(
222 array(
223 'backup-email-link-login-text' => array(
224 'label' => \esc_html__( 'Send backup code via email link text', 'wp-2fa' ),
225 'description' => \esc_html__( 'This text is shown on the 2FA code page as the link to send a backup code via email.', 'wp-2fa' ),
226 ),
227 'backup-codes-login-text' => array(
228 'label' => \esc_html__( 'Use backup code link text', 'wp-2fa' ),
229 'description' => \esc_html__( 'This text is shown on the 2FA code page as the link to use a backup code instead.', 'wp-2fa' ),
230 ),
231 ),
232 $customized_content_dialogs
233 );
234 }
235
236 /**
237 * Filter to add more customizable content dialogs on the 2FA code page. Each dialog should have a unique setting key and an array of options which should include:
238 * 'label' (string) - The label for the dialog, shown in the settings page.
239 * 'description' (string) - A description for the dialog, shown in the settings page.
240 * 'type' (string) - The type of input to use in the settings page. Can be 'text' or 'editor'. Default is 'editor'.
241 * 'note' (string) - A note about the dialog, shown in the settings page.
242 */
243 $customized_content_dialogs = \apply_filters( WP_2FA_PREFIX . 'customizable_content_dialogs', $customized_content_dialogs );
244
245 if ( ! $is_enterprise ) {
246 $allowed_non_enterprise_keys = array(
247 'default-text-code-page',
248 'default-backup-code-page',
249 'login-to-view-area',
250 );
251 $customized_content_dialogs = array_intersect_key( $customized_content_dialogs, array_flip( $allowed_non_enterprise_keys ) );
252 }
253
254 $section_open = true;
255 foreach ( $customized_content_dialogs as $setting_key => $setting_options ) {
256 if ( isset( $setting_options['section'] ) ) {
257 if ( $section_open ) {
258 echo '</div>'; // Close previous settings-card.
259 }
260 $section_open = true;
261 ?>
262 <div class="settings-card">
263 <?php
264 Settings_Builder::build_option(
265 array(
266 'title' => $setting_options['section'],
267 'id' => \esc_attr( $setting_key ),
268 'type' => 'section-title',
269 )
270 );
271 ?>
272 <?php
273 continue;
274 }
275 ?>
276 <div class="form-group settings-row">
277 <div class="settings-label-group">
278 <?php
279 Settings_Builder::build_option(
280 array(
281 'text' => $setting_options['label'],
282 'id' => 'general-settings-tab',
283 'type' => 'settings-label',
284 )
285 );
286
287 if ( isset( $setting_options['description'] ) ) {
288 Settings_Builder::build_option(
289 array(
290 'text' => $setting_options['description'],
291 'class' => 'description-settings-card',
292 'id' => 'general-settings-tab',
293 'type' => 'description',
294 )
295 );
296 }
297 ?>
298 </div>
299 <div class="settings-control">
300 <?php
301 $setting = array(
302 'id' => $setting_key,
303 'type' => ( isset( $setting_options['type'] ) && trim( $setting_options['type'] ) ) ? $setting_options['type'] : 'editor',
304 'placeholder' => \esc_html__( 'Enter custom message', 'wp-2fa' ),
305 'class' => 'form-input',
306 'option_name' => 'wp_2fa_white_label[' . $setting_key . ']',
307 'default' => WP2FA::get_wp2fa_white_label_setting( sanitize_key( $setting_key ), true ),
308 );
309 if ( isset( $setting_options['note'] ) ) {
310 $setting['hint'] = $setting_options['note'];
311 }
312
313 Settings_Builder::build_option(
314 $setting
315 );
316 ?>
317 </div>
318 </div>
319 <?php
320 }
321 ?>
322 </div>
323
324 </div><!-- /.tab-panel-settings -->
325
326
327 <!-- ══════════════════════════════════════════════════════
328 TAB 2 2FA Styles
329 ══════════════════════════════════════════════════════════ -->
330 </div>
331 <style>
332 .settings-toggleable {
333 display: none;
334 }
335 </style>
336