label) for the always-on Lite tabs. * * @var array */ private $tabs = []; public function __construct() { $this->tabs = [ 'general' => __( 'General', 'ai-explainer-pro' ), 'badges' => __( 'Badges', 'ai-explainer-pro' ), 'authenticity' => __( 'Public Page & Widget', 'ai-explainer-pro' ), 'defense' => __( 'AI Scraper Defense', 'ai-explainer-pro' ), ]; } public function render() { $this->handle_save(); // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only tab navigation, no state change. $current_tab = isset( $_GET['tab'] ) ? sanitize_key( wp_unslash( $_GET['tab'] ) ) : 'general'; if ( ! array_key_exists( $current_tab, $this->tabs ) ) { $current_tab = 'general'; } ?>

tabs as $slug => $label ) : ?>
render_general_tab(); break; case 'badges': $this->render_badges_tab(); break; case 'defense': $this->render_defense_tab(); break; case 'authenticity': if ( class_exists( 'AIEP_Authenticity' ) ) { AIEP_Authenticity::render_settings_tab(); } break; } ?>

[ 'ai_explainer_pro_show_on_posts', 'ai_explainer_pro_show_on_pages', 'ai_explainer_pro_show_on_home', 'ai_explainer_pro_show_on_archive', ], 'badges' => [ 'ai_explainer_pro_show_human_badge', 'ai_explainer_pro_show_ai_badge', ], 'defense' => [ 'aiep_scraper_defense_enabled', ], 'authenticity' => [ 'aiep_authenticity_enabled', ], ]; if ( isset( $tab_booleans[ $active ] ) ) { foreach ( $tab_booleans[ $active ] as $key ) { update_option( $key, isset( $_POST[ $key ] ) ? 1 : 0 ); } } $text_fields = [ 'ai_explainer_pro_badge_position' => 'sanitize_key', 'ai_explainer_pro_detection_threshold' => 'floatval', 'ai_explainer_pro_badge_template' => 'sanitize_key', ]; foreach ( $text_fields as $key => $sanitize ) { if ( isset( $_POST[ $key ] ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Wrapped in sanitize_text_field, then re-sanitized by the per-key callback ($sanitize is sanitize_key or floatval). update_option( $key, call_user_func( $sanitize, sanitize_text_field( wp_unslash( $_POST[ $key ] ) ) ) ); } } // Public authenticity page + widget (Lite + Pro). Special-cased // here because we need to know the previous value to decide // whether to flush rewrite rules. if ( 'authenticity' === $active ) { $auth_was = (int) get_option( 'aiep_authenticity_enabled', 1 ); $auth_now = isset( $_POST['aiep_authenticity_enabled'] ) ? 1 : 0; update_option( 'aiep_authenticity_enabled', $auth_now ); $slug_changed = false; if ( isset( $_POST['aiep_authenticity_slug'] ) ) { $new_slug = sanitize_title( wp_unslash( $_POST['aiep_authenticity_slug'] ) ); $old_slug = get_option( 'aiep_authenticity_slug' ); if ( $new_slug && $new_slug !== $old_slug ) { update_option( 'aiep_authenticity_slug', $new_slug ); $slug_changed = true; } } // Flush rewrite rules whenever the toggle or the slug changes, // otherwise the /authenticity URL returns 404 until the user // manually re-saves Settings → Permalinks. if ( ( $auth_was !== $auth_now || $slug_changed ) && class_exists( 'AIEP_Authenticity' ) ) { AIEP_Authenticity::flush_rules(); } } echo '

' . esc_html__( 'Settings saved.', 'ai-explainer-pro' ) . '

'; } private function render_general_tab() { ?>

__( 'Single Posts', 'ai-explainer-pro' ), 'ai_explainer_pro_show_on_pages' => __( 'Pages', 'ai-explainer-pro' ), 'ai_explainer_pro_show_on_home' => __( 'Homepage / Blog', 'ai-explainer-pro' ), 'ai_explainer_pro_show_on_archive' => __( 'Archives / Categories', 'ai-explainer-pro' ), ]; foreach ( $display_options as $key => $label ) : $checked = get_option( $key, ( 'ai_explainer_pro_show_on_posts' === $key ) ? 1 : 0 ); ?>

$on_posts ? __( 'Single Posts', 'ai-explainer-pro' ) : '', 'page' => $on_pages ? __( 'Pages', 'ai-explainer-pro' ) : '', 'home' => $on_home ? __( 'Homepage / Blog', 'ai-explainer-pro' ) : '', 'archive' => $on_archive ? __( 'Archives / Categories', 'ai-explainer-pro' ) : '', ] ); ?>

' . esc_html__( 'none — open the General tab and tick at least one box', 'ai-explainer-pro' ) . ''; } else { echo esc_html( implode( ', ', $enabled_targets ) ); } ?>

:

✓

⚠

🤖

$count ) : ?>

render_htaccess_block( $htaccess ); ?>