wsl.users.gateway.php ➔ wsl_process_login_new_users_gateway()   F
last analyzed

Complexity

Conditions 62
Paths > 20000

Size

Total Lines 679

Duplication

Lines 12
Ratio 1.77 %

Importance

Changes 0
Metric Value
cc 62
nc 3779371920
nop 3
dl 12
loc 679
rs 0
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/*!
3
* WordPress Social Login
4
*
5
* https://miled.github.io/wordpress-social-login/ | https://github.com/miled/wordpress-social-login
6
*   (c) 2011-2020 Mohamed Mrassi and contributors | https://wordpress.org/plugins/wordpress-social-login/
7
*/
8
9
/**
10
* New Users Gateway: Accounts linking + Profile Completion
11
*
12
* When enabled, Bouncer will popup this screen for unrecognised user, where they will be given the choice to either associate
13
* any existing account in your website with the provider ID they have connected with or to create a new user account.
14
*/
15
16
// Exit if accessed directly
17
if( !defined( 'ABSPATH' ) ) exit;
18
19
// --------------------------------------------------------------------
20
21
function wsl_process_login_new_users_gateway( $provider, $redirect_to, $hybridauth_user_profile )
22
{
23
	// HOOKABLE:
24
	do_action( "wsl_process_login_new_users_gateway_start", $provider, $redirect_to, $hybridauth_user_profile );
25
26
	$assets_base_url = WORDPRESS_SOCIAL_LOGIN_PLUGIN_URL . 'assets/img/16x16/';
27
28
	// remove wsl widget
29
	remove_action( 'register_form', 'wsl_render_auth_widget_in_wp_register_form' );
30
31
	$hybridauth_user_email          = sanitize_email( $hybridauth_user_profile->email );
32
    $hybridauth_user_email_verified = sanitize_email( $hybridauth_user_profile->emailVerified );
33
	$hybridauth_user_login          = sanitize_user( $hybridauth_user_profile->displayName, true );
34
	$hybridauth_user_avatar         = $hybridauth_user_profile->photoURL;
35
36
	if ( empty( $hybridauth_user_avatar ) )
37
	{
38
		$hybridauth_user_avatar  = 'https://secure.gravatar.com/avatar/' . md5( $hybridauth_user_email ) . '?size=145';
39
	}
40
41
	$hybridauth_user_website     = $hybridauth_user_profile->webSiteURL;
0 ignored issues
show
Unused Code introduced by
$hybridauth_user_website is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
42
	$hybridauth_user_link        = $hybridauth_user_profile->profileURL;
0 ignored issues
show
Unused Code introduced by
$hybridauth_user_link is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
43
44
	$hybridauth_user_login       = trim( str_replace( array( ' ', '.' ), '_', $hybridauth_user_login ) );
45
	$hybridauth_user_login       = trim( str_replace( '__', '_', $hybridauth_user_login ) );
46
47
	$requested_user_email        = isset( $_REQUEST["user_email"] ) ? trim( $_REQUEST["user_email"] ) : $hybridauth_user_email;
48
	$requested_user_login        = isset( $_REQUEST["user_login"] ) ? trim( $_REQUEST["user_login"] ) : $hybridauth_user_login;
49
50
	$requested_user_email        = apply_filters( 'wsl_new_users_gateway_alter_requested_email', $requested_user_email );
51
	$requested_user_login        = apply_filters( 'wsl_new_users_gateway_alter_requested_login', $requested_user_login );
52
53
	$user_id    = 0;
54
	$shall_pass = false;
55
56
	$bouncer_account_linking    = false;
57
	$account_linking_errors     = array();
58
59
	$bouncer_profile_completion = false;
60
	$profile_completion_errors  = array();
61
62
	$registration_enabled = get_option( 'wsl_settings_bouncer_registration_enabled' );
63
	$linking_enabled      = get_option( 'wsl_settings_bouncer_accounts_linking_enabled' );
64
	$require_email        = get_option( 'wsl_settings_bouncer_profile_completion_require_email' );
65
	$change_username      = get_option( 'wsl_settings_bouncer_profile_completion_change_username' );
66
	$extra_fields         = get_option( 'wsl_settings_bouncer_profile_completion_hook_extra_fields' );
67
68
	// Better UX when possible without UI prompts to user
69
	if( ! isset( $_REQUEST["bouncer_profile_completion"] ) && ! isset( $_REQUEST["bouncer_profile_completion"] ) )
70
	{
71
		// when linking is enabled, email is verified by IDp
72
		// then try to do account linking WITHOUT asking the user to link to WP account
73
		// if verified email exists to a WP user
74
		if( $linking_enabled == 1 && ! empty( $hybridauth_user_email_verified ) )
75
		{
76
			// check if the verified email exist in wp_users
77
			$user_id = (int) wsl_wp_email_exists( $hybridauth_user_email_verified );
78
79
			if( $user_id )
80
			{
81
				$shall_pass = true;
82
			}
83
		}
84
85
		//  if account_linking is disabled, try to create a new user
86
		if( ! $shall_pass && $linking_enabled == 2 )
87
		{
88
			// Bouncer::Profile Completion enabled?
89
			// > if not enabled or email is verified by IDp
90
			//   we just let the user pass
91
			if( ( $require_email == 2 || ( ! empty( $hybridauth_user_email_verified ) ) )
92
				&& $change_username == 2 && $extra_fields == 2 )
93
			{
94
				$shall_pass = true;
95
			}
96
97
		}
98
	}
99
100
	if( isset( $_REQUEST["bouncer_account_linking"] ) )
101
	{
102
		if( $linking_enabled == 2 )
103
		{
104
			return wsl_process_login_render_notice_page( _wsl__( "Not tonight.", 'wordpress-social-login' ) );
105
		}
106
107
		$bouncer_account_linking = true;
108
109
		$username = isset( $_REQUEST["user_login"]    ) ? trim( $_REQUEST["user_login"]    ) : '';
110
		$password = isset( $_REQUEST["user_password"] ) ? trim( $_REQUEST["user_password"] ) : '';
111
112
		# http://codex.wordpress.org/Function_Reference/wp_authenticate
113
		$user = wp_authenticate( $username, $password );
114
115
		// WP_Error object?
116
		if( is_wp_error( $user ) )
117
		{
118
			// we give no useful hint.
119
			$account_linking_errors[] =
120
								sprintf(
121
										_wsl__(
122
												'<strong>ERROR</strong>: Invalid username or incorrect password. <a href="%s">Lost your password</a>?',
123
												'wordpress-social-login'
124
										),
125
										wp_lostpassword_url( home_url() )
126
								);
127
		}
128
129
		elseif( is_a( $user, 'WP_User') )
130
		{
131
			$user_id = $user->ID;
132
133
			$shall_pass = true;
134
		}
135
	}
136
137
	elseif( isset( $_REQUEST["bouncer_profile_completion"] ) )
138
	{
139
		// Bouncer::Profile Completion enabled?
140
		// > if not enabled we just let the user pass
141
		if( $require_email == 2 && $change_username == 2 && $extra_fields == 2 )
142
		{
143
			$shall_pass = true;
144
		}
145
146
		// otherwise we request email &or username &or extra fields
147
		else
148
		{
149
			$bouncer_profile_completion = true;
150
151
			/**
152
			* Code based on wpmu_validate_user_signup()
153
			*
154
			* Ref: http://codex.wordpress.org/Function_Reference/wpmu_validate_user_signup
155
			*/
156
157
			# {{{ validate usermail
158
			if( $require_email == 1 )
159
			{
160
				if ( empty( $requested_user_email ) )
161
				{
162
					$profile_completion_errors[] = _wsl__( '<strong>ERROR</strong>: Please type your e-mail address.', 'wordpress-social-login' );
163
				}
164
165
				if ( ! is_email( $requested_user_email ) )
166
				{
167
					$profile_completion_errors[] = _wsl__( '<strong>ERROR</strong>: Please enter a valid email address.', 'wordpress-social-login' );
168
				}
169
170
				if ( wsl_wp_email_exists( $requested_user_email ) )
171
				{
172
					$profile_completion_errors[] = _wsl__( '<strong>ERROR</strong>: Sorry, that email address is already used!', 'wordpress-social-login' );
173
				}
174
			}
175
			# }}} validate usermail
176
177
			# {{{ validate username (called login in wsl)
178
			if( $change_username == 1 )
179
			{
180
				$illegal_names = array(  'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator' );
181
182
				$illegal_names = apply_filters( 'wsl_new_users_gateway_alter_illegal_names', $illegal_names );
183
184
				if ( in_array( $requested_user_login, $illegal_names ) == true )
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
185
				{
186
					$profile_completion_errors[] = _wsl__( '<strong>ERROR</strong>: That username is not allowed.', 'wordpress-social-login' );
187
				}
188
189
				if ( strlen( $requested_user_login ) < 4 )
190
				{
191
					$profile_completion_errors[] = _wsl__( '<strong>ERROR</strong>: Username must be at least 4 characters.', 'wordpress-social-login' );
192
				}
193
194
				if ( preg_match( '/^[0-9]*$/', $requested_user_login ) )
195
				{
196
					$profile_completion_errors[] = _wsl__( '<strong>ERROR</strong>: Sorry, usernames must have letters too!', 'wordpress-social-login' );
197
				}
198
199
				if ( username_exists( $requested_user_login) )
200
				{
201
					$profile_completion_errors[] = _wsl__( '<strong>ERROR</strong>: Sorry, that username already exists!', 'wordpress-social-login' );
202
				}
203
			}
204
			# }}} validate username
205
206
			# ... well, that was a lot of sorries.
207
208
			# {{{ extra fields
209
			if( $extra_fields == 1 )
210
			{
211
				$errors = new WP_Error();
212
213
				$errors = apply_filters( 'registration_errors', $errors, $requested_user_login, $requested_user_email );
214
215
				if( $errors = $errors->get_error_messages() )
216
				{
217
					foreach ( $errors as $error )
218
					{
219
						$profile_completion_errors[] = $error;
220
					}
221
				}
222
			}
223
			# }}} extra fields
224
225
			$profile_completion_errors = apply_filters( 'wsl_new_users_gateway_alter_profile_completion_errors', $profile_completion_errors );
226
227
			// all check?
228
			if( ! $profile_completion_errors )
229
			{
230
				$shall_pass = true;
231
			}
232
		}
233
	}
234
235
	if( $shall_pass == false )
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
236
	{
237
		$provider_name = wsl_get_provider_name_by_id( $provider );
238
?>
239
<!DOCTYPE html>
240
	<head>
241
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
242
        <meta name="viewport" content="width=device-width, initial-scale=1" />
243
		<title><?php echo get_bloginfo('name'); ?></title>
244
		<style type="text/css">
245
			body {
246
				background: #f3f6f8;
247
				color: #324155;
248
				font-family: -apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif;
249
				font-size: 16px;
250
				line-height: 1.6;
251
			}
252
			hr {
253
				border-color: #eeeeee;
254
				border-style: none none solid;
255
				border-width: 0 0 1px;
256
				margin: 2px 0 0;
257
			}
258
			h4 {
259
				font-size: 14px;
260
				margin-bottom: 10px;
261
			}
262
			#login {
263
				max-width: 620px;
264
				min-width: 340px;
265
				margin: auto;
266
				padding: 114px 0 0;
267
			}
268
			#login-panel {
269
				background: none repeat scroll 0 0 #fff;
270
				box-shadow: 0 1px 3px rgba(0, 0, 0, 0.13);
271
				margin: 2em auto;
272
				box-sizing: border-box;
273
				display: inline-block;
274
				padding: 70px 0 15px;
275
				position: relative;
276
				text-align: center;
277
				width: 100%;
278
			}
