Passed
Push — master ( e29497...7ab2d6 )
by Paul
04:36
created
site-reviews.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,9 @@
 block discarded – undo
21 21
 if( !class_exists( 'GL_Plugin_Check_v3' )) {
22 22
 	require_once __DIR__.'/activate.php';
23 23
 }
24
-if( !(new GL_Plugin_Check_v3( __FILE__ ))->canProceed() )return;
24
+if( !(new GL_Plugin_Check_v3( __FILE__ ))->canProceed() ) {
25
+	return;
26
+}
25 27
 require_once __DIR__.'/autoload.php';
26 28
 require_once __DIR__.'/compatibility.php';
27 29
 require_once __DIR__.'/helpers.php';
Please login to merge, or discard this patch.
plugin/Modules/Html/Field.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 			'is_valid' => true,
27 27
 			'is_widget' => false,
28 28
 			'path' => '',
29
-		]);
29
+		] );
30 30
 		$this->normalize();
31 31
 	}
32 32
 
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	{
46 46
 		if( !$this->field['is_valid'] )return;
47 47
 		if( $this->field['is_raw'] ) {
48
-			return glsr( Builder::class )->{$this->field['type']}( $this->field );
48
+			return glsr( Builder::class )->{$this->field['type']}($this->field);
49 49
 		}
50 50
 		if( !$this->field['is_setting'] ) {
51 51
 			return $this->buildField();
@@ -73,9 +73,9 @@  discard block
 block discarded – undo
73 73
 			'context' => [
74 74
 				'class' => $this->getFieldClass(),
75 75
 				'errors' => $this->getFieldErrors(),
76
-				'field' => glsr( Builder::class )->{$this->field['type']}( $this->field ),
76
+				'field' => glsr( Builder::class )->{$this->field['type']}($this->field),
77 77
 			],
78
-		]);
78
+		] );
79 79
 		return apply_filters( 'site-reviews/rendered/field', $field, $this->field['type'], $this->field );
80 80
 	}
81 81
 
@@ -87,10 +87,10 @@  discard block
 block discarded – undo
87 87
 		return glsr( Template::class )->build( 'partials/form/table-row', [
88 88
 			'context' => [
89 89
 				'class' => $this->getFieldClass(),
90
-				'field' => glsr( Builder::class )->{$this->field['type']}( $this->field ),
90
+				'field' => glsr( Builder::class )->{$this->field['type']}($this->field),
91 91
 				'label' => glsr( Builder::class )->label( $this->field['legend'], ['for' => $this->field['id']] ),
92 92
 			],
93
-		]);
93
+		] );
94 94
 	}
95 95
 
96 96
 	/**
@@ -99,16 +99,16 @@  discard block
 block discarded – undo
99 99
 	protected function buildSettingMultiField()
100 100
 	{
101 101
 		$dependsOn = $this->getFieldDependsOn();
102
-		unset( $this->field['data-depends'] );
102
+		unset($this->field['data-depends']);
103 103
 		return glsr( Template::class )->build( 'partials/form/table-row-multiple', [
104 104
 			'context' => [
105 105
 				'class' => $this->getFieldClass(),
106 106
 				'depends_on' => $dependsOn,
107
-				'field' => glsr( Builder::class )->{$this->field['type']}( $this->field ),
107
+				'field' => glsr( Builder::class )->{$this->field['type']}($this->field),
108 108
 				'label' => glsr( Builder::class )->label( $this->field['legend'], ['for' => $this->field['id']] ),
109 109
 				'legend' => $this->field['legend'],
110 110
 			],
111
-		]);
111
+		] );
112 112
 	}
113 113
 
114 114
 	/**
@@ -117,13 +117,13 @@  discard block
 block discarded – undo
117 117
 	protected function getFieldClass()
118 118
 	{
119 119
 		$classes = [];
120
-		if( !empty( $this->field['errors'] )) {
120
+		if( !empty($this->field['errors']) ) {
121 121
 			$classes[] = 'glsr-has-error';
122 122
 		}
123 123
 		if( $this->field['is_hidden'] ) {
124 124
 			$classes[] = 'hidden';
125 125
 		}
126
-		if( !empty( $this->field['required'] )) {
126
+		if( !empty($this->field['required']) ) {
127 127
 			$classes[] = 'glsr-required';
128 128
 		}
129 129
 		return implode( ' ', $classes );
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 	 */
135 135
 	protected function getFieldDependsOn()
136 136
 	{
137
-		return !empty( $this->field['data-depends'] )
137
+		return !empty($this->field['data-depends'])
138 138
 			? $this->field['data-depends']
139 139
 			: '';
140 140
 	}
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	 */
145 145
 	protected function getFieldErrors()
146 146
 	{
147
-		if( empty( $this->field['errors'] ) || !is_array( $this->field['errors'] ))return;
147
+		if( empty($this->field['errors']) || !is_array( $this->field['errors'] ) )return;
148 148
 		$errors = array_reduce( $this->field['errors'], function( $carry, $error ) {
149 149
 			return $carry.glsr( Builder::class )->span( $error, ['class' => 'glsr-field-error'] );
150 150
 		});
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 			'context' => [
153 153
 				'errors' => $errors,
154 154
 			],
155
-		]);
155
+		] );
156 156
 	}
