' . esc_html__( 'The generation report has expired. Run Generate Embeddings again to see results.', 'ai-search' ) . '
';
} else {
$ok_count = count( $report['ok'] );
$failed_count = count( $report['failed'] );
if ( (int) $report['requested'] === 0 ) {
echo ''
. esc_html__( 'Nothing to do: every published item of the selected type already has an embedding. To regenerate, delete existing embeddings in the Cache & Clean tab first.', 'ai-search' )
. '
';
} else {
$class = $failed_count === 0 ? 'notice-success' : ( $ok_count === 0 ? 'notice-error' : 'notice-warning' );
echo '';
printf(
/* translators: 1: number generated, 2: number failed, 3: number requested */
esc_html__( 'Embedding generation finished: %1$d generated, %2$d failed (of %3$d selected).', 'ai-search' ),
(int) $ok_count,
(int) $failed_count,
(int) $report['requested']
);
echo '';
if ( ! empty( $report['stopped'] ) ) {
echo ' ' . esc_html__( 'Generation was stopped early because the provider returned an error that would repeat for every item. Fix the cause below and run again — items already generated are kept.', 'ai-search' );
}
echo '
';
}
if ( $failed_count > 0 ) {
// Group failures by error code so one root cause reads as one line.
$groups = [];
foreach ( $report['failed'] as $f ) {
$code = isset( $f['code'] ) ? (string) $f['code'] : 'unknown';
if ( ! isset( $groups[ $code ] ) ) {
$groups[ $code ] = [ 'message' => (string) $f['message'], 'titles' => [] ];
}
$groups[ $code ]['titles'][] = (string) $f['title'];
}
echo '' . esc_html__( 'Why items failed:', 'ai-search' ) . '
';
foreach ( $groups as $code => $g ) {
$titles = array_slice( $g['titles'], 0, 5 );
$more = count( $g['titles'] ) - count( $titles );
$summary = implode( ', ', $titles );
if ( $more > 0 ) {
/* translators: %d: number of additional items */
$summary .= ' ' . sprintf( esc_html__( 'and %d more', 'ai-search' ), (int) $more );
}
echo '' . esc_html( $code ) . ' — ' . esc_html( $g['message'] );
echo '
' . esc_html( $summary ) . ' ';
}
echo '
';
echo '
' . esc_html__( 'The same details are written to the PHP error log (wp-content/debug.log when WP_DEBUG_LOG is on).', 'ai-search' ) . '
';
}
if ( $ok_count > 0 ) {
echo '';
/* translators: %d: number of items */
printf( esc_html__( 'Show %d generated items', 'ai-search' ), (int) $ok_count );
echo '
';
foreach ( $report['ok'] as $title ) {
echo '- ' . esc_html( $title ) . '
';
}
echo '
';
}
}
}
?>
true, 'exclude_from_search' => false ], 'objects' );
unset( $ai_status_types['attachment'] );
$ai_status_rows = $wpdb->get_results(
"SELECT p.post_type,
COUNT(*) AS total,
SUM( CASE WHEN pm.post_id IS NULL THEN 0 ELSE 1 END ) AS indexed
FROM {$wpdb->posts} p
LEFT JOIN {$wpdb->postmeta} pm ON pm.post_id = p.ID AND pm.meta_key = '_ai_search_embedding'
WHERE p.post_status = 'publish'
GROUP BY p.post_type",
OBJECT_K
);
$ai_status_pending = 0;
?>
|
|
|
name ] ) ? $ai_status_rows[ $ai_status_type->name ] : null;
$total = $row ? (int) $row->total : 0;
$indexed = $row ? (int) $row->indexed : 0;
$missing = max( 0, $total - $indexed );
$ai_status_pending += $missing;
if ( 0 === $total ) {
continue;
}
?>
| labels->name ); ?> |
|
0 ) {
echo '' . esc_html( number_format_i18n( $missing ) ) . '';
} else {
echo '' . esc_html__( 'Up to date', 'ai-search' ) . '';
}
?> |
0 ) : ?>
' . esc_html( number_format_i18n( $ai_status_pending ) ) . '' );
?>
' . esc_html__( 'Cache & Clean', 'ai-search' ) . ''
);
?>