esc_url_raw( rest_url( 'infinibase/v1/ask' ) ), 'nonce' => wp_create_nonce( 'infinibase_ask' ), 'wpRestNonce' => wp_create_nonce( 'wp_rest' ), 'supportUrl' => esc_url_raw( get_option( 'infinibase_support_url', '' ) ), 'i18n' => array( 'emptyError' => __( 'Please enter a question (at least 5 characters).', 'infinibase' ), 'genericError' => __( 'We are unable to process your question at this time.', 'infinibase' ), 'readMore' => __( 'Read more →', 'infinibase' ), 'contactBtn' => __( 'Contact Support →', 'infinibase' ), ), ); } function infinibase_enqueue_frontend_assets() { if ( ! wp_style_is( 'infinibase-style', 'registered' ) ) { infinibase_register_frontend_assets(); } wp_enqueue_style( 'infinibase-style' ); if ( ! wp_script_is( 'infinibase-script', 'enqueued' ) ) { wp_enqueue_script( 'infinibase-script' ); wp_localize_script( 'infinibase-script', 'infinibaseData', infinibase_get_frontend_config() ); } } function infinibase_render_light_shortcode( $atts = array() ) { $atts = is_array( $atts ) ? $atts : array(); $atts['theme'] = 'light'; return infinibase_render_shortcode( $atts ); } function infinibase_render_dark_shortcode( $atts = array() ) { $atts = is_array( $atts ) ? $atts : array(); $atts['theme'] = 'dark'; return infinibase_render_shortcode( $atts ); } function infinibase_render_shortcode( $atts = array() ) { infinibase_enqueue_frontend_assets(); $saved_heading = get_option( 'infinibase_shortcode_heading', 'Questions' ); if ( empty( $saved_heading ) ) { $saved_heading = 'Questions'; } $saved_subtitle = get_option( 'infinibase_shortcode_subtitle', 'The short ones are here. For anything else, ask our AI below.' ); if ( '' === trim( $saved_subtitle ) ) { $saved_subtitle = 'The short ones are here. For anything else, ask our AI below.'; } $atts = shortcode_atts( array( 'theme' => 'light', 'title' => $saved_heading, 'subtitle' => $saved_subtitle, ), $atts, 'infinibase' ); $heading_text = mb_substr( trim( $atts['title'] ), 0, 9 ); if ( '' === $heading_text ) { $heading_text = 'Questions'; } $theme_mode = ( 'dark' === strtolower( $atts['theme'] ) ) ? 'dark' : 'light'; $theme_class = 'infinite-faqs-theme-' . $theme_mode; $config_json = wp_json_encode( infinibase_get_frontend_config() ); $static_faqs = get_option( 'infinibase_static_faqs', array() ); if ( ! is_array( $static_faqs ) ) { $static_faqs = array(); } ob_start(); ?>