279
			#avatar {
280
				margin-left: -76px;
281
				top: -80px;
282
				left: 50%;
283
				padding: 4px;
284
				position: absolute;
285
			}
286
			#avatar img {
287
				background: none repeat scroll 0 0 #fff;
288
				border: 3px solid #f1f1f1;
289
				border-radius: 75px !important;
290
				box-shadow: 0 1px 3px rgba(0, 0, 0, 0.13);
291
				height: 145px;
292
				width: 145px;
293
			}
294
			#welcome {
295
				height: 55px;
296
				margin: 15px 20px 35px;
297
			}
298
			#idp-icon {
299
				position: absolute;
300
				margin-top: 2px;
301
				margin-left: -19px;
302
			}
303
			#login-form{
304
				margin: 0;
305
				padding: 0;
306
			}
307
			.button-primary {
308
				background-color: #21759b;
309
				background-image: linear-gradient(to bottom, #2a95c5, #21759b);
310
				border-color: #21759b #21759b #1e6a8d;
311
				border-radius: 3px;
312
				border-style: solid;
313
				border-width: 1px;
314
				box-shadow: 0 1px 0 rgba(120, 200, 230, 0.5) inset;
315
				box-sizing: border-box;
316
				color: #fff;
317
				cursor: pointer;
318
				display: inline-block;
319
				float: none;
320
				font-size: 12px;
321
				height: 36px;
322
				line-height: 23px;
323
				margin: 0;
324
				padding: 0 10px 1px;
325
				text-decoration: none;
326
				text-shadow: 0 1px 0 rgba(0, 0, 0, 0.1);
327
				white-space: nowrap;
328
			}
329
			.button-primary.focus, .button-primary:hover{
330
				background:#1e8cbe;
331
				border-color:#0074a2;
332
				-webkit-box-shadow:inset 0 1px 0 rgba(120,200,230,.6);
333
				box-shadow:inset 0 1px 0 rgba(120,200,230,.6);
334
				color:#fff;
335
			}
336
			input[type="text"],
337
			input[type="password"] {
338
				border: 1px solid #e5e5e5;
339
				box-shadow: 1px 1px 2px rgba(200, 200, 200, 0.2) inset;
340
				color: #555;
341
				font-size: 17px;
342
				height: 30px;
343
				line-height: 1;
344
				margin-bottom: 16px;
345
				margin-right: 6px;
346
				margin-top: 2px;
347
				outline: 0 none;
348
				padding: 3px;
349
				width: 100%;
350
			}
351
			input[type="text"]:focus,
352
			input[type="password"]:focus {
353
				border-color:#5b9dd9;
354
				-webkit-box-shadow:0 0 2px rgba(30,140,190,.8);
355
				box-shadow:0 0 2px rgba(30,140,190,.8)
356
			}
357
			input[type="submit"]{
358
				float:right;
359
			}
360
			label{
361
				color:#777;
362
				font-size:14px;
363
				cursor:pointer;
364
				vertical-align:middle;
365
				text-align: left;
366
			}
367
			table {
368
				width:530px;
369
				margin-left:auto;
370
				margin-right:auto;
371
			}
372
			#mapping-options {
373
				width:555px;
374
			}
