'colormag-featured-image', ), $atts ); $out['size'] = $atts['size']; return $out; } add_filter( 'shortcode_atts_gallery', 'colormag_gallery_atts', 10, 3 ); /****************************************************************************************/ add_filter( 'body_class', 'colormag_body_class' ); /** * Filter the body_class * * Throwing different body class for the different layouts in the body tag */ function colormag_body_class( $classes ) { global $post; if( $post ) { $layout_meta = get_post_meta( $post->ID, 'colormag_page_layout', true ); } if( is_home() ) { $queried_id = get_option( 'page_for_posts' ); $layout_meta = get_post_meta( $queried_id, 'colormag_page_layout', true ); } if( empty( $layout_meta ) || is_archive() || is_search() ) { $layout_meta = 'default_layout'; } $colormag_default_layout = get_theme_mod( 'colormag_default_layout', 'right_sidebar' ); $colormag_default_page_layout = get_theme_mod( 'colormag_default_page_layout', 'right_sidebar' ); $colormag_default_post_layout = get_theme_mod( 'colormag_default_single_posts_layout', 'right_sidebar' ); if( $layout_meta == 'default_layout' ) { if( is_page() ) { if( $colormag_default_page_layout == 'right_sidebar' ) { $classes[] = ''; } elseif( $colormag_default_page_layout == 'left_sidebar' ) { $classes[] = 'left-sidebar'; } elseif( $colormag_default_page_layout == 'no_sidebar_full_width' ) { $classes[] = 'no-sidebar-full-width'; } elseif( $colormag_default_page_layout == 'no_sidebar_content_centered' ) { $classes[] = 'no-sidebar'; } } elseif( is_single() ) { if( $colormag_default_post_layout == 'right_sidebar' ) { $classes[] = ''; } elseif( $colormag_default_post_layout == 'left_sidebar' ) { $classes[] = 'left-sidebar'; } elseif( $colormag_default_post_layout == 'no_sidebar_full_width' ) { $classes[] = 'no-sidebar-full-width'; } elseif( $colormag_default_post_layout == 'no_sidebar_content_centered' ) { $classes[] = 'no-sidebar'; } } elseif( $colormag_default_layout == 'right_sidebar' ) { $classes[] = ''; } elseif( $colormag_default_layout == 'left_sidebar' ) { $classes[] = 'left-sidebar'; } elseif( $colormag_default_layout == 'no_sidebar_full_width' ) { $classes[] = 'no-sidebar-full-width'; } elseif( $colormag_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( 'colormag_site_layout', 'wide_layout' ) == 'wide_layout' ) { $classes[] = 'wide'; } elseif( get_theme_mod( 'colormag_site_layout', 'wide_layout' ) == 'boxed_layout' ) { $classes[] = ''; } return $classes; } /****************************************************************************************/ if ( ! function_exists( 'colormag_sidebar_select' ) ) : /** * Function to select the sidebar */ function colormag_sidebar_select() { global $post; if( $post ) { $layout_meta = get_post_meta( $post->ID, 'colormag_page_layout', true ); } if( is_home() ) { $queried_id = get_option( 'page_for_posts' ); $layout_meta = get_post_meta( $queried_id, 'colormag_page_layout', true ); } if( empty( $layout_meta ) || is_archive() || is_search() ) { $layout_meta = 'default_layout'; } $colormag_default_layout = get_theme_mod( 'colormag_default_layout', 'right_sidebar' ); $colormag_default_page_layout = get_theme_mod( 'colormag_default_page_layout', 'right_sidebar' ); $colormag_default_post_layout = get_theme_mod( 'colormag_default_single_posts_layout', 'right_sidebar' ); if( $layout_meta == 'default_layout' ) { if( is_page() ) { if( $colormag_default_page_layout == 'right_sidebar' ) { get_sidebar(); } elseif ( $colormag_default_page_layout == 'left_sidebar' ) { get_sidebar( 'left' ); } } if( is_single() ) { if( $colormag_default_post_layout == 'right_sidebar' ) { get_sidebar(); } elseif ( $colormag_default_post_layout == 'left_sidebar' ) { get_sidebar( 'left' ); } } elseif( $colormag_default_layout == 'right_sidebar' ) { get_sidebar(); } elseif ( $colormag_default_layout == 'left_sidebar' ) { get_sidebar( 'left' ); } } elseif( $layout_meta == 'right_sidebar' ) { get_sidebar(); } elseif( $layout_meta == 'left_sidebar' ) { get_sidebar( 'left' ); } } endif; /****************************************************************************************/ if ( ! function_exists( 'colormag_entry_meta' ) ) : /** * Shows meta information of post. */ function colormag_entry_meta() { if ( 'post' == get_post_type() ) : echo '
'; ?> %2$s'; 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', 'colormag' ), esc_url( get_permalink() ), esc_attr( get_the_time() ), $time_string ); ?> 0 Comment', 'colormag' ), __( ' 1 Comment', 'colormag' ), __( ' % Comments', 'colormag' ) ); ?> ', __( ', ', 'colormag' ), '' ); if ( $tags_list ) echo $tags_list; edit_post_link( __( 'Edit', 'colormag' ), '', '' ); echo '
'; endif; } endif; /****************************************************************************************/ add_action( 'admin_head', 'colormag_favicon' ); add_action( 'wp_head', 'colormag_favicon' ); /** * Favicon for the site */ function colormag_favicon() { if ( get_theme_mod( 'colormag_favicon_show', '0' ) == '1' ) { $colormag_favicon = get_theme_mod( 'colormag_favicon_upload', '' ); $colormag_favicon_output = ''; if ( !empty( $colormag_favicon ) ) { $colormag_favicon_output .= ''; } echo $colormag_favicon_output; } } /****************************************************************************************/ add_action('wp_head', 'colormag_custom_css'); /** * Hooks the Custom Internal CSS to head section */ function colormag_custom_css() { $colormag_internal_css = ''; $primary_color = get_theme_mod( 'colormag_primary_color', '#289dcc' ); if( $primary_color != '#289dcc' ) { $colormag_internal_css .= ' .colormag-button,blockquote,button,input[type=reset],input[type=button],input[type=submit]{background-color:'.$primary_color.'}#site-title a,.next a:hover,.previous a:hover,.social-links i.fa:hover,a{color:'.$primary_color.'}.fa.search-top:hover{background-color:'.$primary_color.'}#site-navigation{border-top:4px solid '.$primary_color.'}.home-icon.front_page_on,.main-navigation a:hover,.main-navigation ul li ul li a:hover,.main-navigation ul li ul li:hover>a,.main-navigation ul li.current-menu-ancestor>a,.main-navigation ul li.current-menu-item ul li a:hover,.main-navigation ul li.current-menu-item>a,.main-navigation ul li.current_page_ancestor>a,.main-navigation ul li.current_page_item>a,.main-navigation ul li:hover>a,.main-small-navigation li a:hover,.site-header .menu-toggle:hover{background-color:'.$primary_color.'}.main-small-navigation .current-menu-item>a,.main-small-navigation .current_page_item>a{background:'.$primary_color.'}.promo-button-area a:hover{border:2px solid '.$primary_color.';background-color:'.$primary_color.'}#content .wp-pagenavi .current,#content .wp-pagenavi a:hover,.format-link .entry-content a,.pagination span{background-color:'.$primary_color.'}.pagination a span:hover{color:'.$primary_color.';border-color:'.$primary_color.'}#content .comments-area a.comment-edit-link:hover,#content .comments-area a.comment-permalink:hover,#content .comments-area article header cite a:hover,.comments-area .comment-author-link a:hover{color:'.$primary_color.'}.comments-area .comment-author-link span{background-color:'.$primary_color.'}.comment .comment-reply-link:hover,.nav-next a,.nav-previous a{color:'.$primary_color.'}#secondary .widget-title{border-bottom:2px solid '.$primary_color.'}#secondary .widget-title span{background-color:'.$primary_color.'}.footer-widgets-area .widget-title{border-bottom:2px solid '.$primary_color.'}.footer-widgets-area .widget-title span{background-color:'.$primary_color.'}.footer-widgets-area a:hover{color:'.$primary_color.'}.advertisement_above_footer .widget-title{border-bottom:2px solid '.$primary_color.'}.advertisement_above_footer .widget-title span{background-color:'.$primary_color.'}a#scroll-up i{color:'.$primary_color.'}.page-header .page-title{border-bottom:2px solid '.$primary_color.'}#content .post .article-content .above-entry-meta .cat-links a,.page-header .page-title span{background-color:'.$primary_color.'}#content .post .article-content .entry-title a:hover,.entry-meta .byline i,.entry-meta .cat-links i,.entry-meta a,.post .entry-title a:hover,.search .entry-title a:hover{color:'.$primary_color.'}.entry-meta .post-format i{background-color:'.$primary_color.'}.entry-meta .comments-link a:hover,.entry-meta .edit-link a:hover,.entry-meta .posted-on a:hover,.entry-meta .tag-links a:hover,.single #content .tags a:hover{color:'.$primary_color.'}.more-link,.no-post-thumbnail{background-color:'.$primary_color.'}.post-box .entry-meta .cat-links a:hover,.post-box .entry-meta .posted-on a:hover,.post.post-box .entry-title a:hover{color:'.$primary_color.'}.widget_featured_slider .slide-content .above-entry-meta .cat-links a{background-color:'.$primary_color.'}.widget_featured_slider .slide-content .below-entry-meta .byline a:hover,.widget_featured_slider .slide-content .below-entry-meta .comments a:hover,.widget_featured_slider .slide-content .below-entry-meta .posted-on a:hover,.widget_featured_slider .slide-content .entry-title a:hover{color:'.$primary_color.'}.widget_highlighted_posts .article-content .above-entry-meta .cat-links a{background-color:'.$primary_color.'}.byline a:hover,.comments a:hover,.edit-link a:hover,.posted-on a:hover,.tag-links a:hover,.widget_highlighted_posts .article-content .below-entry-meta .byline a:hover,.widget_highlighted_posts .article-content .below-entry-meta .comments a:hover,.widget_highlighted_posts .article-content .below-entry-meta .posted-on a:hover,.widget_highlighted_posts .article-content .entry-title a:hover{color:'.$primary_color.'}.widget_featured_posts .article-content .above-entry-meta .cat-links a{background-color:'.$primary_color.'}.widget_featured_posts .article-content .entry-title a:hover{color:'.$primary_color.'}.widget_featured_posts .widget-title{border-bottom:2px solid '.$primary_color.'}.widget_featured_posts .widget-title span{background-color:'.$primary_color.'}.related-posts-main-title .fa,.single-related-posts .article-content .entry-title a:hover{color:'.$primary_color.'}'; } if( !empty( $colormag_internal_css ) ) { echo ''; ?> '; ?>post_parent ) : get_adjacent_post( false, '', true ); $next = get_adjacent_post( false, '', false ); if ( ! $next && ! $previous ) return; } // Don't print empty markup in archives if there's only one page. if ( $wp_query->max_num_pages < 2 && ( is_home() || is_archive() || is_search() ) ) return; $nav_class = ( is_single() ) ? 'post-navigation' : 'paging-navigation'; ?> 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', 'colormag' ) . '' : '' ); printf( '
    %1$s
    ', sprintf( __( '%1$s at %2$s', 'colormag' ), get_comment_date(), get_comment_time() ) ); printf( 'Permalink', esc_url( get_comment_link( $comment->comment_ID ) ) ); edit_comment_link(); ?>
    comment_approved ) : ?>

    __( 'Reply', 'colormag' ), 'after' => '', 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
    ' . get_bloginfo( 'name', 'display' ) . ''; $wp_link = '' . __( 'WordPress', 'colormag' ) . ''; $tg_link = ''.__( 'ThemeGrill', 'colormag') .''; $default_footer_value = sprintf( __( 'Copyright © %1$s %2$s. All rights reserved.', 'colormag' ), date( 'Y' ), $site_link ).'
    '.sprintf( __( 'Theme: %1$s by %2$s.', 'colormag' ), 'ColorMag', $tg_link ).' '.sprintf( __( 'Powered by %s.', 'colormag' ), $wp_link ); $colormag_footer_copyright = ''; echo $colormag_footer_copyright; } endif; /**************************************************************************************/ /* * Category Color Options */ if ( ! function_exists( 'colormag_category_color' ) ) : function colormag_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('colormag_category_color_'.$wp_category_id); return $color; } } endif; /**************************************************************************************/ /* * Breaking News/Latest Posts ticker section in the header */ if ( ! function_exists( 'colormag_breaking_news' ) ) : function colormag_breaking_news() { $get_featured_posts = new WP_Query( array( 'posts_per_page' => 5, 'post_type' => 'post', 'ignore_sticky_posts' => true ) ); ?>
    1, 'post_type' => 'post', 'ignore_sticky_posts' => true, 'orderby' => 'rand' ) ); ?>
    have_posts() ):$get_random_post->the_post(); ?>
    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('colormag_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('colormag_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; } } /**************************************************************************************/ /* * Category Color for widgets and other */ if ( !function_exists('colormag_colored_category') ) : function colormag_colored_category() { global $post; $categories = get_the_category(); $separator = ' '; $output = ''; if($categories) { $output .= '
    '; foreach($categories as $category) { $color_code = colormag_category_color(get_cat_id($category->cat_name)); if (!empty($color_code)) { $output .= ''.$category->cat_name.''.$separator; } else { $output .= ''.$category->cat_name.''.$separator; } } $output .='
    '; echo trim($output, $separator); } } endif; /**************************************************************************************/ /* * Creating responsive video for posts/pages */ if ( !function_exists('colormag_responsive_video') ) : function colormag_responsive_video( $html, $url, $attr, $post_ID ) { return '
    '.$html.'
    '; } add_filter( 'embed_oembed_html', 'colormag_responsive_video', 10, 4 ) ; endif; /**************************************************************************************/ /* * Use of the hooks for Category Color in the archive titles */ function colormag_colored_category_title($title) { $color_value = colormag_category_color(get_cat_id($title)); $color_border_value = colormag_category_color(get_cat_id($title)); if ( !empty($color_value) ) { return '

    '.''.$title.'

    '; } else { return '

    '.$title.'

    '; } } function colormag_category_title_function($category_title) { add_filter('single_cat_title', 'colormag_colored_category_title'); } add_action('colormag_category_title','colormag_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 ); add_filter( 'woocommerce_show_page_title', '__return_false' ); add_action('woocommerce_before_main_content', 'colormag_wrapper_start', 10); add_action('woocommerce_after_main_content', 'colormag_wrapper_end', 10); function colormag_wrapper_start() { echo '
    '; } function colormag_wrapper_end() { echo '
    '; } ?>