@@ -115,9 +115,9 @@ protected function addCSS(string $css, string $hook = 'add-css')
115115 * @param string $action
116116 * @param bool
117117 */
118- protected function verifyToken (string $ token = '' , string $ source = '' )
118+ protected function verifyToken (? string $ token = null , ? string $ source = null )
119119 {
120- if ( ! empty ( $ token) ) {
120+ if ( $ token ) {
121121
122122 $ transient = new Transient ();
123123 $ data = (string )$ transient ->getTemp ($ token );
@@ -154,7 +154,7 @@ protected function verifyToken(string $token = '', string $source = '')
154154 * Verify current request.
155155 *
156156 * @access protected
157- * @param bool $force Token validation
157+ * @param bool $force, Token validation
158158 * @return void
159159 */
160160 protected function verifyRequest (bool $ force = false )
@@ -189,31 +189,38 @@ protected function verifyRequest(bool $force = false)
189189
190190 /**
191191 * Sanitize current request.
192- *
192+ *
193193 * @access protected
194- * @param bool $verify Request
195- * @param bool $force Token validation
196- * @return mixed
194+ * @param bool $verify, Request
195+ * @param bool $force, Token validation
196+ * @return array
197197 */
198- protected function sanitizeRequest (bool $ verify = true , bool $ force = false )
198+ protected function sanitizeRequest (bool $ verify = true , bool $ force = false ) : array
199199 {
200- if ( $ verify ) $ this ->verifyRequest ($ force );
201-
202200 $ request = $ this ->getRequest ();
203- $ excepts = $ this ->applyFilter ('sanitize-request ' , [
204- 'submit ' ,
205- '--token ' ,
206- '--source ' ,
207- '--ignore '
208- ]);
201+ $ excepts = [
202+ 'PHPSESSID ' , 'COOKIES '
203+ ];
204+
205+ if ( !$ force ) {
206+ $ excepts = $ this ->mergeArray ([
207+ 'submit ' , '--token ' , '--source ' , '--ignore '
208+ ], $ excepts );
209+ }
210+
211+ if ( $ verify ) {
212+ $ this ->verifyRequest ($ force );
213+ }
214+
215+ $ excepts = $ this ->applyFilter ('sanitize-request ' , $ excepts );
209216
210217 foreach ($ excepts as $ except ) {
211218 if ( isset ($ request [$ except ]) ) {
212219 unset($ request [$ except ]);
213220 }
214221 }
215222
216- return $ request ;
223+ return $ request ?: [] ;
217224 }
218225
219226 /**
0 commit comments