<?php
/**
 * Theme Options
 * @since 1.0.0
 * @package Royalnews WordPress Theme WordPress ThemeWordPress Theme
 */

/**
 * Needed Files for theme options
 * @since 1.0
 * @package RoyalNews
 */
royalnews_file_include( array(
    'customizer/options/header',
    'customizer/options/header-category',
    'customizer/options/top-stories',
    'customizer/options/slider',
    'customizer/options/sidebar',
    'customizer/options/breadcrumb',
    'customizer/options/blog',
    'customizer/options/general',
    'customizer/options/footer-news',
    'customizer/options/footer',
    'customizer/options/stt',
    'customizer/options/reset',
    'customizer/options/site-identity', 
    'customizer/options/goto-pro', 
));

if( !class_exists( 'Royalnews_Options' ) ) {
	class Royalnews_Options extends RoyalNews_Kirki {
        protected static $instance = null;

        public $config = 'royalnews';

        public function __construct() {

            parent::__construct( $this->config, array(
                'royalnews_options' => array(
                    'title' => __( 'RoyalNews Options', 'royalnews' ),
                    'priority'  => 5,
                    'section'   => apply_filters( 'royalnews_customizer_theme_option_panel', [] ),
                ),
            ));
        }

        /**
         * Returns the *Singleton* instance of this class.
         */
        public static function get_instance() {
            if ( null === self::$instance ) {
                self::$instance = new self();
            }
            return self::$instance;
        }
    }
}

Royalnews_Options::get_instance();

if( !function_exists( 'royalnews_value' ) ) {
    function royalnews_value( $id ) {
        return Royalnews_Options::get_instance()->get( $id );
    }
}

/**
 * Use custom css from customizer
 * @since 1.0
 * @package RoyalNews
 */
function royalnews_dynamic_style(){
    $header_text_color = get_header_textcolor(); ?>

    <style type="text/css">
        .royalnews-site-title, .royalnews-site-title a, .royalnews-site-description,
        .royalnews-site-branding .royalnews-site-title a, .royalnews-time-wrapper .royalnews-time-inner time{
            color: #<?php echo esc_html( $header_text_color ); ?>;
        }?>
    </style>
<?php }

add_action( 'wp_head', 'royalnews_dynamic_style' );