157 157
 
158 158
 	/**
@@ -175,13 +175,13 @@  discard block
 block discarded – undo
175 175
 			'name', 'type',
176 176
 		];
177 177
 		foreach( $requiredValues as $value ) {
178
-			if( isset( $this->field[$value] ))continue;
178
+			if( isset($this->field[$value]) )continue;
179 179
 			$missingValues[] = $value;
180 180
 			$this->field['is_valid'] = false;
181 181
 		}
182
-		if( !empty( $missingValues )) {
182
+		if( !empty($missingValues) ) {
183 183
 			glsr_log()
184
-				->warning( 'Field is missing: '.implode( ', ', $missingValues ))
184
+				->warning( 'Field is missing: '.implode( ', ', $missingValues ) )
185 185
 				->info( $this->field );
186 186
 		}
187 187
 		return $this->field['is_valid'];
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 		if( !$this->isFieldValid() )return;
196 196
 		$this->field['path'] = $this->field['name'];
197 197
 		$className = glsr( Helper::class )->buildClassName( $this->field['type'], __NAMESPACE__.'\Fields' );
198
-		if( class_exists( $className )) {
198
+		if( class_exists( $className ) ) {
199 199
 			$this->field = array_merge(
200 200
 				wp_parse_args( $this->field, $className::defaults() ),
201 201
 				$className::required()
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 	 */
211 211
 	protected function normalizeFieldId()
212 212
 	{
213
-		if( isset( $this->field['id'] ) || $this->field['is_raw'] )return;
213
+		if( isset($this->field['id']) || $this->field['is_raw'] )return;
214 214
 		$this->field['id'] = glsr( Helper::class )->convertPathToId(
215 215
 			$this->field['path'],
216 216
 			$this->getFieldPrefix()
Please login to merge, or discard this patch.
plugin/Modules/Html/Partials/FormResults.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 		$this->errors = $args['errors'];
22 22
 		return glsr( Builder::class )->div( wpautop( $args['message'] ), [
23 23
 			'class' => $this->getClass(),
24
-		]);
24
+		] );
25 25
 	}
26 26
 
27 27
 	/**
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 */
30 30
 	protected function getClass()
