@@ -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 | $this->checkAdminNonce( $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 | |
@@ -81,11 +81,11 @@ discard block |
||
81 | 81 | protected function checkAjaxNonce( array $request ) |
82 | 82 | { |
83 | 83 | if( !is_user_logged_in() )return; |
84 | - if( !isset( $request['nonce'] )) { |
|
84 | + if( !isset($request['nonce']) ) { |
|
85 | 85 | glsr_log()->error( 'The AJAX request must include a nonce' )->info( $request ); |
86 | 86 | wp_die(); |
87 | 87 | } |
88 | - if( !wp_verify_nonce( $request['nonce'], $request['action'] )) { |
|
88 | + if( !wp_verify_nonce( $request['nonce'], $request['action'] ) ) { |
|
89 | 89 | glsr_log()->error( 'Nonce check failed for ajax request' )->info( $request ); |
90 | 90 | wp_die( -1, 403 ); |
91 | 91 | } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | { |
99 | 99 | foreach( ['request', Application::ID] as $key ) { |
100 | 100 | $request = glsr( Helper::class )->filterInputArray( $key ); |
101 | - if( !empty( $request ))break; |
|
101 | + if( !empty($request) )break; |
|
102 | 102 | } |
103 | 103 | return $this->normalizeRequest( $request ); |
104 | 104 | } |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | */ |
109 | 109 | protected function isValidPostRequest( array $request = [] ) |
110 | 110 | { |
111 | - return !empty( $request['action'] ) && empty( glsr( Helper::class )->filterInput( 'ajax_request' )); |
|
111 | + return !empty($request['action']) && empty(glsr( Helper::class )->filterInput( 'ajax_request' )); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | */ |
117 | 117 | protected function isValidPublicNonce( array $request ) |
118 | 118 | { |
119 | - if( is_user_logged_in() && !wp_verify_nonce( $request['_wpnonce'], $request['action'] )) { |
|
119 | + if( is_user_logged_in() && !wp_verify_nonce( $request['_wpnonce'], $request['action'] ) ) { |
|
120 | 120 | glsr_log()->error( 'Nonce check failed for public request' )->info( $request ); |
121 | 121 | return false; |
122 | 122 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | */ |
129 | 129 | protected function normalizeRequest( array $request ) |
130 | 130 | { |
131 | - if( isset( $request[Application::ID]['action'] )) { |
|
131 | + if( isset($request[Application::ID]['action']) ) { |
|
132 | 132 | $request = $request[Application::ID]; |
133 | 133 | } |
134 | 134 | if( glsr( Helper::class )->filterInput( 'action', $request ) == 'submit-review' ) { |
@@ -145,11 +145,11 @@ discard block |
||
145 | 145 | protected function routeRequest( $type, $action, array $request = [] ) |
146 | 146 | { |
147 | 147 | $actionHook = 'site-reviews/route/'.$type.'/request'; |
148 | - $controller = glsr( glsr( Helper::class )->buildClassName( $type.'-controller', 'Controllers' )); |
|
148 | + $controller = glsr( glsr( Helper::class )->buildClassName( $type.'-controller', 'Controllers' ) ); |
|
149 | 149 | $method = glsr( Helper::class )->buildMethodName( $action, 'router' ); |
150 | 150 | $request = apply_filters( 'site-reviews/route/request', $request, $action, $type ); |
151 | 151 | do_action( $actionHook, $action, $request ); |
152 | - if( is_callable( [$controller, $method] )) { |
|
152 | + if( is_callable( [$controller, $method] ) ) { |
|
153 | 153 | call_user_func( [$controller, $method], $request ); |
154 | 154 | return; |
155 | 155 | } |
@@ -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 | $this->checkAdminNonce( $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 | |
@@ -80,7 +90,9 @@ discard block |
||
80 | 90 | */ |
81 | 91 | protected function checkAjaxNonce( array $request ) |
82 | 92 | { |
83 | - if( !is_user_logged_in() )return; |
|
93 | + if( !is_user_logged_in() ) { |
|
94 | + return; |
|
95 | + } |
|
84 | 96 | if( !isset( $request['nonce'] )) { |
85 | 97 | glsr_log()->error( 'The AJAX request must include a nonce' )->info( $request ); |
86 | 98 | wp_die(); |
@@ -98,7 +110,9 @@ discard block |
||
98 | 110 | { |
99 | 111 | foreach( ['request', Application::ID] as $key ) { |
100 | 112 | $request = glsr( Helper::class )->filterInputArray( $key ); |
101 | - if( !empty( $request ))break; |
|
113 | + if( !empty( $request )) { |
|
114 | + break; |
|
115 | + } |
|
102 | 116 | } |
103 | 117 | return $this->normalizeRequest( $request ); |
104 | 118 | } |