<?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', 'wppowersuite-lite' );
$cptb_key_attr = 'data-cptb-key-placeholder';
?>
<h2><?php esc_html_e( 'Permalinks & archives', 'wppowersuite-lite' ); ?></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.', 'wppowersuite-lite' ); ?></p>

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