← All changes
|
includes/features/bbpc_attachments/code/sanitize.php
+75
-74
1.3.3
→
2.2.0
View file →
| @@ -1,74 +1,75 @@ | ||
| 1 | -<?php | |
| 2 | - | |
| 3 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 4 | - exit; | |
| 5 | -} | |
| 6 | - | |
| 7 | -if ( ! function_exists( 'bbpc_sanitize_key_expanded' ) ) { | |
| 8 | - function bbpc_sanitize_key_expanded( $key ) { | |
| 9 | - $key = strtolower( $key ); | |
| 10 | - $key = preg_replace( '/[^a-z0-9._\-]/', '', $key ); | |
| 11 | - | |
| 12 | - return $key; | |
| 13 | - } | |
| 14 | -} | |
| 15 | - | |
| 16 | -if ( ! function_exists( 'bbpc_sanitize_extended' ) ) { | |
| 17 | - function bbpc_sanitize_extended( $text, $tags = null, $protocols = [], $strip_shortcodes = false ) { | |
| 18 | - $tags = is_null( $tags ) ? wp_kses_allowed_html( 'post' ) : $tags; | |
| 19 | - $text = stripslashes( $text ); | |
| 20 | - | |
| 21 | - if ( $strip_shortcodes ) { | |
| 22 | - $text = strip_shortcodes( $text ); | |
| 23 | - } | |
| 24 | - | |
| 25 | - return wp_kses( trim( $text ), $tags, $protocols ); | |
| 26 | - } | |
| 27 | -} | |
| 28 | - | |
| 29 | -if ( ! function_exists( 'bbpc_sanitize_basic' ) ) { | |
| 30 | - function bbpc_sanitize_basic( $text, $strip_shortcodes = true ) { | |
| 31 | - $text = stripslashes( $text ); | |
| 32 | - | |
| 33 | - if ( $strip_shortcodes ) { | |
| 34 | - $text = strip_shortcodes( $text ); | |
| 35 | - } | |
| 36 | - | |
| 37 | - return trim( wp_kses( $text, [] ) ); | |
| 38 | - } | |
| 39 | -} | |
| 40 | - | |
| 41 | -if ( ! function_exists( 'bbpc_sanitize_html' ) ) { | |
| 42 | - function bbpc_sanitize_html( $text, $tags = null, $protocols = [] ) { | |
| 43 | - $tags = is_null( $tags ) ? wp_kses_allowed_html( 'post' ) : $tags; | |
| 44 | - | |
| 45 | - return wp_kses( trim( stripslashes( $text ) ), $tags, $protocols ); | |
| 46 | - } | |
| 47 | -} | |
| 48 | - | |
| 49 | -if ( ! function_exists( 'bbpc_sanitize_slug' ) ) { | |
| 50 | - function bbpc_sanitize_slug( $text ) { | |
| 51 | - return trim( sanitize_title_with_dashes( stripslashes( $text ) ), "-_ \t\n\r\0\x0B" ); | |
| 52 | - } | |
| 53 | -} | |
| 54 | - | |
| 55 | -if ( ! function_exists( 'bbpc_sanitize_html_classes' ) ) { | |
| 56 | - function bbpc_sanitize_html_classes( $classes ) { | |
| 57 | - $list = explode( ' ', trim( stripslashes( $classes ) ) ); | |
| 58 | - $list = array_map( 'sanitize_html_class', $list ); | |
| 59 | - | |
| 60 | - return trim( join( ' ', $list ) ); | |
| 61 | - } | |
| 62 | -} | |
| 63 | - | |
| 64 | -if ( ! function_exists( 'bbpc_sanitize_basic_array' ) ) { | |
| 65 | - function bbpc_sanitize_basic_array( $input, $strip_shortcodes = true ) { | |
| 66 | - $output = []; | |
| 67 | - | |
| 68 | - foreach ( $input as $key => $value ) { | |
| 69 | - $output[ $key ] = bbpc_sanitize_basic( $value, $strip_shortcodes ); | |
| 70 | - } | |
| 71 | - | |
| 72 | - return $output; | |
| 73 | - } | |
| 74 | -} | |
| 1 | +<?php | |
| 2 | + | |
| 3 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 4 | + exit; | |
| 5 | +} | |
| 6 | + | |
| 7 | +if ( ! function_exists( 'forumax_sanitize_key_expanded' ) ) { | |
| 8 | + function forumax_sanitize_key_expanded( $key ) { | |
| 9 | + $key = strtolower( $key ); | |
| 10 | + $key = preg_replace( '/[^a-z0-9._\-]/', '', $key ); | |
| 11 | + | |
| 12 | + return $key; | |
| 13 | + } | |
| 14 | +} | |
| 15 | + | |
| 16 | +if ( ! function_exists( 'bbpc_sanitize_extended' ) ) { | |
| 17 | + function bbpc_sanitize_extended( $text, $tags = null, $protocols = [], $strip_shortcodes = false ) { | |
| 18 | + $tags = is_null( $tags ) ? wp_kses_allowed_html( 'post' ) : $tags; | |
| 19 | + $text = stripslashes( $text ); | |
| 20 | + | |
| 21 | + if ( $strip_shortcodes ) { | |
| 22 | + $text = strip_shortcodes( $text ); | |
| 23 | + } | |
| 24 | + | |
| 25 | + return wp_kses( trim( $text ), $tags, $protocols ); | |
| 26 | + } | |
| 27 | +} | |
| 28 | + | |
| 29 | +if ( ! function_exists( 'bbpc_sanitize_basic' ) ) { | |
| 30 | + function bbpc_sanitize_basic( $text, $strip_shortcodes = true ) { | |
| 31 | + $text = stripslashes( $text ); | |
| 32 | + | |
| 33 | + if ( $strip_shortcodes ) { | |
| 34 | + $text = strip_shortcodes( $text ); | |
| 35 | + } | |
| 36 | + | |
| 37 | + return trim( wp_kses( $text, [] ) ); | |
| 38 | + } | |
| 39 | +} | |
| 40 | + | |
| 41 | +if ( ! function_exists( 'bbpc_sanitize_html' ) ) { | |
| 42 | + function bbpc_sanitize_html( $text, $tags = null, $protocols = [] ) { | |
| 43 | + $tags = is_null( $tags ) ? wp_kses_allowed_html( 'post' ) : $tags; | |
| 44 | + | |
| 45 | + return wp_kses( trim( stripslashes( $text ) ), $tags, $protocols ); | |
| 46 | + } | |
| 47 | +} | |
| 48 | + | |
| 49 | +if ( ! function_exists( 'bbpc_sanitize_slug' ) ) { | |
| 50 | + function bbpc_sanitize_slug( $text ) { | |
| 51 | + return trim( sanitize_title_with_dashes( stripslashes( $text ) ), "-_ \t\n\r\0\x0B" ); | |
| 52 | + } | |
| 53 | +} | |
| 54 | + | |
| 55 | +if ( ! function_exists( 'bbpc_sanitize_html_classes' ) ) { | |
| 56 | + function bbpc_sanitize_html_classes( $classes ) { | |
| 57 | + $list = explode( ' ', trim( stripslashes( $classes ) ) ); | |
| 58 | + $list = array_map( 'sanitize_html_class', $list ); | |
| 59 | + | |
| 60 | + return trim( join( ' ', $list ) ); | |
| 61 | + } | |
| 62 | +} | |
| 63 | + | |
| 64 | +if ( ! function_exists( 'bbpc_sanitize_basic_array' ) ) { | |
| 65 | + function bbpc_sanitize_basic_array( $input, $strip_shortcodes = true ) { | |
| 66 | + $output = []; | |
| 67 | + | |
| 68 | + foreach ( $input as $key => $value ) { | |
| 69 | + $output[ $key ] = bbpc_sanitize_basic( $value, $strip_shortcodes ); | |
| 70 | + } | |
| 71 | + | |
| 72 | + return $output; | |
| 73 | + } | |
| 74 | +} | |
| 75 | + | |