<?php

add_action('admin_enqueue_scripts', 'wcgen_add_admin_scripts', 99);
function wcgen_add_admin_scripts($hook)
{
    if (isset($_GET['page']) && $_GET['page'] == 'digital-warranty-card') {
        // style
        wp_enqueue_style(WCGEN_NAME . '_bootstrap-min', WCGEN_LIBS . 'bootstrap/css/bootstrap.min.css', array(), WCGEN_VER);
        wp_enqueue_style(WCGEN_NAME . '-owl-carousel-css', WCGEN_LIBS . 'owl-carousel/css/owl.carousel.min.css', array(), WCGEN_VER);
		wp_enqueue_style(WCGEN_NAME . '-owl-carousel-theme', WCGEN_LIBS . 'owl-carousel/css/owl.theme.default.min.css', array(), WCGEN_VER);
        wp_enqueue_style(WCGEN_NAME . 'uicss-min', 'https://code.jquery.com/ui/1.13.0/themes/base/jquery-ui.css', array(), WCGEN_VER);
        wp_enqueue_style(WCGEN_NAME . '_admin', WCGEN_CSS . 'admin.css', array(), WCGEN_VER);
        // script
        wp_enqueue_script('jquery');
        if (!did_action('wp_enqueue_media')) {
            wp_enqueue_media();
        }

        wp_enqueue_script('jquery-ui');
	    wp_enqueue_script('jquery-ui-tooltip');
        wp_enqueue_style( 'wp-color-picker' );
        wp_enqueue_script( WCGEN_NAME . '_wp_color_icker', WCGEN_LIBS . 'wp-color-picker/js/wp-color-picker-alpha.min.js', array( 'wp-color-picker' ), WCGEN_VER, true ); 
        wp_add_inline_script(
            WCGEN_NAME . '_wp_color_icker',
            'jQuery( function() { jQuery( ".color-picker" ).wpColorPicker(); } );'
        );
        wp_enqueue_script( WCGEN_NAME . '_wp_color_icker' );        
        wp_enqueue_script(WCGEN_NAME . 'popup-min',  'https://unpkg.com/@popperjs/core@2/dist/umd/popper.js', array('jquery'), WCGEN_VER, true);
        wp_enqueue_script(WCGEN_NAME . '_bootstrap-min', WCGEN_LIBS . 'bootstrap/js/bootstrap.min.js', array('jquery'), WCGEN_VER, true);
        wp_enqueue_script(WCGEN_NAME . '-owl-carousel-js', WCGEN_LIBS . 'owl-carousel/js/owl.carousel.min.js', array(), WCGEN_VER, true);
        wp_enqueue_script(WCGEN_NAME . '_admin', WCGEN_JS . 'admin.js', array('jquery'), WCGEN_VER, true);
        $admin_url = strtok(admin_url('admin-ajax.php', (is_ssl() ? 'https' : 'http')), '?');
        wp_localize_script(WCGEN_NAME . '_admin', 'wcgen_vars', array(
            'ajaxurl' => $admin_url,
            'pluginurl' => WCGEN_TCPDF_URL,
            'ajax_public_nonce' => wp_create_nonce('ajax_public_nonce'),
        ));
      
    }
}

?>