true, 'flex-width' => true, 'header-text' => array( 'site-title', 'site-description' ), )); /*-----------------------------------------------------------------------------------*/ # @ Get Madar Thumbnail Size /*-----------------------------------------------------------------------------------*/ add_theme_support( 'post-thumbnails' ); add_image_size( 'post-thumbnail', 258, 150, true); add_image_size( 'madar-thumbnail', 125, 125, true); add_image_size( 'box-thumbnail', 290, 175, true); add_image_size( 'madar-thumbnail-child', 55, 55, true); add_image_size( 'madar-thumbnail-recent', 150, 100, true); add_image_size( 'madar-thumbnail-mchild', 110, 70, true); add_image_size( 'madar-slide', 860, 410, true); add_image_size( 'madar-featured-big', 980, 400, true); add_image_size( 'madar-slide-item', 80, 80, true); add_image_size( 'madar-box', 315, 160, true); add_image_size( 'madar-box-thumbnail', 345, 240, true); add_image_size( 'madar-small-box-thumbnail', 315, 280, true); add_image_size( 'madar-featured', 878, 300, true); add_image_size( 'madar-related', 185, 110, true); add_image_size( 'madar-recent', 218, 360, true); set_post_thumbnail_size( 100, 100 ); ## small set_post_thumbnail_size( 110, 70 ); ## small mchild set_post_thumbnail_size( 878, 300 ); ## featured // custom menu support add_theme_support( 'menus' ); if ( function_exists( 'register_nav_menus' ) ) { register_nav_menus( array( 'top-menu' => esc_html__( 'Top Menu', 'madar-lite' ), 'header-menu' => esc_html__( 'Primary Menu', 'madar-lite' ), 'footer-menu' => esc_html__( 'Footer Menu', 'madar-lite' ) ) ); } // Set up the WordPress core custom background feature. add_theme_support( 'custom-background', apply_filters( 'madarlite_custom_background_args', array( 'default-color' => 'ffffff', 'default-image' => '', ) ) ); add_action ( 'wp_before_admin_bar_render', 'madar_add_help_button' ); } function madar_add_help_button() { if ( current_user_can( 'edit_theme_options' ) ) { global $wp_admin_bar; $wp_admin_bar->add_menu( array( 'parent' => 'top-secondary', // Off on the right side 'id' => 'madar-lite-retina' , 'title' => __( 'Help' , 'madar-lite' ), 'href' => admin_url( 'themes.php?page=madar-lite-welcome' ), 'meta' => array( 'title' => __( 'Need help with Madar Lite? Click here!', 'madar-lite' ), ), )); } } function madarlite_about_page() { add_theme_page( __('Madar Lite Panel','madar-lite'), __('Madar Lite Panel','madar-lite'), 'edit_theme_options', 'theme-about', 'madarlite_theme_about' ); } add_action('admin_menu', 'madarlite_about_page'); function madarlite_theme_about() { require_once ( trailingslashit(get_template_directory()) . 'inc/theme-about.php' ); } // Functions for adding script to Admin Area function madarlite_admin_style() { wp_enqueue_style( 'madarlite_about_css', get_template_directory_uri() . '/inc/admin-style.css', false ); } add_action( 'admin_enqueue_scripts', 'madarlite_admin_style' ); if ( ! function_exists( 'madarlite_fonts_url' ) ) : /** * Register default Google fonts */ /** * Register default Google fonts */ function madarlite_fonts_url() { $fonts_url = ''; /* Translators: If there are characters in your language that are not * supported by Open Sans, translate this to 'off'. Do not translate * into your own language. */ $open_sans = _x( 'on', 'Open Sans font: on or off', 'madar-lite' ); /* Translators: If there are characters in your language that are not * supported by Oswald, translate this to 'off'. Do not translate * into your own language. */ $oswald = _x( 'on', 'Oswald font: on or off', 'madar-lite' ); if ( 'off' !== $oswald || 'off' !== $open_sans ) { $font_families = array(); if ( 'off' !== $oswald ) { $font_families[] = 'Oswald:400,500,600,700,300,100,800,900'; } if ( 'off' !== $open_sans ) { $font_families[] = 'Open Sans:400,300,300italic,400italic,600,600italic,700,700italic'; } $query_args = array( 'family' => urlencode( implode( '|', $font_families ) ), 'subset' => urlencode( 'latin,latin-ext' ), ); $fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' ); } return esc_url_raw( $fonts_url ); } endif; /* * Category Color Options */ if ( ! function_exists( 'madarlite_category_color' ) ) : function madarlite_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('madarlite_category_color_'.$wp_category_id); return $color; } } endif; /* * Use of the hooks for Category Color in the archive titles */ function madarlite_colored_category_title($title) { $color_value = madarlite_category_color(get_cat_id($title)); $color_border_value = madarlite_category_color(get_cat_id($title)); if ( !empty($color_value) ) { return '

'.''.$title.'

'; } else { return '

'.$title.'