375
			#mapping-authenticate {
376
				display:none;
377
			}
378
			#mapping-complete-info {
379
				display:none;
380
			}
381
			#mapping-authenticate, #mapping-complete-info {
382
				width: 93%;
383
                padding-left: 15px;
384
                padding-right: 20px;
385
			}
386
			.error {
387
				display:none;
388
				background-color: #fff;
389
				border-left: 4px solid #dd3d36;
390
				box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.1);
391
                margin: 0 22px;
392
                margin-top: 16px;
393
                padding: 6px 12px;
394
				text-align:left;
395
			}
396
			.back-to-options {
397
				float: left;
398
				margin: 7px 0px;
399
			}
400
			.back-to-home {
401
				font-size: 14px;
402
				margin-top: -22px;
403
			}
404
			a {
405
				color: #00aadc;
406
				text-decoration: none;
407
			}
408
			.back-to-home a {
409
				color: #005082;
410
				text-decoration: none;
411
			}
412
			<?php
413
				if( $linking_enabled == 2 )
414
				{
415
					?>
416
					#welcome, #mapping-options, #errors-account-linking, #mapping-complete-info {display: none;}
417
					#errors-profile-completion, #mapping-complete-info {display: block;}
418
					<?php
419
				}
420
				elseif( $bouncer_account_linking )
