'sanitize_text_field', 'default' => '', ] ); register_setting( 'aisp_global_settings', 'aisp_autocomplete_here_limit', [ 'sanitize_callback' => 'absint', 'default' => 5, ] ); } /** * Enqueue admin JS and CSS. * Uses WordPress AJAX endpoint — key is never sent to the browser directly. */ public function enqueue_admin_scripts( $hook ) { if ( 'toplevel_page_aisp-autocomplete' !== $hook ) { return; } wp_enqueue_style( 'aisp-admin-style', plugin_dir_url( AISP_SMART_AUTOCOMPLETE_ADDRESS_FILE ) . 'assets/css/admin.css', [], AISP_SMART_AUTOCOMPLETE_ADDRESS_VERSION ); wp_enqueue_script( 'aisp-check-key', plugin_dir_url( AISP_SMART_AUTOCOMPLETE_ADDRESS_FILE ) . 'assets/js/admin-check-key.js', [ 'jquery' ], AISP_SMART_AUTOCOMPLETE_ADDRESS_VERSION, true ); wp_localize_script( 'aisp-check-key', 'aispCheckKey', [ 'ajaxUrl' => admin_url( 'admin-ajax.php' ), 'action' => 'aisp_check_api_key', 'nonce' => wp_create_nonce( 'aisp_check_api_key' ), 'checking' => __( 'Checking…', 'aisp-smart-autocomplete-address' ), 'empty' => __( 'Please enter an API key first.', 'aisp-smart-autocomplete-address' ), 'error' => __( 'Network error while checking key.', 'aisp-smart-autocomplete-address' ), ] ); } /** Render settings page with tabs. */ public function render_settings_page() { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- safe read for tab navigation. $active_tab = isset( $_GET['tab'] ) ? sanitize_key( $_GET['tab'] ) : 'settings'; echo '
'; echo '

' . esc_html__( 'Smart Autocomplete Address', 'aisp-smart-autocomplete-address' ) . '

'; echo ''; switch ( $active_tab ) { case 'settings': $this->render_global_tab(); break; case 'custom-field': if ( class_exists( 'AISP_Autocomplete_Custom_Field_Integration' ) ) { AISP_Autocomplete_Custom_Field_Integration::render_settings_tab(); } break; case 'woocommerce': if ( class_exists( 'AISP_Autocomplete_WC_Integration' ) ) { AISP_Autocomplete_WC_Integration::render_woocommerce_tab(); } break; case 'fluent-forms': if ( class_exists( 'AISP_Autocomplete_Fluent_Forms_Integration' ) ) { AISP_Autocomplete_Fluent_Forms_Integration::render_settings_tab(); } break; case 'sureforms': if ( class_exists( 'AISP_Autocomplete_SureForms_Integration' ) ) { AISP_Autocomplete_SureForms_Integration::render_settings_tab(); } break; case 'contact-form-7': if ( class_exists( 'AISP_Autocomplete_CF7_Integration' ) ) { AISP_Autocomplete_CF7_Integration::render_settings_tab(); } break; case 'wpforms': if ( class_exists( 'AISP_Autocomplete_WPForms_Integration' ) ) { AISP_Autocomplete_WPForms_Integration::render_settings_tab(); } break; case 'help': $this->render_help_tab(); break; default: $this->render_global_tab(); break; } echo '
'; } /** Render a nav tab link. */ private function render_tab_link( $slug, $label, $active_tab ) { $url = esc_url( add_query_arg( 'tab', $slug ) ); $active = $active_tab === $slug ? 'nav-tab-active' : ''; return sprintf( '%3$s', $url, esc_attr( $active ), esc_html( $label ) ); } /** Render a conditional tab (dimmed if required plugin not active). */ private function render_conditional_tab( $class, $slug, $label, $active_tab, $req = '' ) { if ( class_exists( $class ) ) { printf( '%3$s', esc_url( add_query_arg( 'tab', $slug ) ), esc_attr( $active_tab === $slug ? 'nav-tab-active' : '' ), esc_html( $label ) ); } else { echo '' . esc_html( $label ); if ( $req ) { echo ' (' . esc_html( $req ) . ')'; } echo ''; } } /** Render global settings tab. */ private function render_global_tab() { ?>

tags linking to the HERE Developer Portal. */ __( 'Enter your HERE API key. Get it from the %1$sHERE Developer Portal%2$s.', 'aisp-smart-autocomplete-address' ), [ 'a' => [ 'href' => [], 'target' => [], 'rel' => [] ] ] ), '', '' ); ?>

  1. [ 'href' => [], 'target' => [], 'rel' => [] ] ] ), '', '' ); ?>

  2. https://yoursite.com
    https://www.yoursite.com

, %2$s closes it. */ __( 'The free plan includes %1$s1,000 autocomplete requests per day%2$s — enough for most small to medium WooCommerce stores.', 'aisp-smart-autocomplete-address' ), [ 'strong' => [] ] ), '', '' ); ?>