<?php

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

function eapsgt_tab_basic_settings() {
	wp_nonce_field( basename( __FILE__ ), "nonce3" );
	$templates = EAPSGT_AnimatedPopupConfig::templates();
	?>
    <div class="eapsgt-basic__admin">
        <div id="eapsgt-basic__option" class="eapsgt-basic__option">
            <table class="eapsgt-detailtbl">
                <tr class="eapsgt-row eapsgt-width-height">
                    <th scope="row">
                        <div class="eapsgt-options"><?php esc_html_e( "PopUp Size", 'easy-animated-popup' ); ?></div>
                    </th>
                    <td><input type="number" id="eapsgt-width" name="eapsgt-width"
                               value="<?php echo esc_attr( get_post_meta( get_the_ID(), 'eapsgt-width', true ) ) ?>"
                               min="0" max="2000" placeholder="width"><?php esc_html_e( " x ", 'easy-animated-popup' ); ?>
                        <input type="number" id="eapsgt-height" name="eapsgt-height"
                               value="<?php echo esc_attr( get_post_meta( get_the_ID(), 'eapsgt-height', true ) ) ?>"
                               min="0" max="2000" placeholder="height"><?php esc_html_e( " px ", 'easy-animated-popup' ); ?>
                        <div><?php esc_html_e( " (Recommended size 400 x 534) ", 'easy-animated-popup' ); ?></td>
                </tr>
                <tr class="eapsgt-row eapsgt-headline">
                    <th scope="row">
                        <div class="eapsgt-options"><?php esc_html_e( "Headline", 'easy-animated-popup' ); ?></div>
                    </th>
                    <td><input type="text" class="eapsgt-filter__item__text"
                               id="eapsgt-headline" name="eapsgt-headline"
                               value="<?php echo esc_attr( get_post_meta( get_the_ID(), 'eapsgt-headline', true ) ) ?>"
                               placeholder="Please enter headline">
                    </td>
                </tr>
                <tr class="eapsgt-row eapsgt-description-text-1">
                    <th scope="row">
                        <div class="eapsgt-options"><?php esc_html_e( "Description Text 1", 'easy-animated-popup' ); ?></div>
                    </th>
                    <td><textarea class="eapsgt-formGroup__input" id="eapsgt-description-text-1"
                                  name="eapsgt-description-text-1"
                                  placeholder="Please enter description"><?php echo esc_attr( esc_textarea( get_post_meta( get_the_ID(), 'eapsgt-description-text-1', true ) ) ) ?></textarea>
                    </td>
                </tr>
                <tr class="eapsgt-row eapsgt-description-text-2">
                    <th>
                        <div class="eapsgt-options"><?php esc_html_e( "Description Text 2", 'easy-animated-popup' ); ?></div>
                    </th>
                    <td><textarea class="eapsgt-formGroup__input" id="eapsgt-description-text-2"
                                  name="eapsgt-description-text-2"
                                  placeholder="Please enter description"><?php echo esc_attr( esc_textarea( get_post_meta( get_the_ID(), 'eapsgt-description-text-2', true ) ) ) ?></textarea>
                    </td>
                </tr>
                <tr class="eapsgt-row eapsgt-description-text-3">
                    <th scope="row">
                        <div class="eapsgt-options"><?php esc_html_e( "Description Text 3", 'easy-animated-popup' ); ?></div>
                    </th>
                    <td><textarea class="eapsgt-formGroup__input" id="eapsgt-description-text-3"
                                  name="eapsgt-description-text-3"
                                  placeholder="Please enter description"><?php echo esc_attr( esc_textarea( get_post_meta( get_the_ID(), 'eapsgt-description-text-3', true ) ) ) ?></textarea>
                    </td>
                </tr>
                <tr class="eapsgt-row eapsgt-button-text">
                    <th scope="row">
                        <div class="eapsgt-options"><?php esc_html_e( "Button Text", 'easy-animated-popup' ); ?></div>
                    </th>
                    <td><input type="text" class="eapsgt-filter__item__text"
                               id="eapsgt-button-text" name="eapsgt-button-text"
                               value="<?php echo esc_attr( get_post_meta( get_the_ID(), 'eapsgt-button-text', true ) ) ?>"
                               placeholder="Please enter button text">
                    </td>
                </tr>
                <tr class="eapsgt-row eapsgt-background-image">
                    <th scope="row">
                        <div class="eapsgt-options"><?php esc_html_e( "Background Image", 'easy-animated-popup' ); ?></div>
                    </th>
                    <td><input type="url" class="eapsgt-filter__item__text"
                               id="eapsgt-background-image"
                               name="eapsgt-background-image"
                               value="<?php echo esc_attr( get_post_meta( get_the_ID(), 'eapsgt-background-image', true ) ) ?>"
                               placeholder="Please enter background image url"></td>
                </tr>
                <tr class="eapsgt-row eapsgt-logo-url">
                    <th scope="row">
                        <div class="eapsgt-options"><?php esc_html_e( "Image URL", 'easy-animated-popup' ); ?></div>
                    </th>
                    <td><input type="url" class="eapsgt-filter__item__text"
                               id="eapsgt-logo-url" name="eapsgt-logo-url"
                               value="<?php echo esc_attr( get_post_meta( get_the_ID(), 'eapsgt-logo-url', true ) ) ?>"
                               placeholder="Please enter logo url"></td>
                </tr>
                <tr class="eapsgt-row eapsgt-logo-url-2">
                    <th scope="row">
                        <div class="eapsgt-options"><?php esc_html_e( "Image URL 2", 'easy-animated-popup' ); ?></div>
                    </th>
                    <td><input type="url" class="eapsgt-filter__item__text"
                               id="eapsgt-logo-url-2" name="eapsgt-logo-url-2"
                               value="<?php echo esc_attr( get_post_meta( get_the_ID(), 'eapsgt-logo-url-2', true ) ) ?>"
                               placeholder="Please enter logo url"></td>
                </tr>
                <tr class="eapsgt-row eapsgt-button-url">
                    <th scope="row">
                        <div class="eapsgt-options"><?php esc_html_e( "Button URL ", 'easy-animated-popup' ); ?></div>
                    </th>
                    <td><input type="url" class="eapsgt-filter__item__text"
                               id="eapsgt-button-url" name="eapsgt-button-url"
                               value="<?php echo esc_attr( get_post_meta( get_the_ID(), 'eapsgt-button-url', true ) ) ?>"
                               data-update="sgt-call" placeholder="Please enter button url"></td>
                </tr>
            </table>
        </div>
        <div class="eapsgt-basic__preview">
			<?php
			foreach ( $templates as $index => $template ) {
				?>
                <div id="eapsgt-welcome<?php echo( $index + 1 ); ?>">
					<?php
					apply_filters( 'preview_eapsgt_' . esc_attr($template), '' ); ?>
                </div>
				<?php
			}
			?>
        </div>
    </div>
	<?php
}

add_filter( 'eapsgt_tab_basic_settings', 'eapsgt_tab_basic_settings' );
