Passed
Push — master ( ae1954...aab291 )
by Paul
08:17 queued 04:15
created
plugin/Database/ReviewManager.php 1 patch
Spacing   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -19,11 +19,11 @@  discard block
 block discarded – undo
19 19
     /**
20 20
      * @return false|Review
21 21
      */
22
-    public function create(CreateReview $command)
22
+    public function create( CreateReview $command )
23 23
     {
24
-        $reviewValues = glsr(CreateReviewDefaults::class)->restrict((array) $command);
25
-        $reviewValues = apply_filters('site-reviews/create/review-values', $reviewValues, $command);
26
-        $reviewValues = glsr(Helper::class)->prefixArrayKeys($reviewValues);
24
+        $reviewValues = glsr( CreateReviewDefaults::class )->restrict( (array)$command );
25
+        $reviewValues = apply_filters( 'site-reviews/create/review-values', $reviewValues, $command );
26
+        $reviewValues = glsr( Helper::class )->prefixArrayKeys( $reviewValues );
27 27
         unset($reviewValues['json']); // @todo remove the need for this
28 28
         $postValues = [
29 29
             'comment_status' => 'closed',
@@ -31,20 +31,20 @@  discard block
 block discarded – undo
31 31
             'ping_status' => 'closed',
32 32
             'post_content' => $reviewValues['_content'],
33 33
             'post_date' => $reviewValues['_date'],
34
-            'post_date_gmt' => get_gmt_from_date($reviewValues['_date']),
34
+            'post_date_gmt' => get_gmt_from_date( $reviewValues['_date'] ),
35 35
             'post_name' => $reviewValues['_review_type'].'-'.$reviewValues['_review_id'],
36
-            'post_status' => $this->getNewPostStatus($reviewValues, $command->blacklisted),
36
+            'post_status' => $this->getNewPostStatus( $reviewValues, $command->blacklisted ),
37 37
             'post_title' => $reviewValues['_title'],
38 38
             'post_type' => Application::POST_TYPE,
39 39
         ];
40
-        $postId = wp_insert_post($postValues, true);
41
-        if (is_wp_error($postId)) {
42
-            glsr_log()->error($postId->get_error_message())->debug($postValues);
40
+        $postId = wp_insert_post( $postValues, true );
41
+        if( is_wp_error( $postId ) ) {
42
+            glsr_log()->error( $postId->get_error_message() )->debug( $postValues );
43 43
             return false;
44 44
         }
45
-        $this->setTerms($postId, $command->category);
46
-        $review = $this->single(get_post($postId));
47
-        do_action('site-reviews/review/created', $review, $command);
45
+        $this->setTerms( $postId, $command->category );
46
+        $review = $this->single( get_post( $postId ) );
47
+        do_action( 'site-reviews/review/created', $review, $command );
48 48
         return $review;
49 49
     }
50 50
 
@@ -52,29 +52,29 @@  discard block
 block discarded – undo
52 52
      * @param string $metaReviewId
53 53
      * @return void
54 54
      */
55
-    public function delete($metaReviewId)
55
+    public function delete( $metaReviewId )
56 56
     {
57
-        if ($postId = $this->getPostId($metaReviewId)) {
58
-            wp_delete_post($postId, true);
57
+        if( $postId = $this->getPostId( $metaReviewId ) ) {
58
+            wp_delete_post( $postId, true );
59 59
         }
60 60
     }
61 61
 
62 62
     /**
63 63
      * @return object
64 64
      */
65
-    public function get(array $args = [])
65
+    public function get( array $args = [] )
66 66
     {
67
-        $args = glsr(ReviewsDefaults::class)->merge($args);
68
-        $metaQuery = glsr(QueryBuilder::class)->buildQuery(
67
+        $args = glsr( ReviewsDefaults::class )->merge( $args );
68
+        $metaQuery = glsr( QueryBuilder::class )->buildQuery(
69 69
             ['assigned_to', 'email', 'ip_address', 'type', 'rating'],
70 70
             $args
71 71
         );
72
-        $taxQuery = glsr(QueryBuilder::class)->buildQuery(
72
+        $taxQuery = glsr( QueryBuilder::class )->buildQuery(
73 73
             ['category'],
74
-            ['category' => $this->normalizeTermIds($args['category'])]
74
+            ['category' => $this->normalizeTermIds( $args['category'] )]
75 75
         );
76
-        $paged = glsr(QueryBuilder::class)->getPaged(
77
-            wp_validate_boolean($args['pagination'])
76
+        $paged = glsr( QueryBuilder::class )->getPaged(
77
+            wp_validate_boolean( $args['pagination'] )
78 78
         );
79 79
         $parameters = [
80 80
             'meta_key' => '_pinned',
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
             'offset' => $args['offset'],
83 83
             'order' => $args['order'],
84 84
             'orderby' => 'meta_value '.$args['orderby'],
85
-            'paged' => glsr_get($args, 'paged', $paged),
85
+            'paged' => glsr_get( $args, 'paged', $paged ),
86 86
             'post__in' => $args['post__in'],
87 87
             'post__not_in' => $args['post__not_in'],
88 88
             'post_status' => 'publish',
@@ -90,62 +90,62 @@  discard block
 block discarded – undo
90 90
             'posts_per_page' => $args['count'],
91 91
             'tax_query' => $taxQuery,
92 92
         ];
93
-        $parameters = apply_filters('site-reviews/get/reviews/query', $parameters, $args);
94
-        $query = new WP_Query($parameters);
95
-        $results = array_map([$this, 'single'], $query->posts);
96
-        $reviews = new Reviews($results, $query->max_num_pages, $args);
97
-        return apply_filters('site-reviews/get/reviews', $reviews, $query);
93
+        $parameters = apply_filters( 'site-reviews/get/reviews/query', $parameters, $args );
94
+        $query = new WP_Query( $parameters );
95
+        $results = array_map( [$this, 'single'], $query->posts );
96
+        $reviews = new Reviews( $results, $query->max_num_pages, $args );
97
+        return apply_filters( 'site-reviews/get/reviews', $reviews, $query );
98 98
     }
99 99
 
100 100
     /**
101 101
      * @param string $metaReviewId
102 102
      * @return int
103 103
      */
104
-    public function getPostId($metaReviewId)
104
+    public function getPostId( $metaReviewId )
105 105
     {
106
-        return glsr(SqlQueries::class)->getPostIdFromReviewId($metaReviewId);
106
+        return glsr( SqlQueries::class )->getPostIdFromReviewId( $metaReviewId );
107 107
     }
108 108
 
109 109
     /**
110 110
      * @return array
111 111
      */
112
-    public function getRatingCounts(array $args = [])
112
+    public function getRatingCounts( array $args = [] )
113 113
     {
114
-        $args = glsr(SiteReviewsSummaryDefaults::class)->filter($args);
115
-        $counts = glsr(CountsManager::class)->get([
116
-            'post_ids' => glsr(Helper::class)->convertStringToArray($args['assigned_to']),
117
-            'term_ids' => $this->normalizeTermIds($args['category']),
114
+        $args = glsr( SiteReviewsSummaryDefaults::class )->filter( $args );
115
+        $counts = glsr( CountsManager::class )->get( [
116
+            'post_ids' => glsr( Helper::class )->convertStringToArray( $args['assigned_to'] ),
117
+            'term_ids' => $this->normalizeTermIds( $args['category'] ),
118 118
             'type' => $args['type'],
119
-        ]);
120
-        return glsr(CountsManager::class)->flatten($counts, [
119
+        ] );
120
+        return glsr( CountsManager::class )->flatten( $counts, [
121 121
             'min' => $args['rating'],
122
-        ]);
122
+        ] );
123 123
     }
124 124
 
125 125
     /**
126 126
      * @param string $commaSeparatedTermIds
127 127
      * @return array
128 128
      */
129
-    public function normalizeTermIds($commaSeparatedTermIds)
129
+    public function normalizeTermIds( $commaSeparatedTermIds )
130 130
     {
131
-        $termIds = glsr_array_column($this->normalizeTerms($commaSeparatedTermIds), 'term_id');
132
-        return array_unique(array_map('intval', $termIds));
131
+        $termIds = glsr_array_column( $this->normalizeTerms( $commaSeparatedTermIds ), 'term_id' );
132
+        return array_unique( array_map( 'intval', $termIds ) );
133 133
     }
134 134
 
135 135
     /**
136 136
      * @param string $commaSeparatedTermIds
137 137
      * @return array
138 138
      */
139
-    public function normalizeTerms($commaSeparatedTermIds)
139
+    public function normalizeTerms( $commaSeparatedTermIds )
140 140
     {
141 141
         $terms = [];
142
-        $termIds = glsr(Helper::class)->convertStringToArray($commaSeparatedTermIds);
143
-        foreach ($termIds as $termId) {
144
-            if (is_numeric($termId)) {
145
-                $termId = intval($termId);
142
+        $termIds = glsr( Helper::class )->convertStringToArray( $commaSeparatedTermIds );
143
+        foreach( $termIds as $termId ) {
144
+            if( is_numeric( $termId ) ) {
145
+                $termId = intval( $termId );
146 146
             }
147
-            $term = term_exists($termId, Application::TAXONOMY);
148
-            if (!isset($term['term_id'])) {
147
+            $term = term_exists( $termId, Application::TAXONOMY );
148
+            if( !isset($term['term_id']) ) {
149 149
                 continue;
150 150
             }
151 151
             $terms[] = $term;
@@ -157,44 +157,44 @@  discard block
 block discarded – undo
157 157
      * @param int $postId
158 158
      * @return void
159 159
      */
160
-    public function revert($postId)
160
+    public function revert( $postId )
161 161
     {
162
-        if (Application::POST_TYPE != get_post_field('post_type', $postId)) {
162
+        if( Application::POST_TYPE != get_post_field( 'post_type', $postId ) ) {
163 163
             return;
164 164
         }
165
-        delete_post_meta($postId, '_edit_last');
166
-        $result = wp_update_post([
165
+        delete_post_meta( $postId, '_edit_last' );
166
+        $result = wp_update_post( [
167 167
             'ID' => $postId,
168
-            'post_content' => glsr(Database::class)->get($postId, 'content'),
169
-            'post_date' => glsr(Database::class)->get($postId, 'date'),
170
-            'post_title' => glsr(Database::class)->get($postId, 'title'),
171
-        ]);
172
-        if (is_wp_error($result)) {
173
-            glsr_log()->error($result->get_error_message());
168
+            'post_content' => glsr( Database::class )->get( $postId, 'content' ),
169
+            'post_date' => glsr( Database::class )->get( $postId, 'date' ),
170
+            'post_title' => glsr( Database::class )->get( $postId, 'title' ),
171
+        ] );
172
+        if( is_wp_error( $result ) ) {
173
+            glsr_log()->error( $result->get_error_message() );
174 174
             return;
175 175
         }
176
-        do_action('site-reviews/review/reverted', glsr_get_review($postId));
176
+        do_action( 'site-reviews/review/reverted', glsr_get_review( $postId ) );
177 177
     }
178 178
 
179 179
     /**
180 180
      * @return Review
181 181
      */
182
-    public function single(WP_Post $post)
182
+    public function single( WP_Post $post )
183 183
     {
184
-        if (Application::POST_TYPE != $post->post_type) {
185
-            $post = new WP_Post((object) []);
184
+        if( Application::POST_TYPE != $post->post_type ) {
185
+            $post = new WP_Post( (object)[] );
186 186
         }
187
-        $review = new Review($post);
188
-        return apply_filters('site-reviews/get/review', $review, $post);
187
+        $review = new Review( $post );
188
+        return apply_filters( 'site-reviews/get/review', $review, $post );
189 189
     }
190 190
 
191 191
     /**
192 192
      * @param bool $isBlacklisted
193 193
      * @return string
194 194
      */
195
-    protected function getNewPostStatus(array $reviewValues, $isBlacklisted)
195
+    protected function getNewPostStatus( array $reviewValues, $isBlacklisted )
196 196
     {
197
-        $requireApproval = glsr(OptionManager::class)->getBool('settings.general.require.approval');
197
+        $requireApproval = glsr( OptionManager::class )->getBool( 'settings.general.require.approval' );
198 198
         return 'local' == $reviewValues['_review_type'] && ($requireApproval || $isBlacklisted)
199 199
             ? 'pending'
200 200
             : 'publish';
@@ -205,15 +205,15 @@  discard block
 block discarded – undo
205 205
      * @param string $termIds
206 206
      * @return void
207 207
      */
208
-    protected function setTerms($postId, $termIds)
208
+    protected function setTerms( $postId, $termIds )
209 209
     {
210
-        $termIds = $this->normalizeTermIds($termIds);
211
-        if (empty($termIds)) {
210
+        $termIds = $this->normalizeTermIds( $termIds );
211
+        if( empty($termIds) ) {
212 212
             return;
213 213
         }
214
-        $termTaxonomyIds = wp_set_object_terms($postId, $termIds, Application::TAXONOMY);
215
-        if (is_wp_error($termTaxonomyIds)) {
216
-            glsr_log()->error($termTaxonomyIds->get_error_message());
214
+        $termTaxonomyIds = wp_set_object_terms( $postId, $termIds, Application::TAXONOMY );
215
+        if( is_wp_error( $termTaxonomyIds ) ) {
216
+            glsr_log()->error( $termTaxonomyIds->get_error_message() );
217 217
         }
218 218
     }
219 219
 }
Please login to merge, or discard this patch.
plugin/Router.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -13,10 +13,10 @@  discard block
 block discarded – undo
13 13
 
14 14
     public function __construct()
15 15
     {
16
-        $this->unguardedActions = apply_filters('site-reviews/router/unguarded-actions', [
16
+        $this->unguardedActions = apply_filters( 'site-reviews/router/unguarded-actions', [
17 17
             'dismiss-notice',
18 18
             'fetch-paged-reviews',
19
-        ]);
19
+        ] );
20 20
     }
21 21
 
22 22
     /**
@@ -25,11 +25,11 @@  discard block
 block discarded – undo
25 25
     public function routeAdminPostRequest()
26 26
     {
27 27
         $request = $this->getRequest();
28
-        if (!$this->isValidPostRequest($request)) {
28
+        if( !$this->isValidPostRequest( $request ) ) {
29 29
             return;
30 30
         }
31
-        check_admin_referer($request['_action']);
32
-        $this->routeRequest('admin', $request['_action'], $request);
31
+        check_admin_referer( $request['_action'] );
32
+        $this->routeRequest( 'admin', $request['_action'], $request );
33 33
     }
34 34
 
35 35
     /**
@@ -38,9 +38,9 @@  discard block
 block discarded – undo
38 38
     public function routeAjaxRequest()
39 39
     {
40 40
         $request = $this->getRequest();
41
-        $this->checkAjaxRequest($request);
42
-        $this->checkAjaxNonce($request);
43
-        $this->routeRequest('ajax', $request['_action'], $request);
41
+        $this->checkAjaxRequest( $request );
42
+        $this->checkAjaxNonce( $request );
43
+        $this->routeRequest( 'ajax', $request['_action'], $request );
44 44
         wp_die();
45 45
     }
46 46
 
@@ -49,45 +49,45 @@  discard block
 block discarded – undo
49 49
      */
50 50
     public function routePublicPostRequest()
51 51
     {
52
-        if (is_admin()) {
52
+        if( is_admin() ) {
53 53
             return;
54 54
         }
55 55
         $request = $this->getRequest();
56
-        if (!$this->isValidPostRequest($request)) {
56
+        if( !$this->isValidPostRequest( $request ) ) {
57 57
             return;
58 58
         }
59
-        if (!$this->isValidPublicNonce($request)) {
59
+        if( !$this->isValidPublicNonce( $request ) ) {
60 60
             return;
61 61
         }
62
-        $this->routeRequest('public', $request['_action'], $request);
62
+        $this->routeRequest( 'public', $request['_action'], $request );
63 63
     }
64 64
 
65 65
     /**
66 66
      * @return void
67 67
      */
68
-    protected function checkAjaxNonce(array $request)
68
+    protected function checkAjaxNonce( array $request )
69 69
     {
70
-        if (!is_user_logged_in() || in_array(glsr_get($request, '_action'), $this->unguardedActions)) {
70
+        if( !is_user_logged_in() || in_array( glsr_get( $request, '_action' ), $this->unguardedActions ) ) {
71 71
             return;
72 72
         }
73
-        if (!isset($request['_nonce'])) {
74
-            $this->sendAjaxError('request is missing a nonce', $request);
73
+        if( !isset($request['_nonce']) ) {
74
+            $this->sendAjaxError( 'request is missing a nonce', $request );
75 75
         }
76
-        if (!wp_verify_nonce($request['_nonce'], $request['_action'])) {
77
-            $this->sendAjaxError('request failed the nonce check', $request, 403);
76
+        if( !wp_verify_nonce( $request['_nonce'], $request['_action'] ) ) {
77
+            $this->sendAjaxError( 'request failed the nonce check', $request, 403 );
78 78
         }
79 79
     }
80 80
 
81 81
     /**
82 82
      * @return void
83 83
      */
84
-    protected function checkAjaxRequest(array $request)
84
+    protected function checkAjaxRequest( array $request )
85 85
     {
86
-        if (!isset($request['_action'])) {
87
-            $this->sendAjaxError('request must include an action', $request);
86
+        if( !isset($request['_action']) ) {
87
+            $this->sendAjaxError( 'request must include an action', $request );
88 88
         }
89
-        if (empty($request['_ajax_request'])) {
90
-            $this->sendAjaxError('request is invalid', $request);
89
+        if( empty($request['_ajax_request']) ) {
90
+            $this->sendAjaxError( 'request is invalid', $request );
91 91
         }
92 92
     }
93 93
 
@@ -98,12 +98,12 @@  discard block
 block discarded – undo
98 98
      */
99 99
     protected function getRequest()
100 100
     {
101
-        $request = glsr(Helper::class)->filterInputArray(Application::ID);
102
-        if (glsr(Helper::class)->filterInput('action') == Application::PREFIX.'action') {
101
+        $request = glsr( Helper::class )->filterInputArray( Application::ID );
102
+        if( glsr( Helper::class )->filterInput( 'action' ) == Application::PREFIX.'action' ) {
103 103
             $request['_ajax_request'] = true;
104 104
         }
105
-        if ('submit-review' == glsr(Helper::class)->filterInput('_action', $request)) {
106
-            $request['_recaptcha-token'] = glsr(Helper::class)->filterInput('g-recaptcha-response');
105
+        if( 'submit-review' == glsr( Helper::class )->filterInput( '_action', $request ) ) {
106
+            $request['_recaptcha-token'] = glsr( Helper::class )->filterInput( 'g-recaptcha-response' );
107 107
         }
108 108
         return $request;
109 109
     }
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
     /**
112 112
      * @return bool
113 113
      */
114
-    protected function isValidPostRequest(array $request = [])
114
+    protected function isValidPostRequest( array $request = [] )
115 115
     {
116 116
         return !empty($request['_action']) && empty($request['_ajax_request']);
117 117
     }
@@ -119,10 +119,10 @@  discard block
 block discarded – undo
119 119
     /**
120 120
      * @return bool
121 121
      */
122
-    protected function isValidPublicNonce(array $request)
122
+    protected function isValidPublicNonce( array $request )
123 123
     {
124
-        if (is_user_logged_in() && !wp_verify_nonce($request['_nonce'], $request['_action'])) {
125
-            glsr_log()->error('nonce check failed for public request')->debug($request);
124
+        if( is_user_logged_in() && !wp_verify_nonce( $request['_nonce'], $request['_action'] ) ) {
125
+            glsr_log()->error( 'nonce check failed for public request' )->debug( $request );
126 126
             return false;
127 127
         }
128 128
         return true;
@@ -133,19 +133,19 @@  discard block
 block discarded – undo
133 133
      * @param string $action
134 134
      * @return void
135 135
      */
136
-    protected function routeRequest($type, $action, array $request = [])
136
+    protected function routeRequest( $type, $action, array $request = [] )
137 137
     {
138 138
         $actionHook = 'site-reviews/route/'.$type.'/request';
139
-        $controller = glsr(glsr(Helper::class)->buildClassName($type.'-controller', 'Controllers'));
140
-        $method = glsr(Helper::class)->buildMethodName($action, 'router');
141
-        $request = apply_filters('site-reviews/route/request', $request, $action, $type);
142
-        do_action($actionHook, $action, $request);
143
-        if (is_callable([$controller, $method])) {
144
-            call_user_func([$controller, $method], $request);
139
+        $controller = glsr( glsr( Helper::class )->buildClassName( $type.'-controller', 'Controllers' ) );
140
+        $method = glsr( Helper::class )->buildMethodName( $action, 'router' );
141
+        $request = apply_filters( 'site-reviews/route/request', $request, $action, $type );
142
+        do_action( $actionHook, $action, $request );
143
+        if( is_callable( [$controller, $method] ) ) {
144
+            call_user_func( [$controller, $method], $request );
145 145
             return;
146 146
         }
147
-        if (0 === did_action($actionHook)) {
148
-            glsr_log('Unknown '.$type.' router request: '.$action);
147
+        if( 0 === did_action( $actionHook ) ) {
148
+            glsr_log( 'Unknown '.$type.' router request: '.$action );
149 149
         }
150 150
     }
151 151
 
@@ -154,14 +154,14 @@  discard block
 block discarded – undo
154 154
      * @param int $statusCode
155 155
      * @return void
156 156
      */
157
-    protected function sendAjaxError($error, array $request, $statusCode = 400)
157
+    protected function sendAjaxError( $error, array $request, $statusCode = 400 )
158 158
     {
159
-        glsr_log()->error($error)->debug($request);
160
-        glsr(Notice::class)->addError(__('There was an error (try reloading the page).', 'site-reviews').' <code>'.$error.'</code>');
161
-        wp_send_json_error([
162
-            'message' => __('The form could not be submitted. Please notify the site administrator.', 'site-reviews'),
163
-            'notices' => glsr(Notice::class)->get(),
159
+        glsr_log()->error( $error )->debug( $request );
160
+        glsr( Notice::class )->addError( __( 'There was an error (try reloading the page).', 'site-reviews' ).' <code>'.$error.'</code>' );
161
+        wp_send_json_error( [
162
+            'message' => __( 'The form could not be submitted. Please notify the site administrator.', 'site-reviews' ),
163
+            'notices' => glsr( Notice::class )->get(),
164 164
             'error' => $error,
165
-        ]);
165
+        ] );
166 166
     }
167 167
 }
Please login to merge, or discard this patch.
plugin/Helper.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
      * @param string $path
18 18
      * @return string
19 19
      */
20
-    public function buildClassName($name, $path = '')
20
+    public function buildClassName( $name, $path = '' )
21 21
     {
22
-        $className = $this->camelCase($name);
23
-        $path = ltrim(str_replace(__NAMESPACE__, '', $path), '\\');
22
+        $className = $this->camelCase( $name );
23
+        $path = ltrim( str_replace( __NAMESPACE__, '', $path ), '\\' );
24 24
         return !empty($path)
25 25
             ? __NAMESPACE__.'\\'.$path.'\\'.$className
26 26
             : $className;
@@ -31,18 +31,18 @@  discard block
 block discarded – undo
31 31
      * @param string $prefix
32 32
      * @return string
33 33
      */
34
-    public function buildMethodName($name, $prefix = '')
34
+    public function buildMethodName( $name, $prefix = '' )
35 35
     {
36
-        return lcfirst($prefix.$this->buildClassName($name));
36
+        return lcfirst( $prefix.$this->buildClassName( $name ) );
37 37
     }
38 38
 
39 39
     /**
40 40
      * @param string $name
41 41
      * @return string
42 42
      */
43
-    public function buildPropertyName($name)
43
+    public function buildPropertyName( $name )
44 44
     {
45
-        return lcfirst($this->buildClassName($name));
45
+        return lcfirst( $this->buildClassName( $name ) );
46 46
     }
47 47
 
48 48
     /**
@@ -50,30 +50,30 @@  discard block
 block discarded – undo
50 50
      * @param mixed $value
51 51
      * @return mixed
52 52
      */
53
-    public function castTo($cast = '', $value)
53
+    public function castTo( $cast = '', $value )
54 54
     {
55
-        switch ($cast) {
55
+        switch( $cast ) {
56 56
             case 'array':
57
-                return (array) $value;
57
+                return (array)$value;
58 58
             case 'bool':
59 59
             case 'boolean':
60
-                return filter_var($value, FILTER_VALIDATE_BOOLEAN);
60
+                return filter_var( $value, FILTER_VALIDATE_BOOLEAN );
61 61
             case 'float':
62
-                return (float) filter_var($value, FILTER_VALIDATE_FLOAT, FILTER_FLAG_ALLOW_THOUSAND);
62
+                return (float)filter_var( $value, FILTER_VALIDATE_FLOAT, FILTER_FLAG_ALLOW_THOUSAND );
63 63
             case 'int':
64 64
             case 'integer':
65
-                return (int) filter_var($value, FILTER_VALIDATE_INT);
65
+                return (int)filter_var( $value, FILTER_VALIDATE_INT );
66 66
             case 'object':
67
-                return (object) (array) $value;
67
+                return (object)(array)$value;
68 68
             case 'str':
69 69
             case 'string':
70
-                if (is_object($value) && in_array('__toString', get_class_methods($value))) {
71
-                    return (string) $value->__toString();
70
+                if( is_object( $value ) && in_array( '__toString', get_class_methods( $value ) ) ) {
71
+                    return (string)$value->__toString();
72 72
                 }
73
-                if (is_array($value) || is_object($value)) {
74
-                    return serialize($value);
73
+                if( is_array( $value ) || is_object( $value ) ) {
74
+                    return serialize( $value );
75 75
                 }
76
-                return (string) $value;
76
+                return (string)$value;
77 77
             default:
78 78
                 return $value;
79 79
         }
@@ -83,13 +83,13 @@  discard block
 block discarded – undo
83 83
      * @param string $key
84 84
      * @return mixed
85 85
      */
86
-    public function filterInput($key, array $request = [])
86
+    public function filterInput( $key, array $request = [] )
87 87
     {
88
-        if (isset($request[$key])) {
88
+        if( isset($request[$key]) ) {
89 89
             return $request[$key];
90 90
         }
91
-        $variable = filter_input(INPUT_POST, $key);
92
-        if (is_null($variable) && isset($_POST[$key])) {
91
+        $variable = filter_input( INPUT_POST, $key );
92
+        if( is_null( $variable ) && isset($_POST[$key]) ) {
93 93
             $variable = $_POST[$key];
94 94
         }
95 95
         return $variable;
@@ -99,13 +99,13 @@  discard block
 block discarded – undo
99 99
      * @param string $key
100 100
      * @return array
101 101
      */
102
-    public function filterInputArray($key)
102
+    public function filterInputArray( $key )
103 103
     {
104
-        $variable = filter_input(INPUT_POST, $key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
105
-        if (empty($variable) && !empty($_POST[$key]) && is_array($_POST[$key])) {
104
+        $variable = filter_input( INPUT_POST, $key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
105
+        if( empty($variable) && !empty($_POST[$key]) && is_array( $_POST[$key] ) ) {
106 106
             $variable = $_POST[$key];
107 107
         }
108
-        return (array) $variable;
108
+        return (array)$variable;
109 109
     }
110 110
 
111 111
     /**
@@ -113,11 +113,11 @@  discard block
 block discarded – undo
113 113
      */
114 114
     public function getIpAddress()
115 115
     {
116
-        $cloudflareIps = glsr(Cache::class)->getCloudflareIps();
117
-        $ipv6 = defined('AF_INET6')
116
+        $cloudflareIps = glsr( Cache::class )->getCloudflareIps();
117
+        $ipv6 = defined( 'AF_INET6' )
118 118
             ? $cloudflareIps['v6']
119 119
             : [];
120
-        $whitelist = apply_filters('site-reviews/whip/whitelist', [
120
+        $whitelist = apply_filters( 'site-reviews/whip/whitelist', [
121 121
             Whip::CLOUDFLARE_HEADERS => [
122 122
                 Whip::IPV4 => $cloudflareIps['v4'],
123 123
                 Whip::IPV6 => $ipv6,
@@ -126,11 +126,11 @@  discard block
 block discarded – undo
126 126
                 Whip::IPV4 => ['127.0.0.1'],
127 127
                 Whip::IPV6 => ['::1'],
128 128
             ],
129
-        ]);
129
+        ] );
130 130
         $methods = Whip::CUSTOM_HEADERS | Whip::CLOUDFLARE_HEADERS | Whip::REMOTE_ADDR;
131
-        $methods = apply_filters('site-reviews/whip/methods', $methods);
132
-        $whip = new Whip($methods, $whitelist);
133
-        do_action_ref_array('site-reviews/whip', [$whip]);
134
-        return (string) $whip->getValidIpAddress();
131
+        $methods = apply_filters( 'site-reviews/whip/methods', $methods );
132
+        $whip = new Whip( $methods, $whitelist );
133
+        do_action_ref_array( 'site-reviews/whip', [$whip] );
134
+        return (string)$whip->getValidIpAddress();
135 135
     }
136 136
 }
Please login to merge, or discard this patch.
plugin/Application.php 1 patch
Spacing   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -28,13 +28,13 @@  discard block
 block discarded – undo
28 28
     public function __construct()
29 29
     {
30 30
         static::$instance = $this;
31
-        $this->file = realpath(trailingslashit(dirname(__DIR__)).static::ID.'.php');
32
-        $plugin = get_file_data($this->file, [
31
+        $this->file = realpath( trailingslashit( dirname( __DIR__ ) ).static::ID.'.php' );
32
+        $plugin = get_file_data( $this->file, [
33 33
             'languages' => 'Domain Path',
34 34
             'name' => 'Plugin Name',
35 35
             'version' => 'Version',
36
-        ], 'plugin');
37
-        array_walk($plugin, function ($value, $key) {
36
+        ], 'plugin' );
37
+        array_walk( $plugin, function( $value, $key ) {
38 38
             $this->$key = $value;
39 39
         });
40 40
     }
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
      */
45 45
     public function activate()
46 46
     {
47
-        $this->make(DefaultsManager::class)->set();
47
+        $this->make( DefaultsManager::class )->set();
48 48
         $this->scheduleCronJob();
49 49
         $this->upgrade();
50 50
     }
@@ -55,34 +55,34 @@  discard block
 block discarded – undo
55 55
     public function catchFatalError()
56 56
     {
57 57
         $error = error_get_last();
58
-        if (E_ERROR !== $error['type'] || false === strpos($error['message'], $this->path())) {
58
+        if( E_ERROR !== $error['type'] || false === strpos( $error['message'], $this->path() ) ) {
59 59
             return;
60 60
         }
61
-        glsr_log()->error($error['message']);
61
+        glsr_log()->error( $error['message'] );
62 62
     }
63 63
 
64 64
     /**
65 65
      * @param string $name
66 66
      * @return array
67 67
      */
68
-    public function config($name)
68
+    public function config( $name )
69 69
     {
70
-        $configFile = $this->path('config/'.$name.'.php');
71
-        $config = file_exists($configFile)
70
+        $configFile = $this->path( 'config/'.$name.'.php' );
71
+        $config = file_exists( $configFile )
72 72
             ? include $configFile
73 73
             : [];
74
-        return apply_filters('site-reviews/config/'.$name, $config);
74
+        return apply_filters( 'site-reviews/config/'.$name, $config );
75 75
     }
76 76
 
77 77
     /**
78 78
      * @param string $property
79 79
      * @return string
80 80
      */
81
-    public function constant($property, $className = 'static')
81
+    public function constant( $property, $className = 'static' )
82 82
     {
83 83
         $constant = $className.'::'.$property;
84
-        return defined($constant)
85
-            ? apply_filters('site-reviews/const/'.$property, constant($constant))
84
+        return defined( $constant )
85
+            ? apply_filters( 'site-reviews/const/'.$property, constant( $constant ) )
86 86
             : '';
87 87
     }
88 88
 
@@ -98,17 +98,17 @@  discard block
 block discarded – undo
98 98
      * @param string $view
99 99
      * @return void|string
100 100
      */
101
-    public function file($view)
101
+    public function file( $view )
102 102
     {
103
-        $view.= '.php';
103
+        $view .= '.php';
104 104
         $filePaths = [];
105
-        if (glsr(Helper::class)->startsWith('templates/', $view)) {
106
-            $filePaths[] = $this->themePath(glsr(Helper::class)->removePrefix('templates/', $view));
105
+        if( glsr( Helper::class )->startsWith( 'templates/', $view ) ) {
106
+            $filePaths[] = $this->themePath( glsr( Helper::class )->removePrefix( 'templates/', $view ) );
107 107
         }
108
-        $filePaths[] = $this->path($view);
109
-        $filePaths[] = $this->path('views/'.$view);
110
-        foreach ($filePaths as $file) {
111
-            if (!file_exists($file)) {
108
+        $filePaths[] = $this->path( $view );
109
+        $filePaths[] = $this->path( 'views/'.$view );
110
+        foreach( $filePaths as $file ) {
111
+            if( !file_exists( $file ) ) {
112 112
                 continue;
113 113
             }
114 114
             return $file;
@@ -120,33 +120,33 @@  discard block
 block discarded – undo
120 120
      */
121 121
     public function getDefaults()
122 122
     {
123
-        if (empty($this->defaults)) {
124
-            $this->defaults = $this->make(DefaultsManager::class)->get();
123
+        if( empty($this->defaults) ) {
124
+            $this->defaults = $this->make( DefaultsManager::class )->get();
125 125
             $this->upgrade();
126 126
         }
127
-        return apply_filters('site-reviews/get/defaults', $this->defaults);
127
+        return apply_filters( 'site-reviews/get/defaults', $this->defaults );
128 128
     }
129 129
 
130 130
     /**
131 131
      * @return bool
132 132
      */
133
-    public function getPermission($page = '')
133
+    public function getPermission( $page = '' )
134 134
     {
135 135
         $permissions = [
136 136
             'addons' => 'install_plugins',
137 137
             'settings' => 'manage_options',
138 138
             // 'welcome' => 'activate_plugins',
139 139
         ];
140
-        return glsr_get($permissions, $page, $this->constant('CAPABILITY'));
140
+        return glsr_get( $permissions, $page, $this->constant( 'CAPABILITY' ) );
141 141
     }
142 142
 
143 143
     /**
144 144
      * @return bool
145 145
      */
146
-    public function hasPermission($page = '')
146
+    public function hasPermission( $page = '' )
147 147
     {
148 148
         $isAdmin = $this->isAdmin();
149
-        return !$isAdmin || ($isAdmin && current_user_can($this->getPermission($page)));
149
+        return !$isAdmin || ($isAdmin && current_user_can( $this->getPermission( $page ) ));
150 150
     }
151 151
 
152 152
     /**
@@ -154,8 +154,8 @@  discard block
 block discarded – undo
154 154
      */
155 155
     public function init()
156 156
     {
157
-        $this->make(Actions::class)->run();
158
-        $this->make(Filters::class)->run();
157
+        $this->make( Actions::class )->run();
158
+        $this->make( Filters::class )->run();
159 159
     }
160 160
 
161 161
     /**
@@ -170,14 +170,14 @@  discard block
 block discarded – undo
170 170
      * @param string $file
171 171
      * @return string
172 172
      */
173
-    public function path($file = '', $realpath = true)
173
+    public function path( $file = '', $realpath = true )
174 174
     {
175
-        $path = plugin_dir_path($this->file);
176
-        if (!$realpath) {
177
-            $path = trailingslashit(WP_PLUGIN_DIR).basename(dirname($this->file));
175
+        $path = plugin_dir_path( $this->file );
176
+        if( !$realpath ) {
177
+            $path = trailingslashit( WP_PLUGIN_DIR ).basename( dirname( $this->file ) );
178 178
         }
179
-        $path = trailingslashit($path).ltrim(trim($file), '/');
180
-        return apply_filters('site-reviews/path', $path, $file);
179
+        $path = trailingslashit( $path ).ltrim( trim( $file ), '/' );
180
+        return apply_filters( 'site-reviews/path', $path, $file );
181 181
     }
182 182
 
183 183
     /**
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
      */
186 186
     public function registerAddons()
187 187
     {
188
-        do_action('site-reviews/addon/register', $this);
188
+        do_action( 'site-reviews/addon/register', $this );
189 189
     }
190 190
 
191 191
     /**
@@ -193,8 +193,8 @@  discard block
 block discarded – undo
193 193
      */
194 194
     public function registerLanguages()
195 195
     {
196
-        load_plugin_textdomain(static::ID, false,
197
-            trailingslashit(plugin_basename($this->path()).'/'.$this->languages)
196
+        load_plugin_textdomain( static::ID, false,
197
+            trailingslashit( plugin_basename( $this->path() ).'/'.$this->languages )
198 198
         );
199 199
     }
200 200
 
@@ -203,26 +203,26 @@  discard block
 block discarded – undo
203 203
      */
204 204
     public function registerReviewTypes()
205 205
     {
206
-        $types = apply_filters('site-reviews/addon/types', []);
207
-        $this->reviewTypes = wp_parse_args($types, [
208
-            'local' => __('Local', 'site-reviews'),
209
-        ]);
206
+        $types = apply_filters( 'site-reviews/addon/types', [] );
207
+        $this->reviewTypes = wp_parse_args( $types, [
208
+            'local' => __( 'Local', 'site-reviews' ),
209
+        ] );
210 210
     }
211 211
 
212 212
     /**
213 213
      * @param string $view
214 214
      * @return void
215 215
      */
216
-    public function render($view, array $data = [])
216
+    public function render( $view, array $data = [] )
217 217
     {
218
-        $view = apply_filters('site-reviews/render/view', $view, $data);
219
-        $file = apply_filters('site-reviews/views/file', $this->file($view), $view, $data);
220
-        if (!file_exists($file)) {
221
-            glsr_log()->error('File not found: '.$file);
218
+        $view = apply_filters( 'site-reviews/render/view', $view, $data );
219
+        $file = apply_filters( 'site-reviews/views/file', $this->file( $view ), $view, $data );
220
+        if( !file_exists( $file ) ) {
221
+            glsr_log()->error( 'File not found: '.$file );
222 222
             return;
223 223
         }
224
-        $data = apply_filters('site-reviews/views/data', $data, $view);
225
-        extract($data);
224
+        $data = apply_filters( 'site-reviews/views/data', $data, $view );
225
+        extract( $data );
226 226
         include $file;
227 227
     }
228 228
 
@@ -231,19 +231,19 @@  discard block
 block discarded – undo
231 231
      */
232 232
     public function scheduleCronJob()
233 233
     {
234
-        if (wp_next_scheduled(static::CRON_EVENT)) {
234
+        if( wp_next_scheduled( static::CRON_EVENT ) ) {
235 235
             return;
236 236
         }
237
-        wp_schedule_event(time(), 'twicedaily', static::CRON_EVENT);
237
+        wp_schedule_event( time(), 'twicedaily', static::CRON_EVENT );
238 238
     }
239 239
 
240 240
     /**
241 241
      * @param string $file
242 242
      * @return string
243 243
      */
244
-    public function themePath($file = '')
244
+    public function themePath( $file = '' )
245 245
     {
246
-        return get_stylesheet_directory().'/'.static::ID.'/'.ltrim(trim($file), '/');
246
+        return get_stylesheet_directory().'/'.static::ID.'/'.ltrim( trim( $file ), '/' );
247 247
     }
248 248
 
249 249
     /**
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
      */
252 252
     public function unscheduleCronJob()
253 253
     {
254
-        wp_unschedule_event(intval(wp_next_scheduled(static::CRON_EVENT)), static::CRON_EVENT);
254
+        wp_unschedule_event( intval( wp_next_scheduled( static::CRON_EVENT ) ), static::CRON_EVENT );
255 255
     }
256 256
 
257 257
     /**
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
      */
260 260
     public function upgrade()
261 261
     {
262
-        $this->make(Upgrader::class)->run();
262
+        $this->make( Upgrader::class )->run();
263 263
     }
264 264
 
265 265
     /**
@@ -267,10 +267,10 @@  discard block
 block discarded – undo
267 267
      * @return void
268 268
      * @action upgrader_process_complete
269 269
      */
270
-    public function upgraded($upgrader, array $data)
270
+    public function upgraded( $upgrader, array $data )
271 271
     {
272
-        if (array_key_exists('plugins', $data)
273
-            && in_array(plugin_basename($this->file), $data['plugins'])
272
+        if( array_key_exists( 'plugins', $data )
273
+            && in_array( plugin_basename( $this->file ), $data['plugins'] )
274 274
             && 'update' === $data['action']
275 275
             && 'plugin' === $data['type']
276 276
         ) {
@@ -282,29 +282,29 @@  discard block
 block discarded – undo
282 282
      * @param string $path
283 283
      * @return string
284 284
      */
285
-    public function url($path = '')
285
+    public function url( $path = '' )
286 286
     {
287
-        $url = esc_url(plugin_dir_url($this->file).ltrim(trim($path), '/'));
288
-        return apply_filters('site-reviews/url', $url, $path);
287
+        $url = esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' ) );
288
+        return apply_filters( 'site-reviews/url', $url, $path );
289 289
     }
290 290
 
291 291
     /**
292 292
      * @param string $versionLevel
293 293
      * @return string
294 294
      */
295
-    public function version($versionLevel = '')
295
+    public function version( $versionLevel = '' )
296 296
     {
297 297
         $pattern = '/^v?(\d{1,5})(\.\d++)?(\.\d++)?(.+)?$/i';
298
-        preg_match($pattern, $this->version, $matches);
299
-        switch ($versionLevel) {
298
+        preg_match( $pattern, $this->version, $matches );
299
+        switch( $versionLevel ) {
300 300
             case 'major':
301
-                $version = glsr_get($matches, 1);
301
+                $version = glsr_get( $matches, 1 );
302 302
                 break;
303 303
             case 'minor':
304
-                $version = glsr_get($matches, 1).glsr_get($matches, 2);
304
+                $version = glsr_get( $matches, 1 ).glsr_get( $matches, 2 );
305 305
                 break;
306 306
             case 'patch':
307
-                $version = glsr_get($matches, 1).glsr_get($matches, 2).glsr_get($matches, 3);
307
+                $version = glsr_get( $matches, 1 ).glsr_get( $matches, 2 ).glsr_get( $matches, 3 );
308 308
                 break;
309 309
         }
310 310
         return empty($version)
Please login to merge, or discard this patch.
plugin/Controllers/MenuController.php 1 patch
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -20,20 +20,20 @@  discard block
 block discarded – undo
20 20
     public function registerMenuCount()
21 21
     {
22 22
         global $menu, $typenow;
23
-        foreach ($menu as $key => $value) {
24
-            if (!isset($value[2]) || $value[2] != 'edit.php?post_type='.Application::POST_TYPE) {
23
+        foreach( $menu as $key => $value ) {
24
+            if( !isset($value[2]) || $value[2] != 'edit.php?post_type='.Application::POST_TYPE ) {
25 25
                 continue;
26 26
             }
27
-            $postCount = wp_count_posts(Application::POST_TYPE);
28
-            $pendingCount = glsr(Builder::class)->span(number_format_i18n($postCount->pending), [
27
+            $postCount = wp_count_posts( Application::POST_TYPE );
28
+            $pendingCount = glsr( Builder::class )->span( number_format_i18n( $postCount->pending ), [
29 29
                 'class' => 'unapproved-count',
30
-            ]);
31
-            $awaitingModeration = glsr(Builder::class)->span($pendingCount, [
30
+            ] );
31
+            $awaitingModeration = glsr( Builder::class )->span( $pendingCount, [
32 32
                 'class' => 'awaiting-mod count-'.$postCount->pending,
33
-            ]);
34
-            $menu[$key][0].= ' '.$awaitingModeration;
35
-            if (Application::POST_TYPE === $typenow) {
36
-                $menu[$key][4].= ' current';
33
+            ] );
34
+            $menu[$key][0] .= ' '.$awaitingModeration;
35
+            if( Application::POST_TYPE === $typenow ) {
36
+                $menu[$key][4] .= ' current';
37 37
             }
38 38
             break;
39 39
         }
@@ -45,19 +45,19 @@  discard block
 block discarded – undo
45 45
      */
46 46
     public function registerSubMenus()
47 47
     {
48
-        $pages = $this->parseWithFilter('submenu/pages', [
49
-            'settings' => __('Settings', 'site-reviews'),
50
-            'tools' => __('Tools', 'site-reviews'),
51
-            'addons' => __('Add-ons', 'site-reviews'),
52
-            'documentation' => __('Documentation', 'site-reviews'),
53
-        ]);
54
-        foreach ($pages as $slug => $title) {
55
-            $method = glsr(Helper::class)->buildMethodName('render-'.$slug.'-menu');
56
-            $callback = apply_filters('site-reviews/addon/submenu/callback', [$this, $method], $slug);
57
-            if (!is_callable($callback)) {
48
+        $pages = $this->parseWithFilter( 'submenu/pages', [
49
+            'settings' => __( 'Settings', 'site-reviews' ),
50
+            'tools' => __( 'Tools', 'site-reviews' ),
51
+            'addons' => __( 'Add-ons', 'site-reviews' ),
52
+            'documentation' => __( 'Documentation', 'site-reviews' ),
53
+        ] );
54
+        foreach( $pages as $slug => $title ) {
55
+            $method = glsr( Helper::class )->buildMethodName( 'render-'.$slug.'-menu' );
56
+            $callback = apply_filters( 'site-reviews/addon/submenu/callback', [$this, $method], $slug );
57
+            if( !is_callable( $callback ) ) {
58 58
                 continue;
59 59
             }
60
-            add_submenu_page('edit.php?post_type='.Application::POST_TYPE, $title, $title, glsr()->getPermission($slug), $slug, $callback);
60
+            add_submenu_page( 'edit.php?post_type='.Application::POST_TYPE, $title, $title, glsr()->getPermission( $slug ), $slug, $callback );
61 61
         }
62 62
     }
63 63
 
@@ -68,9 +68,9 @@  discard block
 block discarded – undo
68 68
      */
69 69
     public function renderAddonsMenu()
70 70
     {
71
-        $this->renderPage('addons', [
72
-            'template' => glsr(Template::class),
73
-        ]);
71
+        $this->renderPage( 'addons', [
72
+            'template' => glsr( Template::class ),
73
+        ] );
74 74
     }
75 75
 
76 76
     /**
@@ -80,23 +80,23 @@  discard block
 block discarded – undo
80 80
      */
81 81
     public function renderDocumentationMenu()
82 82
     {
83
-        $tabs = $this->parseWithFilter('documentation/tabs', [
84
-            'support' => __('Support', 'site-reviews'),
85
-            'faq' => __('FAQ', 'site-reviews'),
86
-            'shortcodes' => __('Shortcodes', 'site-reviews'),
87
-            'hooks' => __('Hooks', 'site-reviews'),
88
-            'functions' => __('Functions', 'site-reviews'),
89
-            'addons' => __('Addons', 'site-reviews'),
90
-        ]);
91
-        $addons = apply_filters('site-reviews/addon/documentation', []);
92
-        ksort($addons);
93
-        if (empty($addons)) {
83
+        $tabs = $this->parseWithFilter( 'documentation/tabs', [
84
+            'support' => __( 'Support', 'site-reviews' ),
85
+            'faq' => __( 'FAQ', 'site-reviews' ),
86
+            'shortcodes' => __( 'Shortcodes', 'site-reviews' ),
87
+            'hooks' => __( 'Hooks', 'site-reviews' ),
88
+            'functions' => __( 'Functions', 'site-reviews' ),
89
+            'addons' => __( 'Addons', 'site-reviews' ),
90
+        ] );
91
+        $addons = apply_filters( 'site-reviews/addon/documentation', [] );
92
+        ksort( $addons );
93
+        if( empty($addons) ) {
94 94
             unset($tabs['addons']);
95 95
         }
96
-        $this->renderPage('documentation', [
96
+        $this->renderPage( 'documentation', [
97 97
             'addons' => $addons,
98 98
             'tabs' => $tabs,
99
-        ]);
99
+        ] );
100 100
     }
101 101
 
102 102
     /**
@@ -106,25 +106,25 @@  discard block
 block discarded – undo
106 106
      */
107 107
     public function renderSettingsMenu()
108 108
     {
109
-        $tabs = $this->parseWithFilter('settings/tabs', [
110
-            'general' => __('General', 'site-reviews'),
111
-            'reviews' => __('Reviews', 'site-reviews'),
112
-            'submissions' => __('Submissions', 'site-reviews'),
113
-            'schema' => __('Schema', 'site-reviews'),
114
-            'translations' => __('Translations', 'site-reviews'),
115
-            'addons' => __('Addons', 'site-reviews'),
116
-            'licenses' => __('Licenses', 'site-reviews'),
117
-        ]);
118
-        if (empty(glsr(Helper::class)->dataGet(glsr()->defaults, 'settings.addons'))) {
109
+        $tabs = $this->parseWithFilter( 'settings/tabs', [
110
+            'general' => __( 'General', 'site-reviews' ),
111
+            'reviews' => __( 'Reviews', 'site-reviews' ),
112
+            'submissions' => __( 'Submissions', 'site-reviews' ),
113
+            'schema' => __( 'Schema', 'site-reviews' ),
114
+            'translations' => __( 'Translations', 'site-reviews' ),
115
+            'addons' => __( 'Addons', 'site-reviews' ),
116
+            'licenses' => __( 'Licenses', 'site-reviews' ),
117
+        ] );
118
+        if( empty(glsr( Helper::class )->dataGet( glsr()->defaults, 'settings.addons' )) ) {
119 119
             unset($tabs['addons']);
120 120
         }
121
-        if (empty(glsr(Helper::class)->dataGet(glsr()->defaults, 'settings.licenses'))) {
121
+        if( empty(glsr( Helper::class )->dataGet( glsr()->defaults, 'settings.licenses' )) ) {
122 122
             unset($tabs['licenses']);
123 123
         }
124
-        $this->renderPage('settings', [
125
-            'settings' => glsr(Settings::class),
124
+        $this->renderPage( 'settings', [
125
+            'settings' => glsr( Settings::class ),
126 126
             'tabs' => $tabs,
127
-        ]);
127
+        ] );
128 128
     }
129 129
 
130 130
     /**
@@ -134,28 +134,28 @@  discard block
 block discarded – undo
134 134
      */
135 135
     public function renderToolsMenu()
136 136
     {
137
-        $tabs = $this->parseWithFilter('tools/tabs', [
138
-            'general' => __('General', 'site-reviews'),
139
-            'sync' => __('Sync Reviews', 'site-reviews'),
140
-            'console' => __('Console', 'site-reviews'),
141
-            'system-info' => __('System Info', 'site-reviews'),
142
-        ]);
143
-        if (!apply_filters('site-reviews/addon/sync/enable', false)) {
137
+        $tabs = $this->parseWithFilter( 'tools/tabs', [
138
+            'general' => __( 'General', 'site-reviews' ),
139
+            'sync' => __( 'Sync Reviews', 'site-reviews' ),
140
+            'console' => __( 'Console', 'site-reviews' ),
141
+            'system-info' => __( 'System Info', 'site-reviews' ),
142
+        ] );
143
+        if( !apply_filters( 'site-reviews/addon/sync/enable', false ) ) {
144 144
             unset($tabs['sync']);
145 145
         }
146
-        $this->renderPage('tools', [
146
+        $this->renderPage( 'tools', [
147 147
             'data' => [
148 148
                 'context' => [
149
-                    'base_url' => admin_url('edit.php?post_type='.Application::POST_TYPE),
150
-                    'console' => strval(glsr(Console::class)),
149
+                    'base_url' => admin_url( 'edit.php?post_type='.Application::POST_TYPE ),
150
+                    'console' => strval( glsr( Console::class ) ),
151 151
                     'id' => Application::ID,
152
-                    'system' => strval(glsr(System::class)),
152
+                    'system' => strval( glsr( System::class ) ),
153 153
                 ],
154
-                'services' => apply_filters('site-reviews/addon/sync/services', []),
154
+                'services' => apply_filters( 'site-reviews/addon/sync/services', [] ),
155 155
             ],
156 156
             'tabs' => $tabs,
157
-            'template' => glsr(Template::class),
158
-        ]);
157
+            'template' => glsr( Template::class ),
158
+        ] );
159 159
     }
160 160
 
161 161
     /**
@@ -164,8 +164,8 @@  discard block
 block discarded – undo
164 164
      */
165 165
     public function setCustomPermissions()
166 166
     {
167
-        foreach (wp_roles()->roles as $role => $value) {
168
-            wp_roles()->remove_cap($role, 'create_'.Application::POST_TYPE);
167
+        foreach( wp_roles()->roles as $role => $value ) {
168
+            wp_roles()->remove_cap( $role, 'create_'.Application::POST_TYPE );
169 169
         }
170 170
     }
171 171
 
@@ -174,28 +174,28 @@  discard block
 block discarded – undo
174 174
      */
175 175
     protected function getNotices()
176 176
     {
177
-        return glsr(Builder::class)->div(glsr(Notice::class)->get(), [
177
+        return glsr( Builder::class )->div( glsr( Notice::class )->get(), [
178 178
             'id' => 'glsr-notices',
179
-        ]);
179
+        ] );
180 180
     }
181 181
 
182 182
     /**
183 183
      * @param string $hookSuffix
184 184
      * @return array
185 185
      */
186
-    protected function parseWithFilter($hookSuffix, array $args = [])
186
+    protected function parseWithFilter( $hookSuffix, array $args = [] )
187 187
     {
188
-        return apply_filters('site-reviews/addon/'.$hookSuffix, $args);
188
+        return apply_filters( 'site-reviews/addon/'.$hookSuffix, $args );
189 189
     }
190 190
 
191 191
     /**
192 192
      * @param string $page
193 193
      * @return void
194 194
      */
195
-    protected function renderPage($page, array $data = [])
195
+    protected function renderPage( $page, array $data = [] )
196 196
     {
197
-        $data['http_referer'] = (string) wp_get_referer();
197
+        $data['http_referer'] = (string)wp_get_referer();
198 198
         $data['notices'] = $this->getNotices();
199
-        glsr()->render('pages/'.$page.'/index', $data);
199
+        glsr()->render( 'pages/'.$page.'/index', $data );
200 200
     }
201 201
 }
Please login to merge, or discard this patch.
plugin/Controllers/AjaxController.php 1 patch
Spacing   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -15,9 +15,9 @@  discard block
 block discarded – undo
15 15
     /**
16 16
      * @return void
17 17
      */
18
-    public function routerChangeStatus(array $request)
18
+    public function routerChangeStatus( array $request )
19 19
     {
20
-        wp_send_json_success($this->execute(new ChangeStatus($request)));
20
+        wp_send_json_success( $this->execute( new ChangeStatus( $request ) ) );
21 21
     }
22 22
 
23 23
     /**
@@ -25,11 +25,11 @@  discard block
 block discarded – undo
25 25
      */
26 26
     public function routerClearConsole()
27 27
     {
28
-        glsr(AdminController::class)->routerClearConsole();
29
-        wp_send_json_success([
30
-            'console' => glsr(Console::class)->get(),
31
-            'notices' => glsr(Notice::class)->get(),
32
-        ]);
28
+        glsr( AdminController::class )->routerClearConsole();
29
+        wp_send_json_success( [
30
+            'console' => glsr( Console::class )->get(),
31
+            'notices' => glsr( Notice::class )->get(),
32
+        ] );
33 33
     }
34 34
 
35 35
     /**
@@ -37,32 +37,32 @@  discard block
 block discarded – undo
37 37
      */
38 38
     public function routerCountReviews()
39 39
     {
40
-        glsr(AdminController::class)->routerCountReviews();
41
-        wp_send_json_success([
42
-            'notices' => glsr(Notice::class)->get(),
43
-        ]);
40
+        glsr( AdminController::class )->routerCountReviews();
41
+        wp_send_json_success( [
42
+            'notices' => glsr( Notice::class )->get(),
43
+        ] );
44 44
     }
45 45
 
46 46
     /**
47 47
      * @return void
48 48
      */
49
-    public function routerDismissNotice(array $request)
49
+    public function routerDismissNotice( array $request )
50 50
     {
51
-        glsr(NoticeController::class)->routerDismissNotice($request);
51
+        glsr( NoticeController::class )->routerDismissNotice( $request );
52 52
         wp_send_json_success();
53 53
     }
54 54
 
55 55
     /**
56 56
      * @return void
57 57
      */
58
-    public function routerMceShortcode(array $request)
58
+    public function routerMceShortcode( array $request )
59 59
     {
60 60
         $shortcode = $request['shortcode'];
61 61
         $response = false;
62
-        if (array_key_exists($shortcode, glsr()->mceShortcodes)) {
62
+        if( array_key_exists( $shortcode, glsr()->mceShortcodes ) ) {
63 63
             $data = glsr()->mceShortcodes[$shortcode];
64
-            if (!empty($data['errors'])) {
65
-                $data['btn_okay'] = [esc_html__('Okay', 'site-reviews')];
64
+            if( !empty($data['errors']) ) {
65
+                $data['btn_okay'] = [esc_html__( 'Okay', 'site-reviews' )];
66 66
             }
67 67
             $response = [
68 68
                 'body' => $data['fields'],
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
                 'title' => $data['title'],
73 73
             ];
74 74
         }
75
-        wp_send_json_success($response);
75
+        wp_send_json_success( $response );
76 76
     }
77 77
 
78 78
     /**
@@ -80,95 +80,95 @@  discard block
 block discarded – undo
80 80
      */
81 81
     public function routerFetchConsole()
82 82
     {
83
-        glsr(AdminController::class)->routerFetchConsole();
84
-        wp_send_json_success([
85
-            'console' => glsr(Console::class)->get(),
86
-            'notices' => glsr(Notice::class)->get(),
87
-        ]);
83
+        glsr( AdminController::class )->routerFetchConsole();
84
+        wp_send_json_success( [
85
+            'console' => glsr( Console::class )->get(),
86
+            'notices' => glsr( Notice::class )->get(),
87
+        ] );
88 88
     }
89 89
 
90 90
     /**
91 91
      * @return void
92 92
      */
93
-    public function routerSearchPosts(array $request)
93
+    public function routerSearchPosts( array $request )
94 94
     {
95
-        $results = glsr(Database::class)->searchPosts($request['search']);
96
-        wp_send_json_success([
97
-            'empty' => '<div>'.__('Nothing found.', 'site-reviews').'</div>',
95
+        $results = glsr( Database::class )->searchPosts( $request['search'] );
96
+        wp_send_json_success( [
97
+            'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>',
98 98
             'items' => $results,
99
-        ]);
99
+        ] );
100 100
     }
101 101
 
102 102
     /**
103 103
      * @return void
104 104
      */
105
-    public function routerSearchTranslations(array $request)
105
+    public function routerSearchTranslations( array $request )
106 106
     {
107
-        if (empty($request['exclude'])) {
107
+        if( empty($request['exclude']) ) {
108 108
             $request['exclude'] = [];
109 109
         }
110
-        $results = glsr(Translation::class)
111
-            ->search($request['search'])
110
+        $results = glsr( Translation::class )
111
+            ->search( $request['search'] )
112 112
             ->exclude()
113
-            ->exclude($request['exclude'])
113
+            ->exclude( $request['exclude'] )
114 114
             ->renderResults();
115
-        wp_send_json_success([
116
-            'empty' => '<div>'.__('Nothing found.', 'site-reviews').'</div>',
115
+        wp_send_json_success( [
116
+            'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>',
117 117
             'items' => $results,
118
-        ]);
118
+        ] );
119 119
     }
120 120
 
121 121
     /**
122 122
      * @return void
123 123
      */
124
-    public function routerSubmitReview(array $request)
124
+    public function routerSubmitReview( array $request )
125 125
     {
126
-        $command = glsr(PublicController::class)->routerSubmitReview($request);
127
-        $redirect = trim(strval(get_post_meta($command->post_id, 'redirect_to', true)));
128
-        $redirect = apply_filters('site-reviews/review/redirect', $redirect, $command);
126
+        $command = glsr( PublicController::class )->routerSubmitReview( $request );
127
+        $redirect = trim( strval( get_post_meta( $command->post_id, 'redirect_to', true ) ) );
128
+        $redirect = apply_filters( 'site-reviews/review/redirect', $redirect, $command );
129 129
         $data = [
130
-            'errors' => glsr()->sessionGet($command->form_id.'errors', false),
131
-            'message' => glsr()->sessionGet($command->form_id.'message', ''),
132
-            'recaptcha' => glsr()->sessionGet($command->form_id.'recaptcha', false),
130
+            'errors' => glsr()->sessionGet( $command->form_id.'errors', false ),
131
+            'message' => glsr()->sessionGet( $command->form_id.'message', '' ),
132
+            'recaptcha' => glsr()->sessionGet( $command->form_id.'recaptcha', false ),
133 133
             'redirect' => $redirect,
134 134
         ];
135
-        if (false === $data['errors']) {
135
+        if( false === $data['errors'] ) {
136 136
             glsr()->sessionClear();
137
-            wp_send_json_success($data);
137
+            wp_send_json_success( $data );
138 138
         }
139
-        wp_send_json_error($data);
139
+        wp_send_json_error( $data );
140 140
     }
141 141
 
142 142
     /**
143 143
      * @return void
144 144
      */
145
-    public function routerFetchPagedReviews(array $request)
145
+    public function routerFetchPagedReviews( array $request )
146 146
     {
147 147
         $urlQuery = [];
148
-        parse_str(parse_url(glsr_get($request, 'url'), PHP_URL_QUERY), $urlQuery);
148
+        parse_str( parse_url( glsr_get( $request, 'url' ), PHP_URL_QUERY ), $urlQuery );
149 149
         $args = [
150
-            'paged' => glsr_get($urlQuery, glsr()->constant('PAGED_QUERY_VAR'), 1),
151
-            'pagedUrl' => home_url(parse_url(glsr_get($request, 'url'), PHP_URL_PATH)),
150
+            'paged' => glsr_get( $urlQuery, glsr()->constant( 'PAGED_QUERY_VAR' ), 1 ),
151
+            'pagedUrl' => home_url( parse_url( glsr_get( $request, 'url' ), PHP_URL_PATH ) ),
152 152
             'pagination' => 'ajax',
153 153
             'schema' => false,
154 154
         ];
155
-        $atts = (array) json_decode(glsr_get($request, 'atts'));
156
-        $html = glsr(SiteReviews::class)->build(wp_parse_args($args, $atts));
157
-        return wp_send_json_success([
155
+        $atts = (array)json_decode( glsr_get( $request, 'atts' ) );
156
+        $html = glsr( SiteReviews::class )->build( wp_parse_args( $args, $atts ) );
157
+        return wp_send_json_success( [
158 158
             'pagination' => $html->getPagination(),
159 159
             'reviews' => $html->getReviews(),
160
-        ]);
160
+        ] );
161 161
     }
162 162
 
163 163
     /**
164 164
      * @return void
165 165
      */
166
-    public function routerTogglePinned(array $request)
166
+    public function routerTogglePinned( array $request )
167 167
     {
168
-        $isPinned = $this->execute(new TogglePinned($request));
169
-        wp_send_json_success([
170
-            'notices' => glsr(Notice::class)->get(),
168
+        $isPinned = $this->execute( new TogglePinned( $request ) );
169
+        wp_send_json_success( [
170
+            'notices' => glsr( Notice::class )->get(),
171 171
             'pinned' => $isPinned,
172
-        ]);
172
+        ] );
173 173
     }
174 174
 }
Please login to merge, or discard this patch.
plugin/Modules/Notice.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -13,41 +13,41 @@  discard block
 block discarded – undo
13 13
      * @param string|array|WP_Error $message
14 14
      * @return void
15 15
      */
16
-    public function add($type, $message, array $args = [])
16
+    public function add( $type, $message, array $args = [] )
17 17
     {
18
-        if (empty(array_filter([$message, $type]))) {
18
+        if( empty(array_filter( [$message, $type] )) ) {
19 19
             return;
20 20
         }
21 21
         $args['message'] = $message;
22 22
         $args['type'] = $type;
23
-        add_settings_error(Application::ID, '', json_encode($this->normalize($args)));
23
+        add_settings_error( Application::ID, '', json_encode( $this->normalize( $args ) ) );
24 24
     }
25 25
 
26 26
     /**
27 27
      * @param string|array|WP_Error $message
28 28
      * @return void
29 29
      */
30
-    public function addError($message, array $args = [])
30
+    public function addError( $message, array $args = [] )
31 31
     {
32
-        $this->add('error', $message, $args);
32
+        $this->add( 'error', $message, $args );
33 33
     }
34 34
 
35 35
     /**
36 36
      * @param string|array|WP_Error $message
37 37
      * @return void
38 38
      */
39
-    public function addSuccess($message, array $args = [])
39
+    public function addSuccess( $message, array $args = [] )
40 40
     {
41
-        $this->add('success', $message, $args);
41
+        $this->add( 'success', $message, $args );
42 42
     }
43 43
 
44 44
     /**
45 45
      * @param string|array|WP_Error $message
46 46
      * @return void
47 47
      */
48
-    public function addWarning($message, array $args = [])
48
+    public function addWarning( $message, array $args = [] )
49 49
     {
50
-        $this->add('warning', $message, $args);
50
+        $this->add( 'warning', $message, $args );
51 51
     }
52 52
 
53 53
     /**
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
     {
58 58
         global $wp_settings_errors;
59 59
         $wp_settings_errors = [];
60
-        delete_transient('settings_errors');
60
+        delete_transient( 'settings_errors' );
61 61
         return $this;
62 62
     }
63 63
 
@@ -66,39 +66,39 @@  discard block
 block discarded – undo
66 66
      */
67 67
     public function get()
68 68
     {
69
-        $notices = array_map('unserialize',
70
-            array_unique(array_map('serialize', get_settings_errors(Application::ID)))
69
+        $notices = array_map( 'unserialize',
70
+            array_unique( array_map( 'serialize', get_settings_errors( Application::ID ) ) )
71 71
         );
72
-        $notices = array_reduce($notices, function ($carry, $notice) {
73
-            return $carry.$this->buildNotice(json_decode($notice['message'], true));
72
+        $notices = array_reduce( $notices, function( $carry, $notice ) {
73
+            return $carry.$this->buildNotice( json_decode( $notice['message'], true ) );
74 74
         });
75
-        return apply_filters('site-reviews/notices', $notices);
75
+        return apply_filters( 'site-reviews/notices', $notices );
76 76
     }
77 77
 
78 78
     /**
79 79
      * @return string
80 80
      */
81
-    protected function buildNotice(array $args)
81
+    protected function buildNotice( array $args )
82 82
     {
83
-        $messages = array_reduce($args['messages'], function ($carry, $message) {
84
-            return $carry.glsr(Builder::class)->p($message);
83
+        $messages = array_reduce( $args['messages'], function( $carry, $message ) {
84
+            return $carry.glsr( Builder::class )->p( $message );
85 85
         });
86 86
         $class = 'notice notice-'.$args['type'];
87
-        if ($args['inline']) {
88
-            $class.= ' inline';
87
+        if( $args['inline'] ) {
88
+            $class .= ' inline';
89 89
         }
90
-        if ($args['dismissible']) {
91
-            $class.= ' is-dismissible';
90
+        if( $args['dismissible'] ) {
91
+            $class .= ' is-dismissible';
92 92
         }
93
-        return glsr(Builder::class)->div($messages, [
93
+        return glsr( Builder::class )->div( $messages, [
94 94
             'class' => $class,
95
-        ]);
95
+        ] );
96 96
     }
97 97
 
98 98
     /**
99 99
      * @return array
100 100
      */
101
-    protected function normalize(array $args)
101
+    protected function normalize( array $args )
102 102
     {
103 103
         $defaults = [
104 104
             'dismissible' => true,
@@ -106,13 +106,13 @@  discard block
 block discarded – undo
106 106
             'message' => '',
107 107
             'type' => '',
108 108
         ];
109
-        $args = shortcode_atts($defaults, $args);
110
-        if (!in_array($args['type'], ['error', 'warning', 'success'])) {
109
+        $args = shortcode_atts( $defaults, $args );
110
+        if( !in_array( $args['type'], ['error', 'warning', 'success'] ) ) {
111 111
             $args['type'] = 'success';
112 112
         }
113
-        $args['messages'] = is_wp_error($args['message'])
114
-            ? (array) $args['message']->get_error_message()
115
-            : (array) $args['message'];
113
+        $args['messages'] = is_wp_error( $args['message'] )
114
+            ? (array)$args['message']->get_error_message()
115
+            : (array)$args['message'];
116 116
         unset($args['message']);
117 117
         return $args;
118 118
     }
Please login to merge, or discard this patch.
plugin/Database.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
      * @param bool $single
18 18
      * @return mixed
19 19
      */
20
-    public function get($postId, $key, $single = true)
20
+    public function get( $postId, $key, $single = true )
21 21
     {
22
-        $key = glsr(Helper::class)->prefix('_', $key);
23
-        return get_post_meta(intval($postId), $key, $single);
22
+        $key = glsr( Helper::class )->prefix( '_', $key );
23
+        return get_post_meta( intval( $postId ), $key, $single );
24 24
     }
25 25
 
26 26
     /**
@@ -28,16 +28,16 @@  discard block
 block discarded – undo
28 28
      * @param string $assignedTo
29 29
      * @return void|WP_Post
30 30
      */
31
-    public function getAssignedToPost($postId, $assignedTo = '')
31
+    public function getAssignedToPost( $postId, $assignedTo = '' )
32 32
     {
33
-        if (empty($assignedTo)) {
34
-            $assignedTo = $this->get($postId, 'assigned_to');
33
+        if( empty($assignedTo) ) {
34
+            $assignedTo = $this->get( $postId, 'assigned_to' );
35 35
         }
36
-        if (empty($assignedTo)) {
36
+        if( empty($assignedTo) ) {
37 37
             return;
38 38
         }
39
-        $assignedPost = get_post($assignedTo);
40
-        if ($assignedPost instanceof WP_Post && $assignedPost->ID != $postId) {
39
+        $assignedPost = get_post( $assignedTo );
40
+        if( $assignedPost instanceof WP_Post && $assignedPost->ID != $postId ) {
41 41
             return $assignedPost;
42 42
         }
43 43
     }
@@ -47,25 +47,25 @@  discard block
 block discarded – undo
47 47
      * @param string $metaValue
48 48
      * @return array|int
49 49
      */
50
-    public function getReviewCount($metaKey = '', $metaValue = '')
50
+    public function getReviewCount( $metaKey = '', $metaValue = '' )
51 51
     {
52
-        if (!$metaKey) {
53
-            return (array) wp_count_posts(Application::POST_TYPE);
52
+        if( !$metaKey ) {
53
+            return (array)wp_count_posts( Application::POST_TYPE );
54 54
         }
55
-        $counts = glsr(Cache::class)->getReviewCountsFor($metaKey);
56
-        if (!$metaValue) {
55
+        $counts = glsr( Cache::class )->getReviewCountsFor( $metaKey );
56
+        if( !$metaValue ) {
57 57
             return $counts;
58 58
         }
59
-        return glsr_get($counts, $metaValue, 0);
59
+        return glsr_get( $counts, $metaValue, 0 );
60 60
     }
61 61
 
62 62
     /**
63 63
      * @param string $metaReviewType
64 64
      * @return array
65 65
      */
66
-    public function getReviewIdsByType($metaReviewType)
66
+    public function getReviewIdsByType( $metaReviewType )
67 67
     {
68
-        return glsr(SqlQueries::class)->getReviewIdsByType($metaReviewType);
68
+        return glsr( SqlQueries::class )->getReviewIdsByType( $metaReviewType );
69 69
     }
70 70
 
71 71
     /**
@@ -73,24 +73,24 @@  discard block
 block discarded – undo
73 73
      * @param string $status
74 74
      * @return array
75 75
      */
76
-    public function getReviewsMeta($key, $status = 'publish')
76
+    public function getReviewsMeta( $key, $status = 'publish' )
77 77
     {
78
-        if ('all' == $status || empty($status)) {
79
-            $status = get_post_stati(['exclude_from_search' => false]);
78
+        if( 'all' == $status || empty($status) ) {
79
+            $status = get_post_stati( ['exclude_from_search' => false] );
80 80
         }
81
-        return glsr(SqlQueries::class)->getReviewsMeta($key, $status);
81
+        return glsr( SqlQueries::class )->getReviewsMeta( $key, $status );
82 82
     }
83 83
 
84 84
     /**
85 85
      * @param string $field
86 86
      * @return array
87 87
      */
88
-    public function getTermIds(array $values, $field)
88
+    public function getTermIds( array $values, $field )
89 89
     {
90 90
         $termIds = [];
91
-        foreach ($values as $value) {
92
-            $term = get_term_by($field, $value, Application::TAXONOMY);
93
-            if (!isset($term->term_id)) {
91
+        foreach( $values as $value ) {
92
+            $term = get_term_by( $field, $value, Application::TAXONOMY );
93
+            if( !isset($term->term_id) ) {
94 94
                 continue;
95 95
             }
96 96
             $termIds[] = $term->term_id;
@@ -101,17 +101,17 @@  discard block
 block discarded – undo
101 101
     /**
102 102
      * @return array
103 103
      */
104
-    public function getTerms(array $args = [])
104
+    public function getTerms( array $args = [] )
105 105
     {
106
-        $args = wp_parse_args($args, [
106
+        $args = wp_parse_args( $args, [
107 107
             'count' => false,
108 108
             'fields' => 'id=>name',
109 109
             'hide_empty' => false,
110 110
             'taxonomy' => Application::TAXONOMY,
111
-        ]);
112
-        $terms = get_terms($args);
113
-        if (is_wp_error($terms)) {
114
-            glsr_log()->error($terms->get_error_message());
111
+        ] );
112
+        $terms = get_terms( $args );
113
+        if( is_wp_error( $terms ) ) {
114
+            glsr_log()->error( $terms->get_error_message() );
115 115
             return [];
116 116
         }
117 117
         return $terms;
@@ -121,36 +121,36 @@  discard block
 block discarded – undo
121 121
      * @param string $searchTerm
122 122
      * @return void|string
123 123
      */
124
-    public function searchPosts($searchTerm)
124
+    public function searchPosts( $searchTerm )
125 125
     {
126 126
         $args = [
127 127
             'post_status' => 'publish',
128 128
             'post_type' => 'any',
129 129
         ];
130
-        if (is_numeric($searchTerm)) {
130
+        if( is_numeric( $searchTerm ) ) {
131 131
             $args['post__in'] = [$searchTerm];
132 132
         } else {
133 133
             $args['orderby'] = 'relevance';
134 134
             $args['posts_per_page'] = 10;
135 135
             $args['s'] = $searchTerm;
136 136
         }
137
-        $queryBuilder = glsr(QueryBuilder::class);
138
-        add_filter('posts_search', [$queryBuilder, 'filterSearchByTitle'], 500, 2);
139
-        $search = new WP_Query($args);
140
-        remove_filter('posts_search', [$queryBuilder, 'filterSearchByTitle'], 500);
141
-        if (!$search->have_posts()) {
137
+        $queryBuilder = glsr( QueryBuilder::class );
138
+        add_filter( 'posts_search', [$queryBuilder, 'filterSearchByTitle'], 500, 2 );
139
+        $search = new WP_Query( $args );
140
+        remove_filter( 'posts_search', [$queryBuilder, 'filterSearchByTitle'], 500 );
141
+        if( !$search->have_posts() ) {
142 142
             return;
143 143
         }
144 144
         $results = '';
145
-        while ($search->have_posts()) {
145
+        while( $search->have_posts() ) {
146 146
             $search->the_post();
147 147
             ob_start();
148
-            glsr()->render('partials/editor/search-result', [
148
+            glsr()->render( 'partials/editor/search-result', [
149 149
                 'ID' => get_the_ID(),
150
-                'permalink' => esc_url((string) get_permalink()),
151
-                'title' => esc_attr(get_the_title()),
152
-            ]);
153
-            $results.= ob_get_clean();
150
+                'permalink' => esc_url( (string)get_permalink() ),
151
+                'title' => esc_attr( get_the_title() ),
152
+            ] );
153
+            $results .= ob_get_clean();
154 154
         }
155 155
         wp_reset_postdata();
156 156
         return $results;
@@ -162,10 +162,10 @@  discard block
 block discarded – undo
162 162
      * @param mixed $value
163 163
      * @return int|bool
164 164
      */
165
-    public function set($postId, $key, $value)
165
+    public function set( $postId, $key, $value )
166 166
     {
167
-        $key = glsr(Helper::class)->prefix('_', $key);
168
-        return update_post_meta($postId, $key, $value);
167
+        $key = glsr( Helper::class )->prefix( '_', $key );
168
+        return update_post_meta( $postId, $key, $value );
169 169
     }
170 170
 
171 171
     /**
@@ -174,8 +174,8 @@  discard block
 block discarded – undo
174 174
      * @param mixed $value
175 175
      * @return int|bool
176 176
      */
177
-    public function update($postId, $key, $value)
177
+    public function update( $postId, $key, $value )
178 178
     {
179
-        return $this->set($postId, $key, $value);
179
+        return $this->set( $postId, $key, $value );
180 180
     }
181 181
 }
Please login to merge, or discard this patch.
plugin/Controllers/NoticeController.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -17,19 +17,19 @@  discard block
 block discarded – undo
17 17
     public function filterAdminNotices()
18 18
     {
19 19
         $screen = glsr_current_screen();
20
-        $this->renderRebusifyNotice($screen->post_type);
21
-        $this->renderAddonsNotice($screen->id);
20
+        $this->renderRebusifyNotice( $screen->post_type );
21
+        $this->renderAddonsNotice( $screen->id );
22 22
     }
23 23
 
24 24
     /**
25 25
      * @return void
26 26
      */
27
-    public function routerDismissNotice(array $request)
27
+    public function routerDismissNotice( array $request )
28 28
     {
29
-        $key = glsr_get($request, 'notice');
30
-        $method = glsr(Helper::class)->buildMethodName($key, 'dismiss');
31
-        if (method_exists($this, $method)) {
32
-            call_user_func([$this, $method], $key);
29
+        $key = glsr_get( $request, 'notice' );
30
+        $method = glsr( Helper::class )->buildMethodName( $key, 'dismiss' );
31
+        if( method_exists( $this, $method ) ) {
32
+            call_user_func( [$this, $method], $key );
33 33
         }
34 34
     }
35 35
 
@@ -37,9 +37,9 @@  discard block
 block discarded – undo
37 37
      * @param string $key
38 38
      * @return void
39 39
      */
40
-    protected function dismissRebusify($key)
40
+    protected function dismissRebusify( $key )
41 41
     {
42
-        $this->setUserMeta($key, glsr()->version('major'));
42
+        $this->setUserMeta( $key, glsr()->version( 'major' ) );
43 43
     }
44 44
 
45 45
     /**
@@ -47,20 +47,20 @@  discard block
 block discarded – undo
47 47
      * @param mixed $fallback
48 48
      * @return mixed
49 49
      */
50
-    protected function getUserMeta($key, $fallback)
50
+    protected function getUserMeta( $key, $fallback )
51 51
     {
52
-        $meta = get_user_meta(get_current_user_id(), static::USER_META_KEY, true);
53
-        return glsr_get($meta, $key, $fallback);
52
+        $meta = get_user_meta( get_current_user_id(), static::USER_META_KEY, true );
53
+        return glsr_get( $meta, $key, $fallback );
54 54
     }
55 55
 
56 56
     /**
57 57
      * @param string $screenId
58 58
      * @return void
59 59
      */
60
-    protected function renderAddonsNotice($screenId)
60
+    protected function renderAddonsNotice( $screenId )
61 61
     {
62
-        if (Application::POST_TYPE.'_page_addons' == $screenId) {
63
-            echo glsr()->render('partials/notices/addons');
62
+        if( Application::POST_TYPE.'_page_addons' == $screenId ) {
63
+            echo glsr()->render( 'partials/notices/addons' );
64 64
         }
65 65
     }
66 66
 
@@ -68,12 +68,12 @@  discard block
 block discarded – undo
68 68
      * @param string $screenPostType
69 69
      * @return void
70 70
      */
71
-    protected function renderRebusifyNotice($screenPostType)
71
+    protected function renderRebusifyNotice( $screenPostType )
72 72
     {
73
-        if (Application::POST_TYPE == $screenPostType
74
-            && version_compare(glsr()->version('major'), $this->getUserMeta('rebusify', 0), '>')
75
-            && !glsr(OptionManager::class)->getBool('settings.general.rebusify')) {
76
-            echo glsr()->render('partials/notices/rebusify');
73
+        if( Application::POST_TYPE == $screenPostType
74
+            && version_compare( glsr()->version( 'major' ), $this->getUserMeta( 'rebusify', 0 ), '>' )
75
+            && !glsr( OptionManager::class )->getBool( 'settings.general.rebusify' ) ) {
76
+            echo glsr()->render( 'partials/notices/rebusify' );
77 77
         }
78 78
     }
79 79
 
@@ -82,12 +82,12 @@  discard block
 block discarded – undo
82 82
      * @param mixed $fallback
83 83
      * @return mixed
84 84
      */
85
-    protected function setUserMeta($key, $value)
85
+    protected function setUserMeta( $key, $value )
86 86
     {
87 87
         $userId = get_current_user_id();
88
-        $meta = (array) get_user_meta($userId, static::USER_META_KEY, true);
89
-        $meta = array_filter(wp_parse_args($meta, []));
88
+        $meta = (array)get_user_meta( $userId, static::USER_META_KEY, true );
89
+        $meta = array_filter( wp_parse_args( $meta, [] ) );
90 90
         $meta[$key] = $value;
91
-        update_user_meta($userId, static::USER_META_KEY, $meta);
91
+        update_user_meta( $userId, static::USER_META_KEY, $meta );
92 92
     }
93 93
 }
Please login to merge, or discard this patch.