| @@ 90-126 (lines=37) @@ | ||
| 87 | * |
|
| 88 | * @see like_escape |
|
| 89 | */ |
|
| 90 | function pods_sanitize_like( $input ) { |
|
| 91 | ||
| 92 | if ( '' === $input || is_int( $input ) || is_float( $input ) || empty( $input ) ) { |
|
| 93 | return $input; |
|
| 94 | } |
|
| 95 | ||
| 96 | $output = array(); |
|
| 97 | ||
| 98 | if ( is_object( $input ) ) { |
|
| 99 | $input = get_object_vars( $input ); |
|
| 100 | ||
| 101 | foreach ( $input as $key => $val ) { |
|
| 102 | $output[ $key ] = pods_sanitize_like( $val ); |
|
| 103 | } |
|
| 104 | ||
| 105 | $output = (object) $output; |
|
| 106 | } |
|
| 107 | elseif ( is_array( $input ) ) { |
|
| 108 | foreach ( $input as $key => $val ) { |
|
| 109 | $output[ $key ] = pods_sanitize_like( $val ); |
|
| 110 | } |
|
| 111 | } |
|
| 112 | else { |
|
| 113 | global $wpdb; |
|
| 114 | ||
| 115 | if ( pods_version_check( 'wp', '4.0' ) ) { |
|
| 116 | $output = $wpdb->esc_like( pods_sanitize( $input ) ); |
|
| 117 | } |
|
| 118 | else { |
|
| 119 | // like_escape is deprecated in WordPress 4.0 |
|
| 120 | $output = like_escape( pods_sanitize( $input ) ); |
|
| 121 | } |
|
| 122 | } |
|
| 123 | ||
| 124 | return $output; |
|
| 125 | ||
| 126 | } |
|
| 127 | ||
| 128 | /** |
|
| 129 | * Filter input and return slashed output |
|
| @@ 263-300 (lines=38) @@ | ||
| 260 | * |
|
| 261 | * @see wp_unslash |
|
| 262 | */ |
|
| 263 | function pods_unslash( $input ) { |
|
| 264 | ||
| 265 | if ( '' === $input || is_int( $input ) || is_float( $input ) || empty( $input ) ) { |
|
| 266 | return $input; |
|
| 267 | } |
|
| 268 | ||
| 269 | $output = array(); |
|
| 270 | ||
| 271 | if ( empty( $input ) ) { |
|
| 272 | $output = $input; |
|
| 273 | } |
|
| 274 | elseif ( is_object( $input ) ) { |
|
| 275 | $input = get_object_vars( $input ); |
|
| 276 | ||
| 277 | foreach ( $input as $key => $val ) { |
|
| 278 | $output[ $key ] = pods_unslash( $val ); |
|
| 279 | } |
|
| 280 | ||
| 281 | $output = (object) $output; |
|
| 282 | } |
|
| 283 | elseif ( is_array( $input ) ) { |
|
| 284 | foreach ( $input as $key => $val ) { |
|
| 285 | $output[ $key ] = pods_unslash( $val ); |
|
| 286 | } |
|
| 287 | } |
|
| 288 | else { |
|
| 289 | // @todo Figure out what to do to unescape mysql_real_escape_string |
|
| 290 | if ( pods_version_check( 'wp', '3.6' ) ) { |
|
| 291 | $output = wp_unslash( $input ); |
|
| 292 | } |
|
| 293 | else { |
|
| 294 | $output = stripslashes( $input ); |
|
| 295 | } |
|
| 296 | } |
|
| 297 | ||
| 298 | return $output; |
|
| 299 | ||
| 300 | } |
|
| 301 | ||
| 302 | /** |
|
| 303 | * Filter input and return sanitized output |
|