$default_background_color, )); /** * Add Thumbnails support */ if (function_exists('add_theme_support')) { add_theme_support('post-thumbnails'); add_image_size('imaj', 106, 106, true); add_image_size('slider', 980, 179, true); } /** * Register Navigation Menus */ if (function_exists('wp_nav_menu')) { if (function_exists('add_theme_support')) { add_theme_support('nav-menus'); add_action('init', 'register_my_menus'); function register_my_menus() { register_nav_menus(array('top-links'=>__('Top Links', 'bluenight'), 'main-menu'=>__('Main Menu', 'bluenight'), 'footer-links'=>__('Footer Links', 'bluenight'))); } } } add_action('admin_menu', 'bluenight_theme_page'); add_action('widgets_init', 'theme_widgets_init'); register_widget('Widget_Recent_Avatar_Comments'); register_widget('Widget_Popular_Posts'); add_filter('excerpt_length', 'custom_excerpt_length'); add_filter('excerpt_more', 'new_excerpt_more'); add_action('template_redirect', 'ajax_comments'); add_action('template_redirect', 'ajax_recentcomments'); } endif; /** * Languages Initialization */ if (!function_exists('theme_languages_init')): function theme_languages_init(){ load_theme_textdomain('bluenight', get_template_directory() . '/languages'); } endif; /** * Widgets Initialization */ if (!function_exists('theme_widgets_init')): function theme_widgets_init() { if (function_exists('register_sidebar')){ register_sidebar( array( 'name'=>'Right Sidebar', 'before_widget'=>'', 'before_title'=>'

', 'after_title'=>'

', ) ); } if (function_exists('register_sidebar')){ register_sidebar( array( 'name'=>'Footer', 'before_widget'=>'', 'before_title'=>'

', 'after_title'=>'

', ) ); } } endif; /* BlueNight Panel */ if (!function_exists('bluenight_theme_page')): function bluenight_theme_page () { global $themename; if ( count($_POST) > 0 && isset($_POST['bluenight_settings']) ) { $options = array ( 'logo_img','logo_alt','logo_txt', 'logo_tagline', 'tagline_width', 'contact_email', 'twitter_link', 'facebook_link', 'lazy_load_photos', 'video_per_page', 'video_layout', 'gb_comments_num', 'about_tit', 'about_txt','sidebar_pos','excerpt_length','related_posts_orderby','paginate_num','featured', 'slide_cat', 'slide_num', 'slide','ss_color'); foreach ( $options as $opt ) { delete_option ( 'bluenight_'.$opt, $_POST[$opt] ); add_option ( 'bluenight_'.$opt, $_POST[$opt] ); } } add_theme_page("BlueNight Panel", "BlueNight Panel", 'edit_themes', basename(__FILE__), 'bluenight_settings'); } endif; if (!function_exists('bluenight_settings')): function bluenight_settings (){ global $themename, $shortname, $options; ?>

Options Panel

General Settings

Leave this empty if you entered an image as logo
Page layout options
(default: 70)
Video Category
Fetaured Posts

'recent_avatar_comments', 'description' => __( 'The most recent comments on your site.','bluenight' ) ); parent::__construct('recent-avatar-comments', __('Recent Comments (BlueNight)','bluenight'), $widget_ops); $this->alt_option_name = 'recent_avatar_comments'; add_action( 'comment_post', array(&$this, 'flush_widget_cache') ); add_action( 'transition_comment_status', array(&$this, 'flush_widget_cache') ); } function flush_widget_cache() { wp_cache_delete('recent_avatar_comments', 'widget'); } function widget( $args, $instance) { global $comments, $comment; $cache = wp_cache_get('recent_avatar_comments', 'widget'); if ( ! is_array( $cache ) ) { $cache = array(); } if ( ! isset( $args['widget_id'] ) ) { $args['widget_id'] = $this->id; } if ( isset( $cache[ $args['widget_id'] ] ) ) { echo $cache[ $args['widget_id'] ]; return; } extract($args, EXTR_SKIP); $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Recent Comments (BlueNight)', 'bluenight' ) : $instance['title'], $instance, $this->id_base ); if ( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) ) { $number = get_option('comments_per_page'); } $output = ''; $output .= $before_widget; if ( $title ) { $output .= $before_title . $title . $after_title; } $output .= '
'; $output .= recentcomments($number, NULL, $recentcomments_pager_id, NULL); $output .= '
'; $output .= $after_widget; echo $output; $cache[$args['widget_id']] = $output; wp_cache_set('recent_avatar_comments', $cache, 'widget'); } function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = strip_tags($new_instance['title']); $instance['number'] = absint( $new_instance['number'] ); $this->flush_widget_cache(); $alloptions = wp_cache_get( 'alloptions', 'options' ); if ( isset($alloptions['recent_avatar_comments']) ){ delete_option('recent_avatar_comments'); } return $instance; } function form( $instance ) { $title = isset($instance['title']) ? esc_attr($instance['title']) : ''; $number = isset($instance['number']) ? absint($instance['number']) : 5; ?>

'popular_post', 'description' => __( "The most popular posts on your site.", "bluenight") ); parent::__construct('popular-posts', __('Popular Posts','bluenight'), $widget_ops); $this->alt_option_name = 'popular_post'; add_action( 'save_post', array(&$this, 'flush_widget_cache') ); add_action( 'deleted_post', array(&$this, 'flush_widget_cache') ); add_action( 'switch_theme', array(&$this, 'flush_widget_cache') ); } function form($instance){ $title = isset($instance['title']) ? esc_attr($instance['title']) : ''; $number = isset($instance['number']) ? absint($instance['number']) : 5; $excerpt_number = isset($instance['excerpt_number']) ? absint($instance['excerpt_number']) : 50; $posts_orderby = isset($instance['posts_orderby']) ? esc_attr($instance['posts_orderby']) : 'comment_count'; ?>

flush_widget_cache(); $alloptions = wp_cache_get( 'alloptions', 'options' ); if ( isset($alloptions['popular_post']) ){ delete_option('popular_post'); } return $instance; } function flush_widget_cache() { wp_cache_delete('popular_posts', 'widget'); } function widget($args, $instance){ extract($args, EXTR_SKIP); echo $before_widget; $title = empty($instance['title']) ? __('Popular Posts','bluenight') : apply_filters('widget_title', $instance['title']); $posts_orderby = empty($instance['posts_orderby']) ? 'comment_count' : $instance['posts_orderby']; if (!empty($title)){ echo $before_title . $title . $after_title;; } if ( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) ){ $number = 5; } if ( empty( $instance['excerpt_number'] ) || ! $excerpt_number = absint( $instance['excerpt_number'] ) ){ $excerpt_number = 50; } // Show Popular Post ?>

'; $current_after = '

'; $delimiter = '»'; $home = 'Home'; // text for the 'Home' link $before = ''; // tag before the current crumb $after = ''; // tag after the current crumb if (!is_home() && !is_front_page() || is_paged()) { echo $current_before; global $post; $homeLink = home_url('/'); echo ''.$home.' '.$delimiter.' '; if (is_category()) { global $wp_query; $cat_obj = $wp_query->get_queried_object(); $thisCat = $cat_obj->term_id; $thisCat = get_category($thisCat); $parentCat = get_category($thisCat->parent); if ($thisCat->parent != 0) { echo(get_category_parents($parentCat, TRUE, ' '.$delimiter.' ')); } echo $before.'Archive by category "'.single_cat_title('', false).'"'.$after; } elseif (is_day()) { echo ''.get_the_time('Y').' '.$delimiter.' '; echo ''.get_the_time('m').' '.$delimiter.' '; echo $before.get_the_time('j').$after; } elseif (is_month()) { echo ''.get_the_time('Y').' '.$delimiter.' '; echo $before.get_the_time('m').$after; } elseif (is_year()) { echo $before.get_the_time('Y').$after; } elseif (is_single() && !is_attachment()) { if (get_post_type() != 'post') { $post_type = get_post_type_object(get_post_type()); $slug = $post_type->rewrite; echo ''.$post_type->labels->singular_name.' '.$delimiter.' '; echo $before.get_the_title().$after; } else { $cat = get_the_category(); $cat = $cat[0]; echo get_category_parents($cat, TRUE, ' '.$delimiter.' '); echo $before.get_the_title().$after; } } elseif (!is_single() && !is_page() && get_post_type() != 'post') { $post_type = get_post_type_object(get_post_type()); echo $before.$post_type->labels->singular_name.$after; } elseif (is_attachment()) { $parent = get_post($post->post_parent); $cat = get_the_category($parent->ID); $cat = $cat[0]; echo get_category_parents($cat, TRUE, ' '.$delimiter.' '); echo ''.$parent->post_title.' '.$delimiter.' '; echo $before.get_the_title().$after; } elseif (is_page() && !$post->post_parent) { echo $before.get_the_title().$after; } elseif (is_page() && $post->post_parent) { $parent_id = $post->post_parent; $breadcrumbs = array(); while ($parent_id) { $page = get_page($parent_id); $breadcrumbs[] = ''.get_the_title($page->ID).''; $parent_id = $page->post_parent; } $breadcrumbs = array_reverse($breadcrumbs); foreach ($breadcrumbs as $crumb){ echo $crumb.' '.$delimiter.' '; } echo $before.get_the_title().$after; } elseif (is_search()) { echo $before.'Search results for "'.get_search_query().'"'.$after; } elseif (is_tag()) { echo $before.'Posts tagged "'.single_tag_title('', false).'"'.$after; } elseif (is_author()) { global $author; $userdata = get_userdata($author); echo $before.'Articles posted by '.$userdata->display_name.$after; } elseif (is_404()) { echo $before.'Error 404'.$after; } if (get_query_var('paged')) { if (is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author()){ echo ' ('; } echo 'Page '.get_query_var('paged'); if (is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author()){ echo ')'; } } echo $current_after; } else{ if(is_home() && is_front_page()){ echo $current_before.''.get_option('blogname').' '.$delimiter.' '.$before.$home.$after.$current_after; } } } endif; /** * Paginate */ if (!function_exists('paginate')): function paginate($args = null) { $range_gap = 3; if (get_option('bluenight_paginate_num') != '' && intval(get_option('bluenight_paginate_num')) > 0) { $range_gap = intval(get_option('bluenight_paginate_num')); } $defaults = array( 'page' => null, 'pages' => null, 'range' => $range_gap, 'gap' => $range_gap, 'anchor' => 1, 'echo' => 1 ); $r = wp_parse_args($args, $defaults); extract($r, EXTR_SKIP); if (!$page && !$pages) { global $wp_query; $page = get_query_var('paged'); $page = !empty($page) ? intval($page) : 1; $posts_per_page = intval(get_query_var('posts_per_page')); $pages = intval(ceil($wp_query->found_posts / $posts_per_page)); } $output = ""; if ($pages > 1) { $ellipsis = "..."; $min_links = $range * 2 + 1; $block_min = min($page - $range, $pages - $min_links); $block_high = max($page + $range, $min_links); $left_gap = (($block_min - $anchor - $gap) > 0) ? true : false; $right_gap = (($block_high + $anchor + $gap) < $pages) ? true : false; if ($left_gap && !$right_gap) { $output .= sprintf('%s%s%s', paginate_loop(1, $anchor), $ellipsis, paginate_loop($block_min, $pages, $page) ); } else if ($left_gap && $right_gap) { $output .= sprintf('%s%s%s%s%s', paginate_loop(1, $anchor), $ellipsis, paginate_loop($block_min, $block_high, $page), $ellipsis, paginate_loop(($pages - $anchor + 1), $pages) ); } else if ($right_gap && !$left_gap) { $output .= sprintf('%s%s%s', paginate_loop(1, $block_high, $page), $ellipsis, paginate_loop(($pages - $anchor + 1), $pages) ); } else { $output .= paginate_loop(1, $pages, $page); } } if ($echo) { echo $output; } return $output; } endif; if (!function_exists('paginate_loop')): function paginate_loop($start, $max, $page = 0) { $output = ""; for ($i = $start; $i <= $max; $i++) { $output .= ($page === intval($i)) ? "$i" : "$i"; } return $output; } endif; if (!function_exists('show_paginate')): function show_paginate() { ?>
null, 'pages' => null, 'per_page' => 5, 'range' => 2, 'gap' => 2, 'anchor' => 1, 'nextpage' => __('« Older Comments','bluenight'), 'previouspage' => __('Newer Comments »', 'bluenight'), 'echo' => 0 ); $r = wp_parse_args($args, $defaults); extract($r, EXTR_SKIP); $page = $args['page']; $page = !empty($page) ? intval($page) : 1; $posts_per_page = $args['per_page']; $pages = intval(ceil(get_comments(array('count'=>true, 'status' => 'approve', 'post_status' => 'publish')) / $posts_per_page)); $output = ""; if ($pages > 1) { if ($page > 1 && !empty($previouspage)) { $output .= "$previouspage"; } if ($page < $pages && !empty($nextpage)) { $output .= "$nextpage"; } } if ($echo) { echo $output; } return $output; } endif; /* Video */ if (!function_exists('is_video')): function is_video(){ $category = get_category(get_query_var('cat'))->slug; if($category=='video'){ return true; } else{ return false; } } endif; if (!function_exists('show_videos')): function show_videos(){ ?>

Video

'.$category_description.''); } } elseif (is_tag()) { // show an optional tag description $tag_description = tag_description(); if (! empty($tag_description)){ echo apply_filters('tag_archive_meta', '
'.$tag_description.'
'); } } } endif; /** * Show post excerpt items */ if (!function_exists('show_post_item')): function show_post_item() { $video_layout = get_option('bluenight_video_layout'); // Video items if(is_video() && $video_layout!=''){ ?>
  • >

    '.$key.'',get_the_title()); } else{ the_title(); } ?>

      

    ', '' ); ?>

    '.__('View:', 'bluenight').$count.''; if (is_video()) { $post_views = ''.$count.''; } if ($count == '') { delete_post_meta($postID, $count_key); add_post_meta($postID, $count_key, '0'); $post_views = __('View: 0', 'bluenight'); } return $post_views; } endif; /** * Update post view count */ if (!function_exists('set_post_views')): function set_post_views($postID) { $count_key = 'post_views_count'; $count = get_post_meta($postID, $count_key, true); if($count==''){ $count = 0; delete_post_meta($postID, $count_key); add_post_meta($postID, $count_key, '0'); }else{ $count++; update_post_meta($postID, $count_key, $count); } } endif; /** * Format Content (remove All images) */ if (!function_exists('content')): function content($num) { $theContent = get_the_content(); $output = preg_replace('/]+./','', $theContent); $limit = $num+1; $content = explode(' ', $output, $limit); array_pop($content); $content = implode(" ",$content)."..."; echo $content; } endif; if (!function_exists('get_search_excerpt')): function get_search_excerpt($key, $content) { $keys = preg_split('/[\s,+]+/', $key); $reg_keys = array(); foreach($keys as $reg_key){ $reg_keys[] = '/('.$reg_key.')/i'; } $content_length = mb_strlen($content, 'utf8'); $posArray = array(); $replaceKeys = array(); foreach ($keys as $keyword) { $posArray[] = mb_stripos($content, $keyword, 1, 'utf8'); $replaceKeys[] = ''.$keyword.''; } sort($posArray); for ($i = 0; $i < count($posArray); $i++) { if ($posArray[$i]) { $pos = $posArray[$i]; break; } } $excerpt_length = get_option('bluenight_excerpt_length'); if ($excerpt_length == '' || intval($excerpt_length) <= 0) { $excerpt_length = 70; } else { $excerpt_length = intval(get_option('bluenight_excerpt_length')); } if ($pos) { if ($pos > 1) { if ($content_length < $excerpt_length) { $content = mb_substr($content, 0, $content_length - 1, 'utf8'); } else { if ($content_length >= $excerpt_length) { $content = mb_substr($content, $pos - 1, $excerpt_length, 'utf8'); } } } else { if ($content_length < $excerpt_length) { $content = mb_substr($content, 0, $content_length - 1, 'utf-8'); } else { if ($content_length >= $excerpt_length) { $content = mb_substr($content, 0, $excerpt_length, 'utf-8'); } } } $content = '

    '.preg_replace($reg_keys, $replaceKeys, $content).new_excerpt_more().'

    '; } else { $content = '

    '.get_the_excerpt().'

    '; } return $content; } endif; if (!function_exists('get_search_results_count')): function get_search_results_count(){ global $wp_query; return $wp_query->found_posts; } endif; if (!function_exists('poular_excerpt')): function poular_excerpt($length) { $excerpt = get_the_excerpt(); $charlength = 50; if ($length) { $charlength = $length; } if (mb_strlen($excerpt) > $charlength) { $subex = mb_substr($excerpt, 0, $charlength - 9); echo $subex.new_excerpt_more(); } else { echo $excerpt; } } endif; /** * Format Post Excerpt */ if (!function_exists('custom_excerpt_length')): function custom_excerpt_length($length) { $strLength = 70; if(get_option('bluenight_excerpt_length') !='' && intval(get_option('bluenight_excerpt_length')) > 0) { $strLength = intval(get_option('bluenight_excerpt_length')); } return $strLength; } endif; if (!function_exists('new_excerpt_more')): function new_excerpt_more($more) { global $post; return '... ['.__('Read more','bluenight').']'; } endif; /** * Related Post */ if (!function_exists('related_post')): function related_post(){ ?>

    <?php the_title(); ?>

    $slug_class) ); ?> <?php the_title(); ?> <?php the_title(); ?> $number, 'offset'=>(intval($pageID) - 1) * $number, 'status'=>'approve', 'post_status'=>'publish'))); } else{ $comments = get_comments( apply_filters( 'widget_comments_args', array('number' => $number, 'status' => 'approve', 'post_status' => 'publish' ) ) ); } $output = ''; $output .= ''; $output .= '

    '.comments_paginate(array('page'=>$pageID, 'per_page'=>$number)).'

    '; if ($echo) { echo $output; } return $output; } endif; if (!function_exists('articlecomments')): function articlecomments($postID, $pageID, $perPage) { // Get comments by post_id $comments = get_comments('post_id='.$postID); $args = array('current'=>$pageID, 'echo'=>true); $comments_per_page = get_option('comments_per_page'); if($perPage){ $comments_per_page = $perPage; } echo ''; echo '

    '; $comment_pages = paginate_comments_links($args); echo $comment_pages.'

    '; } endif; if (!function_exists('comments_items')): function comments_items($comment, $args, $depth) { $GLOBALS['comment'] = $comment; ?>
  • id="li-comment-">
    comment_approved == '0') : ?>