<?php
/**
 * CPT Builder - REST API 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' );
?>
<h2><?php esc_html_e( 'REST API', 'wppowersuite-lite' ); ?></h2>
<p class="description"><?php esc_html_e( 'The REST API is required for the Block Editor (Gutenberg). Disable it only if you specifically want to hide this post type from the API.', 'wppowersuite-lite' ); ?></p>

<table class="form-table" role="presentation">
	<tbody>
		<?php
		cptb_arg_checkbox( $definition, 'show_in_rest', __( 'Show in REST API', 'wppowersuite-lite' ), __( 'Expose this post type via the REST API and enable the Block Editor.', 'wppowersuite-lite' ) );
		cptb_arg_text( $definition, 'rest_base', __( 'REST base', 'wppowersuite-lite' ), __( 'Base URL segment for REST routes. Defaults to the post type key.', 'wppowersuite-lite' ), $cptb_key_ph, 'data-cptb-key-placeholder' );
		cptb_arg_text( $definition, 'rest_namespace', __( 'REST namespace', 'wppowersuite-lite' ), __( 'Custom namespace for REST routes (e.g. "myplugin/v1"). Defaults to "wp/v2".', 'wppowersuite-lite' ), 'wp/v2' );
		cptb_arg_text( $definition, 'rest_controller_class', __( 'REST controller class', 'wppowersuite-lite' ), __( 'Advanced: a custom controller class name. Leave empty to use the default.', 'wppowersuite-lite' ), 'WP_REST_Posts_Controller' );
		?>
	</tbody>
</table>
