Fix Not Being Able To Add New Categories With Intuitive Category Checklist For WordPress

If you use a large amount of categories on your WordPress site, you will find that things get very very messy with a huge amount of categories showing up in the input box. One brilliant way to resolve this is to use a plugin called Intuitive Category Checklist. The good side, is the plugin creates a collapsible tree for all of your categories, the bad side is that you cannot add new categories when using the newer versions of wordpress. The plugin has been abandoned for over 2 years now, so its unlikely that we are going to get an update for this. We are going to have ot take matters into our own hands to maintain this awesome plugin!

Before making any changes to the live file, please make a backup in the event that something goes wrong. Go to your plugin directory and open up the file called “intuative-category-checklist.php” inside the plugin folder. Replace the entire contents of the file with the code below and it should resolve the issue with not being able to add new categories in the edit page.

Adding new categories, will show up at the top of the category box. While they do appear to have ignored the hierarchy of the categories, everything is fine. Its a visual issue, if you refresh the page everything will show up correctly. If anyone wants to work on a fix for this let me know in the comments below and i will update this post.

<?php
/*
  Plugin Name: Intuitive Category Checklist
  Plugin URI: http://www.truimage.net
  Description: Intuitive Category Checklist makes selecting categories easier for sites with a large amount of categories and sub-categorization. This plugin works in both quick edit mode and stand full post mode.
  Author: Dave Berg Schneider
  Version: 1.0.1
  Author URI: http://www.truimage.net
 */
 
define('ICC_PATH', plugin_dir_path(__FILE__));
define('ICC_URL', plugins_url('', __FILE__));
 
add_action('admin_print_scripts', 'icc_print_scripts');
add_action('admin_print_styles', 'icc_print_styles');
 
function icc_print_scripts() {
    wp_enqueue_script('icc_script', ICC_URL . '/assets/icc.js');
}
 
function icc_print_styles() {
    wp_enqueue_style('icc_style', ICC_URL . '/assets/icc.css');
}
 
add_action('add_meta_boxes', 'icc_taxonomy_replace_box');
 
function icc_taxonomy_replace_box($post_type) {
    foreach (get_object_taxonomies($post_type) as $tax_name) {
        $taxonomy = get_taxonomy($tax_name);
        if (!$taxonomy->show_ui || !$taxonomy->hierarchical)
            continue;
 
        $label = isset($taxonomy->label) ? esc_attr($taxonomy->label) : $tax_name;
 
        remove_meta_box($tax_name . 'div', $post_type, 'side');
// Problem solved by faclic.com
        // don't use 'core' as priority
        add_meta_box($tax_name . 'div', $label, 'icc_taxonomy_meta_box', $post_type, 'side', 'high', array('taxonomy' => $tax_name));
    }
}
 
