<!-- File for Poup type=> text -->

<?php
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals -- Variables are confined to this rendering template.

use InstantPopup\Settings\class_instant_setting;
use Admin\Settings\Edit\Class_instant_setting_edit;

if (! defined('ABSPATH')) exit; // Exit if accessed directly

// Set global variable to indicate this is a text popup
$GLOBALS['instant_popup_builder_ipb_current_popup_type'] = 'text';

include_once plugin_dir_path(dirname(__FILE__)) . 'settings/class-instant-setting.php';
include_once plugin_dir_path(dirname(__FILE__)) . 'settings/edit/class-instant-setting-edit.php';
?>
<div class="intant_new_popup_type">
    <div class="instant_inner_wrapper">
        <div class="heading">
            <h1>POPUP TYPE: TEXT</h1>
            <hr>
        </div>
        <form action="" method="post" id='new_pp_form' enctype="multipart/form-data">
            <div class="instant_left_col">
                <div class="input_wrapper">
                    <input type="text" name="popup_title" id="popup_title" placeholder="Enter Your popup name">
                </div>
                <?php

                wp_nonce_field('instant_popup_nonce', '_wpnonce');

                ?>
                <div class="input_wrapper ipb_text_editor">
                    <!-- <div class="label"><label for="">Enter Your Text</label></div> -->
                    <?php
                    // Use WordPress wp_editor (TinyMCE) for text popup content
                    $editor_content = '';
                    $editor_settings = array(
                        'textarea_name' => 'popup_type_value',
                        'textarea_rows' => 15,
                        'media_buttons' => true,
                        'teeny' => false,
                        'tinymce' => array(
                            'toolbar1' => 'bold,italic,underline,strikethrough,|,bullist,numlist,|,blockquote,|,alignleft,aligncenter,alignright,|,link,unlink,|,forecolor,backcolor,|,formatselect,fontsize,|,undo,redo',
                            'toolbar2' => '',
                        ),
                        'quicktags' => true,
                    );
                    wp_editor( $editor_content, 'popup_type_value', $editor_settings );
                    ?>
                    <input type="hidden" name="popup_temp_type" value="popup_text">
                </div>
            </div>
            <div class="instant-right_col postbox">
                <div id="ipb_actions_wrapper">
                    <!-- <div id="delete-action">
                        <a class="submit delete deletion" href="#" style="display: inline;">Move to Trash</a>
                    </div> -->
                    <div id="ipb_pop_action">
                        <p class='preview_links'>
                            <a href="#" class="enhanced-preview-trigger"><i class="fa-solid fa-eye"></i> Preview<span></span></a>
                        </p>
                    </div>
                    <div id="ipb_pop_action">
                        <!-- <button name="instant_popup_builder_draft" id="ipb_action_draft">Save To Draft</button> -->
                        <button type="submit" name="instant_popup_builder_submit" value="Save Draft" class="ipb-save-draft">
                        <i class="fa-solid fa-save"></i> Save Draft
                    </button>
                    </div>
                    <div id="ipb_pop_action">
                        <button type="submit" name="instant_popup_builder_submit" value="Publish" class="ipb-publish">
                        <i class="fa-solid fa-paper-plane"></i> Publish
                    </button>
                    </div>
                </div>


                <!-- <div class="text_submit_btn">
                    <input class="ipb_submit" type="submit" value="Publish" id="text_popup" name="instant_popup_builder_submit">
                </div> -->
            </div>

            <?php

            $instant_popup_builder_updated_tabs = [
                "general" => 'General',
                "design" => 'Design',
                "advance" => 'Advanced',
                'schedule' => "Schedule"
            ];
            class_instant_setting::setting_set_tabs($instant_popup_builder_updated_tabs);
            $tabs = class_instant_setting::setting_get_tabs();
            $instant_popup_builder_edit_setting = new Class_instant_setting_edit();
            ?>
            <?php if(empty($is_edit_mode)){ ?>
            <div class="instant_popup_setting modern-tabs">
                <?php
                // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- $instant_popup_builder_edit_setting->setting_edit_navigation() returns safe HTML
                echo $instant_popup_builder_edit_setting->setting_edit_navigation(); ?>
                <div class="tabs_content">
                    <div id="ipb_text" class="tab_content active">
                        <div class="ipb-settings-tabs">
                            <div class="ipb-tab-content">
                                <div id="text-styling" class="ipb-tab-pane active">
                                    <?php class_instant_setting::design_setting('text-styling'); ?>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div id="general" class="tab_content">

                        <div class="ipb-settings-tabs">
                            <!-- <ul class="v_tabs_list">
                                <li class="display active" data-id="display">Display</li>
                                <li class="trigger" data-id="trigger">Trigger</li>
                                <li class="closing" data-id="closing">Closing</li>
                                <li class="limitation" data-id="limitation">Frequency</li>
                                <li class="position" data-id="position">Position</li>
                                <li class="action" data-id="action">Action</li>
                            </ul> -->
                            <div class="ipb-tab-content">

                                <div id="display" class="ipb-tab-pane active">
                                    <?php class_instant_setting::general_setting('display'); ?>
                                </div>
                                <div id="trigger" class="ipb-tab-pane">
                                    <?php class_instant_setting::general_setting('trigger'); ?>
                                </div>
                                <div id="closing" class="ipb-tab-pane">
                                    <?php class_instant_setting::general_setting('closing'); ?>
                                </div>
                                <div id="limitation" class="ipb-tab-pane">
                                    <?php class_instant_setting::general_setting('limit'); ?>
                                </div>
                                <div id="position" class="ipb-tab-pane">
                                    <?php class_instant_setting::general_setting('position'); ?>
                                </div>
                                <div id="action" class="ipb-tab-pane">
                                    <?php class_instant_setting::general_setting('action'); ?>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div id="design" class="tab_content">

                        <div class="ipb-settings-tabs">
                            <!-- <ul class="v_tabs_list">
                                <li class="theme active" data-id="theme">Theme</li>
                                <li class="background active" data-id="background">Background</li>
                                <li class="size" data-id="size">Size</li>
                                <li class="animation" data-id="animation">Animation</li>
                                <li class="sound" data-id="sound">Sound</li>
                            </ul> -->
                            <div class="ipb-tab-content">

                                <!-- <div id="theme" class="v_tab_content active"> -->
                                <?php
                                //  class_instant_setting::design_setting('theme');
                                ?>
                                <!-- </div> -->
                                <div id="background" class="ipb-tab-pane active">
                                    <?php class_instant_setting::design_setting('background'); ?>
                                </div>
                                <div id="size" class="ipb-tab-pane">
                                    <?php class_instant_setting::design_setting('size'); ?>
                                </div>
                                <div id="animation" class="ipb-tab-pane">
                                    <?php class_instant_setting::design_setting('animation'); ?>
                                </div>
                                <div id="sound" class="ipb-tab-pane">
                                    <?php class_instant_setting::design_setting('sound'); ?>
                                </div>
                                <div id="text-styling" class="ipb-tab-pane">
                                    <?php class_instant_setting::design_setting('text-styling'); ?>
                                </div>
                            </div>
                        </div>
                    </div>
                    <?php /*
                    <div id="advance" class="tab_content">
                        <div class="vertical_tabs">
                            <ul class="v_tabs_list">
                                <li class="sound" data-id="sound">Sound</li>
                            </ul>
                            <div class="v_tabs_content">

                                <div id="sound" class="v_tab_content">
                                    <?php class_instant_setting::advance_setting('sound'); ?>
                                </div>
                            </div>
                        </div>
                    </div> */ ?>
                    <div id="condition" class="tab_content">
                        <div class="ipb-settings-tabs">
                            <!-- <ul class="v_tabs_list">
                                <li class="targeting active" data-id="targeting">Targeting</li>
                                <li class="location" data-id="location">Location</li>
                                <li class="scheduling" data-id="scheduling">Scheduling</li>
                            </ul> -->
                            <div class="ipb-tab-content">

                                <div id="targeting" class="ipb-tab-pane active">
                                    <?php class_instant_setting::condition_setting('targeting'); ?>
                                </div>
                                <div id="location" class="ipb-tab-pane">
                                    <?php class_instant_setting::condition_setting('location'); ?>
                                </div>
                                <div id="scheduling" class="ipb-tab-pane">
                                    <?php class_instant_setting::condition_setting('scheduling'); ?>
                                </div>
                                <div id="language_targeting" class="ipb-tab-pane">
                                    <?php class_instant_setting::condition_setting('language_targeting'); ?>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <?php }else{ ?>
        <div class="instant_popup_setting">
            <?php
            $instant_popup_builder_setting_edit = new Class_instant_setting_edit();
            // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- $instant_popup_builder_setting_edit->setting_edit_navigation() returns safe HTML
            echo $instant_popup_builder_setting_edit->setting_edit_navigation();
            ?>
            <?php
            // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- $instant_popup_builder_setting_edit->setting_edit_screen() returns safe HTML
            echo $instant_popup_builder_setting_edit->setting_edit_screen($row, 'text'); ?>
        </div>
        <?php } ?>
        </form>
    </div>
</div>
