1 <?php if ( ! defined( 'OT_VERSION' ) ) exit( 'No direct script access allowed' ); |
1 <?php |
2 /** |
2 /** |
3 * OptionTree deprecated functions |
3 * OptionTree Deprecated Functions. |
4 * |
4 * |
5 * @package OptionTree |
5 * @package OptionTree |
6 * @author Derek Herman <derek@valendesigns.com> |
|
7 * @copyright Copyright (c) 2013, Derek Herman |
|
8 * @since 2.0 |
|
9 */ |
6 */ |
10 |
7 |
11 /** |
8 if ( ! defined( 'OT_VERSION' ) ) { |
12 * Displays or returns a value from the 'option_tree' array. |
9 exit( 'No direct script access allowed' ); |
13 * |
10 } |
14 * @param string $item_id |
11 |
15 * @param array $options |
|
16 * @param bool $echo |
|
17 * @param bool $is_array |
|
18 * @param int $offset |
|
19 * @return mixed array or comma seperated lists of values |
|
20 * |
|
21 * @access public |
|
22 * @since 1.0.0 |
|
23 * @updated 2.0 |
|
24 * @deprecated 2.0 |
|
25 */ |
|
26 if ( ! function_exists( 'get_option_tree' ) ) { |
12 if ( ! function_exists( 'get_option_tree' ) ) { |
27 |
13 |
28 function get_option_tree( $item_id = '', $options = '', $echo = false, $is_array = false, $offset = -1 ) { |
14 /** |
29 /* load saved options */ |
15 * Displays or returns a value from the 'option_tree' array. |
30 if ( ! $options ) |
16 * |
31 $options = get_option( ot_options_id() ); |
17 * @param string $item_id The item ID. |
32 |
18 * @param array $options Options array. |
33 /* no value return */ |
19 * @param bool $echo Whether to echo or return value. |
34 if ( ! isset( $options[$item_id] ) || empty( $options[$item_id] ) ) |
20 * @param bool $is_array Whether the value option is an array or string. |
35 return; |
21 * @param int $offset The array key. |
36 |
22 * @return mixed Array or comma separated lists of values. |
37 /* set content value & strip slashes */ |
23 * |
38 $content = option_tree_stripslashes( $options[$item_id] ); |
24 * @access public |
39 |
25 * @since 1.0.0 |
40 /* is an array */ |
26 * @updated 2.0 |
41 if ( $is_array == true ) { |
27 * @deprecated 2.0 |
42 /* saved as a comma seperated lists of values, explode into an array */ |
28 */ |
43 if ( !is_array( $content ) ) |
29 function get_option_tree( $item_id = '', $options = array(), $echo = false, $is_array = false, $offset = -1 ) { |
44 $content = explode( ',', $content ); |
|
45 |
|
46 /* get an array value using an offset */ |
|
47 if ( is_numeric( $offset ) && $offset >= 0 ) { |
|
48 $content = $content[$offset]; |
|
49 } else if ( ! is_numeric( $offset ) && isset( $content[$offset] ) ) { |
|
50 $content = $content[$offset]; |
|
51 } |
|
52 |
|
53 /* not an array */ |
|
54 } else if ( $is_array == false ) { |
|
55 /* saved as array, implode and return a comma seperated lists of values */ |
|
56 if ( is_array( $content ) ) |
|
57 $content = implode( ',', $content ); /* This is fucked */ |
|
58 } |
|
59 |
|
60 /* echo content */ |
|
61 if ( $echo ) |
|
62 echo $content; |
|
63 |
|
64 return $content; |
|
65 } |
|
66 |
30 |
|
31 // Load saved options. |
|
32 if ( ! $options ) { |
|
33 $options = get_option( ot_options_id() ); |
|
34 } |
|
35 |
|
36 // No value return. |
|
37 if ( ! isset( $options[ $item_id ] ) || empty( $options[ $item_id ] ) ) { |
|
38 return; |
|
39 } |
|
40 |
|
41 // Set content value & strip slashes. |
|
42 $content = option_tree_stripslashes( $options[ $item_id ] ); |
|
43 |
|
44 if ( true === $is_array ) { |
|
45 if ( ! is_array( $content ) ) { |
|
46 $content = explode( ',', $content ); |
|
47 } |
|
48 |
|
49 if ( is_numeric( $offset ) && 0 <= $offset ) { |
|
50 $content = $content[ $offset ]; |
|
51 } elseif ( ! is_numeric( $offset ) && isset( $content[ $offset ] ) ) { |
|
52 $content = $content[ $offset ]; |
|
53 } |
|
54 } else { |
|
55 if ( is_array( $content ) ) { |
|
56 $content = implode( ',', $content ); |
|
57 } |
|
58 } |
|
59 |
|
60 if ( $echo ) { |
|
61 echo $content; // phpcs:ignore |
|
62 } |
|
63 |
|
64 return $content; |
|
65 } |
67 } |
66 } |
68 |
67 |
69 /** |
|
70 * Custom stripslashes from single value or array. |
|
71 * |
|
72 * @param mixed $input |
|
73 * @return mixed |
|
74 * |
|
75 * @access public |
|
76 * @since 1.1.3 |
|
77 * @deprecated 2.0 |
|
78 */ |
|
79 if ( ! function_exists( 'option_tree_stripslashes' ) ) { |
68 if ( ! function_exists( 'option_tree_stripslashes' ) ) { |
80 |
69 |
81 function option_tree_stripslashes( $input ) { |
70 /** |
82 if ( is_array( $input ) ) { |
71 * Custom stripslashes from single value or array. |
83 foreach( $input as &$val ) { |
72 * |
84 if ( is_array( $val ) ) { |
73 * @param mixed $input Input string or array. |
85 $val = option_tree_stripslashes( $val ); |
74 * @return mixed |
86 } else { |
75 * |
87 $val = stripslashes( $val ); |
76 * @access public |
88 } |
77 * @since 1.1.3 |
89 } |
78 * @deprecated 2.0 |
90 } else { |
79 */ |
91 $input = stripslashes( $input ); |
80 function option_tree_stripslashes( $input ) { |
92 } |
81 if ( is_array( $input ) ) { |
93 return $input; |
82 foreach ( $input as &$val ) { |
94 } |
83 if ( is_array( $val ) ) { |
95 |
84 $val = option_tree_stripslashes( $val ); |
|
85 } else { |
|
86 $val = stripslashes( $val ); |
|
87 } |
|
88 } |
|
89 } else { |
|
90 $input = stripslashes( $input ); |
|
91 } |
|
92 return $input; |
|
93 } |
96 } |
94 } |
97 |
|
98 /* End of file ot-functions-deprecated.php */ |
|
99 /* Location: ./includes/ot-functions-deprecated.php */ |
|