Files

130 lines
6.9 KiB
PHP

<?php
defined( 'ABSPATH' ) || exit;
if ( ! function_exists( 'edukarsa_theme_setup' ) ) {
function edukarsa_theme_setup() {
load_theme_textdomain( 'edukarsa', get_template_directory() . '/languages' );
add_theme_support( 'automatic-feed-links' );
add_theme_support( 'title-tag' );
add_theme_support( 'post-thumbnails' );
add_theme_support( 'align-wide' );
add_theme_support( 'wp-block-styles' );
add_theme_support( 'responsive-embeds' );
add_theme_support( 'editor-styles' );
add_editor_style( 'style.css' );
add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption', 'style', 'script' ) );
add_theme_support( 'custom-logo', array(
'height' => 110,
'width' => 400,
'flex-height' => true,
'flex-width' => true,
) );
add_theme_support( 'custom-header', array(
'default-image' => '',
'width' => 1920,
'height' => 800,
'flex-height' => true,
) );
add_theme_support( 'custom-background', array(
'default-color' => 'ffffff',
) );
register_nav_menus( array(
'menu-utama' => esc_html__( 'Menu Navigasi Utama', 'edukarsa' ),
'menu-footer' => esc_html__( 'Menu Tautan Footer', 'edukarsa' ),
) );
}
}
add_action( 'after_setup_theme', 'edukarsa_theme_setup' );
function edukarsa_register_block_components() {
if ( function_exists( 'register_block_style' ) ) {
register_block_style( 'core/quote', array(
'name' => 'edukarsa-quote',
'label' => esc_html__( 'EduKarsa Quote', 'edukarsa' ),
) );
}
if ( function_exists( 'register_block_pattern' ) ) {
register_block_pattern(
'edukarsa/cta-banner',
array(
'title' => esc_html__( 'EduKarsa CTA Banner', 'edukarsa' ),
'description' => esc_html__( 'Banner ajakan pendaftaran PMB EduKarsa', 'edukarsa' ),
'content' => '<!-- wp:group {"className":"edukarsa-cta-block"} --><div class="wp-block-group edukarsa-cta-block"><p>' . esc_html__( 'Pendaftaran Mahasiswa / Siswa Baru Telah Dibuka!', 'edukarsa' ) . '</p></div><!-- /wp:group -->',
'categories' => array( 'featured' ),
)
);
}
}
add_action( 'init', 'edukarsa_register_block_components' );
function edukarsa_register_sidebars() {
register_sidebar( array(
'name' => esc_html__( 'Sidebar Utama', 'edukarsa' ),
'id' => 'sidebar-utama',
'description' => esc_html__( 'Area widget untuk bilah samping postingan dan halaman.', 'edukarsa' ),
'before_widget' => '<div id="%1$s" class="card-style sidebar-widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="sidebar-widget-title">',
'after_title' => '</h3>',
) );
}
add_action( 'widgets_init', 'edukarsa_register_sidebars' );
// Helper Tombol Berbagi Media Sosial Native (Post & Page)
function edukarsa_social_share() {
$share_url = rawurlencode( get_permalink() );
$share_title = rawurlencode( get_the_title() );
?>
<div class="edukarsa-share-box">
<span class="share-box-title"><?php esc_html_e( 'Bagikan Halaman Ini:', 'edukarsa' ); ?></span>
<div class="share-btn-group">
<a href="https://wa.me/?text=<?php echo $share_title . '%20' . $share_url; ?>" target="_blank" rel="noopener" class="share-pill share-pill-wa" title="WhatsApp">
<svg width="15" height="15" viewBox="0 0 24 24" fill="currentColor"><path d="M12.031 6.172c-3.181 0-5.767 2.586-5.768 5.766-.001 1.298.38 2.27 1.019 3.287l-.711 2.598 2.664-.699c.971.53 1.777.82 2.796.82h.005c3.18 0 5.767-2.586 5.768-5.766 0-3.18-2.587-5.806-5.773-5.806zm3.376 8.214c-.149.42-.767.781-1.072.829-.304.048-.687.069-2.203-.559-1.933-.801-3.178-2.775-3.275-2.905-.095-.129-.778-1.036-.778-1.975 0-.94.492-1.401.667-1.593.175-.192.383-.24.512-.24.129 0 .258.006.371.012.12.006.279-.045.436.334.164.397.558 1.365.607 1.465.049.099.082.217.017.348-.065.131-.098.212-.195.328-.098.115-.205.258-.293.346-.098.098-.201.205-.087.401.115.196.512.846 1.099 1.368.756.673 1.393.882 1.59.98.196.098.312.082.426-.049.115-.131.492-.573.623-.77.131-.196.262-.164.442-.098.18.065 1.147.541 1.344.639.196.098.328.147.377.229.049.082.049.475-.1.895z"/></svg>
<span>WhatsApp</span>
</a>
<a href="https://www.facebook.com/sharer/sharer.php?u=<?php echo $share_url; ?>" target="_blank" rel="noopener" class="share-pill share-pill-fb" title="Facebook">
<svg width="15" height="15" viewBox="0 0 24 24" fill="currentColor"><path d="M22 12c0-5.52-4.48-10-10-10S2 6.48 2 12c0 4.84 3.44 8.87 8 9.8V15H8v-3h2V9.5C10 7.57 11.57 6 13.5 6H16v3h-2c-.55 0-1 .45-1 1v2h3v3h-3v6.95c5.05-.5 9-4.76 9-9.95z"/></svg>
<span>Facebook</span>
</a>
<a href="https://twitter.com/intent/tweet?text=<?php echo $share_title; ?>&url=<?php echo $share_url; ?>" target="_blank" rel="noopener" class="share-pill share-pill-tw" title="X (Twitter)">
<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"/></svg>
<span>X / Twitter</span>
</a>
<button type="button" class="share-pill share-pill-copy" onclick="navigator.clipboard.writeText('<?php echo esc_js( get_permalink() ); ?>'); alert('<?php echo esc_js( __( 'Tautan berhasil disalin ke clipboard!', 'edukarsa' ) ); ?>');">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg>
<span>Salin Link</span>
</button>
</div>
</div>
<?php
}
function edukarsa_enqueue_scripts() {
wp_enqueue_style( 'edukarsa-style', get_stylesheet_uri(), array(), time() );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
if ( file_exists( get_template_directory() . '/assets/edukarsa.js' ) ) {
wp_enqueue_script( 'edukarsa-global-js', get_template_directory_uri() . '/assets/edukarsa.js', array(), time(), true );
}
if ( get_option( 'edukarsa_tampil_bilingual', 1 ) == 1 ) {
wp_enqueue_script(
'google-translate-api',
'https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit',
array( 'edukarsa-global-js' ),
null,
true
);
}
}
add_action( 'wp_enqueue_scripts', 'edukarsa_enqueue_scripts' );