<?php
//$content_width is required even though this is a variable-width theme
if (!isset($content_width))
	$content_width = 400;

//makes replying look neat
if (!function_exists('dwfortnite_threaded_comments')):
function dwfortnite_threaded_comments() {
	if (get_option('thread_comments'))
		wp_enqueue_script('comment-reply');
}
add_action('wp_enqueue_scripts', 'dwfortnite_threaded_comments');
endif;

// displays "Comments are closed" instead of comment form when comments are closed.
if (!function_exists('dwfortnite_closed_comments')):
function dwfortnite_closed_comments() {
	echo '<p>', esc_html__('Comments are closed.', 'dw-fortnite'), '</p>';
}
add_action('comment_form_comments_closed', 'dwfortnite_closed_comments');
endif;

if (!function_exists('dwfortnite_setup')):
function dwfortnite_setup() { //adds theme support
	load_theme_textdomain( 'dw-fortnite', get_template_directory() . '/languages' );
	add_theme_support(
		'custom-logo',
		array(
			'height'      => 190,
			'width'       => 190,
			'flex-width'  => true,
			'flex-height' => true,
		)
	);
	add_theme_support('title-tag');
	add_theme_support('automatic-feed-links');
	add_theme_support('customize-selective-refresh-widgets');
	add_theme_support('post-thumbnails');
	set_post_thumbnail_size( 50, 50);
	add_image_size( 'single-post-thumbnail', 9999, 9999 );
	add_image_size( 'homepage-featured', 150, 150, true );
	add_theme_support('starter-content', array(
	'widgets' => array(
		'left-sidebar' => array(
			array(
				'text',
				array(
					'title' => __('First Sidebar', 'dw-fortnite'),
					'text' => _x('This is some text in the first sidebar.', 'Theme Starter Content', 'dw-fortnite')
				)
			),
			'meta'
		),
		'right-sidebar' => array(
			array(
				'text',
				array(
					'title' => __('Second Sidebar', 'dw-fortnite'),
					'text' => _x('This is some text in the second sidebar.', 'Theme Starter Content', 'dw-fortnite')
				)
			)
		)
	)
));
}
add_action('after_setup_theme', 'dwfortnite_setup');
endif;

if (!function_exists('dwfortnite_register_menu')):
function dwfortnite_register_menu() { //registers the menus, the header menus
	register_nav_menus(
		array(
		  'top_header_menu' => __( 'Top Header Menu', 'dw-fortnite' )
		)
    );
}
add_action( 'init', 'dwfortnite_register_menu' );
endif;

if (!function_exists('dwfortnite_stylesheet')):
function dwfortnite_stylesheet() { //enqueue stylesheets
	wp_enqueue_style('dw-fortnite-style', get_stylesheet_directory_uri().'/style.css');
	/* responsive design: */
	if (is_active_sidebar('left-sidebar')&&is_active_sidebar('right-sidebar')):
		wp_enqueue_style('dw-fortnite-mobile', get_stylesheet_directory_uri().'/mobile.css', array(), false, 'all and (max-width:899px)');
		//if there are two sidebars, use mobile stylesheet at width<900
	elseif (is_active_sidebar('left-sidebar')||is_active_sidebar('right-sidebar')):
		wp_enqueue_style('dw-fortnite-mobile', get_stylesheet_directory_uri().'/mobile.css', array(), false, 'all and (max-width:699px)');
		//if there is one sidebar, use mobile stylesheet at width<700
	else:
		wp_enqueue_style('dw-fortnite-mobile', get_stylesheet_directory_uri().'/mobile.css');
		//if there are no sidebars, use mobile stylesheet without width condition
	endif;
}

add_action('wp_enqueue_scripts', 'dwfortnite_stylesheet');
endif;

if (!function_exists('dwfortnite_sidebars')):
// register the sidebars
function dwfortnite_sidebars() {
	register_sidebar(array(
		'name' => __('Left Sidebar', 'dw-fortnite'),
		'id' => 'left-sidebar'
	));
	register_sidebar(array(
		'name' => __('Right Sidebar', 'dw-fortnite'),
		'id' => 'right-sidebar'
	));
	register_sidebar(array(
		'name' => __('Center Block', 'dw-fortnite'),
		'id' => 'center-block'
	));
}

