File tree Expand file tree Collapse file tree 1 file changed +14
-12
lines changed Expand file tree Collapse file tree 1 file changed +14
-12
lines changed Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ protected function normalize_data( array $data ) {
97
97
$ data = stripslashes_deep ( $ data );
98
98
99
99
// sanitize all scalar values
100
- $ data = $ this ->sanitize_data_array ( $ data );
100
+ $ data = $ this ->sanitize_deep ( $ data );
101
101
102
102
/**
103
103
* @filter `mc4wp_form_data`
@@ -109,22 +109,24 @@ protected function normalize_data( array $data ) {
109
109
}
110
110
111
111
/**
112
- * @param $dirty
112
+ * @param $value
113
113
*
114
- * @return array
114
+ * @return array|string
115
115
*/
116
- public function sanitize_data_array ( $ dirty ) {
117
- $ clean = array ();
118
-
119
- foreach ( $ dirty as $ field => $ value ) {
120
- if ( is_scalar ( $ value ) ) {
121
- $ clean [ $ field ] = sanitize_text_field ( $ value );
122
- } elseif ( is_array ( $ value ) ) {
123
- $ clean [ $ field ] = array_map ( array ( $ this , 'sanitize_data_array ' ), $ value );
116
+ public function sanitize_deep ( $ value ) {
117
+
118
+ if ( is_scalar ( $ value ) ) {
119
+ $ value = sanitize_text_field ( $ value );
120
+ } elseif ( is_array ( $ value ) ) {
121
+ $ value = array_map ( array ( $ this , 'sanitize_deep ' ), $ value );
122
+ } elseif ( is_object ($ value ) ) {
123
+ $ vars = get_object_vars ( $ value );
124
+ foreach ($ vars as $ key =>$ data ) {
125
+ $ value ->{$ key } = $ this ->sanitize_deep ( $ data );
124
126
}
125
127
}
126
128
127
- return $ clean ;
129
+ return $ value ;
128
130
}
129
131
130
132
/**
You can’t perform that action at this time.
0 commit comments