<?php
/**
 * Default theme options.
 *
 * @package DarkMag
 */

if ( ! function_exists( 'darkmag_get_default_theme_options' ) ) :

	/**
	 * Get default theme options.
	 *
	 * @since 1.0.0
	 *
	 * @return array Default theme options.
	 */
function darkmag_get_default_theme_options() {

	$defaults = array();

	// Dark Mode
	$defaults['dark_mode']							= 'dark-mode';

    // Homepage Options
	$defaults['enable_frontpage_content'] 			= true;

	// Breaking News Section	
	$defaults['enable_breaking_news_section']		= false;
	$defaults['breaking_news_section_title']		= esc_html__( 'Breaking News', 'darkmag' );
	$defaults['number_of_breaking_news_items']		= 6;
	$defaults['breaking_news_content_type']			= 'breaking_news_category';

	// Highlighted Posts Section	
	$defaults['enable_highlighted_posts_section']	= false;
	$defaults['number_of_highlighted_posts_items']	= 5;
	$defaults['highlighted_posts_content_type']		= 'highlighted_posts_category';

	// Featured Posts Section	
	$defaults['enable_featured_posts_section']		= false;
	$defaults['featured_posts_section_title']		= esc_html__( 'Featured Posts', 'darkmag' );
	$defaults['featured_posts_column']				= 'col-4';
	$defaults['number_of_featured_posts_items']		= 8;
	$defaults['featured_posts_content_type']		= 'featured_posts_category';

	// Recent Posts Section	
	$defaults['enable_recent_posts_section']		= false;
	$defaults['recent_posts_section_title']			= esc_html__( 'Recent Posts', 'darkmag' );
	$defaults['recent_posts_column']				= 'col-3';
	$defaults['number_of_recent_posts_items']		= 9;
	$defaults['recent_posts_content_type']			= 'recent_posts_category';

	// Popular Posts Section	
	$defaults['enable_popular_posts_section']		= false;
	$defaults['popular_posts_section_title']		= esc_html__( 'Popular Posts', 'darkmag' );
	$defaults['popular_posts_column']				= 'col-2';
	$defaults['number_of_popular_posts_items']		= 6;
	$defaults['popular_posts_content_type']			= 'popular_posts_category';

	// Trending Posts Section	
	$defaults['enable_trending_posts_section']		= false;
	$defaults['trending_posts_section_title']		= esc_html__( 'Trending Posts Slider', 'darkmag' );
	$defaults['number_of_trending_posts_items']		= 3;
	$defaults['trending_posts_content_type']		= 'trending_posts_category';

	// Most Viewed Posts Section	
	$defaults['enable_most_viewed_posts_section']	= false;
	$defaults['most_viewed_posts_section_title']	= esc_html__( 'Most Viewed Posts', 'darkmag' );
	$defaults['most_viewed_posts_column']			= 'col-1';
	$defaults['number_of_most_viewed_posts_items']	= 6;
	$defaults['most_viewed_posts_content_type']		= 'most_viewed_posts_category';

	// Recommended Posts Section	
	$defaults['enable_recommended_posts_section']	= false;
	$defaults['recommended_posts_section_title']	= esc_html__( 'Recommended Posts', 'darkmag' );
	$defaults['recommended_posts_column']			= 'col-4';
	$defaults['number_of_recommended_posts_items']	= 8;
	$defaults['recommended_posts_content_type']		= 'recommended_posts_category';

	// Latest Posts Section
	$defaults['enable_blog_section']				= false;
	$defaults['blog_section_title']					= esc_html__( 'Latest Posts', 'darkmag' );
	$defaults['blog_posts_column']					= 'col-5';
	$defaults['blog_category']	   					= 0; 
	$defaults['blog_number']						= 10;	

	//General Section
	$defaults['your_latest_posts_title']		= esc_html__('Blog','darkmag');
	$defaults['excerpt_length']					= 15;
	$defaults['layout_options_blog']			= 'no-sidebar';
	$defaults['layout_options_archive']			= 'no-sidebar';
	$defaults['layout_options_page']			= 'right-sidebar';	
	$defaults['layout_options_single']			= 'right-sidebar';	

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

	// Pass through filter.
	$defaults = apply_filters( 'darkmag_filter_default_theme_options', $defaults );
	return $defaults;
}

endif;

/**
*  Get theme options
*/
if ( ! function_exists( 'darkmag_get_option' ) ) :

	/**
	 * Get theme option
	 *
	 * @since 1.0.0
	 *
	 * @param string $key Option key.
	 * @return mixed Option value.
	 */
	function darkmag_get_option( $key ) {

		$default_options = darkmag_get_default_theme_options();
		if ( empty( $key ) ) {
			return;
		}

		$theme_options = (array)get_theme_mod( 'theme_options' );
		$theme_options = wp_parse_args( $theme_options, $default_options );

		$value = null;

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

		return $value;

	}

endif;