From 27799d11beaaf7f375d5c23a51979c8183a116ea Mon Sep 17 00:00:00 2001 From: Mas Budi Kusuma Date: Wed, 16 Sep 2026 10:23:07 +0700 Subject: [PATCH] fix(core): hapus duplikasi deklarasi fungsi di setup.php penyebab fatal error 500 --- inc/setup.php | 100 +++++++------------------------------------------- 1 file changed, 13 insertions(+), 87 deletions(-) diff --git a/inc/setup.php b/inc/setup.php index e2cf1a4..7d99e05 100644 --- a/inc/setup.php +++ b/inc/setup.php @@ -1,16 +1,16 @@ - __( 'Menu Utama', 'edukarsa' ), @@ -21,100 +21,26 @@ add_action( 'after_setup_theme', 'edukarsa_setup' ); // 2. MENGHUBUNGKAN ASET (CSS & JS FRONTEND) function edukarsa_scripts() { - $font_choice = get_option( 'edukarsa_font_choice', 'plus_jakarta_sans' ); - $font_url = ''; - $font_family = "'Plus Jakarta Sans', system-ui, sans-serif"; - - switch ( $font_choice ) { - case 'inter': - $font_url = 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap'; - $font_family = "'Inter', system-ui, sans-serif"; - break; - case 'poppins': - $font_url = 'https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700;800&display=swap'; - $font_family = "'Poppins', system-ui, sans-serif"; - break; - case 'roboto': - $font_url = 'https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700;900&display=swap'; - $font_family = "'Roboto', system-ui, sans-serif"; - break; - case 'system': - $font_url = ''; - $font_family = "system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif"; - break; - case 'plus_jakarta_sans': - default: - $font_url = 'https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap'; - $font_family = "'Plus Jakarta Sans', system-ui, sans-serif"; - break; - } - - $deps = array(); - if ( ! empty( $font_url ) ) { - wp_enqueue_style( 'edukarsa-dynamic-font', $font_url, array(), null ); - $deps[] = 'edukarsa-dynamic-font'; - } - - // Load file style.css utama - wp_enqueue_style( - 'edukarsa-style', - get_template_directory_uri() . '/style.css', - $deps, - time(), - 'all' - ); - - // Ambil opsi skema warna dari database - $primary_color = sanitize_hex_color( get_option( 'edukarsa_primary_color', '#0b4a8e' ) ); - $secondary_color = sanitize_hex_color( get_option( 'edukarsa_secondary_color', '#1a73e8' ) ); - $heading_color = sanitize_hex_color( get_option( 'edukarsa_heading_color', '#0f172a' ) ); - - // Injeksi CSS variables dinamis langsung ke selector :root - $custom_css = " - :root { - --primary-color: {$primary_color}; - --secondary-color: {$secondary_color}; - --heading-color: {$heading_color}; - --font-main: {$font_family}; - } - "; - wp_add_inline_style( 'edukarsa-style', $custom_css ); + // Memaksa path absolut langsung ke folder tema dengan Cache Busting time() + wp_enqueue_style( + 'edukarsa-style', + get_template_directory_uri() . '/style.css', + array(), + time(), + 'all' + ); } add_action( 'wp_enqueue_scripts', 'edukarsa_scripts' ); // 3. MEMUAT JAVASCRIPT UNTUK MEDIA UPLOADER (DASHBOARD) function edukarsa_admin_scripts( $hook ) { + // Memastikan skrip uploader dipanggil di halaman pengaturan Edukarsa if ( strpos( $hook, 'edukarsa' ) !== false ) { wp_enqueue_media(); } } add_action( 'admin_enqueue_scripts', 'edukarsa_admin_scripts' ); -// 4. REGISTRASI AREA WIDGET SIDEBAR -function edukarsa_widgets_init() { - register_sidebar( array( - 'name' => __( 'Sidebar Artikel', 'edukarsa' ), - 'id' => 'sidebar-artikel', - 'description' => __( 'Area widget untuk halaman single berita/artikel.', 'edukarsa' ), - 'before_widget' => '', - 'before_title' => '', - ) ); -} -add_action( 'widgets_init', 'edukarsa_widgets_init' ); - -// 4. REDIRECT SETELAH AKTIVASI TEMA -function edukarsa_activation_redirect() { - global $pagenow; - // Cek jika ini halaman themes.php dan ada parameter 'activated' - if ( is_admin() && 'themes.php' === $pagenow && isset( $_GET['activated'] ) ) { - wp_redirect( admin_url( 'admin.php?page=edukarsa_main_menu' ) ); - exit; - } -} -add_action( 'after_switch_theme', 'edukarsa_activation_redirect' ); - // 4. REDIRECT SETELAH AKTIVASI TEMA function edukarsa_activation_redirect() { global $pagenow;