Compare commits

...
3 Commits
6 changed files with 363 additions and 7 deletions
+75 -4
View File
@@ -1,5 +1,76 @@
/**
* EduKarsa Theme Core JavaScript
* Native Zero Plugin Architecture
*/
// 1. GLOBAL INITIALIZER UNTUK GOOGLE TRANSLATE
window.googleTranslateElementInit = function() {
if (typeof google !== 'undefined' && google.translate) {
new google.translate.TranslateElement({
pageLanguage: 'id',
autoDisplay: false
}, 'google_translate_element');
}
};
document.addEventListener("DOMContentLoaded", function() { document.addEventListener("DOMContentLoaded", function() {
// Menu Toggle // 2. LOGIKA SWITCHER BAHASA & MANAJEMEN COOKIE GOOGTRANS
function setLanguageCookie(lang) {
const host = window.location.hostname;
const rootDomain = '.' + host.replace(/^www\./, '');
if (lang === 'id') {
// Reset ke Bahasa Asli (Indonesia)
document.cookie = "googtrans=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
document.cookie = "googtrans=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/; domain=" + host;
document.cookie = "googtrans=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/; domain=" + rootDomain;
} else {
// Set bahasa tujuan (misal /id/en, /id/ar, dll.)
const cookieVal = '/id/' + lang;
document.cookie = "googtrans=" + cookieVal + "; path=/;";
document.cookie = "googtrans=" + cookieVal + "; path=/; domain=" + host;
document.cookie = "googtrans=" + cookieVal + "; path=/; domain=" + rootDomain;
}
window.location.reload();
}
// Pasang Event Listener ke seluruh tombol bahasa (.lang-btn)
const langButtons = document.querySelectorAll('.lang-btn');
const matchCookie = document.cookie.match(/googtrans=\/id\/([a-zA-Z\-]+)/i);
const activeLang = matchCookie ? matchCookie[1].toLowerCase() : 'id';
langButtons.forEach(function(btn) {
const targetLang = (btn.getAttribute('data-lang') || '').toLowerCase();
// Tandai tombol yang sedang aktif
if (targetLang === activeLang) {
btn.classList.add('active');
} else {
btn.classList.remove('active');
}
// Tangkap klik pergantian bahasa
btn.addEventListener('click', function(e) {
e.preventDefault();
const selectedLang = this.getAttribute('data-lang');
if (selectedLang) {
setLanguageCookie(selectedLang);
}
});
});
// Sembunyikan paksa toolbar dan frame pop-up bawaan Google Translate
setInterval(function() {
if (document.body.style.top && document.body.style.top !== '0px') {
document.body.style.top = '0px';
}
const banner = document.querySelector('.goog-te-banner-frame, iframe.goog-te-banner-frame, .VIpgJd-ZVi9od-ORHb-OEVmcd');
if (banner) {
banner.style.display = 'none';
}
}, 150);
// 3. MOBILE MENU TOGGLE
const toggleBtn = document.getElementById("mobile-menu-toggle"); const toggleBtn = document.getElementById("mobile-menu-toggle");
const navMenu = document.getElementById("site-navigation"); const navMenu = document.getElementById("site-navigation");
if (toggleBtn && navMenu) { if (toggleBtn && navMenu) {
@@ -9,7 +80,7 @@ document.addEventListener("DOMContentLoaded", function() {
}); });
} }
// Back to Top // 4. BACK TO TOP BUTTON
const bttBtn = document.getElementById("back-to-top"); const bttBtn = document.getElementById("back-to-top");
if (bttBtn) { if (bttBtn) {
window.addEventListener("scroll", function() { window.addEventListener("scroll", function() {
@@ -20,7 +91,7 @@ document.addEventListener("DOMContentLoaded", function() {
}); });
} }
// Accessibility Panel // 5. TOOLBAR AKSESIBILITAS WCAG 2.1
const a11yTrigger = document.getElementById("a11y-trigger"); const a11yTrigger = document.getElementById("a11y-trigger");
const a11yPanel = document.getElementById("a11y-panel"); const a11yPanel = document.getElementById("a11y-panel");
const a11yClose = document.getElementById("a11y-close"); const a11yClose = document.getElementById("a11y-close");
@@ -55,7 +126,7 @@ document.addEventListener("DOMContentLoaded", function() {
}); });
} }
// Homepage Hero Slider Scroll // 6. HOMEPAGE SLIDER SCROLL OTOMATIS
const slider = document.getElementById('hero-slider-wrapper'); const slider = document.getElementById('hero-slider-wrapper');
if (slider && slider.children.length > 1) { if (slider && slider.children.length > 1) {
setInterval(function() { setInterval(function() {
+2 -2
View File
@@ -5,9 +5,9 @@ if ( post_password_required() ) {
return; return;
} }
?> ?>
<div id="comments" class="comments-area card-style" style="padding: 30px; margin-top: 30px;"> <div id="comments" class="comments-area card-style">
<?php if ( have_comments() ) : ?> <?php if ( have_comments() ) : ?>
<h3 class="comments-title" style="margin-bottom: 20px;"> <h3 class="comments-title">
<?php <?php
$comment_count = get_comments_number(); $comment_count = get_comments_number();
echo esc_html( sprintf( _n( '%d Tanggapan', '%d Tanggapan', $comment_count, 'edukarsa' ), $comment_count ) ); echo esc_html( sprintf( _n( '%d Tanggapan', '%d Tanggapan', $comment_count, 'edukarsa' ), $comment_count ) );
+39
View File
@@ -76,6 +76,35 @@ function edukarsa_register_sidebars() {
} }
add_action( 'widgets_init', 'edukarsa_register_sidebars' ); 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() { function edukarsa_enqueue_scripts() {
wp_enqueue_style( 'edukarsa-style', get_stylesheet_uri(), array(), time() ); wp_enqueue_style( 'edukarsa-style', get_stylesheet_uri(), array(), time() );
@@ -86,5 +115,15 @@ function edukarsa_enqueue_scripts() {
if ( file_exists( get_template_directory() . '/assets/edukarsa.js' ) ) { 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 ); 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' ); add_action( 'wp_enqueue_scripts', 'edukarsa_enqueue_scripts' );
+2
View File
@@ -35,6 +35,8 @@ get_header();
) ); ) );
?> ?>
</div> </div>
<?php edukarsa_social_share(); ?>
</article> </article>
<?php <?php
+4 -1
View File
@@ -49,11 +49,15 @@ get_header();
) ); ) );
?> ?>
</div> </div>
<?php if ( has_tag() ) : ?>
<div class="single-article-footer"> <div class="single-article-footer">
<div class="single-tags-list"> <div class="single-tags-list">
<?php the_tags( '<span class="tag-label">' . esc_html__( 'Topik Terkait:', 'edukarsa' ) . '</span> ', ' ', '' ); ?> <?php the_tags( '<span class="tag-label">' . esc_html__( 'Topik Terkait:', 'edukarsa' ) . '</span> ', ' ', '' ); ?>
</div> </div>
</div> </div>
<?php endif; ?>
<?php edukarsa_social_share(); ?>
</article> </article>
<nav class="inter-post-nav"> <nav class="inter-post-nav">
@@ -92,7 +96,6 @@ get_header();
comments_template(); comments_template();
endif; endif;
?> ?>
<?php endwhile; ?> <?php endwhile; ?>
</div> </div>
<div class="single-sidebar-column"> <div class="single-sidebar-column">
+241
View File
@@ -1019,3 +1019,244 @@ body.edukarsa-popup-open { overflow: hidden; }
display: block; display: block;
stroke: #ffffff; stroke: #ffffff;
} }
/* 24. MODERN NATIVE COMMENT FORM & COMMENTS LIST */
.comments-area {
margin-top: 35px;
padding: 35px;
}
.comments-title {
font-size: 20px;
font-weight: 800;
color: var(--heading-color);
margin-bottom: 24px;
padding-bottom: 12px;
border-bottom: 2px solid #f1f5f9;
}
.comment-respond {
margin-top: 25px;
}
.comment-reply-title {
font-size: 20px;
font-weight: 800;
color: var(--heading-color);
margin-bottom: 8px;
display: flex;
justify-content: space-between;
align-items: center;
}
.comment-reply-title small a {
font-size: 13px;
font-weight: 600;
color: #ef4444;
text-decoration: underline;
}
.comment-notes {
font-size: 13.5px;
color: var(--text-muted);
margin-bottom: 20px;
}
.comment-form {
display: flex;
flex-direction: column;
gap: 18px;
}
.comment-form p {
margin: 0;
}
.comment-form label {
display: block;
font-size: 13px;
font-weight: 700;
color: var(--heading-color);
margin-bottom: 6px;
letter-spacing: 0.2px;
}
.comment-form .required {
color: #ef4444;
margin-left: 2px;
}
.comment-form input[type="text"],
.comment-form input[type="email"],
.comment-form input[type="url"],
.comment-form textarea {
width: 100%;
padding: 12px 16px;
background-color: #f8fafc;
border: 1.5px solid #e2e8f0;
border-radius: 10px;
font-family: inherit;
font-size: 14px;
color: var(--text-color);
outline: none;
transition: all 0.25s ease;
box-sizing: border-box;
}
.comment-form textarea {
min-height: 140px;
resize: vertical;
line-height: 1.6;
}
.comment-form input[type="text"]:focus,
.comment-form input[type="email"]:focus,
.comment-form input[type="url"]:focus,
.comment-form textarea:focus {
background-color: #ffffff;
border-color: var(--secondary-color);
box-shadow: 0 0 0 4px rgba(26, 115, 232, 0.12);
}
.comment-form-cookies-consent {
display: flex;
align-items: flex-start;
gap: 10px;
margin-top: 4px;
}
.comment-form-cookies-consent input[type="checkbox"] {
margin-top: 4px;
width: 16px;
height: 16px;
accent-color: var(--primary-color);
cursor: pointer;
flex-shrink: 0;
}
.comment-form-cookies-consent label {
display: inline;
font-size: 13px;
font-weight: 500;
color: var(--text-muted);
line-height: 1.5;
margin: 0;
cursor: pointer;
}
.form-submit {
margin-top: 8px !important;
}
.comment-form .submit,
#submit {
display: inline-block;
background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
color: #ffffff !important;
padding: 12px 34px;
border-radius: 50px;
font-weight: 700;
font-size: 14px;
letter-spacing: 0.3px;
border: none;
cursor: pointer;
box-shadow: 0 4px 14px rgba(11, 74, 142, 0.25);
transition: all 0.25s ease;
}
.comment-form .submit:hover,
#submit:hover {
background: var(--primary-color);
transform: translateY(-2px);
box-shadow: 0 8px 20px rgba(11, 74, 142, 0.35);
}
.comment-list {
list-style: none;
padding: 0;
margin: 0 0 30px;
}
.comment-list .comment {
margin-bottom: 18px;
padding: 20px 22px;
background: #f8fafc;
border-radius: 12px;
border: 1px solid #e2e8f0;
}
.comment-list .children {
list-style: none;
padding-left: 24px;
margin-top: 15px;
border-left: 2px solid #cbd5e1;
}
.comment-author {
display: flex;
align-items: center;
gap: 10px;
font-size: 14px;
font-weight: 700;
color: var(--heading-color);
margin-bottom: 8px;
}
.comment-author img.avatar {
border-radius: 50%;
width: 42px;
height: 42px;
}
.comment-metadata {
font-size: 12px;
color: var(--text-muted);
margin-bottom: 10px;
}
.comment-reply-link {
display: inline-block;
font-size: 12px;
font-weight: 700;
color: var(--secondary-color);
padding: 4px 12px;
background: #e0f2fe;
border-radius: 20px;
margin-top: 8px;
}
.comment-reply-link:hover {
background: var(--primary-color);
color: #ffffff !important;
}
/* 25. MODERN SOCIAL SHARE BOX */
.edukarsa-share-box {
margin-top: 35px;
padding: 20px 24px;
background: #f8fafc;
border: 1px solid #e2e8f0;
border-radius: 14px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
flex-wrap: wrap;
}
.share-box-title {
font-size: 14px;
font-weight: 800;
color: var(--heading-color);
letter-spacing: 0.2px;
}
.share-btn-group {
display: flex;
align-items: center;
gap: 10px;
flex-wrap: wrap;
}
.share-pill {
display: inline-flex;
align-items: center;
gap: 7px;
padding: 8px 16px;
border-radius: 50px;
font-size: 12.5px;
font-weight: 700;
color: #ffffff !important;
text-decoration: none;
border: none;
cursor: pointer;
transition: all 0.25s ease;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
.share-pill:hover {
transform: translateY(-2px);
box-shadow: 0 6px 16px rgba(0, 0, 0, 0.16);
}
.share-pill svg {
display: block;
flex-shrink: 0;
}
.share-pill-wa { background-color: #25d366; }
.share-pill-wa:hover { background-color: #1ebc57; }
.share-pill-fb { background-color: #1877f2; }
.share-pill-fb:hover { background-color: #0c63d4; }
.share-pill-tw { background-color: #0f1419; }
.share-pill-tw:hover { background-color: #272c30; }
.share-pill-copy { background-color: #475569; }
.share-pill-copy:hover { background-color: #334155; }