• error in console: Error: no such method ‘instance’ for sortable widget instance

    open np-coupon-code.php and chege code:
    old:

    function np_eccw_css_and_js() {	
    		wp_register_style('your_css_and_js', plugins_url('datepicker/jquery-ui.css',__FILE__ ));
    		wp_enqueue_style('your_css_and_js');
    		wp_register_script( 'your_css_and_js', plugins_url('datepicker/jquery-ui.js',__FILE__ ));
    		wp_enqueue_script('your_css_and_js');
    		wp_register_script( 'mycustomjs', plugins_url('np-coupon-code.js',__FILE__ ));
    		wp_enqueue_script('mycustomjs');
    }
    add_action( 'admin_init','np_eccw_css_and_js');

    new:

    function np_eccw_css_and_js($hook_suffix) {	
    	$cpt = 'np_coupon_code';
        if( in_array($hook_suffix, array('post.php', 'post-new.php') ) ){
            $screen = get_current_screen();
            if( is_object( $screen ) && $cpt == $screen->post_type ){
    			wp_register_style('your_css_and_js', plugins_url('datepicker/jquery-ui.css',__FILE__ ));
    			wp_enqueue_style('your_css_and_js');
    			wp_register_script( 'your_css_and_js', plugins_url('datepicker/jquery-ui.js',__FILE__ ));
    			wp_enqueue_script('your_css_and_js');
    			wp_register_script( 'mycustomjs', plugins_url('np-coupon-code.js',__FILE__ ));
    			wp_enqueue_script('mycustomjs');
            }
        }
    }
    add_action( 'admin_enqueue_scripts','np_eccw_css_and_js');
  • The topic ‘Error: no such method ‘instance’ for sortable widget instance’ is closed to new replies.