Passed
Push — master ( e0a59a...75b6ac )
by Paul
06:30 queued 02:41
created
plugin/Modules/Upgrader/Upgrade_4_0_2.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
         $this->migrateSettings();
15 15
         $this->protectMetaKeys();
16 16
         $this->deleteSessions();
17
-        delete_transient(Application::ID.'_cloudflare_ips');
17
+        delete_transient( Application::ID.'_cloudflare_ips' );
18 18
     }
19 19
 
20 20
     /**
@@ -23,11 +23,11 @@  discard block
 block discarded – undo
23 23
     public function deleteSessions()
24 24
     {
25 25
         global $wpdb;
26
-        $wpdb->query("
26
+        $wpdb->query( "
27 27
             DELETE
28 28
             FROM {$wpdb->options}
29 29
             WHERE option_name LIKE '_glsr_session%'
30
-        ");
30
+        " );
31 31
     }
32 32
 
33 33
     /**
@@ -35,23 +35,23 @@  discard block
 block discarded – undo
35 35
      */
36 36
     public function migrateSettings()
37 37
     {
38
-        if ($settings = get_option(OptionManager::databaseKey(3))) {
39
-            $multilingual = 'yes' == Arr::get($settings, 'settings.general.support.polylang')
38
+        if( $settings = get_option( OptionManager::databaseKey( 3 ) ) ) {
39
+            $multilingual = 'yes' == Arr::get( $settings, 'settings.general.support.polylang' )
40 40
                 ? 'polylang'
41 41
                 : '';
42
-            $settings = Arr::set($settings, 'settings.general.multilingual', $multilingual);
43
-            $settings = Arr::set($settings, 'settings.general.rebusify', 'no');
44
-            $settings = Arr::set($settings, 'settings.general.rebusify_email', '');
45
-            $settings = Arr::set($settings, 'settings.general.rebusify_serial', '');
46
-            $settings = Arr::set($settings, 'settings.reviews.name.format', '');
47
-            $settings = Arr::set($settings, 'settings.reviews.name.initial', '');
48
-            $settings = Arr::set($settings, 'settings.submissions.blacklist.integration', '');
49
-            $settings = Arr::set($settings, 'settings.submissions.limit', '');
50
-            $settings = Arr::set($settings, 'settings.submissions.limit_whitelist.email', '');
51
-            $settings = Arr::set($settings, 'settings.submissions.limit_whitelist.ip_address', '');
52
-            $settings = Arr::set($settings, 'settings.submissions.limit_whitelist.username', '');
42
+            $settings = Arr::set( $settings, 'settings.general.multilingual', $multilingual );
43
+            $settings = Arr::set( $settings, 'settings.general.rebusify', 'no' );
44
+            $settings = Arr::set( $settings, 'settings.general.rebusify_email', '' );
45
+            $settings = Arr::set( $settings, 'settings.general.rebusify_serial', '' );
46
+            $settings = Arr::set( $settings, 'settings.reviews.name.format', '' );
47
+            $settings = Arr::set( $settings, 'settings.reviews.name.initial', '' );
48
+            $settings = Arr::set( $settings, 'settings.submissions.blacklist.integration', '' );
49
+            $settings = Arr::set( $settings, 'settings.submissions.limit', '' );
50
+            $settings = Arr::set( $settings, 'settings.submissions.limit_whitelist.email', '' );
51
+            $settings = Arr::set( $settings, 'settings.submissions.limit_whitelist.ip_address', '' );
52
+            $settings = Arr::set( $settings, 'settings.submissions.limit_whitelist.username', '' );
53 53
             unset($settings['settings']['general']['support']);
54
-            update_option(OptionManager::databaseKey(4), $settings);
54
+            update_option( OptionManager::databaseKey( 4 ), $settings );
55 55
         }
56 56
     }
57 57
 
@@ -61,15 +61,15 @@  discard block
 block discarded – undo
61 61
     public function protectMetaKeys()
62 62
     {
63 63
         global $wpdb;
64
-        $keys = array_keys(glsr(CreateReviewDefaults::class)->defaults());
65
-        $keys = implode("','", $keys);
64
+        $keys = array_keys( glsr( CreateReviewDefaults::class )->defaults() );
65
+        $keys = implode( "','", $keys );
66 66
         $postType = Application::POST_TYPE;
67
-        $wpdb->query("
67
+        $wpdb->query( "
68 68
             UPDATE {$wpdb->postmeta} pm
69 69
             INNER JOIN {$wpdb->posts} p ON p.id = pm.post_id
70 70
             SET pm.meta_key = CONCAT('_', pm.meta_key)
71 71
             WHERE pm.meta_key IN ('{$keys}')
72 72
             AND p.post_type = '{$postType}'
73
-        ");
73
+        " );
74 74
     }
75 75
 }
Please login to merge, or discard this patch.
plugin/Modules/Validator.php 1 patch
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -66,14 +66,14 @@  discard block
 block discarded – undo
66 66
      * @param mixed $data
67 67
      * @return array
68 68
      */
69
-    public function validate($data, array $rules = [])
69
+    public function validate( $data, array $rules = [] )
70 70
     {
71
-        $this->normalizeData($data);
72
-        $this->setRules($rules);
73
-        foreach ($this->rules as $attribute => $rules) {
74
-            foreach ($rules as $rule) {
75
-                $this->validateAttribute($attribute, $rule);
76
-                if ($this->shouldStopValidating($attribute)) {
71
+        $this->normalizeData( $data );
72
+        $this->setRules( $rules );
73
+        foreach( $this->rules as $attribute => $rules ) {
74
+            foreach( $rules as $rule ) {
75
+                $this->validateAttribute( $attribute, $rule );
76
+                if( $this->shouldStopValidating( $attribute ) ) {
77 77
                     break;
78 78
                 }
79 79
             }
@@ -88,18 +88,18 @@  discard block
 block discarded – undo
88 88
      * @return void
89 89
      * @throws BadMethodCallException
90 90
      */
91
-    public function validateAttribute($attribute, $rule)
91
+    public function validateAttribute( $attribute, $rule )
92 92
     {
93
-        list($rule, $parameters) = $this->parseRule($rule);
94
-        if ('' == $rule) {
93
+        list($rule, $parameters) = $this->parseRule( $rule );
94
+        if( '' == $rule ) {
95 95
             return;
96 96
         }
97
-        $value = $this->getValue($attribute);
98
-        if (!method_exists($this, $method = 'validate'.$rule)) {
99
-            throw new BadMethodCallException("Method [$method] does not exist.");
97
+        $value = $this->getValue( $attribute );
98
+        if( !method_exists( $this, $method = 'validate'.$rule ) ) {
99
+            throw new BadMethodCallException( "Method [$method] does not exist." );
100 100
         }
101
-        if (!$this->$method($value, $attribute, $parameters)) {
102
-            $this->addFailure($attribute, $rule, $parameters);
101
+        if( !$this->$method( $value, $attribute, $parameters ) ) {
102
+            $this->addFailure( $attribute, $rule, $parameters );
103 103
         }
104 104
     }
105 105
 
@@ -109,9 +109,9 @@  discard block
 block discarded – undo
109 109
      * @param string $rule
110 110
      * @return void
111 111
      */
112
-    protected function addError($attribute, $rule, array $parameters)
112
+    protected function addError( $attribute, $rule, array $parameters )
113 113
     {
114
-        $message = $this->getMessage($attribute, $rule, $parameters);
114
+        $message = $this->getMessage( $attribute, $rule, $parameters );
115 115
         $this->errors[$attribute][] = $message;
116 116
     }
117 117
 
@@ -121,9 +121,9 @@  discard block
 block discarded – undo
121 121
      * @param string $rule
122 122
      * @return void
123 123
      */
124
-    protected function addFailure($attribute, $rule, array $parameters)
124
+    protected function addFailure( $attribute, $rule, array $parameters )
125 125
     {
126
-        $this->addError($attribute, $rule, $parameters);
126
+        $this->addError( $attribute, $rule, $parameters );
127 127
         $this->failedRules[$attribute][$rule] = $parameters;
128 128
     }
129 129
 
@@ -132,9 +132,9 @@  discard block
 block discarded – undo
132 132
      * @param string $attribute
133 133
      * @return string
134 134
      */
135
-    protected function getAttributeType($attribute)
135
+    protected function getAttributeType( $attribute )
136 136
     {
137
-        return !$this->hasRule($attribute, $this->numericRules)
137
+        return !$this->hasRule( $attribute, $this->numericRules )
138 138
             ? 'length'
139 139
             : '';
140 140
     }
@@ -145,13 +145,13 @@  discard block
 block discarded – undo
145 145
      * @param string $rule
146 146
      * @return string|null
147 147
      */
148
-    protected function getMessage($attribute, $rule, array $parameters)
148
+    protected function getMessage( $attribute, $rule, array $parameters )
149 149
     {
150
-        if (in_array($rule, $this->sizeRules)) {
151
-            return $this->getSizeMessage($attribute, $rule, $parameters);
150
+        if( in_array( $rule, $this->sizeRules ) ) {
151
+            return $this->getSizeMessage( $attribute, $rule, $parameters );
152 152
         }
153
-        $lowerRule = Str::snakeCase($rule);
154
-        return $this->translator($lowerRule, $parameters);
153
+        $lowerRule = Str::snakeCase( $rule );
154
+        return $this->translator( $lowerRule, $parameters );
155 155
     }
156 156
 
157 157
     /**
@@ -160,15 +160,15 @@  discard block
 block discarded – undo
160 160
      * @param string|array $rules
161 161
      * @return array|null
162 162
      */
163
-    protected function getRule($attribute, $rules)
163
+    protected function getRule( $attribute, $rules )
164 164
     {
165
-        if (!array_key_exists($attribute, $this->rules)) {
165
+        if( !array_key_exists( $attribute, $this->rules ) ) {
166 166
             return;
167 167
         }
168
-        $rules = (array) $rules;
169
-        foreach ($this->rules[$attribute] as $rule) {
170
-            list($rule, $parameters) = $this->parseRule($rule);
171
-            if (in_array($rule, $rules)) {
168
+        $rules = (array)$rules;
169
+        foreach( $this->rules[$attribute] as $rule ) {
170
+            list($rule, $parameters) = $this->parseRule( $rule );
171
+            if( in_array( $rule, $rules ) ) {
172 172
                 return [$rule, $parameters];
173 173
             }
174 174
         }
@@ -180,17 +180,17 @@  discard block
 block discarded – undo
180 180
      * @param mixed $value
181 181
      * @return mixed
182 182
      */
183
-    protected function getSize($attribute, $value)
183
+    protected function getSize( $attribute, $value )
184 184
     {
185
-        $hasNumeric = $this->hasRule($attribute, $this->numericRules);
186
-        if (is_numeric($value) && $hasNumeric) {
185
+        $hasNumeric = $this->hasRule( $attribute, $this->numericRules );
186
+        if( is_numeric( $value ) && $hasNumeric ) {
187 187
             return $value;
188
-        } elseif (is_array($value)) {
189
-            return count($value);
188
+        } elseif( is_array( $value ) ) {
189
+            return count( $value );
190 190
         }
191
-        return function_exists('mb_strlen')
192
-            ? mb_strlen($value)
193
-            : strlen($value);
191
+        return function_exists( 'mb_strlen' )
192
+            ? mb_strlen( $value )
193
+            : strlen( $value );
194 194
     }
195 195
 
196 196
     /**
@@ -199,11 +199,11 @@  discard block
 block discarded – undo
199 199
      * @param string $rule
200 200
      * @return string|null
201 201
      */
202
-    protected function getSizeMessage($attribute, $rule, array $parameters)
202
+    protected function getSizeMessage( $attribute, $rule, array $parameters )
203 203
     {
204
-        $type = $this->getAttributeType($attribute);
205
-        $lowerRule = Str::snakeCase($rule.$type);
206
-        return $this->translator($lowerRule, $parameters);
204
+        $type = $this->getAttributeType( $attribute );
205
+        $lowerRule = Str::snakeCase( $rule.$type );
206
+        return $this->translator( $lowerRule, $parameters );
207 207
     }
208 208
 
209 209
     /**
@@ -211,9 +211,9 @@  discard block
 block discarded – undo
211 211
      * @param string $attribute
212 212
      * @return mixed
213 213
      */
214
-    protected function getValue($attribute)
214
+    protected function getValue( $attribute )
215 215
     {
216
-        if (isset($this->data[$attribute])) {
216
+        if( isset($this->data[$attribute]) ) {
217 217
             return $this->data[$attribute];
218 218
         }
219 219
     }
@@ -224,9 +224,9 @@  discard block
 block discarded – undo
224 224
      * @param string|array $rules
225 225
      * @return bool
226 226
      */
227
-    protected function hasRule($attribute, $rules)
227
+    protected function hasRule( $attribute, $rules )
228 228
     {
229
-        return !is_null($this->getRule($attribute, $rules));
229
+        return !is_null( $this->getRule( $attribute, $rules ) );
230 230
     }
231 231
 
232 232
     /**
@@ -234,10 +234,10 @@  discard block
 block discarded – undo
234 234
      * @param mixed $data
235 235
      * @return void
236 236
      */
237
-    protected function normalizeData($data)
237
+    protected function normalizeData( $data )
238 238
     {
239
-        $this->data = is_object($data)
240
-            ? get_object_vars($data)
239
+        $this->data = is_object( $data )
240
+            ? get_object_vars( $data )
241 241
             : $data;
242 242
     }
243 243
 
@@ -247,11 +247,11 @@  discard block
 block discarded – undo
247 247
      * @param string $parameter
248 248
      * @return array
249 249
      */
250
-    protected function parseParameters($rule, $parameter)
250
+    protected function parseParameters( $rule, $parameter )
251 251
     {
252
-        return 'regex' == strtolower($rule)
252
+        return 'regex' == strtolower( $rule )
253 253
             ? [$parameter]
254
-            : str_getcsv($parameter);
254
+            : str_getcsv( $parameter );
255 255
     }
256 256
 
257 257
     /**
@@ -259,14 +259,14 @@  discard block
 block discarded – undo
259 259
      * @param string $rule
260 260
      * @return array
261 261
      */
262
-    protected function parseRule($rule)
262
+    protected function parseRule( $rule )
263 263
     {
264 264
         $parameters = [];
265
-        if (false !== strpos($rule, ':')) {
266
-            list($rule, $parameter) = explode(':', $rule, 2);
267
-            $parameters = $this->parseParameters($rule, $parameter);
265
+        if( false !== strpos( $rule, ':' ) ) {
266
+            list($rule, $parameter) = explode( ':', $rule, 2 );
267
+            $parameters = $this->parseParameters( $rule, $parameter );
268 268
         }
269
-        $rule = Str::camelCase($rule);
269
+        $rule = Str::camelCase( $rule );
270 270
         return [$rule, $parameters];
271 271
     }
272 272
 
@@ -274,11 +274,11 @@  discard block
 block discarded – undo
274 274
      * Set the validation rules.
275 275
      * @return void
276 276
      */
277
-    protected function setRules(array $rules)
277
+    protected function setRules( array $rules )
278 278
     {
279
-        foreach ($rules as $key => $rule) {
280
-            $rules[$key] = is_string($rule)
281
-                ? explode('|', $rule)
279
+        foreach( $rules as $key => $rule ) {
280
+            $rules[$key] = is_string( $rule )
281
+                ? explode( '|', $rule )
282 282
                 : $rule;
283 283
         }
284 284
         $this->rules = $rules;
@@ -289,11 +289,11 @@  discard block
 block discarded – undo
289 289
      * @param string $attribute
290 290
      * @return bool
291 291
      */
292
-    protected function shouldStopValidating($attribute)
292
+    protected function shouldStopValidating( $attribute )
293 293
     {
294
-        return $this->hasRule($attribute, $this->implicitRules)
294
+        return $this->hasRule( $attribute, $this->implicitRules )
295 295
             && isset($this->failedRules[$attribute])
296
-            && array_intersect(array_keys($this->failedRules[$attribute]), $this->implicitRules);
296
+            && array_intersect( array_keys( $this->failedRules[$attribute] ), $this->implicitRules );
297 297
     }
298 298
 
299 299
     /**
@@ -302,11 +302,11 @@  discard block
 block discarded – undo
302 302
      * @param string $attribute
303 303
      * @return void|string
304 304
      */
305
-    protected function translator($key, array $parameters)
305
+    protected function translator( $key, array $parameters )
306 306
     {
307
-        $strings = glsr(ValidationStringsDefaults::class)->defaults();
308
-        if (isset($strings[$key])) {
309
-            return $this->replace($strings[$key], $parameters);
307
+        $strings = glsr( ValidationStringsDefaults::class )->defaults();
308
+        if( isset($strings[$key]) ) {
309
+            return $this->replace( $strings[$key], $parameters );
310 310
         }
311 311
         return 'error';
312 312
     }
Please login to merge, or discard this patch.
plugin/Modules/Schema.php 1 patch
Spacing   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -25,21 +25,21 @@  discard block
 block discarded – undo
25 25
     /**
26 26
      * @return array
27 27
      */
28
-    public function build(array $args = [])
28
+    public function build( array $args = [] )
29 29
     {
30 30
         $this->args = $args;
31
-        $schema = $this->buildSummary($args);
31
+        $schema = $this->buildSummary( $args );
32 32
         $reviews = [];
33
-        foreach (glsr(ReviewManager::class)->get($this->args) as $review) {
33
+        foreach( glsr( ReviewManager::class )->get( $this->args ) as $review ) {
34 34
             // Only include critic reviews that have been directly produced by your site, not reviews from third-party sites or syndicated reviews.
35 35
             // @see https://developers.google.com/search/docs/data-types/review
36
-            if ('local' != $review->review_type) {
36
+            if( 'local' != $review->review_type ) {
37 37
                 continue;
38 38
             }
39
-            $reviews[] = $this->buildReview($review);
39
+            $reviews[] = $this->buildReview( $review );
40 40
         }
41
-        if (!empty($reviews)) {
42
-            array_walk($reviews, function (&$review) {
41
+        if( !empty($reviews) ) {
42
+            array_walk( $reviews, function( &$review ) {
43 43
                 unset($review['@context']);
44 44
                 unset($review['itemReviewed']);
45 45
             });
@@ -52,27 +52,27 @@  discard block
 block discarded – undo
52 52
      * @param array|null $args
53 53
      * @return array
54 54
      */
55
-    public function buildSummary($args = null)
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
-        $buildSummary = Helper::buildMethodName($this->getSchemaOptionValue('type'), 'buildSummaryFor');
61
-        $count = array_sum($this->getRatingCounts());
62
-        $schema = method_exists($this, $buildSummary)
60
+        $buildSummary = Helper::buildMethodName( $this->getSchemaOptionValue( 'type' ), 'buildSummaryFor' );
61
+        $count = array_sum( $this->getRatingCounts() );
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
-                $this->getSchemaType('AggregateRating')
68
-                    ->ratingValue($this->getRatingValue())
69
-                    ->reviewCount($count)
70
-                    ->bestRating(glsr()->constant('MAX_RATING', Rating::class))
71
-                    ->worstRating(glsr()->constant('MIN_RATING', Rating::class))
67
+                $this->getSchemaType( 'AggregateRating' )
68
+                    ->ratingValue( $this->getRatingValue() )
69
+                    ->reviewCount( $count )
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();
75
-        return apply_filters('site-reviews/schema/'.$schema['@type'], $schema, $args);
75
+        return apply_filters( 'site-reviews/schema/'.$schema['@type'], $schema, $args );
76 76
     }
77 77
 
78 78
     /**
@@ -80,64 +80,64 @@  discard block
 block discarded – undo
80 80
      */
81 81
     public function render()
82 82
     {
83
-        if (empty(glsr()->schemas)) {
83
+        if( empty(glsr()->schemas) ) {
84 84
             return;
85 85
         }
86
-        printf('<script type="application/ld+json">%s</script>', json_encode(
87
-            apply_filters('site-reviews/schema/all', glsr()->schemas),
86
+        printf( '<script type="application/ld+json">%s</script>', json_encode(
87
+            apply_filters( 'site-reviews/schema/all', glsr()->schemas ),
88 88
             JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES
89
-        ));
89
+        ) );
90 90
     }
91 91
 
92 92
     /**
93 93
      * @return void
94 94
      */
95
-    public function store(array $schema)
95
+    public function store( array $schema )
96 96
     {
97 97
         $schemas = glsr()->schemas;
98 98
         $schemas[] = $schema;
99
-        glsr()->schemas = array_map('unserialize', array_unique(array_map('serialize', $schemas)));
99
+        glsr()->schemas = array_map( 'unserialize', array_unique( array_map( 'serialize', $schemas ) ) );
100 100
     }
101 101
 
102 102
     /**
103 103
      * @param Review $review
104 104
      * @return array
105 105
      */
106
-    protected function buildReview($review)
106
+    protected function buildReview( $review )
107 107
     {
108
-        $schema = $this->getSchemaType('Review')
109
-            ->doIf(!in_array('title', $this->args['hide']), function ($schema) use ($review) {
110
-                $schema->name($review->title);
108
+        $schema = $this->getSchemaType( 'Review' )
109
+            ->doIf( !in_array( 'title', $this->args['hide'] ), function( $schema ) use ($review) {
110
+                $schema->name( $review->title );
111 111
             })
112
-            ->doIf(!in_array('excerpt', $this->args['hide']), function ($schema) use ($review) {
113
-                $schema->reviewBody($review->content);
112
+            ->doIf( !in_array( 'excerpt', $this->args['hide'] ), function( $schema ) use ($review) {
113
+                $schema->reviewBody( $review->content );
114 114
             })
115
-            ->datePublished((new DateTime($review->date)))
116
-            ->author($this->getSchemaType('Person')->name($review->author))
117
-            ->itemReviewed($this->getSchemaType()->name($this->getSchemaOptionValue('name')));
118
-        if (!empty($review->rating)) {
115
+            ->datePublished( (new DateTime( $review->date )) )
116
+            ->author( $this->getSchemaType( 'Person' )->name( $review->author ) )
117
+            ->itemReviewed( $this->getSchemaType()->name( $this->getSchemaOptionValue( 'name' ) ) );
118
+        if( !empty($review->rating) ) {
119 119
             $schema->reviewRating(
120
-                $this->getSchemaType('Rating')
121
-                    ->ratingValue($review->rating)
122
-                    ->bestRating(glsr()->constant('MAX_RATING', Rating::class))
123
-                    ->worstRating(glsr()->constant('MIN_RATING', Rating::class))
120
+                $this->getSchemaType( 'Rating' )
121
+                    ->ratingValue( $review->rating )
122
+                    ->bestRating( glsr()->constant( 'MAX_RATING', Rating::class ) )
123
+                    ->worstRating( glsr()->constant( 'MIN_RATING', Rating::class ) )
124 124
             );
125 125
         }
126
-        return apply_filters('site-reviews/schema/review', $schema->toArray(), $review, $this->args);
126
+        return apply_filters( 'site-reviews/schema/review', $schema->toArray(), $review, $this->args );
127 127
     }
128 128
 
129 129
     /**
130 130
      * @param mixed $schema
131 131
      * @return mixed
132 132
      */
133
-    protected function buildSchemaValues($schema, array $values = [])
133
+    protected function buildSchemaValues( $schema, array $values = [] )
134 134
     {
135
-        foreach ($values as $value) {
136
-            $option = $this->getSchemaOptionValue($value);
137
-            if (empty($option)) {
135
+        foreach( $values as $value ) {
136
+            $option = $this->getSchemaOptionValue( $value );
137
+            if( empty($option) ) {
138 138
                 continue;
139 139
             }
140
-            $schema->$value($option);
140
+            $schema->$value( $option );
141 141
         }
142 142
         return $schema;
143 143
     }
@@ -147,9 +147,9 @@  discard block
 block discarded – undo
147 147
      */
148 148
     protected function buildSummaryForCustom()
149 149
     {
150
-        return $this->buildSchemaValues($this->getSchemaType(), [
150
+        return $this->buildSchemaValues( $this->getSchemaType(), [
151 151
             'description', 'image', 'name', 'url',
152
-        ]);
152
+        ] );
153 153
     }
154 154
 
155 155
     /**
@@ -157,9 +157,9 @@  discard block
 block discarded – undo
157 157
      */
158 158
     protected function buildSummaryForLocalBusiness()
159 159
     {
160
-        return $this->buildSchemaValues($this->buildSummaryForCustom(), [
160
+        return $this->buildSchemaValues( $this->buildSummaryForCustom(), [
161 161
             'address', 'priceRange', 'telephone',
162
-        ]);
162
+        ] );
163 163
     }
164 164
 
165 165
     /**
@@ -167,15 +167,15 @@  discard block
 block discarded – undo
167 167
      */
168 168
     protected function buildSummaryForProduct()
169 169
     {
170
-        $offerType = $this->getSchemaOption('offerType', 'AggregateOffer');
171
-        $offers = $this->buildSchemaValues($this->getSchemaType($offerType), [
170
+        $offerType = $this->getSchemaOption( 'offerType', 'AggregateOffer' );
171
+        $offers = $this->buildSchemaValues( $this->getSchemaType( $offerType ), [
172 172
             'highPrice', 'lowPrice', 'price', 'priceCurrency',
173
-        ]);
173
+        ] );
174 174
         return $this->buildSummaryForCustom()
175
-            ->doIf(!empty($offers->getProperties()), function ($schema) use ($offers) {
176
-                $schema->offers($offers);
175
+            ->doIf( !empty($offers->getProperties()), function( $schema ) use ($offers) {
176
+                $schema->offers( $offers );
177 177
             })
178
-            ->setProperty('@id', $this->getSchemaOptionValue('url').'#product');
178
+            ->setProperty( '@id', $this->getSchemaOptionValue( 'url' ).'#product' );
179 179
     }
180 180
 
181 181
     /**
@@ -183,8 +183,8 @@  discard block
 block discarded – undo
183 183
      */
184 184
     protected function getRatingCounts()
185 185
     {
186
-        if (!isset($this->ratingCounts)) {
187
-            $this->ratingCounts = glsr(ReviewManager::class)->getRatingCounts($this->args);
186
+        if( !isset($this->ratingCounts) ) {
187
+            $this->ratingCounts = glsr( ReviewManager::class )->getRatingCounts( $this->args );
188 188
         }
189 189
         return $this->ratingCounts;
190 190
     }
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
      */
195 195
     protected function getRatingValue()
196 196
     {
197
-        return glsr(Rating::class)->getAverage($this->getRatingCounts());
197
+        return glsr( Rating::class )->getAverage( $this->getRatingCounts() );
198 198
     }
199 199
 
200 200
     /**
@@ -202,15 +202,15 @@  discard block
 block discarded – undo
202 202
      * @param string $fallback
203 203
      * @return string
204 204
      */
205
-    protected function getSchemaOption($option, $fallback)
205
+    protected function getSchemaOption( $option, $fallback )
206 206
     {
207
-        $option = strtolower($option);
208
-        if ($schemaOption = trim((string) get_post_meta(intval(get_the_ID()), 'schema_'.$option, true))) {
207
+        $option = strtolower( $option );
208
+        if( $schemaOption = trim( (string)get_post_meta( intval( get_the_ID() ), 'schema_'.$option, true ) ) ) {
209 209
             return $schemaOption;
210 210
         }
211
-        $setting = glsr(OptionManager::class)->get('settings.schema.'.$option);
212
-        if (is_array($setting)) {
213
-            return $this->getSchemaOptionDefault($setting, $fallback);
211
+        $setting = glsr( OptionManager::class )->get( 'settings.schema.'.$option );
212
+        if( is_array( $setting ) ) {
213
+            return $this->getSchemaOptionDefault( $setting, $fallback );
214 214
         }
215 215
         return !empty($setting)
216 216
             ? $setting
@@ -221,12 +221,12 @@  discard block
 block discarded – undo
221 221
      * @param string $fallback
222 222
      * @return string
223 223
      */
224
-    protected function getSchemaOptionDefault(array $setting, $fallback)
224
+    protected function getSchemaOptionDefault( array $setting, $fallback )
225 225
     {
226
-        $setting = wp_parse_args($setting, [
226
+        $setting = wp_parse_args( $setting, [
227 227
             'custom' => '',
228 228
             'default' => $fallback,
229
-        ]);
229
+        ] );
230 230
         return 'custom' != $setting['default']
231 231
             ? $setting['default']
232 232
             : $setting['custom'];
@@ -237,17 +237,17 @@  discard block
 block discarded – undo
237 237
      * @param string $fallback
238 238
      * @return void|string
239 239
      */
240
-    protected function getSchemaOptionValue($option, $fallback = 'post')
240
+    protected function getSchemaOptionValue( $option, $fallback = 'post' )
241 241
     {
242
-        $value = $this->getSchemaOption($option, $fallback);
243
-        if ($value != $fallback) {
242
+        $value = $this->getSchemaOption( $option, $fallback );
243
+        if( $value != $fallback ) {
244 244
             return $value;
245 245
         }
246
-        if (!is_single() && !is_page()) {
246
+        if( !is_single() && !is_page() ) {
247 247
             return;
248 248
         }
249
-        $method = Helper::buildMethodName($option, 'getThing');
250
-        if (method_exists($this, $method)) {
249
+        $method = Helper::buildMethodName( $option, 'getThing' );
250
+        if( method_exists( $this, $method ) ) {
251 251
             return $this->$method();
252 252
         }
253 253
     }
@@ -256,15 +256,15 @@  discard block
 block discarded – undo
256 256
      * @param string|null $type
257 257
      * @return mixed
258 258
      */
259
-    protected function getSchemaType($type = null)
259
+    protected function getSchemaType( $type = null )
260 260
     {
261
-        if (!is_string($type)) {
262
-            $type = $this->getSchemaOption('type', 'LocalBusiness');
261
+        if( !is_string( $type ) ) {
262
+            $type = $this->getSchemaOption( 'type', 'LocalBusiness' );
263 263
         }
264
-        $className = Helper::buildClassName($type, 'Modules\Schema');
265
-        return class_exists($className)
264
+        $className = Helper::buildClassName( $type, 'Modules\Schema' );
265
+        return class_exists( $className )
266 266
             ? new $className()
267
-            : new UnknownType($type);
267
+            : new UnknownType( $type );
268 268
     }
269 269
 
270 270
     /**
@@ -272,8 +272,8 @@  discard block
 block discarded – undo
272 272
      */
273 273
     protected function getThingDescription()
274 274
     {
275
-        $description = strip_shortcodes(wp_strip_all_tags(get_the_excerpt()));
276
-        return wp_trim_words($description, apply_filters('excerpt_length', 55));
275
+        $description = strip_shortcodes( wp_strip_all_tags( get_the_excerpt() ) );
276
+        return wp_trim_words( $description, apply_filters( 'excerpt_length', 55 ) );
277 277
     }
278 278
 
279 279
     /**
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
      */
282 282
     protected function getThingImage()
283 283
     {
284
-        return (string) get_the_post_thumbnail_url(null, 'large');
284
+        return (string)get_the_post_thumbnail_url( null, 'large' );
285 285
     }
286 286
 
287 287
     /**
@@ -297,6 +297,6 @@  discard block
 block discarded – undo
297 297
      */
298 298
     protected function getThingUrl()
299 299
     {
300
-        return (string) get_the_permalink();
300
+        return (string)get_the_permalink();
301 301
     }
302 302
 }
Please login to merge, or discard this patch.
plugin/Controllers/EditorController/Metaboxes.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -11,29 +11,29 @@
 block discarded – undo
11 11
      * @param int $postId
12 12
      * @return void
13 13
      */
14
-    public function saveAssignedToMetabox($postId)
14
+    public function saveAssignedToMetabox( $postId )
15 15
     {
16
-        if (!wp_verify_nonce(Helper::filterInput('_nonce-assigned-to'), 'assigned_to')) {
16
+        if( !wp_verify_nonce( Helper::filterInput( '_nonce-assigned-to' ), 'assigned_to' ) ) {
17 17
             return;
18 18
         }
19
-        $assignedTo = strval(Helper::filterInput('assigned_to'));
20
-        glsr(Database::class)->update($postId, 'assigned_to', $assignedTo);
19
+        $assignedTo = strval( Helper::filterInput( 'assigned_to' ) );
20
+        glsr( Database::class )->update( $postId, 'assigned_to', $assignedTo );
21 21
     }
22 22
 
23 23
     /**
24 24
      * @param int $postId
25 25
      * @return mixed
26 26
      */
27
-    public function saveResponseMetabox($postId)
27
+    public function saveResponseMetabox( $postId )
28 28
     {
29
-        if (!wp_verify_nonce(Helper::filterInput('_nonce-response'), 'response')) {
29
+        if( !wp_verify_nonce( Helper::filterInput( '_nonce-response' ), 'response' ) ) {
30 30
             return;
31 31
         }
32
-        $response = strval(Helper::filterInput('response'));
33
-        glsr(Database::class)->update($postId, 'response', trim(wp_kses($response, [
32
+        $response = strval( Helper::filterInput( 'response' ) );
33
+        glsr( Database::class )->update( $postId, 'response', trim( wp_kses( $response, [
34 34
             'a' => ['href' => [], 'title' => []],
35 35
             'em' => [],
36 36
             'strong' => [],
37
-        ])));
37
+        ] ) ) );
38 38
     }
39 39
 }
Please login to merge, or discard this patch.
plugin/Controllers/BlocksController.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -13,9 +13,9 @@  discard block
 block discarded – undo
13 13
      * @return array
14 14
      * @filter block_categories
15 15
      */
16
-    public function filterBlockCategories($categories)
16
+    public function filterBlockCategories( $categories )
17 17
     {
18
-        $categories = Arr::consolidateArray($categories);
18
+        $categories = Arr::consolidateArray( $categories );
19 19
         $categories[] = [
20 20
             'icon' => null,
21 21
             'slug' => Application::ID,
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
      * @filter classic_editor_enabled_editors_for_post_type
32 32
      * @plugin classic-editor/classic-editor.php
33 33
      */
34
-    public function filterEnabledEditors($editors, $postType)
34
+    public function filterEnabledEditors( $editors, $postType )
35 35
     {
36 36
         return Application::POST_TYPE == $postType
37 37
             ? ['block_editor' => false, 'classic_editor' => false]
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
      * @return bool
45 45
      * @filter use_block_editor_for_post_type
46 46
      */
47
-    public function filterUseBlockEditor($bool, $postType)
47
+    public function filterUseBlockEditor( $bool, $postType )
48 48
     {
49 49
         return Application::POST_TYPE == $postType
50 50
             ? false
@@ -58,13 +58,13 @@  discard block
 block discarded – undo
58 58
     {
59 59
         wp_register_style(
60 60
             Application::ID.'/blocks',
61
-            glsr()->url('assets/styles/'.Application::ID.'-blocks.css'),
61
+            glsr()->url( 'assets/styles/'.Application::ID.'-blocks.css' ),
62 62
             ['wp-edit-blocks'],
63 63
             glsr()->version
64 64
         );
65 65
         wp_register_script(
66 66
             Application::ID.'/blocks',
67
-            glsr()->url('assets/scripts/'.Application::ID.'-blocks.js'),
67
+            glsr()->url( 'assets/scripts/'.Application::ID.'-blocks.js' ),
68 68
             ['wp-api-fetch', 'wp-blocks', 'wp-i18n', 'wp-editor', 'wp-element', Application::ID],
69 69
             glsr()->version
70 70
         );
@@ -79,14 +79,14 @@  discard block
 block discarded – undo
79 79
         $blocks = [
80 80
             'form', 'reviews', 'summary',
81 81
         ];
82
-        foreach ($blocks as $block) {
83
-            $id = str_replace('_reviews', '', Application::ID.'_'.$block);
84
-            $blockClass = Helper::buildClassName($id.'-block', 'Blocks');
85
-            if (!class_exists($blockClass)) {
86
-                glsr_log()->error(sprintf('Class missing (%s)', $blockClass));
82
+        foreach( $blocks as $block ) {
83
+            $id = str_replace( '_reviews', '', Application::ID.'_'.$block );
84
+            $blockClass = Helper::buildClassName( $id.'-block', 'Blocks' );
85
+            if( !class_exists( $blockClass ) ) {
86
+                glsr_log()->error( sprintf( 'Class missing (%s)', $blockClass ) );
87 87
                 continue;
88 88
             }
89
-            glsr($blockClass)->register($block);
89
+            glsr( $blockClass )->register( $block );
90 90
         }
91 91
     }
92 92
 }
Please login to merge, or discard this patch.
plugin/Controllers/PublicController.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -28,14 +28,14 @@  discard block
 block discarded – undo
28 28
      * @return string
29 29
      * @filter script_loader_tag
30 30
      */
31
-    public function filterEnqueuedScripts($tag, $handle)
31
+    public function filterEnqueuedScripts( $tag, $handle )
32 32
     {
33 33
         $scripts = [Application::ID.'/google-recaptcha'];
34
-        if (in_array($handle, apply_filters('site-reviews/async-scripts', $scripts))) {
35
-            $tag = str_replace(' src=', ' async src=', $tag);
34
+        if( in_array( $handle, apply_filters( 'site-reviews/async-scripts', $scripts ) ) ) {
35
+            $tag = str_replace( ' src=', ' async src=', $tag );
36 36
         }
37
-        if (in_array($handle, apply_filters('site-reviews/defer-scripts', $scripts))) {
38
-            $tag = str_replace(' src=', ' defer src=', $tag);
37
+        if( in_array( $handle, apply_filters( 'site-reviews/defer-scripts', $scripts ) ) ) {
38
+            $tag = str_replace( ' src=', ' defer src=', $tag );
39 39
         }
40 40
         return $tag;
41 41
     }
@@ -44,10 +44,10 @@  discard block
 block discarded – undo
44 44
      * @return array
45 45
      * @filter site-reviews/config/forms/submission-form
46 46
      */
47
-    public function filterFieldOrder(array $config)
47
+    public function filterFieldOrder( array $config )
48 48
     {
49
-        $order = (array) apply_filters('site-reviews/submission-form/order', array_keys($config));
50
-        return array_intersect_key(array_merge(array_flip($order), $config), $config);
49
+        $order = (array)apply_filters( 'site-reviews/submission-form/order', array_keys( $config ) );
50
+        return array_intersect_key( array_merge( array_flip( $order ), $config ), $config );
51 51
     }
52 52
 
53 53
     /**
@@ -55,10 +55,10 @@  discard block
 block discarded – undo
55 55
      * @return array
56 56
      * @filter query_vars
57 57
      */
58
-    public function filterQueryVars($vars)
58
+    public function filterQueryVars( $vars )
59 59
     {
60
-        $vars = Arr::consolidateArray($vars);
61
-        $vars[] = glsr()->constant('PAGED_QUERY_VAR');
60
+        $vars = Arr::consolidateArray( $vars );
61
+        $vars[] = glsr()->constant( 'PAGED_QUERY_VAR' );
62 62
         return $vars;
63 63
     }
64 64
 
@@ -67,18 +67,18 @@  discard block
 block discarded – undo
67 67
      * @return string
68 68
      * @filter site-reviews/render/view
69 69
      */
70
-    public function filterRenderView($view)
70
+    public function filterRenderView( $view )
71 71
     {
72
-        return glsr(Style::class)->filterView($view);
72
+        return glsr( Style::class )->filterView( $view );
73 73
     }
74 74
 
75 75
     /**
76 76
      * @return void
77 77
      * @action site-reviews/builder
78 78
      */
79
-    public function modifyBuilder(Builder $instance)
79
+    public function modifyBuilder( Builder $instance )
80 80
     {
81
-        call_user_func_array([glsr(Style::class), 'modifyField'], [$instance]);
81
+        call_user_func_array( [glsr( Style::class ), 'modifyField'], [$instance] );
82 82
     }
83 83
 
84 84
     /**
@@ -87,18 +87,18 @@  discard block
 block discarded – undo
87 87
      */
88 88
     public function renderSchema()
89 89
     {
90
-        glsr(Schema::class)->render();
90
+        glsr( Schema::class )->render();
91 91
     }
92 92
 
93 93
     /**
94 94
      * @return CreateReview
95 95
      */
96
-    public function routerSubmitReview(array $request)
96
+    public function routerSubmitReview( array $request )
97 97
     {
98
-        $validated = glsr(ValidateReview::class)->validate($request);
99
-        $command = new CreateReview($validated->request);
100
-        if (empty($validated->error) && !$validated->recaptchaIsUnset) {
101
-            $this->execute($command);
98
+        $validated = glsr( ValidateReview::class )->validate( $request );
99
+        $command = new CreateReview( $validated->request );
100
+        if( empty($validated->error) && !$validated->recaptchaIsUnset ) {
101
+            $this->execute( $command );
102 102
         }
103 103
         return $command;
104 104
     }
Please login to merge, or discard this patch.
plugin/Handlers/RegisterShortcodes.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -10,15 +10,15 @@
 block discarded – undo
10 10
     /**
11 11
      * @return void
12 12
      */
13
-    public function handle(Command $command)
13
+    public function handle( Command $command )
14 14
     {
15
-        foreach ($command->shortcodes as $shortcode) {
16
-            $shortcodeClass = Helper::buildClassName($shortcode.'-shortcode', 'Shortcodes');
17
-            if (!class_exists($shortcodeClass)) {
18
-                glsr_log()->error(sprintf('Class missing (%s)', $shortcodeClass));
15
+        foreach( $command->shortcodes as $shortcode ) {
16
+            $shortcodeClass = Helper::buildClassName( $shortcode.'-shortcode', 'Shortcodes' );
17
+            if( !class_exists( $shortcodeClass ) ) {
18
+                glsr_log()->error( sprintf( 'Class missing (%s)', $shortcodeClass ) );
19 19
                 continue;
20 20
             }
21
-            add_shortcode($shortcode, [glsr($shortcodeClass), 'buildShortcode']);
21
+            add_shortcode( $shortcode, [glsr( $shortcodeClass ), 'buildShortcode'] );
22 22
         }
23 23
     }
24 24
 }
Please login to merge, or discard this patch.
plugin/Handlers/RegisterTinymcePopups.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -10,18 +10,18 @@
 block discarded – undo
10 10
     /**
11 11
      * @return void
12 12
      */
13
-    public function handle(Command $command)
13
+    public function handle( Command $command )
14 14
     {
15
-        foreach ($command->popups as $slug => $label) {
16
-            $buttonClass = Helper::buildClassName($slug.'-popup', 'Shortcodes');
17
-            if (!class_exists($buttonClass)) {
18
-                glsr_log()->error(sprintf('Class missing (%s)', $buttonClass));
15
+        foreach( $command->popups as $slug => $label ) {
16
+            $buttonClass = Helper::buildClassName( $slug.'-popup', 'Shortcodes' );
17
+            if( !class_exists( $buttonClass ) ) {
18
+                glsr_log()->error( sprintf( 'Class missing (%s)', $buttonClass ) );
19 19
                 continue;
20 20
             }
21
-            $shortcode = glsr($buttonClass)->register($slug, [
21
+            $shortcode = glsr( $buttonClass )->register( $slug, [
22 22
                 'label' => $label,
23 23
                 'title' => $label,
24
-            ]);
24
+            ] );
25 25
             glsr()->mceShortcodes[$slug] = $shortcode->properties;
26 26
         }
27 27
     }
Please login to merge, or discard this patch.
plugin/Handlers/RegisterWidgets.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -11,17 +11,17 @@
 block discarded – undo
11 11
     /**
12 12
      * @return void
13 13
      */
14
-    public function handle(Command $command)
14
+    public function handle( Command $command )
15 15
     {
16 16
         global $wp_widget_factory;
17
-        foreach ($command->widgets as $key => $values) {
18
-            $widgetClass = Helper::buildClassName($key.'-widget', 'Widgets');
19
-            if (!class_exists($widgetClass)) {
20
-                glsr_log()->error(sprintf('Class missing (%s)', $widgetClass));
17
+        foreach( $command->widgets as $key => $values ) {
18
+            $widgetClass = Helper::buildClassName( $key.'-widget', 'Widgets' );
19
+            if( !class_exists( $widgetClass ) ) {
20
+                glsr_log()->error( sprintf( 'Class missing (%s)', $widgetClass ) );
21 21
                 continue;
22 22
             }
23 23
             // Here we bypass register_widget() in order to pass our custom values to the widget
24
-            $widget = new $widgetClass(Application::ID.'_'.$key, $values['title'], $values);
24
+            $widget = new $widgetClass( Application::ID.'_'.$key, $values['title'], $values );
25 25
             $wp_widget_factory->widgets[$widgetClass] = $widget;
26 26
         }
27 27
     }
Please login to merge, or discard this patch.