Passed
Push — master ( 992102...9c2a96 )
by Paul
04:54
created
plugin/Modules/Html/Partials/SiteReviews.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 				'navigation' => $navigation,
56 56
 			],
57 57
 			'reviews' => $this->buildReviews(),
58
-		]);
58
+		] );
59 59
 	}
60 60
 
61 61
 	/**
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 		$generatedReview = [];
84 84
 		foreach( $review as $key => $value ) {
85 85
 			$method = glsr( Helper::class )->buildMethodName( $key, 'buildOption' );
86
-			if( !method_exists( $this, $method ))continue;
86
+			if( !method_exists( $this, $method ) )continue;
87 87
 			$generatedReview[$key] = $this->$method( $key, $value );
88 88
 		}
89 89
 		return (object)$generatedReview;
@@ -96,12 +96,12 @@  discard block
 block discarded – undo
96 96
 	 */
97 97
 	protected function buildOptionAssignedTo( $key, $value )
98 98
 	{
99
-		if( $this->isHiddenOrEmpty( $key, 'settings.reviews.assigned_links.enabled' ))return;
100
-		$post = get_post( intval( $value ));
101
-		if( !( $post instanceof WP_Post ))return;
99
+		if( $this->isHiddenOrEmpty( $key, 'settings.reviews.assigned_links.enabled' ) )return;
100
+		$post = get_post( intval( $value ) );
101
+		if( !($post instanceof WP_Post) )return;
102 102
 		$permalink = glsr( Builder::class )->a( get_the_title( $post->ID ), [
103 103
 			'href' => get_the_permalink( $post->ID ),
104
-		]);
104
+		] );
105 105
 		$assignedTo = sprintf( __( 'Review of %s', 'site-reviews' ), $permalink );
106 106
 		return $this->wrap( $key, '<span>'.$assignedTo.'</span>' );
107 107
 	}
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 	 */
114 114
 	protected function buildOptionAuthor( $key, $value )
115 115
 	{
116
-		if( $this->isHidden( $key ))return;
116
+		if( $this->isHidden( $key ) )return;
117 117
 		$prefix = !$this->isOptionEnabled( 'settings.reviews.avatars.enabled' )
118 118
 			? apply_filters( 'site-reviews/review/author/prefix', '&mdash;' )
119 119
 			: '';
@@ -127,13 +127,13 @@  discard block
 block discarded – undo
127 127
 	 */
128 128
 	protected function buildOptionAvatar( $key, $value )
129 129
 	{
130
-		if( $this->isHidden( $key, 'settings.reviews.avatars.enabled' ))return;
130
+		if( $this->isHidden( $key, 'settings.reviews.avatars.enabled' ) )return;
131 131
 		$size = $this->getOption( 'settings.reviews.avatars.size', 40 );
132
-		return $this->wrap( $key, glsr( Builder::class )->img([
132
+		return $this->wrap( $key, glsr( Builder::class )->img( [
133 133
 			'src' => $this->generateAvatar( $value ),
134 134
 			'height' => $size,
135 135
 			'width' => $size,
136
-		]));
136
+		] ) );
137 137
 	}
138 138
 
139 139
 	/**
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	protected function buildOptionContent( $key, $value )
145 145
 	{
146 146
 		$text = $this->normalizeText( $value );
147
-		if( $this->isHiddenOrEmpty( $key, $text ))return;
147
+		if( $this->isHiddenOrEmpty( $key, $text ) )return;
148 148
 		return $this->wrap( $key, '<p>'.$text.'</p>' );
149 149
 	}
150 150
 
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	 */
156 156
 	protected function buildOptionDate( $key, $value )
157 157
 	{
158
-		if( $this->isHidden( $key ))return;
158
+		if( $this->isHidden( $key ) )return;
159 159
 		$dateFormat = $this->getOption( 'settings.reviews.date.format', 'default' );
160 160
 		if( $dateFormat == 'relative' ) {
161 161
 			$date = glsr( Date::class )->relative( $value );
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 			$format = $dateFormat == 'custom'
165 165
 				? $this->getOption( 'settings.reviews.date.custom', 'M j, Y' )
166 166
 				: (string)get_option( 'date_format' );
167
-			$date = date_i18n( $format, strtotime( $value ));
167
+			$date = date_i18n( $format, strtotime( $value ) );
168 168
 		}
169 169
 		return $this->wrap( $key, '<span>'.$date.'</span>' );
170 170
 	}
@@ -176,10 +176,10 @@  discard block
 block discarded – undo
176 176
 	 */
177 177
 	protected function buildOptionRating( $key, $value )
178 178
 	{
179
-		if( $this->isHiddenOrEmpty( $key, $value ))return;
179
+		if( $this->isHiddenOrEmpty( $key, $value ) )return;
180 180
 		$rating = glsr( Html::class )->buildPartial( 'star-rating', [
181 181
 			'rating' => $value,
182
-		]);
182
+		] );
183 183
 		return $this->wrap( $key, $rating );
