<?php defined('ABSPATH') or die("No script kiddies please!");
$egpr_reviews = get_option('egp_reviews');
$nverified_api_key = (isset($egpr_reviews['nverified_api_key']) && $egpr_reviews['nverified_api_key'] != '') ? $egpr_reviews['nverified_api_key'] : '';
$enable_floating_review = (isset($egpr_reviews['floating_review']['enable_floating_review']) && $egpr_reviews['floating_review']['enable_floating_review'] == 1) ? 1 : 0;
$default_review = (isset($egpr_reviews['floating_review']['default_review']) && $egpr_reviews['floating_review']['default_review'] != '') ? $egpr_reviews['floating_review']['default_review'] : '';
$layout = (isset($egpr_reviews['floating_review']['layout']) && $egpr_reviews['floating_review']['layout'] != '') ? $egpr_reviews['floating_review']['layout'] : 'template1';
$placement = (isset($egpr_reviews['floating_review']['placement']) && $egpr_reviews['floating_review']['placement'] != '') ? $egpr_reviews['floating_review']['placement'] : '';
$display = (isset($egpr_reviews['floating_review']['show_floating_review_on']) && $egpr_reviews['floating_review']['show_floating_review_on'] != '') ? $egpr_reviews['floating_review']['show_floating_review_on'] : 'all_pages';
$page_specific_display = (isset($egpr_reviews['floating_review']['page_specific_display']) && $egpr_reviews['floating_review']['show_floating_review_on'] != '') ? $egpr_reviews['floating_review']['page_specific_display'] : array();
$cache_check = (isset($egpr_reviews['check_cache']) && $egpr_reviews['check_cache'] == 'true') ? 'true' : 'false';
$cache_period = (isset($egpr_reviews['cache_period']) && $egpr_reviews['cache_period'] != '') ? $egpr_reviews['cache_period']: '24';
?>
<div class="egpr-settings-main-wrapper egpr-rwrapper">
    <div class="egpr-header">
        <?php include_once('panel-head.php'); ?>
    </div>
    <?php if (isset($_GET['restore_message'])) { ?>
        <div class="notice notice-success egpr-message">
            <p><?php _e('Restored Default Settings Successfully.', 'everest-google-places-reviews'); ?></p>
        </div>
    <?php } ?>
    <?php if (isset($_GET['message'])) { ?>
        <div class="notice notice-success egpr-message">
            <p><?php _e('Settings Saved Successfully.', 'everest-google-places-reviews'); ?></p>
        </div>
    <?php } ?>
       <?php if (isset($_GET['cache_message'])) { ?>
        <div class="notice notice-success egpr-message">
            <p><?php _e('Cache Cleared Successfully.', 'everest-google-places-reviews'); ?></p>
        </div>
    <?php } ?>
    <div class="egpr-container egpr-tab-container">
        <div class="egpr-row">
            <div class="egpr_mainwrapper clearfix">
                <div class="egpr_second-wrapper"> 
                    <ul class="egpr-nav-tabs egpr-tabs-left">
                        <li class="tab-link current">
                            <a class="tab_settings" data-tab="api_settings" data-toggle="tab">
                                <span class="dashicons dashicons-admin-generic"></span>
                                <?php _e('API Settings', 'everest-google-places-reviews'); ?>
                            </a>
                        </li>
                        <li class="tab-link">
                            <a class="tab_settings" data-tab="floating_review_settings"  data-toggle="tab">
                                <span class="dashicons dashicons-feedback"></span>
                                <?php _e('Floating Review Settings', 'everest-google-places-reviews'); ?>
                            </a>
                        </li>
                         <li class="tab-link">
                            <a class="tab_settings" data-tab="cachesettings" data-toggle="tab">
                                <span class="dashicons dashicons-update"></span>
                                <?php _e('Cache Settings', 'everest-google-places-reviews'); ?>
                            </a>
                        </li>
                        <li class="tab-link">
                            <a class="tab_settings" data-tab="howtouse" data-toggle="tab">
                                <span class="dashicons dashicons-info"></span>
                                <?php _e('How To Use', 'everest-google-places-reviews'); ?>
                            </a>
                        </li>
                         <li class="tab-link">
                            <a class="tab_settings" data-tab="shortcode_usage" data-toggle="tab">
                                <span class="dashicons dashicons-format-aside"></span>
                                <?php _e('Shortcode Usage', 'everest-google-places-reviews'); ?>
                            </a>
                        </li>
                        <li class="tab-link">
                            <a class="tab_settings" data-tab="aboutus" data-toggle="tab">
                                <span class="dashicons dashicons-businessman"></span>
                                <?php _e('More WordPress Stuff', 'everest-google-places-reviews'); ?>
                            </a>
                        </li>
                    </ul>
                </div>

                <div class="egpr-content-wrapper">
                    <form action="<?php echo admin_url('admin-post.php'); ?>" method="post" enctype="multipart/form-data">
                        <input type="hidden" name="action" value="egpr_save_settings">
                        <?php wp_nonce_field('egpr-nonce', 'egpr_nonce_setup'); ?>
                        <div class="egpr-tab-pane">
                            <div class="egpr-tab-content current" id="api_settings">
                                <?php include_once('api-settings.php'); ?> 
                            </div>
                            <div class="egpr-tab-content" id="floating_review_settings" style="display: none;">
                                <?php include_once('floating-review-page.php'); ?>                 
                            </div>
                             <div class="egpr-tab-content" id="cachesettings" style="display: none;">
                                <?php include_once('cache_settings.php'); ?>                 
                            </div>
                            <div class="egpr-tab-content" id="howtouse" style="display: none;">
                                <?php include_once('egpr-howtouse.php'); ?>               
                            </div>
                           <div class="egpr-tab-content" id="shortcode_usage" style="display: none;">
                                <?php include_once('egpr-shortcode-usage.php'); ?>               
                            </div>

                            <div class="egpr-tab-content" id="aboutus" style="display: none;">
                                <?php include_once('egpr-about.php'); ?>            
                            </div>
                        </div>
                        <div class="egpr-field-wrapper egpr-form-actions-wrap">
                            <input type="submit" class="egpr-button-primary button button-primary" id="egpr-add-button" name="egpr_settings_submit" value="<?php _e('Save Changes', 'everest-google-places-reviews'); ?>">
                            <input type="submit" class="egpr-button-secondary button button-primary" id="egpr-restore-btn" name="egpr_restore_settings" value="<?php _e('Restore Default Settings', 'everest-google-places-reviews'); ?>">
                            <input type="submit" class="egpr-button-secondary button button-primary" id="egpr-clear-cache-btn" name="egpr_clear_cache" value="<?php _e('Clear Cache', 'everest-google-places-reviews'); ?>" onclick="return confirm('<?php _e('Are you sure you want to clear cache for google reviews?', 'everest-google-places-reviews'); ?>')">
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>