<?php
/*
* All the functions and definitions for Ballyhoo are here.
*
* @package Ballyhoo
*/
/*require get_template_directory() . '/color-scheme.php';

new Theme_Prefix_Color_Scheme;*/
function ballyhoo_widgets_init() {
register_sidebar( array(
'name'          => 'Sidebar',
'id'            => 'sidebar',
'before_widget' => '<div class="widgets">',
'after_widget'  => '</div><br>',
'before_title'  => '<h2 class="sidebar-title">',
'after_title'   => '</h2>',
) );
}
add_action( 'widgets_init', 'ballyhoo_widgets_init' );
function ballyhoo_footer_widgets_init() {
register_sidebar( array(
'name'          => 'Footer 1',
'id'            => 'footer-1',
'before_widget' => '<div class="bwidgets">',
'after_widget'  => '</div><br>',
'before_title'  => '<h2 class="footer-widget-title">',
'after_title'   => '</h2>',
) );
}
add_action('widgets_init', 'ballyhoo_footer_widgets_init');

function ballyhoo_footer_2_widgets_init() {

register_sidebar( array(

'name'          => 'Footer 2',

'id'            => 'footer-2',

'before_widget' => '<div class="widgets">',

'after_widget'  => '</div><br>',

'before_title'  => '<h2 class="footer-widget-title">',

'after_title'   => '</h2>',

) );

}

add_action('widgets_init', 'ballyhoo_footer_2_widgets_init');

function ballyhoo_footer_3_widgets_init() {

register_sidebar( array(

'name'          => 'Footer 3',

'id'            => 'footer-3',

'before_widget' => '<div class="widgets">',

'after_widget'  => '</div><br>',

'before_title'  => '<h2 class="footer-widget-title">',

'after_title'   => '</h2>',

) );

}

add_action('widgets_init', 'ballyhoo_footer_3_widgets_init');
wp_enqueue_style( 'google-fonts-code', 'https://fonts.googleapis.com/css?family=Open+Sans:300,400,700' );
// The Add Theme Support section - code that lets WordPress know our theme supports particular features
add_theme_support('status');
add_theme_support('title-tag');
add_theme_support('post-formats', array('aside', 'chat', 'gallery', 'image', 'link', 'quote', 'status', 'video', 'audio'));
add_theme_support('related-posts');
add_theme_support('post-thumbnails');
add_theme_support('jetpack-responsive-videos');
add_theme_support('automatic-feed-links');
add_theme_support('wp-block-styles');
add_theme_support( 'html5', array(
			'search-form',
			'comment-form',
			'comment-list',
			'gallery',
			'caption',
		) );
