Files

133 lines
6.1 KiB
PHP

<?php
defined( 'ABSPATH' ) || exit;
?>
<aside id="secondary" class="edukarsa-custom-sidebar" aria-label="<?php esc_attr_e( 'Sidebar Utama', 'edukarsa' ); ?>">
<?php if ( is_active_sidebar( 'sidebar-utama' ) ) : ?>
<div class="sidebar-dynamic-widgets">
<?php dynamic_sidebar( 'sidebar-utama' ); ?>
</div>
<?php endif; ?>
<?php if ( get_option( 'edukarsa_sidebar_tampil_search', 1 ) == 1 ) : ?>
<div class="card-style sidebar-widget">
<?php get_search_form(); ?>
</div>
<?php endif; ?>
<?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; ?>
<?php
if ( get_option( 'edukarsa_sidebar_tampil_html', 0 ) == 1 ) :
$html_content = get_option( 'edukarsa_sidebar_html_content' );
if ( ! empty( $html_content ) ) :
$html_title = get_option( 'edukarsa_sidebar_html_title' );
?>
<div class="card-style sidebar-widget sidebar-custom-html-box">
<?php if ( ! empty( $html_title ) ) : ?>
<h3 class="sidebar-widget-title"><?php echo esc_html( $html_title ); ?></h3>
<?php endif; ?>
<div class="sidebar-html-rendered-content">
<?php echo do_shortcode( wp_specialchars_decode( $html_content ) ); ?>
</div>
</div>
<?php
endif;
endif;
?>
<?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">&#128197; <?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;">' . esc_html__( 'Belum ada artikel lainnya.', 'edukarsa' ) . '</p>';
endif;
?>
</div>
</div>
<?php endif; ?>
<?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
$cat_limit = intval( get_option( 'edukarsa_sidebar_cats_count', 10 ) );
$cat_args = array(
'hide_empty' => true,
'orderby' => 'count',
'order' => 'DESC',
);
if ( $cat_limit > 0 ) {
$cat_args['number'] = $cat_limit;
}
$categories = get_categories( $cat_args );
if ( ! empty( $categories ) ) :
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;
else :
echo '<li style="font-size:13px; color:var(--text-muted);">' . esc_html__( 'Belum ada kategori.', 'edukarsa' ) . '</li>';
endif;
?>
</ul>
</div>
<?php endif; ?>
<?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="<?php esc_attr_e( 'Banner Pengumuman', 'edukarsa' ); ?>" style="width: 100%; height: auto; border-radius: 8px; display: block;">
</a>
</div>
<?php endif; ?>
</aside>