<?php
/**
 * Button to import a single deployment item.
 *
 * @package EaLab\WP_Deployer
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Button to import a single deployment item.
 *
 * @param string $item_full_uuid The full UUID of the deployment item.
 * @param array  $context The build context.
 *
 * @return string Markup.
 */
function deploy_sync_content__deployment_item__single_import_button( string $item_full_uuid, array $context ): string {
	$button_label = esc_html__( 'Import item', 'deploy-sync-content' );

	// TODO: nonce?
	$link_to_merge = add_query_arg(
		array(
			'action'          => 'handle_import',
			'deploydate'      => $context['bundle_id'] ?? 'unknown_bundle',
			'tab'             => 'import',
			'optionstodeploy' => array( rawurlencode( $item_full_uuid ) ),
		),
		admin_url( DEPLOY_SYNC_CONTENT__BASIC_URI )
	);

	return '<a href="' . esc_attr( $link_to_merge ) . '" class="btn btn-primary">' . $button_label . '</a>';
}
