<?php
/**
* Get started notice
*/
add_action( 'wp_ajax_job_listing_dismissed_notice_handler', 'job_listing_ajax_notice_handler' );

function job_listing_ajax_notice_handler() {
    check_ajax_referer( 'job_listing_welcome_nonce', 'nonce' );

    if ( isset( $_POST['type'] ) ) {
        $job_listing_type = sanitize_text_field( wp_unslash( $_POST['type'] ) );
        update_option( 'dismissed-' . $job_listing_type, true );
    }
    wp_send_json_success();
}

function job_listing_deprecated_hook_admin_notice() {
    if ( get_option( 'dismissed-get_started', false ) ) {
        return;
    }
    $job_listing_current_screen = get_current_screen();
    if (
        $job_listing_current_screen &&
        $job_listing_current_screen->id !== 'appearance_page_job-listing-guide-page' &&
        $job_listing_current_screen->id !== 'appearance_page_joblisting-wizard'
    ) {
        $job_listing_comments_theme = wp_get_theme();
        ?>
        <div class="job-listing-notice-wrapper notice notice-success notice-get-started-class is-dismissible" data-notice="get_started">
            <div class="job-listing-notice">
                <div class="job-listing-notice-content">
                    <div class="job-listing-notice-heading">
                        <h2>
                            <?php esc_html_e( 'Thanks For Installing ', 'job-listing' ); ?>
                            <?php echo esc_html( $job_listing_comments_theme ); ?>
                            <?php esc_html_e( ' Theme', 'job-listing' ); ?>
                        </h2>
                        <p>
                        <?php
                        printf(
                            esc_html__( '%s is now installed and ready to use. We\'ve provided some links to get you started.', 'job-listing' ),
                            esc_html( $job_listing_comments_theme )
                        );
                        ?>
                        </p>
                    </div>
                    <div class="diplay-flex-btn">
                        <a class="button button-primary"
                           href="<?php echo esc_url( admin_url( 'themes.php?page=job-listing-guide-page' ) ); ?>">
                           <?php esc_html_e( 'GET STARTED', 'job-listing' ); ?>
                        </a>
                        <a class="button button-primary"
                           target="_blank"
                           href="<?php echo esc_url( JOB_LISTING_BUY_NOW ); ?>">
                           <?php esc_html_e( 'GO TO PREMIUM', 'job-listing' ); ?>
                        </a>
                        <a class="button button-primary import"
                           href="<?php echo esc_url( admin_url( 'themes.php?page=joblisting-wizard' ) ); ?>">
                           <?php esc_html_e( 'ONE CLICK DEMO IMPORTER', 'job-listing' ); ?>
                        </a>
                    </div>
                </div>
                <div class="job-listing-notice-img">
                    <a href="<?php echo esc_url( JOB_LISTING_THEME_BUNDLE ); ?>" target="_blank">
                        <img src="<?php echo esc_url( get_template_directory_uri() . '/assets/images/notification.png' ); ?>" alt="<?php esc_attr_e( 'logo', 'job-listing' ); ?>">
                    </a>
                </div>
            </div>
        </div>
        <?php
    }
}
add_action( 'admin_notices', 'job_listing_deprecated_hook_admin_notice' );

add_action( 'admin_menu', 'job_listing_getting_started' );
function job_listing_getting_started() {
    add_theme_page(
        esc_html__( 'Get Started', 'job-listing' ),
        esc_html__( 'Get Started', 'job-listing' ),
        'edit_theme_options',
        'job-listing-guide-page',
        'job_listing_test_guide'
    );
}

// After switching theme, reset dismissed notice option
add_action('after_switch_theme', 'job_listing_after_switch_theme');
function job_listing_after_switch_theme() {
    update_option('dismissed-get_started', FALSE);
}

add_action( 'admin_enqueue_scripts', 'job_listing_admin_enqueue_scripts' );
function job_listing_admin_enqueue_scripts( $hook ) {
	wp_enqueue_style(
		'job-listing-admin-style',
		get_template_directory_uri() . '/css/main.css',
		array(),
		wp_get_theme()->get( 'Version' )
	);
	wp_enqueue_script(
		'job-listing-admin-script',
		get_template_directory_uri() . '/js/job-listing-admin-script.js',
		array( 'jquery' ),
		wp_get_theme()->get( 'Version' ),
		true
	);
	wp_localize_script(
		'job-listing-admin-script',
		'job_listing_ajax_object',
		array(
			'ajax_url'      => admin_url( 'admin-ajax.php' ),
			'dismiss_nonce' => wp_create_nonce( 'job_listing_welcome_nonce' ),
			'redirect_url'  => admin_url( 'themes.php?page=job-listing-guide-page' ),
		)
	);
}

