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

WordPress Table of Contents Plus Not Working

I have been using this plugin for a while and i really like it. It seems to have completely stopped working recently. I can...

Function Keys Reversing Between Fn Actions And Normal

My keyboard has the usual F1 to F12 keys along the top. I use these for shortcuts in various applications. These keys also have...

Whirlpool Oven F6E6: Appliance Manager 1 Board Communication

I have a brand new Whirlpool oven W11I OM1 4MS2 H or (859991549450). I bought it alongside the microwave combi oven. I have had...

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

List Sorting Tool

Welcome to our innovative list ordering and management tool. This next-level platform enables you to sort a list of items in ascending or descending...

Sudoku Solver

Welcome to our free online Sudoku solving tool, an interactive platform for puzzle enthusiasts seeking a break from a Sudoku conundrum. This advanced platform...

Apply Image Filters To Image

Digital imagery in the modern world is all about reinforcing emotions and stories behind each photo we take. To amplify this storytelling, we are...

Add Watermark To Image

As the world is increasingly consumed by digital media, protecting your original images is paramount. We are thrilled to introduce you to our innovative...

CSV To Xml Converter

Welcome to our CSV to XML converter tool, a convenient and user-friendly solution for all your data conversion needs. This versatile tool on our...

RGB Image Splitter

Welcome to our innovative RGB Splitter - a unique image analyzer tool that offers an in-depth peek into the building blocks of your photos....

Latest Posts

Latest Questions