<?php
/**
 * CPT Builder - Supports tab.
 *
 * @package CptBuilder
 *
 * @var array<string, mixed> $definition
 */

namespace CptBuilder;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

$selected = isset( $definition['supports'] ) && is_array( $definition['supports'] ) ? $definition['supports'] : [];
?>
<h2><?php esc_html_e( 'Supported features', 'wp-powersuite' ); ?></h2>
<p class="description"><?php esc_html_e( 'Choose which editor features this post type supports. Unchecked features are removed from the edit screen.', 'wp-powersuite' ); ?></p>

<div class="cptb-checkbox-grid">
	<?php foreach ( Config::supportsOptions() as $support => $meta ) : ?>
		<label class="cptb-checkbox-card">
			<input type="checkbox" name="supports[]" value="<?php echo esc_attr( $support ); ?>" <?php checked( in_array( $support, $selected, true ) ); ?>>
			<span class="cptb-checkbox-card__title"><?php echo esc_html( $meta['label'] ); ?></span>
			<span class="cptb-checkbox-card__help"><?php echo esc_html( $meta['help'] ); ?></span>
		</label>
	<?php endforeach; ?>
</div>
