' . esc_html__( 'Term embedding settings saved.', 'ai-search' ) . '

'; } // Confirmation message after bulk regenerate. if ( isset( $_GET['term_embeddings_generated'] ) ) { echo '

' . esc_html__( 'Embeddings generated for selected terms.', 'ai-search' ) . '

'; $processed = get_transient( 'ai_search_processed_term_names' ); if ( $processed && is_array( $processed ) ) { echo '

' . esc_html__( 'Processed terms:', 'ai-search' ) . '

'; delete_transient( 'ai_search_processed_term_names' ); } } $enabled = (bool) get_option( 'ai_search_term_embeddings_enabled', class_exists( 'WooCommerce' ) ); $disabled_taxonomies = (array) get_option( 'ai_search_disabled_taxonomies', [] ); // Discover eligible taxonomies: public ones attached to public post types. $eligible_taxonomies = []; foreach ( get_taxonomies( [ 'public' => true ], 'objects' ) as $tax ) { if ( $tax->name === 'post_format' ) { continue; // not useful for semantic search } $term_count = wp_count_terms( [ 'taxonomy' => $tax->name, 'hide_empty' => false ] ); if ( is_wp_error( $term_count ) ) { $term_count = 0; } $eligible_taxonomies[ $tax->name ] = [ 'label' => $tax->labels->name, 'slug' => $tax->name, 'count' => (int) $term_count, ]; } // Compute status numbers. $total_terms = 0; $indexed_terms = 0; foreach ( $eligible_taxonomies as $slug => $info ) { if ( in_array( $slug, $disabled_taxonomies, true ) ) { continue; } $total_terms += $info['count']; } global $wpdb; $indexed_terms = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->termmeta} WHERE meta_key = %s", '_ai_search_term_embedding' ) ); $pct = $total_terms > 0 ? round( ( $indexed_terms / $total_terms ) * 100 ) : 0; ?>

0 && $indexed_terms < $total_terms ) : ?>

$info ) : $checked = ! in_array( $slug, $disabled_taxonomies, true ); ?>
onchange="aiSearchToggleDisabledTax(this, '')" />