<?php
/**
 * Marriage Counseling functions and definitions
 *
 * @package marriage_counseling
 * @since 1.0
 */

if ( ! function_exists( 'marriage_counseling_support' ) ) :
	function marriage_counseling_support() {

		load_theme_textdomain( 'marriage-counseling', get_template_directory() . '/languages' );

		add_theme_support( 'custom-background', apply_filters( 'marriage_counseling_custom_background', array(
            'default-color' => 'ffffff',
            'default-image' => '',
        )));

		// Add support for block styles.
		add_theme_support( 'wp-block-styles' );

		add_theme_support('woocommerce');

		// Enqueue editor styles.
		add_editor_style(get_stylesheet_directory_uri() . '/assets/css/editor-style.css');

		// Enqueue editor styles.
		add_editor_style(get_stylesheet_directory_uri() . '/assets/css/editor-style.css');

		define('MARRIAGE_COUNSELING_FREE_BUY_NOW',__('https://www.themepixels.net/products/marriage-counseling/','marriage-counseling'));
		define('MARRIAGE_COUNSELING_BUY_NOW',__('https://www.themepixels.net/products/marriage-counseling-wordpress-theme','marriage-counseling'));
		define('MARRIAGE_COUNSELING_LIVE_DEMO',__('themepixels.net/demo-site/marriage-counseling-pro/','marriage-counseling'));
		define('MARRIAGE_COUNSELING_FREE_DOC',__('https://www.themepixels.net/docs/marriage-counseling-free/','marriage-counseling'));
		define('MARRIAGE_COUNSELING_BUNDLE',__('https://www.themepixels.net/products/wp-theme-bundle','marriage-counseling'));
		define('MARRIAGE_COUNSELING_THEME_SUPPORT',__('https://wordpress.org/support/theme/marriage-counseling','marriage-counseling'));
    	require_once get_theme_file_path( '/inc/customizer.php' );
	}
endif;

add_action( 'after_setup_theme', 'marriage_counseling_support' );

if ( ! function_exists( 'marriage_counseling_styles' ) ) :
	function marriage_counseling_styles() {
		// Register theme stylesheet.
		$marriage_counseling_theme_version = wp_get_theme()->get( 'Version' );

		$marriage_counseling_version_string = is_string( $marriage_counseling_theme_version ) ? $marriage_counseling_theme_version : false;
		wp_enqueue_style(
			'marriage-counseling-style',
			get_template_directory_uri() . '/style.css',
			array(),
			$marriage_counseling_version_string
		);

		wp_style_add_data('marriage-counseling', 'rtl', 'replace');

		wp_enqueue_style( 'dashicons' );

		wp_enqueue_style( 'animate-css', esc_url(get_template_directory_uri()).'/assets/css/animate.css' );

		wp_enqueue_script( 'jquery-wow', esc_url(get_template_directory_uri()) . '/assets/js/wow.js', array('jquery') );
        
        wp_enqueue_style( 'marriage-counseling-fonts', get_template_directory_uri() . '/assets/css/fonts.css', array(), $marriage_counseling_version_string );
	    
		 //font-awesome
		 wp_enqueue_style( 'fontawesome', get_template_directory_uri() . '/inc/fontawesome/css/all.css'
		 	, array(), '6.7.0' );
	}
endif;

add_action( 'wp_enqueue_scripts', 'marriage_counseling_styles' );

// Add block patterns
require get_template_directory() . '/inc/block-patterns.php';

// Add block styles
require get_template_directory() . '/inc/block-styles.php';

// Block Filters
require get_template_directory() . '/inc/block-filters.php';

// Svg icons
require get_template_directory() . '/inc/icon-function.php';

/**
* GET START.
*/
require get_template_directory() . '/themeinfo/marriage_counseling_themeinfo_page.php';

// NOTICE FUNCTION
function marriage_counseling_activation_notice() {

    if ( get_option( 'marriage_counseling_notice_dismissed' ) ) {
        return;
    }

    if ( isset( $_GET['page'] ) && $_GET['page'] === 'marriage-counseling-themeinfo-page' ) {
        return;
    }
    marriage_counseling_theme_notice_content( true, false, true );
}

