<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit; }

class Sifency_Addons_CPT_Meta_Modal {
	private $target_cpts = array(
		'doc',
		'portfolio',
		'service',
		'team',
		'event',
		'career',
		'award',
		'client',
		'digital',
		'testimonial',
		'menu',
		'section_templates',
		'themebuilder',
		'stack',
	);

	/**
	 * ---------------------------------------------------------
	 * META MODAL
	 * ---------------------------------------------------------
	 */
	public function render_meta_modal_markup() {
		$screen = get_current_screen();
		if ( ! $screen || 'edit' !== $screen->base || ! in_array( $screen->post_type, $this->target_cpts ) ) {
			return;
		}
		?>
		<div id="sifency-meta-modal" class="sifency-modal-backdrop" style="display:none;">
			<div class="sifency-modal-content">
				<header class="sifency-modal-header">
					<h3>Quick Edit Meta</h3>
					<button type="button" class="sifency-modal-close dashicons dashicons-no-alt"></button>
				</header>
				<div class="sifency-modal-body">
					<div class="sifency-modal-loading"><span class="dashicons dashicons-update spin"></span> Loading...</div>
					<form id="sifency-meta-form" style="display:none;">
						<input type="hidden" name="post_id" id="sifency-meta-post-id" value="">
						
						<div class="sifency-form-group" style="margin-bottom: 15px;">
							<label><strong>Post Title</strong></label>
							<input type="text" name="post_title" id="sifency-post-title" class="widefat">
						</div>
						<div class="sifency-form-group" style="margin-bottom: 15px;">
							<label><strong>Content</strong></label>
							<textarea name="post_content" id="sifency-content" rows="6" class="widefat"></textarea>
						</div>
						<div class="sifency-form-group">
							<label><strong>Excerpt</strong></label>
							<textarea name="post_excerpt" id="sifency-excerpt" rows="3" class="widefat"></textarea>
						</div>
						<hr>
						<div id="sifency-meta-fields-container"></div>
					</form>
				</div>
				<footer class="sifency-modal-footer">
					<button type="button" class="sifency-btn-secondary sifency-modal-close sifency-admin-btn">Cancel</button>
					<button type="button" class="sifency-btn-primary sifency-admin-btn" id="sifency-save-meta">Save Changes</button>
				</footer>
			</div>
		</div>
		<?php
	}
}