' . esc_html__( 'Reset the page index', 'linkcortex' ) . '';
echo '
' . esc_html__( 'Clears the stored keywords found by AI, the link map and all open suggestions, then you can rebuild the index for free. Applied links stay in your pages and can still be undone. Keywords you typed yourself are kept.', 'linkcortex' ) . '
';
echo '';
if ( ! Settings::get( 'debug_log' ) ) {
return;
}
$entries = array_reverse( Logger::entries() );
echo '' . esc_html__( 'Debug log', 'linkcortex' ) . '
';
if ( ! $entries ) {
echo '' . esc_html__( 'Nothing logged yet.', 'linkcortex' ) . '
';
return;
}
echo '';
foreach ( array_slice( $entries, 0, 100 ) as $e ) {
printf( '| %1$s | %2$s | %3$s |
', esc_html( $e['time'] ), esc_html( $e['message'] ), esc_html( (string) wp_json_encode( $e['context'] ) ) );
}
echo '
';
echo '';
}
/**
* Reset the index (confirmed).
*
* @return void
*/
public static function reset_index() {
global $wpdb;
if ( ! current_user_can( 'manage_options' ) ) {
wp_die( esc_html__( 'You do not have permission to do that.', 'linkcortex' ) );
}
check_admin_referer( 'ailsug_reset_index' );
if ( ! empty( $_POST['confirm'] ) ) {
$t = Activator::tables();
// phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Own tables.
$wpdb->query( $wpdb->prepare( 'DELETE FROM %i', $t['index'] ) );
$wpdb->query( $wpdb->prepare( 'DELETE FROM %i', $t['links'] ) );
$wpdb->query( $wpdb->prepare( "DELETE FROM %i WHERE status IN ('pending','accepted','stale','rejected')", $t['suggestions'] ) );
$wpdb->query( $wpdb->prepare( "DELETE FROM %i WHERE status IN ('pending','paused','budget')", $t['queue'] ) );
// phpcs:enable
add_settings_error( 'ailsug', 'reset', __( 'The index was reset. Use "Update page index" on the Keywords screen to rebuild it (free).', 'linkcortex' ), 'success' );
set_transient( 'settings_errors', get_settings_errors(), 30 );
}
wp_safe_redirect( add_query_arg( 'settings-updated', 'true', Menu::url( 'settings', array( 'tab' => 'advanced' ) ) ) );
exit;
}
/**
* Clear the debug log.
*
* @return void
*/
public static function clear_log() {
if ( ! current_user_can( 'manage_options' ) ) {
wp_die( esc_html__( 'You do not have permission to do that.', 'linkcortex' ) );
}
check_admin_referer( 'ailsug_clear_log' );
Logger::clear();
wp_safe_redirect( Menu::url( 'settings', array( 'tab' => 'advanced' ) ) );
exit;
}
}