<?php
if ( ! function_exists( 'q_movies_setup' ) ) :
/**
* Sets up theme defaults and registers support for various
* WordPress features.
*
* Note that this function is hooked into the after_setup_theme
* hook, which runs before the init hook. The init hook is too late
* for some features, such as indicating support post thumbnails.
*/

function q_movies_setup() {

    /**
    * Add support for custom navigation menu.
    */
    register_nav_menus( array(
        'primary'   => __( 'Primary Menu', 'q_movies' ),
    ) );

    /**
     * Enqueue styles and scripts.
     */
	add_action( 'wp_enqueue_scripts', 'q_movies_enqueue_styles' );
    wp_enqueue_script( 'q_movies-script', get_template_directory_uri() . '/js/theme.js', array('jquery'), '1.0.0', true );

    /**
     * Add favicon.
     */
    add_action( 'wp_head', 'q_movies_favicon' );
}
endif; // q_movies_setup
add_action( 'after_setup_theme', 'q_movies_setup' );

function q_movies_favicon() {
    echo '<link rel="shortcut icon" type="image/x-icon" href="' . get_template_directory_uri() . '/favicon.ico" />' . "\n";
    echo '<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">';
}

function q_movies_enqueue_styles() {
	if ( ! is_admin() ) {
		wp_enqueue_style( 'q_movies-style', get_stylesheet_uri() );
	}
}
