11
|
1 |
<?php |
0
|
2 |
/** |
11
|
3 |
* OptionTree Deprecated Functions. |
0
|
4 |
* |
11
|
5 |
* @package OptionTree |
0
|
6 |
*/ |
|
7 |
|
11
|
8 |
if ( ! defined( 'OT_VERSION' ) ) { |
|
9 |
exit( 'No direct script access allowed' ); |
|
10 |
} |
|
11 |
|
0
|
12 |
if ( ! function_exists( 'get_option_tree' ) ) { |
|
13 |
|
11
|
14 |
/** |
|
15 |
* Displays or returns a value from the 'option_tree' array. |
|
16 |
* |
|
17 |
* @param string $item_id The item ID. |
|
18 |
* @param array $options Options array. |
|
19 |
* @param bool $echo Whether to echo or return value. |
|
20 |
* @param bool $is_array Whether the value option is an array or string. |
|
21 |
* @param int $offset The array key. |
|
22 |
* @return mixed Array or comma separated lists of values. |
|
23 |
* |
|
24 |
* @access public |
|
25 |
* @since 1.0.0 |
|
26 |
* @updated 2.0 |
|
27 |
* @deprecated 2.0 |
|
28 |
*/ |
|
29 |
function get_option_tree( $item_id = '', $options = array(), $echo = false, $is_array = false, $offset = -1 ) { |
|
30 |
|
|
31 |
// Load saved options. |
|
32 |
if ( ! $options ) { |
|
33 |
$options = get_option( ot_options_id() ); |
|
34 |
} |
0
|
35 |
|
11
|
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 |
} |
0
|
66 |
} |
|
67 |
|
|
68 |
if ( ! function_exists( 'option_tree_stripslashes' ) ) { |
|
69 |
|
11
|
70 |
/** |
|
71 |
* Custom stripslashes from single value or array. |
|
72 |
* |
|
73 |
* @param mixed $input Input string or array. |
|
74 |
* @return mixed |
|
75 |
* |
|
76 |
* @access public |
|
77 |
* @since 1.1.3 |
|
78 |
* @deprecated 2.0 |
|
79 |
*/ |
|
80 |
function option_tree_stripslashes( $input ) { |
|
81 |
if ( is_array( $input ) ) { |
|
82 |
foreach ( $input as &$val ) { |
|
83 |
if ( is_array( $val ) ) { |
|
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 |
} |
0
|
94 |
} |