function icc_taxonomy_meta_box($post, $box) {
$defaults = array('taxonomy' => 'category');
    if ( !isset($box['args']) || !is_array($box['args']) )
        $args = array();
    else
        $args = $box['args'];
    extract( wp_parse_args($args, $defaults), EXTR_SKIP );
    $tax = get_taxonomy($taxonomy);
 
    ?>
    <div id="taxonomy-<?php echo $taxonomy; ?>" class="categorydiv">
        <ul id="<?php echo $taxonomy; ?>-tabs" class="category-tabs">
            <li class="tabs"><a href="#<?php echo $taxonomy; ?>-all"><?php echo $tax->labels->all_items; ?></a></li>
            <li class="hide-if-no-js"><a href="#<?php echo $taxonomy; ?>-pop"><?php _e( 'Most Used' ); ?></a></li>
        </ul>
 
        <div id="<?php echo $taxonomy; ?>-pop" class="tabs-panel" style="display: none;">
            <ul id="<?php echo $taxonomy; ?>checklist-pop" class="categorychecklist form-no-clear">
                <?php $popular_ids = wp_popular_terms_checklist($taxonomy); ?>
            </ul>
        </div>
 
        <div id="<?php echo $taxonomy; ?>-all" class="tabs-panel">
            <?php
            $name = ( $taxonomy == 'category' ) ? 'post_category' : 'tax_input[' . $taxonomy . ']';
            echo "<input type='hidden' name='{$name}[]' value='0' />"; // Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks.
            ?>
            <ul id="<?php echo $taxonomy; ?>checklist" data-wp-lists="list:<?php echo $taxonomy; ?>" class="<?php echo $taxonomy; ?>checklist form-no-clear">
                <?php wp_terms_checklist($post->ID, array( 'taxonomy' => $taxonomy, 'popular_cats' => $popular_ids ) ) ?>
            </ul>
        </div>
         
         
        <?php if (!current_user_can($tax->cap->assign_terms)) : ?>
            <p><em><?php _e('You cannot modify this taxonomy.'); ?></em></p>
        <?php endif; ?>
        <?php if ( current_user_can($tax->cap->edit_terms) ) : ?>
            <div id="<?php echo $taxonomy; ?>-adder" class="wp-hidden-children">
                <h4>
                    <a id="<?php echo $taxonomy; ?>-add-toggle" href="#<?php echo $taxonomy; ?>-add" class="hide-if-no-js">
                        <?php // problem solved by faclic.com
                            /* translators: %s: add new taxonomy label */
                            printf( __( '+ %s' ), $tax->labels->add_new_item );
                        ?>
                    </a>
                </h4>
                <p id="<?php echo $taxonomy; ?>-add" class="category-add wp-hidden-child">
                    <label class="screen-reader-text" for="new<?php echo $taxonomy; ?>"><?php echo $tax->labels->add_new_item; ?></label>
                    <input type="text" name="new<?php echo $taxonomy; ?>" id="new<?php echo $taxonomy; ?>" class="form-required form-input-tip" value="<?php echo esc_attr( $tax->labels->new_item_name ); ?>" aria-required="true">
                    <label class="screen-reader-text" for="new<?php echo $taxonomy; ?>_parent">
                        <?php echo $tax->labels->parent_item_colon; ?>
                    </label>
                    <?php wp_dropdown_categories( array( 'taxonomy' => $taxonomy, 'hide_empty' => 0, 'name' => 'new'.$taxonomy.'_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => '— ' . $tax->labels->parent_item . ' —' ) ); ?>
                    <input type="button" id="<?php echo $taxonomy; ?>-add-submit" data-wp-lists="add:<?php echo $taxonomy ?>checklist:<?php echo $taxonomy; ?>-add" class="button <?php echo $taxonomy; ?>-add-submit" value="<?php echo esc_attr($tax->labels->add_new_item); ?>" tabindex="3" />
                    <?php wp_nonce_field( 'add-'.$taxonomy, '_ajax_nonce-add-'.$taxonomy, false ); ?>
                    <span id="<?php echo $taxonomy; ?>-ajax-response"></span>
                </p>
            </div>
        <?php endif; ?>
    </div>
    <?php
}

 

Related Articles

Related Questions

Confused About My New Laptop: Did I Buy a Used One?

So, I bought a new laptop with Windows 11 about a month ago, and when I set it up, I noticed it already had...

Is Arch Linux Right for Me or Should I Switch to Debian?

I recently set up Linux on my computer as a dual boot to learn more about it, especially for my studies in Cybersecurity. I'm...

Is upgrading from Ryzen 7 5700X to 7700X worth a 17% performance boost?

I'm considering upgrading my PC, specifically swapping out my Ryzen 7 5700X for a new Ryzen 7 7700X, as recommended by a friend. However,...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Latest Tools

Scavenger Hunt Team Randomizer

Planning a scavenger hunt and need to split participants into random teams? Whether you're organizing a school activity, a corporate team-building event, or a...

File Hash Generator Online – Get Instant MD5 and SHA-256 Hashes

Whether you are validating downloads, checking for corruption, or comparing files for duplicates, having a fast and secure way to generate file hashes is...

Visual CSS Editor for Modern Glass UI Effects

Modern UI design is all about clean, layered aesthetics, and few styles deliver this better than glassmorphism. If you're designing sleek user interfaces and...

Fast and Accurate Tap BPM Counter – Free Web Tool

Whether you're producing music, DJing live, or just figuring out the tempo of a song, knowing the BPM (beats per minute) can be critical....

Glassmorphism CSS Generator with Live Preview

Glassmorphism is one of the most visually striking design trends in modern UI. Its soft, frosted-glass effect adds depth and elegance to web interfaces,...

Add Custom Speech and Caption Boxes to Any Image Online

Creating comic-style images used to require complex design tools or specialist software. Whether you're making memes, teaching graphics, social media posts or lighthearted content,...

Latest Posts

Latest Questions