/* -------------------------------------------------------
* 6) FULL SEO + SOCIAL + GOOGLE NEWS (tek JSON-LD @graph)
* [Kritik] Dosya 2 kez include edilse bile TEK basar
* ----------------------------------------------------- */
if (!function_exists('bdb_output_jsonld')) {
function bdb_output_jsonld() {
// Global kilit (ne olursa olsun bir kere)
if (!empty($GLOBALS['bdb_jsonld_printed'])) return;
$GLOBALS['bdb_jsonld_printed'] = 1;
if (is_admin() || is_feed()) return;
global $post;
$site_url = home_url('/');
$site_name = get_bloginfo('name') ?: 'Bursada Biz';
$graph = [];
// Organization
$graph[] = [
'@type' => 'Organization',
'@id' => $site_url . '#organization',
'name' => $site_name,
'url' => $site_url,
'logo' => [
'@type' => 'ImageObject',
'@id' => $site_url . '#logo',
'url' => bdb_logo_url(),
],
'sameAs' => [
'https://www.facebook.com/bursadabiz16/',
],
];
// WebSite
$graph[] = [
'@type' => 'WebSite',
'@id' => $site_url . '#website',
'url' => $site_url,
'name' => $site_name,
'publisher' => ['@id' => $site_url . '#organization'],
'potentialAction' => [
'@type' => 'SearchAction',
'target' => $site_url . '?s={search_term_string}',
'query-input' => 'required name=search_term_string',
],
'inLanguage' => 'tr-TR',
];
// Post detayları + sosyal meta sadece postta
if (is_singular('post')) {
$post_id = get_queried_object_id();
$title = wp_strip_all_tags(get_the_title($post_id));
$desc = get_the_excerpt($post_id) ? wp_strip_all_tags(get_the_excerpt($post_id)) : '';
$url = get_permalink($post_id);
$thumb_url = get_the_post_thumbnail_url($post_id, 'full');
$final_image = $thumb_url ? $thumb_url : bdb_logo_url();
// OG + Twitter
echo "\n";
echo '' . "\n";
echo '' . "\n";
echo '' . "\n";
echo '' . "\n";
echo '' . "\n";
echo '' . "\n";
echo '' . "\n";
echo '' . "\n";
echo '' . "\n";
echo "\n";
// kategori
$cats = get_the_category($post_id);
$cat_name = !empty($cats) ? $cats[0]->name : 'Haber';
$cat_link = !empty($cats) ? get_category_link($cats[0]->term_id) : $site_url;
$headline = mb_substr($title, 0, 110);
// WebPage
$graph[] = [
'@type' => 'WebPage',
'@id' => $url . '#webpage',
'url' => $url,
'name' => $headline,
'isPartOf' => ['@id' => $site_url . '#website'],
'breadcrumb' => ['@id' => $url . '#breadcrumb'],
'inLanguage' => 'tr-TR',
];
// Breadcrumb
$graph[] = [
'@type' => 'BreadcrumbList',
'@id' => $url . '#breadcrumb',
'itemListElement' => [
['@type' => 'ListItem', 'position' => 1, 'name' => $site_name, 'item' => $site_url],
['@type' => 'ListItem', 'position' => 2, 'name' => $cat_name, 'item' => $cat_link],
['@type' => 'ListItem', 'position' => 3, 'name' => $headline, 'item' => $url],
],
];
// NewsArticle
$graph[] = [
'@type' => 'NewsArticle',
'@id' => $url . '#newsarticle',
'mainEntityOfPage' => ['@id' => $url . '#webpage'],
'headline' => $headline,
'image' => [$final_image],
'datePublished' => get_the_date(DATE_W3C, $post_id),
'dateModified' => get_the_modified_date(DATE_W3C, $post_id),
'author' => [
'@type' => 'Person',
'name' => get_the_author_meta('display_name', $post->post_author),
'url' => get_author_posts_url($post->post_author),
],
'publisher' => ['@id' => $site_url . '#organization'],
'description' => $desc,
'articleSection' => !empty($cats) ? array_values(array_map(function($c){ return $c->name; }, $cats)) : null,
'isAccessibleForFree' => true,
'hasPart' => [
'@type' => 'WebPageElement',
'isAccessibleForFree' => true,
'cssSelector' => 'article, .post-content, .entry-content, .post-text, .post-detail, .single-post-content, #content, main',
],
];
}
$schema = [
'@context' => 'https://schema.org',
'@graph' => $graph,
];
echo '' . "\n";
}
}
// Hook'u sadece 1 kere ekle (dosya 2 kere include edilse bile)
if (!has_action('wp_head', 'bdb_output_jsonld')) {
add_action('wp_head', 'bdb_output_jsonld', 20);
}
/* -------------------------------------------------------
* 6) FULL SEO + SOCIAL + GOOGLE NEWS (tek JSON-LD @graph)
* [Kritik] Dosya 2 kez include edilse bile TEK basar
* ----------------------------------------------------- */
if (!function_exists('bdb_output_jsonld')) {
function bdb_output_jsonld() {
// Global kilit (ne olursa olsun bir kere)
if (!empty($GLOBALS['bdb_jsonld_printed'])) return;
$GLOBALS['bdb_jsonld_printed'] = 1;
if (is_admin() || is_feed()) return;
global $post;
$site_url = home_url('/');
$site_name = get_bloginfo('name') ?: 'Bursada Biz';
$graph = [];
// Organization
$graph[] = [
'@type' => 'Organization',
'@id' => $site_url . '#organization',
'name' => $site_name,
'url' => $site_url,
'logo' => [
'@type' => 'ImageObject',
'@id' => $site_url . '#logo',
'url' => bdb_logo_url(),
],
'sameAs' => [
'https://www.facebook.com/bursadabiz16/',
],
];
// WebSite
$graph[] = [
'@type' => 'WebSite',
'@id' => $site_url . '#website',
'url' => $site_url,
'name' => $site_name,
'publisher' => ['@id' => $site_url . '#organization'],
'potentialAction' => [
'@type' => 'SearchAction',
'target' => $site_url . '?s={search_term_string}',
'query-input' => 'required name=search_term_string',
],
'inLanguage' => 'tr-TR',
];
// Post detayları + sosyal meta sadece postta
if (is_singular('post')) {
$post_id = get_queried_object_id();
$title = wp_strip_all_tags(get_the_title($post_id));
$desc = get_the_excerpt($post_id) ? wp_strip_all_tags(get_the_excerpt($post_id)) : '';
$url = get_permalink($post_id);
$thumb_url = get_the_post_thumbnail_url($post_id, 'full');
$final_image = $thumb_url ? $thumb_url : bdb_logo_url();
// OG + Twitter
echo "\n";
echo '' . "\n";
echo '' . "\n";
echo '' . "\n";
echo '' . "\n";
echo '' . "\n";
echo '' . "\n";
echo '' . "\n";
echo '' . "\n";
echo '' . "\n";
echo "\n";
// kategori
$cats = get_the_category($post_id);
$cat_name = !empty($cats) ? $cats[0]->name : 'Haber';
$cat_link = !empty($cats) ? get_category_link($cats[0]->term_id) : $site_url;
$headline = mb_substr($title, 0, 110);
// WebPage
$graph[] = [
'@type' => 'WebPage',
'@id' => $url . '#webpage',
'url' => $url,
'name' => $headline,
'isPartOf' => ['@id' => $site_url . '#website'],
'breadcrumb' => ['@id' => $url . '#breadcrumb'],
'inLanguage' => 'tr-TR',
];
// Breadcrumb
$graph[] = [
'@type' => 'BreadcrumbList',
'@id' => $url . '#breadcrumb',
'itemListElement' => [
['@type' => 'ListItem', 'position' => 1, 'name' => $site_name, 'item' => $site_url],
['@type' => 'ListItem', 'position' => 2, 'name' => $cat_name, 'item' => $cat_link],
['@type' => 'ListItem', 'position' => 3, 'name' => $headline, 'item' => $url],
],
];
// NewsArticle
$graph[] = [
'@type' => 'NewsArticle',
'@id' => $url . '#newsarticle',
'mainEntityOfPage' => ['@id' => $url . '#webpage'],
'headline' => $headline,
'image' => [$final_image],
'datePublished' => get_the_date(DATE_W3C, $post_id),
'dateModified' => get_the_modified_date(DATE_W3C, $post_id),
'author' => [
'@type' => 'Person',
'name' => get_the_author_meta('display_name', $post->post_author),
'url' => get_author_posts_url($post->post_author),
],
'publisher' => ['@id' => $site_url . '#organization'],
'description' => $desc,
'articleSection' => !empty($cats) ? array_values(array_map(function($c){ return $c->name; }, $cats)) : null,
'isAccessibleForFree' => true,
'hasPart' => [
'@type' => 'WebPageElement',
'isAccessibleForFree' => true,
'cssSelector' => 'article, .post-content, .entry-content, .post-text, .post-detail, .single-post-content, #content, main',
],
];
}
$schema = [
'@context' => 'https://schema.org',
'@graph' => $graph,
];
echo '' . "\n";
}
}
// Hook'u sadece 1 kere ekle (dosya 2 kere include edilse bile)
if (!has_action('wp_head', 'bdb_output_jsonld')) {
add_action('wp_head', 'bdb_output_jsonld', 20);
}