Deutsch add_action('rest_api_init', function () { register_rest_route('lucidworks/v1', '/typeahead', [ 'methods' => 'GET', 'callback' => 'lucidworks_typeahead_proxy', 'permission_callback' => '__return_true', ]); }); function lucidworks_typeahead_proxy(WP_REST_Request $request) { $query = sanitize_text_field($request->get_param('q')); $locale = sanitize_text_field($request->get_param('locale')) ?: 'en'; if (!$query) { return new WP_REST_Response([ 'success' => false, 'error' => 'Missing query', ], 400); } $app = 'Lucidworks_com'; $api_key = '5999531c-9bbb-4a62-87a0-c53cfd1892a0'; // ✅ NEW: dedicated typeahead pipelines $pipeline = $locale === 'de' ? 'de_lucidworks_typeahead' : 'en_lucidworks_typeahead'; $base = "https://lw-docs-dev.b.lucidworks.cloud/api/apps/{$app}"; // Backend confirmed this endpoint shape $url = sprintf( '%s/query/%s?q=%s&rows=5', $base, $pipeline, urlencode($query) ); $response = wp_remote_get($url, [ 'headers' => [ 'Content-Type' => 'application/json', 'x-api-key' => $api_key, ], 'timeout' => 10, ]); if (is_wp_error($response)) { return new WP_REST_Response([ 'success' => false, 'error' => $response->get_error_message(), ], 500); } $body = json_decode(wp_remote_retrieve_body($response), true); return new WP_REST_Response([ 'success' => true, 'mode' => 'typeahead', 'query' => $query, 'response' => $body, ], 200); } /** * Add * Version 9: Includes "Unpublished" status check for crawler filtering. */ function lw_add_category_meta_tag() { // 1. GET STATUS & OBJECT ID $current_id = get_queried_object_id(); if ( ! $current_id ) { return; } $status = get_post_status( $current_id ); // 2. UNPUBLISHED CHECK (First priority for crawler filtering) // If the page is not in a 'publish' state, categorize as Unpublished and exit. if ( $status !== 'publish' ) { echo '' . "\n"; return; } // 3. HOMEPAGE CHECK if ( is_front_page() ) { echo '' . "\n"; return; } // 4. MAP TO MASTER (English ID) global $wpdb; $english_id = $current_id; $trid = $wpdb->get_var( $wpdb->prepare( "SELECT trid FROM {$wpdb->prefix}icl_translations WHERE element_id = %d AND element_type LIKE 'post_%%'", $current_id )); if ( $trid ) { $found_en_id = $wpdb->get_var( $wpdb->prepare( "SELECT element_id FROM {$wpdb->prefix}icl_translations WHERE trid = %d AND language_code = 'en'", $trid )); if ( $found_en_id ) { $english_id = $found_en_id; } } // 5. GET ENGLISH PERMALINK if ( has_action('wpml_switch_language') ) { do_action( 'wpml_switch_language', 'en' ); } $url = get_permalink( $english_id ); $path = trim( parse_url( $url, PHP_URL_PATH ), '/' ); if ( has_action('wpml_switch_language') && defined('ICL_LANGUAGE_CODE') ) { do_action( 'wpml_switch_language', ICL_LANGUAGE_CODE ); } // ----------------------------------------------------------- // RULE SET: EXACT MATCHES // ----------------------------------------------------------- $exact_matches = array( 'company' => 'Company', 'company/careers' => 'Careers', 'company/partners' => 'Partners', 'contact' => 'Contact Us', 'demo' => 'Contact Us', 'demo-thanks' => 'Other', 'info' => 'Other', 'privacy-policy' => 'Legal', 'platform' => 'Platform', // Manual Overrides 'unternehmen/karriere' => 'Careers', 'unternehmen/kontakt' => 'Contact Us', // Platform Pages 'platform/data-acquisition' => 'Lucidworks Platform', 'platform/deployment-options' => 'Lucidworks Platform', 'platform/lucidworks-ai' => 'Lucidworks Platform', 'platform/lucidworks-ai/generative-ai' => 'Lucidworks Platform', 'platform/lucidworks-ai/neural-hybrid-search' => 'Lucidworks Platform', 'platform/lucidworks-enterprise-search-software'=> 'Lucidworks Platform', 'platform/signals-beacon' => 'Lucidworks Platform', // Event Pages 'b2b-chicago-2025' => 'Events', 'b2b-chicago-meeting' => 'Events', 'b2b-chicago-meeting-thank-you' => 'Events', 'b2b-connect-san-diego-2025' => 'Events', 'b2b-connect-san-diego-2025-networking-event' => 'Events', 'b2b-connect-san-diego-2025-thank-you' => 'Events', 'coffee-connect-thank-you' => 'Events', 'etail-connect-east-2025-thank-you' => 'Events', 'etail-east-boston-2025-meeting' => 'Events', 'etail-east-boston-2025-meeting-thank-you' => 'Events', 'etail-east-boston-vip-dinner-2025' => 'Events', 'etail-east-boston-vip-dinner-2025-thank-you' => 'Events', 'event-thank-you' => 'Events', 'info-etail-connect-east-2025' => 'Events', 'lucidworks-coffee-connect-2025' => 'Events', 'san-diego-2025-networking-event-thank-you' => 'Events', 'search-as-a-strategy-unlocking-the-power-of-b2b'=> 'Events', 'thank-you' => 'Events', 'thank-you-for-registering-sig' => 'Events', 'lucidworks-special-interest-group-sig-b2c-may-24' => 'Events', 'lucidworks-special-interest-group-sig-km-jun-24' => 'Events', 'lucidworks-special-interest-group-sig-km-june-24' => 'Events', ); // Check Exact Matches if ( isset( $exact_matches[ $path ] ) ) { echo '' . "\n"; return; } // ----------------------------------------------------------- // RULE SET: PARTIAL MATCHES // ----------------------------------------------------------- $category = ''; if ( strpos( $path, 'analyst-reports' ) !== false ) { $category = 'Analyst Report'; } elseif ( strpos( $path, 'blog' ) !== false ) { $category = 'Blog'; } elseif ( strpos( $path, 'case-studies' ) !== false ) { $category = 'Case Studies'; } elseif ( strpos( $path, 'compare' ) !== false ) { $category = 'Competitor Comparisons'; } elseif ( strpos( $path, 'csoplan' ) !== false ) { $category = 'Customer Success Offerings'; } elseif ( strpos( $path, 'customers' ) !== false ) { $category = 'Customer Stories'; } elseif ( strpos( $path, 'ebooks' ) !== false ) { $category = 'Ebooks'; } elseif ( strpos( $path, 'industries' ) !== false ) { $category = 'Industries'; } elseif ( strpos( $path, 'info/' ) !== false ) { $category = 'Events'; } elseif ( strpos( $path, 'legal' ) !== false ) { $category = 'Legal'; } elseif ( strpos( $path, 'news-press' ) !== false ) { $category = 'News & Press'; } elseif ( strpos( $path, 'on-demand-webinars' ) !== false ) { $category = 'Webinars'; } elseif ( strpos( $path, 'platform/ai-agents' ) !== false ) { $category = 'AI Agents'; } elseif ( strpos( $path, 'platform/ai-boosters' ) !== false ) { $category = 'AI Boosters'; } elseif ( strpos( $path, 'platform/ai-modules' ) !== false ) { $category = 'AI Modules'; } elseif ( strpos( $path, 'platform/studios' ) !== false ) { $category = 'Lucidworks Studios'; } elseif ( strpos( $path, 'solutions' ) !== false ) { $category = 'Solutions'; } elseif ( strpos( $path, 'videos' ) !== false ) { $category = 'Videos'; } if ( ! empty( $category ) ) { echo '' . "\n"; } else { echo '' . "\n"; } } add_action( 'wp_head', 'lw_add_category_meta_tag', 1 );