Passed
Push — master ( ae1954...aab291 )
by Paul
08:17 queued 04:15
created
plugin/Shortcodes/Shortcode.php 1 patch
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -25,17 +25,17 @@  discard block
 block discarded – undo
25 25
      * @param string $type
26 26
      * @return string
27 27
      */
28
-    public function build($atts, array $args = [], $type = 'shortcode')
28
+    public function build( $atts, array $args = [], $type = 'shortcode' )
29 29
     {
30 30
         $this->partialName = $this->getShortcodePartialName();
31 31
         $this->shortcodeName = $this->getShortcodeName();
32
-        $args = $this->normalizeArgs($args, $type);
33
-        $atts = $this->normalizeAtts($atts, $type);
34
-        $partial = glsr(Partial::class)->build($this->partialName, $atts);
32
+        $args = $this->normalizeArgs( $args, $type );
33
+        $atts = $this->normalizeAtts( $atts, $type );
34
+        $partial = glsr( Partial::class )->build( $this->partialName, $atts );
35 35
         $title = !empty($atts['title'])
36 36
             ? $args['before_title'].$atts['title'].$args['after_title']
37 37
             : '';
38
-        $debug = sprintf('<glsr-%1$s hidden data-atts=\'%2$s\'></glsr-%1$s>', $type, $atts['json']);
38
+        $debug = sprintf( '<glsr-%1$s hidden data-atts=\'%2$s\'></glsr-%1$s>', $type, $atts['json'] );
39 39
         return $args['before_widget'].$title.$partial.$debug.$args['after_widget'];
40 40
     }
41 41
 
@@ -43,17 +43,17 @@  discard block
 block discarded – undo
43 43
      * @param string|array $atts
44 44
      * @return string
45 45
      */
46
-    public function buildShortcode($atts = [])
46
+    public function buildShortcode( $atts = [] )
47 47
     {
48
-        return $this->build($atts);
48
+        return $this->build( $atts );
49 49
     }
50 50
 
51 51
     /**
52 52
      * @return array
53 53
      */
54
-    public function getDefaults($atts)
54
+    public function getDefaults( $atts )
55 55
     {
56
-        return glsr($this->getShortcodeDefaultsClassName())->restrict(wp_parse_args($atts));
56
+        return glsr( $this->getShortcodeDefaultsClassName() )->restrict( wp_parse_args( $atts ) );
57 57
     }
58 58
 
59 59
     /**
@@ -62,15 +62,15 @@  discard block
 block discarded – undo
62 62
     public function getHideOptions()
63 63
     {
64 64
         $options = $this->hideOptions();
65
-        return apply_filters('site-reviews/shortcode/hide-options', $options, $this->shortcodeName);
65
+        return apply_filters( 'site-reviews/shortcode/hide-options', $options, $this->shortcodeName );
66 66
     }
67 67
 
68 68
     /**
69 69
      * @return string
70 70
      */
71
-    public function getShortcodeClassName($replace = '', $search = 'Shortcode')
71
+    public function getShortcodeClassName( $replace = '', $search = 'Shortcode' )
72 72
     {
73
-        return str_replace($search, $replace, (new ReflectionClass($this))->getShortName());
73
+        return str_replace( $search, $replace, (new ReflectionClass( $this ))->getShortName() );
74 74
     }
75 75
 
76 76
     /**
@@ -78,8 +78,8 @@  discard block
 block discarded – undo
78 78
      */
79 79
     public function getShortcodeDefaultsClassName()
