<?php 
/*
Funtionality is added by ibbuzz team
for the theme of first ibbuzzteam
*/


define('IBBUZZTHEME_INCLUDES', get_template_directory() . '/includes/');
define('IBBUZZTHEME_THEME', 'MACRONINE LITE');
define('IBBUZZTHEME_ROOT', get_template_directory_uri());
define('IBBUZZTHEME_VAR_PREFIX', 'ibbtwp_'); 

require_once (IBBUZZTHEME_INCLUDES . 'ibbt_theme_functions.php');

if (is_admin()) :
require_once (IBBUZZTHEME_INCLUDES . 'ibbt_admin_functions.php');
require_once (IBBUZZTHEME_INCLUDES . 'ibbt_admin_1.php');
require_once (IBBUZZTHEME_INCLUDES . 'ibbt_admin_2.php');
endif;


add_theme_support('title-tag');  //Enable Title Tag
add_theme_support('post-thumbnails');
add_theme_support( 'post-formats', array( 'aside', 'gallery', 'video','link','image','quote','status','audio','chat' ) );
add_theme_support( "custom-background");
add_theme_support( "custom-header" );
add_theme_support( 'menus' );
add_theme_support( 'html5', array( 'comment-list', 'comment-form', 'search-form', 'gallery', 'caption' ) );
add_theme_support('automatic-feed-links');
add_theme_support( 'woocommerce' ); //woocommerce support 
add_theme_support( 'customize-selective-refresh-widgets' );


function macronine_lite_setup() {
	
	add_editor_style( array( 'css/editor-style.css') );
}
add_action( 'after_setup_theme', 'macronine_lite_setup' );

if ( ! function_exists('ibbuzztheme_comment') ) :

if ( ! isset( $content_width ) ) {
	$content_width = 660;
}


add_theme_support( 'custom-logo' );

function macronine_custom_logo() {
	if ( function_exists( 'the_custom_logo' ) ) {
		the_custom_logo();
	}
}


function ibbuzztheme_comment( $comment, $args, $depth ) {
	$GLOBALS['comment'] = $comment;
	switch ( $comment->comment_type ) :
		case 'pingback' :
		case 'trackback' :
		
	?>
	<li <?php comment_class(); ?> id="comment-<?php comment_ID(); ?>">
		<p><?php _e( 'Pingback:', 'macronine-lite' ); ?> <?php comment_author_link(); ?> <?php edit_comment_link( __( '(Edit)', 'macronine-lite' ), '<span class="edit-link">', '</span>' ); ?></p>
	<?php
			break;
		default :
		// Proceed with normal comments.
		global $post;
	?>
	<li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
		<article id="comment-<?php comment_ID(); ?>" class="comment">
			<header class="comment-meta comment-author vcard">
				<?php
					echo get_avatar( $comment, 44 );
					printf( '<cite><b class="fn">%1$s</b> %2$s</cite>',
						get_comment_author_link(),
						// If current post author is also comment author, make it known visually.
						( $comment->user_id === $post->post_author ) ? '<span>' . __( 'Post author', 'macronine-lite' ) . '</span>' : ''
					);
					printf( '<a href="%1$s"><time datetime="%2$s">%3$s</time></a>',
						esc_url( get_comment_link( $comment->comment_ID ) ),
						get_comment_time( 'c' ),
						/* translators: 1: date, 2: time */
						sprintf( __( '%1$s at %2$s', 'macronine-lite' ), get_comment_date(), get_comment_time() )
					);
				?>
			</header><!-- .comment-meta -->

			<?php if ( '0' == $comment->comment_approved ) : ?>
				<p class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'macronine-lite' ); ?></p>
			<?php endif; ?>

			<section class="comment-content comment">
				<?php comment_text(); ?>
				<?php edit_comment_link( __( 'Edit', 'macronine-lite' ), '<p class="edit-link">', '</p>' ); ?>
			</section><!-- .comment-content -->

			<div class="reply">
				<?php comment_reply_link( array_merge( $args, array( 'reply_text' => __( 'Reply', 'macronine-lite' ), 'after' => ' <span>&darr;</span>', 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
			</div><!-- .reply -->
		</article><!-- #comment-## -->
	<?php
		break;
	endswitch; // end comment_type check
}
endif;

if ( ! function_exists( 'ibbuzztheme_entry_meta' ) ) :

function ibbuzztheme_entry_meta() {
	// Translators: used between list items, there is a space after the comma.
	$categories_list = get_the_category_list( __( ', ', 'macronine-lite' ) );

	// Translators: used between list items, there is a space after the comma.
	$tag_list = get_the_tag_list( '', __( ', ', 'macronine-lite' ) );

	$date = sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a>',
		esc_url( get_permalink() ),
		esc_attr( get_the_time() ),
		esc_attr( get_the_date( 'c' ) ),
		esc_html( get_the_date() )
	);

	$author = sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s</a></span>',
		esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
		esc_attr( sprintf( __( 'View all posts by %s', 'macronine-lite' ), get_the_author() ) ),
		get_the_author()
	);

	
}
endif;



add_action( 'customize_register', 'themename_customize_register' );
function themename_customize_register($wp_customize) {

    $wp_customize->add_section( 'ignite_custom_logo', array(
        'title'          => 'Logo',
        'description'    => 'Display a custom logo?',
        'priority'       => 25,
    ) );

    $wp_customize->add_setting( 'custom_logo', array(
        'default'        => '',
		'sanitize_callback' => 'macroninelite_the_custom_logo',
    ) );

    $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'custom_logo', array(
        'label'   => 'Custom logo',
        'section' => 'ignite_custom_logo',
        'settings'   => 'custom_logo',
    ) ) );
}

if ( ! function_exists( 'macroninelite_the_custom_logo' ) ) :
function macroninelite_the_custom_logo() {
	if ( function_exists( 'the_custom_logo' ) ) {
		the_custom_logo();
	}
}
endif;

//  add subtitle to posts and pages
function vg_subtitle($posttitle) {
   global $post;
   $subtitle = get_post_meta ($post->ID, 'Subtitle', true);
   echo $posttitle;
   if ($subtitle) echo ' - ' . $subtitle;
}
add_action('thematic_postheader_posttitle','vg_subtitle');


function macronine_widgets_init() {    

	register_sidebar(array(
        'name' => __('Sidebar', 'macronine-lite'),
        'id' => 'sidebar-1',
        'before_widget' => '<aside id="%1$s" class="widget %2$s">',
        'after_widget' => '</aside>',
        'before_title' => '<h2 class="widget-title">',
        'after_title' => '</h2>',
	));
}

add_action('widgets_init', 'macronine_widgets_init');


function get_breadcrumb() {
    echo '<a href="'.home_url().'" rel="nofollow">Home</a>';
    if (is_category() || is_single()) {
        echo "&nbsp;&nbsp;&#187;&nbsp;&nbsp;";
        the_category(' &bull; ');
            if (is_single()) {
                echo " &nbsp;&nbsp;&#187;&nbsp;&nbsp; ";
                the_title();
            }
    } elseif (is_page()) {
        echo "&nbsp;&nbsp;&#187;&nbsp;&nbsp;";
        echo the_title();
    } elseif (is_search()) {
        echo "&nbsp;&nbsp;&#187;&nbsp;&nbsp;Search Results for... ";
        echo '"<em>';
        echo the_search_query();
        echo '</em>"';
    }
}


function header_fallback() {    

	echo '<ul class="nav navbar-nav responsive-nav main-nav-list">';

		wp_list_pages(array('title_li' => '', 'depth' => 1));

    echo '</ul>';

}



?>