wp/wp-content/plugins/option-tree/includes/ot-functions-deprecated.php
changeset 0 d970ebf37754
child 5 5e2f62d02dcd
equal deleted inserted replaced
-1:000000000000 0:d970ebf37754
       
     1 <?php if ( ! defined( 'OT_VERSION' ) ) exit( 'No direct script access allowed' );
       
     2 /**
       
     3  * OptionTree deprecated functions
       
     4  *
       
     5  * @package   OptionTree
       
     6  * @author    Derek Herman <derek@valendesigns.com>
       
     7  * @copyright Copyright (c) 2013, Derek Herman
       
     8  * @since     2.0
       
     9  */
       
    10 
       
    11 /**
       
    12  * Displays or returns a value from the 'option_tree' array.
       
    13  *
       
    14  * @param       string    $item_id
       
    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' ) ) {
       
    27 
       
    28   function get_option_tree( $item_id = '', $options = '', $echo = false, $is_array = false, $offset = -1 ) {
       
    29     /* load saved options */
       
    30     if ( ! $options )
       
    31       $options = get_option( 'option_tree' );
       
    32     
       
    33     /* no value return */
       
    34     if ( ! isset( $options[$item_id] ) || empty( $options[$item_id] ) )
       
    35       return;
       
    36     
       
    37     /* set content value & strip slashes */
       
    38     $content = option_tree_stripslashes( $options[$item_id] );
       
    39     
       
    40     /* is an array */
       
    41     if ( $is_array == true ) {
       
    42       /* saved as a comma seperated lists of values, explode into an array */
       
    43       if ( !is_array( $content ) )
       
    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 
       
    67 }
       
    68 
       
    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' ) ) {
       
    80 
       
    81   function option_tree_stripslashes( $input ) {
       
    82     if ( is_array( $input ) ) {
       
    83       foreach( $input as &$val ) {
       
    84         if ( is_array( $val ) ) {
       
    85           $val = option_tree_stripslashes( $val );
       
    86         } else {
       
    87           $val = stripslashes( $val );
       
    88         }
       
    89       }
       
    90     } else {
       
    91       $input = stripslashes( $input );
       
    92     }
       
    93     return $input;
       
    94   }
       
    95 
       
    96 }
       
    97 
       
    98 /* End of file ot-functions-deprecated.php */
       
    99 /* Location: ./includes/ot-functions-deprecated.php */