/* ======================================================
🔥 AI SUMMARY V10 TOPIKSERU (FIXED SAFE VERSION)
======================================================*/
function portal_ai_summary_v10($content) {
if (!is_singular('post') || is_admin()) return $content;
global $post;
if (empty($post->post_content)) return $content;
$text = wp_strip_all_tags(strip_shortcodes($post->post_content));
/* ===============================
CLEAN NOISE
===============================*/
$text = preg_replace('/^\s*.*?\s[–\-]\s+/u', '', $text);
$text = preg_replace('/^[A-Za-z\s\.]+,\s*[A-Za-z\s]+\s[–\-]\s+/u', '', $text);
$text = preg_replace('/Topikseru\.com/iu', '', $text);
$text = preg_replace('/https?:\/\/\S+/iu', '', $text);
$text = preg_replace('/\s+/u', ' ', $text);
$text = trim($text);
/* ===============================
SPLIT SENTENCE
===============================*/
$sentences = preg_split('/(?<=[.?!])\s+/u', $text);
if (empty($sentences) || count($sentences) < 2) {
return $content;
}
$sentences = array_values(array_filter(array_map('trim', $sentences)));
/* ===============================
FILTER DUPLIKAT
===============================*/
$seen = [];
$pool = [];
foreach ($sentences as $s) {
if (!$s) continue;
$s = preg_replace('/^[\-•\–\—"\']+\s*/u', '', $s);
$s = trim(preg_replace('/\s+/u', ' ', $s));
if (mb_strlen($s) < 50) continue;
$hash = md5(mb_strtolower($s));
if (isset($seen[$hash])) continue;
$seen[$hash] = true;
$pool[] = $s;
if (count($pool) >= 3) break;
}
if (empty($pool)) return $content;
/* ===============================
BUILD HTML
===============================*/
$html = '
';
foreach ($pool as $point) {
$html .= '- ' . esc_html($point) . '
';
}
$html .= '
Disclaimer: Ringkasan ini dibuat menggunakan teknologi Artificial Intelligence (AI)
';
return $html . $content;
}
add_filter('the_content', 'portal_ai_summary_v10', 1);/* ======================================================
INTERNAL LINK (FIXED - TIDAK TERBLOK SUMMARY)
======================================================*/
function portal_internal_link($content) {
if (!is_single() || is_admin()) return $content;
global $post;
$targets = [];
foreach ((array)get_the_category($post->ID) as $cat) {
$targets[] = ['k'=>$cat->name,'u'=>get_category_link($cat->term_id)];
}
foreach ((array)get_the_tags($post->ID) as $tag) {
if (str_word_count($tag->name) < 2) continue;
$targets[] = ['k'=>$tag->name,'u'=>get_tag_link($tag->term_id)];
}
$related = get_posts([
'post_type'=>'post',
'posts_per_page'=>3,
'post__not_in'=>[$post->ID]
]);
foreach ($related as $r) {
$targets[] = [
'k'=>get_the_title($r->ID),
'u'=>get_permalink($r->ID)
];
}
$count = 0;
foreach ($targets as $t) {
if ($count >= 5) break;
$content = preg_replace(
'/\b('.preg_quote($t['k'],'/').')\b(?![^<]*>)/iu',
'$1',
$content,
1,
$replaced
);
if (!empty($replaced)) $count++;
}
return $content;
}
add_filter('the_content', 'portal_internal_link', 15);/* ======================================================
SEO + OG CLEAN
======================================================*/
add_action('wp_head', function () {
if (!is_single()) return;
global $post;
$title = get_the_title($post->ID);
$desc = wp_trim_words(strip_tags($post->post_content), 28);
$img = get_the_post_thumbnail_url($post->ID, 'full');
echo '';
echo '';
echo '';
echo '';
echo '';
}, 5);
/* ======================================================
SCHEMA
======================================================*/
add_action('wp_head', function () {
if (!is_single()) return;
global $post;
$schema = [
"@context"=>"https://schema.org",
"@type"=>"NewsArticle",
"headline"=>get_the_title($post->ID),
"datePublished"=>get_the_date('c'),
"dateModified"=>get_the_modified_date('c'),
"mainEntityOfPage"=>get_permalink($post->ID)
];
echo '';
}, 6);/* ======================================================
OPEN GRAPH
======================================================*/
add_action('wp_head', function () {
if (!is_single()) return;
global $post;
$title = get_the_title($post->ID);
$desc = wp_trim_words(strip_tags($post->post_content), 28);
$url = get_permalink($post->ID);
$img = get_the_post_thumbnail_url($post->ID, 'full');
if (!$img) {
$img = 'https://via.placeholder.com/1200x630.png?text=No+Image';
}
echo '';
echo '';
echo '';
echo '';
echo '';
echo '';
}, 1);
Inspektorat Jenderal Kemendagri Archives - Topikseru
Portal Berita Terkini dari Medan untuk Sumatera Utara
Wed, 06 Nov 2024 00:22:55 +0000
id
hourly
1
https://wordpress.org/?v=7.0
https://topikseru.com/wp-content/uploads/2026/02/cropped-cropped-cropped-LOGO-UTAMA_TOPIKSERU-32x32.png
Inspektorat Jenderal Kemendagri Archives - Topikseru
32
32
-
Kemendagri Evaluasi Kinerja Pj Bupati Sugeng pada Triwulan IV
https://topikseru.com/daerah/kemendagri-evaluasi-kinerja-pj-bupati-sugeng-pada-triwulan-iv/
https://topikseru.com/daerah/kemendagri-evaluasi-kinerja-pj-bupati-sugeng-pada-triwulan-iv/#respond
Fri, 01 Nov 2024 08:59:16 +0000
https://topikseru.com/?p=6959
TOPIKSERU.COM, JAKARTA – Penjabat Bupati Tapanuli Tengah, Sugeng...
The post Kemendagri Evaluasi Kinerja Pj Bupati Sugeng pada Triwulan IV appeared first on Topikseru.
]]>
https://topikseru.com/daerah/kemendagri-evaluasi-kinerja-pj-bupati-sugeng-pada-triwulan-iv/feed/
0