// SEO pilot - structured data for homepage and public articles.
if (
(int) get_current_blog_id() === 5 &&
! is_paged() &&
! is_preview() &&
! is_feed() &&
(
is_front_page() ||
(
is_singular( 'post' ) &&
get_post_status( get_queried_object_id() ) === 'publish' &&
empty( get_post_field( 'post_password', get_queried_object_id() ) )
)
)
) {
$inform_home_url = home_url( '/' );
$inform_organization_id =
'https://cestovani.inform.cz/kontakt/#organization';
$inform_website_id = $inform_home_url . '#website';
$inform_webpage_id = $inform_home_url . '#webpage';
$inform_schema = array(
'@context' => 'https://schema.org',
'@graph' => array(
// Publisher.
array(
'@type' => 'Organization',
'@id' => $inform_organization_id,
'name' => 'Inform Data a.s.',
'legalName' => 'Inform Data a.s.',
'identifier' => array(
'@type' => 'PropertyValue',
'propertyID' => 'ICO',
'value' => '02803101'
),
'vatID' => 'CZ02803101',
'address' => array(
'@type' => 'PostalAddress',
'streetAddress' => 'Orlí 542/27',
'addressLocality' => 'Brno',
'postalCode' => '602 00',
'addressCountry' => 'CZ'
)
),
// Magazine website.
array(
'@type' => 'WebSite',
'@id' => $inform_website_id,
'url' => $inform_home_url,
'name' => get_bloginfo( 'name', 'raw' ),
'description' => get_bloginfo(
'description', 'raw'
),
'inLanguage' => get_bloginfo( 'language' ),
'publisher' => array(
'@id' => $inform_organization_id
)
),
// Homepage.
array(
'@type' => 'WebPage',
'@id' => $inform_webpage_id,
'url' => $inform_home_url,
'name' => get_bloginfo( 'name', 'raw' ),
'description' => get_bloginfo(
'description', 'raw'
),
'inLanguage' => get_bloginfo( 'language' ),
'isPartOf' => array(
'@id' => $inform_website_id
)
)
)
);
// Article structured data.
if ( is_singular( 'post' ) ) {
$inform_post = get_queried_object();
$inform_article_url = wp_get_canonical_url( $inform_post );
$inform_article_url = $inform_article_url ?: get_permalink( $inform_post );
$inform_webpage_id = $inform_article_url . '#webpage';
$inform_article_id = $inform_article_url . '#article';
// Clean text for structured data.
$inform_clean_text = static function ( $text ) {
return trim( wp_strip_all_tags( html_entity_decode(
strip_shortcodes( (string) $text ),
ENT_QUOTES,
'UTF-8'
), true ) );
};
$inform_headline = $inform_clean_text(
get_the_title( $inform_post )
);
$inform_excerpt = $inform_clean_text(
get_the_excerpt( $inform_post )
);
// Replace homepage WebPage with article WebPage.
$inform_schema['@graph'][2] = array(
'@type' => 'WebPage',
'@id' => $inform_webpage_id,
'url' => $inform_article_url,
'name' => $inform_headline,
'inLanguage' => get_bloginfo( 'language' ),
'isPartOf' => array(
'@id' => $inform_website_id
),
'mainEntity' => array(
'@id' => $inform_article_id
)
);
// Article.
$inform_article = array(
'@type' => 'Article',
'@id' => $inform_article_id,
'url' => $inform_article_url,
'headline' => $inform_headline,
'mainEntityOfPage' => array(
'@id' => $inform_webpage_id
),
'publisher' => array(
'@id' => $inform_organization_id
),
'isPartOf' => array(
'@id' => $inform_website_id
),
'inLanguage' => get_bloginfo( 'language' )
);
// Article description.
if ( $inform_excerpt !== '' ) {
$inform_article['description'] = $inform_excerpt;
$inform_schema['@graph'][2]['description'] = $inform_excerpt;
}
// Author.
$inform_author = get_the_author_meta(
'display_name',
$inform_post->post_author
);
if ( $inform_author !== '' ) {
$inform_article['author'] = array(
'@type' => 'Person',
'name' => $inform_clean_text( $inform_author )
);
}
// Publication and modification dates.
$inform_published = get_post_datetime(
$inform_post, 'date', 'gmt'
);
$inform_modified = get_post_datetime(
$inform_post, 'modified', 'gmt'
);
if ( $inform_published ) {
$inform_article['datePublished'] =
$inform_published->format( DATE_W3C );
}
if ( $inform_modified ) {
$inform_article['dateModified'] =
$inform_modified->format( DATE_W3C );
}
// Featured image.
$inform_image = wp_get_attachment_image_src(
get_post_thumbnail_id( $inform_post ),
'full'
);
if ( $inform_image ) {
$inform_article['image'] = array(
'@type' => 'ImageObject',
'url' => $inform_image[0],
'width' => (int) $inform_image[1],
'height' => (int) $inform_image[2]
);
}
// Add Article to the existing graph.
$inform_schema['@graph'][] = $inform_article;
}
$inform_schema_json = wp_json_encode(
$inform_schema,
JSON_UNESCAPED_UNICODE |
JSON_UNESCAPED_SLASHES |
JSON_HEX_TAG |
JSON_HEX_AMP |
JSON_HEX_APOS |
JSON_HEX_QUOT
);
if ( $inform_schema_json !== false ) {
echo '' . "\n";
}
}
?>
škola Louka – Státní správa