Completed
Pull Request — master (#378)
by Darren
19:13
created
core/domain/services/validation/email/strategies/InternationalDNS.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -15,43 +15,43 @@
 block discarded – undo
15 15
 class InternationalDNS extends International
16 16
 {
17 17
 
18
-    /**
19
-     * Validates the email in teh same way as the parent, but also
20
-     * verifies the domain exists.
21
-     *
22
-     * @param string $email_address
23
-     * @return bool
24
-     * @throws EmailValidationException
25
-     */
26
-    public function validate($email_address)
27
-    {
28
-        parent::validate($email_address);
29
-        $domain = $this->getDomainPartOfEmail(
30
-            $email_address,
31
-            $this->getAtIndex($email_address)
32
-        );
33
-        if (! checkdnsrr($domain, 'MX')) {
34
-            // domain not found in MX records
35
-            throw new EmailValidationException(
36
-                __(
37
-                // @codingStandardsIgnoreStart
38
-                    'Although the email address provided is formatted correctly, a valid "MX record" could not be located for that address and domain. Please enter a valid email address.',
39
-                    // @codingStandardsIgnoreEnd
40
-                    'event_espresso'
41
-                )
42
-            );
43
-        }
44
-        if (! checkdnsrr($domain, 'A')) {
45
-            // domain not found in A records
46
-            throw new EmailValidationException(
47
-                __(
48
-                // @codingStandardsIgnoreStart
49
-                    'Although the email address provided is formatted correctly, a valid "A record" could not be located for that address and domain. Please enter a valid email address.',
50
-                    // @codingStandardsIgnoreEnd
51
-                    'event_espresso'
52
-                )
53
-            );
54
-        }
55
-        return true;
56
-    }
18
+	/**
19
+	 * Validates the email in teh same way as the parent, but also
20
+	 * verifies the domain exists.
21
+	 *
22
+	 * @param string $email_address
23
+	 * @return bool
24
+	 * @throws EmailValidationException
25
+	 */
26
+	public function validate($email_address)
27
+	{
28
+		parent::validate($email_address);
29
+		$domain = $this->getDomainPartOfEmail(
30
+			$email_address,
31
+			$this->getAtIndex($email_address)
32
+		);
33
+		if (! checkdnsrr($domain, 'MX')) {
34
+			// domain not found in MX records
35
+			throw new EmailValidationException(
36
+				__(
37
+				// @codingStandardsIgnoreStart
38
+					'Although the email address provided is formatted correctly, a valid "MX record" could not be located for that address and domain. Please enter a valid email address.',
39
+					// @codingStandardsIgnoreEnd
40
+					'event_espresso'
41
+				)
42
+			);
43
+		}
44
+		if (! checkdnsrr($domain, 'A')) {
45
+			// domain not found in A records
46
+			throw new EmailValidationException(
47
+				__(
48
+				// @codingStandardsIgnoreStart
49
+					'Although the email address provided is formatted correctly, a valid "A record" could not be located for that address and domain. Please enter a valid email address.',
50
+					// @codingStandardsIgnoreEnd
51
+					'event_espresso'
52
+				)
53
+			);
54
+		}
55
+		return true;
56
+	}
57 57
 }
Please login to merge, or discard this patch.
core/domain/services/validation/email/strategies/Basic.php 1 patch
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -15,112 +15,112 @@
 block discarded – undo
15 15
 class Basic implements EmailValidatorInterface
16 16
 {
17 17
 
18
-    /**
19
-     * @param string $email_address
20
-     * @return bool
21
-     * @throws EmailValidationException
22
-     */
23
-    public function validate($email_address)
24
-    {
25
-        if (! preg_match('/^.+\@\S+$/', $email_address)) {
26
-            // email not in correct {string}@{string} format
27
-            throw new EmailValidationException(
28
-                esc_html__('Email does not have the required @ sign.', 'event_espresso')
29
-            );
30
-        }
31
-        $atIndex = $this->getAtIndex($email_address);
32
-        $local = $this->getLocalPartOfEmail($email_address, $atIndex);
33
-        $localLen = strlen($local);
34
-        if ($localLen < 1) {
35
-            // no local part
36
-            throw new EmailValidationException(
37
-                esc_html__('Email local-part (before the @) is required.', 'event_espresso')
38
-            );
39
-        }
40
-        if ($localLen > 64) {
41
-            // local part length exceeded
42
-            throw new EmailValidationException(
43
-                esc_html__('Email local-part (before the @) is too long.', 'event_espresso')
44
-            );
45
-        }
46
-        if ($local[0] === '.') {
47
-            // local part starts with '.'
48
-            throw new EmailValidationException(
49
-                esc_html__('Email local-part (before the @) must not begin with a period.', 'event_espresso')
50
-            );
51
-        }
52
-        if ($local[$localLen - 1] === '.') {
53
-            // local part starts or ends with '.'
54
-            throw new EmailValidationException(
55
-                esc_html__('Email local-part (before the @) must not end with a period.', 'event_espresso')
56
-            );
57
-        }
58
-        if (preg_match('/\\.\\./', $local)) {
59
-            // local part has two consecutive dots
60
-            throw new EmailValidationException(
61
-                esc_html__(
62
-                    'Email local-part (before the @) must not have two consecutive periods.',
63
-                    'event_espresso'
64
-                )
65
-            );
66
-        }
67
-        $domain = $this->getDomainPartOfEmail($email_address, $atIndex);
68
-        $domainLen = strlen($domain);
69
-        if ($domainLen < 1) {
70
-            throw new EmailValidationException(
71
-                esc_html__('Email domain (after the @) is required.', 'event_espresso')
72
-            );
73
-        }
74
-        if ($domainLen > 255) {
75
-            // domain part length exceeded
76
-            throw new EmailValidationException(
77
-                esc_html__('Email domain (after the @) is too long.', 'event_espresso')
78
-            );
79
-        }
80
-        if (preg_match('/\\.\\./', $domain)) {
81
-            // domain part has two consecutive dots
82
-            throw new EmailValidationException(
83
-                esc_html__('Email domain (after the @) must not have two consecutive periods.', 'event_espresso')
84
-            );
85
-        }
86
-        return true;
87
-    }
18
+	/**
19
+	 * @param string $email_address
20
+	 * @return bool
21
+	 * @throws EmailValidationException
22
+	 */
23
+	public function validate($email_address)
24
+	{
25
+		if (! preg_match('/^.+\@\S+$/', $email_address)) {
26
+			// email not in correct {string}@{string} format
27
+			throw new EmailValidationException(
28
+				esc_html__('Email does not have the required @ sign.', 'event_espresso')
29
+			);
30
+		}
31
+		$atIndex = $this->getAtIndex($email_address);
32
+		$local = $this->getLocalPartOfEmail($email_address, $atIndex);
33
+		$localLen = strlen($local);
34
+		if ($localLen < 1) {
35
+			// no local part
36
+			throw new EmailValidationException(
37
+				esc_html__('Email local-part (before the @) is required.', 'event_espresso')
38
+			);
39
+		}
40
+		if ($localLen > 64) {
41
+			// local part length exceeded
42
+			throw new EmailValidationException(
43
+				esc_html__('Email local-part (before the @) is too long.', 'event_espresso')
44
+			);
45
+		}
46
+		if ($local[0] === '.') {
47
+			// local part starts with '.'
48
+			throw new EmailValidationException(
49
+				esc_html__('Email local-part (before the @) must not begin with a period.', 'event_espresso')
50
+			);
51
+		}
52
+		if ($local[$localLen - 1] === '.') {
53
+			// local part starts or ends with '.'
54
+			throw new EmailValidationException(
55
+				esc_html__('Email local-part (before the @) must not end with a period.', 'event_espresso')
56
+			);
57
+		}
58
+		if (preg_match('/\\.\\./', $local)) {
59
+			// local part has two consecutive dots
60
+			throw new EmailValidationException(
61
+				esc_html__(
62
+					'Email local-part (before the @) must not have two consecutive periods.',
63
+					'event_espresso'
64
+				)
65
+			);
66
+		}
67
+		$domain = $this->getDomainPartOfEmail($email_address, $atIndex);
68
+		$domainLen = strlen($domain);
69
+		if ($domainLen < 1) {
70
+			throw new EmailValidationException(
71
+				esc_html__('Email domain (after the @) is required.', 'event_espresso')
72
+			);
73
+		}
74
+		if ($domainLen > 255) {
75
+			// domain part length exceeded
76
+			throw new EmailValidationException(
77
+				esc_html__('Email domain (after the @) is too long.', 'event_espresso')
78
+			);
79
+		}
80
+		if (preg_match('/\\.\\./', $domain)) {
81
+			// domain part has two consecutive dots
82
+			throw new EmailValidationException(
83
+				esc_html__('Email domain (after the @) must not have two consecutive periods.', 'event_espresso')
84
+			);
85
+		}
86
+		return true;
87
+	}
88 88
 
89 89
 
90
-    /**
91
-     * returns the location of the @ symbol
92
-     *
93
-     * @param string $email_address
94
-     * @return bool|string
95
-     */
96
-    protected function getAtIndex($email_address)
97
-    {
98
-        return strrpos($email_address, '@');
99
-    }
90
+	/**
91
+	 * returns the location of the @ symbol
92
+	 *
93
+	 * @param string $email_address
94
+	 * @return bool|string
95
+	 */
96
+	protected function getAtIndex($email_address)
97
+	{
98
+		return strrpos($email_address, '@');
99
+	}
100 100
 
101 101
 
102
-    /**
103
-     * Gets the local part of the email
104
-     *
105
-     * @param string   $email_address
106
-     * @param bool|int $atIndex
107
-     * @return bool|string
108
-     */
109
-    protected function getLocalPartOfEmail($email_address, $atIndex)
110
-    {
111
-        return substr($email_address, 0, $atIndex);
112
-    }
102
+	/**
103
+	 * Gets the local part of the email
104
+	 *
105
+	 * @param string   $email_address
106
+	 * @param bool|int $atIndex
107
+	 * @return bool|string
108
+	 */
109
+	protected function getLocalPartOfEmail($email_address, $atIndex)
110
+	{
111
+		return substr($email_address, 0, $atIndex);
112
+	}
113 113
 
114 114
 
115
-    /**
116
-     * Gets the domain part of the email
117
-     *
118
-     * @param string   $email_address
119
-     * @param bool|int $atIndex
120
-     * @return bool|string
121
-     */
122
-    protected function getDomainPartOfEmail($email_address, $atIndex)
123
-    {
124
-        return substr($email_address, $atIndex + 1);
125
-    }
115
+	/**
116
+	 * Gets the domain part of the email
117
+	 *
118
+	 * @param string   $email_address
119
+	 * @param bool|int $atIndex
120
+	 * @return bool|string
121
+	 */
122
+	protected function getDomainPartOfEmail($email_address, $atIndex)
123
+	{
124
+		return substr($email_address, $atIndex + 1);
125
+	}
126 126
 }
Please login to merge, or discard this patch.
core/domain/services/validation/email/strategies/International.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -15,26 +15,26 @@
 block discarded – undo
15 15
 class International extends Basic
16 16
 {
17 17
 
18
-    /**
19
-     * @param string $email_address
20
-     * @return bool
21
-     * @throws \EventEspresso\core\domain\services\validation\email\EmailValidationException
22
-     */
23
-    public function validate($email_address)
24
-    {
25
-        parent::validate($email_address);
26
-        if (// plz see http://stackoverflow.com/a/24817336 re: the following regex
27
-        ! preg_match(
28
-        // @codingStandardsIgnoreStart
29
-            '/^(?!\.)((?!.*\.{2})[a-zA-Z0-9\x{0080}-\x{00FF}\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0250}-\x{02AF}\x{0300}-\x{036F}\x{0370}-\x{03FF}\x{0400}-\x{04FF}\x{0500}-\x{052F}\x{0530}-\x{058F}\x{0590}-\x{05FF}\x{0600}-\x{06FF}\x{0700}-\x{074F}\x{0750}-\x{077F}\x{0780}-\x{07BF}\x{07C0}-\x{07FF}\x{0900}-\x{097F}\x{0980}-\x{09FF}\x{0A00}-\x{0A7F}\x{0A80}-\x{0AFF}\x{0B00}-\x{0B7F}\x{0B80}-\x{0BFF}\x{0C00}-\x{0C7F}\x{0C80}-\x{0CFF}\x{0D00}-\x{0D7F}\x{0D80}-\x{0DFF}\x{0E00}-\x{0E7F}\x{0E80}-\x{0EFF}\x{0F00}-\x{0FFF}\x{1000}-\x{109F}\x{10A0}-\x{10FF}\x{1100}-\x{11FF}\x{1200}-\x{137F}\x{1380}-\x{139F}\x{13A0}-\x{13FF}\x{1400}-\x{167F}\x{1680}-\x{169F}\x{16A0}-\x{16FF}\x{1700}-\x{171F}\x{1720}-\x{173F}\x{1740}-\x{175F}\x{1760}-\x{177F}\x{1780}-\x{17FF}\x{1800}-\x{18AF}\x{1900}-\x{194F}\x{1950}-\x{197F}\x{1980}-\x{19DF}\x{19E0}-\x{19FF}\x{1A00}-\x{1A1F}\x{1B00}-\x{1B7F}\x{1D00}-\x{1D7F}\x{1D80}-\x{1DBF}\x{1DC0}-\x{1DFF}\x{1E00}-\x{1EFF}\x{1F00}-\x{1FFF}\x{20D0}-\x{20FF}\x{2100}-\x{214F}\x{2C00}-\x{2C5F}\x{2C60}-\x{2C7F}\x{2C80}-\x{2CFF}\x{2D00}-\x{2D2F}\x{2D30}-\x{2D7F}\x{2D80}-\x{2DDF}\x{2F00}-\x{2FDF}\x{2FF0}-\x{2FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{3100}-\x{312F}\x{3130}-\x{318F}\x{3190}-\x{319F}\x{31C0}-\x{31EF}\x{31F0}-\x{31FF}\x{3200}-\x{32FF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4DC0}-\x{4DFF}\x{4E00}-\x{9FFF}\x{A000}-\x{A48F}\x{A490}-\x{A4CF}\x{A700}-\x{A71F}\x{A800}-\x{A82F}\x{A840}-\x{A87F}\x{AC00}-\x{D7AF}\x{F900}-\x{FAFF}\.!#$%&\'*+-\/=?^_`{|}~\-\d]+)@(?!\.)([a-zA-Z0-9\x{0080}-\x{00FF}\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0250}-\x{02AF}\x{0300}-\x{036F}\x{0370}-\x{03FF}\x{0400}-\x{04FF}\x{0500}-\x{052F}\x{0530}-\x{058F}\x{0590}-\x{05FF}\x{0600}-\x{06FF}\x{0700}-\x{074F}\x{0750}-\x{077F}\x{0780}-\x{07BF}\x{07C0}-\x{07FF}\x{0900}-\x{097F}\x{0980}-\x{09FF}\x{0A00}-\x{0A7F}\x{0A80}-\x{0AFF}\x{0B00}-\x{0B7F}\x{0B80}-\x{0BFF}\x{0C00}-\x{0C7F}\x{0C80}-\x{0CFF}\x{0D00}-\x{0D7F}\x{0D80}-\x{0DFF}\x{0E00}-\x{0E7F}\x{0E80}-\x{0EFF}\x{0F00}-\x{0FFF}\x{1000}-\x{109F}\x{10A0}-\x{10FF}\x{1100}-\x{11FF}\x{1200}-\x{137F}\x{1380}-\x{139F}\x{13A0}-\x{13FF}\x{1400}-\x{167F}\x{1680}-\x{169F}\x{16A0}-\x{16FF}\x{1700}-\x{171F}\x{1720}-\x{173F}\x{1740}-\x{175F}\x{1760}-\x{177F}\x{1780}-\x{17FF}\x{1800}-\x{18AF}\x{1900}-\x{194F}\x{1950}-\x{197F}\x{1980}-\x{19DF}\x{19E0}-\x{19FF}\x{1A00}-\x{1A1F}\x{1B00}-\x{1B7F}\x{1D00}-\x{1D7F}\x{1D80}-\x{1DBF}\x{1DC0}-\x{1DFF}\x{1E00}-\x{1EFF}\x{1F00}-\x{1FFF}\x{20D0}-\x{20FF}\x{2100}-\x{214F}\x{2C00}-\x{2C5F}\x{2C60}-\x{2C7F}\x{2C80}-\x{2CFF}\x{2D00}-\x{2D2F}\x{2D30}-\x{2D7F}\x{2D80}-\x{2DDF}\x{2F00}-\x{2FDF}\x{2FF0}-\x{2FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{3100}-\x{312F}\x{3130}-\x{318F}\x{3190}-\x{319F}\x{31C0}-\x{31EF}\x{31F0}-\x{31FF}\x{3200}-\x{32FF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4DC0}-\x{4DFF}\x{4E00}-\x{9FFF}\x{A000}-\x{A48F}\x{A490}-\x{A4CF}\x{A700}-\x{A71F}\x{A800}-\x{A82F}\x{A840}-\x{A87F}\x{AC00}-\x{D7AF}\x{F900}-\x{FAFF}\-\.\d]+)((\.([a-zA-Z\x{0080}-\x{00FF}\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0250}-\x{02AF}\x{0300}-\x{036F}\x{0370}-\x{03FF}\x{0400}-\x{04FF}\x{0500}-\x{052F}\x{0530}-\x{058F}\x{0590}-\x{05FF}\x{0600}-\x{06FF}\x{0700}-\x{074F}\x{0750}-\x{077F}\x{0780}-\x{07BF}\x{07C0}-\x{07FF}\x{0900}-\x{097F}\x{0980}-\x{09FF}\x{0A00}-\x{0A7F}\x{0A80}-\x{0AFF}\x{0B00}-\x{0B7F}\x{0B80}-\x{0BFF}\x{0C00}-\x{0C7F}\x{0C80}-\x{0CFF}\x{0D00}-\x{0D7F}\x{0D80}-\x{0DFF}\x{0E00}-\x{0E7F}\x{0E80}-\x{0EFF}\x{0F00}-\x{0FFF}\x{1000}-\x{109F}\x{10A0}-\x{10FF}\x{1100}-\x{11FF}\x{1200}-\x{137F}\x{1380}-\x{139F}\x{13A0}-\x{13FF}\x{1400}-\x{167F}\x{1680}-\x{169F}\x{16A0}-\x{16FF}\x{1700}-\x{171F}\x{1720}-\x{173F}\x{1740}-\x{175F}\x{1760}-\x{177F}\x{1780}-\x{17FF}\x{1800}-\x{18AF}\x{1900}-\x{194F}\x{1950}-\x{197F}\x{1980}-\x{19DF}\x{19E0}-\x{19FF}\x{1A00}-\x{1A1F}\x{1B00}-\x{1B7F}\x{1D00}-\x{1D7F}\x{1D80}-\x{1DBF}\x{1DC0}-\x{1DFF}\x{1E00}-\x{1EFF}\x{1F00}-\x{1FFF}\x{20D0}-\x{20FF}\x{2100}-\x{214F}\x{2C00}-\x{2C5F}\x{2C60}-\x{2C7F}\x{2C80}-\x{2CFF}\x{2D00}-\x{2D2F}\x{2D30}-\x{2D7F}\x{2D80}-\x{2DDF}\x{2F00}-\x{2FDF}\x{2FF0}-\x{2FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{3100}-\x{312F}\x{3130}-\x{318F}\x{3190}-\x{319F}\x{31C0}-\x{31EF}\x{31F0}-\x{31FF}\x{3200}-\x{32FF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4DC0}-\x{4DFF}\x{4E00}-\x{9FFF}\x{A000}-\x{A48F}\x{A490}-\x{A4CF}\x{A700}-\x{A71F}\x{A800}-\x{A82F}\x{A840}-\x{A87F}\x{AC00}-\x{D7AF}\x{F900}-\x{FAFF}]){2,63})+)$/u',
30
-            // @codingStandardsIgnoreEnd
31
-            $email_address
32
-        )
33
-        ) {
34
-            throw new EmailValidationException(
35
-                esc_html__('Email address is invalid.', 'event_espresso')
36
-            );
37
-        }
38
-        return true;
39
-    }
18
+	/**
19
+	 * @param string $email_address
20
+	 * @return bool
21
+	 * @throws \EventEspresso\core\domain\services\validation\email\EmailValidationException
22
+	 */
23
+	public function validate($email_address)
24
+	{
25
+		parent::validate($email_address);
26
+		if (// plz see http://stackoverflow.com/a/24817336 re: the following regex
27
+		! preg_match(
28
+		// @codingStandardsIgnoreStart
29
+			'/^(?!\.)((?!.*\.{2})[a-zA-Z0-9\x{0080}-\x{00FF}\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0250}-\x{02AF}\x{0300}-\x{036F}\x{0370}-\x{03FF}\x{0400}-\x{04FF}\x{0500}-\x{052F}\x{0530}-\x{058F}\x{0590}-\x{05FF}\x{0600}-\x{06FF}\x{0700}-\x{074F}\x{0750}-\x{077F}\x{0780}-\x{07BF}\x{07C0}-\x{07FF}\x{0900}-\x{097F}\x{0980}-\x{09FF}\x{0A00}-\x{0A7F}\x{0A80}-\x{0AFF}\x{0B00}-\x{0B7F}\x{0B80}-\x{0BFF}\x{0C00}-\x{0C7F}\x{0C80}-\x{0CFF}\x{0D00}-\x{0D7F}\x{0D80}-\x{0DFF}\x{0E00}-\x{0E7F}\x{0E80}-\x{0EFF}\x{0F00}-\x{0FFF}\x{1000}-\x{109F}\x{10A0}-\x{10FF}\x{1100}-\x{11FF}\x{1200}-\x{137F}\x{1380}-\x{139F}\x{13A0}-\x{13FF}\x{1400}-\x{167F}\x{1680}-\x{169F}\x{16A0}-\x{16FF}\x{1700}-\x{171F}\x{1720}-\x{173F}\x{1740}-\x{175F}\x{1760}-\x{177F}\x{1780}-\x{17FF}\x{1800}-\x{18AF}\x{1900}-\x{194F}\x{1950}-\x{197F}\x{1980}-\x{19DF}\x{19E0}-\x{19FF}\x{1A00}-\x{1A1F}\x{1B00}-\x{1B7F}\x{1D00}-\x{1D7F}\x{1D80}-\x{1DBF}\x{1DC0}-\x{1DFF}\x{1E00}-\x{1EFF}\x{1F00}-\x{1FFF}\x{20D0}-\x{20FF}\x{2100}-\x{214F}\x{2C00}-\x{2C5F}\x{2C60}-\x{2C7F}\x{2C80}-\x{2CFF}\x{2D00}-\x{2D2F}\x{2D30}-\x{2D7F}\x{2D80}-\x{2DDF}\x{2F00}-\x{2FDF}\x{2FF0}-\x{2FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{3100}-\x{312F}\x{3130}-\x{318F}\x{3190}-\x{319F}\x{31C0}-\x{31EF}\x{31F0}-\x{31FF}\x{3200}-\x{32FF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4DC0}-\x{4DFF}\x{4E00}-\x{9FFF}\x{A000}-\x{A48F}\x{A490}-\x{A4CF}\x{A700}-\x{A71F}\x{A800}-\x{A82F}\x{A840}-\x{A87F}\x{AC00}-\x{D7AF}\x{F900}-\x{FAFF}\.!#$%&\'*+-\/=?^_`{|}~\-\d]+)@(?!\.)([a-zA-Z0-9\x{0080}-\x{00FF}\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0250}-\x{02AF}\x{0300}-\x{036F}\x{0370}-\x{03FF}\x{0400}-\x{04FF}\x{0500}-\x{052F}\x{0530}-\x{058F}\x{0590}-\x{05FF}\x{0600}-\x{06FF}\x{0700}-\x{074F}\x{0750}-\x{077F}\x{0780}-\x{07BF}\x{07C0}-\x{07FF}\x{0900}-\x{097F}\x{0980}-\x{09FF}\x{0A00}-\x{0A7F}\x{0A80}-\x{0AFF}\x{0B00}-\x{0B7F}\x{0B80}-\x{0BFF}\x{0C00}-\x{0C7F}\x{0C80}-\x{0CFF}\x{0D00}-\x{0D7F}\x{0D80}-\x{0DFF}\x{0E00}-\x{0E7F}\x{0E80}-\x{0EFF}\x{0F00}-\x{0FFF}\x{1000}-\x{109F}\x{10A0}-\x{10FF}\x{1100}-\x{11FF}\x{1200}-\x{137F}\x{1380}-\x{139F}\x{13A0}-\x{13FF}\x{1400}-\x{167F}\x{1680}-\x{169F}\x{16A0}-\x{16FF}\x{1700}-\x{171F}\x{1720}-\x{173F}\x{1740}-\x{175F}\x{1760}-\x{177F}\x{1780}-\x{17FF}\x{1800}-\x{18AF}\x{1900}-\x{194F}\x{1950}-\x{197F}\x{1980}-\x{19DF}\x{19E0}-\x{19FF}\x{1A00}-\x{1A1F}\x{1B00}-\x{1B7F}\x{1D00}-\x{1D7F}\x{1D80}-\x{1DBF}\x{1DC0}-\x{1DFF}\x{1E00}-\x{1EFF}\x{1F00}-\x{1FFF}\x{20D0}-\x{20FF}\x{2100}-\x{214F}\x{2C00}-\x{2C5F}\x{2C60}-\x{2C7F}\x{2C80}-\x{2CFF}\x{2D00}-\x{2D2F}\x{2D30}-\x{2D7F}\x{2D80}-\x{2DDF}\x{2F00}-\x{2FDF}\x{2FF0}-\x{2FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{3100}-\x{312F}\x{3130}-\x{318F}\x{3190}-\x{319F}\x{31C0}-\x{31EF}\x{31F0}-\x{31FF}\x{3200}-\x{32FF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4DC0}-\x{4DFF}\x{4E00}-\x{9FFF}\x{A000}-\x{A48F}\x{A490}-\x{A4CF}\x{A700}-\x{A71F}\x{A800}-\x{A82F}\x{A840}-\x{A87F}\x{AC00}-\x{D7AF}\x{F900}-\x{FAFF}\-\.\d]+)((\.([a-zA-Z\x{0080}-\x{00FF}\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0250}-\x{02AF}\x{0300}-\x{036F}\x{0370}-\x{03FF}\x{0400}-\x{04FF}\x{0500}-\x{052F}\x{0530}-\x{058F}\x{0590}-\x{05FF}\x{0600}-\x{06FF}\x{0700}-\x{074F}\x{0750}-\x{077F}\x{0780}-\x{07BF}\x{07C0}-\x{07FF}\x{0900}-\x{097F}\x{0980}-\x{09FF}\x{0A00}-\x{0A7F}\x{0A80}-\x{0AFF}\x{0B00}-\x{0B7F}\x{0B80}-\x{0BFF}\x{0C00}-\x{0C7F}\x{0C80}-\x{0CFF}\x{0D00}-\x{0D7F}\x{0D80}-\x{0DFF}\x{0E00}-\x{0E7F}\x{0E80}-\x{0EFF}\x{0F00}-\x{0FFF}\x{1000}-\x{109F}\x{10A0}-\x{10FF}\x{1100}-\x{11FF}\x{1200}-\x{137F}\x{1380}-\x{139F}\x{13A0}-\x{13FF}\x{1400}-\x{167F}\x{1680}-\x{169F}\x{16A0}-\x{16FF}\x{1700}-\x{171F}\x{1720}-\x{173F}\x{1740}-\x{175F}\x{1760}-\x{177F}\x{1780}-\x{17FF}\x{1800}-\x{18AF}\x{1900}-\x{194F}\x{1950}-\x{197F}\x{1980}-\x{19DF}\x{19E0}-\x{19FF}\x{1A00}-\x{1A1F}\x{1B00}-\x{1B7F}\x{1D00}-\x{1D7F}\x{1D80}-\x{1DBF}\x{1DC0}-\x{1DFF}\x{1E00}-\x{1EFF}\x{1F00}-\x{1FFF}\x{20D0}-\x{20FF}\x{2100}-\x{214F}\x{2C00}-\x{2C5F}\x{2C60}-\x{2C7F}\x{2C80}-\x{2CFF}\x{2D00}-\x{2D2F}\x{2D30}-\x{2D7F}\x{2D80}-\x{2DDF}\x{2F00}-\x{2FDF}\x{2FF0}-\x{2FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{3100}-\x{312F}\x{3130}-\x{318F}\x{3190}-\x{319F}\x{31C0}-\x{31EF}\x{31F0}-\x{31FF}\x{3200}-\x{32FF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4DC0}-\x{4DFF}\x{4E00}-\x{9FFF}\x{A000}-\x{A48F}\x{A490}-\x{A4CF}\x{A700}-\x{A71F}\x{A800}-\x{A82F}\x{A840}-\x{A87F}\x{AC00}-\x{D7AF}\x{F900}-\x{FAFF}]){2,63})+)$/u',
30
+			// @codingStandardsIgnoreEnd
31
+			$email_address
32
+		)
33
+		) {
34
+			throw new EmailValidationException(
35
+				esc_html__('Email address is invalid.', 'event_espresso')
36
+			);
37
+		}
38
+		return true;
39
+	}
40 40
 }
Please login to merge, or discard this patch.
core/domain/services/validation/email/EmailValidationService.php 1 patch
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -16,65 +16,65 @@
 block discarded – undo
16 16
 class EmailValidationService implements EmailValidatorInterface
17 17
 {
18 18
 
19
-    /**
20
-     * @var EE_Registration_Config $registration_config
21
-     */
22
-    protected $registration_config;
19
+	/**
20
+	 * @var EE_Registration_Config $registration_config
21
+	 */
22
+	protected $registration_config;
23 23
 
24
-    /**
25
-     * @var Loader $loader
26
-     */
27
-    protected $loader;
24
+	/**
25
+	 * @var Loader $loader
26
+	 */
27
+	protected $loader;
28 28
 
29 29
 
30
-    /**
31
-     * EmailValidationService constructor.
32
-     * Accepts an \EE_Config as an argument.
33
-     *
34
-     * @param EE_Registration_Config $config
35
-     * @param Loader                 $loader
36
-     */
37
-    public function __construct(EE_Registration_Config $config, Loader $loader)
38
-    {
39
-        $this->registration_config = $config;
40
-        $this->loader = $loader;
41
-    }
30
+	/**
31
+	 * EmailValidationService constructor.
32
+	 * Accepts an \EE_Config as an argument.
33
+	 *
34
+	 * @param EE_Registration_Config $config
35
+	 * @param Loader                 $loader
36
+	 */
37
+	public function __construct(EE_Registration_Config $config, Loader $loader)
38
+	{
39
+		$this->registration_config = $config;
40
+		$this->loader = $loader;
41
+	}
42 42
 
43 43
 
44
-    /**
45
-     * Validates the email address. If it's invalid, an EmailValidationException
46
-     * is thrown that describes why its invalid.
47
-     *
48
-     * @param string $email_address
49
-     * @return boolean
50
-     * @throws EmailValidationException
51
-     */
52
-    public function validate($email_address)
53
-    {
54
-        // pick the correct validator according to the config
55
-        switch ($this->registration_config->email_validation_level) {
56
-            case 'basic':
57
-                $validator = $this->loader->getShared(
58
-                    'EventEspresso\core\domain\services\validation\email\strategies\Basic'
59
-                );
60
-                break;
61
-            case 'i18n':
62
-                $validator = $this->loader->getShared(
63
-                    'EventEspresso\core\domain\services\validation\email\strategies\International'
64
-                );
65
-                break;
66
-            case 'i18n_dns':
67
-                $validator = $this->loader->getShared(
68
-                    'EventEspresso\core\domain\services\validation\email\strategies\InternationalDNS'
69
-                );
70
-                break;
71
-            case 'wp_default':
72
-            default:
73
-                $validator = $this->loader->getShared(
74
-                    'EventEspresso\core\domain\services\validation\email\strategies\WordPress'
75
-                );
76
-                break;
77
-        }
78
-        return $validator->validate($email_address);
79
-    }
44
+	/**
45
+	 * Validates the email address. If it's invalid, an EmailValidationException
46
+	 * is thrown that describes why its invalid.
47
+	 *
48
+	 * @param string $email_address
49
+	 * @return boolean
50
+	 * @throws EmailValidationException
51
+	 */
52
+	public function validate($email_address)
53
+	{
54
+		// pick the correct validator according to the config
55
+		switch ($this->registration_config->email_validation_level) {
56
+			case 'basic':
57
+				$validator = $this->loader->getShared(
58
+					'EventEspresso\core\domain\services\validation\email\strategies\Basic'
59
+				);
60
+				break;
61
+			case 'i18n':
62
+				$validator = $this->loader->getShared(
63
+					'EventEspresso\core\domain\services\validation\email\strategies\International'
64
+				);
65
+				break;
66
+			case 'i18n_dns':
67
+				$validator = $this->loader->getShared(
68
+					'EventEspresso\core\domain\services\validation\email\strategies\InternationalDNS'
69
+				);
70
+				break;
71
+			case 'wp_default':
72
+			default:
73
+				$validator = $this->loader->getShared(
74
+					'EventEspresso\core\domain\services\validation\email\strategies\WordPress'
75
+				);
76
+				break;
77
+		}
78
+		return $validator->validate($email_address);
79
+	}
80 80
 }
Please login to merge, or discard this patch.
core/domain/services/contexts/RequestTypeContextChecker.php 1 patch
Indentation   +180 added lines, -180 removed lines patch added patch discarded remove patch
@@ -16,184 +16,184 @@
 block discarded – undo
16 16
 class RequestTypeContextChecker extends ContextChecker implements RequestTypeContextCheckerInterface
17 17
 {
18 18
 
19
-    /**
20
-     * @var RequestTypeContext $request_type
21
-     */
22
-    private $request_type;
23
-
24
-
25
-    /**
26
-     * RequestTypeContextChecker constructor.
27
-     *
28
-     * @param RequestTypeContext $request_type
29
-     */
30
-    public function __construct(RequestTypeContext $request_type)
31
-    {
32
-        $this->request_type = $request_type;
33
-        parent::__construct(
34
-            'RequestTypeContextChecker',
35
-            $this->request_type->validRequestTypes()
36
-        );
37
-    }
38
-
39
-
40
-    /**
41
-     * true if the current request involves some form of activation
42
-     *
43
-     * @return bool
44
-     */
45
-    public function isActivation()
46
-    {
47
-        return $this->request_type->isActivation();
48
-    }
49
-
50
-
51
-    /**
52
-     * @param $is_activation
53
-     * @return bool
54
-     */
55
-    public function setIsActivation($is_activation)
56
-    {
57
-        return $this->request_type->setIsActivation($is_activation);
58
-    }
59
-
60
-
61
-    /**
62
-     * true if the current request is for the admin and is not being made via AJAX
63
-     *
64
-     * @return bool
65
-     */
66
-    public function isAdmin()
67
-    {
68
-        return $this->request_type->slug() === RequestTypeContext::ADMIN;
69
-    }
70
-
71
-
72
-    /**
73
-     * true if the current request is for the admin AND is being made via AJAX
74
-     *
75
-     * @return bool
76
-     */
77
-    public function isAdminAjax()
78
-    {
79
-        return $this->request_type->slug() === RequestTypeContext::AJAX_ADMIN;
80
-    }
81
-
82
-
83
-    /**
84
-     * true if the current request is being made via AJAX... any AJAX
85
-     *
86
-     * @return bool
87
-     */
88
-    public function isAjax()
89
-    {
90
-        return $this->isEeAjax() || $this->isOtherAjax();
91
-    }
92
-
93
-
94
-    /**
95
-     * true if the current request is for either the EE admin or EE frontend AND is being made via AJAX
96
-     *
97
-     * @return bool
98
-     */
99
-    public function isEeAjax()
100
-    {
101
-        return $this->isAdminAjax() || $this->isFrontAjax();
102
-    }
103
-
104
-
105
-    /**
106
-     * true if the current request is being made via AJAX but is NOT for EE related logic
107
-     *
108
-     * @return bool
109
-     */
110
-    public function isOtherAjax()
111
-    {
112
-        return $this->request_type->slug() === RequestTypeContext::AJAX_OTHER;
113
-    }
114
-
115
-    /**
116
-     * true if the current request is for the EE REST API
117
-     *
118
-     * @return bool
119
-     */
120
-    public function isApi()
121
-    {
122
-        return $this->request_type->slug() === RequestTypeContext::API;
123
-    }
124
-
125
-
126
-    /**
127
-     * true if the current request is from the command line
128
-     *
129
-     * @return bool
130
-     */
131
-    public function isCli()
132
-    {
133
-        return $this->request_type->slug() === RequestTypeContext::CLI;
134
-    }
135
-
136
-
137
-    /**
138
-     * true if the current request is for a WP_Cron
139
-     *
140
-     * @return bool
141
-     */
142
-    public function isCron()
143
-    {
144
-        return $this->request_type->slug() === RequestTypeContext::CRON;
145
-    }
146
-
147
-
148
-    /**
149
-     * true if the current request is for a feed (ie: RSS)
150
-     *
151
-     * @return bool
152
-     */
153
-    public function isFeed()
154
-    {
155
-        return $this->request_type->slug() === RequestTypeContext::FEED;
156
-    }
157
-
158
-
159
-    /**
160
-     * true if the current request is for the frontend and is not being made via AJAX
161
-     *
162
-     * @return bool
163
-     */
164
-    public function isFrontend()
165
-    {
166
-        return $this->request_type->slug() === RequestTypeContext::FRONTEND;
167
-    }
168
-
169
-
170
-    /**
171
-     * true if the current request is for the frontend AND is being made via AJAX
172
-     *
173
-     * @return bool
174
-     */
175
-    public function isFrontAjax()
176
-    {
177
-        return $this->request_type->slug() === RequestTypeContext::AJAX_FRONT;
178
-    }
179
-
180
-
181
-    /**
182
-     * true if the current request is for content that is to be displayed within an iframe
183
-     *
184
-     * @return bool
185
-     */
186
-    public function isIframe()
187
-    {
188
-        return $this->request_type->slug() === RequestTypeContext::IFRAME;
189
-    }
190
-
191
-
192
-    /**
193
-     * @return string
194
-     */
195
-    public function slug()
196
-    {
197
-        return $this->request_type->slug();
198
-    }
19
+	/**
20
+	 * @var RequestTypeContext $request_type
21
+	 */
22
+	private $request_type;
23
+
24
+
25
+	/**
26
+	 * RequestTypeContextChecker constructor.
27
+	 *
28
+	 * @param RequestTypeContext $request_type
29
+	 */
30
+	public function __construct(RequestTypeContext $request_type)
31
+	{
32
+		$this->request_type = $request_type;
33
+		parent::__construct(
34
+			'RequestTypeContextChecker',
35
+			$this->request_type->validRequestTypes()
36
+		);
37
+	}
38
+
39
+
40
+	/**
41
+	 * true if the current request involves some form of activation
42
+	 *
43
+	 * @return bool
44
+	 */
45
+	public function isActivation()
46
+	{
47
+		return $this->request_type->isActivation();
48
+	}
49
+
50
+
51
+	/**
52
+	 * @param $is_activation
53
+	 * @return bool
54
+	 */
55
+	public function setIsActivation($is_activation)
56
+	{
57
+		return $this->request_type->setIsActivation($is_activation);
58
+	}
59
+
60
+
61
+	/**
62
+	 * true if the current request is for the admin and is not being made via AJAX
63
+	 *
64
+	 * @return bool
65
+	 */
66
+	public function isAdmin()
67
+	{
68
+		return $this->request_type->slug() === RequestTypeContext::ADMIN;
69
+	}
70
+
71
+
72
+	/**
73
+	 * true if the current request is for the admin AND is being made via AJAX
74
+	 *
75
+	 * @return bool
76
+	 */
77
+	public function isAdminAjax()
78
+	{
79
+		return $this->request_type->slug() === RequestTypeContext::AJAX_ADMIN;
80
+	}
81
+
82
+
83
+	/**
84
+	 * true if the current request is being made via AJAX... any AJAX
85
+	 *
86
+	 * @return bool
87
+	 */
88
+	public function isAjax()
89
+	{
90
+		return $this->isEeAjax() || $this->isOtherAjax();
91
+	}
92
+
93
+
94
+	/**
95
+	 * true if the current request is for either the EE admin or EE frontend AND is being made via AJAX
96
+	 *
97
+	 * @return bool
98
+	 */
99
+	public function isEeAjax()
100
+	{
101
+		return $this->isAdminAjax() || $this->isFrontAjax();
102
+	}
103
+
104
+
105
+	/**
106
+	 * true if the current request is being made via AJAX but is NOT for EE related logic
107
+	 *
108
+	 * @return bool
109
+	 */
110
+	public function isOtherAjax()
111
+	{
112
+		return $this->request_type->slug() === RequestTypeContext::AJAX_OTHER;
113
+	}
114
+
115
+	/**
116
+	 * true if the current request is for the EE REST API
117
+	 *
118
+	 * @return bool
119
+	 */
120
+	public function isApi()
121
+	{
122
+		return $this->request_type->slug() === RequestTypeContext::API;
123
+	}
124
+
125
+
126
+	/**
127
+	 * true if the current request is from the command line
128
+	 *
129
+	 * @return bool
130
+	 */
131
+	public function isCli()
132
+	{
133
+		return $this->request_type->slug() === RequestTypeContext::CLI;
134
+	}
135
+
136
+
137
+	/**
138
+	 * true if the current request is for a WP_Cron
139
+	 *
140
+	 * @return bool
141
+	 */
142
+	public function isCron()
143
+	{
144
+		return $this->request_type->slug() === RequestTypeContext::CRON;
145
+	}
146
+
147
+
148
+	/**
149
+	 * true if the current request is for a feed (ie: RSS)
150
+	 *
151
+	 * @return bool
152
+	 */
153
+	public function isFeed()
154
+	{
155
+		return $this->request_type->slug() === RequestTypeContext::FEED;
156
+	}
157
+
158
+
159
+	/**
160
+	 * true if the current request is for the frontend and is not being made via AJAX
161
+	 *
162
+	 * @return bool
163
+	 */
164
+	public function isFrontend()
165
+	{
166
+		return $this->request_type->slug() === RequestTypeContext::FRONTEND;
167
+	}
168
+
169
+
170
+	/**
171
+	 * true if the current request is for the frontend AND is being made via AJAX
172
+	 *
173
+	 * @return bool
174
+	 */
175
+	public function isFrontAjax()
176
+	{
177
+		return $this->request_type->slug() === RequestTypeContext::AJAX_FRONT;
178
+	}
179
+
180
+
181
+	/**
182
+	 * true if the current request is for content that is to be displayed within an iframe
183
+	 *
184
+	 * @return bool
185
+	 */
186
+	public function isIframe()
187
+	{
188
+		return $this->request_type->slug() === RequestTypeContext::IFRAME;
189
+	}
190
+
191
+
192
+	/**
193
+	 * @return string
194
+	 */
195
+	public function slug()
196
+	{
197
+		return $this->request_type->slug();
198
+	}
199 199
 }
Please login to merge, or discard this patch.
core/domain/services/contexts/RequestTypeContextDetector.php 2 patches
Indentation   +127 added lines, -127 removed lines patch added patch discarded remove patch
@@ -19,131 +19,131 @@
 block discarded – undo
19 19
 class RequestTypeContextDetector
20 20
 {
21 21
 
22
-    /**
23
-     * @var RequestTypeContextFactory $factory
24
-     */
25
-    private $factory;
26
-
27
-    /**
28
-     * @var RequestInterface $request
29
-     */
30
-    private $request;
31
-
32
-
33
-    /**
34
-     * RequestTypeContextDetector constructor.
35
-     *
36
-     * @param RequestInterface          $request
37
-     * @param RequestTypeContextFactory $factory
38
-     */
39
-    public function __construct(RequestInterface $request, RequestTypeContextFactory $factory)
40
-    {
41
-        $this->request = $request;
42
-        $this->factory = $factory;
43
-    }
44
-
45
-
46
-    /**
47
-     * @return RequestTypeContext
48
-     * @throws InvalidArgumentException
49
-     */
50
-    public function detectRequestTypeContext()
51
-    {
52
-        // Detect EE REST API
53
-        if ($this->isEspressoRestApiRequest()) {
54
-            return $this->factory->create(RequestTypeContext::API);
55
-        }
56
-        // Detect AJAX
57
-        if (defined('DOING_AJAX') && DOING_AJAX) {
58
-            if (filter_var($this->request->getRequestParam('ee_front_ajax'), FILTER_VALIDATE_BOOLEAN)) {
59
-                return $this->factory->create(RequestTypeContext::AJAX_FRONT);
60
-            }
61
-            if (filter_var($this->request->getRequestParam('ee_admin_ajax'), FILTER_VALIDATE_BOOLEAN)) {
62
-                return $this->factory->create(RequestTypeContext::AJAX_ADMIN);
63
-            }
64
-            return $this->factory->create(RequestTypeContext::AJAX_OTHER);
65
-        }
66
-        // Detect WP_Cron
67
-        if ($this->isCronRequest()) {
68
-            return $this->factory->create(RequestTypeContext::CRON);
69
-        }
70
-        // Detect command line requests
71
-        if (defined('WP_CLI') && WP_CLI) {
72
-            return $this->factory->create(RequestTypeContext::CLI);
73
-        }
74
-        // detect WordPress admin (ie: "Dashboard")
75
-        if (is_admin()) {
76
-            return $this->factory->create(RequestTypeContext::ADMIN);
77
-        }
78
-        // Detect iFrames
79
-        if ($this->isIframeRoute()) {
80
-            return $this->factory->create(RequestTypeContext::IFRAME);
81
-        }
82
-        // Detect Feeds
83
-        if ($this->isFeedRequest()) {
84
-            return $this->factory->create(RequestTypeContext::FEED);
85
-        }
86
-        // and by process of elimination...
87
-        return $this->factory->create(RequestTypeContext::FRONTEND);
88
-    }
89
-
90
-
91
-    /**
92
-     * @return bool
93
-     */
94
-    private function isEspressoRestApiRequest()
95
-    {
96
-        $ee_rest_url_prefix = RecommendedVersions::compareWordPressVersion('4.4.0')
97
-            ? trim(rest_get_url_prefix(), '/')
98
-            : 'wp-json';
99
-        $ee_rest_url_prefix .= '/' . Domain::API_NAMESPACE;
100
-        return $this->uriPathMatches($ee_rest_url_prefix);
101
-    }
102
-
103
-
104
-    /**
105
-     * @return bool
106
-     */
107
-    private function isCronRequest()
108
-    {
109
-        return $this->uriPathMatches('wp-cron.php');
110
-    }
111
-
112
-
113
-    /**
114
-     * @return bool
115
-     */
116
-    private function isFeedRequest()
117
-    {
118
-        return $this->uriPathMatches('feed');
119
-    }
120
-
121
-
122
-    /**
123
-     * @param string $component
124
-     * @return bool
125
-     */
126
-    private function uriPathMatches($component)
127
-    {
128
-        $request_uri = $this->request->requestUri();
129
-        $parts = explode('?', $request_uri);
130
-        $path = trim(reset($parts), '/');
131
-        return strpos($path, $component) === 0;
132
-    }
133
-
134
-
135
-    /**
136
-     * @return bool
137
-     */
138
-    private function isIframeRoute()
139
-    {
140
-        $is_iframe_route = apply_filters(
141
-            'FHEE__EventEspresso_core_domain_services_contexts_RequestTypeContextDetector__isIframeRoute',
142
-            $this->request->getRequestParam('event_list', '') === 'iframe'
143
-            || $this->request->getRequestParam('ticket_selector', '') === 'iframe'
144
-            || $this->request->getRequestParam('calendar', '') === 'iframe',
145
-            $this
146
-        );
147
-        return filter_var($is_iframe_route, FILTER_VALIDATE_BOOLEAN);
148
-    }
22
+	/**
23
+	 * @var RequestTypeContextFactory $factory
24
+	 */
25
+	private $factory;
26
+
27
+	/**
28
+	 * @var RequestInterface $request
29
+	 */
30
+	private $request;
31
+
32
+
33
+	/**
34
+	 * RequestTypeContextDetector constructor.
35
+	 *
36
+	 * @param RequestInterface          $request
37
+	 * @param RequestTypeContextFactory $factory
38
+	 */
39
+	public function __construct(RequestInterface $request, RequestTypeContextFactory $factory)
40
+	{
41
+		$this->request = $request;
42
+		$this->factory = $factory;
43
+	}
44
+
45
+
46
+	/**
47
+	 * @return RequestTypeContext
48
+	 * @throws InvalidArgumentException
49
+	 */
50
+	public function detectRequestTypeContext()
51
+	{
52
+		// Detect EE REST API
53
+		if ($this->isEspressoRestApiRequest()) {
54
+			return $this->factory->create(RequestTypeContext::API);
55
+		}
56
+		// Detect AJAX
57
+		if (defined('DOING_AJAX') && DOING_AJAX) {
58
+			if (filter_var($this->request->getRequestParam('ee_front_ajax'), FILTER_VALIDATE_BOOLEAN)) {
59
+				return $this->factory->create(RequestTypeContext::AJAX_FRONT);
60
+			}
61
+			if (filter_var($this->request->getRequestParam('ee_admin_ajax'), FILTER_VALIDATE_BOOLEAN)) {
62
+				return $this->factory->create(RequestTypeContext::AJAX_ADMIN);
63
+			}
64
+			return $this->factory->create(RequestTypeContext::AJAX_OTHER);
65
+		}
66
+		// Detect WP_Cron
67
+		if ($this->isCronRequest()) {
68
+			return $this->factory->create(RequestTypeContext::CRON);
69
+		}
70
+		// Detect command line requests
71
+		if (defined('WP_CLI') && WP_CLI) {
72
+			return $this->factory->create(RequestTypeContext::CLI);
73
+		}
74
+		// detect WordPress admin (ie: "Dashboard")
75
+		if (is_admin()) {
76
+			return $this->factory->create(RequestTypeContext::ADMIN);
77
+		}
78
+		// Detect iFrames
79
+		if ($this->isIframeRoute()) {
80
+			return $this->factory->create(RequestTypeContext::IFRAME);
81
+		}
82
+		// Detect Feeds
83
+		if ($this->isFeedRequest()) {
84
+			return $this->factory->create(RequestTypeContext::FEED);
85
+		}
86
+		// and by process of elimination...
87
+		return $this->factory->create(RequestTypeContext::FRONTEND);
88
+	}
89
+
90
+
91
+	/**
92
+	 * @return bool
93
+	 */
94
+	private function isEspressoRestApiRequest()
95
+	{
96
+		$ee_rest_url_prefix = RecommendedVersions::compareWordPressVersion('4.4.0')
97
+			? trim(rest_get_url_prefix(), '/')
98
+			: 'wp-json';
99
+		$ee_rest_url_prefix .= '/' . Domain::API_NAMESPACE;
100
+		return $this->uriPathMatches($ee_rest_url_prefix);
101
+	}
102
+
103
+
104
+	/**
105
+	 * @return bool
106
+	 */
107
+	private function isCronRequest()
108
+	{
109
+		return $this->uriPathMatches('wp-cron.php');
110
+	}
111
+
112
+
113
+	/**
114
+	 * @return bool
115
+	 */
116
+	private function isFeedRequest()
117
+	{
118
+		return $this->uriPathMatches('feed');
119
+	}
120
+
121
+
122
+	/**
123
+	 * @param string $component
124
+	 * @return bool
125
+	 */
126
+	private function uriPathMatches($component)
127
+	{
128
+		$request_uri = $this->request->requestUri();
129
+		$parts = explode('?', $request_uri);
130
+		$path = trim(reset($parts), '/');
131
+		return strpos($path, $component) === 0;
132
+	}
133
+
134
+
135
+	/**
136
+	 * @return bool
137
+	 */
138
+	private function isIframeRoute()
139
+	{
140
+		$is_iframe_route = apply_filters(
141
+			'FHEE__EventEspresso_core_domain_services_contexts_RequestTypeContextDetector__isIframeRoute',
142
+			$this->request->getRequestParam('event_list', '') === 'iframe'
143
+			|| $this->request->getRequestParam('ticket_selector', '') === 'iframe'
144
+			|| $this->request->getRequestParam('calendar', '') === 'iframe',
145
+			$this
146
+		);
147
+		return filter_var($is_iframe_route, FILTER_VALIDATE_BOOLEAN);
148
+	}
149 149
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -96,7 +96,7 @@
 block discarded – undo
96 96
         $ee_rest_url_prefix = RecommendedVersions::compareWordPressVersion('4.4.0')
97 97
             ? trim(rest_get_url_prefix(), '/')
98 98
             : 'wp-json';
99
-        $ee_rest_url_prefix .= '/' . Domain::API_NAMESPACE;
99
+        $ee_rest_url_prefix .= '/'.Domain::API_NAMESPACE;
100 100
         return $this->uriPathMatches($ee_rest_url_prefix);
101 101
     }
102 102
 
Please login to merge, or discard this patch.
core/domain/services/contexts/RequestTypeContextFactory.php 1 patch
Indentation   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -17,104 +17,104 @@
 block discarded – undo
17 17
 class RequestTypeContextFactory
18 18
 {
19 19
 
20
-    /**
21
-     * @var LoaderInterface $loader
22
-     */
23
-    private $loader;
20
+	/**
21
+	 * @var LoaderInterface $loader
22
+	 */
23
+	private $loader;
24 24
 
25 25
 
26
-    /**
27
-     * RequestTypeContextFactory constructor.
28
-     *
29
-     * @param LoaderInterface $loader
30
-     */
31
-    public function __construct(LoaderInterface $loader)
32
-    {
33
-        $this->loader = $loader;
34
-    }
26
+	/**
27
+	 * RequestTypeContextFactory constructor.
28
+	 *
29
+	 * @param LoaderInterface $loader
30
+	 */
31
+	public function __construct(LoaderInterface $loader)
32
+	{
33
+		$this->loader = $loader;
34
+	}
35 35
 
36 36
 
37
-    /**
38
-     * @param string $slug
39
-     * @return RequestTypeContext
40
-     */
41
-    public function create($slug)
42
-    {
43
-        switch ($slug) {
44
-            case RequestTypeContext::ACTIVATION:
45
-                $description = esc_html__(
46
-                    'The current request is for some form of activation',
47
-                    'event_espresso'
48
-                );
49
-                break;
50
-            case RequestTypeContext::API:
51
-                $description = esc_html__(
52
-                    'The current request is for the REST API',
53
-                    'event_espresso'
54
-                );
55
-                break;
56
-            case RequestTypeContext::AJAX_FRONT:
57
-                $description = esc_html__(
58
-                    'The current request is for the frontend via AJAX',
59
-                    'event_espresso'
60
-                );
61
-                break;
62
-            case RequestTypeContext::AJAX_ADMIN:
63
-                $description = esc_html__(
64
-                    'The current request is for the admin via AJAX',
65
-                    'event_espresso'
66
-                );
67
-                break;
68
-            case RequestTypeContext::AJAX_OTHER:
69
-                $description = esc_html__(
70
-                    'The current request is for non-EE related code via AJAX',
71
-                    'event_espresso'
72
-                );
73
-                break;
74
-            case RequestTypeContext::CRON:
75
-                $description = esc_html__(
76
-                    'The current request is for a WP_Cron',
77
-                    'event_espresso'
78
-                );
79
-                break;
80
-            case RequestTypeContext::CLI:
81
-                $description = esc_html__(
82
-                    'The current request is from the command line',
83
-                    'event_espresso'
84
-                );
85
-                break;
86
-            case RequestTypeContext::ADMIN:
87
-                $description = esc_html__(
88
-                    'The current request is for the admin',
89
-                    'event_espresso'
90
-                );
91
-                break;
92
-            case RequestTypeContext::IFRAME:
93
-                $description = esc_html__(
94
-                    'The current request is for an iframe',
95
-                    'event_espresso'
96
-                );
97
-                break;
98
-            case RequestTypeContext::FEED:
99
-                $description = esc_html__(
100
-                    'The current request is for a feed (ie: RSS)',
101
-                    'event_espresso'
102
-                );
103
-                break;
104
-            case RequestTypeContext::FRONTEND:
105
-            default:
106
-                $description = esc_html__(
107
-                    'The current request is for the frontend',
108
-                    'event_espresso'
109
-                );
110
-                break;
111
-        }
112
-        // we're using the Loader with sharing turned on,
113
-        // so that the generated RequestTypeContext object is accessible anywhere
114
-        // by simply requesting it again from the loader
115
-        return $this->loader->getShared(
116
-            'EventEspresso\core\domain\entities\contexts\RequestTypeContext',
117
-            array($slug, $description)
118
-        );
119
-    }
37
+	/**
38
+	 * @param string $slug
39
+	 * @return RequestTypeContext
40
+	 */
41
+	public function create($slug)
42
+	{
43
+		switch ($slug) {
44
+			case RequestTypeContext::ACTIVATION:
45
+				$description = esc_html__(
46
+					'The current request is for some form of activation',
47
+					'event_espresso'
48
+				);
49
+				break;
50
+			case RequestTypeContext::API:
51
+				$description = esc_html__(
52
+					'The current request is for the REST API',
53
+					'event_espresso'
54
+				);
55
+				break;
56
+			case RequestTypeContext::AJAX_FRONT:
57
+				$description = esc_html__(
58
+					'The current request is for the frontend via AJAX',
59
+					'event_espresso'
60
+				);
61
+				break;
62
+			case RequestTypeContext::AJAX_ADMIN:
63
+				$description = esc_html__(
64
+					'The current request is for the admin via AJAX',
65
+					'event_espresso'
66
+				);
67
+				break;
68
+			case RequestTypeContext::AJAX_OTHER:
69
+				$description = esc_html__(
70
+					'The current request is for non-EE related code via AJAX',
71
+					'event_espresso'
72
+				);
73
+				break;
74
+			case RequestTypeContext::CRON:
75
+				$description = esc_html__(
76
+					'The current request is for a WP_Cron',
77
+					'event_espresso'
78
+				);
79
+				break;
80
+			case RequestTypeContext::CLI:
81
+				$description = esc_html__(
82
+					'The current request is from the command line',
83
+					'event_espresso'
84
+				);
85
+				break;
86
+			case RequestTypeContext::ADMIN:
87
+				$description = esc_html__(
88
+					'The current request is for the admin',
89
+					'event_espresso'
90
+				);
91
+				break;
92
+			case RequestTypeContext::IFRAME:
93
+				$description = esc_html__(
94
+					'The current request is for an iframe',
95
+					'event_espresso'
96
+				);
97
+				break;
98
+			case RequestTypeContext::FEED:
99
+				$description = esc_html__(
100
+					'The current request is for a feed (ie: RSS)',
101
+					'event_espresso'
102
+				);
103
+				break;
104
+			case RequestTypeContext::FRONTEND:
105
+			default:
106
+				$description = esc_html__(
107
+					'The current request is for the frontend',
108
+					'event_espresso'
109
+				);
110
+				break;
111
+		}
112
+		// we're using the Loader with sharing turned on,
113
+		// so that the generated RequestTypeContext object is accessible anywhere
114
+		// by simply requesting it again from the loader
115
+		return $this->loader->getShared(
116
+			'EventEspresso\core\domain\entities\contexts\RequestTypeContext',
117
+			array($slug, $description)
118
+		);
119
+	}
120 120
 }
Please login to merge, or discard this patch.
core/domain/services/DomainService.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -20,10 +20,10 @@
 block discarded – undo
20 20
 abstract class DomainService implements DomainServiceInterface
21 21
 {
22 22
 
23
-    /**
24
-     * DomainService constructor.
25
-     */
26
-    public function __construct()
27
-    {
28
-    }
23
+	/**
24
+	 * DomainService constructor.
25
+	 */
26
+	public function __construct()
27
+	{
28
+	}
29 29
 }
Please login to merge, or discard this patch.
core/domain/services/custom_post_types/RegisterCustomPostTypes.php 1 patch
Indentation   +221 added lines, -221 removed lines patch added patch discarded remove patch
@@ -18,240 +18,240 @@
 block discarded – undo
18 18
 class RegisterCustomPostTypes
19 19
 {
20 20
 
21
-    /**
22
-     * @var CustomPostTypeDefinitions $custom_post_types
23
-     */
24
-    public $custom_post_types;
21
+	/**
22
+	 * @var CustomPostTypeDefinitions $custom_post_types
23
+	 */
24
+	public $custom_post_types;
25 25
 
26
-    /**
27
-     * @var WP_Post_Type[] $wp_post_types
28
-     */
29
-    public $wp_post_types = array();
26
+	/**
27
+	 * @var WP_Post_Type[] $wp_post_types
28
+	 */
29
+	public $wp_post_types = array();
30 30
 
31 31
 
32
-    /**
33
-     * RegisterCustomPostTypes constructor.
34
-     *
35
-     * @param CustomPostTypeDefinitions $custom_post_types
36
-     */
37
-    public function __construct(CustomPostTypeDefinitions $custom_post_types)
38
-    {
39
-        $this->custom_post_types = $custom_post_types;
40
-    }
32
+	/**
33
+	 * RegisterCustomPostTypes constructor.
34
+	 *
35
+	 * @param CustomPostTypeDefinitions $custom_post_types
36
+	 */
37
+	public function __construct(CustomPostTypeDefinitions $custom_post_types)
38
+	{
39
+		$this->custom_post_types = $custom_post_types;
40
+	}
41 41
 
42 42
 
43
-    /**
44
-     * @return WP_Post_Type[]
45
-     */
46
-    public function getRegisteredCustomPostTypes()
47
-    {
48
-        return $this->wp_post_types;
49
-    }
43
+	/**
44
+	 * @return WP_Post_Type[]
45
+	 */
46
+	public function getRegisteredCustomPostTypes()
47
+	{
48
+		return $this->wp_post_types;
49
+	}
50 50
 
51 51
 
52
-    /**
53
-     * @return void
54
-     * @throws DomainException
55
-     */
56
-    public function registerCustomPostTypes()
57
-    {
58
-        $custom_post_types = $this->custom_post_types->getDefinitions();
59
-        foreach ($custom_post_types as $custom_post_type => $CPT) {
60
-            $this->wp_post_types[$custom_post_type] = $this->registerCustomPostType(
61
-                $custom_post_type,
62
-                $CPT['singular_name'],
63
-                $CPT['plural_name'],
64
-                $CPT['singular_slug'],
65
-                $CPT['plural_slug'],
66
-                $CPT['args']
67
-            );
68
-        }
69
-    }
52
+	/**
53
+	 * @return void
54
+	 * @throws DomainException
55
+	 */
56
+	public function registerCustomPostTypes()
57
+	{
58
+		$custom_post_types = $this->custom_post_types->getDefinitions();
59
+		foreach ($custom_post_types as $custom_post_type => $CPT) {
60
+			$this->wp_post_types[$custom_post_type] = $this->registerCustomPostType(
61
+				$custom_post_type,
62
+				$CPT['singular_name'],
63
+				$CPT['plural_name'],
64
+				$CPT['singular_slug'],
65
+				$CPT['plural_slug'],
66
+				$CPT['args']
67
+			);
68
+		}
69
+	}
70 70
 
71 71
 
72
-    /**
73
-     * Registers a new custom post type. Sets default settings given only the following params.
74
-     * Returns the registered post type object, or an error object.
75
-     *
76
-     * @param string $post_type          the actual post type name
77
-     *                                   IMPORTANT:
78
-     *                                   this must match what the slug is for admin pages related to this CPT
79
-     *                                   Also any models must use this slug as well
80
-     * @param string $singular_name      a pre-internationalized string for the singular name of the objects
81
-     * @param string $plural_name        a pre-internationalized string for the plural name of the objects
82
-     * @param string $singular_slug
83
-     * @param string $plural_slug
84
-     * @param array  $override_arguments exactly like $args as described in
85
-     *                                   http://codex.wordpress.org/Function_Reference/register_post_type
86
-     * @return WP_Post_Type|WP_Error
87
-     * @throws DomainException
88
-     */
89
-    public function registerCustomPostType(
90
-        $post_type,
91
-        $singular_name,
92
-        $plural_name,
93
-        $singular_slug = '',
94
-        $plural_slug = '',
95
-        array $override_arguments = array()
96
-    ) {
97
-        $wp_post_type = register_post_type(
98
-            $post_type,
99
-            $this->prepareArguments(
100
-                $post_type,
101
-                $singular_name,
102
-                $plural_name,
103
-                $singular_slug,
104
-                $plural_slug,
105
-                $override_arguments
106
-            )
107
-        );
108
-        if ($wp_post_type instanceof WP_Error) {
109
-            throw new DomainException($wp_post_type->get_error_message());
110
-        }
111
-        return $wp_post_type;
112
-    }
72
+	/**
73
+	 * Registers a new custom post type. Sets default settings given only the following params.
74
+	 * Returns the registered post type object, or an error object.
75
+	 *
76
+	 * @param string $post_type          the actual post type name
77
+	 *                                   IMPORTANT:
78
+	 *                                   this must match what the slug is for admin pages related to this CPT
79
+	 *                                   Also any models must use this slug as well
80
+	 * @param string $singular_name      a pre-internationalized string for the singular name of the objects
81
+	 * @param string $plural_name        a pre-internationalized string for the plural name of the objects
82
+	 * @param string $singular_slug
83
+	 * @param string $plural_slug
84
+	 * @param array  $override_arguments exactly like $args as described in
85
+	 *                                   http://codex.wordpress.org/Function_Reference/register_post_type
86
+	 * @return WP_Post_Type|WP_Error
87
+	 * @throws DomainException
88
+	 */
89
+	public function registerCustomPostType(
90
+		$post_type,
91
+		$singular_name,
92
+		$plural_name,
93
+		$singular_slug = '',
94
+		$plural_slug = '',
95
+		array $override_arguments = array()
96
+	) {
97
+		$wp_post_type = register_post_type(
98
+			$post_type,
99
+			$this->prepareArguments(
100
+				$post_type,
101
+				$singular_name,
102
+				$plural_name,
103
+				$singular_slug,
104
+				$plural_slug,
105
+				$override_arguments
106
+			)
107
+		);
108
+		if ($wp_post_type instanceof WP_Error) {
109
+			throw new DomainException($wp_post_type->get_error_message());
110
+		}
111
+		return $wp_post_type;
112
+	}
113 113
 
114 114
 
115
-    /**
116
-     * @param string $post_type          the actual post type name
117
-     * @param string $singular_name      a pre-internationalized string for the singular name of the objects
118
-     * @param string $plural_name        a pre-internationalized string for the plural name of the objects
119
-     * @param string $singular_slug
120
-     * @param string $plural_slug
121
-     * @param array  $override_arguments The default values set in this function will be overridden
122
-     *                                   by whatever you set in $override_arguments
123
-     * @return array
124
-     */
125
-    protected function prepareArguments(
126
-        $post_type,
127
-        $singular_name,
128
-        $plural_name,
129
-        $singular_slug,
130
-        $plural_slug,
131
-        array $override_arguments = array()
132
-    ) {
133
-        // verify plural slug and singular slug, if they aren't we'll use $singular_name and $plural_name
134
-        $singular_slug = ! empty($singular_slug) ? $singular_slug : $singular_name;
135
-        $plural_slug = ! empty($plural_slug) ? $plural_slug : $plural_name;
136
-        $labels = $this->getLabels(
137
-            $singular_name,
138
-            $plural_name,
139
-            $singular_slug,
140
-            $plural_slug
141
-        );
142
-        // note the page_templates arg in the supports index is something specific to EE.
143
-        // WordPress doesn't actually have that in their register_post_type api.
144
-        $arguments = $this->getDefaultArguments($labels, $post_type, $plural_slug);
145
-        if ($override_arguments) {
146
-            if (isset($override_arguments['labels'])) {
147
-                $labels = array_merge($arguments['labels'], $override_arguments['labels']);
148
-            }
149
-            $arguments = array_merge($arguments, $override_arguments);
150
-            $arguments['labels'] = $labels;
151
-        }
152
-        return $arguments;
153
-    }
115
+	/**
116
+	 * @param string $post_type          the actual post type name
117
+	 * @param string $singular_name      a pre-internationalized string for the singular name of the objects
118
+	 * @param string $plural_name        a pre-internationalized string for the plural name of the objects
119
+	 * @param string $singular_slug
120
+	 * @param string $plural_slug
121
+	 * @param array  $override_arguments The default values set in this function will be overridden
122
+	 *                                   by whatever you set in $override_arguments
123
+	 * @return array
124
+	 */
125
+	protected function prepareArguments(
126
+		$post_type,
127
+		$singular_name,
128
+		$plural_name,
129
+		$singular_slug,
130
+		$plural_slug,
131
+		array $override_arguments = array()
132
+	) {
133
+		// verify plural slug and singular slug, if they aren't we'll use $singular_name and $plural_name
134
+		$singular_slug = ! empty($singular_slug) ? $singular_slug : $singular_name;
135
+		$plural_slug = ! empty($plural_slug) ? $plural_slug : $plural_name;
136
+		$labels = $this->getLabels(
137
+			$singular_name,
138
+			$plural_name,
139
+			$singular_slug,
140
+			$plural_slug
141
+		);
142
+		// note the page_templates arg in the supports index is something specific to EE.
143
+		// WordPress doesn't actually have that in their register_post_type api.
144
+		$arguments = $this->getDefaultArguments($labels, $post_type, $plural_slug);
145
+		if ($override_arguments) {
146
+			if (isset($override_arguments['labels'])) {
147
+				$labels = array_merge($arguments['labels'], $override_arguments['labels']);
148
+			}
149
+			$arguments = array_merge($arguments, $override_arguments);
150
+			$arguments['labels'] = $labels;
151
+		}
152
+		return $arguments;
153
+	}
154 154
 
155 155
 
156
-    /**
157
-     * @param string $singular_name
158
-     * @param string $plural_name
159
-     * @param string $singular_slug
160
-     * @param string $plural_slug
161
-     * @return array
162
-     */
163
-    private function getLabels($singular_name, $plural_name, $singular_slug, $plural_slug)
164
-    {
165
-        return array(
166
-            'name'               => $plural_name,
167
-            'singular_name'      => $singular_name,
168
-            'singular_slug'      => $singular_slug,
169
-            'plural_slug'        => $plural_slug,
170
-            'add_new'            => sprintf(
171
-                esc_html_x('Add %s', 'Add Event', 'event_espresso'),
172
-                $singular_name
173
-            ),
174
-            'add_new_item'       => sprintf(
175
-                esc_html_x('Add New %s', 'Add New Event', 'event_espresso'),
176
-                $singular_name
177
-            ),
178
-            'edit_item'          => sprintf(
179
-                esc_html_x('Edit %s', 'Edit Event', 'event_espresso'),
180
-                $singular_name
181
-            ),
182
-            'new_item'           => sprintf(
183
-                esc_html_x('New %s', 'New Event', 'event_espresso'),
184
-                $singular_name
185
-            ),
186
-            'all_items'          => sprintf(
187
-                esc_html_x('All %s', 'All Events', 'event_espresso'),
188
-                $plural_name
189
-            ),
190
-            'view_item'          => sprintf(
191
-                esc_html_x('View %s', 'View Event', 'event_espresso'),
192
-                $singular_name
193
-            ),
194
-            'search_items'       => sprintf(
195
-                esc_html_x('Search %s', 'Search Events', 'event_espresso'),
196
-                $plural_name
197
-            ),
198
-            'not_found'          => sprintf(
199
-                esc_html_x('No %s found', 'No Events found', 'event_espresso'),
200
-                $plural_name
201
-            ),
202
-            'not_found_in_trash' => sprintf(
203
-                esc_html_x('No %s found in Trash', 'No Events found in Trash', 'event_espresso'),
204
-                $plural_name
205
-            ),
206
-            'parent_item_colon'  => '',
207
-            'menu_name'          => $plural_name,
208
-        );
209
-    }
156
+	/**
157
+	 * @param string $singular_name
158
+	 * @param string $plural_name
159
+	 * @param string $singular_slug
160
+	 * @param string $plural_slug
161
+	 * @return array
162
+	 */
163
+	private function getLabels($singular_name, $plural_name, $singular_slug, $plural_slug)
164
+	{
165
+		return array(
166
+			'name'               => $plural_name,
167
+			'singular_name'      => $singular_name,
168
+			'singular_slug'      => $singular_slug,
169
+			'plural_slug'        => $plural_slug,
170
+			'add_new'            => sprintf(
171
+				esc_html_x('Add %s', 'Add Event', 'event_espresso'),
172
+				$singular_name
173
+			),
174
+			'add_new_item'       => sprintf(
175
+				esc_html_x('Add New %s', 'Add New Event', 'event_espresso'),
176
+				$singular_name
177
+			),
178
+			'edit_item'          => sprintf(
179
+				esc_html_x('Edit %s', 'Edit Event', 'event_espresso'),
180
+				$singular_name
181
+			),
182
+			'new_item'           => sprintf(
183
+				esc_html_x('New %s', 'New Event', 'event_espresso'),
184
+				$singular_name
185
+			),
186
+			'all_items'          => sprintf(
187
+				esc_html_x('All %s', 'All Events', 'event_espresso'),
188
+				$plural_name
189
+			),
190
+			'view_item'          => sprintf(
191
+				esc_html_x('View %s', 'View Event', 'event_espresso'),
192
+				$singular_name
193
+			),
194
+			'search_items'       => sprintf(
195
+				esc_html_x('Search %s', 'Search Events', 'event_espresso'),
196
+				$plural_name
197
+			),
198
+			'not_found'          => sprintf(
199
+				esc_html_x('No %s found', 'No Events found', 'event_espresso'),
200
+				$plural_name
201
+			),
202
+			'not_found_in_trash' => sprintf(
203
+				esc_html_x('No %s found in Trash', 'No Events found in Trash', 'event_espresso'),
204
+				$plural_name
205
+			),
206
+			'parent_item_colon'  => '',
207
+			'menu_name'          => $plural_name,
208
+		);
209
+	}
210 210
 
211 211
 
212
-    /**
213
-     * @param array  $labels
214
-     * @param string $post_type
215
-     * @param string $plural_slug
216
-     * @return array
217
-     */
218
-    private function getDefaultArguments(array $labels, $post_type, $plural_slug)
219
-    {
220
-        return array(
221
-            'labels'             => $labels,
222
-            'public'             => true,
223
-            'publicly_queryable' => true,
224
-            'show_ui'            => false,
225
-            'show_ee_ui'         => true,
226
-            'show_in_menu'       => false,
227
-            'show_in_nav_menus'  => false,
228
-            'query_var'          => true,
229
-            'rewrite'            => apply_filters(
230
-                'FHEE__EventEspresso_core_domain_entities_custom_post_types_RegisterCustomPostTypes__getDefaultArguments__rewrite',
231
-                // legacy filter applied for now,
232
-                // later on we'll run a has_filter($tag) check and throw a doing_it_wrong() notice
233
-                apply_filters(
234
-                    'FHEE__EE_Register_CPTs__register_CPT__rewrite',
235
-                    array('slug' => $plural_slug),
236
-                    $post_type
237
-                ),
238
-                $post_type,
239
-                $plural_slug
240
-            ),
241
-            'capability_type'    => 'post',
242
-            'map_meta_cap'       => true,
243
-            'has_archive'        => true,
244
-            'hierarchical'       => false,
245
-            'menu_position'      => null,
246
-            'supports'           => array(
247
-                'title',
248
-                'editor',
249
-                'author',
250
-                'thumbnail',
251
-                'excerpt',
252
-                'custom-fields',
253
-                'comments',
254
-            ),
255
-        );
256
-    }
212
+	/**
213
+	 * @param array  $labels
214
+	 * @param string $post_type
215
+	 * @param string $plural_slug
216
+	 * @return array
217
+	 */
218
+	private function getDefaultArguments(array $labels, $post_type, $plural_slug)
219
+	{
220
+		return array(
221
+			'labels'             => $labels,
222
+			'public'             => true,
223
+			'publicly_queryable' => true,
224
+			'show_ui'            => false,
225
+			'show_ee_ui'         => true,
226
+			'show_in_menu'       => false,
227
+			'show_in_nav_menus'  => false,
228
+			'query_var'          => true,
229
+			'rewrite'            => apply_filters(
230
+				'FHEE__EventEspresso_core_domain_entities_custom_post_types_RegisterCustomPostTypes__getDefaultArguments__rewrite',
231
+				// legacy filter applied for now,
232
+				// later on we'll run a has_filter($tag) check and throw a doing_it_wrong() notice
233
+				apply_filters(
234
+					'FHEE__EE_Register_CPTs__register_CPT__rewrite',
235
+					array('slug' => $plural_slug),
236
+					$post_type
237
+				),
238
+				$post_type,
239
+				$plural_slug
240
+			),
241
+			'capability_type'    => 'post',
242
+			'map_meta_cap'       => true,
243
+			'has_archive'        => true,
244
+			'hierarchical'       => false,
245
+			'menu_position'      => null,
246
+			'supports'           => array(
247
+				'title',
248
+				'editor',
249
+				'author',
250
+				'thumbnail',
251
+				'excerpt',
252
+				'custom-fields',
253
+				'comments',
254
+			),
255
+		);
256
+	}
257 257
 }
Please login to merge, or discard this patch.