/**
* Display a meta box on the post editing screen.
*
* @param object $post The post object
* @param object $walker An optional term walker
* @param bool $show_none Whether to include a 'none' item in the term list
* @param string $type The taxonomy list type (checklist or dropdown)
* @return null
*/
function do_meta_box(WP_Post $post, Walker $walker = null, $show_none = false, $type = 'checklist')
{
$taxonomy = $this->taxo->taxonomy;
$tax = get_taxonomy($taxonomy);
$selected = wp_get_object_terms($post->ID, $taxonomy, array('fields' => 'ids'));
if ($show_none) {
if (isset($tax->labels->no_item)) {
$none = $tax->labels->no_item;
} else {
$none = __('Not Specified', 'ext_taxos');
}
} else {
$none = '';
}
?>
<div id="taxonomy-<?php
echo $taxonomy;
?>
" class="categorydiv">
<?php
switch ($type) {
case 'dropdown':
wp_dropdown_categories(array('show_option_none' => $none, 'hide_empty' => false, 'hierarchical' => true, 'show_count' => false, 'orderby' => 'name', 'selected' => $selected, 'id' => "{$taxonomy}dropdown", 'name' => "tax_input[{$taxonomy}]", 'taxonomy' => $taxonomy, 'walker' => $walker));
break;
case 'checklist':
default:
?>
<style type="text/css">
/* Style for the 'none' item: */
#<?php
echo $taxonomy;
?>
-0 {
color: #888;
border-top: 1px solid #eee;
margin-top: 5px;
}
</style>
<input type="hidden" name="tax_input[<?php
echo $taxonomy;
?>
][]" value="0" />
<ul id="<?php
echo $taxonomy;
?>
checklist" class="list:<?php
echo $taxonomy;
?>
categorychecklist form-no-clear">
<?php
# Standard WP Walker_Category_Checklist does not cut it
if (empty($walker) or !is_a($walker, 'Walker')) {
$walker = new Walker_ExtendedTaxonomyCheckboxes();
}
# Output the terms:
wp_terms_checklist($post->ID, array('taxonomy' => $taxonomy, 'walker' => $walker, 'selected_cats' => $selected, 'checked_ontop' => $this->args['checked_ontop']));
# Output the 'none' item:
if ($show_none) {
$output = '';
$o = (object) array('term_id' => 0, 'name' => $none, 'slug' => 'none');
if (empty($selected)) {
$_selected = array(0);
} else {
$_selected = $selected;
}
$args = array('taxonomy' => $taxonomy, 'selected_cats' => $_selected, 'disabled' => false);
$walker->start_el($output, $o, 1, $args);
$walker->end_el($output, $o, 1, $args);
echo $output;
}
?>
</ul>
<?php
break;
}
?>
</div>
<?php
}