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

namespace CptBuilder;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
?>
<h2><?php esc_html_e( 'Visibility', 'wp-powersuite' ); ?></h2>
<p class="description">
	<?php esc_html_e( '“Public” is a convenient master switch: toggling it applies sensible defaults to the granular options below, which you can still adjust individually afterwards (for example, a public post type that is hidden from the admin bar, or an admin-only post type with “Show UI” enabled).', 'wp-powersuite' ); ?>
</p>

<table class="form-table" role="presentation">
	<tbody>
		<?php
		cptb_arg_checkbox( $definition, 'public', __( 'Public', 'wp-powersuite' ), __( 'Visible on the front end and in the admin (master switch).', 'wp-powersuite' ) );
		cptb_arg_checkbox( $definition, 'publicly_queryable', __( 'Publicly queryable', 'wp-powersuite' ), __( 'Allow front-end queries (single and archive URLs).', 'wp-powersuite' ) );
		cptb_arg_checkbox( $definition, 'show_ui', __( 'Show UI', 'wp-powersuite' ), __( 'Generate the default admin management screens.', 'wp-powersuite' ) );
		cptb_arg_checkbox( $definition, 'show_in_menu', __( 'Show in admin menu', 'wp-powersuite' ), __( 'Display the post type in the admin sidebar menu.', 'wp-powersuite' ) );
		?>
		<tr>
			<th scope="row"><label for="cptb-show-in-menu-parent"><?php esc_html_e( 'Parent menu slug', 'wp-powersuite' ); ?></label></th>
			<td>
				<input
					type="text"
					id="cptb-show-in-menu-parent"
					name="args[show_in_menu_parent]"
					value="<?php echo esc_attr( (string) cptb_arg( $definition, 'show_in_menu_parent' ) ); ?>"
					class="regular-text"
					placeholder="edit.php?post_type=page"
				>
				<p class="description"><?php esc_html_e( 'Optional. Nest this post type under another admin menu (e.g. tools.php or edit.php?post_type=page). Leave empty for a top-level menu.', 'wp-powersuite' ); ?></p>
			</td>
		</tr>
		<tr>
			<th scope="row"><label for="cptb-menu-position"><?php esc_html_e( 'Menu position', 'wp-powersuite' ); ?></label></th>
			<td>
				<?php $cptb_menu_position = cptb_arg( $definition, 'menu_position' ); ?>
				<input type="number" id="cptb-menu-position" name="args[menu_position]" value="<?php echo esc_attr( $cptb_menu_position === '' ? '' : (string) (int) $cptb_menu_position ); ?>" class="small-text" min="1" max="100" step="1" placeholder="25">
				<p class="description"><?php esc_html_e( 'Numeric position in the admin sidebar (5 = below Posts, 20 = below Pages, 25 = below Comments). Leave empty for default.', 'wp-powersuite' ); ?></p>
			</td>
		</tr>
		<?php
		cptb_arg_checkbox( $definition, 'show_in_nav_menus', __( 'Show in nav menus', 'wp-powersuite' ), __( 'Make items available in Appearance → Menus.', 'wp-powersuite' ) );
		cptb_arg_checkbox( $definition, 'show_in_admin_bar', __( 'Show in admin bar', 'wp-powersuite' ), __( 'Add to the “+ New” admin bar menu.', 'wp-powersuite' ) );
		cptb_arg_checkbox( $definition, 'exclude_from_search', __( 'Exclude from search', 'wp-powersuite' ), __( 'Hide items from front-end search results. Warning: WordPress also hides excluded items from taxonomy term archives (e.g. /genre/fiction/).', 'wp-powersuite' ) );
		cptb_arg_checkbox( $definition, 'hierarchical', __( 'Hierarchical', 'wp-powersuite' ), __( 'Allow parent/child relationships (like Pages). Requires the “Page attributes” support.', 'wp-powersuite' ) );
		cptb_arg_checkbox( $definition, 'can_export', __( 'Can export', 'wp-powersuite' ), __( 'Include items in the WordPress export tool.', 'wp-powersuite' ) );
		cptb_arg_checkbox( $definition, 'delete_with_user', __( 'Delete with user', 'wp-powersuite' ), __( 'Delete a user’s items when that user is deleted.', 'wp-powersuite' ) );
		?>
	</tbody>
</table>
