urlencode( implode( '|', $fonts ) ), 'subset' => urlencode( $subsets ), ), '//fonts.googleapis.com/css' ); } return $fonts_url; } } // completion of enqueue for the google font function colornews_scripts() { // use of enqueued google fonts wp_enqueue_style( 'colornews-google-fonts', colornews_fonts_url(), array(), null ); wp_enqueue_style( 'colornews-style', get_stylesheet_uri() ); wp_enqueue_style( 'colornews-fontawesome', get_template_directory_uri().'/font-awesome/css/font-awesome.min.css', array(), '4.4.0' ); //Register bxSlider js file for slider. wp_register_script( 'colornews-bxslider', COLORNEWS_JS_URL . '/jquery.bxslider/jquery.bxslider.min.js', array( 'jquery' ), '4.1.2', true ); if (get_theme_mod('colornews_primary_sticky_menu', 0) == 1) { wp_register_script( 'colornews-sticky-menu', COLORNEWS_JS_URL. '/sticky/jquery.sticky.js', array( 'jquery' ), '20150708', true ); wp_enqueue_script( 'colornews-sticky-menu-setting', COLORNEWS_JS_URL. '/sticky/sticky-setting.js', array( 'colornews-sticky-menu' ), '20150708', true ); } if ( get_theme_mod( 'colornews_breaking_news', 0 ) == 1 ) { wp_register_script( 'colornews-tickerme', COLORNEWS_JS_URL . '/tickerme/tickerme.min.js', array( 'jquery' ), '20150708', true ); wp_enqueue_script( 'colornews-tickerme-setting', COLORNEWS_JS_URL . '/tickerme/ticker-setting.js', array( 'colornews-tickerme' ), '20150708', true ); } // register magnific popup wp_register_script( 'colornews-magnific-popup', COLORNEWS_JS_URL . '/magnific-popup/jquery.magnific-popup.min.js', array( 'jquery' ), '20150714', true ); wp_enqueue_style( 'colornews-featured-image-popup-css', COLORNEWS_JS_URL.'/magnific-popup/magnific-popup.css', array(), '20150714' ); // enqueue image popup wp_enqueue_script( 'colornews-featured-image-popup-setting', COLORNEWS_JS_URL. '/magnific-popup/image-popup-setting.js', array( 'colornews-magnific-popup' ), '20150714', true ); // enqueueing fitvids for responsive videos wp_enqueue_script( 'colornews-fitvids', COLORNEWS_JS_URL. '/fitvids/jquery.fitvids.js', array( 'jquery' ), '1.1', true ); // enqueueing our custom script code wp_enqueue_script( 'colornews-custom', COLORNEWS_JS_URL . '/custom.js', array( 'colornews-bxslider' ), '20150708', true ); // enqueue of custom post-format script if( get_post_format() || is_archive() || is_search() || is_home() ) { wp_enqueue_script( 'colornews-postformat-setting', COLORNEWS_JS_URL. '/post-format.js', array( 'jquery' ), '20150716', true ); } wp_enqueue_script( 'colornews-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20130115', true ); $colornews_user_agent = strtolower($_SERVER['HTTP_USER_AGENT']); if(preg_match('/(?i)msie [1-8]/',$colornews_user_agent)) { wp_enqueue_script( 'html5', COLORNEWS_JS_URL . '/html5shiv.min.js', true ); } if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } } add_action( 'wp_enqueue_scripts', 'colornews_scripts' ); // function to enqueue the image uploader script function colornews_image_uploader() { wp_enqueue_media(); wp_enqueue_script('colornews-widget-image-upload', COLORNEWS_JS_URL . '/image-uploader.js', false, '20150708', true); } add_action('admin_enqueue_scripts', 'colornews_image_uploader'); /****************************************************************************************/ add_filter( 'excerpt_length', 'colornews_excerpt_length' ); /** * Sets the post excerpt length to 40 words. * * function tied to the excerpt_length filter hook. * * @uses filter excerpt_length */ function colornews_excerpt_length( $length ) { return 24; } add_filter( 'excerpt_more', 'colornews_continue_reading' ); /** * Returns a "Continue Reading" link for excerpts */ function colornews_continue_reading() { return ''; } /****************************************************************************************/ /** * Removing the default style of wordpress gallery */ add_filter( 'use_default_gallery_style', '__return_false' ); /** * Filtering the size to be full from thumbnail to be used in WordPress gallery as a default size */ function colornews_gallery_atts( $out, $pairs, $atts ) { $atts = shortcode_atts( array( 'size' => 'colornews-featured-image', ), $atts ); $out['size'] = $atts['size']; return $out; } add_filter( 'shortcode_atts_gallery', 'colornews_gallery_atts', 10, 3 ); /****************************************************************************************/ add_filter( 'body_class', 'colornews_body_class' ); /** * Filter the body_class * * Throwing different body class for the different layouts in the body tag */ function colornews_body_class( $classes ) { global $post; if( $post ) { $layout_meta = get_post_meta( $post->ID, 'colornews_page_layout', true ); } if( is_home() ) { $queried_id = get_option( 'page_for_posts' ); $layout_meta = get_post_meta( $queried_id, 'colornews_page_layout', true ); } if( empty( $layout_meta ) || is_archive() || is_search() ) { $layout_meta = 'default_layout'; } $colornews_default_layout = get_theme_mod( 'colornews_default_layout', 'right_sidebar' ); $colornews_default_page_layout = get_theme_mod( 'colornews_default_page_layout', 'right_sidebar' ); $colornews_default_post_layout = get_theme_mod( 'colornews_default_single_posts_layout', 'right_sidebar' ); if( $layout_meta == 'default_layout' ) { if( is_page() ) { if( $colornews_default_page_layout == 'right_sidebar' ) { $classes[] = ''; } elseif( $colornews_default_page_layout == 'left_sidebar' ) { $classes[] = 'left-sidebar'; } elseif( $colornews_default_page_layout == 'no_sidebar_full_width' ) { $classes[] = 'no-sidebar-full-width'; } elseif( $colornews_default_page_layout == 'no_sidebar_content_centered' ) { $classes[] = 'no-sidebar'; } } elseif( is_single() ) { if( $colornews_default_post_layout == 'right_sidebar' ) { $classes[] = ''; } elseif( $colornews_default_post_layout == 'left_sidebar' ) { $classes[] = 'left-sidebar'; } elseif( $colornews_default_post_layout == 'no_sidebar_full_width' ) { $classes[] = 'no-sidebar-full-width'; } elseif( $colornews_default_post_layout == 'no_sidebar_content_centered' ) { $classes[] = 'no-sidebar'; } } elseif( $colornews_default_layout == 'right_sidebar' ) { $classes[] = ''; } elseif( $colornews_default_layout == 'left_sidebar' ) { $classes[] = 'left-sidebar'; } elseif( $colornews_default_layout == 'no_sidebar_full_width' ) { $classes[] = 'no-sidebar-full-width'; } elseif( $colornews_default_layout == 'no_sidebar_content_centered' ) { $classes[] = 'no-sidebar'; } } elseif( $layout_meta == 'right_sidebar' ) { $classes[] = ''; } elseif( $layout_meta == 'left_sidebar' ) { $classes[] = 'left-sidebar'; } elseif( $layout_meta == 'no_sidebar_full_width' ) { $classes[] = 'no-sidebar-full-width'; } elseif( $layout_meta == 'no_sidebar_content_centered' ) { $classes[] = 'no-sidebar'; } if( get_theme_mod( 'colornews_site_layout', 'boxed_layout' ) == 'wide_layout' ) { $classes[] = 'wide'; } elseif( get_theme_mod( 'colornews_site_layout', 'boxed_layout' ) == 'boxed_layout' ) { $classes[] = 'boxed-layout'; } return $classes; } /****************************************************************************************/ if ( ! function_exists( 'colornews_sidebar_select' ) ) : /** * Function to select the sidebar */ function colornews_sidebar_select() { global $post; if( $post ) { $layout_meta = get_post_meta( $post->ID, 'colornews_page_layout', true ); } if( is_home() ) { $queried_id = get_option( 'page_for_posts' ); $layout_meta = get_post_meta( $queried_id, 'colornews_page_layout', true ); } if( empty( $layout_meta ) || is_archive() || is_search() ) { $layout_meta = 'default_layout'; } $colornews_default_layout = get_theme_mod( 'colornews_default_layout', 'right_sidebar' ); $colornews_default_page_layout = get_theme_mod( 'colornews_default_page_layout', 'right_sidebar' ); $colornews_default_post_layout = get_theme_mod( 'colornews_default_single_posts_layout', 'right_sidebar' ); if( $layout_meta == 'default_layout' ) { if( is_page() ) { if( $colornews_default_page_layout == 'right_sidebar' ) { get_sidebar(); } elseif ( $colornews_default_page_layout == 'left_sidebar' ) { get_sidebar( 'left' ); } } if( is_single() ) { if( $colornews_default_post_layout == 'right_sidebar' ) { get_sidebar(); } elseif ( $colornews_default_post_layout == 'left_sidebar' ) { get_sidebar( 'left' ); } } elseif( $colornews_default_layout == 'right_sidebar' ) { get_sidebar(); } elseif ( $colornews_default_layout == 'left_sidebar' ) { get_sidebar( 'left' ); } } elseif( $layout_meta == 'right_sidebar' ) { get_sidebar(); } elseif( $layout_meta == 'left_sidebar' ) { get_sidebar( 'left' ); } } endif; /**************************************************************************************/ /* * Category Color Options */ if ( ! function_exists( 'colornews_category_color' ) ) : function colornews_category_color( $wp_category_id ) { $args = array( 'orderby' => 'id', 'hide_empty' => 0 ); $category = get_categories( $args ); foreach ($category as $category_list ) { $color = get_theme_mod('colornews_category_color_'.$wp_category_id); return $color; } } endif; /**************************************************************************************/ /* * Category Color Display Settings */ if ( !function_exists('colornews_colored_category_return') ) : function colornews_colored_category_return($display) { global $post; $categories = get_the_category(); $separator = ' '; $output = ''; if($categories) { $output .= '
'; foreach($categories as $category) { $color_code = colornews_category_color(get_cat_id($category->cat_name)); if (!empty($color_code)) { $output .= ''.$category->cat_name.''.$separator; } else { $output .= ''.$category->cat_name.''.$separator; } } $output .='
'; if ( $display == 0 ) { $output = trim($output, $separator); } if ( $display == 1 ) { echo trim($output, $separator); } } if ( $display == 0 ) { return $output; } } endif; /**************************************************************************************/ /* * Breaking News/Latest Posts ticker section in the header */ if ( ! function_exists( 'colornews_breaking_news' ) ) : function colornews_breaking_news() { $get_featured_posts = new WP_Query( array( 'posts_per_page' => 5, 'post_type' => 'post', 'ignore_sticky_posts' => true ) ); ?>
    have_posts() ):$get_featured_posts->the_post(); ?>
