PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 2.0.4
Adminify – White Label, Admin Menu Editor, Login Customizer v2.0.4
4.3.1 4.3.0 4.2.26 4.2.25 4.2.24 4.2.23 4.2.22 4.2.21 4.2.20 4.2.19 4.2.18 4.2.17 4.2.16 4.2.15 4.2.14 4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 4.1.17 All 164 releases
adminify / Inc / Modules / LoginCustomizer / Inc / Output_Customization.php

Output_Customization.php in Adminify – White Label, Admin Menu Editor, Login Customizer 2.0.4, at Inc/Modules/LoginCustomizer/Inc/Output_Customization.php

1,052 lines 40.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WPAdminify\Inc\Modules\LoginCustomizer\Inc;
4
5 use WPAdminify\Inc\Utils ;
6 use WPAdminify\Inc\Classes\Assets ;
7 // Cannot access directly.
8 if ( !defined( 'ABSPATH' ) ) {
9 die;
10 }
11 if ( !class_exists( 'Output_Customization' ) ) {
12 class Output_Customization
13 {
14 public $url ;
15 public $options ;
16 public function __construct()
17 {
18 $this->options = ( new Customize_Settings() )->get();
19 $this->url = WP_ADMINIFY_URL . 'Inc/Modules/LoginCustomizer';
20 // Don't index any of these forms
21 add_action( 'login_head', [ $this, 'login_viewport_meta' ] );
22 add_action( 'login_init', [ $this, 'check_general_texts' ] );
23 add_action( 'login_form_login', [ $this, 'check_login_texts' ] );
24 add_action( 'login_form_register', [ $this, 'check_register_texts' ] );
25 add_action( 'login_form_lostpassword', [ $this, 'check_lostpasswords_texts' ] );
26 add_action( 'login_header', [ $this, 'add_extra_div' ] );
27 add_action( 'jltwp_adminify_login_header', [ $this, 'add_extra_div' ] );
28 add_action( 'login_footer', [ $this, 'close_extra_div' ] );
29 add_action( 'jltwp_adminify_login_footer', [ $this, 'close_extra_div' ] );
30 add_action( 'login_header', [ $this, 'add_header_html' ] );
31 add_action( 'jltwp_adminify_login_header', [ $this, 'add_header_html' ] );
32 add_action( 'login_footer', [ $this, 'add_footer_html' ] );
33 add_action( 'jltwp_adminify_login_footer', [ $this, 'add_footer_html' ] );
34 add_action( 'login_footer', [ $this, 'add_video_html' ] );
35 add_action( 'jltwp_adminify_login_footer', [ $this, 'add_video_html' ] );
36 add_action( 'login_footer', [ $this, 'add_slideshow_html' ] );
37 add_action( 'jltwp_adminify_login_footer', [ $this, 'add_slideshow_html' ] );
38 add_action(
39 'wp_adminify_add_templates',
40 [ $this, 'add_templates' ],
41 10,
42 1
43 );
44 // add_action('login_head', [$this, 'print_login_styles'], 20);
45 add_action( 'login_head', [ $this, 'print_login_styles' ] );
46 add_action( 'customize_preview_init', [ $this, 'login_inline_style' ], 99 );
47 if ( !is_customize_preview() ) {
48 add_action( 'login_enqueue_scripts', [ $this, 'login_inline_style' ], 99 );
49 }
50 add_action( 'login_enqueue_scripts', [ $this, 'jltwp_adminify_login_enqueue_scripts' ], 99 );
51 add_filter( 'login_body_class', [ $this, 'jltwp_adminify_login_body_class' ] );
52 add_filter( 'login_headerurl', [ $this, 'login_logo_url' ], 99 );
53
54 if ( version_compare( $GLOBALS['wp_version'], '5.2', '<' ) ) {
55 add_filter( 'login_headertitle', [ $this, 'logo_title' ] );
56 } else {
57 add_filter( 'login_headertext', [ $this, 'logo_title' ] );
58 }
59
60 add_filter( 'login_errors', [ $this, 'login_error_messages' ] );
61 add_filter( 'login_title', [ $this, 'login_page_title' ], 99 );
62 // TODO
63 // add_filter('login_messages', [$this, 'change_welcome_message']);
64 // add_filter('woocommerce_process_login_errors', [$this, 'woo_login_errors'], 10, 3);
65 $this->enable_wp_shake_js();
66 }
67
68 // Body class
69 public function jltwp_adminify_login_body_class( $classes )
70 {
71 $position = !empty($this->options['credits_logo_position']['background-position']);
72 $position = Utils::jltwp_adminify_class_cleanup( $position );
73 $position = 'wp-adminify-badge-' . esc_attr( $position );
74 $classes[] = $position;
75 $classes[] = 'wp-adminify-login-customizer';
76 // Logo Settings
77 if ( isset( $this->options['logo_settings'] ) && 'text-only' == $this->options['logo_settings'] ) {
78 $classes[] = 'wp-adminify-text-logo';
79 }
80 if ( isset( $this->options['logo_settings'] ) && 'both' == $this->options['logo_settings'] ) {
81 $classes[] = 'wp-adminify-image-logo wp-adminify-text-logo';
82 }
83 if ( isset( $this->options['logo_settings'] ) && 'image-only' == $this->options['logo_settings'] ) {
84 $classes[] = 'wp-adminify-image-logo';
85 }
86 // Column Widths
87 if ( !empty($this->options['alignment_login_width']) && $this->options['alignment_login_width'] == 'fullwidth' ) {
88 if ( !empty($this->options['alignment_login_bg_skew']) != 0 ) {
89 $classes[] = 'wp-adminify-fullwidth';
90 }
91 }
92
93 if ( !empty($this->options['alignment_login_width']) && $this->options['alignment_login_width'] == 'width_two_column' ) {
94 $classes[] = 'wp-adminify-half-screen';
95 if ( isset( $this->options['alignment_login_column'] ) ) {
96 $classes[] = 'jltwp-adminify-login-' . esc_attr( $this->options['alignment_login_column'] );
97 }
98 }
99
100 if ( !empty($this->options['alignment_login_vertical']) ) {
101 $classes[] = 'wp-adminify-vertical-align-' . esc_attr( $this->options['alignment_login_vertical'] );
102 }
103 if ( !empty($this->options['alignment_login_horizontal']) ) {
104 $classes[] = 'wp-adminify-horizontal-align-' . esc_attr( $this->options['alignment_login_horizontal'] );
105 }
106 if ( !empty($this->options['jltwp_adminify_login_bg_type']) == 'slideshow' ) {
107 $classes[] = 'adminify-slideshow';
108 }
109 return $classes;
110 }
111
112 public function get_free_templates()
113 {
114 return [
115 'template-01',
116 'template-02',
117 'template-03',
118 'template-04'
119 ];
120 }
121
122 public function is_pro_template( $template )
123 {
124 return !in_array( $template, (array) $this->get_free_templates() );
125 }
126
127 public function add_templates( $selected_template )
128 {
129 if ( empty($selected_template) ) {
130 return include_once plugin_dir_path( __FILE__ ) . 'templates/template-01.php';
131 }
132 if ( !$this->is_pro_template( $selected_template ) ) {
133 return include_once plugin_dir_path( __FILE__ ) . 'templates/' . $selected_template . '.php';
134 }
135 include_once plugin_dir_path( __FILE__ ) . 'templates/template-01.php';
136 }
137
138 public function jltwp_adminify_login_enqueue_scripts()
139 {
140
141 if ( !empty($this->options['jltwp_adminify_login_bg_type']) == 'slideshow' ) {
142 wp_enqueue_style( 'wp-adminify-vegas', WP_ADMINIFY_ASSETS . 'vendors/vegas/vegas.min.css' );
143 wp_enqueue_script(
144 'wp-adminify-vegas',
145 WP_ADMINIFY_ASSETS . 'vendors/vegas/vegas.min.js',
146 [ 'jquery' ],
147 WP_ADMINIFY_VER,
148 true
149 );
150 }
151
152 }
153
154 public function login_inline_style()
155 {
156 $css = '';
157 $css .= '
158 .wp-adminify-badge {
159 overflow: hidden;
160 position: absolute;
161 bottom: 15px;
162 display: none;
163 right: 15px;
164 z-index: 2;
165 }
166
167 .wp-adminify-badge.left {
168 left: 15px;
169 right: inherit;
170 }
171 .wp-adminify-badge.left-center {
172 right: inherit;
173 top: 48.25%;
174 bottom: inherit;
175 transform: translateY(-50%);
176 }
177 .wp-adminify-badge.left-top {
178 right: inherit;
179 left: 15px;
180 top: 15px;
181 }
182 .wp-adminify-badge.left-bottom {
183 right: inherit;
184 left: 20px;
185 }
186 .wp-adminify-badge.center-top{
187 right: inherit;
188 left: 50%;
189 top: 0;
190 transform: translateX(-50%);
191 }
192 .wp-adminify-badge.center-center {
193 top: 50%;
194 left: 50%;
195 bottom: inherit;
196 right: inherit;
197 transform: translate(-50%, -50%);
198 }
199 .wp-adminify-badge.center-bottom{
200 right: inherit;
201 left: 50%;
202 bottom: 15px;
203 transform: translateX(-50%);
204 }
205 .wp-adminify-badge.right-top {
206 top: 15px;
207 }
208 .wp-adminify-badge.right-center {
209 top: 50%;
210 bottom: inherit;
211 transform: translateY(-50%);
212 }
213
214 .wp-adminify-badge.right {
215 right: 15px;
216 }
217
218 .wp-adminify-badge.middle {
219 left: 15px;
220 right: 15px;
221 margin: 0 auto;
222 }
223
224 .wp-adminify-badge.top-right {
225 top: 15px;
226 right: 15px;
227 bottom: inherit;
228 }
229
230 @media screen and (min-width: 600px) {
231 .wp-adminify-badge {
232 display: block;
233 }
234 }
235
236 @media screen and (max-height: 600px) {
237 .wp-adminify-badge {
238 display: none;
239 }
240 }
241
242 .wp-adminify-badge.is-hidden .wp-adminify-badge__inner {
243 opacity: 0;
244 transform: scale(0);
245 transition: transform 500ms cubic-bezier(0.694, 0.0482, 0.335, 1), opacity 200ms cubic-bezier(0.694, 0.0482, 0.335, 1);
246 }
247
248 .wp-adminify-badge__inner {
249 display: -webkit-box;
250 display: -webkit-flex;
251 display: -ms-flexbox;
252 display: flex;
253 -webkit-align-content: center;
254 -ms-flex-line-pack: center;
255 align-content: center;
256 -webkit-box-pack: center;
257 -webkit-justify-content: center;
258 -ms-flex-pack: center;
259 justify-content: center;
260 -webkit-box-align: center;
261 -webkit-align-items: center;
262 -ms-flex-align: center;
263 align-items: center;
264 position: relative;
265 padding: 8px 15px;
266 transition: transform 500ms cubic-bezier(0.694, 0.0482, 0.335, 1), opacity 200ms cubic-bezier(0.694, 0.0482, 0.335, 1) 300ms;
267 }
268
269 .wp-adminify-badge__text {
270 position: relative;
271 padding-right: 7px;
272 line-height: 1;
273 font-size:16px;
274 }
275
276 .wp-adminify-badge .icon {
277 width: 164px;
278 height: 35px;
279 }
280
281 .wp-adminify-badge__link {
282 position: absolute;
283 top: 0;
284 left: 0;
285 right: 0;
286 bottom: 0;
287 height: 100%;
288 width: 100%;
289 z-index: 9;
290 }
291 ';
292 // Branding text color.
293 if ( isset( $this->options['credits_text_color'] ) ) {
294 $css .= '.wp-adminify-badge__text { color:' . esc_attr( $this->options['credits_text_color'] ) . ';}';
295 }
296 // Icon color.
297 if ( isset( $this->options['branding_icon_color'] ) ) {
298 $css .= '.wp-adminify-badge .icon { color:' . esc_attr( $this->options['branding_icon_color'] ) . ';}';
299 }
300 if ( is_customize_preview() ) {
301 $css .= '
302 body:not(.wp-adminify) .wp-adminify-badge {
303 display: none !important;
304 }
305 ';
306 }
307 // Combine the values from above and minifiy them.
308 $css = preg_replace( '#/\\*.*?\\*/#s', '', $css );
309 $css = preg_replace( '/\\s*([{}|:;,])\\s+/', '$1', $css );
310 $css = preg_replace( '/\\s\\s+(.*)/', '$1', $css );
311 // Add inline style.
312 wp_add_inline_style( 'login', wp_strip_all_tags( $css ) );
313 if ( is_customize_preview() ) {
314 wp_add_inline_style( 'customize-preview', wp_strip_all_tags( $css ) );
315 }
316 }
317
318 // WP Shake JS
319 public function enable_wp_shake_js()
320 {
321 if ( !empty($this->options['login_form_disable_login_shake']) && $this->options['login_form_disable_login_shake'] ) {
322 remove_action( 'login_head', [ $this, 'wp_shake_js' ], 15 );
323 }
324 }
325
326 public function login_logo_url( $logo_url )
327 {
328 $logo_link = $this->options['logo_login_url'];
329 if ( !empty($logo_link) && !empty($logo_link['url']) ) {
330 return $logo_link['url'];
331 }
332 return $logo_url;
333 }
334
335 /**
336 * Filters the logo image title attribute.
337 *
338 * @see https://developer.wordpress.org/reference/hooks/login_headertext/
339 *
340 * @access public
341 */
342 public function logo_title( $title )
343 {
344 if ( isset( $this->options['logo_text'] ) ) {
345 return wp_kses_post( $this->options['logo_text'] );
346 }
347 return $title;
348 }
349
350 public function login_page_title( $title )
351 {
352 if ( !empty($this->options['login_page_title']) ) {
353 return esc_html( $this->options['login_page_title'] );
354 }
355 return $title;
356 }
357
358 /*
359 * Output the Inline CSS
360 */
361 public function print_login_styles()
362 {
363 $position_class = !empty($this->options['credits_logo_position']['background-position']);
364 $position_class = Utils::jltwp_adminify_class_cleanup( $position_class );
365 // Login Style
366 require dirname( __FILE__ ) . '/login-styles.php';
367 // Login Preset Style
368 include dirname( __FILE__ ) . '/login-preset-styles.php';
369 // Login Custom Style
370 include dirname( __FILE__ ) . '/login-custom-styles.php';
371 // Google Font
372 require dirname( __FILE__ ) . '/google-font.php';
373 // Branding
374 require dirname( __FILE__ ) . '/branding.php';
375 }
376
377 /**
378 * Remove the filter login_errors from woocommerce login form.
379 * * * * * * * * * * * * */
380 function woo_login_errors( $validation_error, $arg1, $arg2 )
381 {
382 remove_filter( 'login_errors', [ $this, 'login_error_messages' ] );
383 return $validation_error;
384 }
385
386 /**
387 * Set Errors Messages to Show off
388 * * * * * * * * * * * * * * * * */
389 public function login_error_messages( $error )
390 {
391 global $errors ;
392
393 if ( isset( $errors ) && apply_filters( 'wp_adminify_display_custom_errors', true ) ) {
394 $error_codes = $errors->get_error_codes();
395
396 if ( $this->options['login_error_messages'] ) {
397 // Username
398 $invalid_username = ( array_key_exists( 'error_incorrect_username', $this->options['login_error_messages'] ) && !empty($this->options['login_error_messages']['error_incorrect_username']) ? $this->options['login_error_messages']['error_incorrect_username'] : sprintf( __( '%1$sError:%2$s Invalid Username.', WP_ADMINIFY_TD ), '<strong>', '</strong>' ) );
399 $empty_username = ( array_key_exists( 'error_empty_username', $this->options['login_error_messages'] ) && !empty($this->options['login_error_messages']['error_empty_username']) ? $this->options['login_error_messages']['error_empty_username'] : sprintf( __( '%1$sError:%2$s The username field is empty.', WP_ADMINIFY_TD ), '<strong>', '</strong>' ) );
400 $username_exists = ( array_key_exists( 'error_exists_username', $this->options['login_error_messages'] ) && !empty($this->options['login_error_messages']['error_exists_username']) ? $this->options['login_error_messages']['error_exists_username'] : sprintf( __( '%1$sError:%2$s This username is already registered. Please choose another one.', WP_ADMINIFY_TD ), '<strong>', '</strong>' ) );
401 // Password
402 $invalid_pasword = ( array_key_exists( 'error_incorrect_password', $this->options['login_error_messages'] ) && !empty($this->options['login_error_messages']['error_incorrect_password']) ? $this->options['login_error_messages']['error_incorrect_password'] : sprintf( __( '%1$sError:%2$s Invalid Password.', WP_ADMINIFY_TD ), '<strong>', '</strong>' ) );
403 $empty_password = ( array_key_exists( 'error_empty_password', $this->options['login_error_messages'] ) && !empty($this->options['login_error_messages']['error_empty_password']) ? $this->options['login_error_messages']['error_empty_password'] : sprintf( __( '%1$sError:%2$s The password field is empty.', WP_ADMINIFY_TD ), '<strong>', '</strong>' ) );
404 // Email
405 $invalid_email = ( array_key_exists( 'error_incorrect_email', $this->options['login_error_messages'] ) && !empty($this->options['login_error_messages']['error_incorrect_email']) ? $this->options['login_error_messages']['error_incorrect_email'] : sprintf( __( '%1$sError:%2$s The email address isn\'t correct..', WP_ADMINIFY_TD ), '<strong>', '</strong>' ) );
406 $empty_email = ( array_key_exists( 'error_empty_email', $this->options['login_error_messages'] ) && !empty($this->options['login_error_messages']['error_empty_email']) ? $this->options['login_error_messages']['error_empty_email'] : sprintf( __( '%1$sError:%2$s Please type your email address.', WP_ADMINIFY_TD ), '<strong>', '</strong>' ) );
407 $email_exists = ( array_key_exists( 'error_exists_email', $this->options['login_error_messages'] ) && !empty($this->options['login_error_messages']['error_exists_email']) ? $this->options['login_error_messages']['error_exists_email'] : sprintf( __( '%1$sError:%2$s This email is already registered, please choose another one.', WP_ADMINIFY_TD ), '<strong>', '</strong>' ) );
408 $invalidcombo = ( array_key_exists( 'invalidcombo_message', $this->options['login_error_messages'] ) && !empty($this->options['login_error_messages']['invalidcombo_message']) ? $this->options['login_error_messages']['invalidcombo_message'] : sprintf( __( '%1$sError:%2$s Invalid username or email.', WP_ADMINIFY_TD ), '<strong>', '</strong>' ) );
409 // Username
410 if ( in_array( 'error_incorrect_username', $error_codes ) ) {
411 return $invalid_username;
412 }
413 if ( in_array( 'error_empty_username', $error_codes ) ) {
414 return $empty_username;
415 }
416 if ( in_array( 'error_exists_username', $error_codes ) ) {
417 return $username_exists;
418 }
419 // Password
420 if ( in_array( 'error_incorrect_password', $error_codes ) ) {
421 return $invalid_pasword;
422 }
423 if ( in_array( 'error_empty_password', $error_codes ) ) {
424 return $empty_password;
425 }
426 // Email
427 if ( in_array( 'error_incorrect_email', $error_codes ) ) {
428 return $invalid_email;
429 }
430 if ( in_array( 'error_empty_email', $error_codes ) ) {
431 return "</br>" . $empty_email;
432 }
433 // registeration Form enteries.
434 if ( in_array( 'error_exists_email', $error_codes ) ) {
435 return $email_exists;
436 }
437 // forget password entery.
438 if ( in_array( 'invalidcombo', $error_codes ) ) {
439 return $invalidcombo;
440 }
441 }
442
443 }
444
445 return $error;
446 }
447
448 /**
449 * Manage Welcome Messages
450 *
451 * @param $message
452 * @since 1.0.0
453 * @return string
454 * * * * * * * * * * * * */
455 public function change_welcome_message( $message )
456 {
457
458 if ( $this->options ) {
459 //Check, User Logedout.
460
461 if ( isset( $_GET['loggedout'] ) && TRUE == $_GET['loggedout'] ) {
462 if ( array_key_exists( 'logout_message', $this->options ) && !empty($this->options['logout_message']) ) {
463 $loginpress_message = $this->options['logout_message'];
464 }
465 } else {
466
467 if ( strpos( $message, __( "Please enter your username or email address. You will receive a link to create a new password via email." ) ) == true ) {
468 if ( array_key_exists( 'lostpwd_welcome_message', $this->options ) && !empty($this->options['lostpwd_welcome_message']) ) {
469 $loginpress_message = $this->options['lostpwd_welcome_message'];
470 }
471 } else {
472
473 if ( strpos( $message, __( "Register For This Site" ) ) == true ) {
474 if ( array_key_exists( 'register_welcome_message', $this->options ) && !empty($this->options['register_welcome_message']) ) {
475 $loginpress_message = $this->options['register_welcome_message'];
476 }
477 } else {
478
479 if ( strpos( $message, __( "Your password has been reset." ) ) == true ) {
480 // if ( array_key_exists( 'after_reset_message', $this->options ) && ! empty( $this->options['after_reset_message'] ) ) {
481 $loginpress_message = __( 'Your password has been reset.' ) . ' <a href="' . esc_url( wp_login_url() ) . '">' . __( 'Log in' ) . '</a></p>';
482 // }
483 } else {
484 if ( array_key_exists( 'welcome_message', $this->options ) && !empty($this->options['welcome_message']) ) {
485 $loginpress_message = $this->options['welcome_message'];
486 }
487 }
488
489 }
490
491 }
492
493 }
494
495 return ( !empty($loginpress_message) ? "<p class='custom-message'>" . $loginpress_message . "</p>" : $message );
496 }
497
498 }
499
500 public function add_header_html()
501 {
502 ?>
503 <div class="wp-adminify-background">
504 <div class="wp-adminify-background-wrapper">
505 <div class="login-background"></div>
506 </div>
507 </div>
508 <div class="columns all-centered">
509 <?php
510 }
511
512 public function add_footer_html()
513 {
514 echo '</div></div></div>' ;
515 }
516
517 // Video Background
518 public function add_video_html()
519 {
520
521 if ( !empty($this->options['jltwp_adminify_login_bg_type']) && $this->options['jltwp_adminify_login_bg_type'] === "video" ) {
522 $video_html = '';
523 require dirname( __FILE__ ) . '/footer-video.php';
524 return $video_html;
525 } else {
526 if ( is_customize_preview() ) {
527 printf( '<script type="text/javascript" src="%s?ver=%s"></script>', WP_ADMINIFY_ASSETS . 'vendors/vidim/vidim.min.js', WP_ADMINIFY_VER );
528 }
529 }
530
531 }
532
533 // Slideshow
534 public function add_slideshow_html()
535 {
536
537 if ( !empty($this->options['jltwp_adminify_login_bg_type']) && $this->options['jltwp_adminify_login_bg_type'] === "slideshow" ) {
538 $slideshow_html = '';
539 require dirname( __FILE__ ) . '/footer-slideshow.php';
540 return $slideshow_html;
541 }
542
543 }
544
545 public function add_extra_div()
546 {
547 echo '<div class="wp-adminify-container"><div class="wp-adminify-form-container">' ;
548 }
549
550 public function close_extra_div()
551 {
552 echo '</div></div>' ;
553 }
554
555 // Check Login page texts
556 public function check_login_texts()
557 {
558 add_filter(
559 'gettext',
560 [ $this, 'change_username_label' ],
561 99,
562 3
563 );
564 add_filter(
565 'gettext',
566 [ $this, 'change_password_label' ],
567 99,
568 3
569 );
570 add_filter(
571 'gettext',
572 [ $this, 'change_rememberme_label' ],
573 99,
574 3
575 );
576 add_filter(
577 'gettext',
578 [ $this, 'change_login_label' ],
579 99,
580 3
581 );
582 add_filter(
583 'gettext',
584 [ $this, 'change_register_login_link_text' ],
585 99,
586 3
587 );
588 }
589
590 // Check Register page texts
591 public function check_register_texts()
592 {
593 add_filter(
594 'gettext',
595 [ $this, 'change_register_username_label' ],
596 99,
597 3
598 );
599 add_filter(
600 'gettext',
601 [ $this, 'change_register_email_label' ],
602 99,
603 3
604 );
605 add_filter(
606 'gettext',
607 [ $this, 'change_register_register_label' ],
608 99,
609 3
610 );
611 add_filter(
612 'gettext',
613 [ $this, 'change_register_confirmation_text' ],
614 99,
615 3
616 );
617 add_filter(
618 'gettext',
619 [ $this, 'change_login_register_link_text' ],
620 99,
621 3
622 );
623 }
624
625 // Check Lost Password page texts
626 public function check_lostpasswords_texts()
627 {
628 add_filter(
629 'gettext',
630 [ $this, 'change_lostpasswords_username_label' ],
631 99,
632 3
633 );
634 add_filter(
635 'gettext',
636 [ $this, 'change_lostpasswords_button_label' ],
637 99,
638 3
639 );
640 add_filter(
641 'gettext',
642 [ $this, 'change_register_login_link_text' ],
643 99,
644 3
645 );
646 add_filter(
647 'gettext',
648 [ $this, 'change_login_register_link_text' ],
649 99,
650 3
651 );
652 }
653
654 public function get_image_urls_by_ids( $ids = '' )
655 {
656 if ( empty($ids) ) {
657 return [];
658 }
659 $image_ids = explode( ',', $ids );
660 $images = [];
661 foreach ( $image_ids as $image_id ) {
662 $image_url = wp_get_attachment_url( $image_id );
663 if ( !empty($image_url) ) {
664 $images[] = [
665 'src' => $image_url,
666 ];
667 }
668 }
669 return $images;
670 }
671
672 /**
673 * Customizer output for custom register username label.
674 *
675 * @param string|string $translated_text The translated text.
676 * @param string|string $text The label we want to replace.
677 * @param string|string $domain The text domain of the site.
678 * @return string
679 */
680 public function change_register_username_label( $translated_text, $text, $domain )
681 {
682 $default = 'Username';
683 // Check if is our text
684 if ( $default !== $text ) {
685 return $translated_text;
686 }
687 $label = ( isset( $this->options['login_form_fields']['label_username'] ) ? $this->options['login_form_fields']['label_username'] : $default );
688 // Check if the label is changed
689
690 if ( $label === $text ) {
691 return $translated_text;
692 } else {
693 $translated_text = wp_kses_post( $label );
694 }
695
696 return $translated_text;
697 }
698
699 /**
700 * Customizer output for custom register email label.
701 *
702 * @param string|string $translated_text The translated text.
703 * @param string|string $text The label we want to replace.
704 * @param string|string $domain The text domain of the site.
705 * @return string
706 */
707 public function change_register_email_label( $translated_text, $text, $domain )
708 {
709 $default = 'Username or Email Address';
710 // Check if is our text
711 if ( $default !== $text ) {
712 return $translated_text;
713 }
714 $label = ( isset( $this->options['login_form_fields']['label_username'] ) ? $this->options['login_form_fields']['label_username'] : $default );
715 // Check if the label is changed
716
717 if ( $label === $text ) {
718 return $translated_text;
719 } else {
720 $translated_text = esc_html( $label );
721 }
722
723 return $translated_text;
724 }
725
726 /**
727 * Customizer output for custom register button text.
728 *
729 * @param string|string $translated_text The translated text.
730 * @param string|string $text The label we want to replace.
731 * @param string|string $domain The text domain of the site.
732 * @return string
733 */
734 public function change_register_register_label( $translated_text, $text, $domain )
735 {
736 $default = 'Register';
737 // Check if is our text
738 if ( $default !== $text ) {
739 return $translated_text;
740 }
741 $label = ( isset( $this->options['login_form_fields']['label_register'] ) ? $this->options['login_form_fields']['label_register'] : $default );
742 // Check if the label is changed
743
744 if ( $label === $text ) {
745 return $translated_text;
746 } else {
747 $translated_text = esc_html( $label );
748 }
749
750 return $translated_text;
751 }
752
753 /**
754 * Customizer output for custom registration confirmation text.
755 *
756 * @param string|string $translated_text The translated text.
757 * @param string|string $text The label we want to replace.
758 * @param string|string $domain The text domain of the site.
759 * @return string
760 */
761 public function change_register_confirmation_text( $translated_text, $text, $domain )
762 {
763 $default = 'Registration confirmation will be emailed to you.';
764 // Check if is our text
765 if ( $default !== $text ) {
766 return $translated_text;
767 }
768 // $label = $this->options['register-confirmation-email'];
769 $label = 'Confirm your Email';
770 // Check if the label is changed
771
772 if ( $label === $text ) {
773 return $translated_text;
774 } else {
775 $translated_text = wp_kses_post( $label );
776 }
777
778 return $translated_text;
779 }
780
781 public function change_login_register_link_text( $translated_text, $text, $domain )
782 {
783 $default = 'Log in';
784 // Check if is our text
785 if ( $default !== $text ) {
786 return $translated_text;
787 }
788 $label = ( isset( $this->options['login_form_fields']['input_login'] ) ? $this->options['login_form_fields']['input_login'] : $default );
789 // Check if the label is changed
790
791 if ( $label === $text ) {
792 return $translated_text;
793 } else {
794 $translated_text = esc_html( $label );
795 }
796
797 return $translated_text;
798 }
799
800 /**
801 * Customizer output for custom username label.
802 *
803 * @param string|string $translated_text The translated text.
804 * @param string|string $text The label we want to replace.
805 * @param string|string $domain The text domain of the site.
806 * @return string
807 */
808 public function change_username_label( $translated_text, $text, $domain )
809 {
810 $default = 'Username or Email Address';
811 // Check if is our text
812 if ( $default !== $text ) {
813 return $translated_text;
814 }
815 $label = ( isset( $this->options['login_form_fields']['label_username'] ) ? $this->options['login_form_fields']['label_username'] : $default );
816 // Check if the label is changed
817
818 if ( $label === $text ) {
819 return $translated_text;
820 } else {
821 $translated_text = wp_kses_post( $label );
822 }
823
824 return $translated_text;
825 }
826
827 /**
828 * Customizer output for custom password label.
829 *
830 * @param string|string $translated_text The translated text.
831 * @param string|string $text The label we want to replace.
832 * @param string|string $domain The text domain of the site.
833 * @return string
834 */
835 public function change_password_label( $translated_text, $text, $domain )
836 {
837 $default = 'Password';
838 // Check if is our text
839 if ( $default !== $text ) {
840 return $translated_text;
841 }
842 $label = ( isset( $this->options['login_form_fields']['label_password'] ) ? $this->options['login_form_fields']['label_password'] : $default );
843 // Check if the label is changed
844
845 if ( $label === $text ) {
846 return $translated_text;
847 } else {
848 $translated_text = esc_html( $label );
849 }
850
851 return $translated_text;
852 }
853
854 /**
855 * Customizer output for custom remember me text.
856 *
857 * @param string|string $translated_text The translated text.
858 * @param string|string $text The label we want to replace.
859 * @param string|string $domain The text domain of the site.
860 * @return string
861 */
862 public function change_rememberme_label( $translated_text, $text, $domain )
863 {
864 $default = 'Remember Me';
865 // Check if is our text
866 if ( $default !== $text ) {
867 return $translated_text;
868 }
869 $label = ( isset( $this->options['login_form_fields']['label_remember_me'] ) ? $this->options['login_form_fields']['label_remember_me'] : $default );
870 // Check if the label is changed
871
872 if ( $label === $text ) {
873 return $translated_text;
874 } else {
875 $translated_text = esc_html( $label );
876 }
877
878 return $translated_text;
879 }
880
881 // Check general texts
882 public function check_general_texts()
883 {
884 add_filter(
885 'gettext',
886 [ $this, 'change_lost_password_text' ],
887 99,
888 3
889 );
890 add_filter(
891 'gettext_with_context',
892 [ $this, 'change_back_to_text' ],
893 99,
894 4
895 );
896 }
897
898 /**
899 * Customizer output for custom lost your password text.
900 *
901 * @param string|string $translated_text The translated text.
902 * @param string|string $text The label we want to replace.
903 * @param string|string $domain The text domain of the site.
904 * @return string
905 */
906 public function change_lost_password_text( $translated_text, $text, $domain )
907 {
908 $default = 'Lost your password?';
909 $label = ( isset( $this->options['login_form_fields']['label_lost_password'] ) ? $this->options['login_form_fields']['label_lost_password'] : $default );
910 // Check if is our text
911 if ( $default !== $text ) {
912 return $translated_text;
913 }
914 // Check if the label is changed
915
916 if ( $label === $text ) {
917 return $translated_text;
918 } else {
919 $translated_text = esc_html( $label );
920 }
921
922 return $translated_text;
923 }
924
925 /**
926 * Customizer output for custom login text.
927 *
928 * @param string|string $translated_text The translated text.
929 * @param string|string $text The label we want to replace.
930 * @param string|string $domain The text domain of the site.
931 * @return string
932 */
933 public function change_login_label( $translated_text, $text, $domain )
934 {
935 $default = 'Log In';
936 // Check if is our text
937 if ( $default !== $text ) {
938 return $translated_text;
939 }
940 $label = ( isset( $this->options['login_form_fields']['input_login'] ) ? $this->options['login_form_fields']['input_login'] : $default );
941 // Check if the label is changed
942
943 if ( $label === $text ) {
944 return $translated_text;
945 } else {
946 $translated_text = esc_attr( $label );
947 }
948
949 return $translated_text;
950 }
951
952 public function change_register_login_link_text( $translated_text, $text, $domain )
953 {
954 $default = 'Register';
955 // Check if is our text
956 if ( $default !== $text ) {
957 return $translated_text;
958 }
959 $label = ( isset( $this->options['login_form_fields']['label_register'] ) ? $this->options['login_form_fields']['label_register'] : $default );
960 // Check if the label is changed
961
962 if ( $label === $text ) {
963 return $translated_text;
964 } else {
965 $translated_text = esc_html( $label );
966 }
967
968 return $translated_text;
969 }
970
971 public function change_lostpasswords_username_label( $translated_text, $text, $domain )
972 {
973 $default = 'Username or Email Address';
974 // Check if is our text
975 if ( $default !== $text ) {
976 return $translated_text;
977 }
978 $label = ( isset( $this->options['login_form_fields']['label_lost_password'] ) ? $this->options['login_form_fields']['label_lost_password'] : $default );
979 // Check if the label is changed
980
981 if ( $label === $text ) {
982 return $translated_text;
983 } else {
984 $translated_text = wp_kses_post( $label );
985 }
986
987 return $translated_text;
988 }
989
990 public function change_lostpasswords_button_label( $translated_text, $text, $domain )
991 {
992 $default = 'Reset Password';
993 // Check if is our text
994 if ( $default !== $text ) {
995 return $translated_text;
996 }
997 $label = 'Reset Password';
998 // Check if the label is changed
999
1000 if ( $label === $text ) {
1001 return $translated_text;
1002 } else {
1003 $translated_text = esc_html( $label );
1004 }
1005
1006 return $translated_text;
1007 }
1008
1009 /**
1010 * Customizer output for custom back to text.
1011 *
1012 * @param string|string $translated_text The translated text.
1013 * @param string|string $text The label we want to replace.
1014 * @param string|string $domain The text domain of the site.
1015 * @return string
1016 */
1017 public function change_back_to_text(
1018 $translated_text,
1019 $text,
1020 $context,
1021 $domain
1022 )
1023 {
1024 $default = '&larr; Back to %s';
1025 $label = ( isset( $this->options['login_form_fields']['label_back_to_site'] ) ? $this->options['login_form_fields']['label_back_to_site'] : $default );
1026 // Check if is our text
1027 if ( $default !== $text ) {
1028 return $translated_text;
1029 }
1030 // Check if the label is changed
1031
1032 if ( $label === $text ) {
1033 return $translated_text;
1034 } else {
1035 $translated_text = '&larr; ' . esc_html( $label ) . ' %s';
1036 }
1037
1038 return $translated_text;
1039 }
1040
1041 /**
1042 * Outputs the viewport meta tag.
1043 */
1044 function login_viewport_meta()
1045 {
1046 ?>
1047 <meta name="viewport" content="width=device-width" />
1048 <?php
1049 }
1050
1051 }
1052 }