if ( ! defined( 'JOB_LISTING_DOCS_FREE' ) ) {
define('JOB_LISTING_DOCS_FREE',__('https://demo.misbahwp.com/docs/job-listing-free-docs/','job-listing'));
}
 if ( ! defined( 'JOB_LISTING_DOCS_PRO' ) ) {
define('JOB_LISTING_DOCS_PRO',__('https://demo.misbahwp.com/docs/job-listing-pro-docs/','job-listing'));
}
if ( ! defined( 'JOB_LISTING_BUY_NOW' ) ) {
define('JOB_LISTING_BUY_NOW',__('https://www.misbahwp.com/products/job-listing-wordpress-theme','job-listing'));
}
if ( ! defined( 'JOB_LISTING_SUPPORT_FREE' ) ) {
define('JOB_LISTING_SUPPORT_FREE',__('https://wordpress.org/support/theme/job-listing','job-listing'));
}
if ( ! defined( 'JOB_LISTING_REVIEW_FREE' ) ) {
define('JOB_LISTING_REVIEW_FREE',__('https://wordpress.org/support/theme/job-listing/reviews/#new-post','job-listing'));
}
if ( ! defined( 'JOB_LISTING_DEMO_PRO' ) ) {
define('JOB_LISTING_DEMO_PRO',__('https://demo.misbahwp.com/job-listing/','job-listing'));
}
if( ! defined( 'JOB_LISTING_THEME_BUNDLE' ) ) {
define('JOB_LISTING_THEME_BUNDLE',__('https://www.misbahwp.com/products/wordpress-bundle','job-listing'));
}

