示例#1
0
/**
 * Custom stripslashes from single value or array.
 *
 * @uses stripslashes()
 *
 * @access public
 * @since 1.1.3
 *
 * @param mixed $input
 *
 * @return mixed
 */
function option_tree_stripslashes($input)
{
    if (is_array($input)) {
        foreach ($input as &$val) {
            if (is_array($val)) {
                $val = option_tree_stripslashes($val);
            } else {
                $val = stripslashes($val);
            }
        }
    } else {
        $input = stripslashes($input);
    }
    return $input;
}
示例#2
0
 function get_option_tree_c($item_id = '', $echo = false, $before = '', $after = '', $link = false, $image = false)
 {
     $options = get_option('option_tree');
     // no value return
     if (!isset($options[$item_id]) || empty($options[$item_id])) {
         return;
     }
     // set content value & strip slashes
     $content = option_tree_stripslashes($options[$item_id]);
     /*
      * IMAGE
      * $image = array (
      *  'title' => 'Foo'
      * )
      */
     if (!empty($image)) {
         $content = '<img src="' . $content . '" alt="' . $image['alt'] . '" title="' . $image['alt'] . '" />';
     }
     /*
      * LINK 
      *
      * $link = array( 
      *  'href' => true || 'http://www.site.com',
      *  'target_blank' => true || false,
      *  'content' => true || 'Foo',
      *  'id' => 'Foo'
      * )
      */
     if (!empty($link) || $link['href']) {
         $href = $link === true || $link['href'] === true ? option_tree_stripslashes($options[$item_id]) : $link['href'];
         $anchor_id = $link['id'] ? ' id="' . $link['id'] . '"' : '';
         $anchor_class = $link['class'] ? ' class="' . $link['class'] . '"' : '';
         $target_blank = $link['target_blank'] ? ' target="_blank"' : '';
         $link_content = $link === true || $link['content'] === true ? $content : $link['content'];
         $content = '<a href="' . $href . '"' . $anchor_id . $anchor_class . $target_blank . '>' . $link_content . '</a>';
     }
     // befor and after
     $content = $before . $content . $after;
     // echo content
     if ($echo === true) {
         echo $content;
     } else {
         return $content;
     }
 }