<?php
/**
 * Core functions
 *
 * @package Blorigan
 */

if ( ! function_exists( 'blorigan_get_option' ) ) :

	/**
	 * Get theme option.
	 *
	 * @since 1.0.0
	 *
	 * @param string $key Option key.
	 * @return mixed Option value.
	 */
	function blorigan_get_option( $key ) {
		$default_options = blorigan_get_default_theme_options();

		if ( empty( $key ) ) {
			return;
		}

		$default       = ( isset( $default_options[ $key ] ) ) ? $default_options[ $key ] : '';
		$theme_options = get_theme_mod( 'theme_options', $default_options );
		$theme_options = array_merge( $default_options, $theme_options );
		$value         = '';

		if ( isset( $theme_options[ $key ] ) ) {
			$value = $theme_options[ $key ];
		}

		$value = apply_filters( "blorigan_option_{$key}", $value, $key, $default );

		return $value;
	}

endif;

if ( ! function_exists( 'blorigan_get_default_theme_options' ) ) :

	/**
	 * Get default theme options.
	 *
	 * @since 1.0.0
	 *
	 * @return array Default theme options.
	 */
	function blorigan_get_default_theme_options() {
		$defaults = array();

		// Header.
		$defaults['show_title']   = true;
		$defaults['show_tagline'] = true;

		// Layout.
		$defaults['global_layout']  = 'right-sidebar';
		$defaults['archive_layout'] = 'simple';

		// Footer.
		$defaults['copyright_text']   = esc_html__( 'Copyright &copy; All rights reserved.', 'blorigan' );
		$defaults['go_to_top_status'] = true;

		// Blog.
		$defaults['excerpt_length']     = 40;
		$defaults['read_more_text']     = esc_html__( 'Read More', 'blorigan' );
		$defaults['exclude_categories'] = '';

		// Author Bio.
		$defaults['author_bio_in_single'] = true;

		// Breadcrumb.
		$defaults['breadcrumb_type'] = 'enabled';

		// Related.
		$defaults['related_posts_status'] = true;

		// Slider.
		$defaults['featured_slider_status']            = 'home-page';
		$defaults['featured_slider_enable_full_width'] = false;
		$defaults['featured_slider_enable_carousel']   = false;
		$defaults['featured_slider_carousel_number']   = 3;
		$defaults['featured_slider_transition_delay']  = 3;
		$defaults['featured_slider_enable_arrow']      = true;
		$defaults['featured_slider_enable_pager']      = true;
		$defaults['featured_slider_enable_autoplay']   = true;
		$defaults['featured_slider_type']              = 'featured-category';
		$defaults['featured_slider_number']            = 5;
		$defaults['featured_slider_category']          = 0;

		return apply_filters( 'blorigan_filter_default_theme_options', $defaults );
	}

endif;
