Make WordPress Core


Ignore:
Timestamp:
12/18/2008 07:12:26 PM (16 years ago)
Author:
ryan
Message:

Allow muliple tag-like taxonomies in the post editor. see #6387

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/wp-admin/edit-form-advanced.php

    r10094 r10222  
    264264 * @param object $post
    265265 */
    266 function post_tags_meta_box($post) {
    267 ?>
    268 <p id="jaxtag"><label class="hidden" for="newtag"><?php _e('Tags'); ?></label><input type="text" name="tags_input" class="tags-input" id="tags-input" size="40" tabindex="3" value="<?php echo get_tags_to_edit( $post->ID ); ?>" /></p>
    269 <div id="tagchecklist"></div>
    270 <p id="tagcloud-link" class="hide-if-no-js"><a href='#'><?php _e( 'Choose from the most popular tags' ); ?></a></p>
    271 <?php
    272 }
    273 add_meta_box('tagsdiv', __('Tags'), 'post_tags_meta_box', 'post', 'side', 'core');
     266function post_tags_meta_box($post, $box) {
     267    $tax_name = substr($box['id'], 8);
     268    $taxonomy = get_taxonomy($tax_name);
     269    if ( isset($taxonomy->helps) )
     270        $helps = attribute_escape($taxonomy->helps);
     271    else
     272        $helps = '';
     273?>
     274<div class="tagsdiv" id="<?php echo $tax_name; ?>">
     275    <p class="jaxtag">
     276        <label class="hidden" for="newtag"><?php _e( $box['title'] ); ?></label>
     277        <input type="hidden" name="<?php echo "tax_input[$tax_name]"; ?>" class="the-tags" id="tax-input[<?php echo $tax_name; ?>]" value="<?php echo get_terms_to_edit( $post->ID, $tax_name ); ?>" />
     278     
     279    <span class="ajaxtag" style="display:none;">
     280        <input type="text" name="newtag[<?php echo $tax_name; ?>]" class="newtag form-input-tip" size="16" autocomplete="off" value="<?php _e('Add new tag'); ?>" />
     281        <input type="button" class="button tagadd" value="<?php _e('Add'); ?>" tabindex="3" />
     282    </span>
     283    <?php echo $helps ? "<div class='howto'>$helps</div>" : ''; ?>
     284    </p>
     285    <div class="tagchecklist"></div>
     286</div>
     287<p class="tagcloud-link hide-if-no-js"><a href="#titlediv" class="tagcloud-link" id="link-<?php echo $tax_name; ?>"><?php printf( __('Choose from the most used tags in %s'), $box['title'] ); ?></a></p>
     288<?php
     289}
     290
     291// all tag-style post taxonomies
     292foreach ( get_object_taxonomies('post') as $tax_name ) {
     293    if ( !is_taxonomy_hierarchical($tax_name) ) {
     294        $taxonomy = get_taxonomy($tax_name);
     295        $label = isset($taxonomy->label) ? attribute_escape($taxonomy->label) : $tax_name;
     296
     297        add_meta_box('tagsdiv-' . $tax_name, $label, 'post_tags_meta_box', 'post', 'side', 'core');
     298    }
     299}
    274300
    275301/**
Note: See TracChangeset for help on using the changeset viewer.