184 184
 	}
185 185
 
@@ -190,8 +190,8 @@  discard block
 block discarded – undo
190 190
 	 */
191 191
 	protected function buildOptionResponse( $key, $value )
192 192
 	{
193
-		if( $this->isHiddenOrEmpty( $key, $value ))return;
194
-		$title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' ));
193
+		if( $this->isHiddenOrEmpty( $key, $value ) )return;
194
+		$title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' ) );
195 195
 		$text = $this->normalizeText( $value );
196 196
 		$text = '<p><strong>'.$title.'</strong></p><p>'.$text.'</p>';
197 197
 		return $this->wrap( $key,
@@ -207,8 +207,8 @@  discard block
 block discarded – undo
207 207
 	 */
208 208
 	protected function buildOptionTitle( $key, $value )
209 209
 	{
210
-		if( $this->isHidden( $key ))return;
211
-		if( empty( $value )) {
210
+		if( $this->isHidden( $key ) )return;
211
+		if( empty($value) ) {
212 212
 			$value = __( 'No Title', 'site-reviews' );
213 213
 		}
214 214
 		return $this->wrap( $key, '<h3>'.$value.'</h3>' );
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 			return $avatarUrl;
227 227
 		}
228 228
 		$authorIdOrEmail = get_the_author_meta( 'ID', $review->user_id );
229
-		if( empty( $authorIdOrEmail )) {
229
+		if( empty($authorIdOrEmail) ) {
230 230
 			$authorIdOrEmail = $review->email;
231 231
 		}
232 232
 		return (string)get_avatar_url( $authorIdOrEmail );
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 	 */
238 238
 	protected function generateSchema()
239 239
 	{
240
-		if( !wp_validate_boolean( $this->args['schema'] ))return;
240
+		if( !wp_validate_boolean( $this->args['schema'] ) )return;
241 241
 		glsr( Schema::class )->store(
242 242
 			glsr( Schema::class )->build( $this->args )
243 243
 		);
@@ -263,14 +263,14 @@  discard block
 block discarded – undo
263 263
 	{
264 264
 		$limit = $this->getOption( 'settings.reviews.excerpt.length', 55 );
265 265
 		if( str_word_count( $text, 0 ) > $limit ) {
266
-			$words = array_keys( str_word_count( $text, 2 ));
267
-			$excerpt = ltrim( substr( $text, 0, $words[$limit] ));
268
-			$hiddenText = substr( $text, strlen( $excerpt ));
266
+			$words = array_keys( str_word_count( $text, 2 ) );
267
+			$excerpt = ltrim( substr( $text, 0, $words[$limit] ) );
268
+			$hiddenText = substr( $text, strlen( $excerpt ) );
269 269
 			$showMore = glsr( Builder::class )->span( $hiddenText, [
270 270
 				'class' => 'glsr-hidden glsr-hidden-text',
271 271
 				'data-show-less' => __( 'Show less', 'site-reviews' ),
272 272
 				'data-show-more' => __( 'Show more', 'site-reviews' ),
273
-			]);
273
+			] );
274 274
 			$text = $excerpt.$showMore;
275 275
 		}
276 276
 		return nl2br( $text );
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 	 */
284 284
 	protected function getOption( $path, $fallback = '' )
285 285
 	{
286
-		if( array_key_exists( $path, $this->options )) {
286
+		if( array_key_exists( $path, $this->options ) ) {
287 287
 			return $this->options[$path];
288 288
 		}
289 289
 		return $fallback;
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
 	 */
297 297
 	protected function isHidden( $key, $path = '' )
298 298
 	{
299
-		$isOptionEnabled = !empty( $path )
299
+		$isOptionEnabled = !empty($path)
300 300
 			? $this->isOptionEnabled( $path )
301 301
 			: true;
302 302
 		return in_array( $key, $this->args['hide'] ) || !$isOptionEnabled;
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 	 */
310 310
 	protected function isHiddenOrEmpty( $key, $value )
311 311
 	{
312
-		return $this->isHidden( $key ) || empty( $value );
312
+		return $this->isHidden( $key ) || empty($value);
313 313
 	}
314 314
 
315 315
 	/**
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 	protected function normalizeText( $text )
329 329
 	{
330 330
 		$text = wp_kses( $text, wp_kses_allowed_html() );
331
-		$text = convert_smilies( wptexturize( strip_shortcodes( $text )));
331
+		$text = convert_smilies( wptexturize( strip_shortcodes( $text ) ) );
332 332
 		$text = str_replace( ']]>', ']]&gt;', $text );
333 333
 		$text = preg_replace( '/(\R){2,}/', '$1', $text );
334 334
 		return $this->isOptionEnabled( 'settings.reviews.excerpt.enabled' )
@@ -345,6 +345,6 @@  discard block
 block discarded – undo
345 345
 	{
346 346
 		return glsr( Builder::class )->div( $value, [
347 347
 			'class' => 'glsr-review-'.$key,
348
-		]);
348
+		] );
349 349
 	}
350 350
 }
Please login to merge, or discard this patch.
plugin/Modules/Html/Settings.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 			: $this->$method( $id );
24 24
 		return glsr( Template::class )->build( 'pages/settings/'.$id, [
25 25
 			'context' => $context,
26
-		]);
26
+		] );
27 27
 	}
28 28
 
29 29
 	/**
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	 */
32 32
 	protected function getFieldDefault( array $field )
33 33
 	{
34
-		return isset( $field['default'] )
34
+		return isset($field['default'])
35 35
 			? $field['default']
36 36
 			: '';
37 37
 	}
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	protected function getSettingFields( $path )
43 43
 	{
44 44
 		$settings = glsr( DefaultsManager::class )->settings();
45
-		return array_filter( $settings, function( $key ) use( $path ) {
45
+		return array_filter( $settings, function( $key ) use($path) {
46 46
 			return glsr( Helper::class )->startsWith( $path, $key );
47 47
 		}, ARRAY_FILTER_USE_KEY );
48 48
 	}
@@ -53,10 +53,10 @@  discard block
 block discarded – undo
53 53
 	 */
54 54
 	protected function getTemplateContext( $id )
55 55
 	{
56
-		$fields = $this->getSettingFields( $this->normalizeSettingPath( $id ));
56
+		$fields = $this->getSettingFields( $this->normalizeSettingPath( $id ) );
57 57
 		$rows = '';
58 58
 		foreach( $fields as $name => $field ) {
59
-			$rows.= new Field( $this->normalize( $field, $name ));
59
+			$rows .= new Field( $this->normalize( $field, $name ) );
60 60
 		}
61 61
 		return [
62 62
 			'rows' => $rows,
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	protected function getTemplateContextForTranslations()
70 70
 	{
71 71
 		$translations = glsr( Translator::class )->renderAll();
72
-		$class = empty( $translations )
72
+		$class = empty($translations)
73 73
 			? 'glsr-hidden'
74 74
 			: '';
75 75
 		return [
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 		$field = wp_parse_args( $field, [
89 89
 			'is_setting' => true,
90 90
 			'name' => $name,
91
-		]);
91
+		] );
92 92
 		$field = $this->normalizeLabel( $field );
93 93
 		$field = $this->normalizeValue( $field );
94 94
 		return $field;
@@ -99,9 +99,9 @@  discard block
 block discarded – undo
99 99
 	 */
100 100
 	protected function normalizeLabel( array $field )
101 101
 	{
102
-		if( isset( $field['label'] )) {
102
+		if( isset($field['label']) ) {
103 103
 			$field['legend'] = $field['label'];
104
-			unset( $field['label'] );
104
+			unset($field['label']);
105 105
 		}
106 106
 		else {
107 107
 			$field['is_valid'] = false;
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 	 */
116 116
 	protected function normalizeValue( array $field )
117 117
 	{
118
-		if( !isset( $field['value'] )) {
118
+		if( !isset($field['value']) ) {
119 119
 			$field['value'] = glsr( OptionManager::class )->get(
120 120
 				$field['name'],
121 121
 				$this->getFieldDefault( $field )
Please login to merge, or discard this patch.
plugin/Modules/Html/Field.php 2 patches
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_setting' => false,
27 27
 			'is_valid' => true,
28 28
 			'path' => '',
29
-		]);
29
+		] );
30 30
 		$this->normalize();
31 31
 	}
32 32
 
@@ -72,9 +72,9 @@  discard block
 block discarded – undo
72 72
 		return glsr( Template::class )->build( 'partials/form/field', [
73 73
 			'context' => [
74 74
 				'class' => $this->getFieldClass(),
75
-				'field' => glsr( Builder::class )->{$this->field['type']}( $this->field ),
75
+				'field' => glsr( Builder::class )->{$this->field['type']}($this->field),
76 76
 			],
77
-		]);
77
+		] );
78 78
 	}
79 79
 
80 80
 	/**
@@ -86,10 +86,10 @@  discard block
 block discarded – undo
86 86
 		return glsr( Template::class )->build( 'partials/form/table-row', [
87 87
 			'context' => [
88 88
 				'class' => $this->getFieldClass(),
89
-				'field' => glsr( Builder::class )->{$this->field['type']}( $this->field ),
89
+				'field' => glsr( Builder::class )->{$this->field['type']}($this->field),
90 90
 				'label' => glsr( Builder::class )->label( $this->field['legend'], ['for' => $this->field['id']] ),
91 91
 			],
92
-		]);
92
+		] );
93 93
 	}
94 94
 
95 95
 	/**
@@ -101,11 +101,11 @@  discard block
 block discarded – undo
101 101
 			'context' => [
102 102
 				'class' => $this->getFieldClass(),
103 103
 				'depends_on' => $this->getFieldDependsOn(),
104
-				'field' => glsr( Builder::class )->{$this->field['type']}( $this->field ),
104
+				'field' => glsr( Builder::class )->{$this->field['type']}($this->field),
105 105
 				'label' => glsr( Builder::class )->label( $this->field['legend'], ['for' => $this->field['id']] ),
106 106
 				'legend' => $this->field['legend'],
107 107
 			],
108
-		]);
108
+		] );
109 109
 	}
110 110
 
111 111
 	/**
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 		if( $this->field['is_hidden'] ) {
118 118
 			$classes[] = 'hidden';
119 119
 		}
120
-		if( !empty( $this->field['required'] )) {
120
+		if( !empty($this->field['required']) ) {
121 121
 			$classes[] = 'glsr-required';
122 122
 		}
123 123
 		return implode( ' ', $classes );
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 */
129 129
 	protected function getFieldDependsOn()
130 130
 	{
131
-		return !empty( $this->field['depends_on'] )
131
+		return !empty($this->field['depends_on'])
132 132
 			? $this->field['depends_on']
133 133
 			: '';
134 134
 	}
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 			$path,
155 155
 			glsr( Helper::class )->getPathValue( $path, glsr()->defaults )
156 156
 		);
157
-		if( is_array( $expectedValue )) {
157
+		if( is_array( $expectedValue ) ) {
158 158
 			return !in_array( $optionValue, $expectedValue );
159 159
 		}
160 160
 		return $optionValue != $expectedValue;
@@ -170,13 +170,13 @@  discard block
 block discarded – undo
170 170
 			'name', 'type',
171 171
 		];
172 172
 		foreach( $requiredValues as $value ) {
173
-			if( isset( $this->field[$value] ))continue;
173
+			if( isset($this->field[$value]) )continue;
174 174
 			$missingValues[] = $value;
175 175
 			$this->field['is_valid'] = false;
176 176
 		}
177
-		if( !empty( $missingValues )) {
177
+		if( !empty($missingValues) ) {
178 178
 			glsr_log()
179
-				->warning( 'Field is missing: '.implode( ', ', $missingValues ))
179
+				->warning( 'Field is missing: '.implode( ', ', $missingValues ) )
180 180
 				->info( $this->field );
181 181
 		}
182 182
 		return $this->field['is_valid'];
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	{
190 190
 		if( !$this->isFieldValid() )return;
191 191
 		$className = glsr( Helper::class )->buildClassName( $this->field['type'], __NAMESPACE__.'\Fields' );
192
-		if( class_exists( $className )) {
192
+		if( class_exists( $className ) ) {
193 193
 			$this->field = array_merge(
194 194
 				wp_parse_args( $this->field, $className::defaults() ),
195 195
 				$className::required()
@@ -206,13 +206,13 @@  discard block
 block discarded – undo
206 206
 	 */
207 207
 	protected function normalizeDependsOn()
208 208
 	{
209
-		if( empty( $this->field['depends_on'] ) || !is_array( $this->field['depends_on'] ))return;
209
+		if( empty($this->field['depends_on']) || !is_array( $this->field['depends_on'] ) )return;
210 210
 		$path = key( $this->field['depends_on'] );
211 211
 		$value = $this->field['depends_on'][$path];
212
-		$this->field['depends_on'] = json_encode([
212
+		$this->field['depends_on'] = json_encode( [
213 213
 			'name' => glsr( Helper::class )->convertPathToName( $path, $this->getFieldPrefix() ),
214 214
 			'value' => $value,
215
-		], JSON_HEX_APOS|JSON_HEX_QUOT );
215
+		], JSON_HEX_APOS | JSON_HEX_QUOT );
216 216
 		$this->field['is_hidden'] = $this->isFieldHidden( $path, $value );
217 217
 	}
218 218
 
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 	 */
222 222
 	protected function normalizeId()
223 223
 	{
224
-		if( isset( $this->field['id'] ) || $this->field['is_raw'] )return;
224
+		if( isset($this->field['id']) || $this->field['is_raw'] )return;
225 225
 		$this->field['id'] = glsr( Helper::class )->convertNameToId( $this->field['name'] );
226 226
 	}
227 227
 
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 	 */
243 243
 	protected function normalizeType()
244 244
 	{
245
-		if( in_array( $this->field['type'], static::MULTI_FIELD_TYPES )) {
245
+		if( in_array( $this->field['type'], static::MULTI_FIELD_TYPES ) ) {
246 246
 			$this->field['is_multi'] = true;
247 247
 		}
248 248
 	}
Please login to merge, or discard this patch.
Braces   +15 added lines, -5 removed lines patch added patch discarded remove patch
@@ -43,7 +43,9 @@  discard block
 block discarded – undo
43 43
 	 */
44 44
 	public function build()
45 45
 	{
46
-		if( !$this->field['is_valid'] )return;
46
+		if( !$this->field['is_valid'] ) {
47
+			return;
48
+		}
47 49
 		if( $this->field['is_raw'] ) {
48 50
 			return glsr( Builder::class )->hidden( $this->field );
49 51
 		}
@@ -170,7 +172,9 @@  discard block
 block discarded – undo
170 172
 			'name', 'type',
171 173
 		];
172 174
 		foreach( $requiredValues as $value ) {
173
-			if( isset( $this->field[$value] ))continue;
175
+			if( isset( $this->field[$value] )) {
176
+				continue;
177
+			}
174 178
 			$missingValues[] = $value;
175 179
 			$this->field['is_valid'] = false;
176 180
 		}
@@ -187,7 +191,9 @@  discard block
 block discarded – undo
187 191
 	 */
188 192
 	protected function normalize()
189 193
 	{
190
-		if( !$this->isFieldValid() )return;
194
+		if( !$this->isFieldValid() ) {
195
+			return;
196
+		}
191 197
 		$className = glsr( Helper::class )->buildClassName( $this->field['type'], __NAMESPACE__.'\Fields' );
192 198
 		if( class_exists( $className )) {
193 199
 			$this->field = array_merge(
@@ -206,7 +212,9 @@  discard block
 block discarded – undo
206 212
 	 */
207 213
 	protected function normalizeDependsOn()
208 214
 	{
209
-		if( empty( $this->field['depends_on'] ) || !is_array( $this->field['depends_on'] ))return;
215
+		if( empty( $this->field['depends_on'] ) || !is_array( $this->field['depends_on'] )) {
216
+			return;
217
+		}
210 218
 		$path = key( $this->field['depends_on'] );
211 219
 		$value = $this->field['depends_on'][$path];
212 220
 		$this->field['depends_on'] = json_encode([
@@ -221,7 +229,9 @@  discard block
 block discarded – undo
221 229
 	 */
222 230
 	protected function normalizeId()
223 231
 	{
224
-		if( isset( $this->field['id'] ) || $this->field['is_raw'] )return;
232
+		if( isset( $this->field['id'] ) || $this->field['is_raw'] ) {
233
+			return;
234
+		}
225 235
 		$this->field['id'] = glsr( Helper::class )->convertNameToId( $this->field['name'] );
226 236
 	}
227 237
 
Please login to merge, or discard this patch.