<?php
/**
 * Content Creator functions and definitions
 *
 * @link https://developer.wordpress.org/themes/basics/theme-functions/
 *
 * @subpackage Content Creator
 * @since Content Creator 1.0
 */

if ( ! function_exists( 'content_creator_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 content_creator_setup() {
	load_theme_textdomain( 'content-creator', get_template_directory() . '/languages' );
}
endif;
add_action( 'after_setup_theme', 'content_creator_setup' );

function content_creator_block_assets(){
	wp_enqueue_style( 'fontawesome', get_template_directory_uri() . '/assets/font-awesome/css/all.css', array(), '7.1.0' );
	wp_enqueue_style( 'animatecss', get_template_directory_uri() . '/assets/css/animate.css', array(), '4.1.1' );
	wp_enqueue_style( 'content-creator-style', get_template_directory_uri() . '/style.css', array(), wp_get_theme()->get( 'Version' ) );
	wp_enqueue_script('wow-script', get_template_directory_uri() . '/assets/js/wow.js', array('jquery'), false, true);
	wp_enqueue_style( 'owlcarousel-css', get_template_directory_uri() . '/assets/css/owl.carousel.css', array(), '2.3.4' );
	wp_enqueue_script('owlcarousel-js', get_template_directory_uri() . '/assets/js/owl.carousel.js', array('jquery'), false, true);
	wp_enqueue_script('content-creator-script', get_template_directory_uri() . '/assets/js/script.js', array('jquery'), '1.0.0', true);
	wp_style_add_data( 'content-creator-style', 'rtl', 'replace' );
}
add_action('enqueue_block_assets', 'content_creator_block_assets');

/**
 * Load TGM.
 */
require get_template_directory() . '/inc/tgm/tgm.php';

/**
 * Notice.
 */
require_once get_template_directory() . '/inc/notice/notice.php';

/**
 * Theme Info Page.
 */
require get_template_directory() . '/inc/addon.php';

/**
 * Customizer
 */
require get_template_directory() . '/inc/customizer.php';

function content_creator_setup_theme() {
	if ( ! defined( 'CONTENT_CREATOR_PREMIUM_PAGE' ) ) {
		define('CONTENT_CREATOR_PREMIUM_PAGE',__('https://www.theclassictemplates.com/products/youtuber-wordpress-theme','content-creator'));
	}
	if ( ! defined( 'CONTENT_CREATOR_PRO_NAME' ) ) {
		define( 'CONTENT_CREATOR_PRO_NAME', __( 'About Content Creator', 'content-creator' ));
	}
	if ( ! defined( 'CONTENT_CREATOR_THEME_PAGE' ) ) {
		define('CONTENT_CREATOR_THEME_PAGE',__('https://www.theclassictemplates.com/collections/best-wordpress-templates','content-creator'));
	}
	if ( ! defined( 'CONTENT_CREATOR_SUPPORT' ) ) {
		define('CONTENT_CREATOR_SUPPORT',__('https://wordpress.org/support/theme/content-creator/','content-creator'));
	}
	if ( ! defined( 'CONTENT_CREATOR_REVIEW' ) ) {
		define('CONTENT_CREATOR_REVIEW',__('https://wordpress.org/support/theme/content-creator/reviews/','content-creator'));
	}
	if ( ! defined( 'CONTENT_CREATOR_PRO_DEMO' ) ) {
		define('CONTENT_CREATOR_PRO_DEMO',__('https://live.theclassictemplates.com/content-creator-pro/','content-creator'));
	}
	if ( ! defined( 'CONTENT_CREATOR_THEME_DOCUMENTATION' ) ) {
		define('CONTENT_CREATOR_THEME_DOCUMENTATION',__('https://live.theclassictemplates.com/demo/docs/content-creator-free/','content-creator'));
	}
	if ( ! defined( 'CONTENT_CREATOR_BUNDLE_PAGE' ) ) {
		define('CONTENT_CREATOR_BUNDLE_PAGE',__('https://www.theclassictemplates.com/products/wordpress-theme-bundle','content-creator'));
	}
}
add_action('after_setup_theme', 'content_creator_setup_theme');

function content_creator_enqueue_admin_script($hook) {
    // Enqueue admin JS for notices
    wp_enqueue_script('content-creator-welcome-notice', get_template_directory_uri() . '/inc/notice/notice.js', array('jquery'), '', true);
    
    // Localize script to pass data to JavaScript
    wp_localize_script('content-creator-welcome-notice', 'content_creator_localize', array(
        'ajax_url' => admin_url('admin-ajax.php'),
        'nonce' => wp_create_nonce('content_creator_welcome_nonce'),
        'dismiss_nonce' => wp_create_nonce('content_creator_welcome_nonce'), 
        'redirect_url' => admin_url('themes.php?page=content-creator')
    ));
}
add_action('admin_enqueue_scripts', 'content_creator_enqueue_admin_script');