function marriage_counseling_theme_notice_content(
    $marriage_counseling_show_theme_info = true,
    $marriage_counseling_show_box_1 = false,
    $marriage_counseling_show_dismiss = true
) {
?>
	<div class="updated notice notice-theme-info-class <?php echo $marriage_counseling_show_dismiss ? 'is-dismissible' : ''; ?>" data-notice="theme_info">
        <div class="marriage-counseling-theme-info-notice clearfix">
            <div class="marriage-counseling-theme-notice-content">
				<div class="notice-content">
					<div class="inner-notice-contetn">
						<h4 class="best-value"><?php esc_html_e( 'Best Value', 'marriage-counseling' ); ?></h4>
						<h2 class="marriage-counseling-notice-h2">
							<?php
							printf(
								/* translators: 1: Theme name */
								esc_html__('Get 30+ Premium WordPress Themes in One Bundle', 'marriage-counseling'), '<strong>' . esc_html(wp_get_theme()->get('Name')) . '</strong>'
							);
							?>
						</h2>

						<p class="marriage-counseling-notice-p">
							<?php
							printf(
								/* translators: 1: Theme name */
								esc_html__('Premium WordPress Themes for Business, Ecommerce, Blogs, Portfolio and more. Our themes are light & easy to customize ', 'marriage-counseling'), '<strong>' . esc_html(wp_get_theme()->get('Name')) . '</strong>'
							);
							?>
						</p>
					</div>
					<div class="inner-notice-buttons">
						<?php if ( $marriage_counseling_show_theme_info ) : ?>
							<a class="marriage-counseling-btn-theme-info button button-primary bundlee"
								href="<?php echo esc_url( admin_url( 'themes.php?page=marriage-counseling-themeinfo-page' ) ); ?>">
								<?php esc_html_e( 'Theme Info', 'marriage-counseling' ); ?>
							</a>
						<?php endif; ?>
						<a class="marriage-counseling-btn-theme-info button button-primary live-demoo" target="_blank" href="<?php echo esc_url(MARRIAGE_COUNSELING_BUY_NOW); ?>" id="marriage-counseling-bundle-button"> <?php esc_html_e('Buy Now', 'marriage-counseling') ?></a>
						<a class="marriage-counseling-btn-theme-info button button-primary bundlee" target="_blank" href="<?php echo esc_url(MARRIAGE_COUNSELING_LIVE_DEMO); ?>" id="marriage-counseling-collection-button"> <?php esc_html_e('Live Demo', 'marriage-counseling') ?></a>
						<a class="marriage-counseling-btn-theme-info button button-primary bundlee" target="_blank" href="<?php echo esc_url(MARRIAGE_COUNSELING_BUNDLE); ?>" 
						id="marriage-counseling-collection-button"> <?php esc_html_e('Get Bundle', 'marriage-counseling') ?></a>
					</div>
				</div>
				<div class="middle-box">
					<?php if ( $marriage_counseling_show_box_1 ) : ?>
						<div class="box-1">
							<div class="box-info">
								<span class="dashicons dashicons-yes-alt"></span>
								<div>
									<p><?php esc_html_e( '30+ Premium', 'marriage-counseling' ); ?></p>
									<p><?php esc_html_e( 'WordPress Themes', 'marriage-counseling' ); ?></p>
								</div>
							</div>
							<div class="box-info">
								<span class="dashicons dashicons-yes-alt"></span>
								<div>
									<p><?php esc_html_e( 'Single Theme', 'marriage-counseling' ); ?></p>
									<p><?php esc_html_e( 'Starting at $40', 'marriage-counseling' ); ?></p>
								</div>
							</div>
							<div class="box-info">
								<span class="dashicons dashicons-yes-alt"></span>
								<div>
									<p><?php esc_html_e( 'One Time Payment -', 'marriage-counseling' ); ?></p>
									<p><?php esc_html_e( 'no hidden charges', 'marriage-counseling' ); ?></p>
								</div>
							</div>
						</div>
					<?php endif; ?>
					<div class="box-2">
						<p class="box-2-para"><?php esc_html_e( 'Total Value', 'marriage-counseling' ); ?></p>
						<h4><?php esc_html_e( '$2499', 'marriage-counseling' ); ?></h4>
						<p><?php esc_html_e( 'Bundle Price', 'marriage-counseling' ); ?></p>
						<span><sup><?php esc_html_e( '$', 'marriage-counseling' ); ?></sup><h2><?php esc_html_e( '59', 'marriage-counseling' ); ?></h2></span>
						<p class="box-para"><?php esc_html_e( 'One Time Payement', 'marriage-counseling' ); ?></p>
						<p class="box-btn"><?php esc_html_e( 'You Save $2430', 'marriage-counseling' ); ?></p>
					</div>
				</div>
				<div class="notice-image">
					<a href="<?php echo esc_url( MARRIAGE_COUNSELING_BUNDLE ); ?>" target="_blank" rel="noopener noreferrer">
						<img src="<?php echo esc_url( get_stylesheet_directory_uri() . '/assets/images/bundle-img.png' ); ?>" alt="<?php esc_attr_e( 'Theme Screenshot', 'marriage-counseling' ); ?>">
					</a>
				</div>
            </div>
        </div>
    </div>
<?php
}

add_action('admin_notices', 'marriage_counseling_activation_notice');

add_action('wp_ajax_marriage_counseling_dismiss_notice', 'marriage_counseling_dismiss_notice');

function marriage_counseling_notice_status() {
    delete_option('marriage_counseling_notice_dismissed');
}
add_action('after_switch_theme', 'marriage_counseling_notice_status');

function marriage_counseling_dismiss_notice() {
    update_option('marriage_counseling_notice_dismissed', true);
    wp_send_json_success();
}

function marriage_counseling_admin_enqueue_scripts(){
	wp_enqueue_style('marriage-counseling-admin-style', esc_url( get_template_directory_uri() ) . '/assets/css/marriage-counseling-notice.css');
	wp_enqueue_script('marriage-counseling-dismiss-notice-script', get_stylesheet_directory_uri() . '/assets/js/marriage-counseling-notice.js', array('jquery'), null, true);
}
add_action( 'admin_enqueue_scripts', 'marriage_counseling_admin_enqueue_scripts' );