<?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', 'wp-powersuite' );
?>
<h2><?php esc_html_e( 'REST API', 'wp-powersuite' ); ?></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.', 'wp-powersuite' ); ?></p>

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