<?php
/**
 * Lawyer Legal Firm functions and definitions
 *
 * @package lawyer_legal_firm
 * @since 1.0
 */


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

		load_theme_textdomain( 'lawyer-legal-firm', get_template_directory() . '/languages' );

		add_theme_support( 'custom-background', apply_filters( 'lawyer_legal_firm_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');

		define('LAWYER_LEGAL_FIRM_FREE_BUY_NOW',__('https://www.themepixels.net/products/lawyer-legal-firm/','lawyer-legal-firm'));
		define('LAWYER_LEGAL_FIRM_BUY_NOW',__('https://www.themepixels.net/products/law-firm-wordpress-theme','lawyer-legal-firm'));
		define('LAWYER_LEGAL_FIRM_LIVE_DEMO',__('https://themepixels.net/demo-site/lawyer-legal-firm/','lawyer-legal-firm'));
		define('LAWYER_LEGAL_FIRM_FREE_DOC',__('https://www.themepixels.net/docs/lawyer-legal-firm-free/','lawyer-legal-firm'));
		define('LAWYER_LEGAL_FIRM_BUNDLE',__('https://www.themepixels.net/products/wp-theme-bundle','lawyer-legal-firm'));
		define('LAWYER_LEGAL_FIRM_THEME_SUPPORT',__('https://wordpress.org/support/theme/lawyer-legal-firm','lawyer-legal-firm'));

    	require_once get_theme_file_path( '/inc/customizer.php' );
	}
endif;

add_action( 'after_setup_theme', 'lawyer_legal_firm_support' );

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

		$lawyer_legal_firm_version_string = is_string( $lawyer_legal_firm_theme_version ) ? $lawyer_legal_firm_theme_version : false;
		wp_enqueue_style(
			'lawyer-legal-firm-style',
			get_template_directory_uri() . '/style.css',
			array(),
			$lawyer_legal_firm_version_string
		);

		wp_style_add_data('lawyer-legal-firm', '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') );

		//font-awesome
		wp_enqueue_style( 'fontawesome', get_template_directory_uri() . '/inc/fontawesome/css/all.css'
			, array(), '6.7.0' );

		wp_enqueue_script(
		    'lawyer-legal-firm-custom-script',
		    get_template_directory_uri() . '/assets/js/custom-script.js',
		    array('jquery'),
		    $lawyer_legal_firm_version_string,
		    true
		);

	}
endif;

add_action( 'wp_enqueue_scripts', 'lawyer_legal_firm_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';

// TGM
require_once get_template_directory() . '/inc/tgm/tgm.php';

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

// NOTICE FUNCTION
function lawyer_legal_firm_activation_notice() {

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

    if ( isset( $_GET['page'] ) && $_GET['page'] === 'lawyer-legal-firm-themeinfo-page' ) {
        return;
    }
    lawyer_legal_firm_theme_notice_content( true, false, true );
}

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

						<p class="lawyer-legal-firm-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 ', 'lawyer-legal-firm'), '<strong>' . esc_html(wp_get_theme()->get('Name')) . '</strong>'
							);
							?>
						</p>
					</div>
					<div class="inner-notice-buttons">
						<?php if ( $lawyer_legal_firm_show_theme_info ) : ?>
							<a class="lawyer-legal-firm-btn-theme-info button button-primary bundlee"
								href="<?php echo esc_url( admin_url( 'themes.php?page=lawyer-legal-firm-themeinfo-page' ) ); ?>">
								<?php esc_html_e( 'Theme Info', 'lawyer-legal-firm' ); ?>
							</a>
						<?php endif; ?>
						<a class="lawyer-legal-firm-btn-theme-info button button-primary live-demoo" target="_blank" href="<?php echo esc_url(LAWYER_LEGAL_FIRM_BUY_NOW); ?>" id="lawyer-legal-firm-bundle-button"> <?php esc_html_e('Buy Now', 'lawyer-legal-firm') ?></a>
						<a class="lawyer-legal-firm-btn-theme-info button button-primary bundlee" target="_blank" href="<?php echo esc_url(LAWYER_LEGAL_FIRM_LIVE_DEMO); ?>" id="lawyer-legal-firm-collection-button"> <?php esc_html_e('Live Demo', 'lawyer-legal-firm') ?></a>
						<a class="lawyer-legal-firm-btn-theme-info button button-primary bundlee" target="_blank" href="<?php echo esc_url(LAWYER_LEGAL_FIRM_BUNDLE); ?>" 
						id="lawyer-legal-firm-collection-button"> <?php esc_html_e('Get Bundle', 'lawyer-legal-firm') ?></a>
					</div>
				</div>
				<div class="middle-box">
					<?php if ( $lawyer_legal_firm_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', 'lawyer-legal-firm' ); ?></p>
									<p><?php esc_html_e( 'WordPress Themes', 'lawyer-legal-firm' ); ?></p>
								</div>
							</div>
							<div class="box-info">
								<span class="dashicons dashicons-yes-alt"></span>
								<div>
									<p><?php esc_html_e( 'Single Theme', 'lawyer-legal-firm' ); ?></p>
									<p><?php esc_html_e( 'Starting at $40', 'lawyer-legal-firm' ); ?></p>
								</div>
							</div>
							<div class="box-info">
								<span class="dashicons dashicons-yes-alt"></span>
								<div>
									<p><?php esc_html_e( 'One Time Payment -', 'lawyer-legal-firm' ); ?></p>
									<p><?php esc_html_e( 'no hidden charges', 'lawyer-legal-firm' ); ?></p>
								</div>
							</div>
						</div>
					<?php endif; ?>
					<div class="box-2">
						<p class="box-2-para"><?php esc_html_e( 'Total Value', 'lawyer-legal-firm' ); ?></p>
						<h4><?php esc_html_e( '$2499', 'lawyer-legal-firm' ); ?></h4>
						<p><?php esc_html_e( 'Bundle Price', 'lawyer-legal-firm' ); ?></p>
						<span><sup><?php esc_html_e( '$', 'lawyer-legal-firm' ); ?></sup><h2><?php esc_html_e( '59', 'lawyer-legal-firm' ); ?></h2></span>
						<p class="box-para"><?php esc_html_e( 'One Time Payement', 'lawyer-legal-firm' ); ?></p>
						<p class="box-btn"><?php esc_html_e( 'You Save $2430', 'lawyer-legal-firm' ); ?></p>
					</div>
				</div>
				<div class="notice-image">
					<a href="<?php echo esc_url( LAWYER_LEGAL_FIRM_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', 'lawyer-legal-firm' ); ?>">
					</a>
				</div>
            </div>
        </div>
    </div>
<?php
}

add_action('admin_notices', 'lawyer_legal_firm_activation_notice');

add_action('wp_ajax_lawyer_legal_firm_dismiss_notice', 'lawyer_legal_firm_dismiss_notice');

function lawyer_legal_firm_notice_status() {
    delete_option('lawyer_legal_firm_notice_dismissed');
}
add_action('after_switch_theme', 'lawyer_legal_firm_notice_status');

function lawyer_legal_firm_dismiss_notice() {
    update_option('lawyer_legal_firm_notice_dismissed', true);
    wp_send_json_success();
}

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