<?php

/**
 * Custom Fields.
 *
 * @link    https://aiopodcasting.com
 * @since   1.0.0
 *
 * @package AiO_Podcast_Studio
 */

// Exit if accessed directly
if ( ! defined( 'WPINC' ) ) {
	die;
}

if ( 'add' === $form ) : ?>
    <div class="aiopod form-field term-image-group">
        <label for="aiopod-terms-image"><?php esc_html_e( 'Image', 'aio-podcast-studio' ); ?></label>
               
        <div id="aiopod-terms-image-wrapper"></div>

        <input type="hidden" name="image" id="aiopod-terms-image" />
        <input type="hidden" name="image_id" id="aiopod-terms-image_id" />            
        <?php wp_nonce_field( 'aiopod_save_category_fields', 'aiopod_category_fields_nonce' ); // Nonce ?>
        
        <p>            
            <input type="button" id="aiopod-terms-upload-image" class="button button-secondary" value="<?php esc_attr_e( 'Upload Image', 'aio-podcast-studio' ); ?>" />
            <input type="button" id="aiopod-terms-remove-image" class="button button-secondary" value="<?php esc_attr_e( 'Remove Image', 'aio-podcast-studio' ); ?>" style="display: none;" />
        </p>

        <p class="description">
            <?php esc_html_e( 'Recommended size: 400 x 400 pixels.', 'aio-podcast-studio' ); ?>
        </p>
    </div>
<?php elseif ( 'edit' === $form ) : ?>
    <tr class="aiopod form-field term-image-wrap">
        <th scope="row">
            <label for="aiopod-terms-image"><?php esc_html_e( 'Image', 'aio-podcast-studio' ); ?></label>
        </th>
        <td>        
            <div id="aiopod-terms-image-wrapper">
				<?php if ( ! empty( $image ) ) : ?>
                    <img src="<?php echo esc_url( $image ); ?>" alt="" loading="lazy" decoding="async" />
                <?php endif; ?>
            </div>

            <input type="hidden" name="image" id="aiopod-terms-image" value="<?php echo esc_attr( $image ); ?>" />
            <input type="hidden" name="image_id" id="aiopod-terms-image_id" value="<?php echo esc_attr( $image_id ); ?>" />
            <?php wp_nonce_field( 'aiopod_save_category_fields', 'aiopod_category_fields_nonce' ); // Nonce ?>

            <p>
                <input type="button" id="aiopod-terms-upload-image" class="button button-secondary" value="<?php esc_attr_e( 'Upload Image', 'aio-podcast-studio' ); ?>" <?php if ( $image ) echo 'style="display: none;"'; ?>/>
                <input type="button" id="aiopod-terms-remove-image" class="button button-secondary" value="<?php esc_attr_e( 'Remove Image', 'aio-podcast-studio' ); ?>" <?php if ( ! $image ) echo 'style="display: none;"'; ?>/>
            </p>

            <p class="description">
                <?php esc_html_e( 'Recommended size: 400 x 400 pixels.', 'aio-podcast-studio' ); ?>
            </p>
        </td>
    </tr>
<?php endif;
