plugin development - Sanitize WordPress Array Input?

admin2025-01-07  9

I have a form that submits the data in array format. I have sanitized all the data and also tried to escape it using esc_attr, but it is a function of escaping and not sanitizing.

Is there a better way to sanitize the entire array (with text value) instead of each individual value.

$array = array_map( 'esc_attr', $array );

How can we make sure the data is sanitize and not just escaped?

I have a form that submits the data in array format. I have sanitized all the data and also tried to escape it using esc_attr, but it is a function of escaping and not sanitizing.

Is there a better way to sanitize the entire array (with text value) instead of each individual value.

$array = array_map( 'esc_attr', $array );

How can we make sure the data is sanitize and not just escaped?

Share Improve this question edited May 13, 2020 at 7:36 cjbj 15k16 gold badges42 silver badges89 bronze badges asked May 13, 2020 at 7:13 suizsuiz 1113 bronze badges 1
  • 1 This question is similar to: wordpress sanitize array?. If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem. – Matthew Brown aka Lord Matt Commented 14 hours ago
Add a comment  | 

1 Answer 1

Reset to default 0

I'm not completely sure what you mean to do, but are you looking for sanitize_text_field?

$array = array_map( 'sanitize_text_field', $array );
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736252249a30.html

最新回复(0)