<?php
/**
 * Pro themes grid + activation redirect.
 *
 * @package the-construction
 */

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

function the_construction_get_pro_themes() {
	$image_uri = get_template_directory_uri() . '/assets/images/pro-theme/';

	return array(
		array(
			'title' => __( 'Auto Parts Shop WordPress Theme', 'the-construction' ),
			'image' => $image_uri . 'Auto-Parts-Shop-WordPress-Elementor-Theme.jpg',
			'url'   => 'https://www.templatehouse.net/themes/auto-parts-woocommerce-theme/',
		),
		array(
			'title' => __( 'Motors Auto Parts Custom Theme', 'the-construction' ),
			'image' => $image_uri . 'Motors-Auto-Parts-Custom-WooCommerce-Theme.jpg',
			'url'   => 'https://www.templatehouse.net/themes/auto-parts-custom-woocommerce-wordpress-theme/',
		),
		array(
			'title' => __( 'Auto Parts WooCommerce Theme', 'the-construction' ),
			'image' => $image_uri . 'Auto-Parts-WooCommerce-Theme.jpg',
			'url'   => 'https://www.templatehouse.net/themes/auto-parts-wordpress-theme/',
		),
		array(
			'title' => __( 'Nusa Business Consulting Theme', 'the-construction' ),
			'image' => $image_uri . 'Business-Consulting-WordPress-Theme.jpg',
			'url'   => 'https://www.templatehouse.net/themes/nusa-business-consulting-wordpress-theme/',
		),
		array(
			'title' => __( 'Construction Building Theme', 'the-construction' ),
			'image' => $image_uri . 'Construction-Building-WordPress-Theme.jpg',
			'url'   => 'https://www.templatehouse.net/themes/construction-and-building-wordpress-theme/',
		),
		array(
			'title' => __( 'Constructo Construction Theme', 'the-construction' ),
			'image' => $image_uri . 'Constructo-Construction-WordPress-Theme.jpg',
			'url'   => 'https://www.templatehouse.net/themes/constructo-construction-wordpress-theme/',
		),
		array(
			'title' => __( 'Grocery Store WooCommerce Theme', 'the-construction' ),
			'image' => $image_uri . 'Grocery-Store-and-Organic-Food-WooCommerce-eCommerce-WordPress-Theme.jpg',
			'url'   => 'https://www.templatehouse.net/themes/grocery-store-wordpress-theme/',
		),
		array(
			'title' => __( 'HotelBooking Resort Theme', 'the-construction' ),
			'image' => $image_uri . 'HotelBooking-Hotel-and-Resort-Booking-WordPress-Theme.jpg',
			'url'   => 'https://www.templatehouse.net/themes/hotelbooking-hotel-and-resort-booking-wordpress-theme/',
		),
		array(
			'title' => __( 'Food Menu Ordering Plugin', 'the-construction' ),
			'image' => $image_uri . 'info-1.jpg',
			'url'   => 'https://www.templatehouse.net/plugins/food-menu-ordering-for-woocommerce/',
		),
		array(
			'title' => __( 'Soledad Personal Blog Theme', 'the-construction' ),
			'image' => $image_uri . 'Soledad-Optimized-Personal-Blog-WordPress-Theme.jpg',
			'url'   => 'https://www.templatehouse.net/themes/soledad-optimized-personal-blog-wordpress-theme/',
		),
		array(
			'title' => __( 'SpaciaN Real Estate Theme', 'the-construction' ),
			'image' => $image_uri . 'SpaciaN-Real-Estate-Construction-Group-WordPress-Theme.jpg',
			'url'   => 'https://www.templatehouse.net/themes/real-estate-and-construction-group-wordpress-theme/',
		),
		array(
			'title' => __( 'TimelineX AI Story Timeline Builder', 'the-construction' ),
			'image' => $image_uri . 'Timelinex-ai-Story-Timeline-Builder.jpg',
			'url'   => 'https://www.templatehouse.net/plugins/ai-story-timeline-builder-for-wordpress/',
		),
	);
}

function the_construction_render_pro_themes_section() {
	$pro_themes = the_construction_get_pro_themes();
	?>
	<div class="pro-themes-section">
		<h2 class="pro-themes-heading"><?php esc_html_e( 'Our Pro Themes & Plugins', 'the-construction' ); ?></h2>
		<p class="pro-themes-intro"><?php esc_html_e( 'Explore our premium WordPress themes and plugins. Click any screenshot to view full details on our website.', 'the-construction' ); ?></p>
		<div class="pro-themes-grid">
			<?php foreach ( $pro_themes as $pro_theme ) : ?>
				<a class="pro-theme-card" href="<?php echo esc_url( $pro_theme['url'] ); ?>" target="_blank" rel="noopener noreferrer">
					<span class="pro-theme-thumb">
						<img src="<?php echo esc_url( $pro_theme['image'] ); ?>" alt="<?php echo esc_attr( $pro_theme['title'] ); ?>" loading="lazy" />
					</span>
					<span class="pro-theme-title"><?php echo esc_html( $pro_theme['title'] ); ?></span>
				</a>
			<?php endforeach; ?>
		</div>
	</div>
	<?php
}

function the_construction_enqueue_pro_themes_assets( $hook ) {
	wp_enqueue_style(
		'the-construction-pro-themes',
		get_template_directory_uri() . '/assets/css/pro-themes.css',
		array(),
		wp_get_theme()->get( 'Version' )
	);
}
add_action( 'admin_enqueue_scripts', 'the_construction_enqueue_pro_themes_assets' );
