Completed
Push — update/jetpack-sso-styles ( f1147c...bd7da8 )
by
unknown
108:12 queued 98:32
created

Jetpack_SSO_Helpers::is_two_step_required()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 12
rs 9.4285
1
<?php
2
3
class Jetpack_SSO_Helpers {
4
	/**
5
	 * Determine if the login form should be hidden or not
6
	 *
7
	 * Method is private only because it is only used in this class so far.
8
	 * Feel free to change it later
9
	 *
10
	 * @return bool
11
	 **/
12
	static function should_hide_login_form() {
13
		/**
14
		 * Remove the default log in form, only leave the WordPress.com log in button.
15
		 *
16
		 * @module sso
17
		 *
18
		 * @since 3.1.0
19
		 *
20
		 * @param bool get_option( 'jetpack_sso_remove_login_form', false ) Should the default log in form be removed. Default to false.
21
		 */
22
		return (bool) apply_filters( 'jetpack_remove_login_form', get_option( 'jetpack_sso_remove_login_form', false ) );
23
	}
24
25
	static function match_by_email() {
26
		$match_by_email = ( 1 == get_option( 'jetpack_sso_match_by_email', true ) ) ? true: false;
27
		$match_by_email = defined( 'WPCC_MATCH_BY_EMAIL' ) ? WPCC_MATCH_BY_EMAIL : $match_by_email;
28
29
		/**
30
		 * Link the local account to an account on WordPress.com using the same email address.
31
		 *
32
		 * @module sso
33
		 *
34
		 * @since 2.6.0
35
		 *
36
		 * @param bool $match_by_email Should we link the local account to an account on WordPress.com using the same email address. Default to false.
37
		 */
38
		return (bool) apply_filters( 'jetpack_sso_match_by_email', $match_by_email );
39
	}
40
41
	static function new_user_override() {
42
		$new_user_override = defined( 'WPCC_NEW_USER_OVERRIDE' ) ? WPCC_NEW_USER_OVERRIDE : false;
43
44
		/**
45
		 * Allow users to register on your site with a WordPress.com account, even though you disallow normal registrations.
46
		 *
47
		 * @module sso
48
		 *
49
		 * @since 2.6.0
50
		 *
51
		 * @param bool $new_user_override Allow users to register on your site with a WordPress.com account. Default to false.
52
		 */
53
		return (bool) apply_filters( 'jetpack_sso_new_user_override', $new_user_override );
54
	}
55
56
	/**
57
	 * Returns a boolean value for whether two-step authentication is required for SSO.
58
	 *
59
	 * @since 4.1.0
60
	 *
61
	 * @return bool
62
	 */
63
	static function is_two_step_required() {
64
		/**
65
		 * Is it required to have 2-step authentication enabled on WordPress.com to use SSO?
66
		 *
67
		 * @module sso
68
		 *
69
		 * @since 2.8.0
70
		 *
71
		 * @param bool get_option( 'jetpack_sso_require_two_step' ) Does SSO require 2-step authentication?
72
		 */
73
		return (bool) apply_filters( 'jetpack_sso_require_two_step', get_option( 'jetpack_sso_require_two_step', false ) );
74
	}
75
76
	static function bypass_login_forward_wpcom() {
77
		/**
78
		 * Redirect the site's log in form to WordPress.com's log in form.
79
		 *
80
		 * @module sso
81
		 *
82
		 * @since 3.1.0
83
		 *
84
		 * @param bool false Should the site's log in form be automatically forwarded to WordPress.com's log in form.
85
		 */
86
		return (bool) apply_filters( 'jetpack_sso_bypass_login_forward_wpcom', false );
87
	}
88
}
89