add_action('widgets_init', 'dwfortnite_sidebars');
endif;

// display information about a post under the post title
if (!function_exists('dwfortnite_post_meta')):
function dwfortnite_post_meta() {
	echo '<div class="meta">';
	if (get_post_type() == 'page'):
		printf(
		/* translators: %s = author */
			esc_html__('Posted by %s', 'dw-fortnite'),
			get_the_author()
		);
	elseif (has_category()):
		printf(
		/* translators: %1$s = date, %2$s = categories, %3$s = author */
			esc_html__('Posted on %1$s in %2$s by %3$s', 'dw-fortnite'),
			get_the_date(),
			wp_kses_post(get_the_category_list(',')),
			get_the_author()
		);
	else:
		printf(
		/* translators: %1$s = date, %2$s = author */
			esc_html__('Posted on %1$s by %2$s', 'dw-fortnite'),
			get_the_date(),
			get_the_author()
		);
	endif;
	edit_post_link(_x('Edit','verb','dw-fortnite'),' | ');
	if (get_post_type() != 'page' && has_tag()):
		echo '<br />';
		the_tags();
	endif;
	echo '</div>';
}
endif;

// change the archive title to show the search query when showing the archive title on a search result page.
if (!function_exists('dwfortnite_search_title')):
function dwfortnite_search_title($title) {
	if (is_search())
	/* translators: %s = search query */
		$title = sprintf(__('Search: %s', 'dw-fortnite'),get_search_query());
	return $title;
}

add_filter('get_the_archive_title', 'dwfortnite_search_title');
endif;

function google_fonts() {
    wp_enqueue_style( 'google-fonts', 'https://fonts.googleapis.com/css2?family=Ubuntu:ital,wght@0,300;0,400;0,500;0,700;1,300;1,400;1,500;1,700&display=swap', false );
}
add_action( 'wp_enqueue_scripts', 'google_fonts' );

// JS Clock

/**
 * Enqueue Clock script
 */
function fortnite_clock_enqueue_scripts() {
    wp_enqueue_script( 'fortnite-header-clock', get_template_directory_uri() . '/js/fortnite-header-clock.js', array(), true );
}
add_action( 'wp_enqueue_scripts', 'fortnite_clock_enqueue_scripts' );

// Premium Upgrade Section
function fortnite_procontent($wp_customize) {
$wp_customize->add_section( 'pro_sec' , array(
    'title'          => __( 'GET PREMIUM VERSION', 'dw-fortnite' ),
    'description'    => '',
    'priority'       => 10,
    'capability'     => 'edit_theme_options',
   
) );



$wp_customize->add_control( 'button_id', array(
    'type' => 'button',
    'settings' => array(),
    'priority' => 10,
    'section' => 'pro_sec',
    'input_attrs' => array(
        'value' => __( 'BUY PREMIUM VERSION', 'dw-fortnite' ),
        'class' => 'button-primary',
        'onclick'=>"window.open('https:/www.designwicked.com/premium-fortnite', '_blank')"
),
) );

$wp_customize->add_control( 'label', array(
    'type' => 'button',
    'settings' => array(),  
    'label'=> __( 'Premium Features:', 'dw-fortnite' ),
    'priority' => 10,
    'section' => 'pro_sec',
    'input_attrs' => array(
        'value' => __( '12 More Widget Blocks', 'dw-fortnite' ),
        'class' => 'button-secondary',
		'onclick'=>"window.open('https:/www.designwicked.com/premium-fortnite', '_blank')"
),
) );

$wp_customize->add_control( 'label1', array(
    'type' => 'button',
    'settings' => array(),  
    
    'priority' => 10,
    'section' => 'pro_sec',
    'input_attrs' => array(
        'value' => __( 'Footer HTML/Text Content Area', 'dw-fortnite' ),
        'class' => 'button-secondary',
        'onclick'=>"window.open('https:/www.designwicked.com/premium-fortnite', '_blank')"
),
) );

$wp_customize->add_control( 'label2', array(
    'type' => 'button',
    'settings' => array(),  
    
    'priority' => 10,
    'section' => 'pro_sec',
    'input_attrs' => array(
        'value' => __( 'Top Header and Bottom Footer Length Widget Area', 'dw-fortnite' ),
        'class' => 'button-secondary',
        'onclick'=>"window.open('https:/www.designwicked.com/premium-fortnite', '_blank')"
),
) );

$wp_customize->add_control( 'label3', array(
    'type' => 'button',
    'settings' => array(),  
    
    'priority' => 10,
    'section' => 'pro_sec',
    'input_attrs' => array(
        'value' => __( 'bbPress Matching Forum Style', 'dw-fortnite' ),
        'class' => 'button-secondary',
        'onclick'=>"window.open('https:/www.designwicked.com/premium-fortnite', '_blank')"
),
) );

$wp_customize->add_control( 'label4', array(
    'type' => 'button',
    'settings' => array(),  
    
    'priority' => 10,
    'section' => 'pro_sec',
    'input_attrs' => array(
        'value' => __( 'Gaming Images That Are NOT Silhouettes', 'dw-fortnite' ),
        'class' => 'button-secondary',
        'onclick'=>"window.open('https:/www.designwicked.com/premium-fortnite', '_blank')"
),
) );

$wp_customize->add_control( 'label5', array(
    'type' => 'button',
    'settings' => array(),  
    
    'priority' => 10,
    'section' => 'pro_sec',
    'input_attrs' => array(
        'value' => __( 'And More!', 'dw-fortnite' ),
        'class' => 'button-secondary',
        'onclick'=>"window.open('https:/www.designwicked.com/premium-fortnite', '_blank')"
),
) );

}