function job_listing_test_guide() { 
	$job_listing_theme = wp_get_theme();?>
	<div class="wrap" id="main-page">
		<div id="lefty">
			<div id="admin_links">
				<a href="<?php echo esc_url( JOB_LISTING_DOCS_FREE ); ?>" target="_blank" class="blue-button-1"><?php esc_html_e( 'Documentation', 'job-listing' ) ?></a>
				<a href="<?php echo esc_url( admin_url('customize.php') ); ?>" id="customizer" target="_blank"><?php esc_html_e( 'Customize', 'job-listing' ); ?> </a>
				<a class="blue-button-1" href="<?php echo esc_url( JOB_LISTING_SUPPORT_FREE ); ?>" target="_blank" class="btn3"><?php esc_html_e( 'Support', 'job-listing' ) ?></a>
				<a class="blue-button-2" href="<?php echo esc_url( JOB_LISTING_REVIEW_FREE ); ?>" target="_blank" class="btn4"><?php esc_html_e( 'Review', 'job-listing' ) ?></a>
			</div>
			<div id="description">
				<h3><?php esc_html_e('Welcome! Thank you for choosing ','job-listing'); ?><?php echo esc_html( $job_listing_theme ); ?>  <span><?php esc_html_e('Version: ', 'job-listing'); ?><?php echo esc_html($job_listing_theme['Version']);?></span></h3>
				<div class="demo-import-box">
					<h4><?php echo esc_html__('Import homepage demo in just one click.','job-listing'); ?></h4>
					<p><?php echo esc_html__('Get started with the wordpress theme installation','job-listing'); ?></p>
					<a class="button button-primary import" href="themes.php?page=joblisting-wizard"><?php echo esc_html__('ONE CLICK DEMO IMPORTER','job-listing'); ?></a>
				</div>
				<img class="img_responsive" style="width: 100%;" src="<?php echo esc_url( $job_listing_theme->get_screenshot() ); ?>" />
				<div id="description-insidee">
					<?php
						$job_listing_theme = wp_get_theme();
						echo wp_kses_post( apply_filters( 'misbah_theme_description', esc_html( $job_listing_theme->get( 'Description' ) ) ) );
					?>
				</div>
			</div>
		</div>

		<div id="righty">
			<div class="volleyball-postboxx">
				<h3 class="hndle"><?php esc_html_e( 'Upgrade to Premium', 'job-listing' ); ?></h3>
				<div class="volleyball-insidee">
					<p><?php esc_html_e('Discover upgraded pro features with premium version click to upgrade.','job-listing'); ?></p>
					<div id="admin_pro_links">
						<a class="blue-button-2" href="<?php echo esc_url( JOB_LISTING_BUY_NOW ); ?>" target="_blank"><?php esc_html_e( 'Go Pro', 'job-listing' ); ?></a>
						<a class="blue-button-1" href="<?php echo esc_url( JOB_LISTING_DEMO_PRO ); ?>" target="_blank"><?php esc_html_e( 'Live Demo', 'job-listing' ) ?></a>
						<a class="blue-button-2" href="<?php echo esc_url( JOB_LISTING_DOCS_PRO ); ?>" target="_blank"><?php esc_html_e( 'Pro Docs', 'job-listing' ) ?></a>
					</div>
				</div>

				<h3 class="hndle bundle"><?php esc_html_e( 'Get All Themes', 'job-listing' ); ?></h3>
				<div class="insidee theme-bundle">
					<img width="100%" src="<?php echo esc_url( get_template_directory_uri() . '/assets/images/bundle-image.png' ); ?>" alt="<?php esc_attr_e('logo', 'job-listing'); ?>">
					<p class="offer"><?php esc_html_e('Get 100+ Perfect WordPress Theme In A Single Package at just $89.','job-listing'); ?></p>
					<p class="coupon"><?php esc_html_e('Get Our Theme Pack of 100+ WordPress Themes At 30% Off','job-listing'); ?><span class="coupon-code"><?php esc_html_e('"Bundleup15"','job-listing'); ?></span></p>
				<div id="admin_pro_linkss">
					<a class="blue-button-1" href="<?php echo esc_url( JOB_LISTING_THEME_BUNDLE ); ?>" target="_blank"><?php esc_html_e( 'Buy All Themes - $89', 'job-listing' ) ?></a>
				</div>
				<div class="d-table">
			    <ul class="d-column">
			      <li class="feature"><?php esc_html_e('Features','job-listing'); ?></li>
			      <li class="free"><?php esc_html_e('Pro','job-listing'); ?></li>
			      <li class="plus"><?php esc_html_e('Free','job-listing'); ?></li>
			    </ul>
			    <ul class="d-row">
			      <li class="points"><?php esc_html_e('24hrs Priority Support','job-listing'); ?></li>
			      <li class="right"><span class="dashicons dashicons-yes"></span></li>
			      <li class="wrong"><span class="dashicons dashicons-yes"></span></li>
			    </ul>
			    <ul class="d-row">
			      <li class="points"><?php esc_html_e('LearnPress Campatiblity','job-listing'); ?></li>
			      <li class="right"><span class="dashicons dashicons-yes"></span></li>
			      <li class="wrong"><span class="dashicons dashicons-yes"></span></li>
			    </ul>
			    <ul class="d-row">
			      <li class="points"><?php esc_html_e('Kirki Framework','job-listing'); ?></li>
			      <li class="right"><span class="dashicons dashicons-yes"></span></li>
			      <li class="wrong"><span class="dashicons dashicons-yes"></span></li>
			    </ul>
			    <ul class="d-row">
			      <li class="points"><?php esc_html_e('Advance Posttype','job-listing'); ?></li>
			      <li class="right"><span class="dashicons dashicons-yes"></span></li>
			      <li class="wrong"><span class="dashicons dashicons-no"></span></li>
			    </ul>
			    <ul class="d-row">
			      <li class="points"><?php esc_html_e('One Click Demo Import','job-listing'); ?></li>
			      <li class="right"><span class="dashicons dashicons-yes"></span></li>
			      <li class="wrong"><span class="dashicons dashicons-yes"></span></li>
			    </ul>
			    <ul class="d-row">
			      <li class="points"><?php esc_html_e('Section Reordering','job-listing'); ?></li>
			      <li class="right"><span class="dashicons dashicons-yes"></span></li>
			      <li class="wrong"><span class="dashicons dashicons-no"></span></li>
			    </ul>
			    <ul class="d-row">
			      <li class="points"><?php esc_html_e('Enable / Disable Option','job-listing'); ?></li>
			      <li class="right"><span class="dashicons dashicons-yes"></span></li>
			      <li class="wrong"><span class="dashicons dashicons-yes"></span></li>
			    </ul>
			    <ul class="d-row">
			      <li class="points"><?php esc_html_e('Multiple Sections','job-listing'); ?></li>
			      <li class="right"><span class="dashicons dashicons-yes"></span></li>
			      <li class="wrong"><span class="dashicons dashicons-no"></span></li>
			    </ul>
			    <ul class="d-row">
			      <li class="points"><?php esc_html_e('Advance Color Pallete','job-listing'); ?></li>
			      <li class="right"><span class="dashicons dashicons-yes"></span></li>
			      <li class="wrong"><span class="dashicons dashicons-no"></span></li>
			    </ul>
			    <ul class="d-row">
			      <li class="points"><?php esc_html_e('Advance Widgets','job-listing'); ?></li>
			      <li class="right"><span class="dashicons dashicons-yes"></span></li>
			      <li class="wrong"><span class="dashicons dashicons-yes"></span></li>
			    </ul>
			    <ul class="d-row">
			      <li class="points"><?php esc_html_e('Page Templates','job-listing'); ?></li>
			      <li class="right"><span class="dashicons dashicons-yes"></span></li>
			      <li class="wrong"><span class="dashicons dashicons-no"></span></li>
			    </ul>
			    <ul class="d-row">
			      <li class="points"><?php esc_html_e('Advance Typography','job-listing'); ?></li>
			      <li class="right"><span class="dashicons dashicons-yes"></span></li>
			      <li class="wrong"><span class="dashicons dashicons-no"></span></li>
			    </ul>
			    <ul class="d-row">
			      <li class="points"><?php esc_html_e('Section Background Image / Color ','job-listing'); ?></li>
			      <li class="right"><span class="dashicons dashicons-yes"></span></li>
			      <li class="wrong"><span class="dashicons dashicons-no"></span></li>
			    </ul>
	  		</div>
			</div>
		</div>
	</div>
<?php } ?>
