function gh_car_admin_assets( $hook ) {
    global $post_type;
    if ( 'gh_carousel' === $post_type && in_array( $hook, [ 'post.php', 'post-new.php' ], true ) ) {
        wp_enqueue_media();
        wp_add_inline_script( 'jquery', '
            jQuery(function($){
                // FIX: Properly count existing slides on load
                function updateCount() {
                    return $(".gh-slide-row").length;
                }
                
                $("#gh-add-slide").on("click", function(){
                    let count = updateCount();
                    let html = $("#gh-slide-tpl").html().replace(/__IDX__/g, count);
                    $("#gh-slides-wrap").append(html);
                    
                    // Reinitialize upload buttons for new slide
                    initializeUploadButtons();
                });
                
                function initializeUploadButtons() {
                    $(document).off("click", ".gh-upload");
                    $(document).on("click", ".gh-upload", function(e){
                        e.preventDefault();
                        let $btn = $(this), $input = $btn.prev("input"), $prev = $btn.next(".gh-prev");
                        let frame = wp.media({title:"Select Image", button:{text:"Use Image"}, multiple:false}).open()
                            .on("select", function(){
                                let img = frame.state().get("selection").first().toJSON();
                                $input.val(img.id);
                                $prev.html("<img src=\""+img.sizes.thumbnail.url+"\" style=\"max-height:40px;margin-top:4px;display:block;\">");
                            });
                    });
                }
                
                $(document).on("click", ".gh-remove", function(){ 
                    $(this).closest(".gh-slide-row").remove(); 
                });
                
                // Initialize on page load
                initializeUploadButtons();
                
                // FIX: Preserve dynamic fields on submit
                $(document).on("submit", "#post", function(){
                    $(".gh-slide-row").each(function(i){
                        $(this).find("input[name]").each(function(){
                            let name = $(this).attr("name").replace(/__IDX__/g, i);
                            $(this).attr("name", name);
                        });
                    });
                });
            });
        ' );
    }
}<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="https://grandhashala.com/wp-sitemap-index.xsl" ?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap><loc>https://grandhashala.com/wp-sitemap-posts-post-1.xml</loc></sitemap><sitemap><loc>https://grandhashala.com/wp-sitemap-posts-page-1.xml</loc></sitemap><sitemap><loc>https://grandhashala.com/wp-sitemap-posts-books-1.xml</loc></sitemap><sitemap><loc>https://grandhashala.com/wp-sitemap-taxonomies-category-1.xml</loc></sitemap><sitemap><loc>https://grandhashala.com/wp-sitemap-users-1.xml</loc></sitemap></sitemapindex>
