Completed
Pull Request — v2 (#218)
by
unknown
04:15 queued 01:53
created

wsl.auth.widgets.php ➔ wsl_disable_password_authentication()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 41 and the first side effect is on line 18.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/*!
3
* WordPress Social Login
4
*
5
* http://miled.github.io/wordpress-social-login/ | https://github.com/miled/wordpress-social-login
6
*  (c) 2011-2015 Mohamed Mrassi and contributors | http://wordpress.org/plugins/wordpress-social-login/
7
*/
8
9
/**
10
* Authentication widgets generator
11
*
12
* http://miled.github.io/wordpress-social-login/widget.html
13
* http://miled.github.io/wordpress-social-login/themes.html
14
* http://miled.github.io/wordpress-social-login/developer-api-widget.html
15
*/
16
17
// Exit if accessed directly
18
if( !defined( 'ABSPATH' ) ) exit;
19
20
// --------------------------------------------------------------------
21
22
/**
23
* Generate the HTML content of WSL Widget
24
*
25
* Note:
26
*   WSL shortcode arguments are still experimental and might change in future versions.
27
*
28
*   [wordpress_social_login
29
*        auth_mode="login"
30
*        caption="Connect with"
31
*        enable_providers="facebook|google"
32
*        restrict_content="wsl_user_logged_in"
33
*        assets_base_url="http://example.com/wp-content/uploads/2022/01/"
34
*   ]
35
*
36
*   Overall, WSL widget work with these simple rules :
37
*      1. Shortcode arguments rule over the defaults
38
*      2. Filters hooks rule over shortcode arguments
39
*      3. Bouncer rules over everything
40
*/
41
function wsl_render_auth_widget( $args = array() )
0 ignored issues
show
Coding Style introduced by
wsl_render_auth_widget uses the super-global variable $GLOBALS which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
Coding Style introduced by
wsl_render_auth_widget uses the super-global variable $_REQUEST which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
42
{
43
	$auth_mode = isset( $args['mode'] ) && $args['mode'] ? $args['mode'] : 'login';
44
45
	// validate auth-mode
46
	if( ! in_array( $auth_mode, array( 'login', 'link', 'test' ) ) )
47
	{
48
		return;
49
	}
50
51
	// auth-mode eq 'login' => display wsl widget only for NON logged in users
52
	// > this is the default mode of wsl widget.
53
	if( $auth_mode == 'login' && is_user_logged_in() )
54
	{
55
		return;
56
	}
57
58
	// auth-mode eq 'link' => display wsl widget only for LOGGED IN users
59
	// > this will allows users to manually link other social network accounts to their WordPress account
60
	if( $auth_mode == 'link' && ! is_user_logged_in() )
61
	{
62
		return;
63
	}
64
65
	// auth-mode eq 'test' => display wsl widget only for LOGGED IN users only on dashboard
66
	// > used in Authentication Playground on WSL admin dashboard
67
	if( $auth_mode == 'test' && ! is_user_logged_in() && ! is_admin() )
68
	{
69
		return;
70
	}
71
72
	// Bouncer :: Allow authentication?
73
	if( get_option( 'wsl_settings_bouncer_authentication_enabled' ) == 2 )
74
	{
75
		return;
76
	}
77
78
	// HOOKABLE: This action runs just before generating the WSL Widget.
79
	do_action( 'wsl_render_auth_widget_start' );
80
81
	GLOBAL $WORDPRESS_SOCIAL_LOGIN_PROVIDERS_CONFIG;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
82
83
	ob_start();
84
85
	// Icon set. If eq 'none', we show text instead
86
	$social_icon_set = get_option( 'wsl_settings_social_icon_set' );
87
88
	// wpzoom icons set, is shown by default
89
	if( empty( $social_icon_set ) )
90
	{
91
		$social_icon_set = "wpzoom/";
92
	}
93
94
	$assets_base_url  = WORDPRESS_SOCIAL_LOGIN_PLUGIN_URL . 'assets/img/32x32/' . $social_icon_set . '/';
95
96
	$assets_base_url  = isset( $args['assets_base_url'] ) && $args['assets_base_url'] ? $args['assets_base_url'] : $assets_base_url;
97
98
	// HOOKABLE:
99
	$assets_base_url = apply_filters( 'wsl_render_auth_widget_alter_assets_base_url', $assets_base_url );
100
101
	// get the current page url, which we will use to redirect the user to,
102
	// unless Widget::Force redirection is set to 'yes', then this will be ignored and Widget::Redirect URL will be used instead
103
	$redirect_to = wsl_get_current_url();
104
105
	// Use the provided redirect_to if it is given and this is the login page.
106
	if ( in_array( $GLOBALS["pagenow"], array( "wp-login.php", "wp-register.php" ) ) && !empty( $_REQUEST["redirect_to"] ) )
107
	{
108
		$redirect_to = $_REQUEST["redirect_to"];
109
	}
110
111
	// build the authentication url which will call for wsl_process_login() : action=wordpress_social_authenticate
112
	$authenticate_base_url = site_url( 'wp-login.php', 'login_post' ) 
113
                                        . ( strpos( site_url( 'wp-login.php', 'login_post' ), '?' ) ? '&' : '?' ) 
114
                                                . "action=wordpress_social_authenticate&mode=login&";
115
116
	// if not in mode login, we overwrite the auth base url
117
	// > admin auth playground
118
	if( $auth_mode == 'test' )
119
	{
120
		$authenticate_base_url = home_url() . "/?action=wordpress_social_authenticate&mode=test&";
121
	}
122
123
	// > account linking
124
	elseif( $auth_mode == 'link' )
125
	{
126
		$authenticate_base_url = home_url() . "/?action=wordpress_social_authenticate&mode=link&";
127
	}
128
129
	// Connect with caption
130
	$connect_with_label = _wsl__( get_option( 'wsl_settings_connect_with_label' ), 'wordpress-social-login' );
131
132
	$connect_with_label = isset( $args['caption'] ) ? $args['caption'] : $connect_with_label;
133
134
	// HOOKABLE:
135
	$connect_with_label = apply_filters( 'wsl_render_auth_widget_alter_connect_with_label', $connect_with_label );
136
?>
137
138
<!--
139
	wsl_render_auth_widget
140
	WordPress Social Login <?php echo wsl_get_version(); ?>.
141
	http://wordpress.org/plugins/wordpress-social-login/
142
-->
143
<?php
144
	// Widget::Custom CSS
145
	$widget_css = get_option( 'wsl_settings_authentication_widget_css' );
146
147
	// HOOKABLE:
148
	$widget_css = apply_filters( 'wsl_render_auth_widget_alter_widget_css', $widget_css, $redirect_to );
149
150
	// show the custom widget css if not empty
151
	if( ! empty( $widget_css ) )
152
	{
153
?>
154
155
<style type="text/css">
156
<?php
157
	echo
158
		preg_replace(
159
			array( '%/\*(?:(?!\*/).)*\*/%s', '/\s{2,}/', "/\s*([;{}])[\r\n\t\s]/", '/\\s*;\\s*/', '/\\s*{\\s*/', '/;?\\s*}\\s*/' ),
160
				array( '', ' ', '$1', ';', '{', '}' ),
161
					$widget_css );
162
?>
163
</style>
164
<?php
165
	}
166
?>
167
168
<div class="wp-social-login-widget">
169
170
	<div class="wp-social-login-connect-with"><?php echo $connect_with_label; ?></div>
171
172
	<div class="wp-social-login-provider-list">
173
<?php
174
	// Widget::Authentication display
175
	$wsl_settings_use_popup = get_option( 'wsl_settings_use_popup' );
176
177
	// if a user is visiting using a mobile device, WSL will fall back to more in page
178
	$wsl_settings_use_popup = function_exists( 'wp_is_mobile' ) ? wp_is_mobile() ? 2 : $wsl_settings_use_popup : $wsl_settings_use_popup;
179
180
	$no_idp_used = true;
181
182
	// display provider icons
183
	foreach( $WORDPRESS_SOCIAL_LOGIN_PROVIDERS_CONFIG AS $item )
184
	{
185
		$provider_id    = isset( $item["provider_id"]    ) ? $item["provider_id"]   : '' ;
186
		$provider_name  = isset( $item["provider_name"]  ) ? $item["provider_name"] : '' ;
187
188
		// provider enabled?
189
		if( get_option( 'wsl_settings_' . $provider_id . '_enabled' ) )
190
		{
191
			// restrict the enabled providers list
192
			if( isset( $args['enable_providers'] ) )
193
			{
194
				$enable_providers = explode( '|', $args['enable_providers'] ); // might add a couple of pico seconds
195
196
				if( ! in_array( strtolower( $provider_id ), $enable_providers ) )
197
				{
198
					continue;
199
				}
200
			}
201
202
			// build authentication url
203
			$authenticate_url = $authenticate_base_url . "provider=" . $provider_id . "&redirect_to=" . urlencode( $redirect_to );
204
205
			// http://codex.wordpress.org/Function_Reference/esc_url
206
			$authenticate_url = esc_url( $authenticate_url );
207
208
			// in case, Widget::Authentication display is set to 'popup', then we overwrite 'authenticate_url'
209
			// > /assets/js/connect.js will take care of the rest
210
			if( $wsl_settings_use_popup == 1 &&  $auth_mode != 'test' )
211
			{
212
				$authenticate_url= "javascript:void(0);";
213
			}
214
215
			// HOOKABLE: allow user to rebuilt the auth url
216
			$authenticate_url = apply_filters( 'wsl_render_auth_widget_alter_authenticate_url', $authenticate_url, $provider_id, $auth_mode, $redirect_to, $wsl_settings_use_popup );
217
218
			// HOOKABLE: allow use of other icon sets
219
			$provider_icon_markup = apply_filters( 'wsl_render_auth_widget_alter_provider_icon_markup', $provider_id, $provider_name, $authenticate_url );
220
221
			if( $provider_icon_markup != $provider_id )
222
			{
223
				echo $provider_icon_markup;
224
			}
225
			else
226
			{
227
?>
228
229
		<a rel="nofollow" href="<?php echo $authenticate_url; ?>" title="<?php echo sprintf( _wsl__("Connect with %s", 'wordpress-social-login'), $provider_name ) ?>" class="wp-social-login-provider wp-social-login-provider-<?php echo strtolower( $provider_id ); ?>" data-provider="<?php echo $provider_id ?>">
230
			<?php if( $social_icon_set == 'none' ){ echo apply_filters( 'wsl_render_auth_widget_alter_provider_name', $provider_name ); } else { ?><img alt="<?php echo $provider_name ?>" title="<?php echo sprintf( _wsl__("Connect with %s", 'wordpress-social-login'), $provider_name ) ?>" src="<?php echo $assets_base_url . strtolower( $provider_id ) . '.png' ?>" /><?php } ?>
231
232
		</a>
233
<?php
234
			}
235
236
			$no_idp_used = false;
237
		}
238
	}
239
240
	// no provider enabled?
241
	if( $no_idp_used )
242
	{
243
?>
244
		<p style="background-color: #FFFFE0;border:1px solid #E6DB55;padding:5px;">
245
			<?php _wsl_e( '<strong>WordPress Social Login is not configured yet</strong>.<br />Please navigate to <strong>Settings &gt; WP Social Login</strong> to configure this plugin.<br />For more information, refer to the <a rel="nofollow" href="http://miled.github.io/wordpress-social-login">online user guide</a>.', 'wordpress-social-login') ?>.
246
		</p>
247
		<style>#wp-social-login-connect-with{display:none;}</style>
248
<?php
249
	}
250
?>
251
252
	</div>
253
254
	<div class="wp-social-login-widget-clearing"></div>
255
256
</div>
257
258
<?php
259
	// provide popup url for hybridauth callback
260
	if( $wsl_settings_use_popup == 1 )
261
	{
262
?>
263
<input type="hidden" id="wsl_popup_base_url" value="<?php echo esc_url( $authenticate_base_url ) ?>" />
264
<input type="hidden" id="wsl_login_form_uri" value="<?php echo esc_url( site_url( 'wp-login.php', 'login_post' ) ); ?>" />
265
266
<?php
267
	}
268
269
	// HOOKABLE: This action runs just after generating the WSL Widget.
270
	do_action( 'wsl_render_auth_widget_end' );
271
?>
272
<!-- wsl_render_auth_widget -->
273
274
<?php
275
	// Display WSL debugging area bellow the widget.
276
	// wsl_display_dev_mode_debugging_area(); // ! keep this line commented unless you know what you are doing :)
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
277
278
	return ob_get_clean();
279
}
280
281
// --------------------------------------------------------------------
282
283
/**
284
* WSL wordpress_social_login action
285
*
286
* Ref: http://codex.wordpress.org/Function_Reference/add_action
287
*/
288
function wsl_action_wordpress_social_login( $args = array() )
289
{
290
	echo wsl_render_auth_widget( $args );
291
}
292
293
add_action( 'wordpress_social_login', 'wsl_action_wordpress_social_login' );
294
295
// --------------------------------------------------------------------
296
297
/**
298
* WSL wordpress_social_login shortcode
299
*
300
* Note:
301
*   WSL shortcode arguments are still experimental and might change in future versions.
302
*
303
* Ref: http://codex.wordpress.org/Function_Reference/add_shortcode
304
*/
305
function wsl_shortcode_wordpress_social_login( $args = array(), $content = null )
306
{
307
	$restrict_content = isset( $args['restrict_content'] ) && $args['restrict_content'] ? true : false;
308
309
	if( 'wp_user_logged_in' == $restrict_content && is_user_logged_in() )
310
	{
311
		return do_shortcode( $content );
312
	}
313
314
	if( 'wsl_user_logged_in' == $restrict_content && wsl_get_stored_hybridauth_user_profiles_by_user_id( get_current_user_id() ) )
315
	{
316
		return do_shortcode( $content );
317
	}
318
319
	return wsl_render_auth_widget( $args );
320
}
321
322
add_shortcode( 'wordpress_social_login', 'wsl_shortcode_wordpress_social_login' );
323
324
// --------------------------------------------------------------------
325
326
/**
327
* WSL wordpress_social_login_meta shortcode
328
*
329
* Note:
330
*   This shortcode is experimental and might change in future versions.
331
*
332
*   [wordpress_social_login_meta
333
*        user_id="215"
334
*        meta="wsl_current_user_image"
335
*        display="html"
336
*        css_class="my_style_is_better"
337
*   ]
338
*/
339
function wsl_shortcode_wordpress_social_login_meta( $args = array() )
340
{
341
	// wordpress user id default to current user connected
342
	$user_id = isset( $args['user_id'] ) && $args['user_id'] ? $args['user_id'] : get_current_user_id();
343
344
	// display default to plain text
345
	$display = isset( $args['display'] ) && $args['display'] ? $args['display'] : 'plain';
346
347
	// when display is set to html, css_class will be used for the main dom el
348
	$css_class = isset( $args['css_class'] ) && $args['css_class'] ? $args['css_class'] : '';
349
350
	// wsl user meta to display
351
	$meta = isset( $args['meta'] ) && $args['meta'] ? $args['meta'] : null;
352
353
	if( ! is_numeric( $user_id ) )
354
	{
355
		return;
356
	}
357
358
	if( ! $meta )
359
	{
360
		return;
361
	}
362
363
	$assets_base_url  = WORDPRESS_SOCIAL_LOGIN_PLUGIN_URL . 'assets/img/16x16/';
364
365
	$assets_base_url  = isset( $args['assets_base_url'] ) && $args['assets_base_url'] ? $args['assets_base_url'] : $assets_base_url;
366
367
	$return = '';
368
369
	if( 'current_avatar' == $meta )
370
	{
371
		if( 'plain' == $display )
372
		{
373
			$return = wsl_get_user_custom_avatar( $user_id );
374
		}
375
		else
376
		{
377
			$return = '<img class="wordpress_social_login_meta_user_avatar ' . $css_class . '" src="' . wsl_get_user_custom_avatar( $user_id ) . '" />';
378
		}
379
	}
380
381
	if( 'current_provider' == $meta )
382
	{
383
		$provider = get_user_meta( $user_id, 'wsl_current_provider', true );
384
385
		if( 'plain' == $display )
386
		{
387
			$return = $provider;
388
		}
389
		else
390
		{
391
			$return = '<img class="wordpress_social_login_meta_user_provider ' . $css_class . '" src="' . $assets_base_url . strtolower( $provider ) . '.png"> ' . $provider;
392
		}
393
	}
394
395
	if( 'user_identities' == $meta )
396
	{
397
		ob_start();
398
399
		$linked_accounts = wsl_get_stored_hybridauth_user_profiles_by_user_id( $user_id );
400
401
		if( $linked_accounts )
402
		{
403
			?><table class="wp-social-login-linked-accounts-list <?php echo $css_class; ?>"><?php
404
405
			foreach( $linked_accounts AS $item )
406
			{
407
				$identity = $item->profileurl;
408
				$photourl = $item->photourl;
409
410
				if( ! $identity )
411
				{
412
					$identity = $item->identifier;
413
				}
414
415
				?><tr><td><?php if( $photourl ) { ?><img  style="vertical-align: top;width:16px;height:16px;" src="<?php echo $photourl ?>"> <?php } else { ?><img src="<?php echo $assets_base_url . strtolower(  $item->provider ) . '.png' ?>" /> <?php } ?><?php echo ucfirst( $item->provider ); ?> </td><td><?php echo $identity; ?></td></tr><?php
416
417
				echo "\n";
418
			}
419
420
			?></table><?php
421
		}
422
423
		$return = ob_get_clean();
424
425
		if( 'plain' == $display )
426
		{
427
			$return = strip_tags( $return );
428
		}
429
	}
430
431
	return $return;
432
}
433
434
add_shortcode( 'wordpress_social_login_meta', 'wsl_shortcode_wordpress_social_login_meta' );
435
436
// --------------------------------------------------------------------
437
438
/**
439
* Display on comment area
440
*/
441
function wsl_render_auth_widget_in_comment_form()
442
{
443
	$wsl_settings_widget_display = get_option( 'wsl_settings_widget_display' );
444
445
	if( comments_open() )
446
	{
447
		if(
448
			!  $wsl_settings_widget_display
449
		||
450
			$wsl_settings_widget_display == 1
451
		||
452
			$wsl_settings_widget_display == 2
453
		)
454
		{
455
			echo wsl_render_auth_widget();
456
		}
457
	}
458
}
459
460
add_action( 'comment_form_top'              , 'wsl_render_auth_widget_in_comment_form' );
461
add_action( 'comment_form_must_log_in_after', 'wsl_render_auth_widget_in_comment_form' );
462
463
// --------------------------------------------------------------------
464
465
/**
466
* Display on login form
467
*/
468
function wsl_render_auth_widget_in_wp_login_form()
469
{
470
	$wsl_settings_widget_display = get_option( 'wsl_settings_widget_display' );
471
472
	if( $wsl_settings_widget_display == 1 || $wsl_settings_widget_display == 3 )
473
	{
474
		echo wsl_render_auth_widget();
475
	}
476
}
477
478
add_action( 'login_form'                      , 'wsl_render_auth_widget_in_wp_login_form' );
479
add_action( 'bp_before_account_details_fields', 'wsl_render_auth_widget_in_wp_login_form' );
480
add_action( 'bp_before_sidebar_login_form'    , 'wsl_render_auth_widget_in_wp_login_form' );
481
482
// --------------------------------------------------------------------
483
484
/**
485
* Display on login & register form
486
*/
487
function wsl_render_auth_widget_in_wp_register_form()
488
{
489
	$wsl_settings_widget_display = get_option( 'wsl_settings_widget_display' );
490
491
	if( $wsl_settings_widget_display == 1 || $wsl_settings_widget_display == 3 )
492
	{
493
		echo wsl_render_auth_widget();
494
	}
495
}
496
497
add_action( 'register_form'    , 'wsl_render_auth_widget_in_wp_register_form' );
498
add_action( 'after_signup_form', 'wsl_render_auth_widget_in_wp_register_form' );
499
500
// --------------------------------------------------------------------
501
502
/**
503
* Enqueue WSL CSS file
504
*/
505
function wsl_add_stylesheets()
506
{
507
	if( ! wp_style_is( 'wsl-widget', 'registered' ) )
508
	{
509
		wp_register_style( "wsl-widget", WORDPRESS_SOCIAL_LOGIN_PLUGIN_URL . "assets/css/style.css" );
510
	}
511
512
	wp_enqueue_style( "wsl-widget" );
513
514
	if( get_option( 'wsl_settings_disable_password_login' ) == 1 )
515
	{
516
	?>
517
		<style type="text/css">
518
			#loginform > p { display: none !important; }
519
		</style>
520
	<?php
521
	}
522
}
523
524
add_action( 'wp_enqueue_scripts'   , 'wsl_add_stylesheets' );
525
add_action( 'login_enqueue_scripts', 'wsl_add_stylesheets' );
526
527
// --------------------------------------------------------------------
528
529
/**
530
* Enqueue WSL Javascript, only if we use popup
531
*/
532
function wsl_add_javascripts()
533
{
534
	$wsl_settings_use_popup = get_option( 'wsl_settings_use_popup' );
535
    
536
    // if a user is visiting using a mobile device, WSL will fall back to more in page
537
	$wsl_settings_use_popup = function_exists( 'wp_is_mobile' ) ? wp_is_mobile() ? 2 : $wsl_settings_use_popup : $wsl_settings_use_popup;
538
	
539
	if( $wsl_settings_use_popup != 1 )
540
	{
541
		return null;
542
	}
543
544
	if( ! wp_script_is( 'wsl-widget', 'registered' ) )
545
	{
546
		wp_register_script( "wsl-widget", WORDPRESS_SOCIAL_LOGIN_PLUGIN_URL . "assets/js/widget.js" );
547
	}
548
549
	wp_enqueue_script( "jquery" );
550
	wp_enqueue_script( "wsl-widget" );
551
}
552
553
add_action( 'wp_enqueue_scripts'   , 'wsl_add_javascripts' );
554
add_action( 'login_enqueue_scripts', 'wsl_add_javascripts' );
555
556
// --------------------------------------------------------------------
557
558
/**
559
* Disallow authentication using the username/email and password form
560
*/
561
562
if( get_option( 'wsl_settings_disable_password_login' ) == 1 )
563
{
564
	// allow account linking
565
	if( ! ( isset( $_REQUEST["bouncer_account_linking"] ) && get_option( 'wsl_settings_bouncer_accounts_linking_enabled' ) == 1 ) )
566
	{
567
		function wsl_disable_password_authentication()
568
		{
569
			return new WP_Error( 'incorrect_password',
570
        _wsl__( '<strong>ERROR</strong>: Signing in with username and password is not allowed. Please use a Social method to login.', 'wordpress-social-login' )
571
      );
572
		}
573
		add_filter( 'wp_authenticate_user', 'wsl_disable_password_authentication' );
574
	}
575
576
	function wsl_disable_lost_password()
577
	{
578
		return false;
579
	}
580
	add_filter( 'allow_password_reset', 'disable_lost_password' );
581
582
	function wsl_remove_lost_password($text)
583
	{
584
		return str_replace( array('Lost your password?', 'Lost your password'), '', trim($text, '?') );
585
	}
586
	add_filter( 'gettext', 'wsl_remove_lost_password' );
587
}
588
589
// --------------------------------------------------------------------
590