421
				{
422
					?>
423
					#welcome, #mapping-options, #errors-profile-completion, #mapping-complete-info {display: none;}
424
					#errors-account-linking, #mapping-authenticate {display: block;}
425
					<?php
426
				}
427
				elseif( $bouncer_profile_completion )
428
				{
429
					?>
430
					#welcome, #mapping-options, #errors-account-linking, #mapping-complete-info {display: none;}
431
					#errors-profile-completion, #mapping-complete-info {display: block;}
432
					<?php
433
				}
434
			?>
435
		</style>
436
		<script>
437
			// good old time
438
			function toggle_el( el, display )
439
			{
440
				if( el = document.getElementById( el ) )
441
				{
442
					el.style.display = display;
443
				}
444
			}
445
446
			function toggleWidth( el, width )
447
			{
448
				if( el = document.getElementById( el ) )
449
				{
450
					el.style.width = width;
451
				}
452
			}
453
454
			function display_mapping_options()
455
			{
456
				toggleWidth( 'login', '616px' );
457
458
				toggle_el( 'welcome'        , 'block' );
459
				toggle_el( 'mapping-options', 'block' );
460
461
				toggle_el( 'errors-profile-completion', 'none' );
462
				toggle_el( 'mapping-authenticate'     , 'none' );
463
464
				toggle_el( 'errors-account-linking', 'none' );
465
				toggle_el( 'mapping-complete-info' , 'none' );
466
			}
