2025-12-09 09:07:07 +00:00
< ? php
/**
* Article Schema Component
* Generates Article structured data for blog posts
*
* Usage :
* $articleData = [
* 'title' => 'Article Title' ,
* 'description' => 'Article description...' ,
* 'datePublished' => '2024-01-15' ,
* 'dateModified' => '2024-01-20' ,
* 'authorName' => 'John Smith' ,
* 'imageUrl' => 'https://example.com/image.jpg' ,
* 'articleUrl' => 'https://example.com/article'
* ];
* include ( $_SERVER [ 'DOCUMENT_ROOT' ] . '/includes/schema/article-schema.php' );
*/
/**
* Generate Article Schema JSON - LD
*
* @ param string $title Article title
* @ param string $description Article description / excerpt
* @ param string $datePublished Publication date ( Y - m - d format )
* @ param string $dateModified Last modified date ( Y - m - d format )
* @ param string $authorName Author ' s name
* @ param string $imageUrl Featured image URL
* @ param string $articleUrl Canonical article URL
* @ param string $category Optional article category
* @ param array $keywords Optional array of keywords
* @ return string JSON - LD script tag
*/
function generateArticleSchema ( $title , $description , $datePublished , $dateModified , $authorName , $imageUrl , $articleUrl , $category = null , $keywords = []) {
2026-03-21 09:48:46 +00:00
$baseUrl = 'https://ukaiautomation.co.uk' ;
2025-12-09 09:07:07 +00:00
$schema = [
'@context' => 'https://schema.org' ,
'@type' => 'Article' ,
'@id' => $articleUrl . '#article' ,
'headline' => $title ,
'description' => $description ,
'url' => $articleUrl ,
'datePublished' => $datePublished . 'T09:00:00+00:00' ,
'dateModified' => $dateModified . 'T09:00:00+00:00' ,
'author' => [
'@type' => 'Person' ,
'name' => $authorName ,
'url' => $baseUrl . '/about'
],
'publisher' => [
'@type' => 'Organization' ,
'@id' => $baseUrl . '/#organization' ,
2026-03-21 09:48:46 +00:00
'name' => 'UK AI Automation' ,
2025-12-09 09:07:07 +00:00
'logo' => [
'@type' => 'ImageObject' ,
'url' => $baseUrl . '/assets/images/ukds-main-logo.png'
]
],
'image' => [
'@type' => 'ImageObject' ,
'url' => $imageUrl ,
'width' => 1200 ,
'height' => 630
],
'mainEntityOfPage' => [
'@type' => 'WebPage' ,
'@id' => $articleUrl
],
'isPartOf' => [
'@type' => 'Blog' ,
'@id' => $baseUrl . '/blog/#blog' ,
2026-03-21 09:48:46 +00:00
'name' => 'UK AI Automation Blog' ,
2025-12-09 09:07:07 +00:00
'publisher' => [
'@id' => $baseUrl . '/#organization'
]
],
'inLanguage' => 'en-GB'
];
// Add category if provided
if ( $category ) {
$schema [ 'articleSection' ] = $category ;
}
// Add keywords if provided
if ( ! empty ( $keywords )) {
$schema [ 'keywords' ] = implode ( ', ' , $keywords );
}
// Add word count estimate based on description length (rough estimate)
$schema [ 'wordCount' ] = max ( 500 , strlen ( $description ) * 5 );
return '<script type="application/ld+json">' . " \n " .
json_encode ( $schema , JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ) . " \n " .
'</script>' ;
}
/**
* Generate BlogPosting Schema ( more specific than Article )
*/
function generateBlogPostingSchema ( $title , $description , $datePublished , $dateModified , $authorName , $imageUrl , $articleUrl , $category = null , $keywords = []) {
2026-03-21 09:48:46 +00:00
$baseUrl = 'https://ukaiautomation.co.uk' ;
2025-12-09 09:07:07 +00:00
$schema = [
'@context' => 'https://schema.org' ,
'@type' => 'BlogPosting' ,
'@id' => $articleUrl . '#blogposting' ,
'headline' => $title ,
'description' => $description ,
'url' => $articleUrl ,
'datePublished' => $datePublished . 'T09:00:00+00:00' ,
'dateModified' => $dateModified . 'T09:00:00+00:00' ,
'author' => [
'@type' => 'Person' ,
'name' => $authorName ,
'url' => $baseUrl . '/about' ,
'worksFor' => [
'@type' => 'Organization' ,
'@id' => $baseUrl . '/#organization'
]
],
'publisher' => [
'@type' => 'Organization' ,
'@id' => $baseUrl . '/#organization' ,
2026-03-21 09:48:46 +00:00
'name' => 'UK AI Automation' ,
2025-12-09 09:07:07 +00:00
'logo' => [
'@type' => 'ImageObject' ,
'url' => $baseUrl . '/assets/images/ukds-main-logo.png' ,
'width' => 300 ,
'height' => 100
]
],
'image' => [
'@type' => 'ImageObject' ,
'url' => $imageUrl ,
'width' => 1200 ,
'height' => 630
],
'mainEntityOfPage' => [
'@type' => 'WebPage' ,
'@id' => $articleUrl
],
'isPartOf' => [
'@type' => 'Blog' ,
'@id' => $baseUrl . '/blog/#blog' ,
2026-03-21 09:48:46 +00:00
'name' => 'UK AI Automation Blog'
2025-12-09 09:07:07 +00:00
],
'inLanguage' => 'en-GB'
];
if ( $category ) {
$schema [ 'articleSection' ] = $category ;
}
if ( ! empty ( $keywords )) {
$schema [ 'keywords' ] = implode ( ', ' , $keywords );
}
return '<script type="application/ld+json">' . " \n " .
json_encode ( $schema , JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ) . " \n " .
'</script>' ;
}
/**
* Author configurations for the site
*/
$authorProfiles = [
2026-03-21 09:48:46 +00:00
'ukaiautomation-team' => [
'name' => 'UK AI Automation Team' ,
2025-12-09 09:07:07 +00:00
'role' => 'Data Intelligence Experts' ,
2026-03-21 09:48:46 +00:00
'description' => 'Our team of certified data professionals and engineers providing expert guidance on AI automation, data pipelines, and business intelligence.'
2025-12-09 09:07:07 +00:00
],
'technical-team' => [
2026-03-21 09:48:46 +00:00
'name' => 'UK AI Automation Technical Team' ,
2025-12-09 09:07:07 +00:00
'role' => 'Senior Data Engineers' ,
'description' => 'Expert engineers specializing in web scraping technologies, data pipelines, and enterprise data solutions.'
],
'compliance-team' => [
2026-03-21 09:48:46 +00:00
'name' => 'UK AI Automation Compliance Team' ,
2025-12-09 09:07:07 +00:00
'role' => 'Data Protection Specialists' ,
'description' => 'Specialists in GDPR compliance, data protection, and regulatory requirements for data collection.'
]
];
// If $articleData is set, output the schema automatically
if ( isset ( $articleData ) && is_array ( $articleData )) {
echo generateArticleSchema (
$articleData [ 'title' ],
$articleData [ 'description' ],
$articleData [ 'datePublished' ],
$articleData [ 'dateModified' ] ? ? $articleData [ 'datePublished' ],
2026-03-21 09:48:46 +00:00
$articleData [ 'authorName' ] ? ? 'UK AI Automation Team' ,
2025-12-09 09:07:07 +00:00
$articleData [ 'imageUrl' ],
$articleData [ 'articleUrl' ],
$articleData [ 'category' ] ? ? null ,
$articleData [ 'keywords' ] ? ? []
);
}