1, 'post_type' => 'post', 'ignore_sticky_posts' => true, 'orderby' => 'rand' ) ); ?>
have_posts() ):$get_random_post->the_post(); ?>
li.current-menu-ancestor,#site-navigation ul>li.current-menu-item,#site-navigation ul>li.current-menu-parent,#site-navigation ul>li:hover,.block-title,.bottom-header-wrapper .home-icon a:hover,.home .bottom-header-wrapper .home-icon a,.breaking-news-title,.bttn:hover,.carousel-slider-wrapper .bx-controls a,.cat-links a,.category-menu,.category-menu ul.sub-menu,.category-toggle-block,.error,.home-slider .bx-pager a.active,.home-slider .bx-pager a:hover,.navigation .nav-links a:hover,.post .more-link:hover,.random-hover-link a:hover,.search-box,.search-icon:hover,.share-wrap:hover,button,input[type=button]:hover,input[type=reset]:hover,input[type=submit]:hover{background:'.$primary_color.'}a{color:'.$primary_color.'}.entry-footer a:hover{color:'.$primary_color.'}#bottom-footer .copy-right a:hover,#top-footer .widget a:hover,#top-footer .widget a:hover:before,#top-footer .widget li:hover:before,.below-entry-meta span:hover a,.below-entry-meta span:hover i,.caption-title a:hover,.comment .comment-reply-link:hover,.entry-btn a:hover,.entry-title a:hover,.num-404,.tag-cloud-wrap a:hover,.top-menu-wrap ul li.current-menu-ancestor>a,.top-menu-wrap ul li.current-menu-item>a,.top-menu-wrap ul li.current-menu-parent>a,.top-menu-wrap ul li:hover>a,.widget a:hover,.widget a:hover::before{color:'.$primary_color.'}#top-footer .block-title{border-bottom:1px solid '.$primary_color.'}#site-navigation .menu-toggle:hover,.sub-toggle{background:'.$primary_color.'}.colornews_random_post .random-hover-link a:hover{background:'.$primary_color.' none repeat scroll 0 0;border:1px solid '.$primary_color.'}#site-title a:hover{color:'.$primary_color.'}a#scroll-up i{color:'.$primary_color.'}.page-header .page-title{border-bottom:3px solid '.$primary_color.';color:'.$primary_color.'}@media (max-width: 768px) { #site-navigation ul > li:hover > a, #site-navigation ul > li.current-menu-item > a,#site-navigation ul > li.current-menu-ancestor > a,#site-navigation ul > li.current-menu-parent > a {background:' .$primary_color. '}}'; } if( !empty( $colornews_internal_css ) ) { echo ''; ?>'; ?>' . get_bloginfo( 'name', 'display' ) . ''; $wp_link = '' . __( 'WordPress', 'colornews' ) . ''; $tg_link = ''.__( 'ThemeGrill', 'colornews') .''; $default_footer_value = sprintf( __( 'Copyright © %1$s %2$s.', 'colornews' ), date( 'Y' ), $site_link ).' '.sprintf( __( 'Theme: %1$s by %2$s.', 'colornews' ), 'ColorNews', $tg_link ).' '.sprintf( __( 'Powered by %s.', 'colornews' ), $wp_link ); $colornews_footer_copyright = '
'.$default_footer_value.'
'; echo $colornews_footer_copyright; } endif; /****************************************************************************************/ if ( ! function_exists( 'colornews_render_header_image' ) ) : /** * Shows the small info text on top header part */ function colornews_render_header_image() { $header_image = get_header_image(); if( !empty( $header_image ) ) { if(get_theme_mod('colornews_header_image_link', 0) == 1) { ?>
<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>
true, 'update_post_meta_cache' => false, 'update_post_term_cache' => false, 'ignore_sticky_posts' => 1, 'orderby' => 'rand', 'post__not_in' => array($post->ID), 'posts_per_page' => 3 ); // Related by categories if ( get_theme_mod('colornews_related_posts', 'categories') == 'categories' ) { $cats = get_post_meta($post->ID, 'related-posts', true); if ( !$cats ) { $cats = wp_get_post_categories($post->ID, array('fields'=>'ids')); $args['category__in'] = $cats; } else { $args['cat'] = $cats; } } // Related by tags if ( get_theme_mod('colornews_related_posts', 'categories') == 'tags' ) { $tags = get_post_meta($post->ID, 'related-posts', true); if ( !$tags ) { $tags = wp_get_post_tags($post->ID, array('fields'=>'ids')); $args['tag__in'] = $tags; } else { $args['tag_slug__in'] = explode(',', $tags); } if ( !$tags ) { $break = true; } } $query = !isset($break)?new WP_Query($args):new WP_Query; return $query; } } /**************************************************************************************/ /* * Creating Social Menu */ if ( ! function_exists( 'colornews_social_menu' ) ) { function colornews_social_menu() { if ( has_nav_menu( 'social' ) ) { wp_nav_menu( array( 'theme_location' => 'social', 'container' => 'div', 'container_id' => 'menu-social', 'container_class' => 'login-signup-wrap', 'depth' => 1, 'fallback_cb' => false, 'items_wrap' => '' ) ); } } } /**************************************************************************************/ if ( ! function_exists( 'colornews_comment' ) ) : /** * Template for comments and pingbacks. * * Used as a callback by wp_list_comments() for displaying the comments. */ function colornews_comment( $comment, $args, $depth ) { $GLOBALS['comment'] = $comment; switch ( $comment->comment_type ) : case 'pingback' : case 'trackback' : // Display trackbacks differently than normal comments. ?>
  • id="comment-">

    ', '' ); ?>

  • id="li-comment-">
    %1$s%2$s', get_comment_author_link(), // If current post author is also comment author, make it known visually. ( $comment->user_id === $post->post_author ) ? '' . __( 'Post author', 'colornews' ) . '' : '' ); printf( '
    %1$s
    ', sprintf( __( '%1$s at %2$s', 'colornews' ), get_comment_date(), get_comment_time() ) ); printf( 'Permalink', esc_url( get_comment_link( $comment->comment_ID ) ) ); edit_comment_link(); ?>
    comment_approved ) : ?>

    __( 'Reply', 'colornews' ), 'after' => '', 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
    '; ?> 0 Comment', 'colornews' ), __( ' 1 Comment', 'colornews' ), __( ' % Comments', 'colornews' ) ); ?> ', __( ', ', 'colornews' ), '' ); if ( $tags_list ) echo $tags_list; edit_post_link( __( 'Edit', 'colornews' ), '', '' ); echo ''; endif; } endif; /****************************************************************************************/ /* * Support for Google updated/published date */ if ( ! function_exists( 'colornews_published_date' ) ) : function colornews_published_date() { $time_string = ''; if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) { $time_string .= ''; } $time_string = sprintf( $time_string, esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date() ), esc_attr( get_the_modified_date( 'c' ) ), esc_html( get_the_modified_date() ) ); printf( __( '%3$s', 'colornews' ), esc_url( get_permalink() ), esc_attr( get_the_time() ), $time_string ); } endif; /**************************************************************************************/ /* * Creating responsive video for posts/pages */ if ( !function_exists('colornews_responsive_video') ) : function colornews_responsive_video( $html, $url, $attr, $post_ID ) { return '
    '.$html.'
    '; } add_filter( 'embed_oembed_html', 'colornews_responsive_video', 10, 4 ); endif; /**************************************************************************************/ /* * Use of the hooks for Category Color in the archive titles */ function colornews_colored_category_title($title) { $color_value = colornews_category_color(get_cat_id($title)); $color_border_value = colornews_category_color(get_cat_id($title)); if ( !empty($color_value) ) { return '

    '.$title.'

    '; } else { return '

    '.$title.'

    '; } } function colornews_category_title_function($category_title) { add_filter('single_cat_title', 'colornews_colored_category_title'); } add_action('colornews_category_title','colornews_category_title_function'); /**************************************************************************************/ /** * Making the theme Woocommrece compatible */ remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10); remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10); remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0 ); remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10); add_filter( 'woocommerce_show_page_title', '__return_false' ); add_action('woocommerce_before_main_content', 'colornews_wrapper_start', 10); add_action('woocommerce_after_main_content', 'colornews_wrapper_end', 10); add_action( 'woocommerce_sidebar', 'colornews_get_sidebar', 10 ); function colornews_wrapper_start() { echo '
    '; } function colornews_wrapper_end() { echo '
    '; } function colornews_get_sidebar() { colornews_sidebar_select(); echo '
    '; } ?>