<div class="wrockmetro--getting-started--wrapper">
        <div id="wrockmetro-admin-about-page">
                <div class="wrockmetro-about-container  wrockmetro-admin-card wrockmetro-admin-card-header admin-grid-2">
                        <div class="wrockmetro-header-left admin-col">
                                <h2>
                                        <?php echo esc_html( $theme->get('Name') ); ?>
                                </h2>
                                <p>
                                        <?php esc_html_e( 'Multipurpose Premium WordPress Theme', 'wrock-metro' ); ?>
                                </p>

               			 </div>
						<div class="wrockmetro-header-left admin-col">
							<div class="wrockmetro-card-header-button-group">							
								
								
								<a href="<?php echo esc_url( __( 'https://www.insertcart.com/product/wrock-metro/', 'wrock-metro' ) ); ?>" class="wrockmetro-admin-button" rel="noreferrer" target="_blank"><span class="dashicons dashicons-cart"></span><?php esc_html_e( 'Get Pro', 'wrock-metro' ); ?> </a>
								
								<a  href="<?php echo esc_url( __( 'https://www.insertcart.com/wrock-metro-theme-setup-guide-and-documentation/', 'wrock-metro' ) ); ?>" class="wrockmetro-admin-button premium-button"
                                                target="_blank" rel="noreferrer"><span class="dashicons dashicons-book-alt"></span> <?php esc_html_e( 'Documentations', 'wrock-metro' ); ?></a></div>
                        		</div>
							</div>
                <div class="wrockmetro-about-container subscribe-panel">
                        <div class="admin-col">
                                <div class="gutentor-get-started-content">
                                        <h3><?php esc_html_e( 'Wrock Metro Theme', 'wrock-metro' ); ?></h3>
                                        <p><?php esc_html_e( 'Wrock Metro is a sleek and modern WordPress theme designed for Full Site Editing (FSE). It is optimized for speed and performance, ensuring your website loads quickly and efficiently. With its pre-built block patterns, you can easily create stunning layouts and customize your site design without writing a single line of code. wrockmetro is also mobile-friendly, SEO-optimized, and translation-ready, making it a versatile choice for businesses of all sizes.', 'wrock-metro' ); ?></p>
                                      
                                </div>
                        </div>
                       
                      
                </div>
                <div class="wrockmetro-about-container wrockmetro-compare-table">
                        <div class="admin-grid-1">
                                <h3>
                                        <?php esc_html_e( 'Compare Free Vs Pro', 'wrock-metro' ); ?>
									</h3>
									<p class="wrockmetro-compare-table-subtitle"><a href="<?php echo esc_url( __( 'https://www.insertcart.com/product/wrock-metro/', 'wrock-metro' ) ); ?>" target="__blank"><?php esc_html_e( 'Checkout all features', 'wrock-metro' ); ?> <i class="dashicons dashicons-arrow-right-alt"></i></a></p>
                                <table>
                                        <thead>
                                                <tr>
                                                        <th>
                                                                <?php esc_html_e( 'Features', 'wrock-metro' ); ?>
                                                        </th>
                                                        <th>
                                                                <?php esc_html_e( 'Wrock Metro Free', 'wrock-metro' ); ?>
                                                        </th>
                                                        <th>
                                                                <?php esc_html_e( 'Wrock Metro Pro', 'wrock-metro' ); ?>
                                                        </th>
                                                </tr>
                                        </thead>
                                        <tbody>
                                                <tr>
                                                        <td>
                                                                <?php esc_html_e( 'Responsive Design', 'wrock-metro' ); ?>
                                                                </th>
                                                        <td><span class="dashicons dashicons-yes"></span></th>
                                                        <td><span class="dashicons dashicons-yes"></span></th>
                                                </tr>
                                                <tr>
                                                        <td>
                                                                <?php esc_html_e( 'Painless Setup', 'wrock-metro' ); ?>
                                                                </th>
                                                        <td><span class="dashicons dashicons-yes"></span></th>
                                                        <td><span class="dashicons dashicons-yes"></span></th>
                                                </tr>
                                                <tr>
                                                        <td>
                                                                <?php esc_html_e( 'Color Options', 'wrock-metro' ); ?>
                                                                </th>
                                                        <td><span class="dashicons dashicons-yes"></span></th>
                                                        <td><span class="dashicons dashicons-yes"></span></th>
                                                </tr>
                                                <tr>
                                                        <td>
                                                                <?php esc_html_e( 'Premium site demos', 'wrock-metro' ); ?>
                                                                </th>
                                                        <td><span class="dashicons dashicons-no"></span></th>
                                                        <td><span class="dashicons dashicons-yes"></span></th>
                                                </tr>
                                                <tr>
                                                        <td>
                                                                <?php esc_html_e( 'Multiple Block Layout', 'wrock-metro' ); ?>
                                                                </th>
                                                        <td><span class="dashicons dashicons-no"></span></th>
                                                        <td><span class="dashicons dashicons-yes"></span></th>
                                                </tr>
                                                <tr>
                                                        <td>
                                                                <?php esc_html_e( 'Premium Patterns', 'wrock-metro' ); ?>
                                                                </th>
                                                        <td><span class="dashicons dashicons-no"></span></th>
                                                        <td><span class="dashicons dashicons-yes"></span></th>
                                                </tr>
                                                <tr>
                                                        <td>
                                                                <?php esc_html_e( 'Multiple Fonts', 'wrock-metro' ); ?>
                                                                </th>
                                                        <td><span class="dashicons dashicons-no"></span></th>
                                                        <td><span class="dashicons dashicons-yes"></span></th>
                                                </tr>
                                                <tr>
                                                        <td>
                                                                <?php esc_html_e( 'Slider Block ', 'wrock-metro' ); ?>
                                                                </th>
                                                        <td><span class="dashicons dashicons-no"></span></th>
                                                        <td><span class="dashicons dashicons-yes"></span></th>
                                                </tr>
                                                <tr>
                                                        <td>
                                                                <?php esc_html_e( 'Post Listing Block', 'wrock-metro' ); ?>
                                                                </th>
                                                        <td><span class="dashicons dashicons-no"></span></th>
                                                        <td><span class="dashicons dashicons-yes"></span></th>
                                                </tr>
                                                <tr>
                                                        <td>
                                                                <?php esc_html_e( 'WooCommerce Filter Block', 'wrock-metro' ); ?>
                                                                </th>
                                                        <td><span class="dashicons dashicons-no"></span></th>
                                                        <td><span class="dashicons dashicons-yes"></span></th>
                                                </tr>
                                                <tr>
                                                        <td>
                                                                <?php esc_html_e( 'Gallery Block', 'wrock-metro' ); ?>
                                                                </th>
                                                        <td><span class="dashicons dashicons-no"></span></th>
                                                        <td><span class="dashicons dashicons-yes"></span></th>
                                                </tr>
                                                <tr>
                                                        <td>
                                                                <?php esc_html_e( 'Star Rating Block', 'wrock-metro' ); ?>
                                                                </th>
                                                        <td><span class="dashicons dashicons-no"></span></th>
                                                        <td><span class="dashicons dashicons-yes"></span></th>
                                                </tr>
                                                <tr>
                                                        <td>
                                                                <?php esc_html_e( 'Icon Block', 'wrock-metro' ); ?>
                                                                </th>
                                                        <td><span class="dashicons dashicons-no"></span></th>
                                                        <td><span class="dashicons dashicons-yes"></span></th>
                                                </tr>
                                                <tr>
                                                        <td>
                                                                <?php esc_html_e( 'Post Carousel Block', 'wrock-metro' ); ?>
                                                                </th>
                                                        <td><span class="dashicons dashicons-no"></span></th>
                                                        <td><span class="dashicons dashicons-yes"></span></th>
                                                </tr>
                                                <tr>
                                                        <td>
                                                                <?php esc_html_e( 'Google Map Block', 'wrock-metro' ); ?>
                                                                </th>
                                                        <td><span class="dashicons dashicons-no"></span></th>
                                                        <td><span class="dashicons dashicons-yes"></span></th>
                                                </tr>
                                                <tr>
                                                        <td>
                                                                <?php esc_html_e( 'Testimonials Block', 'wrock-metro' ); ?>
                                                                </th>
                                                        <td><span class="dashicons dashicons-no"></span></th>
                                                        <td><span class="dashicons dashicons-yes"></span></th>
                                                </tr>
                                                <tr>
                                                        <td>
                                                                <?php esc_html_e( 'Team Block', 'wrock-metro' ); ?>
                                                                </th>
                                                        <td><span class="dashicons dashicons-no"></span></th>
                                                        <td><span class="dashicons dashicons-yes"></span></th>
                                                </tr>
                                        </tbody>
                                </table>
                        </div>
                </div>

                <div class="feature-list">
                        <div class="wrockmetro-about-container wrockmetro-about-content">
                                <div class="wrockmetro-admin-card features">
                                        <h4 class="wrockmetro-admin-card-title is-medium is-sub"><?php esc_html_e( 'Wrock Metro Core Features', 'wrock-metro' ); ?>
                                        </h4>
                                        <ul class="wrockmetro-options-features">
                                                <li><span class="dashicons dashicons-yes"></span>
												<?php esc_html_e( 'Global page settings(typography,
                                                        color, ...)', 'wrock-metro' ); ?> </li>
                                                <li><span class="dashicons dashicons-yes"></span>
												<?php esc_html_e( 'Site Demo', 'wrock-metro' ); ?>   </li>
                                                <li><span class="dashicons dashicons-yes"></span>
												<?php esc_html_e( 'Predefined sections', 'wrock-metro' ); ?>   </li>
                                                <li><span class="dashicons dashicons-yes"></span>
												<?php esc_html_e( 'Fully Responsive', 'wrock-metro' ); ?>   </li>
                                                <li><span class="dashicons dashicons-yes"></span>
												<?php esc_html_e( 'Highly customizable row columns', 'wrock-metro' ); ?>
                                                </li>
                                                <li><span class="dashicons dashicons-yes"></span>
												<?php esc_html_e( 'Color Options', 'wrock-metro' ); ?>   </li>
                                                <li><span class="dashicons dashicons-yes"></span>
												<?php esc_html_e( 'Device specific responsive controls', 'wrock-metro' ); ?>
                                                </li>
                                                <li><span class="dashicons dashicons-yes"></span>
												<?php esc_html_e( 'Google fonts', 'wrock-metro' ); ?> </li>
                                                <li><span class="dashicons dashicons-yes"></span>
												<?php esc_html_e( 'Classic &amp; gradient color and
                                                        background', 'wrock-metro' ); ?></li>
                                                <li><span class="dashicons dashicons-yes"></span>
												<?php esc_html_e( 'Box-shadow', 'wrock-metro' ); ?></li>
                                                <li><span class="dashicons dashicons-yes"></span>
												<?php esc_html_e( 'Border', 'wrock-metro' ); ?> </li>
                                                <li><span class="dashicons dashicons-yes"></span>
												<?php esc_html_e( 'Advanced Typography', 'wrock-metro' ); ?> </li>
                                                <li><span class="dashicons dashicons-yes"></span>
												<?php esc_html_e( 'Pre build pattrens', 'wrock-metro' ); ?></li>
                                                <li><span class="dashicons dashicons-yes"></span>
												<?php esc_html_e( '&amp; More...', 'wrock-metro' ); ?> </li>
                                        </ul>
                                </div>
                        </div>
                        <div class="wrockmetro-about-side">
                                <div class="wrockmetro-admin-card member"><span><i class="fa fa-star"
                                                        aria-hidden="true"></i> <i class="fa fa-star"
                                                        aria-hidden="true"></i> <i class="fa fa-star"
                                                        aria-hidden="true"></i> <i class="fa fa-star"
                                                        aria-hidden="true"></i> <i class="fa fa-star"
                                                        aria-hidden="true"></i></span>
                                        <h3 class="wrockmetro-admin-card-title is-small"><?php esc_html_e( 'Love our product?', 'wrock-metro' ); ?>
                                        </h3>
                                        <h4 class="wrockmetro-admin-card-title is-small"><?php esc_html_e( 'Motivate us by
                                                giving 5 star on
                                                our profile.', 'wrock-metro' ); ?></h4><a
                                                href="https://wordpress.org/support/theme/wrock-metro/reviews/?filter=5"
                                                class="wrockmetro-admin-button large wrockmetro-block is-default"
                                                target="__blank"><?php esc_html_e( 'Rate Us', 'wrock-metro' ); ?></a>
                                </div>
                                <div class="wrockmetro-admin-card cart-two">
                                        <h3 class="wrockmetro-admin-card-title is-small"><?php esc_html_e( 'Still have question?
                                                Ask Us, now!', 'wrock-metro' ); ?>
                                        </h3>
                                        <p><?php esc_html_e( 'We are always ready with all fix issues you stuck to ensure smoothly works with wrockmetro', 'wrock-metro' ); ?></p><a href="<?php echo esc_url( __( 'https://www.insertcart.com/contact-us/', 'wrock-metro' ) ); ?>"
                                                class="wrockmetro-admin-button primary large wrockmetro-block"><?php esc_html_e( 'Get Support', 'wrock-metro' ); ?></a>
								<a  href="<?php echo esc_url( __( 'https://www.insertcart.com/wrock-metro-theme-setup-guide-and-documentation/', 'wrock-metro' ) ); ?>" class="wrockmetro-admin-button premium-button"
                                                target="_blank" rel="noreferrer"><i class="fa fa-book"></i>
                                                <?php esc_html_e( 'Documentations', 'wrock-metro' ); ?></a>
							
                                </div>
                        </div>
                </div>
					<?php echo wrockmetro_display_core(); ?>
        </div>
</div>
<?php
function wrockmetro_core_style() {

	// Set template directory uri
	$directory_uri = get_template_directory_uri();

	wp_enqueue_style( 'bootstrap', $directory_uri . '/inc/core/bootstrap/css/bootstrap.css' );
	wp_enqueue_style( 'bootstrap-responsive', $directory_uri . '/inc/core/bootstrap/css/bootstrap-responsive.css', 'bootstrap' );
	wp_enqueue_style( 'wrockmetro-responsive', $directory_uri . '/inc/core/bootstrap/css/responsive.css', array( 'bootstrap', 'bootstrap-responsive' ) );
	wp_enqueue_style( 'core_style', get_template_directory_uri() . '/inc/core/css/core.css' );
}
function wrockmetro_get_themes( $request ) {
    $key = 'wrockmetro_' . md5( wp_json_encode( $request ) );

    // Check transient cache first
    if ( false === ( $themes = get_transient( $key ) ) ) {
        // Build the query URL for the GET request
        $url = add_query_arg( $request, 'https://api.wordpress.org/themes/info/1.2/' );

        // Use GET instead of POST
        $response = wp_remote_get( $url );

        // Handle errors in response
        if ( is_wp_error( $response ) ) {
            return $response;
        }

        // Decode JSON response
        $themes = json_decode( wp_remote_retrieve_body( $response ) );

        // Validate the response
        if ( ! is_object( $themes ) || ! isset( $themes->themes ) ) {
            return new WP_Error( 'theme_api_error', 'Unexpected response format from the API' );
        }

        // Cache the result for 24 hours
        set_transient( $key, $themes, 60 * 60 * 24 );
    }

    return $themes;
}



function wrockmetro_enqueue_dashboard_scripts() {
    wp_enqueue_script( 'themeload', get_template_directory_uri() . '/js/themeload.js', array( 'jquery' ), null, true );

    // Fetch themes in PHP
    $request = array(
        'action'  => 'query_themes',
        'browse'  => 'popular', // Adjusted for API v1.2
    );
    $themes = wrockmetro_get_themes( $request );

    // Prepare themes data for frontend
    $themes_data = is_wp_error( $themes ) || ! isset( $themes->themes ) ? [] : $themes->themes;

    wp_localize_script( 'themeload', 'wrockmetroThemes', $themes_data );
}
add_action( 'wp_enqueue_scripts', 'wrockmetro_enqueue_dashboard_scripts' );
function wrockmetro_display_core() {
    ?>
    <div class="wrockmetro-about-container subscribe-panel">
        <div class="admin-col">
            <div class="gutentor-get-started-content">
                <h4 class="wrockmetro-admin-card-title is-medium is-sub"><?php esc_html_e( 'Amazing WP Themes', 'wrock-metro' ); ?></h4>
                <div class="container-fluid">
                    <div id="core_container">
                        <div id="themes-container">
                            <!-- Themes will be dynamically loaded here -->
                        </div>
                        <div id="core_themes" class="row-fluid">
                            <?php
                            $request = array(
                                'action' => 'query_themes',
                                'author' => 'sandy786', // Filter by your author slug
                                'per_page' => 100,     // Fetch more themes (adjust if needed)
                            );

                            $themes = wrockmetro_get_themes( $request );							
							

                            // Handle errors or empty responses
                            if ( is_wp_error( $themes ) ) {
                                echo '<p>' . esc_html__( 'Failed to fetch themes. Please try again later.', 'wrock-metro' ) . '</p>';
                                return;
                            }

                            if ( ! isset( $themes->themes ) || empty( $themes->themes ) ) {
                                echo '<p>' . esc_html__( 'No themes found.', 'wrock-metro' ) . '</p>';
                                return;
                            }

                            $active_theme = wp_get_theme()->get( 'Name' );
							$counter = 1;

                            // For currently active theme.
					foreach ( $themes->themes as $theme ) {
						if( $active_theme == $theme->name ) {?>

							<div id="<?php echo $theme->slug; ?>" class="theme-container span3">
								<div class="image-container">
									<img class="theme-screenshot" src="<?php echo $theme->screenshot_url ?>"/>

									<div class="theme-description">
										<p><?php echo $theme->description; ?></p>
									</div>
								</div>
								<div class="theme-details active">
									<span class="theme-name"><?php echo $theme->name; ?><?php echo ': Current'; ?></span>
									<a class="button button-secondary customize right" target="_blank" href="<?php echo esc_url(home_url()). '/wp-admin/customize.php' ?>"><?php echo 'Customize'; ?></a>
								</div>
							</div>

						<?php
						$counter++;
						break;
						}
					}

					// For all other themes.
					foreach ( $themes->themes as $theme ) {
						if( $active_theme != $theme->name ) {

							// Set the argument array with author name.
							/* $args = array(
								'slug' => $theme->slug,
							); */

							// Set the $request array.
							/* $request = array(
								'body' => array(
									'action'  => 'theme_information',
									'request' => serialize( (object)$args )
								)
							); */
							//$theme_details = wrockmetro_get_themes( $request );
							?>

							<div id="<?php echo $theme->slug; ?>" class="theme-container span3 <?php echo $counter % 4 == 1 ? 'no-left-megin' : ""; ?>">
								<div class="image-container">
									<img class="theme-screenshot" src="<?php echo $theme->screenshot_url ?>"/>

									<div class="theme-description">
										<p><?php echo $theme->description; ?></p>
									</div>
								</div>
								<div class="theme-details">
									<span class="theme-name"><?php echo $theme->name; ?></span>

									<!-- Check if the theme is installed -->
									<?php if( wp_get_theme( $theme->slug )->exists() ) { ?>

										<!-- Show the tick image notifying the theme is already installed. -->									
										<span class="dashicons dashicons-yes" data-toggle="tooltip"    data-placement="bottom"  title="Already installed"  data-alt="Tick icon representing already installed theme" ></span>


										<!-- Activate Button -->
										<a  class="button button-primary activate right"
											href="<?php echo wp_nonce_url( admin_url( 'themes.php?action=activate&amp;stylesheet=' . urlencode( $theme->slug ) ), 'switch-theme_' . $theme->slug );?>" ><?php echo 'Activate'; ?></a>
									<?php }
									else {

										// Set the install url for the theme.
										$install_url = add_query_arg( array(
												'action' => 'install-theme',
												'theme'  => $theme->slug,
											), self_admin_url( 'update.php' ) );
									?>
									
									<?php 
										$downloaded_count = isset($theme_details->downloaded) ? (float) $theme_details->downloaded : 0;
										?>
										<a data-toggle="tooltip" data-placement="bottom" 
										   title="<?php echo 'Downloaded ' . number_format($downloaded_count) . ' times'; ?>" 
										   class="button button-primary install right" 
										   href="<?php echo esc_url( wp_nonce_url( $install_url, 'install-theme_' . $theme->slug ) ); ?>">
										   <?php echo 'Install Now'; ?>
										</a>
																						
									<?php } ?>
									<!-- Preview button -->
									<a class="button button-secondary preview right" target="_blank" href="<?php echo $theme->preview_url; ?>"><?php echo 'Live Preview'; ?></a>
								</div>
							</div>
							<?php
							$counter++;
						}
					}?>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <?php
}