add_action('customize_register', 'fortnite_procontent');

// Add Footer Text Box section to customize
function fortnite_fcontent($wp_customize) {
	$wp_customize->add_section('fortnite-fcontent-section', array(
		'title' => __( 'Footer Text Box', 'dw-fortnite' )
	));

	$wp_customize->add_setting('fortnite-fcontent-text', array(
		'default' => __( 'Example text for the footer box paragraph.', 'dw-fortnite' ),
		'sanitize_callback' => 'wp_kses_post'
	));

	$wp_customize->add_control( new WP_Customize_Control($wp_customize, 'fortnite-fcontent-text-control', array(
		'label' => __( 'Footer Box Paragraph (HTML Accepted):', 'dw-fortnite' ),
		'section' => 'fortnite-fcontent-section',
		'settings' => 'fortnite-fcontent-text',
		'type' => 'textarea'
	)));
}

add_action('customize_register', 'fortnite_fcontent');

// Header Nav
function fortnite_hnav($wp_customize) {
	$wp_customize->add_section('fortnite-hnav-section', array(
		'title' => __( 'Header Navigation', 'dw-fortnite' )
	));

    $wp_customize->add_setting('fortnite-hnav-linkname1', array(
		'default' => __( 'Link 1', 'dw-fortnite' ),
		'sanitize_callback' => 'sanitize_text_field'
	));


	$wp_customize->add_control( new WP_Customize_Control($wp_customize, 'fortnite-hnav-control-linkname1', array(
		'label' => __( 'Link 1 Name:', 'dw-fortnite' ),
		'section' => 'fortnite-hnav-section',
		'description' => __( 'The visible name of the link on the button.', 'dw-fortnite' ),
		'settings' => 'fortnite-hnav-linkname1',
		'type' => 'text'
	)));

	$wp_customize->add_setting('fortnite-hnav-link1', array(
		'default' => __( 'http://', 'dw-fortnite' ),
		'sanitize_callback' => 'sanitize_text_field'
	));


	$wp_customize->add_control( new WP_Customize_Control($wp_customize, 'fortnite-hnav-control-link1', array(
		'label' => __( 'Link 1 Address:', 'dw-fortnite' ),
		'section' => 'fortnite-hnav-section',
		'description' => __( 'You can use /address to point to a directory, or just put a full link including http://', 'dw-fortnite' ),
		'settings' => 'fortnite-hnav-link1',
		'type' => 'text'
	)));

	$wp_customize->add_setting('fortnite-hnav-linkname2', array(
		'default' => __( 'Link 2', 'dw-fortnite' ),
		'sanitize_callback' => 'sanitize_text_field'
	));


	$wp_customize->add_control( new WP_Customize_Control($wp_customize, 'fortnite-hnav-control-linkname2', array(
		'label' => __( 'Link 2 Name:', 'dw-fortnite' ),
		'section' => 'fortnite-hnav-section',
		'settings' => 'fortnite-hnav-linkname2',
		'type' => 'text'
	)));

	$wp_customize->add_setting('fortnite-hnav-link2', array(
		'default' => __( 'http://', 'dw-fortnite' ),
		'sanitize_callback' => 'sanitize_text_field'
	));

	$wp_customize->add_control( new WP_Customize_Control($wp_customize, 'fortnite-hnav-control-link2', array(
		'label' => __( 'Link 2 Address:', 'dw-fortnite' ),
		'section' => 'fortnite-hnav-section',
		'settings' => 'fortnite-hnav-link2',
		'type' => 'text'
	)));

	$wp_customize->add_setting('fortnite-hnav-linkname3', array(
		'default' => __( 'Link 3', 'dw-fortnite' ),
		'sanitize_callback' => 'sanitize_text_field'
	));


	$wp_customize->add_control( new WP_Customize_Control($wp_customize, 'fortnite-hnav-control-linkname3', array(
		'label' => __( 'Link 3 Name:', 'dw-fortnite' ),
		'section' => 'fortnite-hnav-section',
		'settings' => 'fortnite-hnav-linkname3',
		'type' => 'text'
	)));

	$wp_customize->add_setting('fortnite-hnav-link3', array(
		'default' => __( 'http://', 'dw-fortnite' ),
		'sanitize_callback' => 'sanitize_text_field'
	));

	$wp_customize->add_control( new WP_Customize_Control($wp_customize, 'fortnite-hnav-control-link3', array(
		'label' => __( 'Link 3 Address:', 'dw-fortnite' ),
		'section' => 'fortnite-hnav-section',
		'settings' => 'fortnite-hnav-link3',
		'type' => 'text'
	)));

	$wp_customize->add_setting('fortnite-hnav-linkname4', array(
		'default' => __( 'Link 4', 'dw-fortnite' ),
		'sanitize_callback' => 'sanitize_text_field'
	));


	$wp_customize->add_control( new WP_Customize_Control($wp_customize, 'fortnite-hnav-control-linkname4', array(
		'label' => __( 'Link 4 Name:', 'dw-fortnite' ),
		'section' => 'fortnite-hnav-section',
		'settings' => 'fortnite-hnav-linkname4',
		'type' => 'text'
	)));

	$wp_customize->add_setting('fortnite-hnav-link4', array(
		'default' => __( 'http://', 'dw-fortnite' ),
		'sanitize_callback' => 'sanitize_text_field'
	));

	$wp_customize->add_control( new WP_Customize_Control($wp_customize, 'fortnite-hnav-control-link4', array(
		'label' => __( 'Link 4 Address:', 'dw-fortnite' ),
		'section' => 'fortnite-hnav-section',
		'settings' => 'fortnite-hnav-link4',
		'type' => 'text'
	)));

	$wp_customize->add_setting('fortnite-hnav-linkname5', array(
		'default' => __( 'Link 5', 'dw-fortnite' ),
		'sanitize_callback' => 'sanitize_text_field'
	));


	$wp_customize->add_control( new WP_Customize_Control($wp_customize, 'fortnite-hnav-control-linkname5', array(
		'label' => __( 'Link 5 Name:', 'dw-fortnite' ),
		'section' => 'fortnite-hnav-section',
		'settings' => 'fortnite-hnav-linkname5',
		'type' => 'text'
	)));

	$wp_customize->add_setting('fortnite-hnav-link5', array(
		'default' => __( 'http://', 'dw-fortnite' ),
		'sanitize_callback' => 'sanitize_text_field'
	));

	$wp_customize->add_control( new WP_Customize_Control($wp_customize, 'fortnite-hnav-control-link5', array(
		'label' => __( 'Link 5 Address:', 'dw-fortnite' ),
		'section' => 'fortnite-hnav-section',
		'settings' => 'fortnite-hnav-link5',
		'type' => 'text'
	)));
}
		
	add_action('customize_register', 'fortnite_hnav');