<?php

function at_admin_styles()
{
    if (isset($_GET['page']) && in_array($_GET['page'], array('at-google-play', 'at-aptoide', 'at-panel'))) {
        wp_enqueue_style('at-admin-fontawesome', THEMES_URIZ.'/assets/css/font-awesome.css', array(), VERSION);
    }

    if (isset($_GET['page']) && in_array($_GET['page'], array('at-google-play', 'at-aptoide'))) {
        wp_enqueue_style('at-admin-importer', THEMES_URIZ.'/assets/css/importer.css', array(), VERSION, 'all');
        wp_enqueue_style('at-result', THEMES_URIZ.'/assets/css/result.css', array(), VERSION, 'all');
    }

    //if (isset($_GET['page']) && in_array($_GET['page'], array('at-panel'))) {
    //    wp_enqueue_style('wp-color-picker');
    //    wp_enqueue_style('at-admin-panel', THEMES_URIZ.'/assets/css/panel.css', array(), VERSION, 'all');
    //}
}
add_action('admin_enqueue_scripts', 'at_admin_styles');

function at_admin_scripts()
{
    if (is_admin() && get_current_screen()->id === 'post') {
        wp_enqueue_style('new-apk-extractor-admin', THEMES_URIZ.'/assets/css/admin.css', array(), VERSION, 'all');
        wp_enqueue_script('new-apk-extractor-admin', THEMES_URIZ.'/assets/js/admin.js', array('jquery'), VERSION, true);
    }

    if (isset($_GET['page']) && in_array($_GET['page'], array('at-google-play'))) {
        wp_enqueue_script('apex-admin-importer', THEMES_URIZ.'/assets/js/gp.js', array(), VERSION, true);

        wp_localize_script(
            'apex-admin-importer',
            'apex_new_apkextractor_ajax_vars',
            array(
                'ajax_url' => admin_url('admin-ajax.php'),
                'nonce' => wp_create_nonce('gplay_nonce')
            )
        );
    }

    if (isset($_GET['page']) && in_array($_GET['page'], array('at-aptoide'))) {
        wp_enqueue_script('at-apt-admin-importer', THEMES_URIZ.'/assets/js/apt2.js', array(), VERSION, true);
        wp_enqueue_script('at-apt-admin-importer', THEMES_URIZ.'/assets/js/apt.js', array(), VERSION, true);

        wp_localize_script(
            'at-apt-admin-importer',
            'apex_new_apkextractor_ajax_vars',
            array(
                'ajax_url' => admin_url('admin-ajax.php'),
                'nonce' => wp_create_nonce('aptoide_nonce')
            )
        );
    }

    //if (isset($_GET['page']) && in_array($_GET['page'], array('at-panel'))) {
    //    wp_enqueue_script('jquery-ui-sortable');
    //    wp_enqueue_media();
    //    wp_enqueue_script('wp-color-picker');

    //    wp_enqueue_script('at-admin-panel', THEMES_URIZ.'/assets/js/panel.js', array(), VERSION, true);

    //    wp_localize_script(
    //        'at-admin-panel',
    //        'apex_new_apkextractor_ajax_vars',
    //        array(
    //            'ajax_url' => admin_url('admin-ajax.php'),
    //            'nonce' => wp_create_nonce('panel_nonce')
    //        )
    //    );
    //}
}
add_action('admin_enqueue_scripts', 'at_admin_scripts');
