WordPress.org

Make WordPress Core


Ignore:
Timestamp:
03/01/2010 03:48:01 PM (9 years ago)
Author:
ryan
Message:

Custom taxonomy support for inline edit. Props prettyboymp. see #9674

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/template.php

    r13510 r13535  
    912912    $post_type_object = get_post_type_object( $screen->post_type );
    913913
     914    $taxonomy_names = get_object_taxonomies( $screen->post_type );
     915    $hierarchical_taxonomies = array();
     916    $flat_taxonomies = array();
     917    foreach ( $taxonomy_names as $taxonomy_name ) {
     918        $taxonomy = get_taxonomy( $taxonomy_name);
     919       
     920        if( !$taxonomy->show_ui ) continue;
     921       
     922        if( $taxonomy->hierarchical )
     923            $hierarchical_taxonomies[] = $taxonomy;
     924        else
     925            $flat_taxonomies[] = $taxonomy;
     926    }
     927   
    914928    $columns = wp_manage_posts_columns($screen);
    915929    $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns($screen) ) );
     
    10031017    </div></fieldset>
    10041018
    1005 <?php if ( is_object_in_taxonomy($screen->post_type, 'category') && !$bulk ) : ?>
     1019<?php if ( count($hierarchical_taxonomies) && !$bulk ) : ?>
    10061020
    10071021    <fieldset class="inline-edit-col-center inline-edit-categories"><div class="inline-edit-col">
    1008         <span class="title inline-edit-categories-label"><?php _e( 'Categories' ); ?>
     1022   
     1023<?php foreach ( $hierarchical_taxonomies as $taxonomy ) : ?>
     1024
     1025        <span class="title inline-edit-categories-label"><?php echo esc_html($taxonomy->label) ?>
    10091026            <span class="catshow"><?php _e('[more]'); ?></span>
    10101027            <span class="cathide" style="display:none;"><?php _e('[less]'); ?></span>
    10111028        </span>
    1012         <ul class="cat-checklist">
    1013             <?php wp_category_checklist(); ?>
     1029        <ul class="cat-checklist <?php echo esc_attr($taxonomy->name)?>-checklist">
     1030            <?php wp_terms_checklist(null, array('taxonomy' => $taxonomy->name)) ?>
    10141031        </ul>
     1032
     1033<?php endforeach; //$hierarchical_taxonomies as $taxonomy ?>
     1034
    10151035    </div></fieldset>
    10161036
    1017 <?php endif; // is_object_in_taxonomy($screen->post_type, 'category') && !$bulk ?>
     1037<?php endif; // count($hierarchical_taxonomies) && !$bulk ?>
    10181038
    10191039    <fieldset class="inline-edit-col-right"><div class="inline-edit-col">
     
    10591079<?php endif; // $post_type_object->hierarchical ?>
    10601080
    1061 <?php if ( is_object_in_taxonomy($screen->post_type, 'post_tag') && !$bulk ) : ?>
     1081<?php if ( count($flat_taxonomies) && !$bulk ) : ?>
     1082
     1083<?php foreach ( $flat_taxonomies as $taxonomy ) : ?>
    10621084
    10631085        <label class="inline-edit-tags">
    1064             <span class="title"><?php _e( 'Tags' ); ?></span>
    1065             <textarea cols="22" rows="1" name="tags_input" class="tags_input"></textarea>
     1086            <span class="title"><?php echo esc_html($taxonomy->label) ?></span>
     1087            <textarea cols="22" rows="1" name="tax_input[<?php echo esc_attr($taxonomy->name)?>]" class="tax_input_<?php echo esc_attr($taxonomy->name)?>"></textarea>
    10661088        </label>
    10671089
    1068 <?php endif; // is_object_in_taxonomy($screen->post_type, 'post_tag') && !$bulk  ?>
     1090<?php endforeach; //$flat_taxonomies as $taxonomy ?>
     1091
     1092<?php endif; // count($flat_taxonomies) && !$bulk  ?>
    10691093
    10701094<?php if ( $bulk ) : ?>
     
    12261250        echo '<div class="menu_order">' . $post->menu_order . '</div>';
    12271251
    1228     if ( is_object_in_taxonomy($post->post_type, 'post_tag') )
    1229         echo '<div class="tags_input">' . esc_html( str_replace( ',', ', ', get_tags_to_edit($post->ID) ) ) . '</div>';
    1230 
    1231     if ( is_object_in_taxonomy($post->post_type, 'post_tag') )
    1232         echo '<div class="post_category">' . implode( ',', wp_get_post_categories( $post->ID ) ) . '</div>';
    1233 
    1234     if ( $post->post_type == 'post' )
     1252    $taxonomy_names = get_object_taxonomies( $post->post_type );
     1253    foreach ( $taxonomy_names as $taxonomy_name) {
     1254        $taxonomy = get_taxonomy( $taxonomy_name );
     1255
     1256        if ( $taxonomy->hierarchical && $taxonomy->show_ui )
     1257                echo '<div class="post_category" id="'.$taxonomy_name.'_'.$post->ID.'">' . implode( ',', wp_get_object_terms( $post->ID, $taxonomy_name, array('fields'=>'ids')) ) . '</div>';
     1258        elseif ( $taxonomy->show_ui )
     1259            echo '<div class="tags_input" id="'.$taxonomy_name.'_'.$post->ID.'">' . esc_html( str_replace( ',', ', ', get_terms_to_edit($post->ID, $taxonomy_name) ) ) . '</div>';
     1260    }
     1261
     1262    if ( !$post_type_object->hierarchical )
    12351263        echo '<div class="sticky">' . (is_sticky($post->ID) ? 'sticky' : '') . '</div>';
    12361264
Note: See TracChangeset for help on using the changeset viewer.