'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[] = ''; } else if ( $colormag_default_page_layout == 'left_sidebar' ) { $classes[] = 'left-sidebar'; } else if ( $colormag_default_page_layout == 'no_sidebar_full_width' ) { $classes[] = 'no-sidebar-full-width'; } else if ( $colormag_default_page_layout == 'no_sidebar_content_centered' ) { $classes[] = 'no-sidebar'; } } else if ( is_single() ) { if ( $colormag_default_post_layout == 'right_sidebar' ) { $classes[] = ''; } else if ( $colormag_default_post_layout == 'left_sidebar' ) { $classes[] = 'left-sidebar'; } else if ( $colormag_default_post_layout == 'no_sidebar_full_width' ) { $classes[] = 'no-sidebar-full-width'; } else if ( $colormag_default_post_layout == 'no_sidebar_content_centered' ) { $classes[] = 'no-sidebar'; } } else if ( $colormag_default_layout == 'right_sidebar' ) { $classes[] = ''; } else if ( $colormag_default_layout == 'left_sidebar' ) { $classes[] = 'left-sidebar'; } else if ( $colormag_default_layout == 'no_sidebar_full_width' ) { $classes[] = 'no-sidebar-full-width'; } else if ( $colormag_default_layout == 'no_sidebar_content_centered' ) { $classes[] = 'no-sidebar'; } } else if ( $layout_meta == 'right_sidebar' ) { $classes[] = ''; } else if ( $layout_meta == 'left_sidebar' ) { $classes[] = 'left-sidebar'; } else if ( $layout_meta == 'no_sidebar_full_width' ) { $classes[] = 'no-sidebar-full-width'; } else if ( $layout_meta == 'no_sidebar_content_centered' ) { $classes[] = 'no-sidebar'; } if ( get_theme_mod( 'colormag_site_layout', 'wide_layout' ) == 'wide_layout' ) { $classes[] = 'wide'; } else if ( get_theme_mod( 'colormag_site_layout', 'wide_layout' ) == 'boxed_layout' ) { $classes[] = ''; } if ( get_theme_mod( 'colormag_responsive_menu', 0 ) == 1 ) { $classes[] = 'better-responsive-menu'; } 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(); } else if ( $colormag_default_page_layout == 'left_sidebar' ) { get_sidebar( 'left' ); } } if ( is_single() ) { if ( $colormag_default_post_layout == 'right_sidebar' ) { get_sidebar(); } else if ( $colormag_default_post_layout == 'left_sidebar' ) { get_sidebar( 'left' ); } } else if ( $colormag_default_layout == 'right_sidebar' ) { get_sidebar(); } else if ( $colormag_default_layout == 'left_sidebar' ) { get_sidebar( 'left' ); } } else if ( $layout_meta == 'right_sidebar' ) { get_sidebar(); } else if ( $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 '
'; 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 ( ! function_exists( 'has_site_icon' ) || ( ! empty( $colormag_favicon ) && ! has_site_icon() ) ) { $colormag_favicon_output .= ''; } echo $colormag_favicon_output; } } /****************************************************************************************/ /** * Generate darker color * Source: http://stackoverflow.com/questions/3512311/how-to-generate-lighter-darker-color-with-php */ function colormag_darkcolor( $hex, $steps ) { // Steps should be between -255 and 255. Negative = darker, positive = lighter $steps = max( - 255, min( 255, $steps ) ); // Normalize into a six character long hex string $hex = str_replace( '#', '', $hex ); if ( strlen( $hex ) == 3 ) { $hex = str_repeat( substr( $hex, 0, 1 ), 2 ) . str_repeat( substr( $hex, 1, 1 ), 2 ) . str_repeat( substr( $hex, 2, 1 ), 2 ); } // Split into three parts: R, G and B $color_parts = str_split( $hex, 2 ); $return = '#'; foreach ( $color_parts as $color ) { $color = hexdec( $color ); // Convert to decimal $color = max( 0, min( 255, $color + $steps ) ); // Adjust color $return .= str_pad( dechex( $color ), 2, '0', STR_PAD_LEFT ); // Make two char hex code } return $return; } /****************************************************************************************/ add_action( 'wp_head', 'colormag_custom_css', 100 ); /** * Hooks the Custom Internal CSS to head section */ function colormag_custom_css() { $colormag_internal_css = ''; $primary_color = get_theme_mod( 'colormag_primary_color', '#289dcc' ); $primary_dark = colormag_darkcolor( $primary_color, - 30 ); if ( $primary_color != '#289dcc' ) { $colormag_internal_css .= ' .colormag-button,blockquote,button,input[type=reset],input[type=button],input[type=submit],#masthead.colormag-header-clean #site-navigation.main-small-navigation .menu-toggle{background-color:' . $primary_color . '}#site-title a,.next a:hover,.previous a:hover,.social-links i.fa:hover,a,#masthead.colormag-header-clean .social-links li:hover i.fa,#masthead.colormag-header-classic .social-links li:hover i.fa,#masthead.colormag-header-clean .breaking-news .newsticker a:hover,#masthead.colormag-header-classic .breaking-news .newsticker a:hover,#masthead.colormag-header-classic #site-navigation .fa.search-top:hover,#masthead.colormag-header-classic #site-navigation.main-navigation .random-post a:hover .fa-random{color:' . $primary_color . '}.fa.search-top:hover,#masthead.colormag-header-classic #site-navigation.main-small-navigation .menu-toggle{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,#masthead.colormag-header-classic #site-navigation.main-navigation ul#menu-primary ul.sub-menu li:hover > a, #masthead.colormag-header-classic #site-navigation.main-navigation ul#menu-primary ul.sub-menu li.current-menu-ancestor > a, #masthead.colormag-header-classic #site-navigation.main-navigation ul#menu-primary ul.sub-menu li.current-menu-item > a,#masthead .main-small-navigation li:hover > a, #masthead .main-small-navigation li.current-page-ancestor > a, #masthead .main-small-navigation li.current-menu-ancestor > a, #masthead .main-small-navigation li.current-page-item > a, #masthead .main-small-navigation li.current-menu-item > a{background-color:' . $primary_color . '}.main-small-navigation .current-menu-item>a,.main-small-navigation .current_page_item>a{background:' . $primary_color . '}#masthead.colormag-header-classic #site-navigation.main-navigation ul#menu-primary > li:hover > a, #masthead.colormag-header-classic #site-navigation.main-navigation ul#menu-primary > li.current-menu-item > a, #masthead.colormag-header-classic #site-navigation.main-navigation ul#menu-primary > li.current-menu-ancestor > a,#masthead.colormag-header-classic #site-navigation.main-navigation ul#menu-primary ul.sub-menu li:hover, #masthead.colormag-header-classic #site-navigation.main-navigation ul#menu-primary ul.sub-menu li.current-menu-ancestor, #masthead.colormag-header-classic #site-navigation.main-navigation ul#menu-primary ul.sub-menu li.current-menu-item,#masthead.colormag-header-classic #site-navigation.main-small-navigation .menu-toggle,#masthead.colormag-header-classic #site-navigation .menu-toggle:hover{border-color:' . $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,.colormag-footer--classic .footer-widgets-area .widget-title span::before{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 . '}@media (max-width: 768px) {.better-responsive-menu .sub-toggle{background-color:' . $primary_dark . '}}'; } 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'; ?> ' . 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 ) . '', '' ); ?>