Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

Cibulka on "post_tags_meta_box() - Javascript functionality no longer works"

$
0
0

Hello all!

As my custom taxonomies are essential for my articles, I would like to move them from side menu to my custom meta box.

Here is (simplified) code I'm using:

// Remove taxonomy meta_boxes from side
function tax_remove_from_side() {
    remove_meta_box('tagsdiv-skill', 'web', 'side' );
}
add_action('my_custom_hook', 'tax_remove_from_side');

// Add taxonomy meta_boxes to my custom meta_box
function tax_add_to_box() {
	global $post;
	$tax = get_object_taxonomies(get_post_type());
	echo '<div id="meta_tax">';
	foreach ($tax as $t) {
		$t_o = get_taxonomy($t); ?>
		<div class="cell item">';
			<strong><?php echo $t_o->labels->name; ?></strong>
			<?php if ($t_o->hierarchical) {
				post_categories_meta_box($post, array('args' => array('taxonomy' => $t), 'title' => $t_o->labels->name));
			} else {
				post_tags_meta_box($post, array('args' => array('taxonomy' => $t), 'title' => $t_o->labels->name));
			} ?>
		</div>
	}
	echo '</div>';
}
add_action('my_custom_hook_for_metabox', 'tax_add_to_box');

Does that make sense?

My problem: If I remove all nonhierarchical taxonomies from sidemenu, link "Choose from the most used tags" and other JS functionality for nonhierarchical (tag-like)taxonomies stops working. Oddly enough, hierarchical taxonomies (category-like) JS functionality works smoothly.

My current ugly solution: Custom taxonomy called "Very nasty hack" that is left on sidebar (so JS functionality remains) but is never included to my custom meta_box. :) Very nasty, but works.

///

After some digging in core files, I think I've found relevant pieces of code for the problem: file wp-includes/js/post.js, lines 19-179. Especially variable Disabled, defined under function quickClicks on line 58.

I see, that the variable works in a few conditionals later, but to be honest, that is as far as my understanding of the situation goes. :)

///

Any idea how to enable JS functionality for nonhierarchical meta_boxes even if they don't appear at the side menu PROPERLY? THANKS IN ADVANCE!


Viewing all articles
Browse latest Browse all 8245

Trending Articles