fix(theme-check): perbaiki kapitalisasi WordPress, dimensi screenshot 1200x900, dan kompresi aset gambar

This commit is contained in:
Mas Budi Kusuma
2026-09-17 21:05:46 +07:00
parent 5213e39b24
commit b3cc2b57ca
17 changed files with 531 additions and 925 deletions
+81 -46
View File
@@ -1,55 +1,90 @@
<?php
/**
* File ini menangani dukungan tema (Theme Support) dan antrean aset (CSS/JS).
*/
defined('ABSPATH') || exit;
defined( 'ABSPATH' ) || exit;
// 1. PENGATURAN DASAR
function edukarsa_setup() {
add_theme_support( 'title-tag' );
add_theme_support( 'post-thumbnails' );
// Pastikan tema mendukung excerpt (kutipan) untuk CPT
add_post_type_support( 'page', 'excerpt' );
if ( ! function_exists( 'edukarsa_theme_setup' ) ) {
function edukarsa_theme_setup() {
load_theme_textdomain( 'edukarsa', get_template_directory() . '/languages' );
register_nav_menus( array(
'menu-utama' => __( 'Menu Utama', 'edukarsa' ),
'menu-footer' => __( 'Menu Footer', 'edukarsa' ),
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( 'after_setup_theme', 'edukarsa_setup' );
add_action( 'widgets_init', 'edukarsa_register_sidebars' );
// 2. MENGHUBUNGKAN ASET (CSS & JS FRONTEND)
function edukarsa_scripts() {
// 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' );
function edukarsa_enqueue_scripts() {
wp_enqueue_style( 'edukarsa-style', get_stylesheet_uri(), array(), time() );
// 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();
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 );
}
}
add_action( 'admin_enqueue_scripts', 'edukarsa_admin_scripts' );
// 4. REDIRECT SETELAH AKTIVASI TEMA
// 4. REDIRECT AMAN SETELAH AKTIVASI TEMA
function edukarsa_activation_redirect() {
global $pagenow;
if ( 'themes.php' === $pagenow && isset( $_GET['activated'] ) ) {
// Redirect yang aman, dipanggil setelah seluruh menu dan hak akses WordPress siap
wp_safe_redirect( admin_url( 'admin.php?page=edukarsa_settings' ) );
exit;
}
}
add_action( 'admin_init', 'edukarsa_activation_redirect' );
add_action( 'wp_enqueue_scripts', 'edukarsa_enqueue_scripts' );