'social', 'container' => 'div', 'container_class' => 'the-newsmag-social-menu', 'depth' => 1, 'menu_class' => 'menu-social', 'fallback_cb' => false, 'link_before' => '', 'link_after' => '', 'items_wrap' => '', ) ); } } endif; add_action('the_newsmag_footer_copyright', 'the_newsmag_footer_copyright', 10); /** * function to show the footer info, copyright information */ if (!function_exists('the_newsmag_footer_copyright')) : function the_newsmag_footer_copyright() { $site_link = '' . get_bloginfo('name', 'display') . ''; $wp_link = '' . esc_html__('WordPress', 'the-newsmag') . ''; $my_link_name = '' . esc_html__('Bishal Napit', 'the-newsmag') . ''; $default_footer_value = sprintf(esc_html__('Copyright © %1$s %2$s. All rights reserved.', 'the-newsmag'), date('Y'), $site_link) . '
' . sprintf(esc_html__('Theme: %1$s by %2$s.', 'the-newsmag'), esc_html__('The NewsMag', 'the-newsmag'), $my_link_name) . ' ' . sprintf(esc_html__('Powered by %s.', 'the-newsmag'), $wp_link); $the_newsmag_footer_copyright = ''; echo wp_kses_post($the_newsmag_footer_copyright); } endif; add_filter('body_class', 'the_newsmag_body_class'); /** * Filter the body_class * * Throwing different body class for the different layouts in the body tag */ function the_newsmag_body_class($classes) { // custom layout options for posts and pages global $post; if ($post) { $the_newsmag_layout_meta = get_post_meta($post->ID, 'the_newsmag_page_layout', true); } if (is_home()) { $queried_id = get_option('page_for_posts'); $the_newsmag_layout_meta = get_post_meta($queried_id, 'the_newsmag_page_layout', true); } if (empty($the_newsmag_layout_meta) || is_archive() || is_search() || is_404()) { $the_newsmag_layout_meta = 'default_layout'; } $the_newsmag_default_layout = get_theme_mod('the_newsmag_default_layout', 'right_sidebar'); $the_newsmag_default_page_layout = get_theme_mod('the_newsmag_default_page_layout', 'right_sidebar'); $the_newsmag_default_post_layout = get_theme_mod('the_newsmag_default_single_posts_layout', 'right_sidebar'); if ($the_newsmag_layout_meta == 'default_layout') { if (is_page()) { if ($the_newsmag_default_page_layout == 'right_sidebar') { $classes[] = 'right-sidebar'; } elseif ($the_newsmag_default_page_layout == 'left_sidebar') { $classes[] = 'left-sidebar'; } elseif ($the_newsmag_default_page_layout == 'no_sidebar_full_width') { $classes[] = 'no-sidebar-full-width'; } elseif ($the_newsmag_default_page_layout == 'no_sidebar_content_centered') { $classes[] = 'no-sidebar-content-centered'; } } elseif (is_single()) { if ($the_newsmag_default_post_layout == 'right_sidebar') { $classes[] = 'right-sidebar'; } elseif ($the_newsmag_default_post_layout == 'left_sidebar') { $classes[] = 'left-sidebar'; } elseif ($the_newsmag_default_post_layout == 'no_sidebar_full_width') { $classes[] = 'no-sidebar-full-width'; } elseif ($the_newsmag_default_post_layout == 'no_sidebar_content_centered') { $classes[] = 'no-sidebar-content-centered'; } } elseif ($the_newsmag_default_layout == 'right_sidebar') { $classes[] = 'right-sidebar'; } elseif ($the_newsmag_default_layout == 'left_sidebar') { $classes[] = 'left-sidebar'; } elseif ($the_newsmag_default_layout == 'no_sidebar_full_width') { $classes[] = 'no-sidebar-full-width'; } elseif ($the_newsmag_default_layout == 'no_sidebar_content_centered') { $classes[] = 'no-sidebar-content-centered'; } } elseif ($the_newsmag_layout_meta == 'right_sidebar') { $classes[] = 'right-sidebar'; } elseif ($the_newsmag_layout_meta == 'left_sidebar') { $classes[] = 'left-sidebar'; } elseif ($the_newsmag_layout_meta == 'no_sidebar_full_width') { $classes[] = 'no-sidebar-full-width'; } elseif ($the_newsmag_layout_meta == 'no_sidebar_content_centered') { $classes[] = 'no-sidebar-content-centered'; } // custom layout option for site if (get_theme_mod('the_newsmag_site_layout', 'wide_layout') == 'wide_layout') { $classes[] = 'wide'; } elseif (get_theme_mod('the_newsmag_site_layout', 'wide_layout') == 'boxed_layout') { $classes[] = 'boxed'; } return $classes; } /* * function to display the sidebar according to layout choosed */ if (!function_exists('the_newsmag_sidebar_select')) : function the_newsmag_sidebar_select() { global $post; if ($post) { $the_newsmag_layout_meta = get_post_meta($post->ID, 'the_newsmag_page_layout', true); } if (is_home()) { $queried_id = get_option('page_for_posts'); $the_newsmag_layout_meta = get_post_meta($queried_id, 'the_newsmag_page_layout', true); } if (empty($the_newsmag_layout_meta) || is_archive() || is_search() || is_404()) { $the_newsmag_layout_meta = 'default_layout'; } $the_newsmag_default_layout = get_theme_mod('the_newsmag_default_layout', 'right_sidebar'); $the_newsmag_default_page_layout = get_theme_mod('the_newsmag_default_page_layout', 'right_sidebar'); $the_newsmag_default_post_layout = get_theme_mod('the_newsmag_default_single_posts_layout', 'right_sidebar'); if ($the_newsmag_layout_meta == 'default_layout') { if (is_page()) { if ($the_newsmag_default_page_layout == 'right_sidebar') { get_sidebar(); } elseif ($the_newsmag_default_page_layout == 'left_sidebar') { get_sidebar('left'); } } elseif (is_single()) { if ($the_newsmag_default_post_layout == 'right_sidebar') { get_sidebar(); } elseif ($the_newsmag_default_post_layout == 'left_sidebar') { get_sidebar('left'); } } elseif ($the_newsmag_default_layout == 'right_sidebar') { get_sidebar(); } elseif ($the_newsmag_default_layout == 'left_sidebar') { get_sidebar('left'); } } elseif ($the_newsmag_layout_meta == 'right_sidebar') { get_sidebar(); } elseif ($the_newsmag_layout_meta == 'left_sidebar') { get_sidebar('left'); } } endif; add_action('wp_head', 'the_newsmag_custom_css'); /** * Hooks the Custom Internal CSS to head section */ function the_newsmag_custom_css() { // changing color options $the_newsmag_custom_options_color = ''; $primary_color = get_theme_mod('the_newsmag_primary_color', '#4169e1'); if ($primary_color != '#4169e1') { $the_newsmag_custom_options_color .= '.category-title-meta-wrapper{background:rgba(' . the_newsmag_hex2rgb($primary_color) . ')}.the-newsmag-posts-slider-widget .slide-next,.the-newsmag-posts-slider-widget .slide-prev{background:rgba(' . the_newsmag_hex2rgb($primary_color) . ')}.format-image .featured-image .featured-image-caption,.format-image.has-post-thumbnail .entry-meta-comments,.format-image.has-post-thumbnail .entry-title,.format-standard.has-post-thumbnail .entry-meta-comments,.format-standard.has-post-thumbnail .entry-title,.page.has-post-thumbnail .entry-title,.related-post-contents .featured-image .entry-title,.the-newsmag-one-column-widget .first-post .category-title-meta-wrapper,.the-newsmag-posts-grid .category-title-meta-wrapper,.the-newsmag-two-column-widget .first-post .category-title-meta-wrapper{background:rgba(' . the_newsmag_hex2rgb($primary_color) . ')}.format-gallery .slide-next,.format-gallery .slide-prev{background:rgba(' . the_newsmag_hex2rgb($primary_color) . ')}.breaking-news,.header-top-area{border-bottom:4px solid ' . $primary_color . '}.bypostauthor>.comment-body .fn:after,.category-links a,.comment-awaiting-moderation,.date-in-header,.format-chat .chat-details,.format-gallery .slide-next:hover,.format-gallery .slide-prev:hover,.format-quote .quote-details,.main-navigation .current-menu-ancestor>a,.main-navigation .current-menu-item>a,.main-navigation .current_page_ancestor>a,.main-navigation .current_page_item>a,.main-navigation li.focus>a,.main-navigation li:hover>a,.nav-links .page-numbers.current,.nav-links .page-numbers:hover,.page-title span,blockquote,ul.the-newsmag-tabs .ui-tabs-active{background-color:' . $primary_color . '}#footer-menu a:hover,.entry-footer .tags-links,.entry-footer .tags-links .fa-tags,.entry-title a:hover,.footer-copyright a,.latest-news-lists .entry-date:hover,.latest-news-lists .entry-title:hover,.menu-social li a:before,.sticky .category-links a,.sticky .category-links a:hover,.the-newsmag-two-column-widget .first-post .no-featured-image .author a:hover,.the-newsmag-two-column-widget .first-post .no-featured-image .comments-link a:hover,.the-newsmag-two-column-widget .first-post .no-featured-image .entry-title a:hover,.the-newsmag-two-column-widget .first-post .no-featured-image .posted-on a:hover,.widget_archive li a:before,.widget_categories li a:before,.widget_nav_menu li a:before,.widget_pages li a:before,.widget_recent_comments li:before,.widget_recent_entries li a:before,.widget_rss li a:before,a,a#scroll-up i,a.entry-meta-comments:hover,a:active,a:focus,a:hover,footer .footer-sidebar-masonry-area a:hover,footer .footer-sidebar-top-area a:hover,footer .the-newsmag-one-column-widget .first-post .no-featured-image .author a:hover,footer .the-newsmag-one-column-widget .first-post .no-featured-image .comments-link a:hover,footer .the-newsmag-one-column-widget .first-post .no-featured-image .entry-title a:hover,footer .the-newsmag-one-column-widget .first-post .no-featured-image .posted-on a:hover,footer .widget_archive li a:hover:before,footer .widget_categories li a:hover:before,footer .widget_nav_menu li a:hover:before,footer .widget_pages li a:hover:before,footer .widget_recent_comments li:hover:before,footer .widget_recent_entries li a:hover:before,footer .widget_rss li a:hover:before{color:' . $primary_color . '}#infinite-handle span,.continue-more-link,.format-link .link-details,.home .main-navigation a.home-icon,.main-navigation a.home-icon:hover,.main-navigation a.random-post:hover,.menu-social li a:hover:before,.page-links a,.related-posts-main-title span,.sticky,.sticky .continue-more-link,button,input[type=button],input[type=reset],input[type=submit],ins,mark{background:' . $primary_color . '}footer .footer-social-menu{border-top:4px solid ' . $primary_color . '}.latest-news-lists{border:1px solid ' . $primary_color . '}.footer-bottom-area{border-top:4px solid ' . $primary_color . ';border-bottom:4px solid ' . $primary_color . '}button,input[type=button],input[type=reset],input[type=submit],input[type=search],td,th,tr{border:2px solid ' . $primary_color . '}.main-navigation,.main-navigation ul ul a,.post-navigation,.widget-title{border-bottom:4px solid ' . $primary_color . '}.footer-sidebar-masonry-area,.footer-sidebar-top-area,.post-navigation,.post-navigation div+div{border-top:4px solid ' . $primary_color . '}.search-form-top{border:4px solid ' . $primary_color . '}.content-top-sidebar-area,.widget_nav_menu a,.widget_pages a,.widget_recent_comments li,.widget_recent_entries li,li.comments-tab-widget,ul.the-newsmag-tabs{border-bottom:2px solid ' . $primary_color . '}.widget-title span{background:' . $primary_color . '}.content-bottom-sidebar-area{border-top:2px solid ' . $primary_color . '}.widget-entry-meta .comments-link a,.widget-entry-meta .entry-meta .byline a:hover,.widget-entry-meta .entry-meta .comments-link a:hover,.widget-entry-meta .entry-meta .posted-on a:hover,footer .widget-entry-meta .entry-meta .comments-link a:hover{color:' . $primary_color . '}.page-title,.related-posts-main-title{border-bottom:4px solid ' . $primary_color . '}.the-newsmag-posts-slider-widget .slide-next:hover,.the-newsmag-posts-slider-widget .slide-prev:hover{background-color:' . $primary_color . '}.author .author-box,.format-status .status-details{border:2px solid ' . $primary_color . '}.navigation.pagination .nav-links{border-top:2px solid ' . $primary_color . ';border-bottom:2px solid ' . $primary_color . '}.comment-body{border-bottom:2px solid ' . $primary_color . '}.wp-caption{border:1px solid ' . $primary_color . '}@media screen and (max-width:768px){.social-menu,ul#footer-menu{border-top:4px solid ' . $primary_color . '}}'; } // color change options code if (!empty($the_newsmag_custom_options_color)) { echo ''; ?> '; ?> 1, 'post_type' => 'post', 'ignore_sticky_posts' => true, 'orderby' => 'rand' )); ?> have_posts()):$get_random_post->the_post(); ?> '; ?> 'id', 'hide_empty' => 0 ); $category = get_categories($args); foreach ($category as $category_list) { $color = get_theme_mod('the_newsmag_category_color_' . $wp_category_id); return esc_attr($color); } } endif; /* * Category Color display */ if (!function_exists('the_newsmag_colored_category')) : function the_newsmag_colored_category($color = true) { global $post; $categories = get_the_category(); $separator = ' '; $output = ''; if ($categories) { foreach ($categories as $category) { $color_code = the_newsmag_category_color(get_cat_id($category->cat_name)); if (!empty($color_code)) { $output .= '' . $category->cat_name . '' . $separator; } else { $output .= '' . $category->cat_name . '' . $separator; } } if ($color == false) { $output = trim($output, $separator); } if ($color == true) { echo trim($output, $separator); } } if ($color == false) { return $output; } } endif; /** * adding the hooks to filter the single category title to display the colored category title */ if (!function_exists('the_newsmag_colored_category_title')) : function the_newsmag_colored_category_title($title) { $color_value = the_newsmag_category_color(get_cat_id($title)); $color_border_value = the_newsmag_category_color(get_cat_id($title)); if (!empty($color_value)) { return '

' . '' . sprintf(esc_html__('Category: %s', 'the-newsmag'), $title) . '

'; } else { return '

' . sprintf(esc_html__('Category: %s', 'the-newsmag'), $title) . '

'; } } endif; /* * Adding the custom function to filter the category title */ function the_newsmag_category_title_function($category_title) { add_filter('single_cat_title', 'the_newsmag_colored_category_title'); } add_action('the_newsmag_category_title', 'the_newsmag_category_title_function'); /** * Controlling the excerpt length */ function the_newsmag_excerpt_length($length) { return 75; } add_filter('excerpt_length', 'the_newsmag_excerpt_length'); /** * Controlling the excerpt string */ function the_newsmag_excerpt_string($more) { return '…'; } add_filter('excerpt_more', 'the_newsmag_excerpt_string'); /* * Breaking News/Latest Posts ticker section in the header */ if (!function_exists('the_newsmag_breaking_news')) : function the_newsmag_breaking_news() { $get_featured_posts = new WP_Query(array( 'posts_per_page' => 10, 'post_type' => 'post', 'ignore_sticky_posts' => true )); ?> %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()) ); echo $time_string; } endif; /* * Display the related posts */ if (!function_exists('the_newsmag_related_posts_function')) : function the_newsmag_related_posts_function() { global $post; // Define shared post arguments $args = array( 'no_found_rows' => 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('the_newsmag_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('the_newsmag_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; } endif; if (!function_exists('the_newsmag_posts_posted_on')) : /** * Prints HTML with meta information for the current post-date/time and author. */ function the_newsmag_posts_posted_on() { $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()) ); $posted_on = sprintf( esc_html_x('%s', 'post date', 'the-newsmag'), '' . '' . $time_string . '' ); $byline = sprintf( esc_html_x('%s', 'post author', 'the-newsmag'), '' . get_avatar(get_the_author_meta('user_email'), '25') . '' . '' . esc_html(get_the_author()) . '' ); echo ' ' . $byline . ''; echo '' . $posted_on . ''; // WPCS: XSS OK. echo ''; comments_popup_link(wp_kses(__('Leave a reply', 'the-newsmag'), array('i' => array('class' => array()))), wp_kses(__('1 Comment', 'the-newsmag'), array('i' => array('class' => array()))), wp_kses(__('% Comments', 'the-newsmag'), array('i' => array('class' => array()))), '', wp_kses(__('Comments Disabled', 'the-newsmag'), array('i' => array('class' => array())))); echo ''; } endif; /** * function to display the author bio */ if (!function_exists('the_newsmag_author_bio')) : function the_newsmag_author_bio() { if (get_the_author_meta('description')) : ?>

'; printf(esc_html__('Follow %s on:', 'the-newsmag'), $author_name); if ($author_facebook_link) { echo '' . esc_html__('Facebook', 'the-newsmag') . ''; } if ($author_twitter_link) { echo '' . esc_html__('Twitter', 'the-newsmag') . ''; } if ($author_googleplus_link) { echo ''; } echo ''; } } endif; // link post format support added if (!function_exists('the_newsmag_link_post_format')) : function the_newsmag_link_post_format() { if (!preg_match('/]*?href=[\'"](.+?)[\'"]/is', get_the_content(), $matches)) return false; return esc_url_raw($matches[1]); } endif; // status post format support added if (!function_exists('the_newsmag_status_post_format_first_paragraph')) : function the_newsmag_status_post_format_first_paragraph() { $first_paragraph_str = wpautop(get_the_content()); $first_paragraph_str = substr($first_paragraph_str, 0, strpos($first_paragraph_str, '

