<?php
/**
 * Functions which enhance the theme by hooking into WordPress
 *
 * @package guj
 */

/**
 * Adds custom classes to the array of body classes.
 *
 * @param array $classes Classes for the body element.
 * @return array
 */
function guj_body_classes( $classes ) {
	// Adds a class of hfeed to non-singular pages.
	if ( ! is_singular() ) {
		$classes[] = 'hfeed';
		$classes[] = 'archive-view';
	}

        // Adds a class as per blog layout
        $blog_content_layout = guj_get_option('blog_layout_options');
        
        if ( !is_page() && is_active_sidebar('sidebar-1') && 'pull-left' === $blog_content_layout) {
            $classes[] = 'left-sidebar';
            
        } 
        
        if ( !is_page() && is_active_sidebar('sidebar-1') && 'pull-right' === $blog_content_layout) {
            $classes[] = 'right-sidebar';
            
        } 
        
        if ( !is_page() && is_active_sidebar('sidebar-1') && 'no-sidebar'  === $blog_content_layout ) {
            $classes[] = 'no-sidebar';
        }
        
        // Adds a class as per page layout
        $page_content_layout = guj_get_option('page_layout');
        
        if ( is_page() && is_active_sidebar('sidebar-2') && 'page-pull-left' === $page_content_layout) {
            $classes[] = 'page-left-sidebar';
            
        } 
        
        if ( is_page() && is_active_sidebar('sidebar-2') && 'page-pull-right' === $page_content_layout) {
            $classes[] = 'page-right-sidebar';
            
        } 
        
        if (is_page() && is_active_sidebar('sidebar-2') && 'page-no-sidebar' === $page_content_layout ) {
            $classes[] = 'page-no-sidebar';
        }
	
	return $classes;
}
add_filter( 'body_class', 'guj_body_classes' );

/**
 * Add a pingback url auto-discovery header for single posts, pages, or attachments.
 */
function guj_pingback_header() {
	if ( is_singular() && pings_open() ) {
		echo '<link rel="pingback" href="', esc_url( get_bloginfo( 'pingback_url' ) ), '">';
	}
}
add_action( 'wp_head', 'guj_pingback_header' );
