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

namespace CptBuilder;

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

$cptb_key    = isset( $definition['key'] ) ? (string) $definition['key'] : '';
$cptb_key_ph = $cptb_key !== '' ? $cptb_key : __( 'e.g. book', 'wp-powersuite' );
$cptb_key_attr = 'data-cptb-key-placeholder';
?>
<h2><?php esc_html_e( 'Permalinks & archives', 'wp-powersuite' ); ?></h2>
<p class="description"><?php esc_html_e( 'These options control front-end URLs. WP PowerSuite flushes rewrite rules automatically on the next admin page load after you save.', 'wp-powersuite' ); ?></p>

<table class="form-table" role="presentation">
	<tbody>
		<?php
		cptb_arg_checkbox( $definition, 'has_archive', __( 'Has archive', 'wp-powersuite' ), __( 'Enable a post type archive page (e.g. /books/).', 'wp-powersuite' ) );
		cptb_arg_text( $definition, 'has_archive_slug', __( 'Archive slug', 'wp-powersuite' ), __( 'Custom archive slug. Leave empty to use the post type key.', 'wp-powersuite' ), $cptb_key_ph, $cptb_key_attr );
		cptb_arg_checkbox( $definition, 'rewrite', __( 'Pretty permalinks', 'wp-powersuite' ), __( 'Use clean, rewritten URLs for single items.', 'wp-powersuite' ) );
		cptb_arg_text( $definition, 'rewrite_slug', __( 'Permalink slug', 'wp-powersuite' ), __( 'Base slug for single item URLs. Defaults to the post type key.', 'wp-powersuite' ), $cptb_key_ph, $cptb_key_attr );
		cptb_arg_checkbox( $definition, 'rewrite_with_front', __( 'Prepend permalink front', 'wp-powersuite' ), __( 'Include the global permalink base (the "front") before the slug.', 'wp-powersuite' ) );
		cptb_arg_checkbox( $definition, 'rewrite_feeds', __( 'Enable feeds', 'wp-powersuite' ), __( 'Generate feed permalink rules for the archive.', 'wp-powersuite' ) );
		cptb_arg_checkbox( $definition, 'rewrite_pages', __( 'Enable pagination', 'wp-powersuite' ), __( 'Generate paginated archive permalink rules.', 'wp-powersuite' ) );
		cptb_arg_checkbox( $definition, 'query_var', __( 'Enable query var', 'wp-powersuite' ), __( 'Allow querying items by a public query variable.', 'wp-powersuite' ) );
		cptb_arg_text( $definition, 'query_var_slug', __( 'Query var slug', 'wp-powersuite' ), __( 'Custom query variable name. Defaults to the post type key.', 'wp-powersuite' ), $cptb_key_ph, $cptb_key_attr );
		?>
	</tbody>
</table>