') + 4); $first_paragraph_str = strip_tags($first_paragraph_str, ''); return '

' . $first_paragraph_str . '

'; } endif; if (!function_exists('the_newsmag_status_post_format_avatar_image')) : function the_newsmag_status_post_format_avatar_image() { return get_avatar(get_the_author_meta('user_email'), '75'); } endif; // quote post format support added if (!function_exists('the_newsmag_quote_post_format_blockquote')) : function the_newsmag_quote_post_format_blockquote() { $document = new DOMDocument(); $content = apply_filters('the_content', get_the_content('', true)); $output = ''; if ('' != $content) { libxml_use_internal_errors(true); $document->loadHTML(mb_convert_encoding($content, 'html-entities', 'utf-8')); libxml_clear_errors(); $blockquotes = $document->getElementsByTagName('blockquote'); if ($blockquotes->length) { $blockquote = $blockquotes->item(0); $document = new DOMDocument(); $document->appendChild($document->importNode($blockquote, true)); $output .= $document->saveHTML(); } } return wpautop($output); } endif; // audio and video post format support added if (!function_exists('the_newsmag_audio_video_post_format')) : function the_newsmag_audio_video_post_format() { $document = new DOMDocument(); $content = apply_filters('the_content', get_the_content('', true)); if ('' != $content) { libxml_use_internal_errors(true); $document->loadHTML($content); libxml_clear_errors(); $iframes = $document->getElementsByTagName('iframe'); $objects = $document->getElementsByTagName('object'); $embeds = $document->getElementsByTagName('embed'); $document = new DOMDocument(); if ($iframes->length) { $iframe = $iframes->item($iframes->length - 1); $document->appendChild($document->importNode($iframe, true)); } elseif ($objects->length) { $object = $objects->item($objects->length - 1); $document->appendChild($document->importNode($object, true)); } elseif ($embeds->length) { $embed = $embeds->item($embeds->length - 1); $document->appendChild($document->importNode($embed, true)); } return wpautop($document->saveHTML()); } return false; } endif; if (!function_exists('the_newsmag_widget_posts_posted_on')) : /** * Prints HTML with meta information for the current post-date/time and author. */ function the_newsmag_widget_posts_posted_on() { $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()) ); $posted_on = sprintf( esc_html_x('%s', 'post date', 'the-newsmag'), '
' . '' . $time_string . '' ); $byline = sprintf( esc_html_x('%s', 'post author', 'the-newsmag'), '' . get_avatar(get_the_author_meta('user_email'), '25') . '' . '' . esc_html(get_the_author()) . '' ); echo ''; echo '' . $posted_on . ''; // WPCS: XSS OK. if (!post_password_required() && (comments_open() || get_comments_number())) : ?>