31 31
 	{
32
-		$errorClass = !empty( $this->errors )
32
+		$errorClass = !empty($this->errors)
33 33
 			? 'glsr-has-errors'
34 34
 			: '';
35 35
 		return trim( 'glsr-form-messages '.$errorClass );
Please login to merge, or discard this patch.
plugin/Modules/Html/Fields/Languages.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@
 block discarded – undo
32 32
 	 */
33 33
 	protected static function options()
34 34
 	{
35
-		require_once( ABSPATH.'wp-admin/includes/translation-install.php' );
35
+		require_once(ABSPATH.'wp-admin/includes/translation-install.php');
36 36
 		$locales = wp_get_available_translations();
37 37
 		array_walk( $locales, function( &$value ) {
38 38
 			$value = $value['native_name'];
Please login to merge, or discard this patch.
plugin/Router.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 	public function routeAdminPostRequest()
17 17
 	{
18 18
 		$request = $this->getRequest();
19
-		if( !$this->isValidPostRequest( $request ))return;
19
+		if( !$this->isValidPostRequest( $request ) )return;
20 20
 		check_admin_referer( $request['action'] );
21 21
 		$this->routeRequest( 'admin', $request['action'], $request );
22 22
 	}
@@ -40,8 +40,8 @@  discard block
 block discarded – undo
40 40
 	{
41 41
 		if( is_admin() )return;
42 42
 		$request = $this->getRequest();
43
-		if( !$this->isValidPostRequest( $request ))return;
44
-		if( !$this->isValidPublicNonce( $request ))return;
43
+		if( !$this->isValidPostRequest( $request ) )return;
44
+		if( !$this->isValidPublicNonce( $request ) )return;
45 45
 		$this->routeRequest( 'public', $request['action'], $request );
46 46
 	}
47 47
 
@@ -51,10 +51,10 @@  discard block
 block discarded – undo
51 51
 	protected function checkAjaxNonce( array $request )
52 52
 	{
53 53
 		if( !is_user_logged_in() )return;
54
-		if( !isset( $request['nonce'] )) {
54
+		if( !isset($request['nonce']) ) {
55 55
 			$this->sendAjaxError( 'The request is missing a nonce', $request );
56 56
 		}
57
-		if( !wp_verify_nonce( $request['nonce'], $request['action'] )) {
57
+		if( !wp_verify_nonce( $request['nonce'], $request['action'] ) ) {
58 58
 			$this->sendAjaxError( 'The request failed the nonce check', $request, 403 );
59 59
 		}
60 60
 	}
@@ -64,10 +64,10 @@  discard block
 block discarded – undo
64 64
 	 */
65 65
 	protected function checkAjaxRequest( array $request )
66 66
 	{
67
-		if( !isset( $request['action'] )) {
67
+		if( !isset($request['action']) ) {
68 68
 			$this->sendAjaxError( 'The request must include an action', $request );
69 69
 		}
70
-		if( empty( $request['ajax_request'] )) {
70
+		if( empty($request['ajax_request']) ) {
71 71
 			$this->sendAjaxError( 'The request is invalid', $request );
72 72
 		}
73 73
 	}
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	 */
91 91
 	protected function isValidPostRequest( array $request = [] )
92 92
 	{
93
-		return !empty( $request['action'] ) && empty( $request['ajax_request'] );
93
+		return !empty($request['action']) && empty($request['ajax_request']);
94 94
 	}
95 95
 
96 96
 	/**
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	 */
99 99
 	protected function isValidPublicNonce( array $request )
100 100
 	{
101
-		if( is_user_logged_in() && !wp_verify_nonce( $request['nonce'], $request['action'] )) {
101
+		if( is_user_logged_in() && !wp_verify_nonce( $request['nonce'], $request['action'] ) ) {
102 102
 			glsr_log()->error( 'Nonce check failed for public request' )->info( $request );
103 103
 			return false;
104 104
 		}
@@ -127,11 +127,11 @@  discard block
 block discarded – undo
127 127
 	protected function routeRequest( $type, $action, array $request = [] )
128 128
 	{
129 129
 		$actionHook = 'site-reviews/route/'.$type.'/request';
130
-		$controller = glsr( glsr( Helper::class )->buildClassName( $type.'-controller', 'Controllers' ));
130
+		$controller = glsr( glsr( Helper::class )->buildClassName( $type.'-controller', 'Controllers' ) );
131 131
 		$method = glsr( Helper::class )->buildMethodName( $action, 'router' );
132 132
 		$request = apply_filters( 'site-reviews/route/request', $request, $action, $type );
133 133
 		do_action( $actionHook, $action, $request );
134
-		if( is_callable( [$controller, $method] )) {
134
+		if( is_callable( [$controller, $method] ) ) {
135 135
 			call_user_func( [$controller, $method], $request );
136 136
 			return;
137 137
 		}
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 	protected function sendAjaxError( $error, array $request, $statusCode = 400 )
149 149
 	{
150 150
 		glsr_log()->error( $error )->info( $request );
151
-		wp_send_json_error([
151
+		wp_send_json_error( [
152 152
 			'message' => __( 'The form could not be submitted. Please notify the site administrator.', 'site-reviews' ),
153 153
 			'error' => $error,
154 154
 		], $statusCode );
Please login to merge, or discard this patch.
Braces   +15 added lines, -5 removed lines patch added patch discarded remove patch
@@ -16,7 +16,9 @@  discard block
 block discarded – undo
16 16
 	public function routeAdminPostRequest()
17 17
 	{
18 18
 		$request = $this->getRequest();
19
-		if( !$this->isValidPostRequest( $request ))return;
19
+		if( !$this->isValidPostRequest( $request )) {
20
+			return;
21
+		}
20 22
 		check_admin_referer( $request['action'] );
21 23
 		$this->routeRequest( 'admin', $request['action'], $request );
22 24
 	}
@@ -38,10 +40,16 @@  discard block
 block discarded – undo
38 40
 	 */
39 41
 	public function routePublicPostRequest()
40 42
 	{
41
-		if( is_admin() )return;
43
+		if( is_admin() ) {
44
+			return;
45
+		}
42 46
 		$request = $this->getRequest();
43
-		if( !$this->isValidPostRequest( $request ))return;
44
-		if( !$this->isValidPublicNonce( $request ))return;
47
+		if( !$this->isValidPostRequest( $request )) {
48
+			return;
49
+		}
50
+		if( !$this->isValidPublicNonce( $request )) {
51
+			return;
52
+		}
45 53
 		$this->routeRequest( 'public', $request['action'], $request );
46 54
 	}
47 55
 
@@ -50,7 +58,9 @@  discard block
 block discarded – undo
50 58
 	 */
51 59
 	protected function checkAjaxNonce( array $request )
52 60
 	{
53
-		if( !is_user_logged_in() )return;
61
+		if( !is_user_logged_in() ) {
62
+			return;
63
+		}
54 64
 		if( !isset( $request['nonce'] )) {
55 65
 			$this->sendAjaxError( 'The request is missing a nonce', $request );
56 66
 		}
Please login to merge, or discard this patch.
compatibility.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,5 +9,5 @@
 block discarded – undo
9 9
  */
10 10
 add_filter( 'sbp_exclude_defer_scripts', function( $scriptHandles ) {
11 11
 	$scriptHandles[] = 'site-reviews/google-recaptcha';
12
-	return array_keys( array_flip( $scriptHandles ));
12
+	return array_keys( array_flip( $scriptHandles ) );
13 13
 });
Please login to merge, or discard this patch.