__( 'Primary Menu', 'realistic' ), 'mobile-menu' => __( 'Mobile Menu', 'realistic' ) ) ); // Switch default core markup for search form, comment form, and comments to output valid HTML5. add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption', ) ); // Enable support for Post Formats. add_theme_support( 'post-formats', array( 'video', ) ); } } add_action( 'after_setup_theme', 'material_setup' ); /*-----------------------------------------------------------------------------------*/ /* Set the content width based on the theme's design and stylesheet. /*-----------------------------------------------------------------------------------*/ if ( ! isset( $content_width ) ) { $content_width = 640; /* pixels */ } /*-----------------------------------------------------------------------------------*/ /* Register Sidebar & Widget-areas /*-----------------------------------------------------------------------------------*/ function material_widgets_init() { register_sidebar( array( 'name' => __( 'Main Sidebar', 'realistic' ), 'id' => 'sidebar', 'description' => 'Main Sidebar widget area.', 'before_widget' => '', 'before_title' => '

', 'after_title' => '

', ) ); } add_action( 'widgets_init', 'material_widgets_init' ); /*-----------------------------------------------------------------------------------*/ /* Enqueue scripts and styles. /*-----------------------------------------------------------------------------------*/ function realistic_scripts() { // Loading jQuery wp_enqueue_script( 'jquery' ); wp_enqueue_script( 'material-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20120206', true ); wp_enqueue_script( 'material-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20130115', true ); if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } // Loading Google's font "Roboto" wp_enqueue_style( 'roboto_google_font', '//fonts.googleapis.com/css?family=Roboto:400italic,300,700,400', false, null, 'all' ); // Loading MDL JS wp_enqueue_script( 'materialjs', get_template_directory_uri() . '/js/material.min.js' ); // Loading MDL CSS ( based on selected Color Scheme ) $theme_color = get_theme_mod( 'theme_color', 'default' ); if ( $theme_color == 'default' ) { wp_enqueue_style('materialcss', get_template_directory_uri().'/css/material-default.min.css'); } elseif ( $theme_color == 'style1' ) { wp_enqueue_style('materialcss', get_template_directory_uri().'/css/material-style1.min.css'); } elseif ( $theme_color == 'style2' ) { wp_enqueue_style('materialcss', get_template_directory_uri().'/css/material-style2.min.css'); } elseif ( $theme_color == 'style3' ) { wp_enqueue_style('materialcss', get_template_directory_uri().'/css/material-style3.min.css'); } elseif ( $theme_color == 'style4' ) { wp_enqueue_style('materialcss', get_template_directory_uri().'/css/material-style4.min.css'); } elseif ( $theme_color == 'style5' ) { wp_enqueue_style('materialcss', get_template_directory_uri().'/css/material-style5.min.css'); } // Loading Material icons wp_enqueue_style( 'materialicons', '//fonts.googleapis.com/icon?family=Material+Icons', false, null, 'all' ); // Loading the Stylesheet wp_enqueue_style( 'material-style', get_stylesheet_uri() ); // Loading Custom font icons wp_enqueue_style( 'fonticons', get_template_directory_uri().'/css/fontello.css' ); } add_action( 'wp_enqueue_scripts', 'realistic_scripts' ); /*-----------------------------------------------------------------------------------*/ /* Custom template tags for this theme. /*-----------------------------------------------------------------------------------*/ require get_template_directory() . '/inc/template-tags.php'; /*-----------------------------------------------------------------------------------*/ /* Custom functions that act independently of the theme templates. /*-----------------------------------------------------------------------------------*/ require get_template_directory() . '/inc/extras.php'; /*-----------------------------------------------------------------------------------*/ /* Load Jetpack compatibility file. /*-----------------------------------------------------------------------------------*/ require get_template_directory() . '/inc/jetpack.php'; /*-----------------------------------------------------------------------------------*/ /* Add Post Thumbnail Support /*-----------------------------------------------------------------------------------*/ if ( function_exists( 'add_theme_support' ) ) { add_theme_support( 'post-thumbnails' ); add_image_size( 'featured', 218, 181, true ); //featured image add_image_size( 'small', 120, 120, true ); //small thumb add_image_size( 'tiny', 70, 70, true ); //tiny thumb } /*-----------------------------------------------------------------------------------*/ /* Loading theme widgets. /*-----------------------------------------------------------------------------------*/ // Add the Social Widget include("functions/widget-socialicons.php"); // Add Recent Posts Widget include("functions/widget-recentposts.php"); // Add Popular Posts Widget include("functions/widget-popularposts.php"); // Add Facebook Like box Widget include("functions/widget-fblikebox.php"); // Add the Login Widget include("functions/widget-login.php"); /*-----------------------------------------------------------------------------------*/ /* adding MDL classes to some HTML elements /*-----------------------------------------------------------------------------------*/ function material_add_mdl_classes() { ?> ID ); if ( $size == 'featured' ) { if (has_post_thumbnail( $post->ID ) ) { $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), $size ); $image = $image[0]; } // use first attached image if no featured image was already set. elseif ( !empty($images) ) { $image = reset($images); $image = wp_get_attachment_image_src( $image->ID, $size ); $image = $image[0]; } else { $image = get_template_directory_uri() . '/images/nothumb-218x181.png'; } } elseif ( $size == 'small' ) { if (has_post_thumbnail( $post->ID ) ) { $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), $size ); $image = $image[0]; } // use first attached image if no featured image was already set. elseif ( !empty($images) ) { $image = reset($images); $image = wp_get_attachment_image_src( $image->ID, $size ); $image = $image[0]; } else { $image = get_template_directory_uri() . '/images/nothumb-120x120.png'; } } else { if (has_post_thumbnail( $post->ID ) ) { $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), $size ); $image = $image[0]; } // use first attached image if no featured image was already set. elseif ( !empty($images) ) { $image = reset($images); $image = wp_get_attachment_image_src( $image->ID, $size ); $image = $image[0]; } else { $image = get_template_directory_uri() . '/images/nothumb-70x70.png'; } } return $image; } } // Get first Video from Video Posts if (!function_exists('realistic_get_first_embed_video')) { function realistic_get_first_embed_video( $post_id ) { $post = get_post( $post_id ); $content = do_shortcode( apply_filters( 'the_content', $post->post_content ) ); $embeds = get_media_embedded_in_content( $content ); if( !empty( $embeds ) ) { //check what is the first embed containg video tag, youtube or vimeo foreach( $embeds as $embed ) { if ( strpos( $embed, 'video' ) || strpos( $embed, 'youtube' ) || strpos( $embed, 'vimeo' ) || strpos( $embed, 'dailymotion' ) || strpos( $embed, 'vine' ) || strpos( $embed, 'wordPress.tv' ) || strpos( $embed, 'hulu' )) { return $embed; } } } else { //No video embedded found return ; } } } // Truncate string to x letters/words. function realistic_truncate( $str, $length = 40, $units = 'letters', $ellipsis = ' …' ) { if ( $units == 'letters' ) { if ( mb_strlen( $str ) > $length ) { return mb_substr( $str, 0, $length ) . $ellipsis; } else { return $str; } } else { $words = explode( ' ', $str ); if ( count( $words ) > $length ) { return implode( " ", array_slice( $words, 0, $length ) ) . $ellipsis; } else { return $str; } } } /*-----------------------------------------------------------------------------------*/ /* Post Format Icon /*-----------------------------------------------------------------------------------*/ if ( ! function_exists( 'realistic_post_format_icon' ) ) { function realistic_post_format_icon( $format = 'format' ) { if ( $format == 'video' ) { $icon = 'play_circle_filled'; } else { $icon = 'description'; } echo '
' . $icon . '
'; } } /*-----------------------------------------------------------------------------------*/ /* Breadcrumbs /*-----------------------------------------------------------------------------------*/ if (!function_exists('realistic_breadcrumb')) { function realistic_breadcrumb() { echo '
'.sprintf( __( "Home","realistic")); echo '
>
'; if (is_category() || is_single()) { $categories = get_the_category(); $output = ''; if($categories){ echo '
'.$categories[0]->cat_name.'
>
'; } if (is_single()) { echo "
"; the_title(); echo "
"; } } elseif (is_page()) { echo "
"; the_title(); echo "
"; } } } /*-----------------------------------------------------------------------------------*/ /* Pagination (for WP 4.0 and earlier versions) /*-----------------------------------------------------------------------------------*/ if (!function_exists('realistic_pagination')) { function realistic_pagination($pages = '', $range = 2) { $showitems = ($range * 1)+1; global $paged; if(empty($paged)) $paged = 1; if($pages == '') { global $wp_query; $pages = $wp_query->max_num_pages; if(!$pages){ $pages = 1; } } if(1 != $pages) { echo ""; } } } /*-----------------------------------------------------------------------------------*/ /* Excerpt /*-----------------------------------------------------------------------------------*/ // Remove [...] & shortcodes. function realistic_custom_excerpt( $output ) { return preg_replace( '/\[[^\]]*]/', '', $output ); } add_filter( 'get_the_excerpt', 'realistic_custom_excerpt' ); remove_filter('the_excerpt', 'wpautop'); if ( ! function_exists( 'realistic_excerpt' ) ) { function realistic_excerpt( $limit = 30 ) { return realistic_truncate( get_the_excerpt(), $limit, 'words' ); } } /*-----------------------------------------------------------------------------------*/ /* Header Area /*-----------------------------------------------------------------------------------*/ // Display favicon if set. if ( ! function_exists( 'realistic_favicon' ) ) { function realistic_favicon() { $favicon_image = get_theme_mod( 'favicon_image', get_template_directory_uri() .'/images/favicon.gif' ); if ( $favicon_image ) { ?> <?php bloginfo('name'); echo ' - '; bloginfo('description'); ?>
name ) . '" ' . '>' . $category[0]->name.''; ?>
= 5 && intval( $length ) <= 120 ) { echo realistic_excerpt( $length ); } } } /*-----------------------------------------------------------------------------------*/ /* Single Post Settings /*-----------------------------------------------------------------------------------*/ //Display meta info if enabled. if ( ! function_exists( 'realistic_post_meta' ) ) { function realistic_post_meta() { $post_meta = get_theme_mod( 'post_meta', '1' ); if ( $post_meta ) { ?>
name ) . '" ' . '>' . $category[0]->name.'
'; echo '
comment
'; _e('Tagged: ', 'realistic'); realistic_entry_tags(); ?>
0 && intval( $related_posts_number ) <= 6 ) { if ( $related_posts_query && $related_posts_query == 'tags') { // Query type: Tags global $post; $orig_post = $post; $tags = wp_get_post_tags($post->ID); if ($tags) { $tag_ids = array(); foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id; $args=array( 'tag__in' => $tag_ids, 'post__not_in' => array($post->ID), 'posts_per_page'=> $related_posts_number, // Number of related posts that will be displayed. 'ignore_sticky_posts'=>1, 'orderby'=>'rand' // Randomize the posts ); $my_query = new wp_query( $args ); if( $my_query->have_posts() ) { ?>