AI Search: '
. 'the automatic registration with the AI Search Service failed after 3 attempts. '
. 'A firewall, security plugin or network timeout may be blocking the outbound call. '
. 'Try reconnecting manually from General settings.'
. '
';
}
// Clear the retention cron on deactivation; the table and its data stay.
register_deactivation_hook( __FILE__, 'ai_search_deactivate_plugin' );
/**
* Plugin deactivation handler.
*
* @since 1.31.0
*/
function ai_search_deactivate_plugin() {
$timestamp = wp_next_scheduled( 'ai_search_purge_logs' );
if ( $timestamp ) {
wp_unschedule_event( $timestamp, 'ai_search_purge_logs' );
}
}
// Handle activation redirect
add_action( 'admin_init', 'ai_search_activation_redirect' );
/**
* Redirect to setup wizard after plugin activation.
*/
function ai_search_activation_redirect() {
// Check if we should redirect
if ( ! get_transient( 'ai_search_activation_redirect' ) ) {
return;
}
// Delete the transient so we don't redirect again
delete_transient( 'ai_search_activation_redirect' );
// Don't redirect if activating multiple plugins or doing bulk action
if ( isset( $_GET['activate-multi'] ) || ! current_user_can( 'manage_options' ) ) {
return;
}
// Don't redirect if setup was already completed
if ( get_option( 'ai_search_setup_completed', false ) ) {
return;
}
// Redirect to setup wizard
wp_safe_redirect( admin_url( 'admin.php?page=ai-search&setup=wizard' ) );
exit;
}
// Initialize the plugin (skipped during unit tests — the test bootstrap
// wires up its own stubs and instantiates the class without side effects).
if ( ! defined( 'AI_SEARCH_SKIP_BOOTSTRAP' ) ) {
AI_Search::get_instance();
}