// —————————–
// MedyaPress: Hızlı Haber SEO Paketi
// —————————–
// 1️⃣ Otomatik Meta Description ve NewsArticle JSON-LD
add_action(‘wp_head’, function() {
if(!is_single() || ‘post’ !== get_post_type()) return;
global $post;
// 1️⃣ Meta Description
$description = get_post_meta($post->ID, ‘_yoast_wpseo_metadesc’, true); // Rank Math veya Yoast varsa
if(empty($description)) {
$content = wp_strip_all_tags($post->post_content);
$content = trim($content);
if(!empty($content)) {
$paragraphs = preg_split(‘/\r\n|\r|\n/’, $content);
$first_paragraph = ”;
foreach($paragraphs as $p){
$p = trim($p);
if(!empty($p)){
$first_paragraph = $p;
break;
}
}
if(empty($first_paragraph)) $first_paragraph = mb_substr($content, 0, 160, ‘UTF-8’);
$description = mb_substr($first_paragraph, 0, 160, ‘UTF-8’);
if(mb_strlen($first_paragraph, ‘UTF-8’) > 160) $description .= ‘…’;
}
}
if(!empty($description)) {
echo ‘‘ . “\n”;
}
// 2️⃣ NewsArticle JSON-LD
$title = get_the_title($post);
$url = get_permalink($post);
$date = get_the_date(‘c’, $post);
$author = get_the_author_meta(‘display_name’, $post->post_author);
$image = get_the_post_thumbnail_url($post, ‘full’);
if(!$image) $image = ‘https://medya.press/wp-content/uploads/placeholder.jpg’;
?>
5]);
if(is_wp_error($response)) {
error_log(‘Ping hatası: ‘ . $ping_url . ‘ – ‘ . $response->get_error_message());
}
}
}, 10, 2);
