feat(single-sidebar-seo): custom dashboard sidebar, intra & inter-post paging, dan native schema seo

This commit is contained in:
Mas Budi Kusuma
2026-09-15 23:59:21 +07:00
parent 0d680b2fa5
commit ff3d851f1e
6 changed files with 741 additions and 136 deletions
+119 -15
View File
@@ -43,16 +43,23 @@ add_action( 'admin_bar_menu', 'edukarsa_admin_bar_shortcut', 80 );
function edukarsa_register_settings() {
$options = array(
// Desain & Fitur Global
'edukarsa_font_choice', 'edukarsa_primary_color', 'edukarsa_secondary_color', 'edukarsa_heading_color',
'edukarsa_tampil_bilingual', 'edukarsa_lang_en', 'edukarsa_lang_ar', 'edukarsa_lang_zh', 'edukarsa_lang_ja',
'edukarsa_tampil_accessibility',
// Halaman Depan Seksi
'edukarsa_tampil_slider', 'edukarsa_tampil_stats', 'edukarsa_tampil_about', 'edukarsa_tampil_milestone', 'edukarsa_tampil_program', 'edukarsa_tampil_video', 'edukarsa_tampil_keunggulan', 'edukarsa_tampil_cta', 'edukarsa_tampil_faq', 'edukarsa_tampil_news',
'edukarsa_header_logo',
// Label Kustom Frontend
'edukarsa_milestone_subtitle', 'edukarsa_milestone_title',
'edukarsa_program_subtitle', 'edukarsa_program_title',
'edukarsa_keunggulan_subtitle', 'edukarsa_keunggulan_title',
'edukarsa_faq_subtitle', 'edukarsa_faq_title',
'edukarsa_news_title',
// Data Beranda
'edukarsa_stat1_angka', 'edukarsa_stat1_label', 'edukarsa_stat1_desc', 'edukarsa_stat1_icon',
'edukarsa_stat2_angka', 'edukarsa_stat2_label', 'edukarsa_stat2_desc', 'edukarsa_stat2_icon',
'edukarsa_stat3_angka', 'edukarsa_stat3_label', 'edukarsa_stat3_desc', 'edukarsa_stat3_icon',
@@ -60,6 +67,24 @@ function edukarsa_register_settings() {
'edukarsa_video1_thumb', 'edukarsa_video1_url', 'edukarsa_video2_thumb', 'edukarsa_video2_url',
'edukarsa_mid_bg_image', 'edukarsa_mid_bg_color',
'edukarsa_cta_bg', 'edukarsa_cta_title', 'edukarsa_cta_btn_teks', 'edukarsa_cta_btn_url',
// KUSTOMISASI SIDEBAR (Bebas Menu Widget)
'edukarsa_sidebar_tampil_search',
'edukarsa_sidebar_tampil_cta',
'edukarsa_sidebar_cta_badge',
'edukarsa_sidebar_cta_title',
'edukarsa_sidebar_cta_desc',
'edukarsa_sidebar_cta_btn_text',
'edukarsa_sidebar_cta_btn_url',
'edukarsa_sidebar_tampil_recent',
'edukarsa_sidebar_recent_title',
'edukarsa_sidebar_recent_count',
'edukarsa_sidebar_tampil_cats',
'edukarsa_sidebar_cats_title',
'edukarsa_sidebar_banner_img',
'edukarsa_sidebar_banner_url',
// Footer & WA
'edukarsa_footer_logo', 'edukarsa_footer_desc', 'edukarsa_footer_alamat', 'edukarsa_footer_telp', 'edukarsa_footer_email', 'edukarsa_footer_jam',
'edukarsa_wa_btn_text', 'edukarsa_wa_default_msg',
'edukarsa_tampil_fb', 'edukarsa_footer_fb', 'edukarsa_tampil_ig', 'edukarsa_footer_ig', 'edukarsa_tampil_yt', 'edukarsa_footer_yt', 'edukarsa_tampil_tiktok', 'edukarsa_footer_tiktok', 'edukarsa_tampil_x', 'edukarsa_footer_x',
@@ -156,7 +181,6 @@ function edukarsa_settings_page_html() {
</div>
</div>
<!-- Opsi Fitur Bahasa -->
<div class="switch-row" style="margin-top: 18px; background: #eef2ff; border-color: #c7d2fe;">
<div class="switch-label-wrap">
<div class="switch-label" style="color: #3730a3;">
@@ -189,7 +213,6 @@ function edukarsa_settings_page_html() {
</div>
</div>
<!-- Opsi Fitur Aksesibilitas Disabilitas -->
<div class="switch-row" style="background: #f0fdf4; border-color: #bbf7d0;">
<div class="switch-label-wrap">
<div class="switch-label" style="color: #166534;">
@@ -393,27 +416,109 @@ function edukarsa_settings_page_html() {
</div>
</div>
<!-- 6. Footer, Kontak & Floating WhatsApp -->
<!-- 6. KUSTOMISASI SIDEBAR (BARU: PENGGANTI WIDGET WP) -->
<div class="edukarsa-card">
<div class="edukarsa-card-header"><h2>📞 6. Footer, Kontak & Tombol WhatsApp</h2></div>
<div class="edukarsa-card-header">
<h2>📑 6. Pengaturan Sidebar (Artikel & Halaman)</h2>
</div>
<div class="edukarsa-card-body">
<p style="font-size: 13px; color: #64748b; margin-top:0; margin-bottom: 15px;">
Kelola komponen sidebar artikel secara native tanpa perlu menu Widget WordPress.
</p>
<!-- Toggle Komponen Sidebar -->
<div class="switch-row-inline">
<div class="switch-row">
<span class="switch-label">Kotak Pencarian Cepat</span>
<label class="edukarsa-switch">
<input type="checkbox" name="edukarsa_sidebar_tampil_search" value="1" <?php checked(1, get_option('edukarsa_sidebar_tampil_search', 1)); ?>>
<span class="slider-round"></span>
</label>
</div>
<div class="switch-row">
<span class="switch-label">Kartu Mini CTA Pendaftaran</span>
<label class="edukarsa-switch">
<input type="checkbox" class="section-toggle" data-target="#sidebar-cta-box" name="edukarsa_sidebar_tampil_cta" value="1" <?php checked(1, get_option('edukarsa_sidebar_tampil_cta', 1)); ?>>
<span class="slider-round"></span>
</label>
</div>
</div>
<!-- Detail Form Mini CTA Sidebar -->
<div id="sidebar-cta-box" class="stat-config-box" style="margin-bottom: 15px;">
<h4>Konfigurasi Mini CTA Sidebar</h4>
<div class="form-grid-2">
<div class="form-field-group"><label>Badge Judul CTA</label><input type="text" name="edukarsa_sidebar_cta_badge" value="<?php echo esc_attr(get_option('edukarsa_sidebar_cta_badge', 'Penerimaan Siswa/Mhs')); ?>"></div>
<div class="form-field-group"><label>Judul Ajakan</label><input type="text" name="edukarsa_sidebar_cta_title" value="<?php echo esc_attr(get_option('edukarsa_sidebar_cta_title', 'Siap Berprestasi Bersama Kami?')); ?>"></div>
</div>
<div class="form-field-group"><label>Deskripsi Singkat</label><textarea name="edukarsa_sidebar_cta_desc" rows="2"><?php echo esc_textarea(get_option('edukarsa_sidebar_cta_desc', 'Daftarkan diri Anda sekarang dan raih peluang beasiswa unggulan.')); ?></textarea></div>
<div class="form-grid-2">
<div class="form-field-group" style="margin-bottom:0;"><label>Teks Tombol</label><input type="text" name="edukarsa_sidebar_cta_btn_text" value="<?php echo esc_attr(get_option('edukarsa_sidebar_cta_btn_text', 'Daftar Sekarang')); ?>"></div>
<div class="form-field-group" style="margin-bottom:0;"><label>Tautan URL Tombol</label><input type="text" name="edukarsa_sidebar_cta_btn_url" value="<?php echo esc_attr(get_option('edukarsa_sidebar_cta_btn_url', '#')); ?>"></div>
</div>
</div>
<div class="switch-row-inline">
<div class="switch-row">
<span class="switch-label">Daftar Berita Terbaru</span>
<label class="edukarsa-switch">
<input type="checkbox" class="section-toggle" data-target="#sidebar-recent-box" name="edukarsa_sidebar_tampil_recent" value="1" <?php checked(1, get_option('edukarsa_sidebar_tampil_recent', 1)); ?>>
<span class="slider-round"></span>
</label>
</div>
<div class="switch-row">
<span class="switch-label">Daftar Kategori Berita</span>
<label class="edukarsa-switch">
<input type="checkbox" class="section-toggle" data-target="#sidebar-cats-box" name="edukarsa_sidebar_tampil_cats" value="1" <?php checked(1, get_option('edukarsa_sidebar_tampil_cats', 1)); ?>>
<span class="slider-round"></span>
</label>
</div>
</div>
<div id="sidebar-recent-box" class="form-grid-2" style="background:#f8fafc; padding:15px; border:1px solid #e2e8f0; border-radius:8px; margin-bottom:15px;">
<div class="form-field-group" style="margin-bottom:0;"><label>Judul Seksi Berita Terkini</label><input type="text" name="edukarsa_sidebar_recent_title" value="<?php echo esc_attr(get_option('edukarsa_sidebar_recent_title', 'Warta Terkini')); ?>"></div>
<div class="form-field-group" style="margin-bottom:0;"><label>Jumlah Pos Ditampilkan</label><input type="number" name="edukarsa_sidebar_recent_count" value="<?php echo esc_attr(get_option('edukarsa_sidebar_recent_count', 5)); ?>" min="1" max="10"></div>
</div>
<div id="sidebar-cats-box" class="form-field-group" style="background:#f8fafc; padding:15px; border:1px solid #e2e8f0; border-radius:8px; margin-bottom:15px;">
<label>Judul Seksi Kategori</label>
<input type="text" name="edukarsa_sidebar_cats_title" value="<?php echo esc_attr(get_option('edukarsa_sidebar_cats_title', 'Kategori Pilihan')); ?>">
</div>
<!-- Banner Iklan / Pengumuman Khusus Sidebar -->
<div class="form-grid-2">
<div class="form-field-group">
<label>Banner Poster Sidebar (Opsional)</label>
<div class="input-with-button">
<input type="text" id="edukarsa_sidebar_banner_img" name="edukarsa_sidebar_banner_img" value="<?php echo esc_url(get_option('edukarsa_sidebar_banner_img')); ?>" placeholder="https://...">
<button type="button" class="button btn-upload" data-target="#edukarsa_sidebar_banner_img">Pilih</button>
</div>
</div>
<div class="form-field-group">
<label>Tautan Klik Banner Poster</label>
<input type="text" name="edukarsa_sidebar_banner_url" value="<?php echo esc_attr(get_option('edukarsa_sidebar_banner_url')); ?>" placeholder="https://...">
</div>
</div>
</div>
</div>
<!-- 7. Footer, Kontak & WhatsApp -->
<div class="edukarsa-card">
<div class="edukarsa-card-header"><h2>📞 7. Footer, Kontak & Tombol WhatsApp</h2></div>
<div class="edukarsa-card-body">
<!-- Opsi Tombol WhatsApp Melayang -->
<div style="background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 8px; padding: 16px 20px; margin-bottom: 20px;">
<h4 style="margin: 0 0 12px; font-size: 13px; color: #166534; display: flex; align-items: center; gap: 6px;">
💬 Kustomisasi Tombol WhatsApp Melayang (Floating Button)
</h4>
<h4 style="margin: 0 0 12px; font-size: 13px; color: #166534;">💬 Kustomisasi Tombol WhatsApp Melayang</h4>
<div class="form-grid-2">
<div class="form-field-group" style="margin-bottom: 0;">
<label>Label / Tulisan Tombol</label>
<input type="text" name="edukarsa_wa_btn_text" value="<?php echo esc_attr(get_option('edukarsa_wa_btn_text', 'Tanya PMB')); ?>" placeholder="cth: Hubungi Kami / Tanya PMB / Konsultasi">
<input type="text" name="edukarsa_wa_btn_text" value="<?php echo esc_attr(get_option('edukarsa_wa_btn_text', 'Tanya PMB')); ?>">
</div>
<div class="form-field-group" style="margin-bottom: 0;">
<label>Template Pesan Awal Otomatis</label>
<input type="text" name="edukarsa_wa_default_msg" value="<?php echo esc_attr(get_option('edukarsa_wa_default_msg', 'Halo Admin EduKarsa, saya ingin bertanya informasi lebih lanjut.')); ?>" placeholder="cth: Halo Admin, saya ingin menanyakan...">
<input type="text" name="edukarsa_wa_default_msg" value="<?php echo esc_attr(get_option('edukarsa_wa_default_msg', 'Halo Admin EduKarsa, saya ingin bertanya informasi lebih lanjut.')); ?>">
</div>
</div>
<p class="description" style="margin-top: 8px; font-size: 12px; color: #15803d;">Nomor WhatsApp otomatis diambil dari kolom Nomor Telepon di bawah.</p>
</div>
<div class="form-grid-2">
@@ -426,12 +531,12 @@ function edukarsa_settings_page_html() {
</div>
<div class="form-field-group">
<label>Jam Operasional / Layanan (Multi-baris / Bebas Tekan Enter)</label>
<textarea name="edukarsa_footer_jam" rows="3" placeholder="Senin – Kamis: 08.00 – 16.00 WIB&#10;Jumat: 08.00 – 11.30 WIB&#10;Sabtu: 08.00 – 12.00 WIB"><?php echo esc_textarea(get_option('edukarsa_footer_jam', "Senin – Jumat: 08.00 – 16.00 WIB\nSabtu: 08.00 – 12.00 WIB")); ?></textarea>
<textarea name="edukarsa_footer_jam" rows="3"><?php echo esc_textarea(get_option('edukarsa_footer_jam', "Senin – Jumat: 08.00 – 16.00 WIB\nSabtu: 08.00 – 12.00 WIB")); ?></textarea>
</div>
</div>
<div class="form-field-group">
<label>Deskripsi Singkat Kampus / Visi Ringkas (Kolom 1)</label>
<label>Deskripsi Singkat Kampus / Visi Ringkas</label>
<textarea name="edukarsa_footer_desc" rows="3"><?php echo esc_textarea(get_option('edukarsa_footer_desc', 'Institusi pendidikan terakreditasi unggul yang berdedikasi mencetak generasi berkarakter cerdas, kompetitif, dan berintegritas.')); ?></textarea>
</div>
@@ -445,7 +550,6 @@ function edukarsa_settings_page_html() {
<div class="form-field-group"><label>Teks Hak Cipta (Copyright Bar)</label><input type="text" name="edukarsa_footer_copyright" value="<?php echo esc_attr(get_option('edukarsa_footer_copyright', 'EduKarsa University. All Rights Reserved.')); ?>"></div>
<h4 style="margin: 25px 0 12px; font-size:14px; color:#0b4a8e; border-bottom:1px solid #e2e8f0; padding-bottom:8px;">Jaringan Media Sosial Resmi</h4>
<div class="switch-row"><span class="switch-label">Facebook</span><div style="display:flex; align-items:center; gap:12px; width:70%;"><input type="text" name="edukarsa_footer_fb" value="<?php echo esc_attr(get_option('edukarsa_footer_fb')); ?>" placeholder="https://facebook.com/..." style="flex-grow:1; border:1px solid #cbd5e1; border-radius:6px; padding:6px 10px;"><label class="edukarsa-switch"><input type="checkbox" name="edukarsa_tampil_fb" value="1" <?php checked(1, get_option('edukarsa_tampil_fb', 1)); ?>><span class="slider-round"></span></label></div></div>
<div class="switch-row"><span class="switch-label">Instagram</span><div style="display:flex; align-items:center; gap:12px; width:70%;"><input type="text" name="edukarsa_footer_ig" value="<?php echo esc_attr(get_option('edukarsa_footer_ig')); ?>" placeholder="https://instagram.com/..." style="flex-grow:1; border:1px solid #cbd5e1; border-radius:6px; padding:6px 10px;"><label class="edukarsa-switch"><input type="checkbox" name="edukarsa_tampil_ig" value="1" <?php checked(1, get_option('edukarsa_tampil_ig', 1)); ?>><span class="slider-round"></span></label></div></div>
<div class="switch-row"><span class="switch-label">YouTube</span><div style="display:flex; align-items:center; gap:12px; width:70%;"><input type="text" name="edukarsa_footer_yt" value="<?php echo esc_attr(get_option('edukarsa_footer_yt')); ?>" placeholder="https://youtube.com/..." style="flex-grow:1; border:1px solid #cbd5e1; border-radius:6px; padding:6px 10px;"><label class="edukarsa-switch"><input type="checkbox" name="edukarsa_tampil_yt" value="1" <?php checked(1, get_option('edukarsa_tampil_yt', 1)); ?>><span class="slider-round"></span></label></div></div>
+119
View File
@@ -0,0 +1,119 @@
<?php
/**
* Modul Native SEO & Structured Data Schema EduKarsa
* 100% Native tanpa plugin eksternal
*/
function edukarsa_native_seo_tags() {
global $post;
$site_name = get_bloginfo( 'name' );
$site_desc = get_bloginfo( 'description' );
$page_url = is_front_page() ? home_url( '/' ) : get_permalink();
$page_title = wp_get_document_title();
$logo_url = get_option( 'edukarsa_header_logo' );
$seo_desc = $site_desc;
$seo_img = $logo_url;
$og_type = 'website';
if ( is_singular() && ! empty( $post ) ) {
$og_type = 'article';
// Deskripsi otomatis dari excerpt atau cuplikan paragraf pertama
if ( ! empty( $post->post_excerpt ) ) {
$seo_desc = strip_tags( $post->post_excerpt );
} else {
$content_text = strip_shortcodes( $post->post_content );
$content_text = wp_strip_all_tags( $content_text );
$seo_desc = wp_trim_words( $content_text, 25, '...' );
}
// Gambar OpenGraph dari Featured Image
if ( has_post_thumbnail( $post->ID ) ) {
$thumb_id = get_post_thumbnail_id( $post->ID );
$img_data = wp_get_attachment_image_src( $thumb_id, 'large' );
if ( $img_data ) {
$seo_img = $img_data[0];
}
}
}
$seo_desc = esc_attr( trim( preg_replace( '/\s+/', ' ', $seo_desc ) ) );
?>
<!-- Native SEO Metadata EduKarsa -->
<meta name="description" content="<?php echo $seo_desc; ?>">
<link rel="canonical" href="<?php echo esc_url( $page_url ); ?>">
<!-- Open Graph Data (Facebook, WhatsApp, Telegram) -->
<meta property="og:locale" content="<?php echo esc_attr( get_locale() ); ?>">
<meta property="og:type" content="<?php echo esc_attr( $og_type ); ?>">
<meta property="og:title" content="<?php echo esc_attr( $page_title ); ?>">
<meta property="og:description" content="<?php echo $seo_desc; ?>">
<meta property="og:url" content="<?php echo esc_url( $page_url ); ?>">
<meta property="og:site_name" content="<?php echo esc_attr( $site_name ); ?>">
<?php if ( ! empty( $seo_img ) ) : ?>
<meta property="og:image" content="<?php echo esc_url( $seo_img ); ?>">
<meta property="og:image:alt" content="<?php echo esc_attr( $page_title ); ?>">
<?php endif; ?>
<!-- Twitter / X Card Data -->
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="<?php echo esc_attr( $page_title ); ?>">
<meta name="twitter:description" content="<?php echo $seo_desc; ?>">
<?php if ( ! empty( $seo_img ) ) : ?>
<meta name="twitter:image" content="<?php echo esc_url( $seo_img ); ?>">
<?php endif; ?>
<!-- Google Structured Data (JSON-LD Schema) -->
<script type="application/ld+json">
<?php if ( is_singular( 'post' ) ) : ?>
{
"@context": "https://schema.org",
"@type": "NewsArticle",
"headline": "<?php echo esc_js( get_the_title() ); ?>",
"description": "<?php echo esc_js( $seo_desc ); ?>",
"url": "<?php echo esc_url( $page_url ); ?>",
"datePublished": "<?php echo esc_js( get_the_date( 'c' ) ); ?>",
"dateModified": "<?php echo esc_js( get_the_modified_date( 'c' ) ); ?>",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "<?php echo esc_url( $page_url ); ?>"
},
<?php if ( ! empty( $seo_img ) ) : ?>
"image": "<?php echo esc_url( $seo_img ); ?>",
<?php endif; ?>
"author": {
"@type": "Person",
"name": "<?php echo esc_js( get_the_author() ); ?>"
},
"publisher": {
"@type": "EducationalOrganization",
"name": "<?php echo esc_js( $site_name ); ?>",
"logo": {
"@type": "ImageObject",
"url": "<?php echo esc_url( $logo_url ); ?>"
}
}
}
<?php else : ?>
{
"@context": "https://schema.org",
"@type": "EducationalOrganization",
"name": "<?php echo esc_js( $site_name ); ?>",
"url": "<?php echo esc_url( home_url( '/' ) ); ?>",
"description": "<?php echo esc_js( $site_desc ); ?>",
<?php if ( ! empty( $logo_url ) ) : ?>
"logo": "<?php echo esc_url( $logo_url ); ?>",
<?php endif; ?>
"sameAs": [
"<?php echo esc_url( get_option( 'edukarsa_footer_fb' ) ); ?>",
"<?php echo esc_url( get_option( 'edukarsa_footer_ig' ) ); ?>",
"<?php echo esc_url( get_option( 'edukarsa_footer_yt' ) ); ?>"
]
}
<?php endif; ?>
</script>
<?php
}
add_action( 'wp_head', 'edukarsa_native_seo_tags', 1 );