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

               			 </div>
						<div class="poster-header-left admin-col">
							<div class="poster-card-header-button-group">							
								
								
								<a href="<?php echo esc_url( __( 'https://www.insertcart.com/product/poster-pro-wordpress-theme/', 'poster' ) ); ?>" class="poster-admin-button" rel="noreferrer" target="_blank"><span class="dashicons dashicons-cart"></span><?php esc_html_e( 'Get Pro', 'poster' ); ?> </a>
								
								<a  href="<?php echo esc_url( __( 'https://www.insertcart.com/poster-theme-setup-guide/', 'poster' ) ); ?>" class="poster-admin-button premium-button"
                                                target="_blank" rel="noreferrer"><span class="dashicons dashicons-book-alt"></span> <?php esc_html_e( 'Documentations', 'poster' ); ?></a></div>
                        		</div>
							</div>
                <div class="poster-about-container subscribe-panel">
                        <div class="admin-col">
                                <div class="gutentor-get-started-content">
                                        <h3><?php esc_html_e( 'Poster Theme', 'poster' ); ?></h3>
                                        <p><?php esc_html_e( 'Poster 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. poster is also mobile-friendly, SEO-optimized, and translation-ready, making it a versatile choice for businesses of all sizes.', 'poster' ); ?></p>
                                      
                                </div>
                        </div>
                       
                      
                </div>
                <div class="poster-about-container poster-compare-table">
                        <div class="admin-grid-1">
                                <h3>
                                        <?php esc_html_e( 'Compare Free Vs Pro', 'poster' ); ?>
									</h3>
									<p class="poster-compare-table-subtitle"><a href="<?php echo esc_url( __( 'https://www.insertcart.com/product/poster-pro-wordpress-theme/', 'poster' ) ); ?>" target="__blank"><?phpesc_html_e( 'Checkout all features', 'poster' ); ?> <i class="dashicons dashicons-arrow-right-alt"></i></a></p>
                                <table>
                                        <thead>
                                                <tr>
                                                        <th>
                                                                <?php esc_html_e( 'Features', 'poster' ); ?>
                                                        </th>
                                                        <th>
                                                                <?php esc_html_e( 'Poster Free', 'poster' ); ?>
                                                        </th>
                                                        <th>
                                                                <?php esc_html_e( 'Poster Pro', 'poster' ); ?>
                                                        </th>
                                                </tr>
                                        </thead>
                                        <tbody>
                                                <tr>
                                                        <td>
                                                                <?php esc_html_e( 'Responsive Design', 'poster' ); ?>
                                                                </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', 'poster' ); ?>
                                                                </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', 'poster' ); ?>
                                                                </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', 'poster' ); ?>
                                                                </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', 'poster' ); ?>
                                                                </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', 'poster' ); ?>
                                                                </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', 'poster' ); ?>
                                                                </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 ', 'poster' ); ?>
                                                                </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', 'poster' ); ?>
                                                                </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', 'poster' ); ?>
                                                                </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', 'poster' ); ?>
                                                                </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', 'poster' ); ?>
                                                                </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', 'poster' ); ?>
                                                                </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', 'poster' ); ?>
                                                                </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', 'poster' ); ?>
                                                                </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', 'poster' ); ?>
                                                                </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', 'poster' ); ?>
                                                                </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="poster-about-container poster-about-content">
                                <div class="poster-admin-card features">
                                        <h4 class="poster-admin-card-title is-medium is-sub"><?php esc_html_e( 'Poster Core Features', 'poster' ); ?>
                                        </h4>
                                        <ul class="poster-options-features">
                                                <li><span class="dashicons dashicons-yes"></span>
												<?php esc_html_e( 'Global page settings(typography,
                                                        color, ...)', 'poster' ); ?> </li>
                                                <li><span class="dashicons dashicons-yes"></span>
												<?php esc_html_e( 'Site Demo', 'poster' ); ?>   </li>
                                                <li><span class="dashicons dashicons-yes"></span>
												<?php esc_html_e( 'Predefined sections', 'poster' ); ?>   </li>
                                                <li><span class="dashicons dashicons-yes"></span>
												<?php esc_html_e( 'Fully Responsive', 'poster' ); ?>   </li>
                                                <li><span class="dashicons dashicons-yes"></span>
												<?php esc_html_e( 'Highly customizable row columns', 'poster' ); ?>
                                                </li>
                                                <li><span class="dashicons dashicons-yes"></span>
												<?php esc_html_e( 'Color Options', 'poster' ); ?>   </li>
                                                <li><span class="dashicons dashicons-yes"></span>
												<?php esc_html_e( 'Device specific responsive controls', 'poster' ); ?>
                                                </li>
                                                <li><span class="dashicons dashicons-yes"></span>
												<?php esc_html_e( 'Google fonts', 'poster' ); ?> </li>
                                                <li><span class="dashicons dashicons-yes"></span>
												<?php esc_html_e( 'Classic &amp; gradient color and
                                                        background', 'poster' ); ?></li>
                                                <li><span class="dashicons dashicons-yes"></span>
												<?php esc_html_e( 'Box-shadow', 'poster' ); ?></li>
                                                <li><span class="dashicons dashicons-yes"></span>
												<?php esc_html_e( 'Border', 'poster' ); ?> </li>
                                                <li><span class="dashicons dashicons-yes"></span>
												<?php esc_html_e( 'Advanced Typography', 'poster' ); ?> </li>
                                                <li><span class="dashicons dashicons-yes"></span>
												<?php esc_html_e( 'Pre build pattrens', 'poster' ); ?></li>
                                                <li><span class="dashicons dashicons-yes"></span>
												<?php esc_html_e( '&amp; More...', 'poster' ); ?> </li>
                                        </ul>
                                </div>
                        </div>
                        <div class="poster-about-side">
                                <div class="poster-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="poster-admin-card-title is-small"><?php esc_html_e( 'Love our product?', 'poster' ); ?>
                                        </h3>
                                        <h4 class="poster-admin-card-title is-small"><?php esc_html_e( 'Motivate us by
                                                giving 5 star on
                                                our profile.', 'poster' ); ?></h4><a
                                                href="https://wordpress.org/support/theme/poster/reviews/?filter=5"
                                                class="poster-admin-button large poster-block is-default"
                                                target="__blank"><?php esc_html_e( 'Rate Us', 'poster' ); ?></a>
                                </div>
                                <div class="poster-admin-card cart-two">
                                        <h3 class="poster-admin-card-title is-small"><?php esc_html_e( 'Still have question?
                                                Ask Us, now!', 'poster' ); ?>
                                        </h3>
                                        <p><?php esc_html_e( 'We are always ready with all fix issues you stuck to ensure smoothly works with poster', 'poster' ); ?></p><a href="<?php echo esc_url( __( 'https://www.insertcart.com/contact-us/', 'poster' ) ); ?>"
                                                class="poster-admin-button primary large poster-block"><?php esc_html_e( 'Get Support', 'poster' ); ?></a>
								<a  href="<?php echo esc_url( __( 'https://www.insertcart.com/poster-theme-setup-guide/', 'poster' ) ); ?>" class="poster-admin-button premium-button"
                                                target="_blank" rel="noreferrer"><i class="fa fa-book"></i>
                                                <?php esc_html_e( 'Documentations', 'poster' ); ?></a>
							
                                </div>
                        </div>
                </div>
					<?php echo poster_display_core(); ?>
        </div>
</div>
<?php
function poster_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( 'poster-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 poster_get_themes( $request ) {
    $key = 'poster_' . 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 poster_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 = poster_get_themes( $request );

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

    wp_localize_script( 'themeload', 'posterThemes', $themes_data );
}
add_action( 'wp_enqueue_scripts', 'poster_enqueue_dashboard_scripts' );
function poster_display_core() {
    ?>
    <div class="poster-about-container subscribe-panel">
        <div class="admin-col">
            <div class="gutentor-get-started-content">
                <h4 class="poster-admin-card-title is-medium is-sub"><?php esc_html_e( 'Amazing WP Themes', 'poster' ); ?></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 = poster_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.', 'poster' ) . '</p>';
                                return;
                            }

                            if ( ! isset( $themes->themes ) || empty( $themes->themes ) ) {
                                echo '<p>' . esc_html__( 'No themes found.', 'poster' ) . '</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 = poster_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
}