467
468
			function display_mapping_authenticate()
469
			{
470
                toggleWidth( 'login', 'auto' );
471
472
				toggle_el( 'welcome'        , 'none' );
473
				toggle_el( 'mapping-options', 'none' );
474
475
				toggle_el( 'errors-account-linking', 'none' );
476
				toggle_el( 'mapping-authenticate'  , 'block' );
477
478
				toggle_el( 'errors-profile-completion', 'none' );
479
				toggle_el( 'mapping-complete-info'    ,'none' );
480
			}
481
482
			function display_mapping_complete_info()
483
			{
484
                toggleWidth( 'login', 'auto' );
485
486
				toggle_el( 'welcome'        , 'none' );
487
				toggle_el( 'mapping-options', 'none' );
488
489
				toggle_el( 'errors-account-linking', 'none' );
490
				toggle_el( 'mapping-authenticate'  , 'none' );
491
492
				toggle_el( 'errors-profile-completion', 'none' );
493
				toggle_el( 'mapping-complete-info'    , 'block' );
494
			}
495
		</script>
496
	</head>
497
	<body>
498
		<div id="login">
499
			<div id="login-panel">
500
				<div id="avatar">
501
					<img src="<?php echo $hybridauth_user_avatar; ?>">
502
				</div>
503
504
				<div id="welcome">
505
					<img id="idp-icon" src="<?php echo $assets_base_url . strtolower($provider); ?>.png" >
506
					<b><?php printf( _wsl__( "Hi %s", 'wordpress-social-login' ), htmlentities( $hybridauth_user_profile->displayName ) ); ?></b>
507
					<p><?php printf( _wsl__( "You're now signed in with your %s account but you are still one step away of getting into our website", 'wordpress-social-login' ), $provider_name ); ?>.</p>
508
509
					<hr />
510
				</div>
511
512
				<table id="mapping-options" style="padding-top: 12px;" border="0">
513
					<tr>
514 View Code Duplication
						<?php if( $linking_enabled == 1 ): ?>
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
515
							<td valign="top"  width="50%" style="text-align:center;">
516
								<h4><?php _wsl_e( "Already have an account", 'wordpress-social-login' ); ?>?</h4>
517
								<p style="font-size: 12px;"><?php printf( _wsl__( "Link your existing account on our website to your %s ID.", 'wordpress-social-login' ), $provider_name ); ?></p>
518
							</td>
519
						<?php endif; ?>
520
521 View Code Duplication
						<?php if( $registration_enabled == 1 ): ?>
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
522
						<td valign="top"  width="50%" style="text-align:center;">
