@@ -158,7 +158,7 @@ public function maybe_process_update() {
158158 if ( ! isset ( $ _POST ['_wpnonce ' ] ) ) {
159159 return false ;
160160 }
161- $ wpnonce = ( isset ( $ _POST ['submit ' ] ) && isset ( $ _POST ['_wpnonce ' ] ) ) ? filter_input ( INPUT_POST , '_wpnonce ' ) : null ;
161+ $ wpnonce = ( isset ( $ _POST ['submit ' ] ) && isset ( $ _POST ['_wpnonce ' ] ) ) ? sanitize_text_field ( $ _POST [ '_wpnonce ' ] ) : null ;
162162
163163 // Only allow class to be used by panel OR encrypted pwds never updated after insert.
164164 if ( empty ( $ wpnonce ) || wp_verify_nonce ( $ wpnonce ) ) {
@@ -251,31 +251,32 @@ public function input_value( $type, $established_data, $use_data_value = false )
251251 * @return bool|string
252252 */
253253 public function run_save_process () {
254- $ nonce = ( isset ( $ _POST ['submit ' ] ) && isset ( $ _POST ['_wpnonce ' ] ) ) ? filter_input ( INPUT_POST , '_wpnonce ' ) : null ;
254+ $ nonce = ( isset ( $ _POST ['submit ' ] ) && isset ( $ _POST ['_wpnonce ' ] ) ) ? sanitize_text_field ( $ _POST [ '_wpnonce ' ] ) : null ;
255255 $ page_slug_as_action = $ this ->section ->panel ->page ->slug ;
256256 if ( empty ( $ nonce ) || false === wp_verify_nonce ( $ nonce , $ page_slug_as_action ) ) {
257257 return false ; // Only run logic if asked to run & auth'd by nonce.
258258 }
259259
260260 $ type = ( ! empty ( $ this ->field_type ) ) ? $ this ->field_type : $ this ->input_type ;
261261
262- $ field_input = isset ( $ _POST [ $ this ->id ] ) ? filter_input ( INPUT_POST , $ this ->id ) : false ;
262+ $ field_input = isset ( $ _POST [ $ this ->id ] ) ? sanitize_text_field ( $ _POST [ $ this ->id ] ) : false ;
263263
264264 $ sanitize_input = $ this ->sanitize_data_input ( $ type , $ this ->id , $ field_input );
265265
266- $ updated = new Update (
266+ $ update_obj = new Update ();
267+ $ updated = $ update_obj ->get_save_data (
267268 $ this ->section ->panel ->page ->slug , // Used to check nonce.
268269 $ this ->data_api , // Doing this way to allow multi-api saving from single section down-the-road.
269270 $ this ->id , // This is the data storage key in the database.
270271 $ sanitize_input , // Sanitized input (maybe empty, triggering delete).
271272 isset ( $ this ->obj_id ) ? $ this ->obj_id : null // Maybe an object ID needed for metadata API.
272273 );
273274
274- if ( $ updated ) {
275- return $ this -> id ;
275+ if ( empty ( $ updated ) || is_wp_error ( $ updated ) ) {
276+ return false ;
276277 }
277278
278- return false ;
279+ return $ this -> id ;
279280 }
280281
281282 /**
@@ -310,7 +311,7 @@ protected function sanitize_data_input( $input_type, $id, $value ) {
310311 if ( ! isset ( $ _POST ['_wpnonce ' ] ) ) {
311312 return false ;
312313 }
313- $ wpnonce = ( isset ( $ _POST ['submit ' ] ) && isset ( $ _POST ['_wpnonce ' ] ) ) ? filter_input ( INPUT_POST , '_wpnonce ' ) : null ;
314+ $ wpnonce = ( isset ( $ _POST ['submit ' ] ) && isset ( $ _POST ['_wpnonce ' ] ) ) ? sanitize_text_field ( $ _POST [ '_wpnonce ' ] ) : null ;
314315
315316 // Only allow class to be used by panel OR encrypted pwds never updated after insert.
316317 if ( empty ( $ wpnonce ) || wp_verify_nonce ( $ wpnonce ) ) {
@@ -319,7 +320,7 @@ protected function sanitize_data_input( $input_type, $id, $value ) {
319320
320321 switch ( $ input_type ) {
321322 case 'password ' :
322- $ hidden_pwd_field = isset ( $ _POST [ 'stored_ ' . $ id ] ) ? filter_input ( INPUT_POST , 'stored_ ' . $ id ) : null ;
323+ $ hidden_pwd_field = isset ( $ _POST [ 'stored_ ' . $ id ] ) ? sanitize_text_field ( $ _POST [ 'stored_ ' . $ id ] ) : null ;
323324
324325 if ( $ hidden_pwd_field === $ value && ! empty ( $ value ) ) {
325326 return '### wpop-encrypted-pwd-field-val-unchanged ### ' ;
@@ -357,5 +358,4 @@ protected function sanitize_data_input( $input_type, $id, $value ) {
357358 * Render is an output placeholder for sub parts.
358359 */
359360 abstract public function render ();
360-
361361}
0 commit comments