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
+102 -60
View File
@@ -1,66 +1,108 @@
<?php
/**
* Template Sidebar EduKarsa
* Template Sidebar Native EduKarsa
* Dikelola 100% dari Dashboard EduKarsa (Bebas Menu Widget WP)
*/
?>
<aside id="secondary" class="widget-area">
<?php if ( is_active_sidebar( 'sidebar-artikel' ) ) : ?>
<?php dynamic_sidebar( 'sidebar-artikel' ); ?>
<?php else : ?>
<!-- 1. Mini Banner CTA PPDB (Sinkron dengan Theme Settings) -->
<div class="card-style sidebar-widget text-center" style="background: linear-gradient(135deg, var(--primary-color), var(--secondary-color)); color: #fff;">
<h3 class="sidebar-widget-title" style="color: #fff; border-color: rgba(255,255,255,0.3);">Pendaftaran Mahasiswa</h3>
<p style="font-size: 14px; margin-bottom: 20px; opacity: 0.95;">
<?php echo esc_html( get_option('edukarsa_cta_title', 'Siap Bergabung Bersama Kami?') ); ?>
</p>
<a href="<?php echo esc_url( get_option('edukarsa_cta_btn_url', '#') ); ?>" class="btn-primary btn-light" style="padding: 10px 24px; font-size: 14px; display: inline-block;">
<?php echo esc_html( get_option('edukarsa_cta_btn_teks', 'Daftar Sekarang') ); ?>
</a>
</div>
<!-- 2. Berita Terkini -->
<div class="card-style sidebar-widget">
<h3 class="sidebar-widget-title">Berita Terkini</h3>
<ul style="list-style: none; padding: 0; margin: 0;">
<?php
$recent_posts = new WP_Query( array(
'post_type' => 'post',
'posts_per_page' => 5,
'post__not_in' => array( get_the_ID() )
) );
if ( $recent_posts->have_posts() ) :
while ( $recent_posts->have_posts() ) : $recent_posts->the_post();
?>
<li style="margin-bottom: 15px; padding-bottom: 12px; border-bottom: 1px solid #f1f5f9;">
<a href="<?php the_permalink(); ?>" style="color: var(--heading-color); font-weight: 700; font-size: 14px; line-height: 1.4; display: block; margin-bottom: 4px;">
<?php the_title(); ?>
</a>
<span style="font-size: 12px; color: #94a3b8;">📅 <?php echo get_the_date(); ?></span>
</li>
<?php
endwhile;
wp_reset_postdata();
else :
echo '<li style="font-size: 13px; color: #94a3b8;">Belum ada berita lainnya.</li>';
endif;
?>
</ul>
</div>
<!-- 3. Kategori Berita -->
<div class="card-style sidebar-widget">
<h3 class="sidebar-widget-title">Kategori</h3>
<ul style="list-style: none; padding: 0; margin: 0; font-size: 14px;">
<?php
$categories = get_categories();
foreach ( $categories as $category ) {
echo '<li style="margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center;">';
echo '<a href="' . esc_url( get_category_link( $category->term_id ) ) . '" style="color: #64748b; font-weight: 500;">' . esc_html( $category->name ) . '</a>';
echo '<span style="background: #f1f5f9; padding: 2px 8px; border-radius: 20px; font-size: 12px; color: var(--primary-color); font-weight: bold;">' . $category->count . '</span>';
echo '</li>';
}
?>
</ul>
</div>
<aside id="secondary" class="edukarsa-custom-sidebar">
<!-- 1. Pencarian Cepat Native -->
<?php if ( get_option( 'edukarsa_sidebar_tampil_search', 1 ) == 1 ) : ?>
<div class="card-style sidebar-widget">
<form role="search" method="get" class="sidebar-search-form" action="<?php echo esc_url( home_url( '/' ) ); ?>">
<div class="sidebar-search-wrapper">
<input type="search" class="sidebar-search-input" placeholder="Cari warta / informasi..." value="<?php echo get_search_query(); ?>" name="s" required>
<button type="submit" class="sidebar-search-btn" aria-label="Cari">🔍</button>
</div>
</form>
</div>
<?php endif; ?>
<!-- 2. Mini Banner CTA Pendaftaran / PMB -->
<?php if ( get_option( 'edukarsa_sidebar_tampil_cta', 1 ) == 1 ) : ?>
<div class="card-style sidebar-widget sidebar-cta-box text-center">
<span class="sidebar-cta-badge"><?php echo esc_html( get_option( 'edukarsa_sidebar_cta_badge', 'Penerimaan Siswa/Mhs' ) ); ?></span>
<h3 class="sidebar-cta-title"><?php echo esc_html( get_option( 'edukarsa_sidebar_cta_title', 'Siap Berprestasi Bersama Kami?' ) ); ?></h3>
<p class="sidebar-cta-desc">
<?php echo nl2br( esc_html( get_option( 'edukarsa_sidebar_cta_desc', 'Daftarkan diri Anda sekarang dan raih peluang beasiswa unggulan.' ) ) ); ?>
</p>
<a href="<?php echo esc_url( get_option( 'edukarsa_sidebar_cta_btn_url', '#' ) ); ?>" class="btn-primary btn-light sidebar-cta-btn">
<?php echo esc_html( get_option( 'edukarsa_sidebar_cta_btn_text', 'Daftar Sekarang' ) ); ?> &raquo;
</a>
</div>
<?php endif; ?>
<!-- 3. Berita Terkini Dinamis -->
<?php if ( get_option( 'edukarsa_sidebar_tampil_recent', 1 ) == 1 ) : ?>
<div class="card-style sidebar-widget">
<h3 class="sidebar-widget-title"><?php echo esc_html( get_option( 'edukarsa_sidebar_recent_title', 'Warta Terkini' ) ); ?></h3>
<div class="sidebar-recent-list">
<?php
$count = intval( get_option( 'edukarsa_sidebar_recent_count', 5 ) );
$recent_query = new WP_Query( array(
'post_type' => 'post',
'posts_per_page' => $count,
'post__not_in' => array( get_the_ID() )
) );
if ( $recent_query->have_posts() ) :
while ( $recent_query->have_posts() ) : $recent_query->the_post();
?>
<article class="sidebar-recent-item">
<?php if ( has_post_thumbnail() ) : ?>
<a href="<?php the_permalink(); ?>" class="sidebar-recent-thumb">
<?php the_post_thumbnail( 'thumbnail' ); ?>
</a>
<?php endif; ?>
<div class="sidebar-recent-info">
<span class="sidebar-recent-date">📅 <?php echo get_the_date( 'd M Y' ); ?></span>
<h4 class="sidebar-recent-title">
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</h4>
</div>
</article>
<?php
endwhile;
wp_reset_postdata();
else :
echo '<p style="font-size:13px; color:var(--text-muted); margin:0;">Belum ada artikel lainnya.</p>';
endif;
?>
</div>
</div>
<?php endif; ?>
<!-- 4. Daftar Kategori Pilihan -->
<?php if ( get_option( 'edukarsa_sidebar_tampil_cats', 1 ) == 1 ) : ?>
<div class="card-style sidebar-widget">
<h3 class="sidebar-widget-title"><?php echo esc_html( get_option( 'edukarsa_sidebar_cats_title', 'Kategori Pilihan' ) ); ?></h3>
<ul class="sidebar-category-list">
<?php
$categories = get_categories( array( 'hide_empty' => true ) );
foreach ( $categories as $category ) :
?>
<li>
<a href="<?php echo esc_url( get_category_link( $category->term_id ) ); ?>" class="sidebar-cat-link">
<span><?php echo esc_html( $category->name ); ?></span>
<span class="sidebar-cat-count"><?php echo esc_html( $category->count ); ?></span>
</a>
</li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
<!-- 5. Banner Poster Promosi / Pengumuman Khusus -->
<?php
$banner_img = get_option( 'edukarsa_sidebar_banner_img' );
if ( ! empty( $banner_img ) ) :
$banner_url = get_option( 'edukarsa_sidebar_banner_url', '#' );
?>
<div class="card-style sidebar-widget sidebar-banner-box" style="padding: 10px; overflow: hidden;">
<a href="<?php echo esc_url( $banner_url ); ?>" target="_blank" rel="noopener">
<img src="<?php echo esc_url( $banner_img ); ?>" alt="Banner Pengumuman" style="width: 100%; height: auto; border-radius: 8px; display: block;">
</a>
</div>
<?php endif; ?>
</aside>