523
							<h4><?php _wsl_e( "New to our website", 'wordpress-social-login' ); ?>?</h4>
524
							<p style="font-size: 12px;"><?php printf( _wsl__( "Create a new account and it will be associated with your %s ID.", 'wordpress-social-login' ), $provider_name ); ?></p>
525
						</td>
526
						<?php endif; ?>
527
					</tr>
528
529
					<tr>
530
						<?php if( $linking_enabled == 1 ): ?>
531
							<td valign="top"  width="50%" style="text-align:center;">
532
								<input type="button" value="<?php _wsl_e( "Link my account", 'wordpress-social-login' ); ?>" class="button-primary" onclick="display_mapping_authenticate();" >
533
							</td>
534
						<?php endif; ?>
535
536
						<?php if( $registration_enabled == 1 ): ?>
537
						<td valign="top"  width="50%" style="text-align:center;">
538
							<?php if( ( $require_email != 1 || ! empty( $hybridauth_user_email_verified ) ) && $change_username != 1 && $extra_fields != 1 ): ?>
539
								<input type="button" value="<?php _wsl_e( "Create a new account", 'wordpress-social-login' ); ?>" class="button-primary" onclick="document.getElementById('info-form').submit();" >
540
							<?php else : ?>
541
								<input type="button" value="<?php _wsl_e( "Create a new account", 'wordpress-social-login' ); ?>" class="button-primary" onclick="display_mapping_complete_info();" >
542
							<?php endif; ?>
543
						</td>
544
						<?php endif; ?>
545
					</tr>
546
				</table>
547
548
				<?php
549
					if( ! empty($account_linking_errors) )
550
					{
551
						echo '<div id="errors-account-linking" class="error">';
552
553
						foreach( $account_linking_errors as $error )
554
						{
555
							?><p style="padding: 2px; margin: 0px;"><?php echo $error; ?></p><?php
556
						}
557
558
						echo '</div>';
559
					}
560
561
					if( $profile_completion_errors )
562
					{
563
						echo '<div id="errors-profile-completion" class="error">';
564
565
						foreach( $profile_completion_errors as $error )
566
						{
567
							?><p style="padding: 2px; margin: 0px;"><?php echo $error; ?></p><?php
568
						}
569
570
						echo '</div>';
571
					}
572
				?>
573
574
				<?php if( $linking_enabled == 1 ): ?>
575
576
					<form method="post" action="<?php echo site_url( 'wp-login.php', 'login_post' ); ?>" id="link-form">
577
						<table id="mapping-authenticate" border="0">
578
							<tr>
579
								<td valign="top" style="text-align:center;">
580
									<h4><?php _wsl_e( "Already have an account", 'wordpress-social-login' ); ?>?</h4>
581
582
									<p><?php printf( _wsl__( "Please enter your username and password of your existing account on our website. Once verified, it will linked to your %s ID", 'wordpress-social-login' ), $provider_name ) ; ?>.</p>
583
								</td>
584
							</tr>
585
							<tr>
586
								<td valign="bottom" style="text-align:left;">
587
									<label>
588
										<?php _wsl_e( "Username", 'wordpress-social-login' ); ?>
589
										<br />
590
										<input type="text" name="user_login" class="input" value=""  size="25" placeholder="" />
591
									</label>
592
593
									<label>
594
										<?php _wsl_e( "Password", 'wordpress-social-login' ); ?>
595
										<br />
596
										<input type="password" name="user_password" class="input" value="" size="25" placeholder="" />
597
									</label>
598
599
									<input type="submit" value="<?php _wsl_e( "Continue", 'wordpress-social-login' ); ?>" class="button-primary" >
600
601
									<a href="javascript:void(0);" onclick="display_mapping_options();" class="back-to-options"><?php _wsl_e( "Cancel", 'wordpress-social-login' ); ?></a>
602
								</td>
603
							</tr>
604
						</table>
605
606
						<input type="hidden" id="redirect_to" name="redirect_to" value="<?php echo $redirect_to ?>">
607
						<input type="hidden" id="provider" name="provider" value="<?php echo $provider ?>">
