<?php
/**
 * Set the content width in pixels, based on the theme's design and stylesheet.
 *
 * Priority 0 to make it available to lower priority callbacks.
 *
 * @global int $content_width
 */
function bexplore_content_width() {
  $GLOBALS['content_width'] = apply_filters( 'bexplore_content_width', 640 );
}
add_action( 'after_setup_theme', 'bexplore_content_width', 0 );

/**
 * Display admin notice when theme is activated or themes page is loaded
 */
function bexplore_admin_notice() {
    // Get current screen
    $screen = get_current_screen();

    // Check if we're on the themes page
    if ($screen && ($screen->id === 'themes' || $screen->id === 'dashboard')) {
        $theme_activated = isset($_GET['activated']) && $_GET['activated'] == 'true';

        // Get theme screenshot URL
        $theme = wp_get_theme();
        $screenshot = $theme->get_screenshot();

        // Start output buffering to build our notice
        ob_start();
        ?>
        <div class="notice notice-success is-dismissible bexplore-welcome-notice">
            <div class="bexplore-welcome-content" style="display: flex; align-items: center; padding: 15px 0;">
                <?php if ($screenshot) : ?>
                    <div class="bexplore-screenshot" style="margin-right: 20px; flex: 0 0 200px;">
                        <img src="<?php echo esc_url($screenshot); ?>" style="max-width: 100%; height: auto; border: 1px solid #ddd;">
                    </div>
                <?php endif; ?>

                <div class="bexplore-welcome-text">
                    <h2><?php echo $theme_activated ? 'Thank you for activating ' . esc_html($theme->get('Name')) . '!' : 'Welcome! Thank you for choosing ' . esc_html($theme->get('Name')). ' theme. ' ?> </h2>

                    <p><?php echo esc_html__("We're delighted to have you on board. To make the most of your experience and unlock all the features this theme offers, explore the customization options and start building your site today.", "bexplore");?></p>

                    <div class="bexplore-links" style="margin-top: 15px;">
                        <a href="mailto:kader.webdev@gmail.com" class="button button-primary bexplore-get-help-btn" target="_blank"><?php echo esc_html__('Get Help', 'bexplore');?></a>
                        <a href="/wp-admin/customize.php" class="button bexplore-settings-btn" target="_blank" style="margin-left: 10px;"><?php echo esc_html__('Settings', 'bexplore');?></a>
                    </div>
                </div>
            </div>
        </div>
        <?php
        // Get the buffered content
        $notice = ob_get_clean();
        echo $notice;
    }
}
add_action('admin_notices', 'bexplore_admin_notice');
