@@ -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 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | public function routeAjaxRequest() |
30 | 30 | { |
31 | 31 | $request = $this->getRequest(); |
32 | - if( !isset( $request['action'] )) { |
|
32 | + if( !isset($request['action']) ) { |
|
33 | 33 | glsr_log()->error( 'The AJAX request must include an action' )->info( $request ); |
34 | 34 | wp_die(); |
35 | 35 | } |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | { |
47 | 47 | if( is_admin() )return; |
48 | 48 | $request = $this->getRequest(); |
49 | - if( !$this->isValidPostRequest( $request ))return; |
|
50 | - if( !$this->isValidPublicNonce( $request ))return; |
|
49 | + if( !$this->isValidPostRequest( $request ) )return; |
|
50 | + if( !$this->isValidPublicNonce( $request ) )return; |
|
51 | 51 | $this->routeRequest( 'public', $request['action'], $request ); |
52 | 52 | } |
53 | 53 | |
@@ -67,11 +67,11 @@ discard block |
||
67 | 67 | protected function checkAjaxNonce( array $request ) |
68 | 68 | { |
69 | 69 | if( !is_user_logged_in() )return; |
70 | - if( !isset( $request['nonce'] )) { |
|
70 | + if( !isset($request['nonce']) ) { |
|
71 | 71 | glsr_log()->error( 'The AJAX request must include a nonce' )->info( $request ); |
72 | 72 | wp_die(); |
73 | 73 | } |
74 | - if( !wp_verify_nonce( $request['nonce'], $request['action'] )) { |
|
74 | + if( !wp_verify_nonce( $request['nonce'], $request['action'] ) ) { |
|
75 | 75 | glsr_log()->error( 'Nonce check failed for ajax request' )->info( $request ); |
76 | 76 | wp_die( -1, 403 ); |
77 | 77 | } |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | { |
85 | 85 | foreach( ['request', Application::ID] as $key ) { |
86 | 86 | $request = glsr( Helper::class )->filterInputArray( $key ); |
87 | - if( !empty( $request ))break; |
|
87 | + if( !empty($request) )break; |
|
88 | 88 | } |
89 | 89 | return $this->normalizeRequest( $request ); |
90 | 90 | } |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | */ |
95 | 95 | protected function isValidPostRequest( array $request = [] ) |
96 | 96 | { |
97 | - return !empty( $request['action'] ) && empty( glsr( Helper::class )->filterInput( 'ajax_request' )); |
|
97 | + return !empty($request['action']) && empty(glsr( Helper::class )->filterInput( 'ajax_request' )); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | protected function isValidPublicNonce( array $request ) |
104 | 104 | { |
105 | - if( is_user_logged_in() && !wp_verify_nonce( $request['_wpnonce'], $request['action'] )) { |
|
105 | + if( is_user_logged_in() && !wp_verify_nonce( $request['_wpnonce'], $request['action'] ) ) { |
|
106 | 106 | glsr_log()->error( 'Nonce check failed for public request' )->info( $request ); |
107 | 107 | return false; |
108 | 108 | } |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | */ |
115 | 115 | protected function normalizeRequest( array $request ) |
116 | 116 | { |
117 | - if( isset( $request[Application::ID]['action'] )) { |
|
117 | + if( isset($request[Application::ID]['action']) ) { |
|
118 | 118 | $request = $request[Application::ID]; |
119 | 119 | } |
120 | 120 | if( glsr( Helper::class )->filterInput( 'action', $request ) == 'submit-review' ) { |
@@ -131,11 +131,11 @@ discard block |
||
131 | 131 | protected function routeRequest( $type, $action, array $request = [] ) |
132 | 132 | { |
133 | 133 | $actionHook = 'site-reviews/route/'.$type.'/request'; |
134 | - $controller = glsr( glsr( Helper::class )->buildClassName( $type.'-controller', 'Controllers' )); |
|
134 | + $controller = glsr( glsr( Helper::class )->buildClassName( $type.'-controller', 'Controllers' ) ); |
|
135 | 135 | $method = glsr( Helper::class )->buildMethodName( $action, 'router' ); |
136 | 136 | $request = apply_filters( 'site-reviews/route/request', $request, $action, $type ); |
137 | 137 | do_action( $actionHook, $action, $request ); |
138 | - if( is_callable( [$controller, $method] )) { |
|
138 | + if( is_callable( [$controller, $method] ) ) { |
|
139 | 139 | call_user_func( [$controller, $method], $request ); |
140 | 140 | return; |
141 | 141 | } |
@@ -16,7 +16,9 @@ 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 )) { |
|
20 | + return; |
|
21 | + } |
|
20 | 22 | check_admin_referer( $request['action'] ); |
21 | 23 | $this->routeRequest( 'admin', $request['action'], $request ); |
22 | 24 | } |
@@ -44,10 +46,16 @@ discard block |
||
44 | 46 | */ |
45 | 47 | public function routePublicPostRequest() |
46 | 48 | { |
47 | - if( is_admin() )return; |
|
49 | + if( is_admin() ) { |
|
50 | + return; |
|
51 | + } |
|
48 | 52 | $request = $this->getRequest(); |
49 | - if( !$this->isValidPostRequest( $request ))return; |
|
50 | - if( !$this->isValidPublicNonce( $request ))return; |
|
53 | + if( !$this->isValidPostRequest( $request )) { |
|
54 | + return; |
|
55 | + } |
|
56 | + if( !$this->isValidPublicNonce( $request )) { |
|
57 | + return; |
|
58 | + } |
|
51 | 59 | $this->routeRequest( 'public', $request['action'], $request ); |
52 | 60 | } |
53 | 61 | |
@@ -57,7 +65,9 @@ discard block |
||
57 | 65 | public function routeWebhookRequest() |
58 | 66 | { |
59 | 67 | $request = filter_input( INPUT_GET, Application::PREFIX.'hook' ); |
60 | - if( !$request )return; |
|
68 | + if( !$request ) { |
|
69 | + return; |
|
70 | + } |
|
61 | 71 | // @todo manage webhook here |
62 | 72 | } |
63 | 73 | |
@@ -66,7 +76,9 @@ discard block |
||
66 | 76 | */ |
67 | 77 | protected function checkAjaxNonce( array $request ) |
68 | 78 | { |
69 | - if( !is_user_logged_in() )return; |
|
79 | + if( !is_user_logged_in() ) { |
|
80 | + return; |
|
81 | + } |
|
70 | 82 | if( !isset( $request['nonce'] )) { |
71 | 83 | glsr_log()->error( 'The AJAX request must include a nonce' )->info( $request ); |
72 | 84 | wp_die(); |
@@ -84,7 +96,9 @@ discard block |
||
84 | 96 | { |
85 | 97 | foreach( ['request', Application::ID] as $key ) { |
86 | 98 | $request = glsr( Helper::class )->filterInputArray( $key ); |
87 | - if( !empty( $request ))break; |
|
99 | + if( !empty( $request )) { |
|
100 | + break; |
|
101 | + } |
|
88 | 102 | } |
89 | 103 | return $this->normalizeRequest( $request ); |
90 | 104 | } |
@@ -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 | /** |
@@ -186,17 +186,17 @@ discard block |
||
186 | 186 | { |
187 | 187 | $file = $_FILES['import-file']; |
188 | 188 | if( $file['error'] !== UPLOAD_ERR_OK ) { |
189 | - return glsr( Notice::class )->addError( $this->getUploadError( $file['error'] )); |
|
189 | + return glsr( Notice::class )->addError( $this->getUploadError( $file['error'] ) ); |
|
190 | 190 | } |
191 | - if( $file['type'] !== 'application/json' || !glsr( Helper::class )->endsWith( '.json', $file['name'] )) { |
|
192 | - return glsr( Notice::class )->addError( __( 'Please use a valid Site Reviews settings file.', 'site-reviews' )); |
|
191 | + if( $file['type'] !== 'application/json' || !glsr( Helper::class )->endsWith( '.json', $file['name'] ) ) { |
|
192 | + return glsr( Notice::class )->addError( __( 'Please use a valid Site Reviews settings file.', 'site-reviews' ) ); |
|
193 | 193 | } |
194 | 194 | $settings = json_decode( file_get_contents( $file['tmp_name'] ), true ); |
195 | - if( empty( $settings )) { |
|
196 | - return glsr( Notice::class )->addWarning( __( 'There were no settings found to import.', 'site-reviews' )); |
|
195 | + if( empty($settings) ) { |
|
196 | + return glsr( Notice::class )->addWarning( __( 'There were no settings found to import.', 'site-reviews' ) ); |
|
197 | 197 | } |
198 | - glsr( OptionManager::class )->set( glsr( OptionManager::class )->normalize( $settings )); |
|
199 | - glsr( Notice::class )->addSuccess( __( 'Settings imported.', 'site-reviews' )); |
|
198 | + glsr( OptionManager::class )->set( glsr( OptionManager::class )->normalize( $settings ) ); |
|
199 | + glsr( Notice::class )->addSuccess( __( 'Settings imported.', 'site-reviews' ) ); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | /** |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | UPLOAD_ERR_CANT_WRITE => __( 'Failed to write file to disk.', 'site-reviews' ), |
215 | 215 | UPLOAD_ERR_EXTENSION => __( 'A PHP extension stopped the file upload.', 'site-reviews' ), |
216 | 216 | ]; |
217 | - return !isset( $errors[$errorCode] ) |
|
217 | + return !isset($errors[$errorCode]) |
|
218 | 218 | ? __( 'Unknown upload error.', 'site-reviews' ) |
219 | 219 | : $errors[$errorCode]; |
220 | 220 | } |