608
						<input type="hidden" id="action" name="action" value="wordpress_social_account_linking">
609
						<input type="hidden" id="bouncer_account_linking" name="bouncer_account_linking" value="1">
610
					</form>
611
612
				<?php endif; ?>
613
614
				<?php if( $registration_enabled == 1 ): ?>
615
616
					<form method="post" action="<?php echo site_url( 'wp-login.php', 'login_post' ); ?>" id="info-form">
617
						<table id="mapping-complete-info" border="0">
618
							<tr>
619
								<td valign="top" style="text-align:center;">
620
									<?php if( $linking_enabled == 1 ): ?>
621
										<h4><?php _wsl_e( "New to our website", 'wordpress-social-login' ); ?>?</h4>
622
									<?php endif; ?>
623
624
									<p><?php printf( _wsl__( "Please fill in your information in the form below. Once completed, you will be able to automatically sign into our website through your %s ID", 'wordpress-social-login' ), $provider_name ); ?>.</p>
625
								</td>
626
							</tr>
627
							<tr>
628
								<td valign="bottom" style="text-align:left;">
629
									<?php if( $change_username == 1 ): ?>
630
										<label>
631
											<?php _wsl_e( "Username", 'wordpress-social-login' ); ?>
632
											<br />
633
											<input type="text" name="user_login" class="input" value="<?php echo $requested_user_login; ?>" size="25" placeholder="" />
634
										</label>
635
									<?php endif; ?>
636
637
									<?php if( $require_email == 1 ): ?>
638
										<label>
639
											<?php _wsl_e( "E-mail", 'wordpress-social-login' ); ?>
640
											<br />
641
											<input type="text" name="user_email" class="input" value="<?php echo $requested_user_email; ?>" size="25" placeholder="" />
642
										</label>
643
									<?php endif; ?>
644
645
									<?php
646
										/**
647
										* Fires following the 'E-mail' field in the user registration form.
648
										*
649
										* hopefully, this won't become a pain in future
650
										*
651
										* Ref: http://codex.wordpress.org/Plugin_API/Action_Reference/register_form
652
										*/
653
										if( $extra_fields == 1 )
654
										{
655
											do_action( 'register_form' );
656
										}
657
									?>
658
659
									<input type="submit" value="<?php _wsl_e( "Continue", 'wordpress-social-login' ); ?>" class="button-primary" >
660
661
									<?php if( $linking_enabled == 1 ): ?>
662
										<a href="javascript:void(0);" onclick="display_mapping_options();" class="back-to-options"><?php _wsl_e( "Cancel", 'wordpress-social-login' ); ?></a>
663
									<?php endif; ?>
664
								</td>
665
							</tr>
666
						</table>
667
668
						<input type="hidden" id="redirect_to" name="redirect_to" value="<?php echo $redirect_to ?>">
669
						<input type="hidden" id="provider" name="provider" value="<?php echo $provider ?>">
670
						<input type="hidden" id="action" name="action" value="wordpress_social_account_linking">
671
						<input type="hidden" id="bouncer_profile_completion" name="bouncer_profile_completion" value="1">
672
					</form>
673
674
				<?php endif; ?>
675
            </div>
676
677
			<p class="back-to-home">
678
				<a href="<?php echo home_url(); ?>">&#8592; <?php printf( _wsl__( "Back to %s", 'wordpress-social-login' ), get_bloginfo('name') ); ?></a>
679
			</p>
680
		</div>
681
682
		<?php
683
			// Development mode on?
684
			if( get_option( 'wsl_settings_development_mode_enabled' ) )
685
			{
686
				wsl_display_dev_mode_debugging_area();
687
			}
688
689
			// HOOKABLE:
690
			do_action( "wsl_process_login_new_users_gateway_closing_body", $provider, $redirect_to, $hybridauth_user_profile );
691
		?>
692
	</body>
693
</html>
694
<?php
695
		die();
696
	}
697
698
	return array( $shall_pass, $user_id, $requested_user_login, $requested_user_email );
699
}
700
701
// --------------------------------------------------------------------
702