/* 
 Theme Name:   Waiki Tekstil
 Theme URI:    https://hubly.id
 Description:  Untuk Waiki Tekstil
 Author:       Putra Danahita
 Author URI:   https://hubly.id
 Template:     hello-elementor
 Version:      1.0
 License:      GNU General Public License v2 or later
 License URI:  http://www.gnu.org/licenses/gpl-2.0.html

 /* == Add your own styles below this line ==
--------------------------------------------*/

// Menambahkan Dynamic Tag khusus untuk Kategori Produk
add_action( 'elementor/dynamic_tags/register', function( $dynamic_tags_manager ) {
    class Waiki_Product_Category_Tag extends \Elementor\Core\DynamicTags\Tag {
        public function get_name() { return 'waiki-product-category'; }
        public function get_title() { return __( 'Waiki First Category', 'text-domain' ); }
        public function get_group() { return 'woocommerce'; }
        public function get_categories() { return [ \Elementor\Modules\DynamicTags\Module::TEXT_CATEGORY ]; }

        public function render() {
            $product_id = get_the_ID();
            if ( $product_id ) {
                $terms = get_the_terms( $product_id, 'product_cat' );
                if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) {
                    echo esc_html( strtoupper( $terms[0]->name ) );
                    return;
                }
            }
            echo 'SHIBORI SERIES'; // Fallback text di editor
        }
    }
    $dynamic_tags_manager->register( new Waiki_Product_Category_Tag() );
});