PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 4.9.2
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v4.9.2
4.9.2 4.9.1 4.9.0 4.8.2 4.8.1 4.8.0 4.7.0 4.6.2 4.6.1 4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 4.5.1 4.5.0 4.4.1 4.4.0 3.3.4 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 All 200 releases
← All changes | includes/Admin/Customizer/Sanitizer.php +75 -75 3.3.44.9.2 View file →
@@ -5,89 +5,89 @@
5 5 use WP_Customize_Setting;
6 6 use WPDeveloper\BetterDocs\Utils\Base;
7 7
8 8 class Sanitizer extends Base {
9 - /**
10 - * Sanitize options like value. Works for Select.
11 - *
12 - * @since 1.0.0
13 - *
14 - * @param string $input
15 - * @param WP_Customize_Setting $setting
16 - *
17 - * @return string
18 - */
19 - public function select( $input, $setting ) {
20 - $input = sanitize_key( $input );
21 - $choices = $setting->manager->get_control( $setting->id )->choices;
9 + /**
10 + * Sanitize options like value. Works for Select.
11 + *
12 + * @since 1.0.0
13 + *
14 + * @param string $input
15 + * @param WP_Customize_Setting $setting
16 + *
17 + * @return string
18 + */
19 + public function select( $input, $setting ) {
20 + $input = sanitize_key( $input );
21 + $choices = $setting->manager->get_control( $setting->id )->choices;
22 22
23 - //return input if valid or return default option
24 - return ( array_key_exists( $input, $choices ) ? $input : $setting->default );
25 - }
23 + //return input if valid or return default option
24 + return ( array_key_exists( $input, $choices ) ? $input : $setting->default );
25 + }
26 26
27 - /**
28 - * Choice
29 - *
30 - * @param mixed $input
31 - * @param mixed $setting
32 - * @return string
33 - */
27 + /**
28 + * Choice
29 + *
30 + * @param mixed $input
31 + * @param mixed $setting
32 + * @return string
33 + */
34 34
35 - public function choices( $input, $setting ) {
36 - return $this->select( $input, $setting );
37 - }
35 + public function choices( $input, $setting ) {
36 + return $this->select( $input, $setting );
37 + }
38 38
39 - /**
40 - *
41 - * Sanitize checkbox values
42 - *
43 - * @since 1.0.0
44 - */
45 - public function checkbox( $input ) {
46 - return $input ? '1' : false;
47 - }
39 + /**
40 + *
41 + * Sanitize checkbox values
42 + *
43 + * @since 1.0.0
44 + */
45 + public function checkbox( $input ) {
46 + return $input ? '1' : false;
47 + }
48 48
49 - /**
50 - * Sanitize integers
51 - * @since 1.0.0
52 - *
53 - * @param int $input
54 - *
55 - * @return int
56 - */
57 - public function integer( $input ) {
58 - return filter_var( $input, FILTER_SANITIZE_NUMBER_INT );
59 - }
49 + /**
50 + * Sanitize integers
51 + * @since 1.0.0
52 + *
53 + * @param int $input
54 + *
55 + * @return int
56 + */
57 + public function integer( $input ) {
58 + return filter_var( $input, FILTER_SANITIZE_NUMBER_INT );
59 + }
60 60
61 - /**
62 - * Sanitize Float
63 - * @param float $input
64 - * @since 1.0.0
65 - *
66 - * @return float
67 - */
68 - public function float( $input ) {
69 - return filter_var( $input, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION );
70 - }
61 + /**
62 + * Sanitize Float
63 + * @param float $input
64 + * @since 1.0.0
65 + *
66 + * @return float
67 + */
68 + public function float( $input ) {
69 + return filter_var( $input, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION );
70 + }
71 71
72 - /**
73 - * Sanitize checkbox values
74 - * @param mixed $color
75 - * @return string
76 - */
77 - public function rgba( $color ) {
78 - if ( empty( $color ) || is_array( $color ) ) {
79 - return 'rgba(0,0,0,0)';
80 - }
72 + /**
73 + * Sanitize checkbox values
74 + * @param mixed $color
75 + * @return string
76 + */
77 + public function rgba( $color ) {
78 + if ( empty( $color ) || is_array( $color ) ) {
79 + return 'rgba(0,0,0,0)';
80 + }
81 81
82 - // If string does not start with 'rgba', then treat as hex
83 - // sanitize the hex color and finally convert hex to rgba
84 - if ( false === strpos( $color, 'rgba' ) ) {
85 - return sanitize_hex_color( $color );
86 - }
82 + // If string does not start with 'rgba', then treat as hex
83 + // sanitize the hex color and finally convert hex to rgba
84 + if ( false === strpos( $color, 'rgba' ) ) {
85 + return sanitize_hex_color( $color );
86 + }
87 87
88 - // By now we know the string is formatted as an rgba color so we need to further sanitize it.
89 - $color = str_replace( ' ', '', $color );
90 - sscanf( $color, 'rgba(%d,%d,%d,%f)', $red, $green, $blue, $alpha );
91 - return 'rgba(' . $red . ',' . $green . ',' . $blue . ',' . $alpha . ')';
92 - }
88 + // By now we know the string is formatted as an rgba color so we need to further sanitize it.
89 + $color = str_replace( ' ', '', $color );
90 + sscanf( $color, 'rgba(%d,%d,%d,%f)', $red, $green, $blue, $alpha );
91 + return 'rgba(' . $red . ',' . $green . ',' . $blue . ',' . $alpha . ')';
92 + }
93 93 }