@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | public function routeAdminPostRequest() |
17 | 17 | { |
18 | 18 | $request = $this->getRequest(); |
19 | - if( !$this->isValidPostRequest( $request ))return; |
|
19 | + if( !$this->isValidPostRequest( $request ) )return; |
|
20 | 20 | check_admin_referer( $request['action'] ); |
21 | 21 | $this->routeRequest( 'admin', $request['action'], $request ); |
22 | 22 | } |
@@ -40,8 +40,8 @@ discard block |
||
40 | 40 | { |
41 | 41 | if( is_admin() )return; |
42 | 42 | $request = $this->getRequest(); |
43 | - if( !$this->isValidPostRequest( $request ))return; |
|
44 | - if( !$this->isValidPublicNonce( $request ))return; |
|
43 | + if( !$this->isValidPostRequest( $request ) )return; |
|
44 | + if( !$this->isValidPublicNonce( $request ) )return; |
|
45 | 45 | $this->routeRequest( 'public', $request['action'], $request ); |
46 | 46 | } |
47 | 47 | |
@@ -51,10 +51,10 @@ discard block |
||
51 | 51 | protected function checkAjaxNonce( array $request ) |
52 | 52 | { |
53 | 53 | if( !is_user_logged_in() )return; |
54 | - if( !isset( $request['nonce'] )) { |
|
54 | + if( !isset($request['nonce']) ) { |
|
55 | 55 | $this->sendAjaxError( 'The request is missing a nonce', $request ); |
56 | 56 | } |
57 | - if( !wp_verify_nonce( $request['nonce'], $request['action'] )) { |
|
57 | + if( !wp_verify_nonce( $request['nonce'], $request['action'] ) ) { |
|
58 | 58 | $this->sendAjaxError( 'The request failed the nonce check', $request, 403 ); |
59 | 59 | } |
60 | 60 | } |
@@ -64,10 +64,10 @@ discard block |
||
64 | 64 | */ |
65 | 65 | protected function checkAjaxRequest( array $request ) |
66 | 66 | { |
67 | - if( !isset( $request['action'] )) { |
|
67 | + if( !isset($request['action']) ) { |
|
68 | 68 | $this->sendAjaxError( 'The request must include an action', $request ); |
69 | 69 | } |
70 | - if( empty( $request['ajax_request'] )) { |
|
70 | + if( empty($request['ajax_request']) ) { |
|
71 | 71 | $this->sendAjaxError( 'The request is invalid', $request ); |
72 | 72 | } |
73 | 73 | } |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | return glsr( Helper::class )->filterInputArray( Application::ID ); |
85 | 85 | } |
86 | 86 | $request = glsr( Helper::class )->filterInputArray( 'request' ); |
87 | - if( empty( $request )) { |
|
87 | + if( empty($request) ) { |
|
88 | 88 | $request = glsr( Helper::class )->filterInputArray( Application::ID ); |
89 | 89 | } |
90 | 90 | return $this->normalizeRequest( $request ); |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | */ |
96 | 96 | protected function isValidPostRequest( array $request = [] ) |
97 | 97 | { |
98 | - return !empty( $request['action'] ) && empty( $request['ajax_request'] ); |
|
98 | + return !empty($request['action']) && empty($request['ajax_request']); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | */ |
104 | 104 | protected function isValidPublicNonce( array $request ) |
105 | 105 | { |
106 | - if( is_user_logged_in() && !wp_verify_nonce( $request['nonce'], $request['action'] )) { |
|
106 | + if( is_user_logged_in() && !wp_verify_nonce( $request['nonce'], $request['action'] ) ) { |
|
107 | 107 | glsr_log()->error( 'Nonce check failed for public request' )->info( $request ); |
108 | 108 | return false; |
109 | 109 | } |
@@ -132,11 +132,11 @@ discard block |
||
132 | 132 | protected function routeRequest( $type, $action, array $request = [] ) |
133 | 133 | { |
134 | 134 | $actionHook = 'site-reviews/route/'.$type.'/request'; |
135 | - $controller = glsr( glsr( Helper::class )->buildClassName( $type.'-controller', 'Controllers' )); |
|
135 | + $controller = glsr( glsr( Helper::class )->buildClassName( $type.'-controller', 'Controllers' ) ); |
|
136 | 136 | $method = glsr( Helper::class )->buildMethodName( $action, 'router' ); |
137 | 137 | $request = apply_filters( 'site-reviews/route/request', $request, $action, $type ); |
138 | 138 | do_action( $actionHook, $action, $request ); |
139 | - if( is_callable( [$controller, $method] )) { |
|
139 | + if( is_callable( [$controller, $method] ) ) { |
|
140 | 140 | call_user_func( [$controller, $method], $request ); |
141 | 141 | return; |
142 | 142 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | protected function sendAjaxError( $error, array $request, $statusCode = 400 ) |
154 | 154 | { |
155 | 155 | glsr_log()->error( $error )->info( $request ); |
156 | - wp_send_json_error([ |
|
156 | + wp_send_json_error( [ |
|
157 | 157 | 'message' => __( 'The form could not be submitted. Please notify the site administrator.', 'site-reviews' ), |
158 | 158 | 'error' => $error, |
159 | 159 | ], $statusCode ); |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | */ |
23 | 23 | public function routerChangeReviewStatus( array $request ) |
24 | 24 | { |
25 | - wp_send_json_success( $this->execute( new ChangeStatus( $request ))); |
|
25 | + wp_send_json_success( $this->execute( new ChangeStatus( $request ) ) ); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | /** |
@@ -31,10 +31,10 @@ discard block |
||
31 | 31 | public function routerClearConsole() |
32 | 32 | { |
33 | 33 | glsr( AdminController::class )->routerClearConsole(); |
34 | - wp_send_json_success([ |
|
34 | + wp_send_json_success( [ |
|
35 | 35 | 'console' => glsr( Console::class )->get(), |
36 | 36 | 'notices' => glsr( Notice::class )->get(), |
37 | - ]); |
|
37 | + ] ); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | public function routerCountReviews() |
44 | 44 | { |
45 | 45 | glsr( AdminController::class )->routerCountReviews(); |
46 | - wp_send_json_success([ |
|
46 | + wp_send_json_success( [ |
|
47 | 47 | 'notices' => glsr( Notice::class )->get(), |
48 | - ]); |
|
48 | + ] ); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | { |
56 | 56 | $shortcode = $request['shortcode']; |
57 | 57 | $response = false; |
58 | - if( array_key_exists( $shortcode, glsr()->mceShortcodes )) { |
|
58 | + if( array_key_exists( $shortcode, glsr()->mceShortcodes ) ) { |
|
59 | 59 | $data = glsr()->mceShortcodes[$shortcode]; |
60 | - if( !empty( $data['errors'] )) { |
|
60 | + if( !empty($data['errors']) ) { |
|
61 | 61 | $data['btn_okay'] = [esc_html__( 'Okay', 'site-reviews' )]; |
62 | 62 | } |
63 | 63 | $response = [ |
@@ -77,10 +77,10 @@ discard block |
||
77 | 77 | public function routerSearchPosts( array $request ) |
78 | 78 | { |
79 | 79 | $results = glsr( Database::class )->searchPosts( $request['search'] ); |
80 | - wp_send_json_success([ |
|
80 | + wp_send_json_success( [ |
|
81 | 81 | 'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>', |
82 | 82 | 'items' => $results, |
83 | - ]); |
|
83 | + ] ); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | */ |
89 | 89 | public function routerSearchTranslations( array $request ) |
90 | 90 | { |
91 | - if( empty( $request['exclude'] )) { |
|
91 | + if( empty($request['exclude']) ) { |
|
92 | 92 | $request['exclude'] = []; |
93 | 93 | } |
94 | 94 | $results = glsr( Translator::class ) |
@@ -96,10 +96,10 @@ discard block |
||
96 | 96 | ->exclude() |
97 | 97 | ->exclude( $request['exclude'] ) |
98 | 98 | ->renderResults(); |
99 | - wp_send_json_success([ |
|
99 | + wp_send_json_success( [ |
|
100 | 100 | 'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>', |
101 | 101 | 'items' => $results, |
102 | - ]); |
|
102 | + ] ); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | 'message' => glsr( Session::class )->get( $request['form_id'].'message', '', true ), |
114 | 114 | 'recaptcha' => glsr( Session::class )->get( $request['form_id'].'recaptcha', false, true ), |
115 | 115 | ]; |
116 | - if( !wp_validate_boolean( $data['errors'] )) { |
|
116 | + if( !wp_validate_boolean( $data['errors'] ) ) { |
|
117 | 117 | wp_send_json_success( $data ); |
118 | 118 | } |
119 | 119 | wp_send_json_error( $data ); |
@@ -124,10 +124,10 @@ discard block |
||
124 | 124 | */ |
125 | 125 | public function routerTogglePinned( array $request ) |
126 | 126 | { |
127 | - $isPinned = $this->execute( new TogglePinned( $request )); |
|
128 | - wp_send_json_success([ |
|
127 | + $isPinned = $this->execute( new TogglePinned( $request ) ); |
|
128 | + wp_send_json_success( [ |
|
129 | 129 | 'notices' => glsr( Notice::class )->get(), |
130 | 130 | 'pinned' => $isPinned, |
131 | - ]); |
|
131 | + ] ); |
|
132 | 132 | } |
133 | 133 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public function enqueueAssets() |
25 | 25 | { |
26 | - $command = new EnqueueAdminAssets([ |
|
26 | + $command = new EnqueueAdminAssets( [ |
|
27 | 27 | 'pointers' => [[ |
28 | 28 | 'content' => __( 'You can pin exceptional reviews so that they are always shown first.', 'site-reviews' ), |
29 | 29 | 'id' => 'glsr-pointer-pinned', |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | 'target' => '#misc-pub-pinned', |
36 | 36 | 'title' => __( 'Pin Your Reviews', 'site-reviews' ), |
37 | 37 | ]], |
38 | - ]); |
|
38 | + ] ); |
|
39 | 39 | $this->execute( $command ); |
40 | 40 | } |
41 | 41 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | { |
48 | 48 | $links['settings'] = glsr( Builder::class )->a( __( 'Settings', 'site-reviews' ), [ |
49 | 49 | 'href' => admin_url( 'edit.php?post_type='.Application::POST_TYPE.'&page=settings' ), |
50 | - ]); |
|
50 | + ] ); |
|
51 | 51 | return $links; |
52 | 52 | } |
53 | 53 | |
@@ -58,19 +58,19 @@ discard block |
||
58 | 58 | public function filterDashboardGlanceItems( array $items ) |
59 | 59 | { |
60 | 60 | $postCount = wp_count_posts( Application::POST_TYPE ); |
61 | - if( empty( $postCount->publish )) { |
|
61 | + if( empty($postCount->publish) ) { |
|
62 | 62 | return $items; |
63 | 63 | } |
64 | 64 | $text = _n( '%s Review', '%s Reviews', $postCount->publish, 'site-reviews' ); |
65 | - $text = sprintf( $text, number_format_i18n( $postCount->publish )); |
|
65 | + $text = sprintf( $text, number_format_i18n( $postCount->publish ) ); |
|
66 | 66 | $items[] = current_user_can( get_post_type_object( Application::POST_TYPE )->cap->edit_posts ) |
67 | 67 | ? glsr( Builder::class )->a( $text, [ |
68 | 68 | 'class' => 'glsr-review-count', |
69 | 69 | 'href' => 'edit.php?post_type='.Application::POST_TYPE, |
70 | - ]) |
|
70 | + ] ) |
|
71 | 71 | : glsr( Builder::class )->span( $text, [ |
72 | 72 | 'class' => 'glsr-review-count', |
73 | - ]); |
|
73 | + ] ); |
|
74 | 74 | return $items; |
75 | 75 | } |
76 | 76 | |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | public function filterTinymcePlugins( array $plugins ) |
82 | 82 | { |
83 | 83 | if( user_can_richedit() |
84 | - && ( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ))) { |
|
84 | + && (current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' )) ) { |
|
85 | 85 | $plugins['glsr_shortcode'] = glsr()->url( 'assets/scripts/mce-plugin.js' ); |
86 | 86 | } |
87 | 87 | return $plugins; |
@@ -93,11 +93,11 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function registerShortcodeButtons() |
95 | 95 | { |
96 | - $command = new RegisterShortcodeButtons([ |
|
96 | + $command = new RegisterShortcodeButtons( [ |
|
97 | 97 | 'site_reviews' => esc_html__( 'Recent Reviews', 'site-reviews' ), |
98 | 98 | 'site_reviews_form' => esc_html__( 'Submit a Review', 'site-reviews' ), |
99 | 99 | 'site_reviews_summary' => esc_html__( 'Summary of Reviews', 'site-reviews' ), |
100 | - ]); |
|
100 | + ] ); |
|
101 | 101 | $this->execute( $command ); |
102 | 102 | } |
103 | 103 | |
@@ -107,10 +107,10 @@ discard block |
||
107 | 107 | */ |
108 | 108 | public function renderReviewEditor( WP_Post $post ) |
109 | 109 | { |
110 | - if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return; |
|
110 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ) )return; |
|
111 | 111 | glsr()->render( 'partials/editor/review', [ |
112 | 112 | 'post' => $post, |
113 | - ]); |
|
113 | + ] ); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
@@ -119,13 +119,13 @@ discard block |
||
119 | 119 | */ |
120 | 120 | public function renderReviewNotice( WP_Post $post ) |
121 | 121 | { |
122 | - if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return; |
|
123 | - glsr( Notice::class )->addWarning( __( 'This review is read-only.', 'site-reviews' )); |
|
122 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ) )return; |
|
123 | + glsr( Notice::class )->addWarning( __( 'This review is read-only.', 'site-reviews' ) ); |
|
124 | 124 | glsr( Html::class )->renderTemplate( 'partials/editor/notice', [ |
125 | 125 | 'context' => [ |
126 | 126 | 'notices' => glsr( Notice::class )->get(), |
127 | 127 | ], |
128 | - ]); |
|
128 | + ] ); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -137,13 +137,13 @@ discard block |
||
137 | 137 | if( glsr_current_screen()->base != 'post' )return; |
138 | 138 | $shortcodes = []; |
139 | 139 | foreach( glsr()->mceShortcodes as $shortcode => $values ) { |
140 | - if( !apply_filters( sanitize_title( $shortcode ).'_condition', true ))continue; |
|
140 | + if( !apply_filters( sanitize_title( $shortcode ).'_condition', true ) )continue; |
|
141 | 141 | $shortcodes[$shortcode] = $values; |
142 | 142 | } |
143 | - if( empty( $shortcodes ))return; |
|
143 | + if( empty($shortcodes) )return; |
|
144 | 144 | glsr()->render( 'partials/editor/tinymce', [ |
145 | 145 | 'shortcodes' => $shortcodes, |
146 | - ]); |
|
146 | + ] ); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | public function routerClearConsole() |
153 | 153 | { |
154 | 154 | glsr( Console::class )->clear(); |
155 | - glsr( Notice::class )->addSuccess( __( 'Console cleared.', 'site-reviews' )); |
|
155 | + glsr( Notice::class )->addSuccess( __( 'Console cleared.', 'site-reviews' ) ); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | /** |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | public function routerCountReviews() |
162 | 162 | { |
163 | 163 | // @todo calculate the review counts here |
164 | - glsr( Notice::class )->addSuccess( __( 'Recalculated review counts.', 'site-reviews' )); |
|
164 | + glsr( Notice::class )->addSuccess( __( 'Recalculated review counts.', 'site-reviews' ) ); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -195,17 +195,17 @@ discard block |
||
195 | 195 | { |
196 | 196 | $file = $_FILES['import-file']; |
197 | 197 | if( $file['error'] !== UPLOAD_ERR_OK ) { |
198 | - return glsr( Notice::class )->addError( $this->getUploadError( $file['error'] )); |
|
198 | + return glsr( Notice::class )->addError( $this->getUploadError( $file['error'] ) ); |
|
199 | 199 | } |
200 | - if( $file['type'] !== 'application/json' || !glsr( Helper::class )->endsWith( '.json', $file['name'] )) { |
|
201 | - return glsr( Notice::class )->addError( __( 'Please use a valid Site Reviews settings file.', 'site-reviews' )); |
|
200 | + if( $file['type'] !== 'application/json' || !glsr( Helper::class )->endsWith( '.json', $file['name'] ) ) { |
|
201 | + return glsr( Notice::class )->addError( __( 'Please use a valid Site Reviews settings file.', 'site-reviews' ) ); |
|
202 | 202 | } |
203 | 203 | $settings = json_decode( file_get_contents( $file['tmp_name'] ), true ); |
204 | - if( empty( $settings )) { |
|
205 | - return glsr( Notice::class )->addWarning( __( 'There were no settings found to import.', 'site-reviews' )); |
|
204 | + if( empty($settings) ) { |
|
205 | + return glsr( Notice::class )->addWarning( __( 'There were no settings found to import.', 'site-reviews' ) ); |
|
206 | 206 | } |
207 | - glsr( OptionManager::class )->set( glsr( OptionManager::class )->normalize( $settings )); |
|
208 | - glsr( Notice::class )->addSuccess( __( 'Settings imported.', 'site-reviews' )); |
|
207 | + glsr( OptionManager::class )->set( glsr( OptionManager::class )->normalize( $settings ) ); |
|
208 | + glsr( Notice::class )->addSuccess( __( 'Settings imported.', 'site-reviews' ) ); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | /** |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | UPLOAD_ERR_CANT_WRITE => __( 'Failed to write file to disk.', 'site-reviews' ), |
224 | 224 | UPLOAD_ERR_EXTENSION => __( 'A PHP extension stopped the file upload.', 'site-reviews' ), |
225 | 225 | ]; |
226 | - return !isset( $errors[$errorCode] ) |
|
226 | + return !isset($errors[$errorCode]) |
|
227 | 227 | ? __( 'Unknown upload error.', 'site-reviews' ) |
228 | 228 | : $errors[$errorCode]; |
229 | 229 | } |
@@ -16,7 +16,9 @@ |
||
16 | 16 | natsort( $routines ); |
17 | 17 | array_walk( $routines, function( $routine ) { |
18 | 18 | $version = str_replace( strtolower( __CLASS__ ).'_', '', $routine ); |
19 | - if( version_compare( glsr()->version, $version, '>=' ))return; |
|
19 | + if( version_compare( glsr()->version, $version, '>=' )) { |
|
20 | + return; |
|
21 | + } |
|
20 | 22 | call_user_func( [$this, $routine] ); |
21 | 23 | }); |
22 | 24 | $this->updateVersion(); |