Passed
Push — master ( 2c1b34...eeeeb5 )
by Paul
04:03
created
plugin/Modules/Translator.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -11,31 +11,31 @@  discard block
 block discarded – undo
11 11
      * @param string $domain
12 12
      * @return string
13 13
      */
14
-    public function translate($original, $domain, array $args)
14
+    public function translate( $original, $domain, array $args )
15 15
     {
16
-        $domains = apply_filters('site-reviews/translator/domains', [Application::ID]);
17
-        if (!in_array($domain, $domains)) {
16
+        $domains = apply_filters( 'site-reviews/translator/domains', [Application::ID] );
17
+        if( !in_array( $domain, $domains ) ) {
18 18
             return $original;
19 19
         }
20
-        $args = $this->normalizeTranslationArgs($args);
21
-        $strings = $this->getTranslationStrings($args['single'], $args['plural']);
22
-        if (empty($strings)) {
20
+        $args = $this->normalizeTranslationArgs( $args );
21
+        $strings = $this->getTranslationStrings( $args['single'], $args['plural'] );
22
+        if( empty($strings) ) {
23 23
             return $original;
24 24
         }
25
-        $string = current($strings);
25
+        $string = current( $strings );
26 26
         return 'plural' == $string['type']
27
-            ? $this->translatePlural($domain, $string, $args)
28
-            : $this->translateSingle($domain, $string, $args);
27
+            ? $this->translatePlural( $domain, $string, $args )
28
+            : $this->translateSingle( $domain, $string, $args );
29 29
     }
30 30
 
31 31
     /**
32 32
      * Used when search/replacing a default text-domain translation
33 33
      * @return string
34 34
      */
35
-    public function getTranslation(array $args)
35
+    public function getTranslation( array $args )
36 36
     {
37
-        $args = $this->normalizeTranslationArgs($args);
38
-        return get_translations_for_domain(Application::ID)->translate_plural($args['single'], $args['plural'], $args['number']);
37
+        $args = $this->normalizeTranslationArgs( $args );
38
+        return get_translations_for_domain( Application::ID )->translate_plural( $args['single'], $args['plural'], $args['number'] );
39 39
     }
40 40
 
41 41
     /**
@@ -43,18 +43,18 @@  discard block
 block discarded – undo
43 43
      * @param string $plural
44 44
      * @return array
45 45
      */
46
-    protected function getTranslationStrings($single, $plural)
46
+    protected function getTranslationStrings( $single, $plural )
47 47
     {
48
-        return array_filter(glsr(Translation::class)->translations(), function ($string) use ($single, $plural) {
49
-            return $string['s1'] == html_entity_decode($single, ENT_COMPAT, 'UTF-8')
50
-                && $string['p1'] == html_entity_decode($plural, ENT_COMPAT, 'UTF-8');
48
+        return array_filter( glsr( Translation::class )->translations(), function( $string ) use ($single, $plural) {
49
+            return $string['s1'] == html_entity_decode( $single, ENT_COMPAT, 'UTF-8' )
50
+                && $string['p1'] == html_entity_decode( $plural, ENT_COMPAT, 'UTF-8' );
51 51
         });
52 52
     }
53 53
 
54 54
     /**
55 55
      * @return array
56 56
      */
57
-    protected function normalizeTranslationArgs(array $args)
57
+    protected function normalizeTranslationArgs( array $args )
58 58
     {
59 59
         $defaults = [
60 60
             'context' => '',
@@ -62,22 +62,22 @@  discard block
 block discarded – undo
62 62
             'plural' => '',
63 63
             'single' => '',
64 64
         ];
65
-        return shortcode_atts($defaults, $args);
65
+        return shortcode_atts( $defaults, $args );
66 66
     }
67 67
 
68 68
     /**
69 69
      * @param string $domain
70 70
      * @return string
71 71
      */
72
-    protected function translatePlural($domain, array $string, array $args)
72
+    protected function translatePlural( $domain, array $string, array $args )
73 73
     {
74
-        if (!empty($string['s2'])) {
74
+        if( !empty($string['s2']) ) {
75 75
             $args['single'] = $string['s2'];
76 76
         }
77
-        if (!empty($string['p2'])) {
77
+        if( !empty($string['p2']) ) {
78 78
             $args['plural'] = $string['p2'];
79 79
         }
80
-        return get_translations_for_domain($domain)->translate_plural(
80
+        return get_translations_for_domain( $domain )->translate_plural(
81 81
             $args['single'],
82 82
             $args['plural'],
83 83
             $args['number'],
@@ -89,12 +89,12 @@  discard block
 block discarded – undo
89 89
      * @param string $domain
90 90
      * @return string
91 91
      */
92
-    protected function translateSingle($domain, array $string, array $args)
92
+    protected function translateSingle( $domain, array $string, array $args )
93 93
     {
94
-        if (!empty($string['s2'])) {
94
+        if( !empty($string['s2']) ) {
95 95
             $args['single'] = $string['s2'];
96 96
         }
97
-        return get_translations_for_domain($domain)->translate(
97
+        return get_translations_for_domain( $domain )->translate(
98 98
             $args['single'],
99 99
             $args['context']
100 100
         );
Please login to merge, or discard this patch.
plugin/Controllers/TranslationController.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
      */
16 16
     public $translator;
17 17
 
18
-    public function __construct(Translator $translator)
18
+    public function __construct( Translator $translator )
19 19
     {
20 20
         $this->translator = $translator;
21 21
     }
@@ -25,15 +25,15 @@  discard block
 block discarded – undo
25 25
      * @return array
26 26
      * @filter bulk_post_updated_messages
27 27
      */
28
-    public function filterBulkUpdateMessages($messages, array $counts)
28
+    public function filterBulkUpdateMessages( $messages, array $counts )
29 29
     {
30
-        $messages = Arr::consolidateArray($messages);
30
+        $messages = Arr::consolidateArray( $messages );
31 31
         $messages[Application::POST_TYPE] = [
32
-            'updated' => _n('%s review updated.', '%s reviews updated.', $counts['updated'], 'site-reviews'),
33
-            'locked' => _n('%s review not updated, somebody is editing it.', '%s reviews not updated, somebody is editing them.', $counts['locked'], 'site-reviews'),
34
-            'deleted' => _n('%s review permanently deleted.', '%s reviews permanently deleted.', $counts['deleted'], 'site-reviews'),
35
-            'trashed' => _n('%s review moved to the Trash.', '%s reviews moved to the Trash.', $counts['trashed'], 'site-reviews'),
36
-            'untrashed' => _n('%s review restored from the Trash.', '%s reviews restored from the Trash.', $counts['untrashed'], 'site-reviews'),
32
+            'updated' => _n( '%s review updated.', '%s reviews updated.', $counts['updated'], 'site-reviews' ),
33
+            'locked' => _n( '%s review not updated, somebody is editing it.', '%s reviews not updated, somebody is editing them.', $counts['locked'], 'site-reviews' ),
34
+            'deleted' => _n( '%s review permanently deleted.', '%s reviews permanently deleted.', $counts['deleted'], 'site-reviews' ),
35
+            'trashed' => _n( '%s review moved to the Trash.', '%s reviews moved to the Trash.', $counts['trashed'], 'site-reviews' ),
36
+            'untrashed' => _n( '%s review restored from the Trash.', '%s reviews restored from the Trash.', $counts['untrashed'], 'site-reviews' ),
37 37
         ];
38 38
         return $messages;
39 39
     }
@@ -45,9 +45,9 @@  discard block
 block discarded – undo
45 45
      * @return string
46 46
      * @filter gettext
47 47
      */
48
-    public function filterGettext($translation, $text, $domain)
48
+    public function filterGettext( $translation, $text, $domain )
49 49
     {
50
-        return apply_filters('site-reviews/gettext/'.$domain, $translation, $text);
50
+        return apply_filters( 'site-reviews/gettext/'.$domain, $translation, $text );
51 51
     }
52 52
 
53 53
     /**
@@ -56,11 +56,11 @@  discard block
 block discarded – undo
56 56
      * @return string
57 57
      * @filter site-reviews/gettext/site-reviews
58 58
      */
59
-    public function filterGettextSiteReviews($translation, $text)
59
+    public function filterGettextSiteReviews( $translation, $text )
60 60
     {
61
-        return $this->translator->translate($translation, Application::ID, [
61
+        return $this->translator->translate( $translation, Application::ID, [
62 62
             'single' => $text,
63
-        ]);
63
+        ] );
64 64
     }
65 65
 
66 66
     /**
@@ -71,9 +71,9 @@  discard block
 block discarded – undo
71 71
      * @return string
72 72
      * @filter gettext_with_context
73 73
      */
74
-    public function filterGettextWithContext($translation, $text, $context, $domain)
74
+    public function filterGettextWithContext( $translation, $text, $context, $domain )
75 75
     {
76
-        return apply_filters('site-reviews/gettext_with_context/'.$domain, $translation, $text, $context);
76
+        return apply_filters( 'site-reviews/gettext_with_context/'.$domain, $translation, $text, $context );
77 77
     }
78 78
 
79 79
     /**
@@ -83,12 +83,12 @@  discard block
 block discarded – undo
83 83
      * @return string
84 84
      * @filter site-reviews/gettext_with_context/site-reviews
85 85
      */
86
-    public function filterGettextWithContextSiteReviews($translation, $text, $context)
86
+    public function filterGettextWithContextSiteReviews( $translation, $text, $context )
87 87
     {
88
-        return $this->translator->translate($translation, Application::ID, [
88
+        return $this->translator->translate( $translation, Application::ID, [
89 89
             'context' => $context,
90 90
             'single' => $text,
91
-        ]);
91
+        ] );
92 92
     }
93 93
 
94 94
     /**
@@ -100,9 +100,9 @@  discard block
 block discarded – undo
100 100
      * @return string
101 101
      * @filter ngettext
102 102
      */
103
-    public function filterNgettext($translation, $single, $plural, $number, $domain)
103
+    public function filterNgettext( $translation, $single, $plural, $number, $domain )
104 104
     {
105
-        return apply_filters('site-reviews/ngettext/'.$domain, $translation, $single, $plural, $number);
105
+        return apply_filters( 'site-reviews/ngettext/'.$domain, $translation, $single, $plural, $number );
106 106
     }
107 107
 
108 108
     /**
@@ -113,13 +113,13 @@  discard block
 block discarded – undo
113 113
      * @return string
114 114
      * @filter site-reviews/ngettext/site-reviews
115 115
      */
116
-    public function filterNgettextSiteReviews($translation, $single, $plural, $number)
116
+    public function filterNgettextSiteReviews( $translation, $single, $plural, $number )
117 117
     {
118
-        return $this->translator->translate($translation, Application::ID, [
118
+        return $this->translator->translate( $translation, Application::ID, [
119 119
             'number' => $number,
120 120
             'plural' => $plural,
121 121
             'single' => $single,
122
-        ]);
122
+        ] );
123 123
     }
124 124
 
125 125
     /**
@@ -132,9 +132,9 @@  discard block
 block discarded – undo
132 132
      * @return string
133 133
      * @filter ngettext_with_context
134 134
      */
135
-    public function filterNgettextWithContext($translation, $single, $plural, $number, $context, $domain)
135
+    public function filterNgettextWithContext( $translation, $single, $plural, $number, $context, $domain )
136 136
     {
137
-        return apply_filters('site-reviews/ngettext_with_context/'.$domain, $translation, $single, $plural, $number, $context);
137
+        return apply_filters( 'site-reviews/ngettext_with_context/'.$domain, $translation, $single, $plural, $number, $context );
138 138
     }
139 139
 
140 140
     /**
@@ -146,14 +146,14 @@  discard block
 block discarded – undo
146 146
      * @return string
147 147
      * @filter site-reviews/ngettext_with_context/site-reviews
148 148
      */
149
-    public function filterNgettextWithContextSiteReviews($translation, $single, $plural, $number, $context)
149
+    public function filterNgettextWithContextSiteReviews( $translation, $single, $plural, $number, $context )
150 150
     {
151
-        return $this->translator->translate($translation, Application::ID, [
151
+        return $this->translator->translate( $translation, Application::ID, [
152 152
             'context' => $context,
153 153
             'number' => $number,
154 154
             'plural' => $plural,
155 155
             'single' => $single,
156
-        ]);
156
+        ] );
157 157
     }
158 158
 
159 159
     /**
@@ -162,11 +162,11 @@  discard block
 block discarded – undo
162 162
      * @return array
163 163
      * @filter display_post_states
164 164
      */
165
-    public function filterPostStates($postStates, $post)
165
+    public function filterPostStates( $postStates, $post )
166 166
     {
167
-        $postStates = Arr::consolidateArray($postStates);
168
-        if (Application::POST_TYPE == Arr::get($post, 'post_type') && array_key_exists('pending', $postStates)) {
169
-            $postStates['pending'] = __('Unapproved', 'site-reviews');
167
+        $postStates = Arr::consolidateArray( $postStates );
168
+        if( Application::POST_TYPE == Arr::get( $post, 'post_type' ) && array_key_exists( 'pending', $postStates ) ) {
169
+            $postStates['pending'] = __( 'Unapproved', 'site-reviews' );
170 170
         }
171 171
         return $postStates;
172 172
     }
@@ -178,10 +178,10 @@  discard block
 block discarded – undo
178 178
      * @filter site-reviews/gettext/default
179 179
      * @filter site-reviews/gettext_with_context/default
180 180
      */
181
-    public function filterPostStatusLabels($translation, $text)
181
+    public function filterPostStatusLabels( $translation, $text )
182 182
     {
183 183
         return $this->canModifyTranslation()
184
-            ? glsr(Labels::class)->filterPostStatusLabels($translation, $text)
184
+            ? glsr( Labels::class )->filterPostStatusLabels( $translation, $text )
185 185
             : $translation;
186 186
     }
187 187
 
@@ -193,22 +193,22 @@  discard block
 block discarded – undo
193 193
      * @return string
194 194
      * @filter site-reviews/ngettext/default
195 195
      */
196
-    public function filterPostStatusText($translation, $single, $plural, $number)
196
+    public function filterPostStatusText( $translation, $single, $plural, $number )
197 197
     {
198
-        if ($this->canModifyTranslation()) {
198
+        if( $this->canModifyTranslation() ) {
199 199
             $strings = [
200
-                'Published' => __('Approved', 'site-reviews'),
201
-                'Pending' => __('Unapproved', 'site-reviews'),
200
+                'Published' => __( 'Approved', 'site-reviews' ),
201
+                'Pending' => __( 'Unapproved', 'site-reviews' ),
202 202
             ];
203
-            foreach ($strings as $search => $replace) {
204
-                if (!Str::contains($single, $search)) {
203
+            foreach( $strings as $search => $replace ) {
204
+                if( !Str::contains( $single, $search ) ) {
205 205
                     continue;
206 206
                 }
207
-                return $this->translator->getTranslation([
207
+                return $this->translator->getTranslation( [
208 208
                     'number' => $number,
209
-                    'plural' => str_replace($search, $replace, $plural),
210
-                    'single' => str_replace($search, $replace, $single),
211
-                ]);
209
+                    'plural' => str_replace( $search, $replace, $plural ),
210
+                    'single' => str_replace( $search, $replace, $single ),
211
+                ] );
212 212
             }
213 213
         }
214 214
         return $translation;
@@ -220,8 +220,8 @@  discard block
 block discarded – undo
220 220
      */
221 221
     public function translatePostStatusLabels()
222 222
     {
223
-        if ($this->canModifyTranslation()) {
224
-            glsr(Labels::class)->translatePostStatusLabels();
223
+        if( $this->canModifyTranslation() ) {
224
+            glsr( Labels::class )->translatePostStatusLabels();
225 225
         }
226 226
     }
227 227
 
@@ -232,6 +232,6 @@  discard block
 block discarded – undo
232 232
     {
233 233
         $screen = glsr_current_screen();
234 234
         return Application::POST_TYPE == $screen->post_type 
235
-            && in_array($screen->base, ['edit', 'post']);
235
+            && in_array( $screen->base, ['edit', 'post'] );
236 236
     }
237 237
 }
Please login to merge, or discard this patch.
plugin/Controllers/PublicController.php 1 patch
Spacing   +18 added lines, -18 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,18 +55,18 @@  discard block
 block discarded – undo
55 55
      * @return string
56 56
      * @filter site-reviews/render/view
57 57
      */
58
-    public function filterRenderView($view)
58
+    public function filterRenderView( $view )
59 59
     {
60
-        return glsr(Style::class)->filterView($view);
60
+        return glsr( Style::class )->filterView( $view );
61 61
     }
62 62
 
63 63
     /**
64 64
      * @return void
65 65
      * @action site-reviews/builder
66 66
      */
67
-    public function modifyBuilder(Builder $instance)
67
+    public function modifyBuilder( Builder $instance )
68 68
     {
69
-        call_user_func_array([glsr(Style::class), 'modifyField'], [$instance]);
69
+        call_user_func_array( [glsr( Style::class ), 'modifyField'], [$instance] );
70 70
     }
71 71
 
72 72
     /**
@@ -75,18 +75,18 @@  discard block
 block discarded – undo
75 75
      */
76 76
     public function renderSchema()
77 77
     {
78
-        glsr(Schema::class)->render();
78
+        glsr( Schema::class )->render();
79 79
     }
80 80
 
81 81
     /**
82 82
      * @return CreateReview
83 83
      */
84
-    public function routerSubmitReview(array $request)
84
+    public function routerSubmitReview( array $request )
85 85
     {
86
-        $validated = glsr(ValidateReview::class)->validate($request);
87
-        $command = new CreateReview($validated->request);
88
-        if (empty($validated->error) && !$validated->recaptchaIsUnset) {
89
-            $this->execute($command);
86
+        $validated = glsr( ValidateReview::class )->validate( $request );
87
+        $command = new CreateReview( $validated->request );
88
+        if( empty($validated->error) && !$validated->recaptchaIsUnset ) {
89
+            $this->execute( $command );
90 90
         }
91 91
         return $command;
92 92
     }
Please login to merge, or discard this patch.
plugin/Database/Cache.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -11,24 +11,24 @@  discard block
 block discarded – undo
11 11
      */
12 12
     public function getCloudflareIps()
13 13
     {
14
-        if (false === ($ipAddresses = get_transient(Application::ID.'_cloudflare_ips'))) {
15
-            $ipAddresses = array_fill_keys(['v4', 'v6'], []);
16
-            foreach (array_keys($ipAddresses) as $version) {
14
+        if( false === ($ipAddresses = get_transient( Application::ID.'_cloudflare_ips' )) ) {
15
+            $ipAddresses = array_fill_keys( ['v4', 'v6'], [] );
16
+            foreach( array_keys( $ipAddresses ) as $version ) {
17 17
                 $url = 'https://www.cloudflare.com/ips-'.$version;
18
-                $response = wp_remote_get($url, ['sslverify' => false]);
19
-                if (is_wp_error($response)) {
20
-                    glsr_log()->error($response->get_error_message());
18
+                $response = wp_remote_get( $url, ['sslverify' => false] );
19
+                if( is_wp_error( $response ) ) {
20
+                    glsr_log()->error( $response->get_error_message() );
21 21
                     continue;
22 22
                 }
23
-                if ('200' != ($statusCode = wp_remote_retrieve_response_code($response))) {
24
-                    glsr_log()->error('Unable to connect to '.$url.' ['.$statusCode.']');
23
+                if( '200' != ($statusCode = wp_remote_retrieve_response_code( $response )) ) {
24
+                    glsr_log()->error( 'Unable to connect to '.$url.' ['.$statusCode.']' );
25 25
                     continue;
26 26
                 }
27 27
                 $ipAddresses[$version] = array_filter(
28
-                    (array) preg_split('/\R/', wp_remote_retrieve_body($response))
28
+                    (array)preg_split( '/\R/', wp_remote_retrieve_body( $response ) )
29 29
                 );
30 30
             }
31
-            set_transient(Application::ID.'_cloudflare_ips', $ipAddresses, WEEK_IN_SECONDS);
31
+            set_transient( Application::ID.'_cloudflare_ips', $ipAddresses, WEEK_IN_SECONDS );
32 32
         }
33 33
         return $ipAddresses;
34 34
     }
@@ -37,16 +37,16 @@  discard block
 block discarded – undo
37 37
      * @param string $metaKey
38 38
      * @return array
39 39
      */
40
-    public function getReviewCountsFor($metaKey)
40
+    public function getReviewCountsFor( $metaKey )
41 41
     {
42
-        $counts = wp_cache_get(Application::ID, $metaKey.'_count');
43
-        if (false === $counts) {
42
+        $counts = wp_cache_get( Application::ID, $metaKey.'_count' );
43
+        if( false === $counts ) {
44 44
             $counts = [];
45
-            $results = glsr(SqlQueries::class)->getReviewCountsFor($metaKey);
46
-            foreach ($results as $result) {
45
+            $results = glsr( SqlQueries::class )->getReviewCountsFor( $metaKey );
46
+            foreach( $results as $result ) {
47 47
                 $counts[$result->name] = $result->num_posts;
48 48
             }
49
-            wp_cache_set(Application::ID, $counts, $metaKey.'_count');
49
+            wp_cache_set( Application::ID, $counts, $metaKey.'_count' );
50 50
         }
51 51
         return $counts;
52 52
     }
@@ -56,12 +56,12 @@  discard block
 block discarded – undo
56 56
      */
57 57
     public function getRemotePostTest()
58 58
     {
59
-        if (false === ($test = get_transient(Application::ID.'_remote_post_test'))) {
60
-            $response = wp_remote_post('https://api.wordpress.org/stats/php/1.0/');
61
-            $test = !is_wp_error($response) && in_array($response['response']['code'], range(200, 299))
59
+        if( false === ($test = get_transient( Application::ID.'_remote_post_test' )) ) {
60
+            $response = wp_remote_post( 'https://api.wordpress.org/stats/php/1.0/' );
61
+            $test = !is_wp_error( $response ) && in_array( $response['response']['code'], range( 200, 299 ) )
62 62
                 ? 'Works'
63 63
                 : 'Does not work';
64
-            set_transient(Application::ID.'_remote_post_test', $test, WEEK_IN_SECONDS);
64
+            set_transient( Application::ID.'_remote_post_test', $test, WEEK_IN_SECONDS );
65 65
         }
66 66
         return $test;
67 67
     }
Please login to merge, or discard this patch.
plugin/Defaults/CreateReviewDefaults.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@
 block discarded – undo
37 37
             'pinned' => false,
38 38
             'rating' => '',
39 39
             'response' => '',
40
-            'review_id' => md5(time().mt_rand()),
40
+            'review_id' => md5( time().mt_rand() ),
41 41
             'review_type' => 'local',
42 42
             'title' => '',
43 43
             'url' => '',
Please login to merge, or discard this patch.
plugin/Modules/Console.php 1 patch
Spacing   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -10,13 +10,13 @@  discard block
 block discarded – undo
10 10
 
11 11
 class Console
12 12
 {
13
-    const DEBUG = 0;      // Detailed debug information
14
-    const INFO = 1;       // Interesting events
15
-    const NOTICE = 2;     // Normal but significant events
16
-    const WARNING = 4;    // Exceptional occurrences that are not errors
17
-    const ERROR = 8;      // Runtime errors that do not require immediate action
18
-    const CRITICAL = 16;  // Critical conditions
19
-    const ALERT = 32;     // Action must be taken immediately
13
+    const DEBUG = 0; // Detailed debug information
14
+    const INFO = 1; // Interesting events
15
+    const NOTICE = 2; // Normal but significant events
16
+    const WARNING = 4; // Exceptional occurrences that are not errors
17
+    const ERROR = 8; // Runtime errors that do not require immediate action
18
+    const CRITICAL = 16; // Critical conditions
19
+    const ALERT = 32; // Action must be taken immediately
20 20
     const EMERGENCY = 64; // System is unusable
21 21
 
22 22
     protected $file;
@@ -25,9 +25,9 @@  discard block
 block discarded – undo
25 25
 
26 26
     public function __construct()
27 27
     {
28
-        $this->file = glsr()->path('console.log');
29
-        $this->log = file_exists($this->file)
30
-            ? file_get_contents($this->file)
28
+        $this->file = glsr()->path( 'console.log' );
29
+        $this->log = file_exists( $this->file )
30
+            ? file_get_contents( $this->file )
31 31
             : '';
32 32
         $this->reset();
33 33
     }
@@ -47,9 +47,9 @@  discard block
 block discarded – undo
47 47
      * @param array $context
48 48
      * @return static
49 49
      */
50
-    public function alert($message, array $context = [])
50
+    public function alert( $message, array $context = [] )
51 51
     {
52
-        return $this->log(static::ALERT, $message, $context);
52
+        return $this->log( static::ALERT, $message, $context );
53 53
     }
54 54
 
55 55
     /**
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
     public function clear()
59 59
     {
60 60
         $this->log = '';
61
-        file_put_contents($this->file, $this->log);
61
+        file_put_contents( $this->file, $this->log );
62 62
     }
63 63
 
64 64
     /**
@@ -68,9 +68,9 @@  discard block
 block discarded – undo
68 68
      * @param array $context
69 69
      * @return static
70 70
      */
71
-    public function critical($message, array $context = [])
71
+    public function critical( $message, array $context = [] )
72 72
     {
73
-        return $this->log(static::CRITICAL, $message, $context);
73
+        return $this->log( static::CRITICAL, $message, $context );
74 74
     }
75 75
 
76 76
     /**
@@ -79,9 +79,9 @@  discard block
 block discarded – undo
79 79
      * @param array $context
80 80
      * @return static
81 81
      */
82
-    public function debug($message, array $context = [])
82
+    public function debug( $message, array $context = [] )
83 83
     {
84
-        return $this->log(static::DEBUG, $message, $context);
84
+        return $this->log( static::DEBUG, $message, $context );
85 85
     }
86 86
 
87 87
     /**
@@ -90,9 +90,9 @@  discard block
 block discarded – undo
90 90
      * @param array $context
91 91
      * @return static
92 92
      */
93
-    public function emergency($message, array $context = [])
93
+    public function emergency( $message, array $context = [] )
94 94
     {
95
-        return $this->log(static::EMERGENCY, $message, $context);
95
+        return $this->log( static::EMERGENCY, $message, $context );
96 96
     }
97 97
 
98 98
     /**
@@ -101,9 +101,9 @@  discard block
 block discarded – undo
101 101
      * @param array $context
102 102
      * @return static
103 103
      */
104
-    public function error($message, array $context = [])
104
+    public function error( $message, array $context = [] )
105 105
     {
106
-        return $this->log(static::ERROR, $message, $context);
106
+        return $this->log( static::ERROR, $message, $context );
107 107
     }
108 108
 
109 109
     /**
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
     public function get()
113 113
     {
114 114
         return empty($this->log)
115
-            ? __('Console is empty', 'site-reviews')
115
+            ? __( 'Console is empty', 'site-reviews' )
116 116
             : $this->log;
117 117
     }
118 118
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
      */
122 122
     public function getLevel()
123 123
     {
124
-        return intval(apply_filters('site-reviews/console/level', static::INFO));
124
+        return intval( apply_filters( 'site-reviews/console/level', static::INFO ) );
125 125
     }
126 126
 
127 127
     /**
@@ -129,8 +129,8 @@  discard block
 block discarded – undo
129 129
      */
130 130
     public function getLevels()
131 131
     {
132
-        $constants = (new ReflectionClass(__CLASS__))->getConstants();
133
-        return array_map('strtolower', array_flip($constants));
132
+        $constants = (new ReflectionClass( __CLASS__ ))->getConstants();
133
+        return array_map( 'strtolower', array_flip( $constants ) );
134 134
     }
135 135
 
136 136
     /**
@@ -139,21 +139,21 @@  discard block
 block discarded – undo
139 139
     public function humanLevel()
140 140
     {
141 141
         $level = $this->getLevel();
142
-        return sprintf('%s (%d)', strtoupper(Arr::get($this->getLevels(), $level, 'unknown')), $level);
142
+        return sprintf( '%s (%d)', strtoupper( Arr::get( $this->getLevels(), $level, 'unknown' ) ), $level );
143 143
     }
144 144
 
145 145
     /**
146 146
      * @param string|null $valueIfEmpty
147 147
      * @return string
148 148
      */
149
-    public function humanSize($valueIfEmpty = null)
149
+    public function humanSize( $valueIfEmpty = null )
150 150
     {
151 151
         $bytes = $this->size();
152
-        if (empty($bytes) && is_string($valueIfEmpty)) {
152
+        if( empty($bytes) && is_string( $valueIfEmpty ) ) {
153 153
             return $valueIfEmpty;
154 154
         }
155
-        $exponent = floor(log(max($bytes, 1), 1024));
156
-        return round($bytes / pow(1024, $exponent), 2).' '.['bytes', 'KB', 'MB', 'GB'][$exponent];
155
+        $exponent = floor( log( max( $bytes, 1 ), 1024 ) );
156
+        return round( $bytes / pow( 1024, $exponent ), 2 ).' '.['bytes', 'KB', 'MB', 'GB'][$exponent];
157 157
     }
158 158
 
159 159
     /**
@@ -163,9 +163,9 @@  discard block
 block discarded – undo
163 163
      * @param array $context
164 164
      * @return static
165 165
      */
166
-    public function info($message, array $context = [])
166
+    public function info( $message, array $context = [] )
167 167
     {
168
-        return $this->log(static::INFO, $message, $context);
168
+        return $this->log( static::INFO, $message, $context );
169 169
     }
170 170
 
171 171
     /**
@@ -175,19 +175,19 @@  discard block
 block discarded – undo
175 175
      * @param string $backtraceLine
176 176
      * @return static
177 177
      */
178
-    public function log($level, $message, $context = [], $backtraceLine = '')
178
+    public function log( $level, $message, $context = [], $backtraceLine = '' )
179 179
     {
180
-        if (empty($backtraceLine)) {
180
+        if( empty($backtraceLine) ) {
181 181
             $backtraceLine = $this->getBacktraceLine();
182 182
         }
183
-        if ($this->canLogEntry($level, $backtraceLine)) {
184
-            $levelName = Arr::get($this->getLevels(), $level);
185
-            $context = Arr::consolidateArray($context);
186
-            $backtraceLine = $this->normalizeBacktraceLine($backtraceLine);
187
-            $message = $this->interpolate($message, $context);
188
-            $entry = $this->buildLogEntry($levelName, $message, $backtraceLine);
189
-            file_put_contents($this->file, $entry.PHP_EOL, FILE_APPEND | LOCK_EX);
190
-            apply_filters('console', $message, $levelName, $backtraceLine); // Show in Blackbar plugin if installed
183
+        if( $this->canLogEntry( $level, $backtraceLine ) ) {
184
+            $levelName = Arr::get( $this->getLevels(), $level );
185
+            $context = Arr::consolidateArray( $context );
186
+            $backtraceLine = $this->normalizeBacktraceLine( $backtraceLine );
187
+            $message = $this->interpolate( $message, $context );
188
+            $entry = $this->buildLogEntry( $levelName, $message, $backtraceLine );
189
+            file_put_contents( $this->file, $entry.PHP_EOL, FILE_APPEND | LOCK_EX );
190
+            apply_filters( 'console', $message, $levelName, $backtraceLine ); // Show in Blackbar plugin if installed
191 191
             $this->reset();
192 192
         }
193 193
         return $this;
@@ -198,17 +198,17 @@  discard block
 block discarded – undo
198 198
      */
199 199
     public function logOnce()
200 200
     {
201
-        $once = Arr::consolidateArray(glsr()->{$this->logOnceKey});
201
+        $once = Arr::consolidateArray( glsr()->{$this->logOnceKey});
202 202
         $levels = $this->getLevels();
203
-        foreach ($once as $entry) {
204
-            $levelName = Arr::get($entry, 'level');
205
-            if (!in_array($levelName, $levels)) {
203
+        foreach( $once as $entry ) {
204
+            $levelName = Arr::get( $entry, 'level' );
205
+            if( !in_array( $levelName, $levels ) ) {
206 206
                 continue;
207 207
             }
208
-            $level = Arr::get(array_flip($levels), $levelName);
209
-            $message = Arr::get($entry, 'message');
210
-            $backtraceLine = Arr::get($entry, 'backtrace');
211
-            $this->log($level, $message, [], $backtraceLine);
208
+            $level = Arr::get( array_flip( $levels ), $levelName );
209
+            $message = Arr::get( $entry, 'message' );
210
+            $backtraceLine = Arr::get( $entry, 'backtrace' );
211
+            $this->log( $level, $message, [], $backtraceLine );
212 212
         }
213 213
         glsr()->{$this->logOnceKey} = [];
214 214
     }
@@ -219,9 +219,9 @@  discard block
 block discarded – undo
219 219
      * @param array $context
220 220
      * @return static
221 221
      */
222
-    public function notice($message, array $context = [])
222
+    public function notice( $message, array $context = [] )
223 223
     {
224
-        return $this->log(static::NOTICE, $message, $context);
224
+        return $this->log( static::NOTICE, $message, $context );
225 225
     }
226 226
 
227 227
     /**
@@ -230,21 +230,21 @@  discard block
 block discarded – undo
230 230
      * @param mixed $data
231 231
      * @return void
232 232
      */
233
-    public function once($levelName, $handle, $data)
233
+    public function once( $levelName, $handle, $data )
234 234
     {
235
-        $once = Arr::consolidateArray(glsr()->{$this->logOnceKey});
236
-        $filtered = array_filter($once, function ($entry) use ($levelName, $handle) {
237
-            return Arr::get($entry, 'level') == $levelName
238
-                && Arr::get($entry, 'handle') == $handle;
235
+        $once = Arr::consolidateArray( glsr()->{$this->logOnceKey});
236
+        $filtered = array_filter( $once, function( $entry ) use ($levelName, $handle) {
237
+            return Arr::get( $entry, 'level' ) == $levelName
238
+                && Arr::get( $entry, 'handle' ) == $handle;
239 239
         });
240
-        if (!empty($filtered)) {
240
+        if( !empty($filtered) ) {
241 241
             return;
242 242
         }
243 243
         $once[] = [
244
-            'backtrace' => $this->getBacktraceLineFromData($data),
244
+            'backtrace' => $this->getBacktraceLineFromData( $data ),
245 245
             'handle' => $handle,
246 246
             'level' => $levelName,
247
-            'message' => '[RECURRING] '.$this->getMessageFromData($data),
247
+            'message' => '[RECURRING] '.$this->getMessageFromData( $data ),
248 248
         ];
249 249
         glsr()->{$this->logOnceKey} = $once;
250 250
     }
@@ -254,8 +254,8 @@  discard block
 block discarded – undo
254 254
      */
255 255
     public function size()
256 256
     {
257
-        return file_exists($this->file)
258
-            ? filesize($this->file)
257
+        return file_exists( $this->file )
258
+            ? filesize( $this->file )
259 259
             : 0;
260 260
     }
261 261
 
@@ -266,9 +266,9 @@  discard block
 block discarded – undo
266 266
      * @param array $context
267 267
      * @return static
268 268
      */
269
-    public function warning($message, array $context = [])
269
+    public function warning( $message, array $context = [] )
270 270
     {
271
-        return $this->log(static::WARNING, $message, $context);
271
+        return $this->log( static::WARNING, $message, $context );
272 272
     }
273 273
 
274 274
     /**
@@ -276,11 +276,11 @@  discard block
 block discarded – undo
276 276
      * @param int $index
277 277
      * @return string
278 278
      */
279
-    protected function buildBacktraceLine($backtrace, $index)
279
+    protected function buildBacktraceLine( $backtrace, $index )
280 280
     {
281
-        return sprintf('%s:%s',
282
-            Arr::get($backtrace, $index.'.file'), // realpath
283
-            Arr::get($backtrace, $index.'.line')
281
+        return sprintf( '%s:%s',
282
+            Arr::get( $backtrace, $index.'.file' ), // realpath
283
+            Arr::get( $backtrace, $index.'.line' )
284 284
         );
285 285
     }
286 286
 
@@ -290,11 +290,11 @@  discard block
 block discarded – undo
290 290
      * @param string $backtraceLine
291 291
      * @return string
292 292
      */
293
-    protected function buildLogEntry($levelName, $message, $backtraceLine = '')
293
+    protected function buildLogEntry( $levelName, $message, $backtraceLine = '' )
294 294
     {
295
-        return sprintf('[%s] %s [%s] %s',
296
-            current_time('mysql'),
297
-            strtoupper($levelName),
295
+        return sprintf( '[%s] %s [%s] %s',
296
+            current_time( 'mysql' ),
297
+            strtoupper( $levelName ),
298 298
             $backtraceLine,
299 299
             $message
300 300
         );
@@ -304,10 +304,10 @@  discard block
 block discarded – undo
304 304
      * @param int $level
305 305
      * @return bool
306 306
      */
307
-    protected function canLogEntry($level, $backtraceLine)
307
+    protected function canLogEntry( $level, $backtraceLine )
308 308
     {
309
-        $levelExists = array_key_exists($level, $this->getLevels());
310
-        if (!Str::contains($backtraceLine, glsr()->path())) {
309
+        $levelExists = array_key_exists( $level, $this->getLevels() );
310
+        if( !Str::contains( $backtraceLine, glsr()->path() ) ) {
311 311
             return $levelExists; // ignore level restriction if triggered outside of the plugin
312 312
         }
313 313
         return $levelExists && $level >= $this->getLevel();
@@ -318,17 +318,17 @@  discard block
 block discarded – undo
318 318
      */
319 319
     protected function getBacktraceLine()
320 320
     {
321
-        $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 6);
322
-        $search = array_search('glsr_log', glsr_array_column($backtrace, 'function'));
323
-        if (false !== $search) {
324
-            return $this->buildBacktraceLine($backtrace, (int) $search);
321
+        $backtrace = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, 6 );
322
+        $search = array_search( 'glsr_log', glsr_array_column( $backtrace, 'function' ) );
323
+        if( false !== $search ) {
324
+            return $this->buildBacktraceLine( $backtrace, (int)$search );
325 325
         }
326
-        $search = array_search('log', glsr_array_column($backtrace, 'function'));
327
-        if (false !== $search) {
328
-            $index = '{closure}' == Arr::get($backtrace, ($search + 2).'.function')
326
+        $search = array_search( 'log', glsr_array_column( $backtrace, 'function' ) );
327
+        if( false !== $search ) {
328
+            $index = '{closure}' == Arr::get( $backtrace, ($search + 2).'.function' )
329 329
                 ? $search + 4
330 330
                 : $search + 1;
331
-            return $this->buildBacktraceLine($backtrace, $index);
331
+            return $this->buildBacktraceLine( $backtrace, $index );
332 332
         }
333 333
         return 'Unknown';
334 334
     }
@@ -337,23 +337,23 @@  discard block
 block discarded – undo
337 337
      * @param mixed $data
338 338
      * @return string
339 339
      */
340
-    protected function getBacktraceLineFromData($data)
340
+    protected function getBacktraceLineFromData( $data )
341 341
     {
342 342
         $backtrace = $data instanceof Throwable
343 343
             ? $data->getTrace()
344
-            : debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1);
345
-        return $this->buildBacktraceLine($backtrace, 0);
344
+            : debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, 1 );
345
+        return $this->buildBacktraceLine( $backtrace, 0 );
346 346
     }
347 347
 
348 348
     /**
349 349
      * @param mixed $data
350 350
      * @return string
351 351
      */
352
-    protected function getMessageFromData($data)
352
+    protected function getMessageFromData( $data )
353 353
     {
354 354
         return $data instanceof Throwable
355
-            ? $this->normalizeThrowableMessage($data->getMessage())
356
-            : print_r($data, 1);
355
+            ? $this->normalizeThrowableMessage( $data->getMessage() )
356
+            : print_r( $data, 1 );
357 357
     }
358 358
 
359 359
     /**
@@ -362,53 +362,53 @@  discard block
 block discarded – undo
362 362
      * @param array $context
363 363
      * @return string
364 364
      */
365
-    protected function interpolate($message, $context = [])
365
+    protected function interpolate( $message, $context = [] )
366 366
     {
367
-        if ($this->isObjectOrArray($message) || !is_array($context)) {
368
-            return print_r($message, true);
367
+        if( $this->isObjectOrArray( $message ) || !is_array( $context ) ) {
368
+            return print_r( $message, true );
369 369
         }
370 370
         $replace = [];
371
-        foreach ($context as $key => $value) {
372
-            $replace['{'.$key.'}'] = $this->normalizeValue($value);
371
+        foreach( $context as $key => $value ) {
372
+            $replace['{'.$key.'}'] = $this->normalizeValue( $value );
373 373
         }
374
-        return strtr($message, $replace);
374
+        return strtr( $message, $replace );
375 375
     }
376 376
 
377 377
     /**
378 378
      * @param mixed $value
379 379
      * @return bool
380 380
      */
381
-    protected function isObjectOrArray($value)
381
+    protected function isObjectOrArray( $value )
382 382
     {
383
-        return is_object($value) || is_array($value);
383
+        return is_object( $value ) || is_array( $value );
384 384
     }
385 385
 
386 386
     /**
387 387
      * @param string $backtraceLine
388 388
      * @return string
389 389
      */
390
-    protected function normalizeBacktraceLine($backtraceLine)
390
+    protected function normalizeBacktraceLine( $backtraceLine )
391 391
     {
392 392
         $search = [
393
-            glsr()->path('plugin/'),
394
-            glsr()->path('plugin/', false),
395
-            trailingslashit(glsr()->path()),
396
-            trailingslashit(glsr()->path('', false)),
393
+            glsr()->path( 'plugin/' ),
394
+            glsr()->path( 'plugin/', false ),
395
+            trailingslashit( glsr()->path() ),
396
+            trailingslashit( glsr()->path( '', false ) ),
397 397
             WP_CONTENT_DIR,
398 398
             ABSPATH,
399 399
         ];
400
-        return str_replace(array_unique($search), '', $backtraceLine);
400
+        return str_replace( array_unique( $search ), '', $backtraceLine );
401 401
     }
402 402
 
403 403
     /**
404 404
      * @param string $message
405 405
      * @return string
406 406
      */
407
-    protected function normalizeThrowableMessage($message)
407
+    protected function normalizeThrowableMessage( $message )
408 408
     {
409
-        $calledIn = strpos($message, ', called in');
409
+        $calledIn = strpos( $message, ', called in' );
410 410
         return false !== $calledIn
411
-            ? substr($message, 0, $calledIn)
411
+            ? substr( $message, 0, $calledIn )
412 412
             : $message;
413 413
     }
414 414
 
@@ -416,14 +416,14 @@  discard block
 block discarded – undo
416 416
      * @param mixed $value
417 417
      * @return string
418 418
      */
419
-    protected function normalizeValue($value)
419
+    protected function normalizeValue( $value )
420 420
     {
421
-        if ($value instanceof DateTime) {
422
-            $value = $value->format('Y-m-d H:i:s');
423
-        } elseif ($this->isObjectOrArray($value)) {
424
-            $value = json_encode($value);
421
+        if( $value instanceof DateTime ) {
422
+            $value = $value->format( 'Y-m-d H:i:s' );
423
+        } elseif( $this->isObjectOrArray( $value ) ) {
424
+            $value = json_encode( $value );
425 425
         }
426
-        return (string) $value;
426
+        return (string)$value;
427 427
     }
428 428
 
429 429
     /**
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
      */
432 432
     protected function reset()
433 433
     {
434
-        if ($this->size() <= pow(1024, 2) / 8) {
434
+        if( $this->size() <= pow( 1024, 2 ) / 8 ) {
435 435
             return;
436 436
         }
437 437
         $this->clear();
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
             $this->file,
440 440
             $this->buildLogEntry(
441 441
                 static::NOTICE,
442
-                __('Console was automatically cleared (128 KB maximum size)', 'site-reviews')
442
+                __( 'Console was automatically cleared (128 KB maximum size)', 'site-reviews' )
443 443
             )
444 444
         );
445 445
     }
Please login to merge, or discard this patch.
deprecated.php 1 patch
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -1,136 +1,136 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-defined('WPINC') || die;
3
+defined( 'WPINC' ) || die;
4 4
 
5
-if (apply_filters('site-reviews/support/deprecated/v4', true)) {
5
+if( apply_filters( 'site-reviews/support/deprecated/v4', true ) ) {
6 6
     // Unprotected review meta has been deprecated
7
-    add_filter('get_post_metadata', function ($data, $postId, $metaKey, $single) {
8
-        $metaKeys = array_keys(glsr('Defaults\CreateReviewDefaults')->defaults());
9
-        if (!in_array($metaKey, $metaKeys) || glsr()->post_type != get_post_type($postId)) {
7
+    add_filter( 'get_post_metadata', function( $data, $postId, $metaKey, $single ) {
8
+        $metaKeys = array_keys( glsr( 'Defaults\CreateReviewDefaults' )->defaults() );
9
+        if( !in_array( $metaKey, $metaKeys ) || glsr()->post_type != get_post_type( $postId ) ) {
10 10
             return $data;
11 11
         }
12 12
         glsr()->deprecated[] = sprintf(
13 13
             'The "%1$s" meta_key has been deprecated for Reviews. Please use the protected "_%1$s" meta_key instead.',
14 14
             $metaKey
15 15
         );
16
-        return get_post_meta($postId, '_'.$metaKey, $single);
17
-    }, 10, 4);
16
+        return get_post_meta( $postId, '_'.$metaKey, $single );
17
+    }, 10, 4 );
18 18
 
19 19
     // Modules/Html/Template.php
20
-    add_filter('site-reviews/interpolate/reviews', function ($context, $template) {
20
+    add_filter( 'site-reviews/interpolate/reviews', function( $context, $template ) {
21 21
         $search = '{{ navigation }}';
22
-        if (false !== strpos($template, $search)) {
22
+        if( false !== strpos( $template, $search ) ) {
23 23
             $context['navigation'] = $context['pagination'];
24 24
             glsr()->deprecated[] = 'The {{ navigation }} template key in "YOUR_THEME/site-reviews/reviews.php" has been deprecated. Please use the {{ pagination }} template key instead.';
25 25
         }
26 26
         return $context;
27
-    }, 10, 2);
27
+    }, 10, 2 );
28 28
 
29 29
     // Database/ReviewManager.php
30
-    add_action('site-reviews/review/created', function ($review) {
31
-        if (has_action('site-reviews/local/review/create')) {
30
+    add_action( 'site-reviews/review/created', function( $review ) {
31
+        if( has_action( 'site-reviews/local/review/create' ) ) {
32 32
             glsr()->deprecated[] = 'The "site-reviews/local/review/create" hook has been deprecated. Please use the "site-reviews/review/created" hook instead.';
33
-            do_action('site-reviews/local/review/create', (array) get_post($review->ID), (array) $review, $review->ID);
33
+            do_action( 'site-reviews/local/review/create', (array)get_post( $review->ID ), (array)$review, $review->ID );
34 34
         }
35
-    }, 9);
35
+    }, 9 );
36 36
 
37 37
     // Handlers/CreateReview.php
38
-    add_action('site-reviews/review/submitted', function ($review) {
39
-        if (has_action('site-reviews/local/review/submitted')) {
38
+    add_action( 'site-reviews/review/submitted', function( $review ) {
39
+        if( has_action( 'site-reviews/local/review/submitted' ) ) {
40 40
             glsr()->deprecated[] = 'The "site-reviews/local/review/submitted" hook has been deprecated. Please use the "site-reviews/review/submitted" hook instead.';
41
-            do_action('site-reviews/local/review/submitted', null, $review);
41
+            do_action( 'site-reviews/local/review/submitted', null, $review );
42 42
         }
43
-        if (has_filter('site-reviews/local/review/submitted/message')) {
43
+        if( has_filter( 'site-reviews/local/review/submitted/message' ) ) {
44 44
             glsr()->deprecated[] = 'The "site-reviews/local/review/submitted/message" hook has been deprecated.';
45 45
         }
46
-    }, 9);
46
+    }, 9 );
47 47
 
48 48
     // Database/ReviewManager.php
49
-    add_filter('site-reviews/create/review-values', function ($values, $command) {
50
-        if (has_filter('site-reviews/local/review')) {
49
+    add_filter( 'site-reviews/create/review-values', function( $values, $command ) {
50
+        if( has_filter( 'site-reviews/local/review' ) ) {
51 51
             glsr()->deprecated[] = 'The "site-reviews/local/review" hook has been deprecated. Please use the "site-reviews/create/review-values" hook instead.';
52
-            return apply_filters('site-reviews/local/review', $values, $command);
52
+            return apply_filters( 'site-reviews/local/review', $values, $command );
53 53
         }
54 54
         return $values;
55
-    }, 9, 2);
55
+    }, 9, 2 );
56 56
 
57 57
     // Handlers/EnqueuePublicAssets.php
58
-    add_filter('site-reviews/enqueue/public/localize', function ($variables) {
59
-        if (has_filter('site-reviews/enqueue/localize')) {
58
+    add_filter( 'site-reviews/enqueue/public/localize', function( $variables ) {
59
+        if( has_filter( 'site-reviews/enqueue/localize' ) ) {
60 60
             glsr()->deprecated[] = 'The "site-reviews/enqueue/localize" hook has been deprecated. Please use the "site-reviews/enqueue/public/localize" hook instead.';
61
-            return apply_filters('site-reviews/enqueue/localize', $variables);
61
+            return apply_filters( 'site-reviews/enqueue/localize', $variables );
62 62
         }
63 63
         return $variables;
64
-    }, 9);
64
+    }, 9 );
65 65
 
66 66
     // Modules/Rating.php
67
-    add_filter('site-reviews/rating/average', function ($average) {
68
-        if (has_filter('site-reviews/average/rating')) {
67
+    add_filter( 'site-reviews/rating/average', function( $average ) {
68
+        if( has_filter( 'site-reviews/average/rating' ) ) {
69 69
             glsr()->deprecated[] = 'The "site-reviews/average/rating" hook has been deprecated. Please use the "site-reviews/rating/average" hook instead.';
70 70
         }
71 71
         return $average;
72
-    }, 9);
72
+    }, 9 );
73 73
 
74 74
     // Modules/Rating.php
75
-    add_filter('site-reviews/rating/ranking', function ($ranking) {
76
-        if (has_filter('site-reviews/bayesian/ranking')) {
75
+    add_filter( 'site-reviews/rating/ranking', function( $ranking ) {
76
+        if( has_filter( 'site-reviews/bayesian/ranking' ) ) {
77 77
             glsr()->deprecated[] = 'The "site-reviews/bayesian/ranking" hook has been deprecated. Please use the "site-reviews/rating/ranking" hook instead.';
78 78
         }
79 79
         return $ranking;
80
-    }, 9);
80
+    }, 9 );
81 81
 
82 82
     // Modules/Html/Partials/SiteReviews.php
83
-    add_filter('site-reviews/review/build/after', function ($renderedFields) {
84
-        if (has_filter('site-reviews/reviews/review/text')) {
83
+    add_filter( 'site-reviews/review/build/after', function( $renderedFields ) {
84
+        if( has_filter( 'site-reviews/reviews/review/text' ) ) {
85 85
             glsr()->deprecated[] = 'The "site-reviews/reviews/review/text" hook has been deprecated. Please use the "site-reviews/review/build/after" hook instead.';
86 86
         }
87
-        if (has_filter('site-reviews/reviews/review/title')) {
87
+        if( has_filter( 'site-reviews/reviews/review/title' ) ) {
88 88
             glsr()->deprecated[] = 'The "site-reviews/reviews/review/title" hook has been deprecated. Please use the "site-reviews/review/build/after" hook instead.';
89 89
         }
90 90
         return $renderedFields;
91
-    }, 9);
91
+    }, 9 );
92 92
 
93 93
     // Modules/Html/Partials/SiteReviews.php
94
-    add_filter('site-reviews/review/build/before', function ($review) {
95
-        if (has_filter('site-reviews/rendered/review')) {
94
+    add_filter( 'site-reviews/review/build/before', function( $review ) {
95
+        if( has_filter( 'site-reviews/rendered/review' ) ) {
96 96
             glsr()->deprecated[] = 'The "site-reviews/rendered/review" hook has been deprecated. Please either use a custom "review.php" template (refer to the documentation), or use the "site-reviews/review/build/after" hook instead.';
97 97
         }
98
-        if (has_filter('site-reviews/rendered/review/meta/order')) {
98
+        if( has_filter( 'site-reviews/rendered/review/meta/order' ) ) {
99 99
             glsr()->deprecated[] = 'The "site-reviews/rendered/review/meta/order" hook has been deprecated. Please use a custom "review.php" template instead (refer to the documentation).';
100 100
         }
101
-        if (has_filter('site-reviews/rendered/review/order')) {
101
+        if( has_filter( 'site-reviews/rendered/review/order' ) ) {
102 102
             glsr()->deprecated[] = 'The "site-reviews/rendered/review/order" hook has been deprecated. Please use a custom "review.php" template instead (refer to the documentation).';
103 103
         }
104
-        if (has_filter('site-reviews/rendered/review-form/login-register')) {
104
+        if( has_filter( 'site-reviews/rendered/review-form/login-register' ) ) {
105 105
             glsr()->deprecated[] = 'The "site-reviews/rendered/review-form/login-register" hook has been deprecated. Please use a custom "login-register.php" template instead (refer to the documentation).';
106 106
         }
107
-        if (has_filter('site-reviews/reviews/navigation_links')) {
107
+        if( has_filter( 'site-reviews/reviews/navigation_links' ) ) {
108 108
             glsr()->deprecated[] = 'The "site-reviews/reviews/navigation_links" hook has been deprecated. Please use a custom "pagination.php" template instead (refer to the documentation).';
109 109
         }
110 110
         return $review;
111
-    }, 9);
111
+    }, 9 );
112 112
 
113
-    add_filter('site-reviews/validate/custom', function ($result, $request) {
114
-        if (has_filter('site-reviews/validate/review/submission')) {
115
-            glsr_log()->warning('The "site-reviews/validate/review/submission" hook has been deprecated. Please use the "site-reviews/validate/custom" hook instead.');
116
-            return apply_filters('site-reviews/validate/review/submission', $result, $request);
113
+    add_filter( 'site-reviews/validate/custom', function( $result, $request ) {
114
+        if( has_filter( 'site-reviews/validate/review/submission' ) ) {
115
+            glsr_log()->warning( 'The "site-reviews/validate/review/submission" hook has been deprecated. Please use the "site-reviews/validate/custom" hook instead.' );
116
+            return apply_filters( 'site-reviews/validate/review/submission', $result, $request );
117 117
         }
118 118
         return $result;
119
-    }, 9, 2);
119
+    }, 9, 2 );
120 120
 
121
-    add_filter('site-reviews/views/file', function ($file, $view, $data) {
122
-        if (has_filter('site-reviews/addon/views/file')) {
121
+    add_filter( 'site-reviews/views/file', function( $file, $view, $data ) {
122
+        if( has_filter( 'site-reviews/addon/views/file' ) ) {
123 123
             glsr()->deprecated[] = 'The "site-reviews/addon/views/file" hook has been deprecated. Please use the "site-reviews/views/file" hook instead.';
124
-            $file = apply_filters('site-reviews/addon/views/file', $file, $view, $data);
124
+            $file = apply_filters( 'site-reviews/addon/views/file', $file, $view, $data );
125 125
         }
126 126
         return $file;
127
-    }, 9, 3);
127
+    }, 9, 3 );
128 128
 }
129 129
 
130
-add_action('wp_footer', function () {
131
-    $notices = array_keys(array_flip(glsr()->deprecated));
132
-    natsort($notices);
133
-    foreach ($notices as $notice) {
134
-        glsr_log()->warning($notice);
130
+add_action( 'wp_footer', function() {
131
+    $notices = array_keys( array_flip( glsr()->deprecated ) );
132
+    natsort( $notices );
133
+    foreach( $notices as $notice ) {
134
+        glsr_log()->warning( $notice );
135 135
     }
136 136
 });
Please login to merge, or discard this patch.
plugin/Handlers/EnqueuePublicAssets.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
      */
27 27
     public function enqueueAssets()
28 28
     {
29
-        if (apply_filters('site-reviews/assets/css', true)) {
29
+        if( apply_filters( 'site-reviews/assets/css', true ) ) {
30 30
             wp_enqueue_style(
31 31
                 Application::ID,
32 32
                 $this->getStylesheet(),
@@ -34,14 +34,14 @@  discard block
 block discarded – undo
34 34
                 glsr()->version
35 35
             );
36 36
         }
37
-        if (apply_filters('site-reviews/assets/js', true)) {
38
-            $dependencies = apply_filters('site-reviews/assets/polyfill', true)
37
+        if( apply_filters( 'site-reviews/assets/js', true ) ) {
38
+            $dependencies = apply_filters( 'site-reviews/assets/polyfill', true )
39 39
                 ? [Application::ID.'/polyfill']
40 40
                 : [];
41
-            $dependencies = apply_filters('site-reviews/enqueue/public/dependencies', $dependencies);
41
+            $dependencies = apply_filters( 'site-reviews/enqueue/public/dependencies', $dependencies );
42 42
             wp_enqueue_script(
43 43
                 Application::ID,
44
-                glsr()->url('assets/scripts/'.Application::ID.'.js'),
44
+                glsr()->url( 'assets/scripts/'.Application::ID.'.js' ),
45 45
                 $dependencies,
46 46
                 glsr()->version,
47 47
                 true
@@ -54,13 +54,13 @@  discard block
 block discarded – undo
54 54
      */
55 55
     public function enqueuePolyfillService()
56 56
     {
57
-        if (!apply_filters('site-reviews/assets/polyfill', true)) {
57
+        if( !apply_filters( 'site-reviews/assets/polyfill', true ) ) {
58 58
             return;
59 59
         }
60
-        wp_enqueue_script(Application::ID.'/polyfill', add_query_arg([
60
+        wp_enqueue_script( Application::ID.'/polyfill', add_query_arg( [
61 61
             'features' => 'Array.prototype.findIndex,CustomEvent,Element.prototype.closest,Element.prototype.dataset,Event,XMLHttpRequest,MutationObserver',
62 62
             'flags' => 'gated',
63
-        ], 'https://polyfill.io/v3/polyfill.min.js'));
63
+        ], 'https://polyfill.io/v3/polyfill.min.js' ) );
64 64
     }
65 65
 
66 66
     /**
@@ -71,14 +71,14 @@  discard block
 block discarded – undo
71 71
         // wpforms-recaptcha
72 72
         // google-recaptcha
73 73
         // nf-google-recaptcha
74
-        if (!glsr(OptionManager::class)->isRecaptchaEnabled()) {
74
+        if( !glsr( OptionManager::class )->isRecaptchaEnabled() ) {
75 75
             return;
76 76
         }
77
-        $language = apply_filters('site-reviews/recaptcha/language', get_locale());
78
-        wp_enqueue_script(Application::ID.'/google-recaptcha', add_query_arg([
77
+        $language = apply_filters( 'site-reviews/recaptcha/language', get_locale() );
78
+        wp_enqueue_script( Application::ID.'/google-recaptcha', add_query_arg( [
79 79
             'hl' => $language,
80 80
             'render' => 'explicit',
81
-        ], 'https://www.google.com/recaptcha/api.js'));
81
+        ], 'https://www.google.com/recaptcha/api.js' ) );
82 82
     }
83 83
 
84 84
     /**
@@ -89,13 +89,13 @@  discard block
 block discarded – undo
89 89
         $variables = [
90 90
             'action' => Application::PREFIX.'action',
91 91
             'ajaxpagination' => $this->getFixedSelectorsForPagination(),
92
-            'ajaxurl' => admin_url('admin-ajax.php'),
92
+            'ajaxurl' => admin_url( 'admin-ajax.php' ),
93 93
             'nameprefix' => Application::ID,
94
-            'validationconfig' => glsr(Style::class)->validation,
95
-            'validationstrings' => glsr(ValidationStringsDefaults::class)->defaults(),
94
+            'validationconfig' => glsr( Style::class )->validation,
95
+            'validationstrings' => glsr( ValidationStringsDefaults::class )->defaults(),
96 96
         ];
97
-        $variables = apply_filters('site-reviews/enqueue/public/localize', $variables);
98
-        wp_add_inline_script(Application::ID, $this->buildInlineScript($variables), 'before');
97
+        $variables = apply_filters( 'site-reviews/enqueue/public/localize', $variables );
98
+        wp_add_inline_script( Application::ID, $this->buildInlineScript( $variables ), 'before' );
99 99
     }
100 100
 
101 101
     /**
@@ -103,35 +103,35 @@  discard block
 block discarded – undo
103 103
      */
104 104
     public function inlineStyles()
105 105
     {
106
-        $inlineStylesheetPath = glsr()->path('assets/styles/inline-styles.css');
107
-        if (!apply_filters('site-reviews/assets/css', true)) {
106
+        $inlineStylesheetPath = glsr()->path( 'assets/styles/inline-styles.css' );
107
+        if( !apply_filters( 'site-reviews/assets/css', true ) ) {
108 108
             return;
109 109
         }
110
-        if (!file_exists($inlineStylesheetPath)) {
111
-            glsr_log()->error('Inline stylesheet is missing: '.$inlineStylesheetPath);
110
+        if( !file_exists( $inlineStylesheetPath ) ) {
111
+            glsr_log()->error( 'Inline stylesheet is missing: '.$inlineStylesheetPath );
112 112
             return;
113 113
         }
114
-        $inlineStylesheetValues = glsr()->config('inline-styles');
114
+        $inlineStylesheetValues = glsr()->config( 'inline-styles' );
115 115
         $stylesheet = str_replace(
116
-            array_keys($inlineStylesheetValues),
117
-            array_values($inlineStylesheetValues),
118
-            file_get_contents($inlineStylesheetPath)
116
+            array_keys( $inlineStylesheetValues ),
117
+            array_values( $inlineStylesheetValues ),
118
+            file_get_contents( $inlineStylesheetPath )
119 119
         );
120
-        wp_add_inline_style(Application::ID, $stylesheet);
120
+        wp_add_inline_style( Application::ID, $stylesheet );
121 121
     }
122 122
 
123 123
     /**
124 124
      * @return string
125 125
      */
126
-    protected function buildInlineScript(array $variables)
126
+    protected function buildInlineScript( array $variables )
127 127
     {
128 128
         $script = 'window.hasOwnProperty("GLSR")||(window.GLSR={});';
129
-        foreach ($variables as $key => $value) {
130
-            $script.= sprintf('GLSR.%s=%s;', $key, json_encode($value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
129
+        foreach( $variables as $key => $value ) {
130
+            $script .= sprintf( 'GLSR.%s=%s;', $key, json_encode( $value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ) );
131 131
         }
132 132
         $pattern = '/\"([^ \-\"]+)\"(:[{\[\"])/'; // removes unnecessary quotes surrounding object keys
133
-        $optimizedScript = preg_replace($pattern, '$1$2', $script);
134
-        return apply_filters('site-reviews/enqueue/public/inline-script', $optimizedScript, $script, $variables);
133
+        $optimizedScript = preg_replace( $pattern, '$1$2', $script );
134
+        return apply_filters( 'site-reviews/enqueue/public/inline-script', $optimizedScript, $script, $variables );
135 135
     }
136 136
 
137 137
     /**
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
     protected function getFixedSelectorsForPagination()
141 141
     {
142 142
         $selectors = ['#wpadminbar', '.site-navigation-fixed'];
143
-        return apply_filters('site-reviews/enqueue/public/localize/ajax-pagination', $selectors);
143
+        return apply_filters( 'site-reviews/enqueue/public/localize/ajax-pagination', $selectors );
144 144
     }
145 145
 
146 146
     /**
@@ -148,9 +148,9 @@  discard block
 block discarded – undo
148 148
      */
149 149
     protected function getStylesheet()
150 150
     {
151
-        $currentStyle = glsr(Style::class)->style;
152
-        return file_exists(glsr()->path('assets/styles/custom/'.$currentStyle.'.css'))
153
-            ? glsr()->url('assets/styles/custom/'.$currentStyle.'.css')
154
-            : glsr()->url('assets/styles/'.Application::ID.'.css');
151
+        $currentStyle = glsr( Style::class )->style;
152
+        return file_exists( glsr()->path( 'assets/styles/custom/'.$currentStyle.'.css' ) )
153
+            ? glsr()->url( 'assets/styles/custom/'.$currentStyle.'.css' )
154
+            : glsr()->url( 'assets/styles/'.Application::ID.'.css' );
155 155
     }
156 156
 }
Please login to merge, or discard this patch.
views/partials/editor/review.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,26 +1,26 @@
 block discarded – undo
1
-<?php defined('WPINC') || die; ?>
1
+<?php defined( 'WPINC' ) || die; ?>
2 2
 
3 3
 <div id="titlediv">
4
-    <input type="text" id="title" value="<?= $post->post_title ? esc_attr($post->post_title) : sprintf('(%s)', __('no title', 'site-reviews')); ?>" readonly>
4
+    <input type="text" id="title" value="<?= $post->post_title ? esc_attr( $post->post_title ) : sprintf( '(%s)', __( 'no title', 'site-reviews' ) ); ?>" readonly>
5 5
 </div>
6 6
 
7 7
 <div id="contentdiv" class="wp-editor-container">
8
-    <textarea readonly><?= esc_attr($post->post_content); ?></textarea>
8
+    <textarea readonly><?= esc_attr( $post->post_content ); ?></textarea>
9 9
 </div>
10 10
 
11
-<?php if (empty($response)) {
11
+<?php if( empty($response) ) {
12 12
     return;
13 13
 } ?>
14 14
 
15 15
 <div class="postbox glsr-response-postbox">
16 16
     <button type="button" class="handlediv" aria-expanded="true">
17
-        <span class="screen-reader-text"><?= __('Toggle panel: Public Response', 'site-reviews'); ?></span>
17
+        <span class="screen-reader-text"><?= __( 'Toggle panel: Public Response', 'site-reviews' ); ?></span>
18 18
         <span class="toggle-indicator" aria-hidden="true"></span>
19 19
     </button>
20 20
     <h2 class="hndle">
21
-        <span><?= __('Public Response', 'site-reviews'); ?></span>
21
+        <span><?= __( 'Public Response', 'site-reviews' ); ?></span>
22 22
     </h2>
23 23
     <div class="inside">
24
-        <?= wpautop(esc_attr($response)); ?>
24
+        <?= wpautop( esc_attr( $response ) ); ?>
25 25
     </div>
26 26
 </div>
Please login to merge, or discard this patch.