Passed
Push — hotfix/fix-counts ( 673622...5fa6b5 )
by Paul
05:31
created
plugin/Modules/Notification.php 2 patches
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 	public function __construct()
34 34
 	{
35 35
 		$types = glsr( OptionManager::class )->get( 'settings.general.notifications', [] );
36
-		$this->email = count( array_intersect( ['admin', 'custom'], $types )) > 0;
36
+		$this->email = count( array_intersect( ['admin', 'custom'], $types ) ) > 0;
37 37
 		$this->slack = in_array( 'slack', $types );
38 38
 		$this->types = $types;
39 39
 	}
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	 */
44 44
 	public function send( Review $review )
45 45
 	{
46
-		if( empty( $this->types ))return;
46
+		if( empty($this->types) )return;
47 47
 		$this->review = $review;
48 48
 		$args = [
49 49
 			'link' => $this->getLink(),
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	 */
59 59
 	protected function buildEmail( array $args )
60 60
 	{
61
-		return glsr( Email::class )->compose([
61
+		return glsr( Email::class )->compose( [
62 62
 			'to' => $this->getEmailAddresses(),
63 63
 			'subject' => $args['title'],
64 64
 			'template' => 'email-notification',
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 				'review_rating' => $this->review->rating,
72 72
 				'review_title' => $this->review->title,
73 73
 			],
74
-		]);
74
+		] );
75 75
 	}
76 76
 
77 77
 	/**
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 			'button_url' => $args['link'],
84 84
 			'fallback' => $this->buildEmail( $args )->read( 'plaintext' ),
85 85
 			'pretext' => $args['title'],
86
-		]);
86
+		] );
87 87
 	}
88 88
 
89 89
 	/**
@@ -92,23 +92,23 @@  discard block
 block discarded – undo
92 92
 	protected function getEmailAddresses()
93 93
 	{
94 94
 		$emails = [];
95
-		if( in_array( 'admin', $this->types )) {
95
+		if( in_array( 'admin', $this->types ) ) {
96 96
 			$emails[] = get_option( 'admin_email' );
97 97
 		}
98
-		if( in_array( 'author', $this->types )) {
99
-			$assignedPost = get_post( intval( $this->review->assigned_to ));
98
+		if( in_array( 'author', $this->types ) ) {
99
+			$assignedPost = get_post( intval( $this->review->assigned_to ) );
100 100
 			if( $assignedPost instanceof WP_Post ) {
101 101
 				$this->email = true;
102
-				$emails[] = get_the_author_meta( 'user_email', intval( $assignedPost->post_author ));
102
+				$emails[] = get_the_author_meta( 'user_email', intval( $assignedPost->post_author ) );
103 103
 			}
104 104
 		}
105
-		if( in_array( 'custom', $this->types )) {
105
+		if( in_array( 'custom', $this->types ) ) {
106 106
 			$customEmails = glsr( OptionManager::class )->get( 'settings.general.notification_email' );
107 107
 			$customEmails = str_replace( [' ', ',', ';'], ',', $customEmails );
108 108
 			$customEmails = explode( ',', $customEmails );
109 109
 			$emails = array_merge( $emails, $customEmails );
110 110
 		}
111
-		$emails = array_filter( array_keys( array_flip( $emails )));
111
+		$emails = array_filter( array_keys( array_flip( $emails ) ) );
112 112
 		return apply_filters( 'site-reviews/notification/emails', $emails, $this->review );
113 113
 	}
114 114
 
@@ -125,16 +125,16 @@  discard block
 block discarded – undo
125 125
 	 */
126 126
 	protected function getTitle()
127 127
 	{
128
-		$assignedTitle = get_the_title( intval( $this->review->assigned_to ));
128
+		$assignedTitle = get_the_title( intval( $this->review->assigned_to ) );
129 129
 		$title = _nx(
130 130
 			'New %s-star review',
131 131
 			'New %s-star review of: %s',
132
-			intval( empty( $assignedTitle )),
132
+			intval( empty($assignedTitle) ),
133 133
 			'This string differs depending on whether or not the review has been assigned to a post.',
134 134
 			'site-reviews'
135 135
 		);
136 136
 		$title = sprintf( '[%s] %s',
137
-			wp_specialchars_decode( strval( get_option( 'blogname' )), ENT_QUOTES ),
137
+			wp_specialchars_decode( strval( get_option( 'blogname' ) ), ENT_QUOTES ),
138 138
 			sprintf( $title, $this->review->rating, $assignedTitle )
139 139
 		);
140 140
 		return apply_filters( 'site-reviews/notification/title', $title, $this->review );
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 	protected function sendToEmail( array $args )
147 147
 	{
148 148
 		$email = $this->buildEmail( $args );
149
-		if( empty( $email->to )) {
149
+		if( empty($email->to) ) {
150 150
 			glsr_log()->error( 'Email notification was not sent (missing email address)' );
151 151
 			return;
152 152
 		}
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 		if( !$this->slack )return;
162 162
 		$notification = $this->buildSlackNotification( $args );
163 163
 		$result = $notification->send();
164
-		if( is_wp_error( $result )) {
164
+		if( is_wp_error( $result ) ) {
165 165
 			$notification->review = null;
166 166
 			glsr_log()->error( $result->get_error_message() )->debug( $notification );
167 167
 		}
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -43,7 +43,9 @@  discard block
 block discarded – undo
43 43
 	 */
44 44
 	public function send( Review $review )
45 45
 	{
46
-		if( empty( $this->types ))return;
46
+		if( empty( $this->types )) {
47
+			return;
48
+		}
47 49
 		$this->review = $review;
48 50
 		$args = [
49 51
 			'link' => $this->getLink(),
@@ -158,7 +160,9 @@  discard block
 block discarded – undo
158 160
 	 */
159 161
 	protected function sendToSlack( array $args )
160 162
 	{
161
-		if( !$this->slack )return;
163
+		if( !$this->slack ) {
164
+			return;
165
+		}
162 166
 		$notification = $this->buildSlackNotification( $args );
163 167
 		$result = $notification->send();
164 168
 		if( is_wp_error( $result )) {
Please login to merge, or discard this patch.
plugin/Modules/Html/Settings.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	 */
55 55
 	protected function getSettingFields( $path )
56 56
 	{
57
-		return array_filter( $this->settings, function( $key ) use( $path ) {
57
+		return array_filter( $this->settings, function( $key ) use($path) {
58 58
 			return glsr( Helper::class )->startsWith( $path, $key );
59 59
 		}, ARRAY_FILTER_USE_KEY );
60 60
 	}
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
 			$field = wp_parse_args( $field, [
70 70
 				'is_setting' => true,
71 71
 				'name' => $name,
72
-			]);
73
-			$rows.= new Field( $this->normalize( $field ));
72
+			] );
73
+			$rows .= new Field( $this->normalize( $field ) );
74 74
 		}
75 75
 		return $rows;
76 76
 	}
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 	 */
82 82
 	protected function getTemplateData( $id )
83 83
 	{
84
-		$fields = $this->getSettingFields( $this->normalizeSettingPath( $id ));
84
+		$fields = $this->getSettingFields( $this->normalizeSettingPath( $id ) );
85 85
 		return [
86 86
 			'context' => [
87 87
 				'rows' => $this->getSettingRows( $fields ),
@@ -95,12 +95,12 @@  discard block
 block discarded – undo
95 95
 	 */
96 96
 	protected function getTemplateDataForAddons( $id )
97 97
 	{
98
-		$fields = $this->getSettingFields( $this->normalizeSettingPath( $id ));
98
+		$fields = $this->getSettingFields( $this->normalizeSettingPath( $id ) );
99 99
 		$settings = glsr( Helper::class )->convertDotNotationArray( $fields );
100 100
 		$settingKeys = array_keys( $settings['settings']['addons'] );
101 101
 		$results = [];
102 102
 		foreach( $settingKeys as $key ) {
103
-			$addonFields = array_filter( $fields, function( $path ) use( $key ) {
103
+			$addonFields = array_filter( $fields, function( $path ) use($key) {
104 104
 				return glsr( Helper::class )->startsWith( 'settings.addons.'.$key, $path );
105 105
 			}, ARRAY_FILTER_USE_KEY );
106 106
 			$results[$key] = $this->getSettingRows( $addonFields );
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	 */
118 118
 	protected function getTemplateDataForLicenses( $id )
119 119
 	{
120
-		$fields = $this->getSettingFields( $this->normalizeSettingPath( $id ));
120
+		$fields = $this->getSettingFields( $this->normalizeSettingPath( $id ) );
121 121
 		ksort( $fields );
122 122
 		return [
123 123
 			'context' => [
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 	protected function getTemplateDataForTranslations()
133 133
 	{
134 134
 		$translations = glsr( Translation::class )->renderAll();
135
-		$class = empty( $translations )
135
+		$class = empty($translations)
136 136
 			? 'glsr-hidden'
137 137
 			: '';
138 138
 		return [
@@ -155,9 +155,9 @@  discard block
 block discarded – undo
155 155
 			$path,
156 156
 			glsr( Helper::class )->dataGet( glsr()->defaults, $path )
157 157
 		);
158
-		if( is_array( $expectedValue )) {
158
+		if( is_array( $expectedValue ) ) {
159 159
 			return is_array( $optionValue )
160
-				? count( array_intersect( $optionValue, $expectedValue )) === 0
160
+				? count( array_intersect( $optionValue, $expectedValue ) ) === 0
161 161
 				: !in_array( $optionValue, $expectedValue );
162 162
 		}
163 163
 		return $optionValue != $expectedValue;
@@ -168,10 +168,10 @@  discard block
 block discarded – undo
168 168
 	 */
169 169
 	protected function isMultiDependency( $path )
170 170
 	{
171
-		if( isset( $this->settings[$path] )) {
171
+		if( isset($this->settings[$path]) ) {
172 172
 			$field = $this->settings[$path];
173
-			return ( $field['type'] == 'checkbox' && !empty( $field['options'] ))
174
-				|| !empty( $field['multiple'] );
173
+			return ($field['type'] == 'checkbox' && !empty($field['options']))
174
+				|| !empty($field['multiple']);
175 175
 		}
176 176
 		return false;
177 177
 	}
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 	 */
193 193
 	protected function normalizeDependsOn( array $field )
194 194
 	{
195
-		if( !empty( $field['depends_on'] ) && is_array( $field['depends_on'] )) {
195
+		if( !empty($field['depends_on']) && is_array( $field['depends_on'] ) ) {
196 196
 			$isFieldHidden = false;
197 197
 			$conditions = [];
198 198
 			foreach( $field['depends_on'] as $path => $value ) {
@@ -200,11 +200,11 @@  discard block
 block discarded – undo
200 200
 					'name' => $this->getFieldNameForDependsOn( $path ),
201 201
 					'value' => $value,
202 202
 				];
203
-				if( $this->isFieldHidden( $path, $value )) {
203
+				if( $this->isFieldHidden( $path, $value ) ) {
204 204
 					$isFieldHidden = true;
205 205
 				}
206 206
 			}
207
-			$field['data-depends'] = json_encode( $conditions, JSON_HEX_APOS|JSON_HEX_QUOT );
207
+			$field['data-depends'] = json_encode( $conditions, JSON_HEX_APOS | JSON_HEX_QUOT );
208 208
 			$field['is_hidden'] = $isFieldHidden;
209 209
 		}
210 210
 		return $field;
@@ -215,9 +215,9 @@  discard block
 block discarded – undo
215 215
 	 */
216 216
 	protected function normalizeLabelAndLegend( array $field )
217 217
 	{
218
-		if( !empty( $field['label'] )) {
218
+		if( !empty($field['label']) ) {
219 219
 			$field['legend'] = $field['label'];
220
-			unset( $field['label'] );
220
+			unset($field['label']);
221 221
 		}
222 222
 		else {
223 223
 			$field['is_valid'] = false;
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 	 */
232 232
 	protected function normalizeValue( array $field )
233 233
 	{
234
-		if( !isset( $field['value'] )) {
234
+		if( !isset($field['value']) ) {
235 235
 			$field['value'] = glsr( OptionManager::class )->get(
236 236
 				$field['name'],
237 237
 				$this->getFieldDefault( $field )
Please login to merge, or discard this patch.
plugin/Modules/Html/Partials/SiteReviewsSummary.php 2 patches
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	{
35 35
 		$this->args = $args;
36 36
 		$this->ratingCounts = glsr( ReviewManager::class )->getRatingCounts( $args );
37
-		if( !array_sum( $this->ratingCounts ) && $this->isHidden( 'if_empty' ))return;
37
+		if( !array_sum( $this->ratingCounts ) && $this->isHidden( 'if_empty' ) )return;
38 38
 		$this->averageRating = glsr( Rating::class )->getAverage( $this->ratingCounts );
39 39
 		$this->generateSchema();
40 40
 		return glsr( Template::class )->build( 'templates/reviews-summary', [
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 				'stars' => $this->buildStars(),
49 49
 				'text' => $this->buildText(),
50 50
 			],
51
-		]);
51
+		] );
52 52
 	}
53 53
 
54 54
 	/**
@@ -56,9 +56,9 @@  discard block
 block discarded – undo
56 56
 	 */
57 57
 	protected function buildPercentage()
58 58
 	{
59
-		if( $this->isHidden( 'bars' ))return;
60
-		$percentages = preg_filter( '/$/', '%', glsr( Rating::class )->getPercentages( $this->ratingCounts ));
61
-		$bars = array_reduce( range( glsr()->constant( 'MAX_RATING', Rating::class ), 1 ), function( $carry, $level ) use( $percentages ) {
59
+		if( $this->isHidden( 'bars' ) )return;
60
+		$percentages = preg_filter( '/$/', '%', glsr( Rating::class )->getPercentages( $this->ratingCounts ) );
61
+		$bars = array_reduce( range( glsr()->constant( 'MAX_RATING', Rating::class ), 1 ), function( $carry, $level ) use($percentages) {
62 62
 			$label = $this->buildPercentageLabel( $this->args['labels'][$level] );
63 63
 			$background = $this->buildPercentageBackground( $percentages[$level] );
64 64
 			$count = apply_filters( 'site-reviews/summary/counts',
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 			$percent = $this->buildPercentageCount( $count );
69 69
 			return $carry.glsr( Builder::class )->div( $label.$background.$percent, [
70 70
 				'class' => 'glsr-bar',
71
-			]);
71
+			] );
72 72
 		});
73 73
 		return $this->wrap( 'percentage', $bars );
74 74
 	}
@@ -79,10 +79,10 @@  discard block
 block discarded – undo
79 79
 	 */
80 80
 	protected function buildPercentageBackground( $percent )
81 81
 	{
82
-		$backgroundPercent = glsr( Builder::class )->span([
82
+		$backgroundPercent = glsr( Builder::class )->span( [
83 83
 			'class' => 'glsr-bar-background-percent',
84 84
 			'style' => 'width:'.$percent,
85
-		]);
85
+		] );
86 86
 		return '<span class="glsr-bar-background">'.$backgroundPercent.'</span>';
87 87
 	}
88 88
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 	 */
110 110
 	protected function buildRating()
111 111
 	{
112
-		if( $this->isHidden( 'rating' ))return;
112
+		if( $this->isHidden( 'rating' ) )return;
113 113
 		return $this->wrap( 'rating', '<span>'.$this->averageRating.'</span>' );
114 114
 	}
115 115
 
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 	 */
119 119
 	protected function buildStars()
120 120
 	{
121
-		if( $this->isHidden( 'stars' ))return;
121
+		if( $this->isHidden( 'stars' ) )return;
122 122
 		$stars = glsr_star_rating( $this->averageRating );
123 123
 		return $this->wrap( 'stars', $stars );
124 124
 	}
@@ -128,9 +128,9 @@  discard block
 block discarded – undo
128 128
 	 */
129 129
 	protected function buildText()
130 130
 	{
131
-		if( $this->isHidden( 'summary' ))return;
132
-		$count = intval( array_sum( $this->ratingCounts ));
133
-		if( empty( $this->args['text'] )) {
131
+		if( $this->isHidden( 'summary' ) )return;
132
+		$count = intval( array_sum( $this->ratingCounts ) );
133
+		if( empty($this->args['text']) ) {
134 134
 			// @todo document this change
135 135
 			 $this->args['text'] = _nx(
136 136
 				'{rating} out of {max} stars (based on {num} review)',
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 			);
142 142
 		}
143 143
 		$summary = str_replace(
144
-			['{rating}','{max}', '{num}'],
144
+			['{rating}', '{max}', '{num}'],
145 145
 			[$this->averageRating, glsr()->constant( 'MAX_RATING', Rating::class ), $count],
146 146
 			$this->args['text']
147 147
 		);
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 	 */
154 154
 	protected function generateSchema()
155 155
 	{
156
-		if( !wp_validate_boolean( $this->args['schema'] ))return;
156
+		if( !wp_validate_boolean( $this->args['schema'] ) )return;
157 157
 		glsr( Schema::class )->store(
158 158
 			glsr( Schema::class )->buildSummary( $this->args )
159 159
 		);
@@ -185,6 +185,6 @@  discard block
 block discarded – undo
185 185
 	{
186 186
 		return glsr( Builder::class )->div( $value, [
187 187
 			'class' => 'glsr-summary-'.$key,
188
-		]);
188
+		] );
189 189
 	}
190 190
 }
Please login to merge, or discard this patch.
Braces   +18 added lines, -6 removed lines patch added patch discarded remove patch
@@ -34,7 +34,9 @@  discard block
 block discarded – undo
34 34
 	{
35 35
 		$this->args = $args;
36 36
 		$this->ratingCounts = glsr( ReviewManager::class )->getRatingCounts( $args );
37
-		if( !array_sum( $this->ratingCounts ) && $this->isHidden( 'if_empty' ))return;
37
+		if( !array_sum( $this->ratingCounts ) && $this->isHidden( 'if_empty' )) {
38
+			return;
39
+		}
38 40
 		$this->averageRating = glsr( Rating::class )->getAverage( $this->ratingCounts );
39 41
 		$this->generateSchema();
40 42
 		return glsr( Template::class )->build( 'templates/reviews-summary', [
@@ -56,7 +58,9 @@  discard block
 block discarded – undo
56 58
 	 */
57 59
 	protected function buildPercentage()
58 60
 	{
59
-		if( $this->isHidden( 'bars' ))return;
61
+		if( $this->isHidden( 'bars' )) {
62
+			return;
63
+		}
60 64
 		$percentages = preg_filter( '/$/', '%', glsr( Rating::class )->getPercentages( $this->ratingCounts ));
61 65
 		$bars = array_reduce( range( glsr()->constant( 'MAX_RATING', Rating::class ), 1 ), function( $carry, $level ) use( $percentages ) {
62 66
 			$label = $this->buildPercentageLabel( $this->args['labels'][$level] );
@@ -109,7 +113,9 @@  discard block
 block discarded – undo
109 113
 	 */
110 114
 	protected function buildRating()
111 115
 	{
112
-		if( $this->isHidden( 'rating' ))return;
116
+		if( $this->isHidden( 'rating' )) {
117
+			return;
118
+		}
113 119
 		return $this->wrap( 'rating', '<span>'.$this->averageRating.'</span>' );
114 120
 	}
115 121
 
@@ -118,7 +124,9 @@  discard block
 block discarded – undo
118 124
 	 */
119 125
 	protected function buildStars()
120 126
 	{
121
-		if( $this->isHidden( 'stars' ))return;
127
+		if( $this->isHidden( 'stars' )) {
128
+			return;
129
+		}
122 130
 		$stars = glsr_star_rating( $this->averageRating );
123 131
 		return $this->wrap( 'stars', $stars );
124 132
 	}
@@ -128,7 +136,9 @@  discard block
 block discarded – undo
128 136
 	 */
129 137
 	protected function buildText()
130 138
 	{
131
-		if( $this->isHidden( 'summary' ))return;
139
+		if( $this->isHidden( 'summary' )) {
140
+			return;
141
+		}
132 142
 		$count = intval( array_sum( $this->ratingCounts ));
133 143
 		if( empty( $this->args['text'] )) {
134 144
 			// @todo document this change
@@ -153,7 +163,9 @@  discard block
 block discarded – undo
153 163
 	 */
154 164
 	protected function generateSchema()
155 165
 	{
156
-		if( !wp_validate_boolean( $this->args['schema'] ))return;
166
+		if( !wp_validate_boolean( $this->args['schema'] )) {
167
+			return;
168
+		}
157 169
 		glsr( Schema::class )->store(
158 170
 			glsr( Schema::class )->buildSummary( $this->args )
159 171
 		);
Please login to merge, or discard this patch.
plugin/Modules/Schema.php 2 patches
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -38,10 +38,10 @@  discard block
 block discarded – undo
38 38
 			if( $review->review_type != 'local' )continue;
39 39
 			$reviews[] = $this->buildReview( $review );
40 40
 		}
41
-		if( !empty( $reviews )) {
41
+		if( !empty($reviews) ) {
42 42
 			array_walk( $reviews, function( &$review ) {
43
-				unset( $review['@context'] );
44
-				unset( $review['itemReviewed'] );
43
+				unset($review['@context']);
44
+				unset($review['itemReviewed']);
45 45
 			});
46 46
 			$schema['review'] = $reviews;
47 47
 		}
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	 */
55 55
 	public function buildSummary( $args = null )
56 56
 	{
57
-		if( is_array( $args )) {
57
+		if( is_array( $args ) ) {
58 58
 			$this->args = $args;
59 59
 		}
60 60
 		$buildSummary = glsr( Helper::class )->buildMethodName( $this->getSchemaOptionValue( 'type' ), 'buildSummaryFor' );
@@ -62,13 +62,13 @@  discard block
 block discarded – undo
62 62
 		$schema = method_exists( $this, $buildSummary )
63 63
 			? $this->$buildSummary()
64 64
 			: $this->buildSummaryForCustom();
65
-		if( !empty( $count )) {
65
+		if( !empty($count) ) {
66 66
 			$schema->aggregateRating(
67 67
 				$this->getSchemaType( 'AggregateRating' )
68 68
 					->ratingValue( $this->getRatingValue() )
69 69
 					->reviewCount( $count )
70
-					->bestRating( glsr()->constant( 'MAX_RATING', Rating::class ))
71
-					->worstRating( glsr()->constant( 'MIN_RATING', Rating::class ))
70
+					->bestRating( glsr()->constant( 'MAX_RATING', Rating::class ) )
71
+					->worstRating( glsr()->constant( 'MIN_RATING', Rating::class ) )
72 72
 			);
73 73
 		}
74 74
 		$schema = $schema->toArray();
@@ -80,11 +80,11 @@  discard block
 block discarded – undo
80 80
 	 */
81 81
 	public function render()
82 82
 	{
83
-		if( empty( glsr()->schemas ))return;
83
+		if( empty(glsr()->schemas) )return;
84 84
 		printf( '<script type="application/ld+json">%s</script>', json_encode(
85 85
 			apply_filters( 'site-reviews/schema/all', glsr()->schemas ),
86 86
 			JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES
87
-		));
87
+		) );
88 88
 	}
89 89
 
90 90
 	/**
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	{
95 95
 		$schemas = glsr()->schemas;
96 96
 		$schemas[] = $schema;
97
-		glsr()->schemas = array_map( 'unserialize', array_unique( array_map( 'serialize', $schemas )));
97
+		glsr()->schemas = array_map( 'unserialize', array_unique( array_map( 'serialize', $schemas ) ) );
98 98
 	}
99 99
 
100 100
 	/**
@@ -104,21 +104,21 @@  discard block
 block discarded – undo
104 104
 	protected function buildReview( $review )
105 105
 	{
106 106
 		$schema = $this->getSchemaType( 'Review' )
107
-			->doIf( !in_array( 'title', $this->args['hide'] ), function( $schema ) use( $review ) {
107
+			->doIf( !in_array( 'title', $this->args['hide'] ), function( $schema ) use($review) {
108 108
 				$schema->name( $review->title );
109 109
 			})
110
-			->doIf( !in_array( 'excerpt', $this->args['hide'] ), function( $schema ) use( $review ) {
110
+			->doIf( !in_array( 'excerpt', $this->args['hide'] ), function( $schema ) use($review) {
111 111
 				$schema->reviewBody( $review->content );
112 112
 			})
113
-			->datePublished(( new DateTime( $review->date )))
114
-			->author( $this->getSchemaType( 'Person' )->name( $review->author ))
115
-			->itemReviewed( $this->getSchemaType()->name( $this->getSchemaOptionValue( 'name' )));
116
-		if( !empty( $review->rating )) {
113
+			->datePublished( (new DateTime( $review->date )) )
114
+			->author( $this->getSchemaType( 'Person' )->name( $review->author ) )
115
+			->itemReviewed( $this->getSchemaType()->name( $this->getSchemaOptionValue( 'name' ) ) );
116
+		if( !empty($review->rating) ) {
117 117
 			$schema->reviewRating(
118 118
 				$this->getSchemaType( 'Rating' )
119 119
 					->ratingValue( $review->rating )
120
-					->bestRating( glsr()->constant( 'MAX_RATING', Rating::class ))
121
-					->worstRating( glsr()->constant( 'MIN_RATING', Rating::class ))
120
+					->bestRating( glsr()->constant( 'MAX_RATING', Rating::class ) )
121
+					->worstRating( glsr()->constant( 'MIN_RATING', Rating::class ) )
122 122
 			);
123 123
 		}
124 124
 		return apply_filters( 'site-reviews/schema/review', $schema->toArray(), $review, $this->args );
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 	{
133 133
 		foreach( $values as $value ) {
134 134
 			$option = $this->getSchemaOptionValue( $value );
135
-			if( empty( $option ))continue;
135
+			if( empty($option) )continue;
136 136
 			$schema->$value( $option );
137 137
 		}
138 138
 		return $schema;
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	{
146 146
 		return $this->buildSchemaValues( $this->getSchemaType(), [
147 147
 			'description', 'image', 'name', 'url',
148
-		]);
148
+		] );
149 149
 	}
150 150
 
151 151
 	/**
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	{
156 156
 		return $this->buildSchemaValues( $this->buildSummaryForCustom(), [
157 157
 			'address', 'priceRange', 'telephone',
158
-		]);
158
+		] );
159 159
 	}
160 160
 
161 161
 	/**
@@ -166,9 +166,9 @@  discard block
 block discarded – undo
166 166
 		$offerType = $this->getSchemaOption( 'offerType', 'AggregateOffer' );
167 167
 		$offers = $this->buildSchemaValues( $this->getSchemaType( $offerType ), [
168 168
 			'highPrice', 'lowPrice', 'price', 'priceCurrency',
169
-		]);
169
+		] );
170 170
 		return $this->buildSummaryForCustom()
171
-			->doIf( !empty( $offers->getProperties() ), function( $schema ) use( $offers ) {
171
+			->doIf( !empty($offers->getProperties()), function( $schema ) use($offers) {
172 172
 				$schema->offers( $offers );
173 173
 			})
174 174
 			->setProperty( '@id', $this->getSchemaOptionValue( 'url' ).'#product' );
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	 */
180 180
 	protected function getRatingCounts()
181 181
 	{
182
-		if( !isset( $this->ratingCounts )) {
182
+		if( !isset($this->ratingCounts) ) {
183 183
 			$this->ratingCounts = glsr( ReviewManager::class )->getRatingCounts( $this->args );
184 184
 		}
185 185
 		return $this->ratingCounts;
@@ -201,14 +201,14 @@  discard block
 block discarded – undo
201 201
 	protected function getSchemaOption( $option, $fallback )
202 202
 	{
203 203
 		$option = strtolower( $option );
204
-		if( $schemaOption = trim( (string)get_post_meta( intval( get_the_ID() ), 'schema_'.$option, true ))) {
204
+		if( $schemaOption = trim( (string)get_post_meta( intval( get_the_ID() ), 'schema_'.$option, true ) ) ) {
205 205
 			return $schemaOption;
206 206
 		}
207 207
 		$setting = glsr( OptionManager::class )->get( 'settings.schema.'.$option );
208
-		if( is_array( $setting )) {
208
+		if( is_array( $setting ) ) {
209 209
 			return $this->getSchemaOptionDefault( $setting, $fallback );
210 210
 		}
211
-		return !empty( $setting )
211
+		return !empty($setting)
212 212
 			? $setting
213 213
 			: $fallback;
214 214
 	}
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 		$setting = wp_parse_args( $setting, [
223 223
 			'custom' => '',
224 224
 			'default' => $fallback,
225
-		]);
225
+		] );
226 226
 		return $setting['default'] != 'custom'
227 227
 			? $setting['default']
228 228
 			: $setting['custom'];
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 		}
242 242
 		if( !is_single() && !is_page() )return;
243 243
 		$method = glsr( Helper::class )->buildMethodName( $option, 'getThing' );
244
-		if( method_exists( $this, $method )) {
244
+		if( method_exists( $this, $method ) ) {
245 245
 			return $this->$method();
246 246
 		}
247 247
 	}
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 	 */
253 253
 	protected function getSchemaType( $type = null )
254 254
 	{
255
-		if( !is_string( $type )) {
255
+		if( !is_string( $type ) ) {
256 256
 			$type = $this->getSchemaOption( 'type', 'LocalBusiness' );
257 257
 		}
258 258
 		$className = glsr( Helper::class )->buildClassName( $type, 'Modules\Schema' );
@@ -267,11 +267,11 @@  discard block
 block discarded – undo
267 267
 	protected function getThingDescription()
268 268
 	{
269 269
 		$post = get_post();
270
-		if( !( $post instanceof WP_Post )) {
270
+		if( !($post instanceof WP_Post) ) {
271 271
 			return '';
272 272
 		}
273
-		$text = strip_shortcodes( wp_strip_all_tags( $post->post_excerpt ));
274
-		return wp_trim_words( $text, apply_filters( 'excerpt_length', 55 ));
273
+		$text = strip_shortcodes( wp_strip_all_tags( $post->post_excerpt ) );
274
+		return wp_trim_words( $text, apply_filters( 'excerpt_length', 55 ) );
275 275
 	}
276 276
 
277 277
 	/**
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -35,7 +35,9 @@  discard block
 block discarded – undo
35 35
 		foreach( glsr( ReviewManager::class )->get( $this->args ) as $review ) {
36 36
 			// Only include critic reviews that have been directly produced by your site, not reviews from third-party sites or syndicated reviews.
37 37
 			// @see https://developers.google.com/search/docs/data-types/review
38
-			if( $review->review_type != 'local' )continue;
38
+			if( $review->review_type != 'local' ) {
39
+				continue;
40
+			}
39 41
 			$reviews[] = $this->buildReview( $review );
40 42
 		}
41 43
 		if( !empty( $reviews )) {
@@ -80,7 +82,9 @@  discard block
 block discarded – undo
80 82
 	 */
81 83
 	public function render()
82 84
 	{
83
-		if( empty( glsr()->schemas ))return;
85
+		if( empty( glsr()->schemas )) {
86
+			return;
87
+		}
84 88
 		printf( '<script type="application/ld+json">%s</script>', json_encode(
85 89
 			apply_filters( 'site-reviews/schema/all', glsr()->schemas ),
86 90
 			JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES
@@ -132,7 +136,9 @@  discard block
 block discarded – undo
132 136
 	{
133 137
 		foreach( $values as $value ) {
134 138
 			$option = $this->getSchemaOptionValue( $value );
135
-			if( empty( $option ))continue;
139
+			if( empty( $option )) {
140
+				continue;
141
+			}
136 142
 			$schema->$value( $option );
137 143
 		}
138 144
 		return $schema;
@@ -239,7 +245,9 @@  discard block
 block discarded – undo
239 245
 		if( $value != $fallback ) {
240 246
 			return $value;
241 247
 		}
242
-		if( !is_single() && !is_page() )return;
248
+		if( !is_single() && !is_page() ) {
249
+			return;
250
+		}
243 251
 		$method = glsr( Helper::class )->buildMethodName( $option, 'getThing' );
244 252
 		if( method_exists( $this, $method )) {
245 253
 			return $this->$method();
Please login to merge, or discard this patch.
plugin/Modules/System.php 2 patches
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 			'setting' => 'Plugin Settings',
41 41
 			'reviews' => 'Review Counts',
42 42
 		];
43
-		$systemInfo = array_reduce( array_keys( $details ), function( $carry, $key ) use( $details ) {
43
+		$systemInfo = array_reduce( array_keys( $details ), function( $carry, $key ) use($details) {
44 44
 			$methodName = glsr( Helper::class )->buildMethodName( 'get-'.$key.'-details' );
45 45
 			if( method_exists( $this, $methodName ) && $systemDetails = $this->$methodName() ) {
46 46
 				return $carry.$this->implode(
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
 	{
61 61
 		$plugins = get_plugins();
62 62
 		$activePlugins = (array)get_option( 'active_plugins', [] );
63
-		$inactive = array_diff_key( $plugins, array_flip( $activePlugins ));
64
-		return $this->normalizePluginList( array_diff_key( $plugins, $inactive ));
63
+		$inactive = array_diff_key( $plugins, array_flip( $activePlugins ) );
64
+		return $this->normalizePluginList( array_diff_key( $plugins, $inactive ) );
65 65
 	}
66 66
 
67 67
 	/**
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	public function getInactivePluginDetails()
96 96
 	{
97 97
 		$activePlugins = (array)get_option( 'active_plugins', [] );
98
-		$inactivePlugins = $this->normalizePluginList( array_diff_key( get_plugins(), array_flip( $activePlugins )));
98
+		$inactivePlugins = $this->normalizePluginList( array_diff_key( get_plugins(), array_flip( $activePlugins ) ) );
99 99
 		$multisitePlugins = $this->getMultisitePluginDetails();
100 100
 		return is_array( $multisitePlugins )
101 101
 			? array_diff( $inactivePlugins, $multisitePlugins )
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	 */
108 108
 	public function getMuPluginDetails()
109 109
 	{
110
-		if( empty( $plugins = get_mu_plugins() ))return;
110
+		if( empty($plugins = get_mu_plugins()) )return;
111 111
 		return $this->normalizePluginList( $plugins );
112 112
 	}
113 113
 
@@ -117,8 +117,8 @@  discard block
 block discarded – undo
117 117
 	public function getMultisitePluginDetails()
118 118
 	{
119 119
 		$activePlugins = (array)get_site_option( 'active_sitewide_plugins', [] );
120
-		if( !is_multisite() || empty( $activePlugins ))return;
121
-		return $this->normalizePluginList( array_intersect_key( get_plugins(), $activePlugins ));
120
+		if( !is_multisite() || empty($activePlugins) )return;
121
+		return $this->normalizePluginList( array_intersect_key( get_plugins(), $activePlugins ) );
122 122
 	}
123 123
 
124 124
 	/**
@@ -145,11 +145,11 @@  discard block
 block discarded – undo
145 145
 			'Memory Limit' => ini_get( 'memory_limit' ),
146 146
 			'Post Max Size' => ini_get( 'post_max_size' ),
147 147
 			'Sendmail Path' => ini_get( 'sendmail_path' ),
148
-			'Session Cookie Path' => esc_html( ini_get( 'session.cookie_path' )),
149
-			'Session Name' => esc_html( ini_get( 'session.name' )),
150
-			'Session Save Path' => esc_html( ini_get( 'session.save_path' )),
151
-			'Session Use Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_cookies' )), true ),
152
-			'Session Use Only Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_only_cookies' )), true ),
148
+			'Session Cookie Path' => esc_html( ini_get( 'session.cookie_path' ) ),
149
+			'Session Name' => esc_html( ini_get( 'session.name' ) ),
150
+			'Session Save Path' => esc_html( ini_get( 'session.save_path' ) ),
151
+			'Session Use Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_cookies' ) ), true ),
152
+			'Session Use Only Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_only_cookies' ) ), true ),
153 153
 			'Upload Max Filesize' => ini_get( 'upload_max_filesize' ),
154 154
 		];
155 155
 	}
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
 	{
162 162
 		$counts = glsr( CountsManager::class )->getCounts();
163 163
 		$counts = glsr( Helper::class )->flattenArray( $counts );
164
- 		array_walk( $counts, function( &$ratings ) use( $counts ) {
165
-			if( !is_array( $ratings )) {
164
+ 		array_walk( $counts, function( &$ratings ) use($counts) {
165
+			if( !is_array( $ratings ) ) {
166 166
 				glsr_log()
167 167
 					->error( '$ratings is not an array, possibly due to incorrectly imported reviews.' )
168 168
 					->debug( $ratings )
@@ -201,8 +201,8 @@  discard block
 block discarded – undo
201 201
 		ksort( $settings );
202 202
 		$details = [];
203 203
 		foreach( $settings as $key => $value ) {
204
-			if( $helper->startsWith( 'strings', $key ) && $helper->endsWith( 'id', $key ))continue;
205
-			$value = htmlspecialchars( trim( preg_replace('/\s\s+/', '\\n', $value )), ENT_QUOTES, 'UTF-8' );
204
+			if( $helper->startsWith( 'strings', $key ) && $helper->endsWith( 'id', $key ) )continue;
205
+			$value = htmlspecialchars( trim( preg_replace( '/\s\s+/', '\\n', $value ) ), ENT_QUOTES, 'UTF-8' );
206 206
 			$details[$key] = $value;
207 207
 		}
208 208
 		return $details;
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 		return [
217 217
 			'Console level' => glsr( Console::class )->humanLevel(),
218 218
 			'Console size' => glsr( Console::class )->humanSize( '0' ),
219
-			'Last Rating Count' => date_i18n( 'Y-m-d H:i', glsr( OptionManager::class )->get( 'last_review_count' )),
219
+			'Last Rating Count' => date_i18n( 'Y-m-d H:i', glsr( OptionManager::class )->get( 'last_review_count' ) ),
220 220
 			'Version (current)' => glsr()->version,
221 221
 			'Version (previous)' => glsr( OptionManager::class )->get( 'version_upgraded_from' ),
222 222
 		];
@@ -277,10 +277,10 @@  discard block
 block discarded – undo
277 277
 			'WPE_APIKEY' => 'WP Engine',
278 278
 		];
279 279
 		foreach( $checks as $key => $value ) {
280
-			if( !$this->isWebhostCheckValid( $key ))continue;
280
+			if( !$this->isWebhostCheckValid( $key ) )continue;
281 281
 			return $value;
282 282
 		}
283
-		return implode( ',', array_filter( [DB_HOST, filter_input( INPUT_SERVER, 'SERVER_NAME' )] ));
283
+		return implode( ',', array_filter( [DB_HOST, filter_input( INPUT_SERVER, 'SERVER_NAME' )] ) );
284 284
 	}
285 285
 
286 286
 	/**
@@ -301,8 +301,8 @@  discard block
 block discarded – undo
301 301
 	{
302 302
 		$plugins = get_plugins();
303 303
 		$activePlugins = (array)get_option( 'active_plugins', [] );
304
-		$inactive = $this->normalizePluginList( array_diff_key( $plugins, array_flip( $activePlugins )));
305
-		$active = $this->normalizePluginList( array_diff_key( $plugins, $inactive ));
304
+		$inactive = $this->normalizePluginList( array_diff_key( $plugins, array_flip( $activePlugins ) ) );
305
+		$active = $this->normalizePluginList( array_diff_key( $plugins, $inactive ) );
306 306
 		return $active + $inactive;
307 307
 	}
308 308
 
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
 	protected function implode( $title, array $details )
314 314
 	{
315 315
 		$strings = ['['.$title.']'];
316
-		$padding = max( array_map( 'strlen', array_keys( $details )) );
316
+		$padding = max( array_map( 'strlen', array_keys( $details ) ) );
317 317
 		$padding = max( [$padding, static::PAD] );
318 318
 		foreach( $details as $key => $value ) {
319 319
 			$strings[] = is_string( $key )
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 	protected function normalizePluginList( array $plugins )
343 343
 	{
344 344
 		$plugins = array_map( function( $plugin ) {
345
-			return sprintf( '%s v%s', glsr_get( $plugin, 'Name' ), glsr_get( $plugin, 'Version' ));
345
+			return sprintf( '%s v%s', glsr_get( $plugin, 'Name' ), glsr_get( $plugin, 'Version' ) );
346 346
 		}, $plugins );
347 347
 		natcasesort( $plugins );
348 348
 		return array_flip( $plugins );
@@ -356,9 +356,9 @@  discard block
 block discarded – undo
356 356
 		$keys = [
357 357
 			'licenses.', 'submissions.recaptcha.key', 'submissions.recaptcha.secret',
358 358
 		];
359
-		array_walk( $settings, function( &$value, $setting ) use( $keys ) {
359
+		array_walk( $settings, function( &$value, $setting ) use($keys) {
360 360
 			foreach( $keys as $key ) {
361
-				if( !glsr( Helper::class )->startsWith( $key, $setting ) || empty( $value ))continue;
361
+				if( !glsr( Helper::class )->startsWith( $key, $setting ) || empty($value) )continue;
362 362
 				$value = str_repeat( '•', 13 );
363 363
 				return;
364 364
 			}
Please login to merge, or discard this patch.
Braces   +15 added lines, -5 removed lines patch added patch discarded remove patch
@@ -107,7 +107,9 @@  discard block
 block discarded – undo
107 107
 	 */
108 108
 	public function getMuPluginDetails()
109 109
 	{
110
-		if( empty( $plugins = get_mu_plugins() ))return;
110
+		if( empty( $plugins = get_mu_plugins() )) {
111
+			return;
112
+		}
111 113
 		return $this->normalizePluginList( $plugins );
112 114
 	}
113 115
 
@@ -117,7 +119,9 @@  discard block
 block discarded – undo
117 119
 	public function getMultisitePluginDetails()
118 120
 	{
119 121
 		$activePlugins = (array)get_site_option( 'active_sitewide_plugins', [] );
120
-		if( !is_multisite() || empty( $activePlugins ))return;
122
+		if( !is_multisite() || empty( $activePlugins )) {
123
+			return;
124
+		}
121 125
 		return $this->normalizePluginList( array_intersect_key( get_plugins(), $activePlugins ));
122 126
 	}
123 127
 
@@ -201,7 +205,9 @@  discard block
 block discarded – undo
201 205
 		ksort( $settings );
202 206
 		$details = [];
203 207
 		foreach( $settings as $key => $value ) {
204
-			if( $helper->startsWith( 'strings', $key ) && $helper->endsWith( 'id', $key ))continue;
208
+			if( $helper->startsWith( 'strings', $key ) && $helper->endsWith( 'id', $key )) {
209
+				continue;
210
+			}
205 211
 			$value = htmlspecialchars( trim( preg_replace('/\s\s+/', '\\n', $value )), ENT_QUOTES, 'UTF-8' );
206 212
 			$details[$key] = $value;
207 213
 		}
@@ -277,7 +283,9 @@  discard block
 block discarded – undo
277 283
 			'WPE_APIKEY' => 'WP Engine',
278 284
 		];
279 285
 		foreach( $checks as $key => $value ) {
280
-			if( !$this->isWebhostCheckValid( $key ))continue;
286
+			if( !$this->isWebhostCheckValid( $key )) {
287
+				continue;
288
+			}
281 289
 			return $value;
282 290
 		}
283 291
 		return implode( ',', array_filter( [DB_HOST, filter_input( INPUT_SERVER, 'SERVER_NAME' )] ));
@@ -358,7 +366,9 @@  discard block
 block discarded – undo
358 366
 		];
359 367
 		array_walk( $settings, function( &$value, $setting ) use( $keys ) {
360 368
 			foreach( $keys as $key ) {
361
-				if( !glsr( Helper::class )->startsWith( $key, $setting ) || empty( $value ))continue;
369
+				if( !glsr( Helper::class )->startsWith( $key, $setting ) || empty( $value )) {
370
+					continue;
371
+				}
362 372
 				$value = str_repeat( '•', 13 );
363 373
 				return;
364 374
 			}
Please login to merge, or discard this patch.
plugin/Modules/Slack.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 */
36 36
 	public function compose( Review $review, array $notification )
37 37
 	{
38
-		if( empty( $this->endpoint )) {
38
+		if( empty($this->endpoint) ) {
39 39
 			return $this;
40 40
 		}
41 41
 		$args = shortcode_atts( glsr( SlackDefaults::class )->defaults(), $notification );
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	 */
61 61
 	public function send()
62 62
 	{
63
-		if( empty( $this->endpoint )) {
63
+		if( empty($this->endpoint) ) {
64 64
 			return new WP_Error( 'slack', 'Slack notification was not sent: missing endpoint' );
65 65
 		}
66 66
 		return wp_remote_post( $this->endpoint, [
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 			'redirection' => 5,
73 73
 			'sslverify' => false,
74 74
 			'timeout' => 45,
75
-		]);
75
+		] );
76 76
 	}
77 77
 
78 78
 	/**
@@ -92,11 +92,11 @@  discard block
 block discarded – undo
92 92
 	 */
93 93
 	protected function buildAuthorField()
94 94
 	{
95
-		$email = !empty( $this->review->email )
95
+		$email = !empty($this->review->email)
96 96
 			? '<'.$this->review->email.'>'
97 97
 			: '';
98 98
 		$author = trim( rtrim( $this->review->author ).' '.$email );
99
-		return ['value' => implode( ' - ', array_filter( [$author, $this->review->ip_address] ))];
99
+		return ['value' => implode( ' - ', array_filter( [$author, $this->review->ip_address] ) )];
100 100
 	}
101 101
 
102 102
 	/**
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 	 */
105 105
 	protected function buildContentField()
106 106
 	{
107
-		return !empty( $this->review->content )
107
+		return !empty($this->review->content)
108 108
 			? ['value' => $this->review->content]
109 109
 			: [];
110 110
 	}
@@ -129,9 +129,9 @@  discard block
 block discarded – undo
129 129
 	protected function buildStarsField()
130 130
 	{
131 131
 		$solidStars = str_repeat( '★', $this->review->rating );
132
-		$emptyStars = str_repeat( '☆', max( 0, glsr()->constant( 'MAX_RATING', Rating::class ) - $this->review->rating ));
132
+		$emptyStars = str_repeat( '☆', max( 0, glsr()->constant( 'MAX_RATING', Rating::class ) - $this->review->rating ) );
133 133
 		$stars = $solidStars.$emptyStars;
134
-		$stars = apply_filters( 'site-reviews/slack/stars', $stars, $this->review->rating, glsr()->constant( 'MAX_RATING', Rating::class ));
134
+		$stars = apply_filters( 'site-reviews/slack/stars', $stars, $this->review->rating, glsr()->constant( 'MAX_RATING', Rating::class ) );
135 135
 		return ['title' => $stars];
136 136
 	}
137 137
 
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 	 */
141 141
 	protected function buildTitleField()
142 142
 	{
143
-		return !empty( $this->review->title )
143
+		return !empty($this->review->title)
144 144
 			? ['title' => $this->review->title]
145 145
 			: [];
146 146
 	}
Please login to merge, or discard this patch.
plugin/Database/CountsManager.php 2 patches
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -30,12 +30,12 @@  discard block
 block discarded – undo
30 30
 		$query = $this->queryReviews( $args );
31 31
 		while( $query ) {
32 32
 			// glsr_log($query);
33
-			$types = array_keys( array_flip( glsr_array_column( $query->reviews, 'type' )));
34
-			$types = array_unique( array_merge( ['local'], $types ));
33
+			$types = array_keys( array_flip( glsr_array_column( $query->reviews, 'type' ) ) );
34
+			$types = array_unique( array_merge( ['local'], $types ) );
35 35
 			foreach( $types as $type ) {
36 36
 				$type = $this->normalizeType( $type );
37
-				if( isset( $counts[$type] ))continue;
38
-				$counts[$type] = array_fill_keys( range( 0, glsr()->constant( 'MAX_RATING', Rating::class )), 0 );
37
+				if( isset($counts[$type]) )continue;
38
+				$counts[$type] = array_fill_keys( range( 0, glsr()->constant( 'MAX_RATING', Rating::class ) ), 0 );
39 39
 			}
40 40
 			foreach( $query->reviews as $review ) {
41 41
 				$type = $this->normalizeType( $review->type );
@@ -73,11 +73,11 @@  discard block
 block discarded – undo
73 73
 	{
74 74
 		$terms = glsr( Database::class )->getTerms( ['fields' => 'all'] );
75 75
 		foreach( $terms as $term ) {
76
-			$this->setTermCounts( $term->term_id, $this->buildTermCounts( $term->term_taxonomy_id ));
76
+			$this->setTermCounts( $term->term_id, $this->buildTermCounts( $term->term_taxonomy_id ) );
77 77
 		}
78 78
 		$postIds = glsr( SqlQueries::class )->getReviewsMeta( 'assigned_to' );
79 79
 		foreach( $postIds as $postId ) {
80
-			$this->setPostCounts( $postId, $this->buildPostCounts( $postId ));
80
+			$this->setPostCounts( $postId, $this->buildPostCounts( $postId ) );
81 81
 		}
82 82
 		$this->setCounts( $this->buildCounts() );
83 83
 	}
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 			$this->getCounts(),
102 102
 			$review->review_type,
103 103
 			$review->rating
104
-		));
104
+		) );
105 105
 	}
106 106
 
107 107
 	/**
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 	 */
110 110
 	public function decreasePostCounts( Review $review )
111 111
 	{
112
-		if( empty( $counts = $this->getPostCounts( $review->assigned_to )))return;
112
+		if( empty($counts = $this->getPostCounts( $review->assigned_to )) )return;
113 113
 		$counts = $this->decreaseRating( $counts, $review->review_type, $review->rating );
114 114
 		$this->setPostCounts( $review->assigned_to, $counts );
115 115
 	}
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 	public function decreaseTermCounts( Review $review )
121 121
 	{
122 122
 		foreach( $review->term_ids as $termId ) {
123
-			if( empty( $counts = $this->getTermCounts( $termId )))continue;
123
+			if( empty($counts = $this->getTermCounts( $termId )) )continue;
124 124
 			$counts = $this->decreaseRating( $counts, $review->review_type, $review->rating );
125 125
 			$this->setTermCounts( $termId, $counts );
126 126
 		}
@@ -132,15 +132,15 @@  discard block
 block discarded – undo
132 132
 	public function flatten( array $reviewCounts, array $args = [] )
133 133
 	{
134 134
 		$counts = [];
135
-		array_walk_recursive( $reviewCounts, function( $num, $index ) use( &$counts ) {
136
-			$counts[$index] = $num + intval( glsr_get( $counts, $index, 0 ));
135
+		array_walk_recursive( $reviewCounts, function( $num, $index ) use(&$counts) {
136
+			$counts[$index] = $num + intval( glsr_get( $counts, $index, 0 ) );
137 137
 		});
138 138
 		$args = wp_parse_args( $args, [
139 139
 			'max' => glsr()->constant( 'MAX_RATING', Rating::class ),
140 140
 			'min' => glsr()->constant( 'MIN_RATING', Rating::class ),
141
-		]);
141
+		] );
142 142
 		foreach( $counts as $index => &$num ) {
143
-			if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] ))continue;
143
+			if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] ) )continue;
144 144
 			$num = 0;
145 145
 		}
146 146
 		return $counts;
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 	{
154 154
 		$args = $this->normalizeArgs( $args );
155 155
 		$counts = [];
156
-		if( $this->isMixedCount( $args )) {
156
+		if( $this->isMixedCount( $args ) ) {
157 157
 			$counts = [$this->buildCounts( $args )]; // force query the database
158 158
 		}
159 159
 		else {
@@ -163,13 +163,13 @@  discard block
 block discarded – undo
163 163
 			foreach( $args['term_ids'] as $termId ) {
164 164
 				$counts[] = $this->getTermCounts( $termId );
165 165
 			}
166
-			if( empty( $counts )) {
166
+			if( empty($counts) ) {
167 167
 				$counts[] = $this->getCounts();
168 168
 			}
169 169
 		}
170 170
 		return in_array( $args['type'], ['', 'all'] )
171 171
 			? $this->normalize( [$this->flatten( $counts )] )
172
-			: $this->normalize( glsr_array_column( $counts, $args['type'] ));
172
+			: $this->normalize( glsr_array_column( $counts, $args['type'] ) );
173 173
 	}
174 174
 
175 175
 	/**
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 	public function getCounts()
179 179
 	{
180 180
 		$counts = glsr( OptionManager::class )->get( 'counts', [] );
181
-		if( !is_array( $counts )) {
181
+		if( !is_array( $counts ) ) {
182 182
 			glsr_log()->error( '$counts is not an array' )->debug( $counts );
183 183
 			return [];
184 184
 		}
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 	 */
192 192
 	public function getPostCounts( $postId )
193 193
 	{
194
-		return array_filter( (array)get_post_meta( $postId, static::META_COUNT, true ));
194
+		return array_filter( (array)get_post_meta( $postId, static::META_COUNT, true ) );
195 195
 	}
196 196
 
197 197
 	/**
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 	 */
201 201
 	public function getTermCounts( $termId )
202 202
 	{
203
-		return array_filter( (array)get_term_meta( $termId, static::META_COUNT, true ));
203
+		return array_filter( (array)get_term_meta( $termId, static::META_COUNT, true ) );
204 204
 	}
205 205
 
206 206
 	/**
@@ -218,10 +218,10 @@  discard block
 block discarded – undo
218 218
 	 */
219 219
 	public function increaseCounts( Review $review )
220 220
 	{
221
-		if( empty( $counts = $this->getCounts() )) {
221
+		if( empty($counts = $this->getCounts()) ) {
222 222
 			$counts = $this->buildCounts();
223 223
 		}
224
-		$this->setCounts( $this->increaseRating( $counts, $review->review_type, $review->rating ));
224
+		$this->setCounts( $this->increaseRating( $counts, $review->review_type, $review->rating ) );
225 225
 	}
226 226
 
227 227
 	/**
@@ -229,9 +229,9 @@  discard block
 block discarded – undo
229 229
 	 */
230 230
 	public function increasePostCounts( Review $review )
231 231
 	{
232
-		if( !( get_post( $review->assigned_to ) instanceof WP_Post ))return;
232
+		if( !(get_post( $review->assigned_to ) instanceof WP_Post) )return;
233 233
 		$counts = $this->getPostCounts( $review->assigned_to );
234
-		$counts = empty( $counts )
234
+		$counts = empty($counts)
235 235
 			? $this->buildPostCounts( $review->assigned_to )
236 236
 			: $this->increaseRating( $counts, $review->review_type, $review->rating );
237 237
 		$this->setPostCounts( $review->assigned_to, $counts );
@@ -242,10 +242,10 @@  discard block
 block discarded – undo
242 242
 	 */
243 243
 	public function increaseTermCounts( Review $review )
244 244
 	{
245
-		$terms = glsr( ReviewManager::class )->normalizeTerms( implode( ',', $review->term_ids ));
245
+		$terms = glsr( ReviewManager::class )->normalizeTerms( implode( ',', $review->term_ids ) );
246 246
 		foreach( $terms as $term ) {
247 247
 			$counts = $this->getTermCounts( $term['term_id'] );
248
-			$counts = empty( $counts )
248
+			$counts = empty($counts)
249 249
 				? $this->buildTermCounts( $term['term_taxonomy_id'] )
250 250
 				: $this->increaseRating( $counts, $review->review_type, $review->rating );
251 251
 			$this->setTermCounts( $term['term_id'], $counts );
@@ -268,8 +268,8 @@  discard block
 block discarded – undo
268 268
 	{
269 269
 		$ratingCounts = $this->flatten( $reviewCounts );
270 270
 		update_post_meta( $postId, static::META_COUNT, $reviewCounts );
271
-		update_post_meta( $postId, static::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts ));
272
-		update_post_meta( $postId, static::META_RANKING, glsr( Rating::class )->getRanking( $ratingCounts ));
271
+		update_post_meta( $postId, static::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts ) );
272
+		update_post_meta( $postId, static::META_RANKING, glsr( Rating::class )->getRanking( $ratingCounts ) );
273 273
 	}
274 274
 
275 275
 	/**
@@ -279,11 +279,11 @@  discard block
 block discarded – undo
279 279
 	public function setTermCounts( $termId, array $reviewCounts )
280 280
 	{
281 281
 		$term = get_term( $termId, Application::TAXONOMY );
282
-		if( !isset( $term->term_id ))return;
282
+		if( !isset($term->term_id) )return;
283 283
 		$ratingCounts = $this->flatten( $reviewCounts );
284 284
 		update_term_meta( $termId, static::META_COUNT, $reviewCounts );
285
-		update_term_meta( $termId, static::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts ));
286
-		update_term_meta( $termId, static::META_RANKING, glsr( Rating::class )->getRanking( $ratingCounts ));
285
+		update_term_meta( $termId, static::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts ) );
286
+		update_term_meta( $termId, static::META_RANKING, glsr( Rating::class )->getRanking( $ratingCounts ) );
287 287
 	}
288 288
 
289 289
 	/**
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 	 */
294 294
 	protected function decreaseRating( array $reviewCounts, $type, $rating )
295 295
 	{
296
-		if( isset( $reviewCounts[$type][$rating] )) {
296
+		if( isset($reviewCounts[$type][$rating]) ) {
297 297
 			$reviewCounts[$type][$rating] = max( 0, $reviewCounts[$type][$rating] - 1 );
298 298
 		}
299 299
 		return $reviewCounts;
@@ -306,10 +306,10 @@  discard block
 block discarded – undo
306 306
 	 */
307 307
 	protected function increaseRating( array $reviewCounts, $type, $rating )
308 308
 	{
309
-		if( !array_key_exists( $type, glsr()->reviewTypes )) {
309
+		if( !array_key_exists( $type, glsr()->reviewTypes ) ) {
310 310
 			return $reviewCounts;
311 311
 		}
312
-		if( !array_key_exists( $type, $reviewCounts )) {
312
+		if( !array_key_exists( $type, $reviewCounts ) ) {
313 313
 			$reviewCounts[$type] = [];
314 314
 		}
315 315
 		$reviewCounts = $this->normalize( $reviewCounts );
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 	 */
323 323
 	protected function isMixedCount( array $args )
324 324
 	{
325
-		return !empty( $args['post_ids'] ) && !empty( $args['term_ids'] );
325
+		return !empty($args['post_ids']) && !empty($args['term_ids']);
326 326
 	}
327 327
 
328 328
 	/**
@@ -330,12 +330,12 @@  discard block
 block discarded – undo
330 330
 	 */
331 331
 	protected function normalize( array $reviewCounts )
332 332
 	{
333
-		if( empty( $reviewCounts )) {
333
+		if( empty($reviewCounts) ) {
334 334
 			$reviewCounts = [[]];
335 335
 		}
336 336
 		foreach( $reviewCounts as &$counts ) {
337
-			foreach( range( 0, glsr()->constant( 'MAX_RATING', Rating::class )) as $index ) {
338
-				if( isset( $counts[$index] ))continue;
337
+			foreach( range( 0, glsr()->constant( 'MAX_RATING', Rating::class ) ) as $index ) {
338
+				if( isset($counts[$index]) )continue;
339 339
 				$counts[$index] = 0;
340 340
 			}
341 341
 			ksort( $counts );
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 			'post_ids' => [],
353 353
 			'term_ids' => [],
354 354
 			'type' => 'local',
355
-		]);
355
+		] );
356 356
 		$args['post_ids'] = glsr( Polylang::class )->getPostIds( $args['post_ids'] );
357 357
 		$args['type'] = $this->normalizeType( $args['type'] );
358 358
 		return $args;
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
 	 */
365 365
 	protected function normalizeType( $type )
366 366
 	{
367
-		return empty( $type ) || !is_string( $type )
367
+		return empty($type) || !is_string( $type )
368 368
 			? 'local'
369 369
 			: $type;
370 370
 	}
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
 		$hasMore = is_array( $reviews )
380 380
 			? count( $reviews ) == static::LIMIT
381 381
 			: false;
382
-		return (object) [
382
+		return (object)[
383 383
 			'has_more' => $hasMore,
384 384
 			'reviews' => $reviews,
385 385
 		];
Please login to merge, or discard this patch.
Braces   +21 added lines, -7 removed lines patch added patch discarded remove patch
@@ -34,7 +34,9 @@  discard block
 block discarded – undo
34 34
 			$types = array_unique( array_merge( ['local'], $types ));
35 35
 			foreach( $types as $type ) {
36 36
 				$type = $this->normalizeType( $type );
37
-				if( isset( $counts[$type] ))continue;
37
+				if( isset( $counts[$type] )) {
38
+					continue;
39
+				}
38 40
 				$counts[$type] = array_fill_keys( range( 0, glsr()->constant( 'MAX_RATING', Rating::class )), 0 );
39 41
 			}
40 42
 			foreach( $query->reviews as $review ) {
@@ -109,7 +111,9 @@  discard block
 block discarded – undo
109 111
 	 */
110 112
 	public function decreasePostCounts( Review $review )
111 113
 	{
112
-		if( empty( $counts = $this->getPostCounts( $review->assigned_to )))return;
114
+		if( empty( $counts = $this->getPostCounts( $review->assigned_to ))) {
115
+			return;
116
+		}
113 117
 		$counts = $this->decreaseRating( $counts, $review->review_type, $review->rating );
114 118
 		$this->setPostCounts( $review->assigned_to, $counts );
115 119
 	}
@@ -120,7 +124,9 @@  discard block
 block discarded – undo
120 124
 	public function decreaseTermCounts( Review $review )
121 125
 	{
122 126
 		foreach( $review->term_ids as $termId ) {
123
-			if( empty( $counts = $this->getTermCounts( $termId )))continue;
127
+			if( empty( $counts = $this->getTermCounts( $termId ))) {
128
+				continue;
129
+			}
124 130
 			$counts = $this->decreaseRating( $counts, $review->review_type, $review->rating );
125 131
 			$this->setTermCounts( $termId, $counts );
126 132
 		}
@@ -140,7 +146,9 @@  discard block
 block discarded – undo
140 146
 			'min' => glsr()->constant( 'MIN_RATING', Rating::class ),
141 147
 		]);
142 148
 		foreach( $counts as $index => &$num ) {
143
-			if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] ))continue;
149
+			if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] )) {
150
+				continue;
151
+			}
144 152
 			$num = 0;
145 153
 		}
146 154
 		return $counts;
@@ -229,7 +237,9 @@  discard block
 block discarded – undo
229 237
 	 */
230 238
 	public function increasePostCounts( Review $review )
231 239
 	{
232
-		if( !( get_post( $review->assigned_to ) instanceof WP_Post ))return;
240
+		if( !( get_post( $review->assigned_to ) instanceof WP_Post )) {
241
+			return;
242
+		}
233 243
 		$counts = $this->getPostCounts( $review->assigned_to );
234 244
 		$counts = empty( $counts )
235 245
 			? $this->buildPostCounts( $review->assigned_to )
@@ -279,7 +289,9 @@  discard block
 block discarded – undo
279 289
 	public function setTermCounts( $termId, array $reviewCounts )
280 290
 	{
281 291
 		$term = get_term( $termId, Application::TAXONOMY );
282
-		if( !isset( $term->term_id ))return;
292
+		if( !isset( $term->term_id )) {
293
+			return;
294
+		}
283 295
 		$ratingCounts = $this->flatten( $reviewCounts );
284 296
 		update_term_meta( $termId, static::META_COUNT, $reviewCounts );
285 297
 		update_term_meta( $termId, static::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts ));
@@ -335,7 +347,9 @@  discard block
 block discarded – undo
335 347
 		}
336 348
 		foreach( $reviewCounts as &$counts ) {
337 349
 			foreach( range( 0, glsr()->constant( 'MAX_RATING', Rating::class )) as $index ) {
338
-				if( isset( $counts[$index] ))continue;
350
+				if( isset( $counts[$index] )) {
351
+					continue;
352
+				}
339 353
 				$counts[$index] = 0;
340 354
 			}
341 355
 			ksort( $counts );
Please login to merge, or discard this patch.
plugin/Database/SqlQueries.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -22,11 +22,11 @@  discard block
 block discarded – undo
22 22
 	 */
23 23
 	public function deleteAllSessions( $sessionCookiePrefix )
24 24
 	{
25
-		return $this->db->query("
25
+		return $this->db->query( "
26 26
 			DELETE
27 27
 			FROM {$this->db->options}
28 28
 			WHERE option_name LIKE '{$sessionCookiePrefix}_%'
29
-		");
29
+		" );
30 30
 	}
31 31
 
32 32
 	/**
@@ -35,11 +35,11 @@  discard block
 block discarded – undo
35 35
 	 */
36 36
 	public function deleteExpiredSessions( $expiredSessions )
37 37
 	{
38
-		return $this->db->query("
38
+		return $this->db->query( "
39 39
 			DELETE
40 40
 			FROM {$this->db->options}
41 41
 			WHERE option_name IN ('{$expiredSessions}')
42
-		");
42
+		" );
43 43
 	}
44 44
 
45 45
 	/**
@@ -49,13 +49,13 @@  discard block
 block discarded – undo
49 49
 	 */
50 50
 	public function getExpiredSessions( $sessionCookiePrefix, $limit )
51 51
 	{
52
-		return (array) $this->db->get_results("
52
+		return (array)$this->db->get_results( "
53 53
 			SELECT option_name AS name, option_value AS expiration
54 54
 			FROM {$this->db->options}
55 55
 			WHERE option_name LIKE '{$sessionCookiePrefix}_expires_%'
56 56
 			ORDER BY option_value ASC
57 57
 			LIMIT 0, {$limit}
58
-		");
58
+		" );
59 59
 	}
60 60
 
61 61
 	/**
@@ -64,14 +64,14 @@  discard block
 block discarded – undo
64 64
 	 */
65 65
 	public function getPostIdFromReviewId( $metaReviewId )
66 66
 	{
67
-		$postId = $this->db->get_var("
67
+		$postId = $this->db->get_var( "
68 68
 			SELECT p.ID
69 69
 			FROM {$this->db->posts} AS p
70 70
 			INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id
71 71
 			WHERE p.post_type = '{$this->postType}'
72 72
 			AND m.meta_key = 'review_id'
73 73
 			AND m.meta_value = '{$metaReviewId}'
74
-		");
74
+		" );
75 75
 		return intval( $postId );
76 76
 	}
77 77
 
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 	 */
83 83
 	public function getReviewCounts( array $args, $lastPostId = 0, $limit = 500 )
84 84
 	{
85
-		return (array) $this->db->get_results("
85
+		return (array)$this->db->get_results( "
86 86
 			SELECT DISTINCT p.ID, m1.meta_value AS rating, m2.meta_value AS type
87 87
 			FROM {$this->db->posts} AS p
88 88
 			INNER JOIN {$this->db->postmeta} AS m1 ON p.ID = m1.post_id
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 			{$this->getAndForCounts( $args )}
97 97
 			ORDER By p.ID ASC
98 98
 			LIMIT {$limit}
99
-		");
99
+		" );
100 100
 	}
101 101
 
102 102
 	/**
@@ -106,14 +106,14 @@  discard block
 block discarded – undo
106 106
 	 */
107 107
 	public function getReviewCountsFor( $metaKey )
108 108
 	{
109
-		return (array) $this->db->get_results("
109
+		return (array)$this->db->get_results( "
110 110
 			SELECT DISTINCT m.meta_value AS name, COUNT(*) num_posts
111 111
 			FROM {$this->db->posts} AS p
112 112
 			INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id
113 113
 			WHERE p.post_type = '{$this->postType}'
114 114
 			AND m.meta_key = '{$metaKey}'
115 115
 			GROUP BY name
116
-		");
116
+		" );
117 117
 	}
118 118
 
119 119
 	/**
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 	 */
124 124
 	public function getReviewIdsByType( $reviewType )
125 125
 	{
126
-		$results = $this->db->get_col("
126
+		$results = $this->db->get_col( "
127 127
 			SELECT DISTINCT m1.meta_value AS review_id
128 128
 			FROM {$this->db->posts} AS p
129 129
 			INNER JOIN {$this->db->postmeta} AS m1 ON p.ID = m1.post_id
@@ -132,8 +132,8 @@  discard block
 block discarded – undo
132 132
 			AND m1.meta_key = 'review_id'
133 133
 			AND m2.meta_key = 'review_type'
134 134
 			AND m2.meta_value = '{$reviewType}'
135
-		");
136
-		return array_keys( array_flip( $results ));
135
+		" );
136
+		return array_keys( array_flip( $results ) );
137 137
 	}
138 138
 
139 139
 	/**
@@ -144,9 +144,9 @@  discard block
 block discarded – undo
144 144
 	public function getReviewRatingsFromIds( array $postIds, $greaterThanId = 0, $limit = 100 )
145 145
 	{
146 146
 		sort( $postIds );
147
-		$postIds = array_slice( $postIds, intval( array_search( $greaterThanId, $postIds )), $limit );
147
+		$postIds = array_slice( $postIds, intval( array_search( $greaterThanId, $postIds ) ), $limit );
148 148
 		$postIds = implode( ',', $postIds );
149
-		return (array) $this->db->get_results("
149
+		return (array)$this->db->get_results( "
150 150
 			SELECT p.ID, m.meta_value AS rating
151 151
 			FROM {$this->db->posts} AS p
152 152
 			INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 			GROUP BY p.ID
159 159
 			ORDER By p.ID ASC
160 160
 			LIMIT {$limit}
161
-		");
161
+		" );
162 162
 	}
163 163
 
164 164
 	/**
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 	 */
169 169
 	public function getReviewsMeta( $key, $status = 'publish' )
170 170
 	{
171
-		$values = $this->db->get_col("
171
+		$values = $this->db->get_col( "
172 172
 			SELECT DISTINCT m.meta_value
173 173
 			FROM {$this->db->postmeta} m
174 174
 			LEFT JOIN {$this->db->posts} p ON p.ID = m.post_id
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 			AND p.post_status = '{$status}'
179 179
 			GROUP BY p.ID -- remove duplicate meta_value entries
180 180
 			ORDER BY m.meta_id ASC -- sort by oldest meta_value
181
-		");
181
+		" );
182 182
 		sort( $values );
183 183
 		return $values;
184 184
 	}
@@ -189,16 +189,16 @@  discard block
 block discarded – undo
189 189
 	 */
190 190
 	protected function getAndForCounts( array $args, $and = '' )
191 191
 	{
192
-		$postIds = implode( ',', array_filter( glsr_get( $args, 'post_ids')));
193
-		$termIds = implode( ',', array_filter( glsr_get( $args, 'term_ids')));
194
-		if( !empty( $args['type'] )) {
195
-			$and.= "AND m2.meta_value = '{$args['type']}' ";
192
+		$postIds = implode( ',', array_filter( glsr_get( $args, 'post_ids' ) ) );
193
+		$termIds = implode( ',', array_filter( glsr_get( $args, 'term_ids' ) ) );
194
+		if( !empty($args['type']) ) {
195
+			$and .= "AND m2.meta_value = '{$args['type']}' ";
196 196
 		}
197 197
 		if( $postIds ) {
198
-			$and.= "AND m3.meta_key = 'assigned_to' AND m3.meta_value IN ({$postIds}) ";
198
+			$and .= "AND m3.meta_key = 'assigned_to' AND m3.meta_value IN ({$postIds}) ";
199 199
 		}
200 200
 		if( $termIds ) {
201
-			$and.= "AND tr.term_taxonomy_id IN ({$termIds}) ";
201
+			$and .= "AND tr.term_taxonomy_id IN ({$termIds}) ";
202 202
 		}
203 203
 		return apply_filters( 'site-reviews/query/and-for-counts', $and );
204 204
 	}
@@ -209,11 +209,11 @@  discard block
 block discarded – undo
209 209
 	 */
210 210
 	protected function getInnerJoinForCounts( array $args, $innerJoin = '' )
211 211
 	{
212
-		if( !empty( glsr_get( $args, 'post_ids'))) {
213
-			$innerJoin.= "INNER JOIN {$this->db->postmeta} AS m3 ON p.ID = m3.post_id ";
212
+		if( !empty(glsr_get( $args, 'post_ids' )) ) {
213
+			$innerJoin .= "INNER JOIN {$this->db->postmeta} AS m3 ON p.ID = m3.post_id ";
214 214
 		}
215
-		if( !empty( glsr_get( $args, 'term_ids'))) {
216
-			$innerJoin.= "INNER JOIN {$this->db->term_relationships} AS tr ON p.ID = tr.object_id ";
215
+		if( !empty(glsr_get( $args, 'term_ids' )) ) {
216
+			$innerJoin .= "INNER JOIN {$this->db->term_relationships} AS tr ON p.ID = tr.object_id ";
217 217
 		}
218 218
 		return apply_filters( 'site-reviews/query/inner-join-for-counts', $innerJoin );
219 219
 	}
Please login to merge, or discard this patch.
plugin/Router.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	{
21 21
 		$this->unguardedActions = apply_filters( 'site-reviews/router/unguarded-actions', [
22 22
 			'fetch-paged-reviews',
23
-		]);
23
+		] );
24 24
 	}
25 25
 
26 26
 	/**
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	public function routeAdminPostRequest()
30 30
 	{
31 31
 		$request = $this->getRequest();
32
-		if( !$this->isValidPostRequest( $request ))return;
32
+		if( !$this->isValidPostRequest( $request ) )return;
33 33
 		check_admin_referer( $request['_action'] );
34 34
 		$this->routeRequest( 'admin', $request['_action'], $request );
35 35
 	}
@@ -53,8 +53,8 @@  discard block
 block discarded – undo
53 53
 	{
54 54
 		if( is_admin() )return;
55 55
 		$request = $this->getRequest();
56
-		if( !$this->isValidPostRequest( $request ))return;
57
-		if( !$this->isValidPublicNonce( $request ))return;
56
+		if( !$this->isValidPostRequest( $request ) )return;
57
+		if( !$this->isValidPublicNonce( $request ) )return;
58 58
 		$this->routeRequest( 'public', $request['_action'], $request );
59 59
 	}
60 60
 
@@ -66,10 +66,10 @@  discard block
 block discarded – undo
66 66
 		if( !is_user_logged_in()
67 67
 			|| in_array( glsr_get( $request, '_action' ), $this->unguardedActions )
68 68
 		)return;
69
-		if( !isset( $request['_nonce'] )) {
69
+		if( !isset($request['_nonce']) ) {
70 70
 			$this->sendAjaxError( 'request is missing a nonce', $request );
71 71
 		}
72
-		if( !wp_verify_nonce( $request['_nonce'], $request['_action'] )) {
72
+		if( !wp_verify_nonce( $request['_nonce'], $request['_action'] ) ) {
73 73
 			$this->sendAjaxError( 'request failed the nonce check', $request, 403 );
74 74
 		}
75 75
 	}
@@ -79,10 +79,10 @@  discard block
 block discarded – undo
79 79
 	 */
80 80
 	protected function checkAjaxRequest( array $request )
81 81
 	{
82
-		if( !isset( $request['_action'] )) {
82
+		if( !isset($request['_action']) ) {
83 83
 			$this->sendAjaxError( 'request must include an action', $request );
84 84
 		}
85
-		if( empty( $request['_ajax_request'] )) {
85
+		if( empty($request['_ajax_request']) ) {
86 86
 			$this->sendAjaxError( 'request is invalid', $request );
87 87
 		}
88 88
 	}
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 	 */
110 110
 	protected function isValidPostRequest( array $request = [] )
111 111
 	{
112
-		return !empty( $request['_action'] ) && empty( $request['_ajax_request'] );
112
+		return !empty($request['_action']) && empty($request['_ajax_request']);
113 113
 	}
114 114
 
115 115
 	/**
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	 */
118 118
 	protected function isValidPublicNonce( array $request )
119 119
 	{
120
-		if( is_user_logged_in() && !wp_verify_nonce( $request['_nonce'], $request['_action'] )) {
120
+		if( is_user_logged_in() && !wp_verify_nonce( $request['_nonce'], $request['_action'] ) ) {
121 121
 			glsr_log()->error( 'nonce check failed for public request' )->debug( $request );
122 122
 			return false;
123 123
 		}
@@ -132,11 +132,11 @@  discard block
 block discarded – undo
132 132
 	protected function routeRequest( $type, $action, array $request = [] )
133 133
 	{
134 134
 		$actionHook = 'site-reviews/route/'.$type.'/request';
135
-		$controller = glsr( glsr( Helper::class )->buildClassName( $type.'-controller', 'Controllers' ));
135
+		$controller = glsr( glsr( Helper::class )->buildClassName( $type.'-controller', 'Controllers' ) );
136 136
 		$method = glsr( Helper::class )->buildMethodName( $action, 'router' );
137 137
 		$request = apply_filters( 'site-reviews/route/request', $request, $action, $type );
138 138
 		do_action( $actionHook, $action, $request );
139
-		if( is_callable( [$controller, $method] )) {
139
+		if( is_callable( [$controller, $method] ) ) {
140 140
 			call_user_func( [$controller, $method], $request );
141 141
 			return;
142 142
 		}
@@ -154,10 +154,10 @@  discard block
 block discarded – undo
154 154
 	{
155 155
 		glsr_log()->error( $error )->debug( $request );
156 156
 		glsr( Notice::class )->addError( __( 'There was an error (try refreshing the page).', 'site-reviews' ).' <code>'.$error.'</code>' );
157
-		wp_send_json_error([
157
+		wp_send_json_error( [
158 158
 			'message' => __( 'The form could not be submitted. Please notify the site administrator.', 'site-reviews' ),
159 159
 			'notices' => glsr( Notice::class )->get(),
160 160
 			'error' => $error,
161
-		]);
161
+		] );
162 162
 	}
163 163
 }
Please login to merge, or discard this patch.
Braces   +15 added lines, -5 removed lines patch added patch discarded remove patch
@@ -29,7 +29,9 @@  discard block
 block discarded – undo
29 29
 	public function routeAdminPostRequest()
30 30
 	{
31 31
 		$request = $this->getRequest();
32
-		if( !$this->isValidPostRequest( $request ))return;
32
+		if( !$this->isValidPostRequest( $request )) {
33
+			return;
34
+		}
33 35
 		check_admin_referer( $request['_action'] );
34 36
 		$this->routeRequest( 'admin', $request['_action'], $request );
35 37
 	}
@@ -51,10 +53,16 @@  discard block
 block discarded – undo
51 53
 	 */
52 54
 	public function routePublicPostRequest()
53 55
 	{
54
-		if( is_admin() )return;
56
+		if( is_admin() ) {
57
+			return;
58
+		}
55 59
 		$request = $this->getRequest();
56
-		if( !$this->isValidPostRequest( $request ))return;
57
-		if( !$this->isValidPublicNonce( $request ))return;
60
+		if( !$this->isValidPostRequest( $request )) {
61
+			return;
62
+		}
63
+		if( !$this->isValidPublicNonce( $request )) {
64
+			return;
65
+		}
58 66
 		$this->routeRequest( 'public', $request['_action'], $request );
59 67
 	}
60 68
 
@@ -65,7 +73,9 @@  discard block
 block discarded – undo
65 73
 	{
66 74
 		if( !is_user_logged_in()
67 75
 			|| in_array( glsr_get( $request, '_action' ), $this->unguardedActions )
68
-		)return;
76
+		) {
77
+			return;
78
+		}
69 79
 		if( !isset( $request['_nonce'] )) {
70 80
 			$this->sendAjaxError( 'request is missing a nonce', $request );
71 81
 		}
Please login to merge, or discard this patch.