'Sidebar',
'id' => 'sidebar',
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '',
) );
}
add_action( 'widgets_init', 'ballyhoo_widgets_init' );
function ballyhoo_footer_widgets_init() {
register_sidebar( array(
'name' => 'Footer 1',
'id' => 'footer-1',
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
) );
}
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' => '',
'after_widget' => '
',
'before_title' => '',
) );
}
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' => '',
'after_widget' => '
',
'before_title' => '',
) );
}
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,400i' );
// 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' => get_template_directory_uri(), '/imgs/book.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 ballyhoo_the_custom_logo() {
if ( function_exists( 'the_custom_logo' ) ) {
the_custom_logo();
}
}
function bh_woocommerce_support() {
add_theme_support( 'ballyhoo' );
}
add_action( 'ballyhoo','bh_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( 'ballyhoo', 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 );
// End Add Theme Support section
// Functions to register and carry out Theme Customization functions
function ballyhoo_customize_register($wp_customize) {
// Defining the settings
$wp_customize->add_setting( 'font_family' , array(
'default' => 'Open Sans',
'sanitize_callback' => 'sanitize_font_family',
'transport' => 'refresh',
));
$wp_customize->add_setting('ballyhoo_banner', array(
'default' => 'no',
'sanitize_callback' => 'sanitize_ballyhoo_banner',
'transport' => 'refresh',
));
$wp_customize->add_setting('ballyhoo_copyright_text', array(
'default' => '0',
'sanitize_callback' => 'sanitize_ballyhoo_checkbox',
'transport' => 'refresh',
));
$wp_customize->add_setting('site_name_navigation_bar', array(
'default' => '0',
'sanitize_callback' => 'sanitize_ballyhoo_checkbox',
'transport' => 'refresh',
));
$wp_customize->add_setting('banner_text', array(
'default' => 'Your lovely banner text',
'sanitize_callback' => 'esc_html',
'transport' => 'refresh',
));
$wp_customize->add_setting('banner_colour', array(
'default' => '#111111',
'sanitize_callback' => 'sanitize_hex_color',
'transport' => 'refresh',
));
$wp_customize->add_setting('banner_text_colour', array(
'default' => '#ffffff',
'sanitize_callback' => 'sanitize_hex_color',
'transport' => 'refresh',
));
// Defining the section (where the Settings are)
$wp_customize->add_section('theme_options', array(
'title' => __('Theme Options', 'ballyhoo'),
'priority' => '170',
));
// Defining the options
$wp_customize->add_control('font__family', array(
'label' => __( 'Font Family', 'ballyhoo' ),
'description' => 'Select a font family from below',
'section' => 'theme_options',
'settings' => 'font_family',
'default' => 'Open Sans',
'type' => 'select',
'choices' => array(
'Arial' => 'Arial',
'Arima Madurai' => 'Arima Madurai',
'Arimo' => 'Arimo',
'Atma' => 'Atma',
'Assistant' => 'Assistant',
'Calibri' => 'Calibri',
'Chivo' => 'Chivo',
'Cinzel Decorative' => 'Cinzel Decorative',
'Comic Sans MS' => 'Comic Sans MS',
'Comfortaa' => 'Comfortaa',
'Dosis' => 'Dosis',
'Exo' => 'Exo',
'Fira Sans' => 'Fira Sans',
'Gelasio' => 'Gelasio',
'Georgia' => 'Georgia',
'Heebo' => 'Heebo',
'Inria Serif' => 'Inria Serif',
'Kalam' => 'Kalam',
'Khula' => 'Khula',
'Kulim Park' => 'Kulim Park',
'Lato' => 'Lato',
'Lucida Console' => 'Lucida Console',
'Lucida Handwriting' => 'Lucida Handwriting',
'Merriweather' => 'Merriweather',
'Monaco' => 'Monaco',
'Mali' => 'Mali',
'Mitr' => 'Mitr',
'Muli' => 'Muli',
'Montserrat' => 'Montserrat',
'Mukta' => 'Mukta',
'Nunito' => 'Nunito',
'Open Sans' => 'Open Sans (default)',
'Open Sans Condensed' => 'Open Sans Condensed',
'Overpass' => 'Overpass',
'Overpass Mono' => 'Overpass Mono',
'Oxygen' => 'Oxygen',
'Playfair Display' => 'Playfair Display',
'Poppins' => 'Poppins',
'Public Sans' => 'Public Sans',
'Quicksand' => 'Quicksand',
'Raleway' => 'Raleway',
'Roboto' => 'Roboto',
'Roboto Mono' => 'Roboto Mono',
'Roboto Slab' => 'Roboto Slab',
'Rubik' => 'Rubik',
'Times New Roman' => 'Times New Roman',
'Titillium Web' => 'Titillium Web',
'Ubuntu' => 'Ubuntu',
'Verdana' => 'Verdana',
'Work Sans' => 'Work Sans',
'Yantramanav' => 'Yantramanav',
),
)
);
$wp_customize->add_control('ballyhoo__banner', array(
'label' => __('Banner', 'ballyhoo'),
'description' => 'Do you want a banner that displays above the website details?',
'section' => 'theme_options',
'settings' => 'ballyhoo_banner',
'default' => 'no',
'type' => 'radio',
'choices' => array(
'yes' => 'Yes',
'no' => 'No',
),
));
$wp_customize->add_control('ballyhoo__copyright_text', array(
'label' => __('Display copyright text below footer', 'ballyhoo'),
'section' => 'theme_options',
'settings' => 'ballyhoo_copyright_text',
'default' => '0',
'type' => 'checkbox',
'priority' => '70',
));
$wp_customize->add_control('site__name__navigation__bar', array(
'label' => __('Add link to homepage with website name on navigation bar', 'ballyhoo'),
'section' => 'theme_options',
'settings' => 'site_name_navigation_bar',
'default' => '0',
'type' => 'checkbox',
'priority' => '80',
));
$wp_customize->add_control('banner__text', array(
'label' => __('Banner Text', 'ballyhoo'),
'description' => 'If you have enabled the banner, type in your text for the banner here:',
'section' => 'theme_options',
'settings' => 'banner_text',
'default' => '',
'type' => 'text',
));
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'banner_colour', array(
'label' => __( 'Banner Colour', 'ballyhoo' ),
'section' => 'theme_options',
)));
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'banner_text_colour', array(
'label' => __( 'Banner Text Colour', 'ballyhoo' ),
'section' => 'theme_options',
)));
}
add_action( 'customize_register', 'ballyhoo_customize_register' );
$bh_font_preference = get_theme_mod('font__family', 'Open Sans');
function sanitize_font_family( $default_family ) {
if ( ! in_array( $default_family, array( 'Arial', 'Arima Madurai', 'Arimo', 'Atma', 'Assistant', 'Calibri', 'Chivo', 'Cinzel Decorative', 'Comic Sans MS', 'Comfortaa', 'Dosis', 'Exo', 'Fira Sans', 'Gelasio', 'Georgia', 'Heebo', 'Inria Serif', 'Kalam', 'Khula', 'Kulim Park', 'Lato', 'Lucida Console', 'Lucida Handwriting', 'Merriweather', 'Monaco', 'Mali', 'Mitr', 'Muli', 'Montserrat', 'Mukta', 'Nunito', 'Open Sans', 'Open Sans (default)', 'Open Sans Condensed', 'Overpass', 'Overpass Mono', 'Oxygen', 'Playfair Display', 'Poppins', 'Public Sans', 'Quicksand', 'Raleway', 'Roboto', 'Roboto Mono', 'Roboto Slab', 'Rubik', 'Times New Roman', 'Titillium Web', 'Ubuntu', 'Verdana', 'Work Sans', 'Yantramanav') ) ) {
$default_family = 'Open Sans';
}
return $default_family;
}
function sanitize_ballyhoo_banner( $default_banner ) {
if ( ! in_array( $default_banner, array( 'Yes', 'yes', 'No', 'no') ) ) {
$default_banner = 'no';
}
return $default_banner;
}
function sanitize_ballyhoo_checkbox($checkbox_setting) {
if ($checkbox_setting == '0' or '1') {
return $checkbox_setting;
}
else {
return;
}
}
// End Theme Customization Functions
// Custom functions - functions exclusive to this theme - see ballyhoo.calumchilds.com/documentation/functions for documentation
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) {
?>