Files
edukarsa/sidebar.php
T

67 lines
3.5 KiB
PHP

<?php
/**
* Template Sidebar EduKarsa
*/
?>
<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>
<?php endif; ?>
</aside>