add_theme_support( 'gutenberg', array(
    'wide-images' => true,
    'colors' => array(
        '#ffffff',
        '#111111',
        '#cccccc',
    ),
 
) );
$defaults = array(
	'default-color'          => '#ffffff',
	'default-image'          => ''
);
add_theme_support('custom-background', $defaults);
$args = array(
	'default-image'          => 'http://photos.calumchilds.com/imgs/IMG_LEAF_FROST.jpg',
	'width'                  => 1400,
	'height'                 => 400,
	'flex-height'            => false,
	'flex-width'             => false,
	'uploads'                => true,
	'random-default'         => false,
	'header-text'            => true,
	'default-text-color'     => '#111111',
	'wp-head-callback'       => '',
	'admin-head-callback'    => '',
	'admin-preview-callback' => '',
);
add_theme_support( 'custom-header', $args);
add_theme_support('custom-logo');
function woocommerce_support() {
add_theme_support( 'woocommerce' );
}
add_action( 'ballyhoo','woocommerce_support' );
add_theme_support( 'wc-product-gallery-zoom' );
add_theme_support( 'wc-product-gallery-lightbox' );
add_theme_support( 'wc-product-gallery-slider' );
function ballyhoo_add_woocommerce_support() {
    add_theme_support( 'woocommerce', array(
        'thumbnail_image_width' => 150,
        'single_image_width'    => 300,

        'product_grid'          => array(
            'default_rows'    => 3,
            'min_rows'        => 2,
            'max_rows'        => 8,
            'default_columns' => 4,
            'min_columns'     => 2,
            'max_columns'     => 5,
        ),
    ) );
}
add_action( 'after_setup_theme', 'ballyhoo_add_woocommerce_support' );
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 );
function fa_version_number() {
	// Put Font Awesome version number here after the v - 5.3.1 is the default.
	echo 'v5.3.1';
}
function ballyhoo_slug_editor_styles() {
    wp_enqueue_style( 'ballyhoo-slug-editor-style', get_template_directory_uri() . '/editor-style.css' );
}
add_action( 'enqueue_block_editor_assets', 'ballyhoo_slug_editor_styles' );
if ( ! isset( $content_width ) ) :
$content_width = 900;
endif;
// ballyhoo_index_post(); outputs different code based on the post-type defined between the two brackets
// For example: the default post type is defined as ballyhoo_index_post('normal');
// If nothing is there between the two brackets, the code for the Normal post type will be outputted.
function ballyhoo_index_post($post_type) {
	?>
<?php if ($post_type === 'aside') : ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h1 class="post-title"><?php the_title(); ?></h1>
<?php the_post_thumbnail( 'single-post-thumbnail' ); ?>
<?php the_content(); ?>
</div>
<?php elseif ($post_type === 'audio') : ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h1 class="post-title"><?php the_title(); ?></h1>
<?php the_post_thumbnail( 'single-post-thumbnail' ); ?>
<?php the_content(); ?>
</div>
<?php elseif ($post_type === 'chat') : ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h1 class="post-title"><?php the_title(); ?></h1>
<p class="post-comment-number"><i class="far fa-comment" aria-label="Number of comments:" title="Number of comments"></i> <?php comments_popup_link('No Comments', '1 Comment', '% Comments', 'ballyhoo'); ?></p>
<?php the_post_thumbnail( 'single-post-thumbnail' ); ?>
<?php the_content(); ?>
</div>
<?php elseif ($post_type === 'gallery') : ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<a href="<?php the_permalink(); ?>" class="post-link-title"><h1 class="post-title"><?php the_title(); ?></h1></a>
<?php the_post_thumbnail( 'single-post-thumbnail' ); ?>
<?php the_content(); ?>
</div>
<?php elseif ($post_type === 'quote') : ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<a href="<?php the_permalink(); ?>" class="post-link-title"><h1 class="post-title"><?php the_title(); ?></h1></a>
<?php the_post_thumbnail( 'single-post-thumbnail' ); ?>
<?php the_content(); ?>
</div>
<?php elseif ($post_type === 'link') : ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<a href="<?php the_permalink(); ?>" class="post-link-title"><h1 class="post-title"><?php the_title(); ?></h1></a>
<?php the_post_thumbnail('single-post-thumbnail'); ?>
<?php the_content(); ?>
</div>
<?php elseif ($post_type === 'status') : ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<a href="<?php the_permalink(); ?>" class="post-link-title"><h1 class="post-title"><?php the_title(); ?></h1></a>
<p class="post-published-date"><i class="far fa-clock" aria-label="Date and time published:" title="Date and time published:"></i> <?php echo get_the_date(); ?> <?php echo get_the_time(); ?></p>
<?php the_content(); ?>
</div>
<?php elseif ($post_type === 'image') : ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<a href="<?php the_permalink(); ?>" class="post-link-title"><h1 class="post-title"><?php the_title(); ?></h1></a>
<?php the_post_thumbnail('single-post-thumbnail'); ?>
<?php the_content(); ?>
<?php elseif ($post_type === 'normal') : ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<a href="<?php the_permalink(); ?>" class="post-link-title"><h1 class="post-title"><?php the_title(); ?></h1></a>
<?php the_post_thumbnail( 'single-post-thumbnail' ); ?>
<p class="post-published-date"><i class="far fa-clock" aria-label="Date published:" title="Date published:"></i> <?php echo get_the_date(); ?></p> 
<p class="post-comment-number"><i class="far fa-comment" aria-label="Number of comments:" title="Number of comments"></i> <?php comments_popup_link('No Comments', '1 Comment', '% Comments', 'ballyhoo'); ?></p>
<p class="post-author"><i class="far fa-user"></i> <?php the_author(); ?></p>
<?php the_excerpt(); ?>
<a class="button" href="<?php the_permalink(); ?>"><?php echo esc_html('Tell me more...', 'ballyhoo'); ?></a>
</div>
<?php endif; ?>
<?php
}