<?php

function jenny_theme_setup() {

	add_theme_support( 'title-tag' );

	/*
	 * Enable support for custom logo.
	 *
	 *  @since Jenny 1.0
	 */
	add_theme_support( 'custom-logo', array(
		'height'      => 120,
		'width'       => 360,
		'flex-height' => true,
	) );

	/**
	 * Enable support for Post Thumbnails on posts and pages.
	 *
	 * @link http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails
	 */
	add_theme_support( 'post-thumbnails' );

	add_theme_support( 'custom-header', apply_filters( 'custom_header_args', array(
		'default-text-color'     => '#121212',
		'width'                  => 1800,
		'height'                 => 450,
		'flex-height'            => true,
		'wp-head-callback'       => 'jenny_header_style',
	) ) );

	$defaults = array(
		'default-color'          => '#E0E8EF',
		'default-repeat'         => 'no-repeat',
		'default-position-x'     => 'center',
		'wp-head-callback'       => '_custom_background_cb',
	);

	add_theme_support( 'custom-background', $defaults );

	add_theme_support( 'screen-reader-text' );

	add_theme_support( 'automatic-feed-links' );

	add_theme_support( 'html5', array( 'comment-list', 'comment-form', 'gallery', 'caption' ) );

	// Add support for Responsive Embeds
	add_theme_support( 'responsive-embeds'); 

	// Add support for Block Styles
	add_theme_support( 'wp-block-styles' );

	// Add support for editor styles
	add_theme_support( 'editor-styles' );
	add_editor_style( get_template_directory_uri() . '/assets/css/editor-style.css' );

	// Load Text Domain
	load_theme_textdomain( 'jenny', get_template_directory() . '/languages' );

	// Post Formats
	add_theme_support( 'post-formats', array( 'gallery', 'video', 'audio' ) );


	register_nav_menus( array(
            'primary' => __( 'Primary Menu', 'jenny' ),
            'footer'  => __( 'Footer Menu', 'jenny' ),
        ) );
        


	if ( ! isset( $content_width ) ) $content_width = 1080;
}

function jenny_body_classes( $classes ) {
	// Adds "custom-background-image" class when custom background image present
	if ( get_background_image() ) {
		$classes[] = 'custom-background-image';
	}
	// Adds color class when custom color scheme chosen from theme settings
	if ( get_theme_mod( 'jenny_layout_color_setting', 'default') !== 'default') {
		$classes[] = get_theme_mod( 'jenny_layout_color_setting', 'default');
	}

	return $classes;
}
add_filter( 'body_class', 'jenny_body_classes' );


/**
 * Handles JavaScript detection.
 *
 * Adds a `js` class to the root `<html>` element when JavaScript is detected.
 *
 * @since Jenny 1.0
 */
function jenny_javascript_detection() {
	echo "<script>(function(html){html.className = html.className.replace(/\bno-js\b/,'js')})(document.documentElement);</script>\n";
}
add_action( 'wp_head', 'jenny_javascript_detection', 0 );