<?php
/**
 * Advanced settings tab.
 *
 * @package Rsmspark_Content_Widgets
 *
 * @var array<string, mixed> $settings Plugin settings.
 */

defined( 'ABSPATH' ) || exit;

if ( class_exists( 'Rsmspark_Advanced_Settings', false ) ) {
	Rsmspark_Advanced_Settings::render_admin_notices();
}

?>
<form method="post" action="<?php echo esc_url( Rsmspark_Content_Widgets_Admin::settings_url( 'advanced' ) ); ?>">
	<?php wp_nonce_field( 'rsmspark_content_widgets_save_settings', 'rsmspark_content_widgets_settings_nonce' ); ?>
	<input type="hidden" name="rsm_settings_tab" value="advanced" />

	<table class="form-table" role="presentation">
		<tr>
			<th scope="row"><?php esc_html_e( 'Debug mode', 'rsm-content-widgets' ); ?></th>
			<td>
				<label>
					<input type="checkbox" name="rsmspark_content_widgets_debug_mode" value="1" <?php checked( ! empty( $settings['debug_mode'] ) ); ?> />
					<?php esc_html_e( 'Show HTML comments in page source when a widget is disabled, a template is missing, or render output is empty.', 'rsm-content-widgets' ); ?>
				</label>
			</td>
		</tr>
		<tr>
			<th scope="row"><?php esc_html_e( 'Per-widget asset loading', 'rsm-content-widgets' ); ?></th>
			<td>
				<label>
					<input type="checkbox" name="rsmspark_content_widgets_per_widget_assets" value="1" <?php checked( ! empty( $settings['per_widget_assets'] ) ); ?> />
					<?php esc_html_e( 'Load widget CSS/JS only when that widget renders (skip the shared bundle on initial page load).', 'rsm-content-widgets' ); ?>
				</label>
			</td>
		</tr>
		<tr>
			<th scope="row"><?php esc_html_e( 'Disable all styling', 'rsm-content-widgets' ); ?></th>
			<td>
				<label>
					<input type="checkbox" name="rsmspark_content_widgets_disable_all_styling" value="1" <?php checked( ! empty( $settings['disable_all_styling'] ) ); ?> />
					<?php esc_html_e( 'Do not enqueue widget stylesheets (useful when your theme provides all styling).', 'rsm-content-widgets' ); ?>
				</label>
			</td>
		</tr>
		<tr>
			<th scope="row"><?php esc_html_e( 'Experimental blocks', 'rsm-content-widgets' ); ?></th>
			<td>
				<label>
					<input type="checkbox" name="rsmspark_content_widgets_experimental_blocks" value="1" <?php checked( ! empty( $settings['experimental_blocks'] ) ); ?> />
					<?php esc_html_e( 'Show duplicate legacy block names (rsmspark-cw-compat/*) in the block inserter. Legacy blocks always render on the front end.', 'rsm-content-widgets' ); ?>
				</label>
			</td>
		</tr>
		<tr>
			<th scope="row"><?php esc_html_e( 'Legacy shortcode support', 'rsm-content-widgets' ); ?></th>
			<td>
				<label>
					<input type="checkbox" name="rsmspark_content_widgets_legacy_shortcodes" value="1" <?php checked( ! empty( $settings['legacy_shortcode_support'] ) ); ?> />
					<?php esc_html_e( 'Register SiteOrigin-style shortcode tags (hero, features, tabs, …) alongside the rsm_* tags.', 'rsm-content-widgets' ); ?>
				</label>
			</td>
		</tr>
	</table>

	<?php submit_button(); ?>
</form>

<div class="rsm-settings-section" style="margin-top:1.5em;max-width:640px;">
	<h3 class="rsm-settings-section-title"><?php esc_html_e( 'Content Widgets Pro', 'rsm-content-widgets' ); ?></h3>
	<p>
		<?php esc_html_e( 'This free WordPress.org build includes all shipped free widgets and needs no license key. Advanced widgets ship as a separate plugin.', 'rsm-content-widgets' ); ?>
	</p>
	<p>
		<a class="button" href="https://rsmspark.com/pricing/" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'View Pro options', 'rsm-content-widgets' ); ?></a>
		<a class="button button-link" href="https://rsmspark.com/documentation" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Documentation', 'rsm-content-widgets' ); ?></a>
	</p>
</div>

<table class="form-table" role="presentation">
	<tr>
		<th scope="row"><?php esc_html_e( 'Plugin version', 'rsm-content-widgets' ); ?></th>
		<td><code><?php echo esc_html( RSMSPARK_CONTENT_WIDGETS_VERSION ); ?></code></td>
	</tr>
	<tr>
		<th scope="row"><?php esc_html_e( 'Plugin slug', 'rsm-content-widgets' ); ?></th>
		<td><code><?php echo esc_html( RSMSPARK_CONTENT_WIDGETS_SLUG ); ?></code></td>
	</tr>
</table>
