get_queried_object(); if ( isset( $page_obj->ID ) && $page_obj->ID >= 0 ) return $page_obj->ID; return -1; } /** * Get custom field of the current page * $type = string|int */ function sienna_get_custom_field($filedname, $id = NULL, $single=true) { global $post; if($id==NULL) $id = get_the_ID(); if($id==NULL) $id = sienna_get_page_id(); $value = get_post_meta($id, $filedname, $single); if($single) return stripslashes($value); else return $value; } /** * Get Limited String * $output = string * $max_char = int */ function sienna_get_limited_string($output, $max_char=100, $end='...') { $output = str_replace(']]>', ']]>', $output); $output = strip_tags($output); $output = strip_shortcodes($output); if ((strlen($output)>$max_char) && ($espacio = strpos($output, " ", $max_char ))) { $output = substr($output, 0, $espacio).$end; return $output; } else { return $output; } } /** * Tests if any of a post's assigned categories are descendants of target categories * * @param mixed $cats The target categories. Integer ID or array of integer IDs * @param mixed $_post The post * @return bool True if at least 1 of the post's categories is a descendant of any of the target categories * @see get_term_by() You can get a category by name or slug, then pass ID to this function * @uses get_term_children() Gets descendants of target category * @uses in_category() Tests against descendant categories * @version 2.7 */ function sienna_post_is_in_descendant_category( $cats, $_post = null ) { foreach ( (array) $cats as $cat ) { // get_term_children() accepts integer ID only $descendants = get_term_children( (int) $cat, 'category'); if ( $descendants && in_category( $descendants, $_post ) ) return true; } return false; } /** * Twitter's Blogger.js output for Twitter widgets * $unique_id = string * $username = string * limit = int */ function sienna_twitter_script($unique_id,$username,$limit) { ?>
  • id="li-comment-">
    comment_approved == '0') : ?>

    $depth, 'max_depth' => $args['max_depth']))) ?>
    '; $after_widget = ''; $before_title = '

    '; $after_title = '

    '; register_sidebar(array('name' => __('Sidebar Middle','sienna_wdl'),'id' => 'sidebar-middle','before_widget' => $before_widget,'after_widget' => $after_widget,'before_title' => $before_title,'after_title' => $after_title)); } /** * Filter for get_the_excerpt */ function sienna_get_the_excerpt($content){ return str_replace(' [...]','',$content); } /** * Get the sidebar ID */ function sienna_get_sidebar_id(){ global $post; $sidebar_id = 'sidebar-default'; if(isset($post->ID)) if(is_active_sidebar('sidebar-'.$post->ID)) $sidebar_id = 'sidebar-'.$post->ID; return $sidebar_id; } /** * Improved Wordpress page menu function */ function sienna_wp_page_menu( $args = array() ) { $defaults = array('sort_column' => 'menu_order, post_title', 'menu_id' => 'menu', 'menu_class' => 'menu', 'echo' => true, 'link_before' => '', 'link_after' => '', 'show_home' => 1); $args = wp_parse_args( $args, $defaults ); $args = apply_filters( 'wp_page_menu_args', $args ); $menu = ''; $list_args = $args; // Show Home in the menu if ( ! empty($args['show_home']) ) { if ( true === $args['show_home'] || '1' === $args['show_home'] || 1 === $args['show_home'] ) $text = __('Home','sienna_wdl'); else $text = $args['show_home']; $class = ''; if ( is_front_page() && !is_paged() ) $class = 'class="current_page_item"'; $menu .= '
  • ' . $args['link_before'] . $text . $args['link_after'] . '
  • '; // If the front page is a page, add it to the exclude list if (get_option('show_on_front') == 'page') { if ( !empty( $list_args['exclude'] ) ) { $list_args['exclude'] .= ','; } else { $list_args['exclude'] = ''; } $list_args['exclude'] .= get_option('page_on_front'); } } $list_args['echo'] = false; $list_args['title_li'] = ''; $menu .= str_replace( array( "\r", "\n", "\t" ), '', wp_list_pages($list_args) ); if ( $menu ) $menu = ''; $menu = apply_filters( 'wp_page_menu', $menu, $args ); if ( $args['echo'] ) echo $menu; else return $menu; } function sienna_theme_ads_show() { global $sienna_option; $count = $sienna_option['main']['number_125_ads']; if($count>0) { for($i=1; $i<=$count; $i++) { if(!empty($sienna_option['main']['ad_125_link'.$i]) && !empty($sienna_option['main']['ad_125_image'.$i])) { ?>