<?php
/**
 * Wpstream theme core
 *
 * @package wpstream-theme
 */

// JETPACK functions.
if ( defined( 'JETPACK__VERSION' ) ) {
	require get_template_directory() . '/inc/jetpack.php';
}

// Load theme functionality
function wpstream_load_theme_files() {
    $core_files = array(
	    '/framework/helper-functions.php',
	    '/framework/load-scripts.php',
		'/framework/theme-settings.php',
		'/framework/blog-functions.php',
		'/framework/wpstream-help-functions.php',
		'/framework/pagination-functions.php',
		'/framework/dashboard-functions.php',
		'/framework/query-functions.php',
	    '/framework/css-js-include.php',
	    '/framework/theme-admin.php',
	    '/inc/template-functions.php',
	    '/inc/template-tags.php',
	    '/inc/comment-list.php',
	    '/framework/style-functions.php',
	    '/framework/register-plugins.php',
	    '/woocommerce/woocommerce-functions.php',
	);
	foreach( $core_files as $file ) {

		$file_path = get_template_directory() . $file;
		if ( file_exists( $file_path ) ) {
			require_once $file_path;
		} else {
			error_log( 'Missing required file: ' . $file_path );
		}
	}
}
add_action('after_setup_theme', 'wpstream_load_theme_files');

/**
 * Load js for players
 *
 * @return void
 */

 if ( ! function_exists( 'wpstream_load_player_js_on_demand' ) ) :
	function wpstream_load_player_js_on_demand() {
		$wpstream_unit_card_use_video       = get_theme_mod( 'wpstream_unit_card_use_video');
		if($wpstream_unit_card_use_video){
			wp_enqueue_script('video.min');
			wp_enqueue_script('wpstream-player');
		}
	
	}
endif;