' . esc_html__( 'Token recovered!', 'ai-search' ) . ' ' . esc_html__( 'A fresh API token was issued for this site. Your existing usage limits and quotas were preserved.', 'ai-search' ) . '
' . esc_html__( 'Token recovery failed.', 'ai-search' ) . ' ' . esc_html__( 'Could not issue a new token. Please try again in a few minutes or contact support.', 'ai-search' ) . '
';
}
// The service returns error: "Invalid token" specifically when the
// token isn't found in its DB (vs. "Origin mismatch" which has its
// own dedicated reconnect flow). Offer one-click recovery only for
// that case so we don't show a misleading button for other errors.
$is_invalid_token = $error_data && isset( $error_data['error'] ) && $error_data['error'] === 'Invalid token';
if ( $is_invalid_token ) {
$recover_url = wp_nonce_url(
admin_url( 'admin-post.php?action=ai_search_recover_token' ),
'ai_search_recover_token'
);
echo '
' . esc_html__( 'Your token is no longer recognized by the service. You can reconnect by issuing a fresh token — your usage limits and quotas will be preserved.', 'ai-search' ) . '
' . esc_html__( 'Not registered.', 'ai-search' ) . ' ' . esc_html__( 'Please save your settings to register with the AI Search Service.', 'ai-search' ) . '
';
}
}
// Subscription panel + activation form moved to a dedicated Upgrade /
// Subscription tab in v1.37.0. Badge visibility + tooltip customisation
// moved to a dedicated Appearance tab in v1.37.0.
// General now hosts only the notices + service status.
// Blocks shipped in 1.33.0 and are entirely opt-in, which means a store
// can update and never discover the headline feature. Announce it once,
// dismissible, and only while it has not been dismissed.
//
// v1.35.0 auto-dismiss: if the site already has an AI Search block
// somewhere (post, page, template, pattern - any post_type with the
// block marker in post_content), the user found the feature on their
// own and the promo card is just noise. Mark it dismissed and never
// render it again. Cheap LIKE query with LIMIT 1, runs once per view.
if ( ! get_option( 'ai_search_blocks_notice_dismissed', false ) ) {
global $wpdb;
$ais_block_used = $wpdb->get_var(
"SELECT 1 FROM {$wpdb->posts}
WHERE post_status IN ( 'publish', 'draft', 'inherit' )
AND ( post_content LIKE '%wp:ai-search/search-box%'
OR post_content LIKE '%wp:ai-search/search-button%' )
LIMIT 1"
);
if ( $ais_block_used ) {
update_option( 'ai_search_blocks_notice_dismissed', true );
}
}
// v1.45.0: Vector format migration card. Only renders when the install is
// on the legacy v1 (JSON postmeta) format AND has at least one post with a
// v1 embedding — i.e. a store that would actually benefit from migrating.
// Hidden after dismiss (30 days) and gone forever once finalize runs.
if ( class_exists( 'AI_Search_Vector_Migration' )
&& AI_Search_Vector_Migration::needs_migration()
&& ! AI_Search_Vector_Migration::is_dismissed() ) :
$vm_progress = AI_Search_Vector_Migration::progress();
$vm_nonce = wp_create_nonce( 'ai_search_vector_migration' );
?>