PluginProbe
Customify / 2.10.1
Customify v2.10.1
2.10.9 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.7.1 1.3.0 1.3.1 1.4.0 1.4.1 1.4.2 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.6.0 1.6.0.1 1.6.5 1.7.0 1.7.1 All 77 releases
← All changes | includes/filter-functions.php +179 -149 1.7.12.10.1 View file →
@@ -4,192 +4,222 @@
4 4 *
5 5 * Think modifying colors, etc.
6 6 */
7 7
8 -/**
9 - * Adjust a hex color brightness
10 - * Allows us to create hover styles for custom link colors
11 - *
12 - * Taken from the Storefront theme by Automattic: https://github.com/woocommerce/storefront
13 - *
14 - * @param string $hex hex color e.g. #111111.
15 - * @param integer $steps factor by which to brighten/darken ranging from -255 (darken) to 255 (brighten).
16 - * @return string brightened/darkened hex color
17 - */
18 -function pixcloud_adjust_color_brightness( $hex, $steps ) {
19 - // Steps should be between -255 and 255. Negative = darker, positive = lighter.
20 - $steps = max( -255, min( 255, $steps ) );
8 +if ( ! function_exists( 'pixcloud_adjust_color_brightness' ) ) {
9 + /**
10 + * Adjust a hex color brightness
11 + * Allows us to create hover styles for custom link colors
12 + *
13 + * Taken from the Storefront theme by Automattic: https://github.com/woocommerce/storefront
14 + *
15 + * @param string $hex hex color e.g. #111111.
16 + * @param integer $steps factor by which to brighten/darken ranging from -255 (darken) to 255 (brighten).
17 + *
18 + * @return string brightened/darkened hex color
19 + */
20 + function pixcloud_adjust_color_brightness( $hex, $steps ) {
21 + // Steps should be between -255 and 255. Negative = darker, positive = lighter.
22 + $steps = max( - 255, min( 255, $steps ) );
21 23
22 - // Format the hex color string.
23 - $hex = str_replace( '#', '', $hex );
24 + // Format the hex color string.
25 + $hex = str_replace( '#', '', $hex );
24 26
25 - if ( 3 == strlen( $hex ) ) {
26 - $hex = str_repeat( substr( $hex, 0, 1 ), 2 ) . str_repeat( substr( $hex, 1, 1 ), 2 ) . str_repeat( substr( $hex, 2, 1 ), 2 );
27 - }
27 + if ( 3 == strlen( $hex ) ) {
28 + $hex = str_repeat( substr( $hex, 0, 1 ), 2 ) . str_repeat( substr( $hex, 1, 1 ), 2 ) . str_repeat( substr( $hex, 2, 1 ), 2 );
29 + }
28 30
29 - // Get decimal values.
30 - $r = hexdec( substr( $hex, 0, 2 ) );
31 - $g = hexdec( substr( $hex, 2, 2 ) );
32 - $b = hexdec( substr( $hex, 4, 2 ) );
31 + // Get decimal values.
32 + $r = hexdec( substr( $hex, 0, 2 ) );
33 + $g = hexdec( substr( $hex, 2, 2 ) );
34 + $b = hexdec( substr( $hex, 4, 2 ) );
33 35
34 - // Adjust number of steps and keep it inside 0 to 255.
35 - $r = max( 0, min( 255, $r + $steps ) );
36 - $g = max( 0, min( 255, $g + $steps ) );
37 - $b = max( 0, min( 255, $b + $steps ) );
36 + // Adjust number of steps and keep it inside 0 to 255.
37 + $r = max( 0, min( 255, $r + $steps ) );
38 + $g = max( 0, min( 255, $g + $steps ) );
39 + $b = max( 0, min( 255, $b + $steps ) );
38 40
39 - $r_hex = str_pad( dechex( $r ), 2, '0', STR_PAD_LEFT );
40 - $g_hex = str_pad( dechex( $g ), 2, '0', STR_PAD_LEFT );
41 - $b_hex = str_pad( dechex( $b ), 2, '0', STR_PAD_LEFT );
41 + $r_hex = str_pad( dechex( $r ), 2, '0', STR_PAD_LEFT );
42 + $g_hex = str_pad( dechex( $g ), 2, '0', STR_PAD_LEFT );
43 + $b_hex = str_pad( dechex( $b ), 2, '0', STR_PAD_LEFT );
42 44
43 - return '#' . $r_hex . $g_hex . $b_hex;
45 + return '#' . $r_hex . $g_hex . $b_hex;
46 + }
44 47 }
45 48
46 -/**
47 - * Negate the value.
48 - *
49 - * @param int|float $value
50 - * @return int|float
51 - */
52 -function pixcloud_negate( $value ) {
53 - if ( ! is_numeric( $value ) ) {
54 - return $value;
49 +if ( ! function_exists( 'pixcloud_negate' ) ) {
50 + /**
51 + * Negate the value.
52 + *
53 + * @param int|float $value
54 + *
55 + * @return int|float
56 + */
57 + function pixcloud_negate( $value ) {
58 + if ( ! is_numeric( $value ) ) {
59 + return $value;
60 + }
61 +
62 + return - $value;
55 63 }
64 +}
56 65
57 - return - $value;
58 -}
66 +if ( ! function_exists( 'pixcloud_min' ) ) {
67 + /**
68 + * Ensure that value is at least the $min value.
69 + *
70 + * @param int|float $value
71 + * @param int|float $min
72 + *
73 + * @return int|float
74 + */
75 + function pixcloud_min( $value, $min ) {
76 + if ( ! is_numeric( $value ) || ! is_numeric( $min ) ) {
77 + return $value;
78 + }
59 79
60 -/**
61 - * Ensure that value is at least the $min value.
62 - *
63 - * @param int|float $value
64 - * @param int|float $min
65 - * @return int|float
66 - */
67 -function pixcloud_min( $value, $min ) {
68 - if ( ! is_numeric( $value ) || ! is_numeric( $min ) ) {
80 + if ( $value < $min ) {
81 + return $min;
82 + }
83 +
69 84 return $value;
70 85 }
86 +}
71 87
72 - if ( $value < $min ) {
73 - return $min;
74 - }
88 +if ( ! function_exists( 'pixcloud_max' ) ) {
89 + /**
90 + * Ensure that value is at most the $max value.
91 + *
92 + * @param int|float $value
93 + * @param int|float $max
94 + *
95 + * @return int|float
96 + */
97 + function pixcloud_max( $value, $max ) {
98 + if ( ! is_numeric( $value ) || ! is_numeric( $max ) ) {
99 + return $value;
100 + }
75 101
76 - return $value;
77 -}
102 + if ( $value > $max ) {
103 + return $max;
104 + }
78 105
79 -/**
80 - * Ensure that value is at most the $max value.
81 - *
82 - * @param int|float $value
83 - * @param int|float $max
84 - * @return int|float
85 - */
86 -function pixcloud_max( $value, $max ) {
87 - if ( ! is_numeric( $value ) || ! is_numeric( $max ) ) {
88 106 return $value;
89 107 }
108 +}
90 109
91 - if ( $value > $max ) {
92 - return $max;
93 - }
110 +if ( ! function_exists( 'pixcloud_min_max' ) ) {
111 + /**
112 + * Ensure that value is between $min and $max.
113 + *
114 + * @param int|float $value
115 + * @param int|float $min
116 + * @param int|float $max
117 + *
118 + * @return int|float
119 + */
120 + function pixcloud_min_max( $value, $min, $max ) {
121 + if ( ! is_numeric( $value ) || ! is_numeric( $min ) || ! is_numeric( $max ) ) {
122 + return $value;
123 + }
94 124
95 - return $value;
96 -}
125 + if ( $value < $min ) {
126 + $value = $min;
127 + }
97 128
98 -/**
99 - * Ensure that value is between $min and $max.
100 - *
101 - * @param int|float $value
102 - * @param int|float $min
103 - * @param int|float $max
104 - * @return int|float
105 - */
106 -function pixcloud_min_max( $value, $min, $max ) {
107 - if ( ! is_numeric( $value ) || ! is_numeric( $min ) || ! is_numeric( $max ) ) {
129 + if ( $value > $max ) {
130 + $value = $max;
131 + }
132 +
108 133 return $value;
109 134 }
135 +}
110 136
111 - if ( $value < $min ) {
112 - $value = $min;
113 - }
137 +if ( ! function_exists( 'pixcloud_add' ) ) {
138 + /**
139 + * Add something to the value.
140 + *
141 + * @param int|float $value
142 + * @param int|float $add
143 + *
144 + * @return int|float
145 + */
146 + function pixcloud_add( $value, $add ) {
147 + if ( ! is_numeric( $value ) || ! is_numeric( $add ) ) {
148 + return $value;
149 + }
114 150
115 - if ( $value > $max ) {
116 - $value = $max;
151 + return $value + $add;
117 152 }
153 +}
118 154
119 - return $value;
120 -}
155 +if ( ! function_exists( 'pixcloud_substract' ) ) {
156 + /**
157 + * Substract something from the value.
158 + *
159 + * @param int|float $value
160 + * @param int|float $substract
161 + *
162 + * @return int|float
163 + */
164 + function pixcloud_substract( $value, $substract ) {
165 + if ( ! is_numeric( $value ) || ! is_numeric( $substract ) ) {
166 + return $value;
167 + }
121 168
122 -/**
123 - * Add something to the value.
124 - *
125 - * @param int|float $value
126 - * @param int|float $add
127 - * @return int|float
128 - */
129 -function pixcloud_add( $value, $add ) {
130 - if ( ! is_numeric( $value ) || ! is_numeric( $add ) ) {
131 - return $value;
169 + return $value - $substract;
132 170 }
171 +}
133 172
134 - return $value + $add;
135 -}
173 +if ( ! function_exists( 'pixcloud_multiply' ) ) {
174 + /**
175 + * Multiply the value.
176 + *
177 + * @param int|float $value
178 + * @param int|float $multiply
179 + *
180 + * @return int|float
181 + */
182 + function pixcloud_multiply( $value, $multiply ) {
183 + if ( ! is_numeric( $value ) || ! is_numeric( $multiply ) ) {
184 + return $value;
185 + }
136 186
137 -/**
138 - * Substract something from the value.
139 - *
140 - * @param int|float $value
141 - * @param int|float $substract
142 - * @return int|float
143 - */
144 -function pixcloud_substract( $value, $substract ) {
145 - if ( ! is_numeric( $value ) || ! is_numeric( $substract ) ) {
146 - return $value;
187 + return $value * $multiply;
147 188 }
189 +}
148 190
149 - return $value - $substract;
150 -}
191 +if ( ! function_exists( 'pixcloud_divide' ) ) {
192 + /**
193 + * Divide the value.
194 + *
195 + * @param int|float $value
196 + * @param int|float $divide
197 + *
198 + * @return int|float
199 + */
200 + function pixcloud_divide( $value, $divide ) {
201 + if ( ! is_numeric( $value ) || ! is_numeric( $divide ) || empty( $divide ) ) {
202 + return $value;
203 + }
151 204
152 -/**
153 - * Multiply the value.
154 - *
155 - * @param int|float $value
156 - * @param int|float $multiply
157 - * @return int|float
158 - */
159 -function pixcloud_multiply( $value, $multiply ) {
160 - if ( ! is_numeric( $value ) || ! is_numeric( $multiply ) ) {
161 - return $value;
205 + return $value / $divide;
162 206 }
207 +}
163 208
164 - return $value * $multiply;
165 -}
209 +if ( ! function_exists( 'pixcloud_modulo' ) ) {
210 + /**
211 + * Divide the value and get the remainder.
212 + *
213 + * @param int|float $value
214 + * @param int|float $divide
215 + *
216 + * @return int|float
217 + */
218 + function pixcloud_modulo( $value, $divide ) {
219 + if ( ! is_numeric( $value ) || ! is_numeric( $divide ) || empty( $divide ) ) {
220 + return $value;
221 + }
166 222
167 -/**
168 - * Divide the value.
169 - *
170 - * @param int|float $value
171 - * @param int|float $divide
172 - * @return int|float
173 - */
174 -function pixcloud_divide( $value, $divide ) {
175 - if ( ! is_numeric( $value ) || ! is_numeric( $divide ) || empty( $divide ) ) {
176 - return $value;
223 + return $value % $divide;
177 224 }
178 -
179 - return $value / $divide;
180 225 }
181 -
182 -/**
183 - * Divide the value and get the remainder.
184 - *
185 - * @param int|float $value
186 - * @param int|float $divide
187 - * @return int|float
188 - */
189 -function pixcloud_modulo( $value, $divide ) {
190 - if ( ! is_numeric( $value ) || ! is_numeric( $divide ) || empty( $divide ) ) {
191 - return $value;
192 - }
193 -
194 - return $value % $divide;
195 -}