Thickbox for WordPress Admin

im trying to load wp thickbox in admin from inside a class in this way

function add_admin_scripts($hook) {
        global $post;
        if ($hook == 'post-new.php' || $hook == 'post.php') {
            if ('gm-weaver' === $post->post_type) {
                wp_enqueue_style('weaver', untrailingslashit(plugin_dir_url(__FILE__)) . '/../assets/css/weaver.css');
                add_thickbox();
                wp_enqueue_script('mm-weaver-script', untrailingslashit(plugin_dir_url(__FILE__)) . '/../assets/js/weaver.js', array('jquery', 'thickbox'), "1.0", TRUE);
            }
        }
    }

thickbox working but not re-sizing as given inline parameter

Read More
<a title="Title" href="#TB_inline?width=300&height=500&inlineId=my-content-id" id="insert-my-media" class="button thickbox">C media</a>'
            . '<div id="my-content-id" style="display:none;">
                <form>
                <input type="text">
                </form>
                </div>

if i use same html in front end with add_thickbox() it works fine.
again if i use

wp_enqueue_script('mm-weaver-script', untrailingslashit(plugin_dir_url(__FILE__)) . '/../assets/js/thickbox.js', array('jquery'), TRUE)

in add_admin_scripts($hook){…} instead of add_thickbox() it works fine on admin,

  1. whats the problem with add_thickbox() to load thickbox.js for admin?
  2. what are the proper way to use thickbox in wp admin?

Related posts