<?php

/**
 * Handles all customizations for the opt-in modal.
 *
 * @since 2.0.0
 */

namespace SolidWP\Mail\Telemetry;

class Modal {

	/**
	 * Customizes the optin_args
	 *
	 * @since 2.0.0
	 *
	 * @param array  $args         The arguments used to render the modal.
	 * @param string $nexcess_slug The Nexcess slug of the plugin displaying the modal.
	 *
	 * @return array<string, mixed>
	 */
	public function optin_args( array $args, string $nexcess_slug ): array {
		if ( $nexcess_slug !== 'solid-mail' ) {
			return $args;
		}

		$args['plugin_logo']        = WPSMTP_ASSETS_URL . 'images/solid-mail-logo.svg';
		$args['plugin_logo_width']  = 233;
		$args['plugin_logo_height'] = 48;
		$args['permissions_url']    = 'https://go.solidwp.com/solid-mail-opt-in-usage-sharing';
		$args['tos_url']            = 'https://go.solidwp.com/solid-mail-terms-usage-modal';
		$args['privacy_url']        = 'https://go.solidwp.com/solid-mail-privacy-usage-modal';
		$args['plugin_logo_alt']    = esc_attr__( 'Kadence Mail Logo', 'wp-smtp' );
		$args['plugin_name']        = esc_html__( 'Kadence Mail', 'wp-smtp' );

		$args['heading'] = sprintf(
			// Translators: The plugin name.
			esc_html__( 'We hope you love %s.', 'wp-smtp' ),
			$args['plugin_name']
		);

		$args['intro'] = $this->get_intro( $args['user_name'] );

		return $args;
	}

	/**
	 * Provides the intro text with the current users's display name inserted.
	 *
	 * @param string $user_name The user to which the modal is shown.
	 *
	 * @return string
	 */
	public function get_intro( string $user_name ): string {
		return esc_html__( 'Want to help shape the future of Kadence Mail? Opting in shares anonymous usage data with our team at Liquid Web, the company behind Kadence Mail, so we can keep building tools that work better for you. You\'ll also receive product updates and important announcements via email—unsubscribe any time. Click \'Allow & Continue\' below to join us.', 'wp-smtp' );
	}
}
