[wp-trac] [WordPress Trac] #14877: Ability to create exclusive custom taxonomies

WordPress Trac wp-trac at lists.automattic.com
Tue Sep 27 16:01:32 UTC 2011


#14877: Ability to create exclusive custom taxonomies
-----------------------------+-----------------------------
 Reporter:  benbalter        |       Owner:  nacin
     Type:  feature request  |      Status:  reviewing
 Priority:  normal           |   Milestone:  Future Release
Component:  Taxonomy         |     Version:
 Severity:  minor            |  Resolution:
 Keywords:                   |
-----------------------------+-----------------------------
Changes (by sanchothefat):

 * cc: sanchothefat (added)


Comment:

 This is something I really really wanna see in core.

 Just my thoughts on the initial post here:

 Where we have 'heirarchical' => true it would make more sense to me to
 have a 'type' argument which would accept one of:

  - heirarchical
  - exclusive
  - flat

 My reasoning here is that an exclusive taxonomy could not be heirarchical.
 If it's one term it shouldn't be in another. The value 'flat' would equate
 to the tag style taxonomy.

 There's another benefit to this approach which is that core methods could
 be added to register valid taxonomy types. The register_taxonomy_type
 function would take the type id and a callback function for the metabox.
 It'd be a neater solution to creating custom taxonomy meta boxes as well.

 An example pseudocode function:

 {{{
 register_taxonomy_type( $type, $meta_box, $editable = true, $terms ) {

     // add $type to valid taxonomy types

     // associate the meta box callback function with the $type

     // if $editable is false then don't show 'add new' links or main admin
 UI
     // and rescind manage_terms capabilities

     // if $terms is supplied these would be the default terms in the
 taxonomy
     // $terms should be required when $editable is false

 }
 }}}

 So for post formats you'd have:

 {{{
 register_taxonomy_type(
     'post_format',
     'post_formats_meta_box',
     false,
     array( 'gallery' => __( 'Gallery' ), 'video' => __( 'Video' ),
 ...etc... )
 );
 }}}


 With regards to backwards compatibility it would simply be a case of if
 the 'type' argument is not present the 'heirarchical' boolean is mapped to
 the 'heirarchical' or 'flat' taxonomy types.

 This is probably what you had in mind already but wanted to get my ideas
 down in the appropriate place.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/14877#comment:11>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list