<?php defined('ABSPATH') or die('No script kiddies please!'); ?>

<?php 

// echo "<pre>";
// print_r($wpwab_settings);
// echo "</pre>";

?>

<div class="wrap wpwab-wrap">
    <div class="wpwab-content-wrap">
        <div class="wpwab-page-list">
            <div class="wpwab-content-wrap">
                <div class="wpwab-field-wrap" id="wpwab-pages" >
                    <label><?php _e('Pages', wpwab_TD); ?></label>
                    <div class="wpwab-field">
                        <label><input type="radio" name="wpwab_settings[multi][pages]" value="all" id="wpwab-all-pages-multi"  <?php echo ((isset($wpwab_settings['multi']['pages'])) && $wpwab_settings['multi']['pages'] === "all") ? "checked='checked'" : ""; ?>>All Pages</label>

                        <label><input type="radio" name="wpwab_settings[multi][pages]" value="page" id="wpwab-specific-pages-multi"   <?php echo ((isset($wpwab_settings['multi']['pages'])) && $wpwab_settings['multi']['pages'] === "page") ? "checked='checked'" : ""; ?>>Specific Pages</label><br>
                    </div>

                    <div class="wpwab-multi-settings-page" id="wpwab-show-pagelist"></div>
                    
                    <input type="hidden" name="wpwab_settings[multi][page_details]" value=<?php echo isset($wpwab_settings['multi']['pages']) ? $wpwab_settings['multi']['pages']:''; ?> id="wpwab-page-details-multi">
                </div>
                <div class="wpwab-field-wrap" >
                    <label><?php _e('Post', wpwab_TD); ?></label>
                    <div class="wpwab-field">
                        <label><input type="radio" name="wpwab_settings[multi][posts]" value="all" id="wpwab-all-posts-multi" <?php echo ((isset($wpwab_settings['multi']['posts'])) && $wpwab_settings['multi']['posts'] === "all") ? "checked='checked'" : ""; ?> >All Post</label>
                        <label><input type="radio" name="wpwab_settings[multi][posts]" value="post"  class="wpwab-list" id="wpwab-specific-post-multi" <?php echo ((isset($wpwab_settings['multi']['posts'])) && $wpwab_settings['multi']['posts'] === "post") ? "checked='checked'" : ""; ?>>
                            Specific Post </label> <br >
                    </div>
                    <div class="wpwab-multi-settings-post" id="wpwab-show-postlist" > </div>

                    <input type="hidden" name="wpwab_settings[multi][post_details]" value=<?php echo isset($wpwab_settings['multi']['posts']) ? $wpwab_settings['multi']['posts']:''; ?> id="wpwab-post-details-multi"> 
                    
                    <!-- <input type="hidden" name="wpwab_settings[multi][post_details]" value="post" id="wpwab-post-details-multi"> -->
                </div>
                <div class="wpwab-field-wrap">
                    <label><?php _e('Category', wpwab_TD); ?></label>
                    <div class="wpwab-field">
                        <label><input type="radio" name="wpwab_settings[multi][category]" value="all" id="wpwab-all-category"<?php echo ((isset($wpwab_settings['multi']['category'])) && $wpwab_settings['multi']['category'] === "all") ? "checked='checked'" : ""; ?>>All Category</label>
                        <label><input type="radio" name="wpwab_settings[multi][category]" id="wpwab-specific-category" value="specific" <?php echo ((isset($wpwab_settings['multi']['category'])) && $wpwab_settings['multi']['category'] === "specific") ? "checked='checked'" : ""; ?>>Specific Category</label><br>
                    </div>
                </div>
                <div id="wpwab-display-selection" >
                    <div class="wpwab-tab-contents" >
                        <?php
                        // $selected_pages = (isset($wpwab_settings['multi']['specific_pages_list']) && $wpwab_settings['multi']['specific_pages_list'] !='') ? implode(',', $wpwab_settings['multi']['specific_pages_list']) : '';
                        // $selected_posts = (isset($wpwab_settings['multi']['specific_posts_list']) && $wpwab_settings['multi']['specific_posts_list'] != '') ? implode(',', $wpwab_settings['multi']['specific_posts_list']) : '';

                        $selected_pages = (isset($wpwab_settings['multi']['specific_pages_list']) && $wpwab_settings['multi']['specific_pages_list'] !='') ? ($wpwab_settings['multi']['specific_pages_list']) : '';
                        $selected_posts = (isset($wpwab_settings['multi']['specific_posts_list']) && $wpwab_settings['multi']['specific_posts_list'] != '') ? ( $wpwab_settings['multi']['specific_posts_list']) : '';
                        ?>
                        <input type="hidden" id="wpwab-selected-pages-multi" name="wpwab_settings[multi][specific_pages_list]" value="<?php echo $selected_pages; ?>"/>
                        <input type="hidden" id="wpwab-selected-posts-multi" name="wpwab_settings[multi][specific_posts_list]" value="<?php echo $selected_posts; ?>"/>

                    </div>
                </div>
                <div id="wpwab-display-category" style="display: none;" >
                    <div class="wpwab-field-wrap" >
                        <label class="wpwab-block"><?php _e('Select Category', wpwab_TD); ?></label>
                        <div class="wpwab-field">
                            <?php
                            $categories = get_categories(array('hide_empty' => 0));
                            $specific_category = (!empty($wpwab_settings['multi']['specific_category'])) ? $wpwab_settings['multi']['specific_category'] : array();
                            foreach ($categories as $category) {
                                ?>
                                <label class="wpwab-block"><input type="checkbox" id="wpwab-category-" value="<?php echo $category->term_id; ?>"  name="wpwab_settings[multi][specific_category][]" <?php echo (in_array($category->term_id, $specific_category)) ? 'checked="checked"' : ''; ?> ><?php echo $category->name; ?></label>
                                <?php }
                                ?>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
