<?php

$from = [ 20613, 22677 ];
$to = 25691;

$links = [];
foreach ( $from as $from_id ) {
	switch_to_blog( $from_id );
	$from_links = get_bookmarks();

	foreach ( $from_links as $from_link ) {
		$bookmark = get_bookmark( $from_link->link_id, ARRAY_A );

		$cat_names = array_map(
			function( $cat_id ) {
				$cat = get_term( $cat_id, 'link_category' );
				return $cat->name;
			},
			$bookmark['link_category']
		);

		$bookmark['cat_names'] = $cat_names;

		unset( $bookmark['link_id'] );

		$links[] = $bookmark;
	}
	restore_current_blog();
}

switch_to_blog( $to );

foreach ( $links as $link ) {
	$link_id = wp_insert_link( $link );

	if ( ! $link_id ) {
		print_r( $link );
		die;
	}

	wp_set_object_terms( $link_id, $link['cat_names'], 'link_category' );
}

restore_current_blog();
