<?php
/**
 * Provide a dashboard view for the plugin
 *
 * This file is used to markup the admin dashboard of the plugin.
 *
 * @link       https://cdgraham.com
 * @since      1.1.1
 *
 * @package    Card_Oracle
 * @subpackage Card_Oracle/admin/partials
 */

if ( 'dashboard' === $active_tab ) :
	$is_premium = isset( $card_oracle_is_premium ) ? (bool) $card_oracle_is_premium : card_oracle_fs()->can_use_premium_code__premium_only();
	$upgrade_url = isset( $card_oracle_upgrade_url ) ? $card_oracle_upgrade_url : card_oracle_fs()->get_upgrade_url();
	$dashboard_version = defined( 'CARD_ORACLE_VERSION' ) ? CARD_ORACLE_VERSION : '';
	$wizard_url        = admin_url( 'admin.php?page=card-oracle-admin-menu&tab=wizard' );

	$shortcodes = array(
		array(
			'code'  => 'card-oracle id=',
			'label' => __( 'Reading Shortcode', 'card-oracle' ),
		),
		array(
			'code'  => 'card-oracle-daily id=',
			'label' => __( 'Daily Card Shortcode', 'card-oracle' ),
		),
		array(
			'code'  => 'card-oracle-random id=',
			'label' => __( 'Random Card Shortcode', 'card-oracle' ),
		),
	);

	if ( $is_premium ) {
		// Push premium fields on to fields array.
		$premium_shortcodes = array(
			array(
				'code'  => get_site_url() . '/feed/tco/?reading=',
				'label' => __( 'RSS Link', 'card-oracle' ),
			),
		);

		$shortcodes = array_merge( $shortcodes, $premium_shortcodes );
	}

	$system_status_items = isset( $card_oracle_system_status ) ? $card_oracle_system_status : array();
	$tile_cards           = array(
		array(
			'label'       => __( 'Readings', 'card-oracle' ),
			'description' => __( 'Organise spreads and layouts.', 'card-oracle' ),
			'value'       => $readings_text,
			'url'         => admin_url( 'edit.php?post_type=co_readings' ),
			'icon'        => 'dashicons-welcome-view-site',
		),
		array(
			'label'       => __( 'Positions', 'card-oracle' ),
			'description' => __( 'Fine-tune card placement.', 'card-oracle' ),
			'value'       => $positions_text,
			'url'         => admin_url( 'edit.php?post_type=co_positions' ),
			'icon'        => 'dashicons-editor-ol',
		),
		array(
			'label'       => __( 'Cards', 'card-oracle' ),
			'description' => __( 'Maintain your tarot library.', 'card-oracle' ),
			'value'       => $cards_text,
			'url'         => admin_url( 'edit.php?post_type=co_cards' ),
			'icon'        => 'dashicons-admin-page',
		),
		array(
			'label'       => __( 'Descriptions', 'card-oracle' ),
			'description' => __( 'Craft copy for every draw.', 'card-oracle' ),
			'value'       => $descriptions_text,
			'url'         => admin_url( 'edit.php?post_type=co_descriptions' ),
			'icon'        => 'dashicons-media-text',
		),
	);
	$random_days_option = get_option( CARD_ORACLE_RANDOM_DAYS );
	$random_days        = is_numeric( $random_days_option ) ? absint( $random_days_option ) : 0;
	$random_label       = 0 === $random_days
		? __( 'Resets every 10 minutes', 'card-oracle' )
		: sprintf( __( 'Resets every %d days', 'card-oracle' ), $random_days );

	$powered_by_enabled = 'yes' === get_option( 'card_oracle_powered_by', 'yes' );
	$email_enabled      = 'yes' === get_option( 'card_oracle_allow_email', 'yes' );

	$general_metrics    = array(
		array(
			'label' => __( 'Random card rotation', 'card-oracle' ),
			'value' => $random_label,
			'url'   => admin_url( 'admin.php?page=card-oracle-admin-menu&tab=general' ),
		),
		array(
			'label' => __( 'Powered by footer', 'card-oracle' ),
			'value' => $powered_by_enabled ? __( 'Enabled', 'card-oracle' ) : __( 'Disabled', 'card-oracle' ),
			'url'   => admin_url( 'admin.php?page=card-oracle-admin-menu&tab=general' ),
		),
		array(
			'label' => __( 'Allow User Emails', 'card-oracle' ),
			'value' => $email_enabled ? __( 'Allowed', 'card-oracle' ) : __( 'Disabled', 'card-oracle' ),
			'url'   => admin_url( 'admin.php?page=card-oracle-admin-menu&tab=email' ),
		),
	);

	if ( $is_premium ) {
		// Email metrics.
		$from_address = get_option( 'card_oracle_from_email', get_option( 'admin_email' ) );
		$from_name    = get_option( 'card_oracle_from_email_name', get_bloginfo( 'name' ) );

		$general_metrics[] = array(
			'label' => __( 'Email sender address', 'card-oracle' ),
			'value' => $from_address ? $from_address : __( 'Using admin email', 'card-oracle' ),
			'url'   => admin_url( 'admin.php?page=card-oracle-admin-menu&tab=email' ),
		);

		$general_metrics[] = array(
			'label' => __( 'Email sender name', 'card-oracle' ),
			'value' => $from_name ? $from_name : __( 'Using site title', 'card-oracle' ),
			'url'   => admin_url( 'admin.php?page=card-oracle-admin-menu&tab=email' ),
		);

		// Payment metrics.
		$provider_slug = get_option( 'card_oracle_payment_provider', '' );
		if ( $provider_slug ) {
			$provider_map = array(
				'paypal' => __( 'PayPal', 'card-oracle' ),
				'stripe' => __( 'Stripe', 'card-oracle' ),
			);
			$provider_label = isset( $provider_map[ $provider_slug ] ) ? $provider_map[ $provider_slug ] : ucwords( str_replace( '_', ' ', $provider_slug ) );
			$general_metrics[] = array(
				'label' => __( 'Payment provider', 'card-oracle' ),
				'value' => $provider_label,
				'url'   => admin_url( 'admin.php?page=card-oracle-admin-menu&tab=payments' ),
			);

			if ( 'stripe' === $provider_slug ) {
				$stripe_mode = 'yes' === get_option( 'card_oracle_stripe_sandbox', 'no' )
					? __( 'Stripe test mode', 'card-oracle' )
					: __( 'Stripe live mode', 'card-oracle' );
				$general_metrics[] = array(
					'label' => __( 'Stripe environment', 'card-oracle' ),
					'value' => $stripe_mode,
					'url'   => admin_url( 'admin.php?page=card-oracle-admin-menu&tab=payments' ),
				);
			}
		}

		// Integration metrics.
		$integration_slug = card_oracle_normalize_integration_slug( get_option( 'card_oracle_integration', '' ) );
		if ( $integration_slug ) {
			$integration_label = ucwords( str_replace( '_', ' ', str_replace( '_api', '', $integration_slug ) ) );
			$general_metrics[] = array(
				'label' => __( 'Integration', 'card-oracle' ),
				'value' => $integration_label,
				'url'   => admin_url( 'admin.php?page=card-oracle-admin-menu&tab=integrations' ),
			);

			$integration_status = __( 'Credentials required', 'card-oracle' );
			if ( in_array( $integration_slug, array( 'mailchimp_api', 'mailchimp' ), true ) && get_option( 'card_oracle_mailchimp_api_key' ) ) {
				$integration_status = __( 'Mailchimp API key added', 'card-oracle' );
			} elseif ( in_array( $integration_slug, array( 'activecampaign_api', 'activecampaign' ), true ) && get_option( 'card_oracle_activecampaign_api_key' ) ) {
				$integration_status = __( 'ActiveCampaign API key added', 'card-oracle' );
			} elseif ( in_array( $integration_slug, array( 'brevo_api', 'brevo' ), true ) && card_oracle_get_brevo_option( 'card_oracle_brevo_api_key' ) ) {
				$integration_status = __( 'Brevo API key added', 'card-oracle' );
			} elseif ( in_array( $integration_slug, array( 'thenewsletter_api', 'thenewsletter' ), true ) ) {
				$integration_status = __( 'Using The Newsletter Plugin', 'card-oracle' );
			}

			$general_metrics[] = array(
				'label' => __( 'Integration status', 'card-oracle' ),
				'value' => $integration_status,
				'url'   => admin_url( 'admin.php?page=card-oracle-admin-menu&tab=integrations' ),
			);
		}
	}

	$quick_links          = array(
		array(
			'label'       => __( 'Launch Setup Wizard', 'card-oracle' ),
			'description' => __( 'Guided steps to create your first reading.', 'card-oracle' ),
			'url'         => $wizard_url,
			'icon'        => 'dashicons-admin-tools',
		),
		array(
			'label'       => __( 'Add New Reading', 'card-oracle' ),
			'description' => __( 'Start a fresh spread with custom positions.', 'card-oracle' ),
			'url'         => admin_url( 'post-new.php?post_type=co_readings' ),
			'icon'        => 'dashicons-plus-alt',
		),
		array(
			'label'       => __( 'Create Card', 'card-oracle' ),
			'description' => __( 'Expand your deck with more archetypes.', 'card-oracle' ),
			'url'         => admin_url( 'post-new.php?post_type=co_cards' ),
			'icon'        => 'dashicons-images-alt2',
		),
		array(
			'label'       => __( 'Check Configuration Status', 'card-oracle' ),
			'description' => __( 'Review key settings before publishing.', 'card-oracle' ),
			'url'         => admin_url( 'admin.php?page=card-oracle-admin-menu&tab=status' ),
			'icon'        => 'dashicons-visibility',
		),
	);
	?>
	<div id="co_dashboard" class="co-dashboard">
		<header class="co-dashboard__hero">
			<div class="co-dashboard__hero-text">
				<?php if ( ! empty( $dashboard_version ) ) : ?>
					<span class="co-dashboard__badge"><?php printf( esc_html__( 'Version %s', 'card-oracle' ), esc_html( $dashboard_version ) ); ?></span>
				<?php endif; ?>
				<h1 class="co-dashboard__hero-title"><?php esc_html_e( 'Welcome to your Card Oracle workspace', 'card-oracle' ); ?></h1>
				<p class="co-dashboard__hero-description">
					<?php esc_html_e( 'Launch new readings, manage your decks, and keep visitors engaged from a single, streamlined hub.', 'card-oracle' ); ?>
				</p>
				<div class="co-dashboard__hero-actions">
					<a class="button button-primary button-hero" href="<?php echo esc_url( $wizard_url ); ?>">
						<?php esc_html_e( 'Launch Setup Wizard', 'card-oracle' ); ?>
					</a>
					<a class="button button-secondary" href="<?php echo esc_url( admin_url( 'edit.php?post_type=co_readings' ) ); ?>">
						<?php esc_html_e( 'View All Readings', 'card-oracle' ); ?>
					</a>
				</div>
			</div>
			<div class="co-dashboard__hero-metrics">
				<?php foreach ( $tile_cards as $metric ) : ?>
					<div class="co-dashboard__metric">
						<span class="co-dashboard__metric-label"><?php echo esc_html( $metric['label'] ); ?></span>
						<strong class="co-dashboard__metric-value"><?php echo esc_html( $metric['value'] ); ?></strong>
					</div>
				<?php endforeach; ?>
			</div>
		</header>

		<div class="co-dashboard__layout">
			<div class="co-dashboard__primary">
				<?php if ( isset( $card_oracle_onboarding_show ) && $card_oracle_onboarding_show && ! empty( $card_oracle_onboarding_tasks ) ) : ?>
				<section class="co-dashboard__section">
					<div class="card-oracle-card card-oracle-card--onboarding">
						<div class="card-oracle-card-header card-oracle-onboarding-header">
							<?php esc_html_e( 'Getting Started', 'card-oracle' ); ?>
							<form method="post" class="card-oracle-onboarding-dismiss">
								<?php wp_nonce_field( 'card_oracle_onboarding' ); ?>
								<input type="hidden" name="card_oracle_onboarding_action" value="dismiss" />
								<button type="submit" class="button button-link card-oracle-onboarding-dismiss__button">
									<?php esc_html_e( 'Dismiss checklist', 'card-oracle' ); ?>
								</button>
							</form>
						</div>
						<div class="card-oracle-card-body card-oracle-card-body--column card-oracle-onboarding-body">
							<p class="card-oracle-onboarding-progress">
								<?php
								printf(
									esc_html__( '%1$d of %2$d tasks complete', 'card-oracle' ),
									intval( $card_oracle_onboarding_completed_count ),
									intval( $card_oracle_onboarding_total )
								);
								?>
							</p>
							<ul class="card-oracle-onboarding-list">
								<?php foreach ( $card_oracle_onboarding_tasks as $task ) : ?>
									<?php
									$class_names = array( 'card-oracle-onboarding-task' );
									if ( ! empty( $task['completed'] ) ) {
										$class_names[] = 'card-oracle-onboarding-task--complete';
									}
									?>
								<li class="<?php echo esc_attr( implode( ' ', $class_names ) ); ?>">
									<span class="card-oracle-onboarding-task__status dashicons <?php echo ! empty( $task['completed'] ) ? 'dashicons-yes card-oracle-onboarding-task__status--complete' : 'dashicons-editor-help'; ?>" aria-hidden="true"></span>
									<div class="card-oracle-onboarding-task__content">
										<span class="card-oracle-onboarding-task__label"><?php echo esc_html( $task['label'] ); ?></span>
										<span class="card-oracle-onboarding-task__description"><?php echo esc_html( $task['description'] ); ?></span>
									</div>
									<?php if ( empty( $task['completed'] ) && ! empty( $task['cta_url'] ) ) : ?>
										<a class="button button-secondary card-oracle-onboarding-task__action" href="<?php echo esc_url( $task['cta_url'] ); ?>"><?php echo esc_html( $task['cta_label'] ); ?></a>
									<?php endif; ?>
								</li>
								<?php endforeach; ?>
							</ul>
						</div>
					</div>
				</section>
				<?php elseif ( isset( $card_oracle_onboarding_dismissed, $card_oracle_onboarding_total, $card_oracle_onboarding_completed_count ) && $card_oracle_onboarding_dismissed && $card_oracle_onboarding_completed_count < $card_oracle_onboarding_total ) : ?>
				<section class="co-dashboard__section">
					<div class="card-oracle-card card-oracle-card--onboarding-dismissed">
						<div class="card-oracle-card-body card-oracle-card-body--row card-oracle-onboarding-dismissed">
							<span class="dashicons dashicons-yes"></span>
							<p><?php esc_html_e( 'You dismissed the getting started checklist.', 'card-oracle' ); ?></p>
							<form method="post">
								<?php wp_nonce_field( 'card_oracle_onboarding' ); ?>
								<input type="hidden" name="card_oracle_onboarding_action" value="restore" />
								<button type="submit" class="button button-link">
									<?php esc_html_e( 'Restore checklist', 'card-oracle' ); ?>
								</button>
							</form>
						</div>
					</div>
				</section>
				<?php endif; ?>

				<section class="co-dashboard__section">
					<div class="co-dashboard__section-heading">
						<h2><?php esc_html_e( 'Content overview', 'card-oracle' ); ?></h2>
						<p><?php esc_html_e( 'Quick glance at the assets that power your readings.', 'card-oracle' ); ?></p>
					</div>
					<div class="co-dashboard__tile-grid">
						<?php foreach ( $tile_cards as $tile ) : ?>
							<a class="co-dashboard-tile" href="<?php echo esc_url( $tile['url'] ); ?>">
								<span class="co-dashboard-tile__icon dashicons <?php echo esc_attr( $tile['icon'] ); ?>" aria-hidden="true"></span>
								<span class="co-dashboard-tile__label"><?php echo esc_html( $tile['label'] ); ?></span>
								<strong class="co-dashboard-tile__value"><?php echo esc_html( $tile['value'] ); ?></strong>
								<span class="co-dashboard-tile__description"><?php echo esc_html( $tile['description'] ); ?></span>
							</a>
						<?php endforeach; ?>
					</div>
				</section>

				<?php if ( ! $is_premium ) : ?>
				<section class="co-dashboard__section">
					<div class="card-oracle-card card-oracle-card--premium-callout">
						<div class="card-oracle-card-header">
							<?php esc_html_e( 'Unlock Premium Features', 'card-oracle' ); ?>
							<span class="card-oracle-premium-badge"><?php esc_html_e( 'Premium', 'card-oracle' ); ?></span>
						</div>
						<div class="card-oracle-card-body card-oracle-card-body--column">
							<p class="card-oracle-premium-summary"><?php esc_html_e( 'Upgrade to Card Oracle Premium to access automation, integrations, and advanced delivery options.', 'card-oracle' ); ?></p>
							<ul class="card-oracle-status-list card-oracle-premium-list">
								<li><?php esc_html_e( 'Automated email delivery for readings', 'card-oracle' ); ?></li>
								<li><?php esc_html_e( 'Mailchimp, ActiveCampaign, Brevo integrations', 'card-oracle' ); ?></li>
								<li><?php esc_html_e( 'Premium payment providers and RSS syndication', 'card-oracle' ); ?></li>
							</ul>
							<div class="card-oracle-status-actions">
								<a class="button button-primary" href="<?php echo esc_url( $upgrade_url ); ?>" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'See Premium Plans', 'card-oracle' ); ?></a>
							</div>
						</div>
					</div>
				</section>
				<?php endif; ?>

				<?php if ( ! empty( $system_status_items ) ) : ?>
				<section class="co-dashboard__section">
					<div class="card-oracle-card">
						<div class="card-oracle-card-header">
							<?php esc_html_e( 'Configuration Status', 'card-oracle' ); ?>
						</div>
						<div class="card-oracle-card-body card-oracle-card-body--column">
							<ul class="card-oracle-status-list">
								<?php foreach ( $system_status_items as $item ) : ?>
								<li>
									<span class="card-oracle-status-label"><?php echo esc_html( $item['label'] ); ?>:</span>
									<span class="card-oracle-status-value"><?php echo esc_html( $item['value'] ); ?></span>
								</li>
								<?php endforeach; ?>
							</ul>
							<div class="card-oracle-status-actions">
								<a class="button button-secondary" href="<?php echo esc_url( admin_url( 'admin.php?page=card-oracle-admin-menu&tab=general' ) ); ?>"><?php esc_html_e( 'View Settings', 'card-oracle' ); ?></a>
							</div>
						</div>
					</div>
				</section>
				<?php endif; ?>
			</div>

			<aside class="co-dashboard__aside">
				<section class="co-dashboard__section co-dashboard__section--panel">
					<div class="co-dashboard__section-heading">
						<h2><?php esc_html_e( 'Quick actions', 'card-oracle' ); ?></h2>
						<p><?php esc_html_e( 'Jump straight into the workflows you use most often.', 'card-oracle' ); ?></p>
					</div>
					<ul class="co-dashboard__link-list">
						<?php foreach ( $quick_links as $link ) : ?>
							<li class="co-dashboard__link-item">
								<span class="dashicons <?php echo esc_attr( $link['icon'] ); ?>" aria-hidden="true"></span>
								<div class="co-dashboard__link-content">
									<a href="<?php echo esc_url( $link['url'] ); ?>"><?php echo esc_html( $link['label'] ); ?></a>
									<p><?php echo esc_html( $link['description'] ); ?></p>
								</div>
							</li>
						<?php endforeach; ?>
					</ul>
				</section>

				<section class="co-dashboard__section co-dashboard__section--panel">
					<div class="co-dashboard__section-heading">
						<h2><?php esc_html_e( 'Need a hand?', 'card-oracle' ); ?></h2>
						<p><?php esc_html_e( 'Review diagnostics or reach out when you need support.', 'card-oracle' ); ?></p>
					</div>
					<div class="co-dashboard__support-actions">
						<a class="button button-secondary" href="<?php echo esc_url( admin_url( 'admin.php?page=card-oracle-admin-menu&tab=status' ) ); ?>">
							<?php esc_html_e( 'Open Status Report', 'card-oracle' ); ?>
						</a>
						<a class="button button-link" href="mailto:support@chillichalli.com">
							<?php esc_html_e( 'Email Support', 'card-oracle' ); ?>
						</a>
					</div>
				</section>
			</aside>
	</div>

		<?php if ( ! empty( $general_metrics ) ) : ?>
		<section class="co-dashboard__section co-dashboard__section--panel">
			<div class="co-dashboard__section-heading">
				<h2><?php esc_html_e( 'General settings at a glance', 'card-oracle' ); ?></h2>
				<p><?php esc_html_e( 'Review key behaviour and premium settings without leaving the dashboard.', 'card-oracle' ); ?></p>
			</div>
			<div class="co-dashboard__tile-grid co-dashboard__tile-grid--readings">
				<?php foreach ( $general_metrics as $metric ) : ?>
					<?php
					// Determine link text based on the tab in the URL
					$link_text = __( 'Adjust in Settings', 'card-oracle' );
					if ( isset( $metric['url'] ) ) {
						if ( strpos( $metric['url'], 'tab=general' ) !== false ) {
							$link_text = __( 'Adjust in General Settings', 'card-oracle' );
						} elseif ( strpos( $metric['url'], 'tab=email' ) !== false ) {
							$link_text = __( 'Adjust in Email Settings', 'card-oracle' );
						} elseif ( strpos( $metric['url'], 'tab=payments' ) !== false ) {
							$link_text = __( 'Adjust in Payment Settings', 'card-oracle' );
						} elseif ( strpos( $metric['url'], 'tab=integrations' ) !== false ) {
							$link_text = __( 'Adjust in Integration Settings', 'card-oracle' );
						}
					}
					?>
					<div class="co-dashboard-tile co-dashboard-tile--reading">
						<div class="co-dashboard-tile__label"><?php echo esc_html( $metric['label'] ); ?></div>
						<div class="co-dashboard-tile__value"><?php echo esc_html( $metric['value'] ); ?></div>
						<?php if ( isset( $metric['url'] ) ) : ?>
							<div class="co-dashboard-tile__description co-dashboard-tile__description--reading">
								<a class="button button-link" href="<?php echo esc_url( $metric['url'] ); ?>">
									<?php echo esc_html( $link_text ); ?>
								</a>
							</div>
						<?php endif; ?>
					</div>
				<?php endforeach; ?>
			</div>
		</section>
		<?php endif; ?>

		<?php $reading_count = count( $readings ); ?>
		<?php if ( 0 < $reading_count ) : ?>
		<section class="co-dashboard__section">
			<header class="card-oracle-dashboard">
				<span class="dashicons dashicons-chart-bar" aria-hidden="true"></span>
				<h2><?php esc_html_e( 'Reading Statistics', 'card-oracle' ); ?></h2>
			</header>
			<div class="card-oracle-stats"> <!-- Statistics for each Reading -->
			<?php
				for ( $i = 0; $i < $reading_count; $i++ ) { //phpcs:ignore Generic.WhiteSpace.ScopeIndent
					$position_text = esc_html(
						sprintf(
							/* translators: %d is a number */
							_n( '%d position', '%d positions', $reading_array[ $i ]->positions, 'card-oracle' ),
							number_format_i18n( $reading_array[ $i ]->positions )
						)
					);

					$card_text = esc_html(
						sprintf(
							/* translators: %d is a number */
							_n( '%d card', '%d cards', $reading_array[ $i ]->cards, 'card-oracle' ),
							number_format_i18n( $reading_array[ $i ]->cards )
						)
					);

					$description_text = esc_html(
						sprintf(
							/* translators: %d is a number */
							_n( '%d description', '%d descriptions', $reading_array[ $i ]->descriptions, 'card-oracle' ),
							number_format_i18n( $reading_array[ $i ]->descriptions )
						)
					);

					$shortcode_name = sprintf( 'card-oracle-shortcodes-%d', $i );
			?>
			<div class="card-oracle-stat">
				<div class="card-oracle-stat-header">
					<?php echo esc_html( $readings[ $i ]->post_title ); ?>
				</div>
				<div class="card-oracle-stat-body">
					<p><?php echo esc_html( $position_text ); ?></p>
					<p><?php echo esc_html( $card_text ); ?></p>
					<p><?php echo esc_html( $description_text ); ?></p>
					<?php /* phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped */ ?>
					<div class="card-oracle-modal-link">
						<a href="#card-oracle-open-modal-<?php echo esc_attr( $readings[ $i ]->ID ); ?>"><?php esc_html_e( 'Reading Shortcodes', 'card-oracle' ); ?></a>
					</div>
					<div id="card-oracle-open-modal-<?php echo esc_attr( $readings[ $i ]->ID ); ?>" class="card-oracle-modal-dialog">
						<div>
							<a href="#close" title="Close" class="card-oracle-modal-close">X</a>
							<h2>Tarot Card Oracle Shortcodes</h2>
							<?php
						foreach ( $shortcodes as $shortcode ) {
							printf(
								'<div class="card-oracle-shortcode-row"><p class="card-oracle-shortcode-header">%1$s</p><input class="card-oracle-shortcode" id="copy%2$s-%7$s" size="24" value="[%3$s&quot;%2$s&quot;]"><button class="copy-action-btn button" title="%4$s" value="[%3$s&quot;%2$s&quot;]"><img src="%5$s" alt="%6$s"></button></div>',
								esc_html( $shortcode['label'] ),
								esc_attr( $readings[ $i ]->ID ),
								$shortcode['code'],
								esc_attr__( 'Click to copy shortcode', 'card-oracle' ),
								esc_url( CARD_ORACLE_CLIPPY ),
								esc_attr__( 'Copy to clipboard', 'card-oracle' ),
								esc_attr( $shortcode['type'] )
							);
						}
						?>
						</div>
					</div>
					<?php /* phpcs:enable WordPress.Security.EscapeOutput.OutputNotEscaped */ ?>
				</div>
			</div>
			<?php } ?>
			</div> <!-- Statistics for each Reading -->
		</section>
		<?php endif; ?>
	</div> <!-- co_dashboard -->
<?php endif; ?>