'; } } function madarlite_category_title_function($category_title) { add_filter('single_cat_title', 'madarlite_colored_category_title'); } add_action('madarlite_category_title','madarlite_category_title_function'); if ( !function_exists('madarlite_colored_category') ) : function madarlite_colored_category() { global $post; $categories = get_the_category(); $separator = ' '; $output = ''; if($categories) { $output .= '
'; foreach($categories as $category) { $color_code = madarlite_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; /*-----------------------------------------------------------------------------------*/ # @ Get Madar Navigation Fallback /*-----------------------------------------------------------------------------------*/ function madarlite_nav_fallback(){ echo '' . __( 'Create your menu here', 'madar-lite' ) . ''; } /*-----------------------------------------------------------------------------------*/ # Get Madar Principal Files ! /*-----------------------------------------------------------------------------------*/ // Excerpt Length function madarlite_excerpt_length( $length ) { global $madarlite_excerptlength; if ($madarlite_excerptlength) { return $madarlite_excerptlength; } else { return 30; //default value } } add_filter( 'excerpt_length', 'madarlite_excerpt_length', 999 ); function madarlite_excerpt_more($more) { $getappend = esc_html__( ' Continue Reading »', 'madar-lite' ); return ''.$getappend.''; } add_filter('excerpt_more', 'madarlite_excerpt_more'); function madarlite_posted_on() { $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 = '' . $time_string . ''; echo '
' . $posted_on . '
'; $categories_list = get_the_category_list( __( ', ', 'madar-lite' ) ); if ( $categories_list && madarlite_categorized_blog() ) { echo '
' . $categories_list . '
'; } } function madarlite_categorized_blog() { if ( false === ( $all_the_cool_cats = get_transient( 'madarlite_categories' ) ) ) { // Create an array of all the categories that are attached to posts. $all_the_cool_cats = get_categories( array( 'fields' => 'ids', 'hide_empty' => 1, // We only need to know if there is more than one category. 'number' => 2, ) ); // Count the number of categories that are attached to the posts. $all_the_cool_cats = count( $all_the_cool_cats ); set_transient( 'madarlite_categories', $all_the_cool_cats ); } if ( $all_the_cool_cats > 1 ) { // This blog has more than 1 category so madarlite_categorized_blog should return true. return true; } else { // This blog has only 1 category so madarlite_categorized_blog should return false. return false; } } function madarlite_post_meta(){ ?>

' . __('Read More','madar-lite') . ''); else: the_excerpt(); endif; } // Post Author and Date Design function madarlite_author_meta() { $archive_year = get_the_time('Y'); $archive_month = get_the_time('m'); $archive_day = get_the_time('d'); ?>

'', 'link_before'=> '
', 'link_after'=> '
', 'next_or_number'=> 'number', 'nextpagelink' => __('Next page', 'madar-lite'), 'previouspagelink'=> __('Previous page', 'madar-lite'), 'pagelink'=> '%', ); /*-----------------------------------------------------------------------------------*/ # @ Get Madar Custom Image Resizer /*-----------------------------------------------------------------------------------*/ function madarlite_thumb($width='315', $height='150', $type){ $feat_image = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?> <?php the_title(); ?> height="" width=""> get_the_title())); } ?> get_the_title(), 'title' => get_the_title())); } ?> comment_content); $blah = explode(' ', $comment_text); if (count($blah) > $num_words) { $k = $num_words; $use_dotdotdot = 1; } else { $k = count($blah); $use_dotdotdot = 0; } $excerpt = ''; for ($i=0; $i<$k; $i++) { $excerpt .= $blah[$i] . ' '; } $excerpt .= ($use_dotdotdot) ? '...' : ''; return apply_filters('get_comment_excerpt', $excerpt); } /*-----------------------------------------------------------------------------------*/ # @ Get Madar Comment Counter /*-----------------------------------------------------------------------------------*/ function madarlite_getcomment_count($id, $post='normal'){ if ($post == 'normal'){ $num_comments = get_comments_number($id); // get_comments_number returns only a numeric value if ( comments_open() ) { if ( $num_comments == 0 ) { $comments = __('0', 'madar-lite'); } elseif ( $num_comments > 1 ) { $comments = $num_comments . ' ' . __('Comments', 'madar-lite'); } else { $comments = '1 ' . __('reply', 'madar-lite'); } $write_comments = ''. $comments.''; } else { $write_comments = __('Closed', 'madar-lite'); } return $write_comments; }elseif ($post == 'index') { $num_comments = get_comments_number($id); // get_comments_number returns only a numeric value if ( comments_open() ) { if ( $num_comments == 0 ) { $write_comments = '0'; } elseif ( $num_comments > 1 ) { $write_comments = $num_comments . ''; } else { $write_comments = '1'; } } else { $write_comments = 'closed'; } return $write_comments; }elseif ($post == 'post') { $num_comments = get_comments_number(); // get_comments_number returns only a numeric value if ( comments_open() ) { if ( $num_comments == 0 ) { $comments = '0'; $commentsdesc = __('Be First!', 'madar-lite'); } elseif ( $num_comments > 1 ) { $comments = $num_comments; $commentsdesc = __('Comments', 'madar-lite'); } else { $comments = '1'; $commentsdesc = __('Comment', 'madar-lite'); } $write_comments = '
'. $comments.'
'. $commentsdesc.'
'; } else { $write_comments = __('Closed', 'madar-lite'); } return $write_comments; } } /*-----------------------------------------------------------------------------------*/ # @ Get Madar Random Post /*-----------------------------------------------------------------------------------*/ add_action('init', 'madarlite_random_post'); function madarlite_random_post(){ if ( isset($_GET['madarliterand']) ){ $args = array( 'posts_per_page' => 1, 'orderby' => 'rand', 'no_found_rows' => true, 'ignore_sticky_posts' => true ); $random = new WP_Query( $args ); if ($random->have_posts()) { while ($random->have_posts()) : $random->the_post(); $URL = get_permalink(); endwhile; wp_reset_query(); ?> have_posts()) : $data->the_post(); ?>