80 80
     {
81
-        return glsr(Helper::class)->buildClassName(
82
-            $this->getShortcodeClassName('Defaults'),
81
+        return glsr( Helper::class )->buildClassName(
82
+            $this->getShortcodeClassName( 'Defaults' ),
83 83
             'Defaults'
84 84
         );
85 85
     }
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
      */
90 90
     public function getShortcodeName()
91 91
     {
92
-        return glsr(Helper::class)->snakeCase($this->getShortcodeClassName());
92
+        return glsr( Helper::class )->snakeCase( $this->getShortcodeClassName() );
93 93
     }
94 94
 
95 95
     /**
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
      */
98 98
     public function getShortcodePartialName()
99 99
     {
100
-        return glsr(Helper::class)->dashCase($this->getShortcodeClassName());
100
+        return glsr( Helper::class )->dashCase( $this->getShortcodeClassName() );
101 101
     }
102 102
 
103 103
     /**
@@ -105,15 +105,15 @@  discard block
 block discarded – undo
105 105
      * @param string $type
106 106
      * @return array
107 107
      */
108
-    public function normalizeArgs($args, $type = 'shortcode')
108
+    public function normalizeArgs( $args, $type = 'shortcode' )
109 109
     {
110
-        $args = wp_parse_args($args, [
110
+        $args = wp_parse_args( $args, [
111 111
             'before_widget' => '<div class="glsr-'.$type.' '.$type.'-'.$this->partialName.'">',
112 112
             'after_widget' => '</div>',
113 113
             'before_title' => '<h3 class="glsr-'.$type.'-title">',
114 114
             'after_title' => '</h3>',
115
-        ]);
116
-        return apply_filters('site-reviews/shortcode/args', $args, $type, $this->partialName);
115
+        ] );
116
+        return apply_filters( 'site-reviews/shortcode/args', $args, $type, $this->partialName );
117 117
     }
118 118
 
119 119
     /**
@@ -121,16 +121,16 @@  discard block
 block discarded – undo
121 121
      * @param string $type
122 122
      * @return array
123 123
      */
124
-    public function normalizeAtts($atts, $type = 'shortcode')
124
+    public function normalizeAtts( $atts, $type = 'shortcode' )
125 125
     {
126
-        $atts = apply_filters('site-reviews/shortcode/atts', $atts, $type, $this->partialName);
127
-        $atts = $this->getDefaults($atts);
128
-        array_walk($atts, function (&$value, $key) {
129
-            $methodName = glsr(Helper::class)->buildMethodName($key, 'normalize');
130
-            if (!method_exists($this, $methodName)) {
126
+        $atts = apply_filters( 'site-reviews/shortcode/atts', $atts, $type, $this->partialName );
127
+        $atts = $this->getDefaults( $atts );
128
+        array_walk( $atts, function( &$value, $key ) {
129
+            $methodName = glsr( Helper::class )->buildMethodName( $key, 'normalize' );
130
+            if( !method_exists( $this, $methodName ) ) {
131 131
                 return;
132 132
             }
133
-            $value = $this->$methodName($value);
133
+            $value = $this->$methodName( $value );
134 134
         });
135 135
         return $atts;
136 136
     }
@@ -144,12 +144,12 @@  discard block
 block discarded – undo
144 144
      * @param string $postId
145 145
      * @return int|string
146 146
      */
147
-    protected function normalizeAssignedTo($postId)
147
+    protected function normalizeAssignedTo( $postId )
148 148
     {
149
-        if ('parent_id' == $postId) {
150
-            $postId = intval(wp_get_post_parent_id(intval(get_the_ID())));
151
-        } elseif ('post_id' == $postId) {
152
-            $postId = intval(get_the_ID());
149
+        if( 'parent_id' == $postId ) {
150
+            $postId = intval( wp_get_post_parent_id( intval( get_the_ID() ) ) );
151
+        } elseif( 'post_id' == $postId ) {
152
+            $postId = intval( get_the_ID() );
153 153
         }
154 154
         return $postId;
155 155
     }
@@ -158,23 +158,23 @@  discard block
 block discarded – undo
158 158
      * @param string $postId
159 159
      * @return int|string
160 160
      */
161
-    protected function normalizeAssignTo($postId)
161
+    protected function normalizeAssignTo( $postId )
162 162
     {
163
-        return $this->normalizeAssignedTo($postId);
163
+        return $this->normalizeAssignedTo( $postId );
164 164
     }
165 165
 
166 166
     /**
167 167
      * @param string|array $hide
168 168
      * @return array
169 169
      */
170
-    protected function normalizeHide($hide)
170
+    protected function normalizeHide( $hide )
171 171
     {
172
-        if (is_string($hide)) {
173
-            $hide = explode(',', $hide);
172
+        if( is_string( $hide ) ) {
173
+            $hide = explode( ',', $hide );
174 174
         }
175
-        $hideKeys = array_keys($this->getHideOptions());
176
-        return array_filter(array_map('trim', $hide), function ($value) use ($hideKeys) {
177
-            return in_array($value, $hideKeys);
175
+        $hideKeys = array_keys( $this->getHideOptions() );
176
+        return array_filter( array_map( 'trim', $hide ), function( $value ) use ($hideKeys) {
177
+            return in_array( $value, $hideKeys );
178 178
         });
179 179
     }
180 180
 
@@ -182,51 +182,51 @@  discard block
 block discarded – undo
182 182
      * @param string $id
183 183
      * @return string
184 184
      */
185
-    protected function normalizeId($id)
185
+    protected function normalizeId( $id )
186 186
     {
187
-        return sanitize_title($id);
187
+        return sanitize_title( $id );
188 188
     }
189 189
 
190 190
     /**
191 191
      * @param string $labels
192 192
      * @return array
193 193
      */
194
-    protected function normalizeLabels($labels)
194
+    protected function normalizeLabels( $labels )
195 195
     {
196 196
         $defaults = [
197
-            __('Excellent', 'site-reviews'),
198
-            __('Very good', 'site-reviews'),
199
-            __('Average', 'site-reviews'),
200
-            __('Poor', 'site-reviews'),
201
-            __('Terrible', 'site-reviews'),
197
+            __( 'Excellent', 'site-reviews' ),
198
+            __( 'Very good', 'site-reviews' ),
199
+            __( 'Average', 'site-reviews' ),
200
+            __( 'Poor', 'site-reviews' ),
201
+            __( 'Terrible', 'site-reviews' ),
202 202
         ];
203
-        $maxRating = glsr()->constant('MAX_RATING', Rating::class);
204
-        $defaults = array_pad(array_slice($defaults, 0, $maxRating), $maxRating, '');
205
-        $labels = array_map('trim', explode(',', $labels));
206
-        foreach ($defaults as $i => $label) {
207
-            if (empty($labels[$i])) {
203
+        $maxRating = glsr()->constant( 'MAX_RATING', Rating::class );
204
+        $defaults = array_pad( array_slice( $defaults, 0, $maxRating ), $maxRating, '' );
205
+        $labels = array_map( 'trim', explode( ',', $labels ) );
206
+        foreach( $defaults as $i => $label ) {
207
+            if( empty($labels[$i]) ) {
208 208
                 continue;
209 209
             }
210 210
             $defaults[$i] = $labels[$i];
211 211
         }
212
-        return array_combine(range($maxRating, 1), $defaults);
212
+        return array_combine( range( $maxRating, 1 ), $defaults );
213 213
     }
214 214
 
215 215
     /**
216 216
      * @param string $schema
217 217
      * @return bool
218 218
      */
219
-    protected function normalizeSchema($schema)
219
+    protected function normalizeSchema( $schema )
220 220
     {
221
-        return wp_validate_boolean($schema);
221
+        return wp_validate_boolean( $schema );
222 222
     }
223 223
 
224 224
     /**
225 225
      * @param string $text
226 226
      * @return string
227 227
      */
228
-    protected function normalizeText($text)
228
+    protected function normalizeText( $text )
229 229
     {
230
-        return trim($text);
230
+        return trim( $text );
231 231
     }
232 232
 }
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 = glsr(Helper::class)->buildMethodName($this->getSchemaOptionValue('type'), 'buildSummaryFor');
61
-        $count = array_sum($this->getRatingCounts());
62
-        $schema = method_exists($this, $buildSummary)
60
+        $buildSummary = glsr( Helper::class )->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 = glsr(Helper::class)->buildMethodName($option, 'getThing');
250
-        if (method_exists($this, $method)) {
249
+        $method = glsr( Helper::class )->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 = glsr(Helper::class)->buildClassName($type, 'Modules\Schema');
265
-        return class_exists($className)
264
+        $className = glsr( Helper::class )->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/Modules/Html/Settings.php 1 patch
Spacing   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -18,31 +18,31 @@  discard block
 block discarded – undo
18 18
      * @param string $id
19 19
      * @return string
20 20
      */
21
-    public function buildFields($id)
21
+    public function buildFields( $id )
22 22
     {
23
-        $this->settings = glsr(DefaultsManager::class)->settings();
24
-        $method = glsr(Helper::class)->buildMethodName($id, 'getTemplateDataFor');
25
-        $data = !method_exists($this, $method)
26
-            ? $this->getTemplateData($id)
27
-            : $this->$method($id);
28
-        return glsr(Template::class)->build('pages/settings/'.$id, $data);
23
+        $this->settings = glsr( DefaultsManager::class )->settings();
24
+        $method = glsr( Helper::class )->buildMethodName( $id, 'getTemplateDataFor' );
25
+        $data = !method_exists( $this, $method )
26
+            ? $this->getTemplateData( $id )
27
+            : $this->$method( $id );
28
+        return glsr( Template::class )->build( 'pages/settings/'.$id, $data );
29 29
     }
30 30
 
31 31
     /**
32 32
      * @return string
33 33
      */
34
-    protected function getFieldDefault(array $field)
34
+    protected function getFieldDefault( array $field )
35 35
     {
36
-        return glsr_get($field, 'default');
36
+        return glsr_get( $field, 'default' );
37 37
     }
38 38
 
39 39
     /**
40 40
      * @return string
41 41
      */
42
-    protected function getFieldNameForDependsOn($path)
42
+    protected function getFieldNameForDependsOn( $path )
43 43
     {
44
-        $fieldName = glsr(Helper::class)->convertPathToName($path, OptionManager::databaseKey());
45
-        return $this->isMultiDependency($path)
44
+        $fieldName = glsr( Helper::class )->convertPathToName( $path, OptionManager::databaseKey() );
45
+        return $this->isMultiDependency( $path )
46 46
             ? $fieldName.'[]'
47 47
             : $fieldName;
48 48
     }
@@ -50,25 +50,25 @@  discard block
 block discarded – undo
50 50
     /**
51 51
      * @return array
52 52
      */
53
-    protected function getSettingFields($path)
53
+    protected function getSettingFields( $path )
54 54
     {
55
-        return array_filter($this->settings, function ($key) use ($path) {
56
-            return glsr(Helper::class)->startsWith($path, $key);
57
-        }, ARRAY_FILTER_USE_KEY);
55
+        return array_filter( $this->settings, function( $key ) use ($path) {
56
+            return glsr( Helper::class )->startsWith( $path, $key );
57
+        }, ARRAY_FILTER_USE_KEY );
58 58
     }
59 59
 
60 60
     /**
61 61
      * @return string
62 62
      */
63
-    protected function getSettingRows(array $fields)
63
+    protected function getSettingRows( array $fields )
64 64
     {
65 65
         $rows = '';
66
-        foreach ($fields as $name => $field) {
67
-            $field = wp_parse_args($field, [
66
+        foreach( $fields as $name => $field ) {
67
+            $field = wp_parse_args( $field, [
68 68
                 'is_setting' => true,
69 69
                 'name' => $name,
70
-            ]);
71
-            $rows.= new Field($this->normalize($field));
70
+            ] );
71
+            $rows .= new Field( $this->normalize( $field ) );
72 72
         }
73 73
         return $rows;
74 74
     }
@@ -77,12 +77,12 @@  discard block
 block discarded – undo
77 77
      * @param string $id
78 78
      * @return array
79 79
      */
80
-    protected function getTemplateData($id)
80
+    protected function getTemplateData( $id )
81 81
     {
82
-        $fields = $this->getSettingFields($this->normalizeSettingPath($id));
82
+        $fields = $this->getSettingFields( $this->normalizeSettingPath( $id ) );
83 83
         return [
84 84
             'context' => [
85
-                'rows' => $this->getSettingRows($fields),
85
+                'rows' => $this->getSettingRows( $fields ),
86 86
             ],
87 87
         ];
88 88
     }
@@ -91,19 +91,19 @@  discard block
 block discarded – undo
91 91
      * @param string $id
92 92
      * @return array
93 93
      */
94
-    protected function getTemplateDataForAddons($id)
94
+    protected function getTemplateDataForAddons( $id )
95 95
     {
96
-        $fields = $this->getSettingFields($this->normalizeSettingPath($id));
97
-        $settings = glsr(Helper::class)->convertDotNotationArray($fields);
98
-        $settingKeys = array_keys($settings['settings']['addons']);
96
+        $fields = $this->getSettingFields( $this->normalizeSettingPath( $id ) );
97
+        $settings = glsr( Helper::class )->convertDotNotationArray( $fields );
98
+        $settingKeys = array_keys( $settings['settings']['addons'] );
99 99
         $results = [];
100
-        foreach ($settingKeys as $key) {
101
-            $addonFields = array_filter($fields, function ($path) use ($key) {
102
-                return glsr(Helper::class)->startsWith('settings.addons.'.$key, $path);
103
-            }, ARRAY_FILTER_USE_KEY);
104
-            $results[$key] = $this->getSettingRows($addonFields);
100
+        foreach( $settingKeys as $key ) {
101
+            $addonFields = array_filter( $fields, function( $path ) use ($key) {
102
+                return glsr( Helper::class )->startsWith( 'settings.addons.'.$key, $path );
103
+            }, ARRAY_FILTER_USE_KEY );
104
+            $results[$key] = $this->getSettingRows( $addonFields );
105 105
         }
106
-        ksort($results);
106
+        ksort( $results );
107 107
         return [
108 108
             'settings' => $results,
109 109
         ];
@@ -113,13 +113,13 @@  discard block
 block discarded – undo
113 113
      * @param string $id
114 114
      * @return array
115 115
      */
116
-    protected function getTemplateDataForLicenses($id)
116
+    protected function getTemplateDataForLicenses( $id )
117 117
     {
118
-        $fields = $this->getSettingFields($this->normalizeSettingPath($id));
119
-        ksort($fields);
118
+        $fields = $this->getSettingFields( $this->normalizeSettingPath( $id ) );
119
+        ksort( $fields );
120 120
         return [
121 121
             'context' => [
122
-                'rows' => $this->getSettingRows($fields),
122
+                'rows' => $this->getSettingRows( $fields ),
123 123
             ],
124 124
         ];
125 125
     }
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
      */
130 130
     protected function getTemplateDataForTranslations()
131 131
     {
132
-        $translations = glsr(Translation::class)->renderAll();
132
+        $translations = glsr( Translation::class )->renderAll();
133 133
         $class = empty($translations)
134 134
             ? 'glsr-hidden'
135 135
             : '';
@@ -147,16 +147,16 @@  discard block
 block discarded – undo
147 147
      * @param string|array $expectedValue
148 148
      * @return bool
149 149
      */
150
-    protected function isFieldHidden($path, $expectedValue)
150
+    protected function isFieldHidden( $path, $expectedValue )
151 151
     {
152
-        $optionValue = glsr(OptionManager::class)->get(
152
+        $optionValue = glsr( OptionManager::class )->get(
153 153
             $path,
154
-            glsr(Helper::class)->dataGet(glsr()->defaults, $path)
154
+            glsr( Helper::class )->dataGet( glsr()->defaults, $path )
155 155
         );
156
-        if (is_array($expectedValue)) {
157
-            return is_array($optionValue)
158
-                ? 0 === count(array_intersect($optionValue, $expectedValue))
159
-                : !in_array($optionValue, $expectedValue);
156
+        if( is_array( $expectedValue ) ) {
157
+            return is_array( $optionValue )
158
+                ? 0 === count( array_intersect( $optionValue, $expectedValue ) )
159
+                : !in_array( $optionValue, $expectedValue );
160 160
         }
161 161
         return $optionValue != $expectedValue;
162 162
     }
@@ -164,9 +164,9 @@  discard block
 block discarded – undo
164 164
     /**
165 165
      * @return bool
166 166
      */
167
-    protected function isMultiDependency($path)
167
+    protected function isMultiDependency( $path )
168 168
     {
169
-        if (isset($this->settings[$path])) {
169
+        if( isset($this->settings[$path]) ) {
170 170
             $field = $this->settings[$path];
171 171
             return ('checkbox' == $field['type'] && !empty($field['options']))
172 172
                 || !empty($field['multiple']);
@@ -177,32 +177,32 @@  discard block
 block discarded – undo
177 177
     /**
178 178
      * @return array
179 179
      */
180
-    protected function normalize(array $field)
180
+    protected function normalize( array $field )
181 181
     {
182
-        $field = $this->normalizeDependsOn($field);
183
-        $field = $this->normalizeLabelAndLegend($field);
184
-        $field = $this->normalizeValue($field);
182
+        $field = $this->normalizeDependsOn( $field );
183
+        $field = $this->normalizeLabelAndLegend( $field );
184
+        $field = $this->normalizeValue( $field );
185 185
         return $field;
186 186
     }
187 187
 
188 188
     /**
189 189
      * @return array
190 190
      */
191
-    protected function normalizeDependsOn(array $field)
191
+    protected function normalizeDependsOn( array $field )
192 192
     {
193
-        if (!empty($field['depends_on']) && is_array($field['depends_on'])) {
193
+        if( !empty($field['depends_on']) && is_array( $field['depends_on'] ) ) {
194 194
             $isFieldHidden = false;
195 195
             $conditions = [];
196
-            foreach ($field['depends_on'] as $path => $value) {
196
+            foreach( $field['depends_on'] as $path => $value ) {
197 197
                 $conditions[] = [
198
-                    'name' => $this->getFieldNameForDependsOn($path),
198
+                    'name' => $this->getFieldNameForDependsOn( $path ),
199 199
                     'value' => $value,
200 200
                 ];
201
-                if ($this->isFieldHidden($path, $value)) {
201
+                if( $this->isFieldHidden( $path, $value ) ) {
202 202
                     $isFieldHidden = true;
203 203
                 }
204 204
             }
205
-            $field['data-depends'] = json_encode($conditions, JSON_HEX_APOS | JSON_HEX_QUOT);
205
+            $field['data-depends'] = json_encode( $conditions, JSON_HEX_APOS | JSON_HEX_QUOT );
206 206
             $field['is_hidden'] = $isFieldHidden;
207 207
         }
208 208
         return $field;
@@ -211,14 +211,14 @@  discard block
 block discarded – undo
211 211
     /**
212 212
      * @return array
213 213
      */
214
-    protected function normalizeLabelAndLegend(array $field)
214
+    protected function normalizeLabelAndLegend( array $field )
215 215
     {
216
-        if (!empty($field['label'])) {
216
+        if( !empty($field['label']) ) {
217 217
             $field['legend'] = $field['label'];
218 218
             unset($field['label']);
219 219
         } else {
220 220
             $field['is_valid'] = false;
221
-            glsr_log()->warning('Setting field is missing a label')->debug($field);
221
+            glsr_log()->warning( 'Setting field is missing a label' )->debug( $field );
222 222
         }
223 223
         return $field;
224 224
     }
@@ -226,12 +226,12 @@  discard block
 block discarded – undo
226 226
     /**
227 227
      * @return array
228 228
      */
229
-    protected function normalizeValue(array $field)
229
+    protected function normalizeValue( array $field )
230 230
     {
231
-        if (!isset($field['value'])) {
232
-            $field['value'] = glsr(OptionManager::class)->get(
231
+        if( !isset($field['value']) ) {
232
+            $field['value'] = glsr( OptionManager::class )->get(
233 233
                 $field['name'],
234
-                $this->getFieldDefault($field)
234
+                $this->getFieldDefault( $field )
235 235
             );
236 236
         }
237 237
         return $field;
@@ -240,8 +240,8 @@  discard block
 block discarded – undo
240 240
     /**
241 241
      * @return string
242 242
      */
243
-    protected function normalizeSettingPath($path)
243
+    protected function normalizeSettingPath( $path )
244 244
     {
245
-        return glsr(Helper::class)->prefix('settings.', rtrim($path, '.'));
245
+        return glsr( Helper::class )->prefix( 'settings.', rtrim( $path, '.' ) );
246 246
     }
247 247
 }
Please login to merge, or discard this patch.
plugin/Controllers/ListTableController.php 1 patch
Spacing   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -19,15 +19,15 @@  discard block
 block discarded – undo
19 19
      */
20 20
     public function approve()
21 21
     {
22
-        if (Application::ID != filter_input(INPUT_GET, 'plugin')) {
22
+        if( Application::ID != filter_input( INPUT_GET, 'plugin' ) ) {
23 23
             return;
24 24
         }
25
-        check_admin_referer('approve-review_'.($postId = $this->getPostId()));
26
-        wp_update_post([
25
+        check_admin_referer( 'approve-review_'.($postId = $this->getPostId()) );
26
+        wp_update_post( [
27 27
             'ID' => $postId,
28 28
             'post_status' => 'publish',
29
-        ]);
30
-        wp_safe_redirect(wp_get_referer());
29
+        ] );
30
+        wp_safe_redirect( wp_get_referer() );
31 31
         exit;
32 32
     }
33 33
 
@@ -36,15 +36,15 @@  discard block
 block discarded – undo
36 36
      * @return array
37 37
      * @filter bulk_post_updated_messages
38 38
      */
39
-    public function filterBulkUpdateMessages($messages, array $counts)
39
+    public function filterBulkUpdateMessages( $messages, array $counts )
40 40
     {
41
-        $messages = glsr(Helper::class)->consolidateArray($messages);
41
+        $messages = glsr( Helper::class )->consolidateArray( $messages );
42 42
         $messages[Application::POST_TYPE] = [
43
-            'updated' => _n('%s review updated.', '%s reviews updated.', $counts['updated'], 'site-reviews'),
44
-            'locked' => _n('%s review not updated, somebody is editing it.', '%s reviews not updated, somebody is editing them.', $counts['locked'], 'site-reviews'),
45
-            'deleted' => _n('%s review permanently deleted.', '%s reviews permanently deleted.', $counts['deleted'], 'site-reviews'),
46
-            'trashed' => _n('%s review moved to the Trash.', '%s reviews moved to the Trash.', $counts['trashed'], 'site-reviews'),
47
-            'untrashed' => _n('%s review restored from the Trash.', '%s reviews restored from the Trash.', $counts['untrashed'], 'site-reviews'),
43
+            'updated' => _n( '%s review updated.', '%s reviews updated.', $counts['updated'], 'site-reviews' ),
44
+            'locked' => _n( '%s review not updated, somebody is editing it.', '%s reviews not updated, somebody is editing them.', $counts['locked'], 'site-reviews' ),
45
+            'deleted' => _n( '%s review permanently deleted.', '%s reviews permanently deleted.', $counts['deleted'], 'site-reviews' ),
46
+            'trashed' => _n( '%s review moved to the Trash.', '%s reviews moved to the Trash.', $counts['trashed'], 'site-reviews' ),
47
+            'untrashed' => _n( '%s review restored from the Trash.', '%s reviews restored from the Trash.', $counts['untrashed'], 'site-reviews' ),
48 48
         ];
49 49
         return $messages;
50 50
     }
@@ -54,20 +54,20 @@  discard block
 block discarded – undo
54 54
      * @return array
55 55
      * @filter manage_.Application::POST_TYPE._posts_columns
56 56
      */
57
-    public function filterColumnsForPostType($columns)
57
+    public function filterColumnsForPostType( $columns )
58 58
     {
59
-        $columns = glsr(Helper::class)->consolidateArray($columns);
59
+        $columns = glsr( Helper::class )->consolidateArray( $columns );
60 60
         $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE];
61
-        foreach ($postTypeColumns as $key => &$value) {
62
-            if (!array_key_exists($key, $columns) || !empty($value)) {
61
+        foreach( $postTypeColumns as $key => &$value ) {
62
+            if( !array_key_exists( $key, $columns ) || !empty($value) ) {
63 63
                 continue;
64 64
             }
65 65
             $value = $columns[$key];
66 66
         }
67
-        if (count(glsr(Database::class)->getReviewsMeta('review_type')) < 2) {
67
+        if( count( glsr( Database::class )->getReviewsMeta( 'review_type' ) ) < 2 ) {
68 68
             unset($postTypeColumns['review_type']);
69 69
         }
70
-        return array_filter($postTypeColumns, 'strlen');
70
+        return array_filter( $postTypeColumns, 'strlen' );
71 71
     }
72 72
 
73 73
     /**
@@ -76,10 +76,10 @@  discard block
 block discarded – undo
76 76
      * @return string
77 77
      * @filter post_date_column_status
78 78
      */
79
-    public function filterDateColumnStatus($status, $post)
79
+    public function filterDateColumnStatus( $status, $post )
80 80
     {
81
-        if (Application::POST_TYPE == glsr_get($post, 'post_type')) {
82
-            $status = __('Submitted', 'site-reviews');
81
+        if( Application::POST_TYPE == glsr_get( $post, 'post_type' ) ) {
82
+            $status = __( 'Submitted', 'site-reviews' );
83 83
         }
84 84
         return $status;
85 85
     }
@@ -90,10 +90,10 @@  discard block
 block discarded – undo
90 90
      * @return array
91 91
      * @filter default_hidden_columns
92 92
      */
93
-    public function filterDefaultHiddenColumns($hidden, $screen)
93
+    public function filterDefaultHiddenColumns( $hidden, $screen )
94 94
     {
95
-        if (glsr_get($screen, 'id') == 'edit-'.Application::POST_TYPE) {
96
-            $hidden = glsr(Helper::class)->consolidateArray($hidden);
95
+        if( glsr_get( $screen, 'id' ) == 'edit-'.Application::POST_TYPE ) {
96
+            $hidden = glsr( Helper::class )->consolidateArray( $hidden );
97 97
             $hidden = ['reviewer'];
98 98
         }
99 99
         return $hidden;
@@ -105,11 +105,11 @@  discard block
 block discarded – undo
105 105
      * @return array
106 106
      * @filter display_post_states
107 107
      */
108
-    public function filterPostStates($postStates, $post)
108
+    public function filterPostStates( $postStates, $post )
109 109
     {
110
-        $postStates = glsr(Helper::class)->consolidateArray($postStates);
111
-        if (Application::POST_TYPE == glsr_get($post, 'post_type') && array_key_exists('pending', $postStates)) {
112
-            $postStates['pending'] = __('Unapproved', 'site-reviews');
110
+        $postStates = glsr( Helper::class )->consolidateArray( $postStates );
111
+        if( Application::POST_TYPE == glsr_get( $post, 'post_type' ) && array_key_exists( 'pending', $postStates ) ) {
112
+            $postStates['pending'] = __( 'Unapproved', 'site-reviews' );
113 113
         }
114 114
         return $postStates;
115 115
     }
@@ -120,28 +120,28 @@  discard block
 block discarded – undo
120 120
      * @return array
121 121
      * @filter post_row_actions
122 122
      */
123
-    public function filterRowActions($actions, $post)
123
+    public function filterRowActions( $actions, $post )
124 124
     {
125
-        if (Application::POST_TYPE != glsr_get($post, 'post_type') || 'trash' == $post->post_status) {
125
+        if( Application::POST_TYPE != glsr_get( $post, 'post_type' ) || 'trash' == $post->post_status ) {
126 126
             return $actions;
127 127
         }
128 128
         unset($actions['inline hide-if-no-js']); //Remove Quick-edit
129 129
         $rowActions = [
130
-            'approve' => esc_attr__('Approve', 'site-reviews'),
131
-            'unapprove' => esc_attr__('Unapprove', 'site-reviews'),
130
+            'approve' => esc_attr__( 'Approve', 'site-reviews' ),
131
+            'unapprove' => esc_attr__( 'Unapprove', 'site-reviews' ),
132 132
         ];
133 133
         $newActions = [];
134
-        foreach ($rowActions as $key => $text) {
135
-            $newActions[$key] = glsr(Builder::class)->a($text, [
136
-                'aria-label' => sprintf(esc_attr_x('%s this review', 'Approve the review', 'site-reviews'), $text),
134
+        foreach( $rowActions as $key => $text ) {
135
+            $newActions[$key] = glsr( Builder::class )->a( $text, [
136
+                'aria-label' => sprintf( esc_attr_x( '%s this review', 'Approve the review', 'site-reviews' ), $text ),
137 137
                 'class' => 'glsr-change-status',
138 138
                 'href' => wp_nonce_url(
139
-                    admin_url('post.php?post='.$post->ID.'&action='.$key.'&plugin='.Application::ID),
139
+                    admin_url( 'post.php?post='.$post->ID.'&action='.$key.'&plugin='.Application::ID ),
140 140
                     $key.'-review_'.$post->ID
141 141
                 ),
142
-            ]);
142
+            ] );
143 143
         }
144
-        return $newActions + glsr(Helper::class)->consolidateArray($actions);
144
+        return $newActions + glsr( Helper::class )->consolidateArray( $actions );
145 145
     }
146 146
 
147 147
     /**
@@ -149,13 +149,13 @@  discard block
 block discarded – undo
149 149
      * @return array
150 150
      * @filter manage_edit-.Application::POST_TYPE._sortable_columns
151 151
      */
152
-    public function filterSortableColumns($columns)
152
+    public function filterSortableColumns( $columns )
153 153
     {
154
-        $columns = glsr(Helper::class)->consolidateArray($columns);
154
+        $columns = glsr( Helper::class )->consolidateArray( $columns );
155 155
         $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE];
156 156
         unset($postTypeColumns['cb']);
157
-        foreach ($postTypeColumns as $key => $value) {
158
-            if (glsr(Helper::class)->startsWith('taxonomy', $key)) {
157
+        foreach( $postTypeColumns as $key => $value ) {
158
+            if( glsr( Helper::class )->startsWith( 'taxonomy', $key ) ) {
159 159
                 continue;
160 160
             }
161 161
             $columns[$key] = $key;
@@ -173,22 +173,22 @@  discard block
 block discarded – undo
173 173
      * @return string
174 174
      * @filter ngettext
175 175
      */
176
-    public function filterStatusText($translation, $single, $plural, $number, $domain)
176
+    public function filterStatusText( $translation, $single, $plural, $number, $domain )
177 177
     {
178
-        if ($this->canModifyTranslation($domain)) {
178
+        if( $this->canModifyTranslation( $domain ) ) {
179 179
             $strings = [
180
-                'Published' => __('Approved', 'site-reviews'),
181
-                'Pending' => __('Unapproved', 'site-reviews'),
180
+                'Published' => __( 'Approved', 'site-reviews' ),
181
+                'Pending' => __( 'Unapproved', 'site-reviews' ),
182 182
             ];
183
-            foreach ($strings as $search => $replace) {
184
-                if (false === strpos($single, $search)) {
183
+            foreach( $strings as $search => $replace ) {
184
+                if( false === strpos( $single, $search ) ) {
185 185
                     continue;
186 186
                 }
187
-                $translation = $this->getTranslation([
187
+                $translation = $this->getTranslation( [
188 188
                     'number' => $number,
189
-                    'plural' => str_replace($search, $replace, $plural),
190
-                    'single' => str_replace($search, $replace, $single),
191
-                ]);
189
+                    'plural' => str_replace( $search, $replace, $plural ),
190
+                    'single' => str_replace( $search, $replace, $single ),
191
+                ] );
192 192
             }
193 193
         }
194 194
         return $translation;
@@ -200,10 +200,10 @@  discard block
 block discarded – undo
200 200
      * @return void
201 201
      * @action bulk_edit_custom_box
202 202
      */
203
-    public function renderBulkEditFields($columnName, $postType)
203
+    public function renderBulkEditFields( $columnName, $postType )
204 204
     {
205
-        if ('assigned_to' == $columnName && Application::POST_TYPE == $postType) {
206
-            glsr()->render('partials/editor/bulk-edit-assigned-to');
205
+        if( 'assigned_to' == $columnName && Application::POST_TYPE == $postType ) {
206
+            glsr()->render( 'partials/editor/bulk-edit-assigned-to' );
207 207
         }
208 208
     }
209 209
 
@@ -212,9 +212,9 @@  discard block
 block discarded – undo
212 212
      * @return void
213 213
      * @action restrict_manage_posts
214 214
      */
215
-    public function renderColumnFilters($postType)
215
+    public function renderColumnFilters( $postType )
216 216
     {
217
-        glsr(Columns::class)->renderFilters($postType);
217
+        glsr( Columns::class )->renderFilters( $postType );
218 218
     }
219 219
 
220 220
     /**
@@ -223,9 +223,9 @@  discard block
 block discarded – undo
223 223
      * @return void
224 224
      * @action manage_posts_custom_column
225 225
      */
226
-    public function renderColumnValues($column, $postId)
226
+    public function renderColumnValues( $column, $postId )
227 227
     {
228
-        glsr(Columns::class)->renderValues($column, $postId);
228
+        glsr( Columns::class )->renderValues( $column, $postId );
229 229
     }
230 230
 
231 231
     /**
@@ -233,14 +233,14 @@  discard block
 block discarded – undo
233 233
      * @return void
234 234
      * @action save_post_.Application::POST_TYPE
235 235
      */
236
-    public function saveBulkEditFields($postId)
236
+    public function saveBulkEditFields( $postId )
237 237
     {
238
-        if (!current_user_can('edit_posts')) {
238
+        if( !current_user_can( 'edit_posts' ) ) {
239 239
             return;
240 240
         }
241
-        $assignedTo = filter_input(INPUT_GET, 'assigned_to');
242
-        if ($assignedTo && get_post($assignedTo)) {
243
-            glsr(Database::class)->update($postId, 'assigned_to', $assignedTo);
241
+        $assignedTo = filter_input( INPUT_GET, 'assigned_to' );
242
+        if( $assignedTo && get_post( $assignedTo ) ) {
243
+            glsr( Database::class )->update( $postId, 'assigned_to', $assignedTo );
244 244
         }
245 245
     }
246 246
 
@@ -248,15 +248,15 @@  discard block
 block discarded – undo
248 248
      * @return void
249 249
      * @action pre_get_posts
250 250
      */
251
-    public function setQueryForColumn(WP_Query $query)
251
+    public function setQueryForColumn( WP_Query $query )
252 252
     {
253
-        if (!$this->hasPermission($query)) {
253
+        if( !$this->hasPermission( $query ) ) {
254 254
             return;
255 255
         }
256
-        $this->setMetaQuery($query, [
256
+        $this->setMetaQuery( $query, [
257 257
             'rating', 'review_type',
258
-        ]);
259
-        $this->setOrderby($query);
258
+        ] );
259
+        $this->setOrderby( $query );
260 260
     }
261 261
 
262 262
     /**
@@ -265,15 +265,15 @@  discard block
 block discarded – undo
265 265
      */
266 266
     public function unapprove()
267 267
     {
268
-        if (Application::ID != filter_input(INPUT_GET, 'plugin')) {
268
+        if( Application::ID != filter_input( INPUT_GET, 'plugin' ) ) {
269 269
             return;
270 270
         }
271
-        check_admin_referer('unapprove-review_'.($postId = $this->getPostId()));
272
-        wp_update_post([
271
+        check_admin_referer( 'unapprove-review_'.($postId = $this->getPostId()) );
272
+        wp_update_post( [
273 273
             'ID' => $postId,
274 274
             'post_status' => 'pending',
275
-        ]);
276
-        wp_safe_redirect(wp_get_referer());
275
+        ] );
276
+        wp_safe_redirect( wp_get_referer() );
277 277
         exit;
278 278
     }
279 279
 
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
      * @param string $domain
283 283
      * @return bool
284 284
      */
285
-    protected function canModifyTranslation($domain = 'default')
285
+    protected function canModifyTranslation( $domain = 'default' )
286 286
     {
287 287
         $screen = glsr_current_screen();
288 288
         return 'default' == $domain
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
      * Get the modified translation string.
295 295
      * @return string
296 296
      */
297
-    protected function getTranslation(array $args)
297
+    protected function getTranslation( array $args )
298 298
     {
299 299
         $defaults = [
300 300
             'number' => 0,
@@ -302,57 +302,57 @@  discard block
 block discarded – undo
302 302
             'single' => '',
303 303
             'text' => '',
304 304
         ];
305
-        $args = (object) wp_parse_args($args, $defaults);
306
-        $translations = get_translations_for_domain(Application::ID);
305
+        $args = (object)wp_parse_args( $args, $defaults );
306
+        $translations = get_translations_for_domain( Application::ID );
307 307
         return $args->text
308
-            ? $translations->translate($args->text)
309
-            : $translations->translate_plural($args->single, $args->plural, $args->number);
308
+            ? $translations->translate( $args->text )
309
+            : $translations->translate_plural( $args->single, $args->plural, $args->number );
310 310
     }
311 311
 
312 312
     /**
313 313
      * @return bool
314 314
      */
315
-    protected function hasPermission(WP_Query $query)
315
+    protected function hasPermission( WP_Query $query )
316 316
     {
317 317
         global $pagenow;
318 318
         return is_admin()
319 319
             && $query->is_main_query()
320
-            && Application::POST_TYPE == $query->get('post_type')
320
+            && Application::POST_TYPE == $query->get( 'post_type' )
321 321
             && 'edit.php' == $pagenow;
322 322
     }
323 323
 
324 324
     /**
325 325
      * @return void
326 326
      */
327
-    protected function setMetaQuery(WP_Query $query, array $metaKeys)
327
+    protected function setMetaQuery( WP_Query $query, array $metaKeys )
328 328
     {
329
-        foreach ($metaKeys as $key) {
330
-            if (!($value = filter_input(INPUT_GET, $key))) {
329
+        foreach( $metaKeys as $key ) {
330
+            if( !($value = filter_input( INPUT_GET, $key )) ) {
331 331
                 continue;
332 332
             }
333
-            $metaQuery = (array) $query->get('meta_query');
333
+            $metaQuery = (array)$query->get( 'meta_query' );
334 334
             $metaQuery[] = [
335
-                'key' => glsr(Helper::class)->prefix('_', $key),
335
+                'key' => glsr( Helper::class )->prefix( '_', $key ),
336 336
                 'value' => $value,
337 337
             ];
338
-            $query->set('meta_query', $metaQuery);
338
+            $query->set( 'meta_query', $metaQuery );
339 339
         }
340 340
     }
341 341
 
342 342
     /**
343 343
      * @return void
344 344
      */
345
-    protected function setOrderby(WP_Query $query)
345
+    protected function setOrderby( WP_Query $query )
346 346
     {
347
-        $orderby = $query->get('orderby');
347
+        $orderby = $query->get( 'orderby' );
348 348
         $columns = glsr()->postTypeColumns[Application::POST_TYPE];
349 349
         unset($columns['cb'], $columns['title'], $columns['date']);
350
-        if (in_array($orderby, array_keys($columns))) {
351
-            if ('reviewer' == $orderby) {
350
+        if( in_array( $orderby, array_keys( $columns ) ) ) {
351
+            if( 'reviewer' == $orderby ) {
352 352
                 $orderby = '_author';
353 353
             }
354
-            $query->set('meta_key', $orderby);
355
-            $query->set('orderby', 'meta_value');
354
+            $query->set( 'meta_key', $orderby );
355
+            $query->set( 'orderby', 'meta_value' );
356 356
         }
357 357
     }
358 358
 }
Please login to merge, or discard this patch.
plugin/HelperTraits/Arr.php 1 patch
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -7,10 +7,10 @@  discard block
 block discarded – undo
7 7
     /**
8 8
      * @return bool
9 9
      */
10
-    public function compareArrays(array $arr1, array $arr2)
10
+    public function compareArrays( array $arr1, array $arr2 )
11 11
     {
12
-        sort($arr1);
13
-        sort($arr2);
12
+        sort( $arr1 );
13
+        sort( $arr2 );
14 14
         return $arr1 == $arr2;
15 15
     }
16 16
 
@@ -18,21 +18,21 @@  discard block
 block discarded – undo
18 18
      * @param mixed $array
19 19
      * @return array
20 20
      */
21
-    public function consolidateArray($array)
21
+    public function consolidateArray( $array )
22 22
     {
23
-        return is_array($array) || is_object($array)
24
-            ? (array) $array
23
+        return is_array( $array ) || is_object( $array )
24
+            ? (array)$array
25 25
             : [];
26 26
     }
27 27
 
28 28
     /**
29 29
      * @return array
30 30
      */
31
-    public function convertDotNotationArray(array $array)
31
+    public function convertDotNotationArray( array $array )
32 32
     {
33 33
         $results = [];
34
-        foreach ($array as $path => $value) {
35
-            $results = $this->dataSet($results, $path, $value);
34
+        foreach( $array as $path => $value ) {
35
+            $results = $this->dataSet( $results, $path, $value );
36 36
         }
37 37
         return $results;
38 38
     }
@@ -42,12 +42,12 @@  discard block
 block discarded – undo
42 42
      * @param mixed $callback
43 43
      * @return array
44 44
      */
45
-    public function convertStringToArray($string, $callback = null)
45
+    public function convertStringToArray( $string, $callback = null )
46 46
     {
47
-        $array = array_map('trim', explode(',', $string));
47
+        $array = array_map( 'trim', explode( ',', $string ) );
48 48
         return $callback
49
-            ? array_filter($array, $callback)
50
-            : array_filter($array);
49
+            ? array_filter( $array, $callback )
50
+            : array_filter( $array );
51 51
     }
52 52
 
53 53
     /**
@@ -57,12 +57,12 @@  discard block
 block discarded – undo
57 57
      * @param mixed $fallback
58 58
      * @return mixed
59 59
      */
60
-    public function dataGet($data, $path = '', $fallback = '')
60
+    public function dataGet( $data, $path = '', $fallback = '' )
61 61
     {
62
-        $data = $this->consolidateArray($data);
63
-        $keys = explode('.', $path);
64
-        foreach ($keys as $key) {
65
-            if (!isset($data[$key])) {
62
+        $data = $this->consolidateArray( $data );
63
+        $keys = explode( '.', $path );
64
+        foreach( $keys as $key ) {
65
+            if( !isset($data[$key]) ) {
66 66
                 return $fallback;
67 67
             }
68 68
             $data = $data[$key];
@@ -76,14 +76,14 @@  discard block
 block discarded – undo
76 76
      * @param mixed $value
77 77
      * @return array
78 78
      */
79
-    public function dataSet(array $data, $path, $value)
79
+    public function dataSet( array $data, $path, $value )
80 80
     {
81
-        $token = strtok($path, '.');
81
+        $token = strtok( $path, '.' );
82 82
         $ref = &$data;
83
-        while (false !== $token) {
84
-            $ref = $this->consolidateArray($ref);
83
+        while( false !== $token ) {
84
+            $ref = $this->consolidateArray( $ref );
85 85
             $ref = &$ref[$token];
86
-            $token = strtok('.');
86
+            $token = strtok( '.' );
87 87
         }
88 88
         $ref = $value;
89 89
         return $data;
@@ -94,17 +94,17 @@  discard block
 block discarded – undo
94 94
      * @param string $prefix
95 95
      * @return array
96 96
      */
97
-    public function flattenArray(array $array, $flattenValue = false, $prefix = '')
97
+    public function flattenArray( array $array, $flattenValue = false, $prefix = '' )
98 98
     {
99 99
         $result = [];
100
-        foreach ($array as $key => $value) {
101
-            $newKey = ltrim($prefix.'.'.$key, '.');
102
-            if ($this->isIndexedFlatArray($value)) {
103
-                if ($flattenValue) {
104
-                    $value = '['.implode(', ', $value).']';
100
+        foreach( $array as $key => $value ) {
101
+            $newKey = ltrim( $prefix.'.'.$key, '.' );
102
+            if( $this->isIndexedFlatArray( $value ) ) {
103
+                if( $flattenValue ) {
104
+                    $value = '['.implode( ', ', $value ).']';
105 105
                 }
106
-            } elseif (is_array($value)) {
107
-                $result = array_merge($result, $this->flattenArray($value, $flattenValue, $newKey));
106
+            } elseif( is_array( $value ) ) {
107
+                $result = array_merge( $result, $this->flattenArray( $value, $flattenValue, $newKey ) );
108 108
                 continue;
109 109
             }
110 110
             $result[$newKey] = $value;
@@ -117,47 +117,47 @@  discard block
 block discarded – undo
117 117
      * @param string $position
118 118
      * @return array
119 119
      */
120
-    public function insertInArray(array $array, array $insert, $key, $position = 'before')
120
+    public function insertInArray( array $array, array $insert, $key, $position = 'before' )
121 121
     {
122
-        $keyPosition = intval(array_search($key, array_keys($array)));
123
-        if ('after' == $position) {
122
+        $keyPosition = intval( array_search( $key, array_keys( $array ) ) );
123
+        if( 'after' == $position ) {
124 124
             ++$keyPosition;
125 125
         }
126
-        if (false !== $keyPosition) {
127
-            $result = array_slice($array, 0, $keyPosition);
128
-            $result = array_merge($result, $insert);
129
-            return array_merge($result, array_slice($array, $keyPosition));
126
+        if( false !== $keyPosition ) {
127
+            $result = array_slice( $array, 0, $keyPosition );
128
+            $result = array_merge( $result, $insert );
129
+            return array_merge( $result, array_slice( $array, $keyPosition ) );
130 130
         }
131
-        return array_merge($array, $insert);
131
+        return array_merge( $array, $insert );
132 132
     }
133 133
 
134 134
     /**
135 135
      * @param mixed $array
136 136
      * @return bool
137 137
      */
138
-    public function isIndexedFlatArray($array)
138
+    public function isIndexedFlatArray( $array )
139 139
     {
140
-        if (!is_array($array) || array_filter($array, 'is_array')) {
140
+        if( !is_array( $array ) || array_filter( $array, 'is_array' ) ) {
141 141
             return false;
142 142
         }
143
-        return wp_is_numeric_array($array);
143
+        return wp_is_numeric_array( $array );
144 144
     }
145 145
 
146 146
     /**
147 147
      * @param bool $prefixed
148 148
      * @return array
149 149
      */
150
-    public function prefixArrayKeys(array $values, $prefixed = true)
150
+    public function prefixArrayKeys( array $values, $prefixed = true )
151 151
     {
152 152
         $trim = '_';
153 153
         $prefix = $prefixed
154 154
             ? $trim
155 155
             : '';
156 156
         $prefixed = [];
157
-        foreach ($values as $key => $value) {
158
-            $key = trim($key);
159
-            if (0 === strpos($key, $trim)) {
160
-                $key = substr($key, strlen($trim));
157
+        foreach( $values as $key => $value ) {
158
+            $key = trim( $key );
159
+            if( 0 === strpos( $key, $trim ) ) {
160
+                $key = substr( $key, strlen( $trim ) );
161 161
             }
162 162
             $prefixed[$prefix.$key] = $value;
163 163
         }
@@ -167,15 +167,15 @@  discard block
 block discarded – undo
167 167
     /**
168 168
      * @return array
169 169
      */
170
-    public function removeEmptyArrayValues(array $array)
170
+    public function removeEmptyArrayValues( array $array )
171 171
     {
172 172
         $result = [];
173
-        foreach ($array as $key => $value) {
174
-            if (!$value) {
173
+        foreach( $array as $key => $value ) {
174
+            if( !$value ) {
175 175
                 continue;
176 176
             }
177
-            $result[$key] = is_array($value)
178
-                ? $this->removeEmptyArrayValues($value)
177
+            $result[$key] = is_array( $value )
178
+                ? $this->removeEmptyArrayValues( $value )
179 179
                 : $value;
180 180
         }
181 181
         return $result;
@@ -184,8 +184,8 @@  discard block
 block discarded – undo
184 184
     /**
185 185
      * @return array
186 186
      */
187
-    public function unprefixArrayKeys(array $values)
187
+    public function unprefixArrayKeys( array $values )
188 188
     {
189
-        return $this->prefixArrayKeys($values, false);
189
+        return $this->prefixArrayKeys( $values, false );
190 190
     }
191 191
 }
Please login to merge, or discard this patch.
plugin/Database/SqlQueries.php 1 patch
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -21,17 +21,17 @@  discard block
 block discarded – undo
21 21
      * @param string $metaReviewId
22 22
      * @return int
23 23
      */
24
-    public function getPostIdFromReviewId($metaReviewId)
24
+    public function getPostIdFromReviewId( $metaReviewId )
25 25
     {
26
-        $postId = $this->db->get_var("
26
+        $postId = $this->db->get_var( "
27 27
             SELECT p.ID
28 28
             FROM {$this->db->posts} AS p
29 29
             INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id
30 30
             WHERE p.post_type = '{$this->postType}'
31 31
             AND m.meta_key = '_review_id'
32 32
             AND m.meta_value = '{$metaReviewId}'
33
-        ");
34
-        return intval($postId);
33
+        " );
34
+        return intval( $postId );
35 35
     }
36 36
 
37 37
     /**
@@ -39,23 +39,23 @@  discard block
 block discarded – undo
39 39
      * @param int $limit
40 40
      * @return array
41 41
      */
42
-    public function getReviewCounts(array $args, $lastPostId = 0, $limit = 500)
42
+    public function getReviewCounts( array $args, $lastPostId = 0, $limit = 500 )
43 43
     {
44
-        return (array) $this->db->get_results("
44
+        return (array)$this->db->get_results( "
45 45
             SELECT DISTINCT p.ID, m1.meta_value AS rating, m2.meta_value AS type
46 46
             FROM {$this->db->posts} AS p
47 47
             INNER JOIN {$this->db->postmeta} AS m1 ON p.ID = m1.post_id
48 48
             INNER JOIN {$this->db->postmeta} AS m2 ON p.ID = m2.post_id
49
-            {$this->getInnerJoinForCounts($args)}
49
+            {$this->getInnerJoinForCounts( $args )}
50 50
             WHERE p.ID > {$lastPostId}
51 51
             AND p.post_status = 'publish'
52 52
             AND p.post_type = '{$this->postType}'
53 53
             AND m1.meta_key = '_rating'
54 54
             AND m2.meta_key = '_review_type'
55
-            {$this->getAndForCounts($args)}
55
+            {$this->getAndForCounts( $args )}
56 56
             ORDER By p.ID ASC
57 57
             LIMIT {$limit}
58
-        ");
58
+        " );
59 59
     }
60 60
 
61 61
     /**
@@ -63,17 +63,17 @@  discard block
 block discarded – undo
63 63
      * @param string $metaKey
64 64
      * @return array
65 65
      */
66
-    public function getReviewCountsFor($metaKey)
66
+    public function getReviewCountsFor( $metaKey )
67 67
     {
68
-        $metaKey = glsr(Helper::class)->prefix('_', $metaKey);
69
-        return (array) $this->db->get_results("
68
+        $metaKey = glsr( Helper::class )->prefix( '_', $metaKey );
69
+        return (array)$this->db->get_results( "
70 70
             SELECT DISTINCT m.meta_value AS name, COUNT(*) num_posts
71 71
             FROM {$this->db->posts} AS p
72 72
             INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id
73 73
             WHERE p.post_type = '{$this->postType}'
74 74
             AND m.meta_key = '{$metaKey}'
75 75
             GROUP BY name
76
-        ");
76
+        " );
77 77
     }
78 78
 
79 79
     /**
@@ -81,9 +81,9 @@  discard block
 block discarded – undo
81 81
      * @param string $reviewType
82 82
      * @return array
83 83
      */
84
-    public function getReviewIdsByType($reviewType)
84
+    public function getReviewIdsByType( $reviewType )
85 85
     {
86
-        $results = $this->db->get_col("
86
+        $results = $this->db->get_col( "
87 87
             SELECT DISTINCT m1.meta_value AS review_id
88 88
             FROM {$this->db->posts} AS p
89 89
             INNER JOIN {$this->db->postmeta} AS m1 ON p.ID = m1.post_id
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
             AND m1.meta_key = '_review_id'
93 93
             AND m2.meta_key = '_review_type'
94 94
             AND m2.meta_value = '{$reviewType}'
95
-        ");
96
-        return array_keys(array_flip($results));
95
+        " );
96
+        return array_keys( array_flip( $results ) );
97 97
     }
98 98
 
99 99
     /**
@@ -101,12 +101,12 @@  discard block
 block discarded – undo
101 101
      * @param int $limit
102 102
      * @return array
103 103
      */
104
-    public function getReviewRatingsFromIds(array $postIds, $greaterThanId = 0, $limit = 100)
104
+    public function getReviewRatingsFromIds( array $postIds, $greaterThanId = 0, $limit = 100 )
105 105
     {
106
-        sort($postIds);
107
-        $postIds = array_slice($postIds, intval(array_search($greaterThanId, $postIds)), $limit);
108
-        $postIds = implode(',', $postIds);
109
-        return (array) $this->db->get_results("
106
+        sort( $postIds );
107
+        $postIds = array_slice( $postIds, intval( array_search( $greaterThanId, $postIds ) ), $limit );
108
+        $postIds = implode( ',', $postIds );
109
+        return (array)$this->db->get_results( "
110 110
             SELECT p.ID, m.meta_value AS rating
111 111
             FROM {$this->db->posts} AS p
112 112
             INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
             GROUP BY p.ID
119 119
             ORDER By p.ID ASC
120 120
             LIMIT {$limit}
121
-        ");
121
+        " );
122 122
     }
123 123
 
124 124
     /**
@@ -126,10 +126,10 @@  discard block
 block discarded – undo
126 126
      * @param string $status
127 127
      * @return array
128 128
      */
129
-    public function getReviewsMeta($key, $status = 'publish')
129
+    public function getReviewsMeta( $key, $status = 'publish' )
130 130
     {
131
-        $key = glsr(Helper::class)->prefix('_', $key);
132
-        $values = $this->db->get_col("
131
+        $key = glsr( Helper::class )->prefix( '_', $key );
132
+        $values = $this->db->get_col( "
133 133
             SELECT DISTINCT m.meta_value
134 134
             FROM {$this->db->postmeta} m
135 135
             LEFT JOIN {$this->db->posts} p ON p.ID = m.post_id
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
             AND p.post_status = '{$status}'
140 140
             GROUP BY p.ID -- remove duplicate meta_value entries
141 141
             ORDER BY m.meta_id ASC -- sort by oldest meta_value
142
-        ");
143
-        sort($values);
142
+        " );
143
+        sort( $values );
144 144
         return $values;
145 145
     }
146 146
 
@@ -148,34 +148,34 @@  discard block
 block discarded – undo
148 148
      * @param string $and
149 149
      * @return string
150 150
      */
151
-    protected function getAndForCounts(array $args, $and = '')
151
+    protected function getAndForCounts( array $args, $and = '' )
152 152
     {
153
-        $postIds = implode(',', array_filter(glsr_get($args, 'post_ids', [])));
154
-        $termIds = implode(',', array_filter(glsr_get($args, 'term_ids', [])));
155
-        if (!empty($args['type'])) {
156
-            $and.= "AND m2.meta_value = '{$args['type']}' ";
153
+        $postIds = implode( ',', array_filter( glsr_get( $args, 'post_ids', [] ) ) );
154
+        $termIds = implode( ',', array_filter( glsr_get( $args, 'term_ids', [] ) ) );
155
+        if( !empty($args['type']) ) {
156
+            $and .= "AND m2.meta_value = '{$args['type']}' ";
157 157
         }
158
-        if ($postIds) {
159
-            $and.= "AND m3.meta_key = '_assigned_to' AND m3.meta_value IN ({$postIds}) ";
158
+        if( $postIds ) {
159
+            $and .= "AND m3.meta_key = '_assigned_to' AND m3.meta_value IN ({$postIds}) ";
160 160
         }
161
-        if ($termIds) {
162
-            $and.= "AND tr.term_taxonomy_id IN ({$termIds}) ";
161
+        if( $termIds ) {
162
+            $and .= "AND tr.term_taxonomy_id IN ({$termIds}) ";
163 163
         }
164
-        return apply_filters('site-reviews/query/and-for-counts', $and);
164
+        return apply_filters( 'site-reviews/query/and-for-counts', $and );
165 165
     }
166 166
 
167 167
     /**
168 168
      * @param string $innerJoin
169 169
      * @return string
170 170
      */
171
-    protected function getInnerJoinForCounts(array $args, $innerJoin = '')
171
+    protected function getInnerJoinForCounts( array $args, $innerJoin = '' )
172 172
     {
173
-        if (!empty(glsr_get($args, 'post_ids'))) {
174
-            $innerJoin.= "INNER JOIN {$this->db->postmeta} AS m3 ON p.ID = m3.post_id ";
173
+        if( !empty(glsr_get( $args, 'post_ids' )) ) {
174
+            $innerJoin .= "INNER JOIN {$this->db->postmeta} AS m3 ON p.ID = m3.post_id ";
175 175
         }
176
-        if (!empty(glsr_get($args, 'term_ids'))) {
177
-            $innerJoin.= "INNER JOIN {$this->db->term_relationships} AS tr ON p.ID = tr.object_id ";
176
+        if( !empty(glsr_get( $args, 'term_ids' )) ) {
177
+            $innerJoin .= "INNER JOIN {$this->db->term_relationships} AS tr ON p.ID = tr.object_id ";
178 178
         }
179
-        return apply_filters('site-reviews/query/inner-join-for-counts', $innerJoin);
179
+        return apply_filters( 'site-reviews/query/inner-join-for-counts', $innerJoin );
180 180
     }
181 181
 }
Please login to merge, or discard this patch.
plugin/Modules/Upgrader.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -18,24 +18,24 @@  discard block
 block discarded – undo
18 18
     public function run()
19 19
     {
20 20
         $filenames = [];
21
-        $iterator = new DirectoryIterator(dirname(__FILE__).'/Upgrader');
22
-        foreach ($iterator as $fileinfo) {
23
-            if ($fileinfo->isFile()) {
21
+        $iterator = new DirectoryIterator( dirname( __FILE__ ).'/Upgrader' );
22
+        foreach( $iterator as $fileinfo ) {
23
+            if( $fileinfo->isFile() ) {
24 24
                 $filenames[] = $fileinfo->getFilename();
25 25
             }
26 26
         }
27
-        natsort($filenames);
27
+        natsort( $filenames );
28 28
         $this->currentVersion = $this->currentVersion();
29
-        array_walk($filenames, function ($file) {
30
-            $className = str_replace('.php', '', $file);
31
-            $upgradeFromVersion = str_replace(['Upgrade_', '_'], ['', '.'], $className);
32
-            $suffix = preg_replace('/[\d.]+(.+)?/', '${1}', glsr()->version); // allow alpha/beta versions
33
-            if ('0.0.0' == $this->currentVersion
34
-                || version_compare($this->currentVersion, $upgradeFromVersion.$suffix, '>=')) {
29
+        array_walk( $filenames, function( $file ) {
30
+            $className = str_replace( '.php', '', $file );
31
+            $upgradeFromVersion = str_replace( ['Upgrade_', '_'], ['', '.'], $className );
32
+            $suffix = preg_replace( '/[\d.]+(.+)?/', '${1}', glsr()->version ); // allow alpha/beta versions
33
+            if( '0.0.0' == $this->currentVersion
34
+                || version_compare( $this->currentVersion, $upgradeFromVersion.$suffix, '>=' ) ) {
35 35
                 return;
36 36
             }
37
-            glsr('Modules\\Upgrader\\'.$className);
38
-            glsr_log()->notice('Completed Upgrade for v'.$upgradeFromVersion.$suffix);
37
+            glsr( 'Modules\\Upgrader\\'.$className );
38
+            glsr_log()->notice( 'Completed Upgrade for v'.$upgradeFromVersion.$suffix );
39 39
         });
40 40
         $this->finish();
41 41
     }
@@ -45,10 +45,10 @@  discard block
 block discarded – undo
45 45
      */
46 46
     public function finish()
47 47
     {
48
-        if ($this->currentVersion !== glsr()->version) {
48
+        if( $this->currentVersion !== glsr()->version ) {
49 49
             $this->setReviewCounts();
50
-            $this->updateVersionFrom($this->currentVersion);
51
-        } elseif (!glsr(OptionManager::class)->get('last_review_count', false)) {
50
+            $this->updateVersionFrom( $this->currentVersion );
51
+        } elseif( !glsr( OptionManager::class )->get( 'last_review_count', false ) ) {
52 52
             $this->setReviewCounts();
53 53
         }
54 54
     }
@@ -60,10 +60,10 @@  discard block
 block discarded – undo
60 60
     {
61 61
         $fallback = '0.0.0';
62 62
         $majorVersions = [4, 3, 2];
63
-        foreach ($majorVersions as $majorVersion) {
64
-            $settings = get_option(OptionManager::databaseKey($majorVersion));
65
-            $version = glsr_get($settings, 'version', $fallback);
66
-            if (version_compare($version, $fallback, '>')) {
63
+        foreach( $majorVersions as $majorVersion ) {
64
+            $settings = get_option( OptionManager::databaseKey( $majorVersion ) );
65
+            $version = glsr_get( $settings, 'version', $fallback );
66
+            if( version_compare( $version, $fallback, '>' ) ) {
67 67
                 return $version;
68 68
             }
69 69
         }
@@ -75,16 +75,16 @@  discard block
 block discarded – undo
75 75
      */
76 76
     protected function setReviewCounts()
77 77
     {
78
-        add_action('admin_init', 'glsr_calculate_ratings');
78
+        add_action( 'admin_init', 'glsr_calculate_ratings' );
79 79
     }
80 80
 
81 81
     /**
82 82
      * @param string $previousVersion
83 83
      * @return void
84 84
      */
85
-    protected function updateVersionFrom($previousVersion)
85
+    protected function updateVersionFrom( $previousVersion )
86 86
     {
87
-        glsr(OptionManager::class)->set('version', glsr()->version);
88
-        glsr(OptionManager::class)->set('version_upgraded_from', $previousVersion);
87
+        glsr( OptionManager::class )->set( 'version', glsr()->version );
88
+        glsr( OptionManager::class )->set( 'version_upgraded_from', $previousVersion );
89 89
     }
90 90
 }
Please login to merge, or discard this patch.
plugin/Modules/Wpml.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -13,44 +13,44 @@  discard block
 block discarded – undo
13 13
     /**
14 14
      * {@inheritdoc}
15 15
      */
16
-    public function getPost($postId)
16
+    public function getPost( $postId )
17 17
     {
18
-        $postId = trim($postId);
19
-        if (!is_numeric($postId)) {
18
+        $postId = trim( $postId );
19
+        if( !is_numeric( $postId ) ) {
20 20
             return;
21 21
         }
22
-        if ($this->isEnabled()) {
23
-            $postId = apply_filters('wpml_object_id', $postId, 'any', true);
22
+        if( $this->isEnabled() ) {
23
+            $postId = apply_filters( 'wpml_object_id', $postId, 'any', true );
24 24
         }
25
-        return get_post(intval($postId));
25
+        return get_post( intval( $postId ) );
26 26
     }
27 27
 
28 28
     /**
29 29
      * {@inheritdoc}
30 30
      */
31
-    public function getPostIds(array $postIds)
31
+    public function getPostIds( array $postIds )
32 32
     {
33
-        if (!$this->isEnabled()) {
33
+        if( !$this->isEnabled() ) {
34 34
             return $postIds;
35 35
         }
36 36
         $newPostIds = [];
37
-        foreach ($this->cleanIds($postIds) as $postId) {
38
-            $postType = get_post_type($postId);
39
-            if (!$postType) {
37
+        foreach( $this->cleanIds( $postIds ) as $postId ) {
38
+            $postType = get_post_type( $postId );
39
+            if( !$postType ) {
40 40
                 continue;
41 41
             }
42 42
             $elementType = 'post_'.$postType;
43
-            $trid = apply_filters('wpml_element_trid', null, $postId, $elementType);
44
-            $translations = apply_filters('wpml_get_element_translations', null, $trid, $elementType);
45
-            if (!is_array($translations)) {
43
+            $trid = apply_filters( 'wpml_element_trid', null, $postId, $elementType );
44
+            $translations = apply_filters( 'wpml_get_element_translations', null, $trid, $elementType );
45
+            if( !is_array( $translations ) ) {
46 46
                 $translations = [];
47 47
             }
48 48
             $newPostIds = array_merge(
49 49
                 $newPostIds,
50
-                array_column($translations, 'element_id')
50
+                array_column( $translations, 'element_id' )
51 51
             );
52 52
         }
53
-        return $this->cleanIds($newPostIds);
53
+        return $this->cleanIds( $newPostIds );
54 54
     }
55 55
 
56 56
     /**
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
      */
59 59
     public function isActive()
60 60
     {
61
-        return defined('ICL_SITEPRESS_VERSION');
61
+        return defined( 'ICL_SITEPRESS_VERSION' );
62 62
     }
63 63
 
64 64
     /**
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
     public function isEnabled()
68 68
     {
69 69
         return $this->isActive()
70
-            && 'wpml' == glsr(OptionManager::class)->get('settings.general.multilingual');
70
+            && 'wpml' == glsr( OptionManager::class )->get( 'settings.general.multilingual' );
71 71
     }
72 72
 
73 73
     /**
@@ -76,14 +76,14 @@  discard block
 block discarded – undo
76 76
     public function isSupported()
77 77
     {
78 78
         return $this->isActive()
79
-            && version_compare(ICL_SITEPRESS_VERSION, static::SUPPORTED_VERSION, '>=');
79
+            && version_compare( ICL_SITEPRESS_VERSION, static::SUPPORTED_VERSION, '>=' );
80 80
     }
81 81
 
82 82
     /**
83 83
      * @return array
84 84
      */
85
-    protected function cleanIds(array $postIds)
85
+    protected function cleanIds( array $postIds )
86 86
     {
87
-        return array_filter(array_unique($postIds));
87
+        return array_filter( array_unique( $postIds ) );
88 88
     }
89 89
 }
Please login to merge, or discard this patch.
plugin/Modules/Polylang.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -13,37 +13,37 @@  discard block
 block discarded – undo
13 13
     /**
14 14
      * {@inheritdoc}
15 15
      */
16
-    public function getPost($postId)
16
+    public function getPost( $postId )
17 17
     {
18
-        $postId = trim($postId);
19
-        if (!is_numeric($postId)) {
18
+        $postId = trim( $postId );
19
+        if( !is_numeric( $postId ) ) {
20 20
             return;
21 21
         }
22
-        if ($this->isEnabled()) {
23
-            $polylangPostId = pll_get_post($postId, pll_get_post_language(get_the_ID()));
22
+        if( $this->isEnabled() ) {
23
+            $polylangPostId = pll_get_post( $postId, pll_get_post_language( get_the_ID() ) );
24 24
         }
25
-        if (!empty($polylangPostId)) {
25
+        if( !empty($polylangPostId) ) {
26 26
             $postId = $polylangPostId;
27 27
         }
28
-        return get_post(intval($postId));
28
+        return get_post( intval( $postId ) );
29 29
     }
30 30
 
31 31
     /**
32 32
      * {@inheritdoc}
33 33
      */
34
-    public function getPostIds(array $postIds)
34
+    public function getPostIds( array $postIds )
35 35
     {
36
-        if (!$this->isEnabled()) {
36
+        if( !$this->isEnabled() ) {
37 37
             return $postIds;
38 38
         }
39 39
         $newPostIds = [];
40
-        foreach ($this->cleanIds($postIds) as $postId) {
40
+        foreach( $this->cleanIds( $postIds ) as $postId ) {
41 41
             $newPostIds = array_merge(
42 42
                 $newPostIds,
43
-                array_values(pll_get_post_translations($postId))
43
+                array_values( pll_get_post_translations( $postId ) )
44 44
             );
45 45
         }
46
-        return $this->cleanIds($newPostIds);
46
+        return $this->cleanIds( $newPostIds );
47 47
     }
48 48
 
49 49
     /**
@@ -51,10 +51,10 @@  discard block
 block discarded – undo
51 51
      */
52 52
     public function isActive()
53 53
     {
54
-        return function_exists('PLL')
55
-            && function_exists('pll_get_post')
56
-            && function_exists('pll_get_post_language')
57
-            && function_exists('pll_get_post_translations');
54
+        return function_exists( 'PLL' )
55
+            && function_exists( 'pll_get_post' )
56
+            && function_exists( 'pll_get_post_language' )
57
+            && function_exists( 'pll_get_post_translations' );
58 58
     }
59 59
 
60 60
     /**
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
     public function isEnabled()
64 64
     {
65 65
         return $this->isActive()
66
-            && 'polylang' == glsr(OptionManager::class)->get('settings.general.multilingual');
66
+            && 'polylang' == glsr( OptionManager::class )->get( 'settings.general.multilingual' );
67 67
     }
68 68
 
69 69
     /**
@@ -71,15 +71,15 @@  discard block
 block discarded – undo
71 71
      */
72 72
     public function isSupported()
73 73
     {
74
-        return defined('POLYLANG_VERSION')
75
-            && version_compare(POLYLANG_VERSION, static::SUPPORTED_VERSION, '>=');
74
+        return defined( 'POLYLANG_VERSION' )
75
+            && version_compare( POLYLANG_VERSION, static::SUPPORTED_VERSION, '>=' );
76 76
     }
77 77
 
78 78
     /**
79 79
      * @return array
80 80
      */
81
-    protected function cleanIds(array $postIds)
81
+    protected function cleanIds( array $postIds )
82 82
     {
83
-        return array_filter(array_unique($postIds));
83
+        return array_filter( array_unique( $postIds ) );
84 84
     }
85 85
 }
Please login to merge, or discard this patch.