Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #23416, comment 9


Ignore:
Timestamp:
11/22/2014 04:24:11 PM (11 years ago)
Author:
cisco87
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #23416, comment 9

    initial v1  
    11What about a function like this which allows you to sanitise an array recursively and to apply filters to each of the keys to strip_tags or whatever?
    22Whether its an array or a value it just iterate and recurse allowing you to create filter for all the values in an array like for authors[] or the key author just hooking "filter_array_authors" or "filter_array_author"
    3 
     3and you can call it with
     4{{{ $_POST = recur_filter($_POST); }}}
    45{{{
    5 function recur_trim($vars, $pkey = null) {
     6function recur_filter($vars, $pkey = null) {
    67        $filter = "filter_array";
    78       
     
    2425                                        $arg = $pkey;
    2526                                }
    26                                 $vars[$key] = recur_trim($vars[$key], $arg);
     27                                $vars[$key] = recur_filter($vars[$key], $arg);
    2728                        }
    2829                        else {