/**
 * Astra Child functions
 */

add_action( 'wp_enqueue_scripts', 'astra_child_enqueue_styles' );
function astra_child_enqueue_styles() {
    wp_enqueue_style( 'astra-child-style', get_stylesheet_directory_uri() . '/style.css', array('astra-theme-css'), '1.0' );
    wp_enqueue_style( 'astra-child-extra', get_stylesheet_directory_uri() . '/extra.css', array('astra-child-style'), '1.0' );
}

// ====================
// Schema Markup
// ====================

add_action('wp_head', 'workspace_kit_schema');
function workspace_kit_schema() {
    // Website schema
    $website_schema = [
        '@context' => 'https://schema.org',
        '@type' => 'WebSite',
        'name' => get_bloginfo('name'),
        'url' => get_site_url(),
        'potentialAction' => [
            '@type' => 'SearchAction',
            'target' => get_site_url() . '/?s={search_term_string}',
            'query-input' => 'required name=search_term_string'
        ]
    ];

    // Organization schema
    $org_schema = [
        '@context' => 'https://schema.org',
        '@type' => 'Organization',
        'name' => get_bloginfo('name'),
        'url' => get_site_url(),
        'logo' => get_site_url() . '/wp-content/uploads/logo.png',
        'sameAs' => []
    ];

    // Breadcrumb schema
    if (is_single() || is_page()) {
        global $post;
        $breadcrumb = [
            '@context' => 'https://schema.org',
            '@type' => 'BreadcrumbList',
            'itemListElement' => [
                [
                    '@type' => 'ListItem',
                    'position' => 1,
                    'name' => 'Home',
                    'item' => get_site_url()
                ],
                [
                    '@type' => 'ListItem',
                    'position' => 2,
                    'name' => get_the_title($post),
                    'item' => get_permalink($post)
                ]
            ]
        ];
        echo '<script type="application/ld+json">' . json_encode($breadcrumb, JSON_UNESCAPED_SLASHES) . '</script>';
    }

    echo '<script type="application/ld+json">' . json_encode($website_schema, JSON_UNESCAPED_SLASHES) . '</script>';
    echo '<script type="application/ld+json">' . json_encode($org_schema, JSON_UNESCAPED_SLASHES) . '</script>';
}

// BlogPosting schema for posts
add_action('wp_head', 'workspace_kit_blogposting_schema');
function workspace_kit_blogposting_schema() {
    if (!is_single()) return;

    global $post;
    $author = get_the_author_meta('display_name', $post->post_author);
    $image = get_the_post_thumbnail_url($post, 'full');
    $published = get_the_date('c');
    $modified = get_the_modified_date('c');

    $schema = [
        '@context' => 'https://schema.org',
        '@type' => 'BlogPosting',
        'headline' => get_the_title(),
        'description' => wp_strip_all_tags(get_the_excerpt()),
        'image' => $image,
        'datePublished' => $published,
        'dateModified' => $modified,
        'author' => [
            '@type' => 'Person',
            'name' => $author
        ],
        'publisher' => [
            '@type' => 'Organization',
            'name' => get_bloginfo('name'),
            'logo' => [
                '@type' => 'ImageObject',
                'url' => get_site_url() . '/wp-content/uploads/logo.png'
            ]
        ],
        'mainEntityOfPage' => [
            '@type' => 'WebPage',
            '@id' => get_permalink()
        ]
    ];

    echo '<script type="application/ld+json">' . json_encode($schema, JSON_UNESCAPED_SLASHES) . '</script>';
}
add_action('wp_footer', 'amazon_associates_disclosure');
function amazon_associates_disclosure() {
    echo '<div style="text-align:center;padding:1rem;font-size:0.9rem;color:#888;border-top:1px solid #eee;margin-top:2rem;">
    As an Amazon Associate I earn from qualifying purchases.
    </div>';
}
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="https://workplace-kit.co.uk/wp-sitemap-index.xsl" ?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap><loc>https://workplace-kit.co.uk/wp-sitemap-posts-post-1.xml</loc></sitemap><sitemap><loc>https://workplace-kit.co.uk/wp-sitemap-posts-page-1.xml</loc></sitemap><sitemap><loc>https://workplace-kit.co.uk/wp-sitemap-taxonomies-category-1.xml</loc></sitemap><sitemap><loc>https://workplace-kit.co.uk/wp-sitemap-users-1.xml</loc></sitemap></sitemapindex>
