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

namespace CptBuilder;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
?>
<h2><?php esc_html_e( 'Visibility', 'wppowersuite-lite' ); ?></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).', 'wppowersuite-lite' ); ?>
</p>

<table class="form-table" role="presentation">
	<tbody>
		<?php
		cptb_arg_checkbox( $definition, 'public', __( 'Public', 'wppowersuite-lite' ), __( 'Visible on the front end and in the admin (master switch).', 'wppowersuite-lite' ) );
		cptb_arg_checkbox( $definition, 'publicly_queryable', __( 'Publicly queryable', 'wppowersuite-lite' ), __( 'Allow front-end queries (single and archive URLs).', 'wppowersuite-lite' ) );
		cptb_arg_checkbox( $definition, 'show_ui', __( 'Show UI', 'wppowersuite-lite' ), __( 'Generate the default admin management screens.', 'wppowersuite-lite' ) );
		cptb_arg_checkbox( $definition, 'show_in_menu', __( 'Show in admin menu', 'wppowersuite-lite' ), __( 'Display the post type in the admin sidebar menu.', 'wppowersuite-lite' ) );
		?>
		<tr>
			<th scope="row"><label for="cptb-show-in-menu-parent"><?php esc_html_e( 'Parent menu slug', 'wppowersuite-lite' ); ?></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.', 'wppowersuite-lite' ); ?></p>
			</td>
		</tr>
		<tr>
			<th scope="row"><label for="cptb-menu-position"><?php esc_html_e( 'Menu position', 'wppowersuite-lite' ); ?></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.', 'wppowersuite-lite' ); ?></p>
			</td>
		</tr>
		<?php
		cptb_arg_checkbox( $definition, 'show_in_nav_menus', __( 'Show in nav menus', 'wppowersuite-lite' ), __( 'Make items available in Appearance → Menus.', 'wppowersuite-lite' ) );
		cptb_arg_checkbox( $definition, 'show_in_admin_bar', __( 'Show in admin bar', 'wppowersuite-lite' ), __( 'Add to the “+ New” admin bar menu.', 'wppowersuite-lite' ) );
		cptb_arg_checkbox( $definition, 'exclude_from_search', __( 'Exclude from search', 'wppowersuite-lite' ), __( 'Hide items from front-end search results. Warning: WordPress also hides excluded items from taxonomy term archives (e.g. /genre/fiction/).', 'wppowersuite-lite' ) );
		cptb_arg_checkbox( $definition, 'hierarchical', __( 'Hierarchical', 'wppowersuite-lite' ), __( 'Allow parent/child relationships (like Pages). Requires the “Page attributes” support.', 'wppowersuite-lite' ) );
		cptb_arg_checkbox( $definition, 'can_export', __( 'Can export', 'wppowersuite-lite' ), __( 'Include items in the WordPress export tool.', 'wppowersuite-lite' ) );
		cptb_arg_checkbox( $definition, 'delete_with_user', __( 'Delete with user', 'wppowersuite-lite' ), __( 'Delete a user’s items when that user is deleted.', 'wppowersuite-lite' ) );
		?>
	</tbody>
</table>
