register_term_group
Description
Adds a term group to the global list.
Synopsis
<?php register_term_group( $name , $args = array( 'nicename' => NULL , 'description' => NULL , 'parents' => array() , 'children' => array() , 'post_type' => array( 'post' ) , 'add_meta_box' => false , 'restrict_meta_box' => false , 'meta_box_context' => 'normal' , 'meta_box_priority' => 'high' , 'meta_box_hook_priority' => 10 , 'show_checktable' => true , 'checktable_cols' => 5 , 'checktable_nicename' => NULL , 'checktable_lock' => false , 'checktable_read_only' => false, 'use_thumbnail' => false , 'checktable_taxonomy' => 'category' , 'checktable_unique' => false , 'hide_checktable_for' => array() , 'hide_in_list_for' => array() , 'show_title' => true , 'show_empty_title' => false , 'error_message_none' => NULL , 'show_new_term' => true , 'show_empty_new_term' => true , 'is_folder' => false , 'template' => NULL , 'custom_fields' => array(), /* array of arrays with props key, nicename, description, form_function, save_function, value_function */ 'tag_function' => NULL , 'tag_function_args' => NULL , 'tag_format' => '%s' , /* separators for terms of the group */ 'tag_sep' => __( ' ' ) , 'tag_last_sep' => __( ' ' ) , /* separators for children of the group */ 'sep' => __( ', ' , 'zyx-term-meta' ) , 'last_sep' => __( ' and ' , 'zyx-term-meta' ) , 'tag_class' => NULL , 'children_before_depth' => array() , 'children_after_depth' => array() ) ); ?>
Source
<?php function register_term_group( $name , $args = NULL ){ // ToDo : check the post types against the registered post types? Here may be too early... global $zyx_term_groups, $zyx_term_group_list ; $args = wp_parse_args( $args, array( 'nicename' => NULL , 'description' => NULL , 'parents' => array() , 'children' => array() , 'post_type' => array( 'post' ) , 'add_meta_box' => false , 'restrict_meta_box' => false , 'meta_box_context' => 'normal' , 'meta_box_priority' => 'high' , 'meta_box_hook_priority' => 10 , 'show_checktable' => true , 'checktable_cols' => 5 , 'checktable_nicename' => NULL , 'checktable_lock' => false , 'checktable_read_only' => false, 'use_thumbnail' => false , 'checktable_taxonomy' => 'category' , 'checktable_unique' => false , 'hide_checktable_for' => array() , 'hide_in_list_for' => array() , 'show_title' => true , 'show_empty_title' => false , 'error_message_none' => NULL , 'show_new_term' => true , 'show_empty_new_term' => true , 'is_folder' => false , 'template' => NULL , 'custom_fields' => array(), /* array of arrays with props key, nicename, description, form_function, save_function, value_function */ 'tag_function' => NULL , 'tag_function_args' => NULL , 'tag_format' => '%s' , /* separators for terms of the group */ 'tag_sep' => __( ' ' ) , 'tag_last_sep' => __( ' ' ) , /* separators for children of the group */ 'sep' => __( ', ' , 'zyx-term-meta' ) , 'last_sep' => __( ' and ' , 'zyx-term-meta' ) , 'tag_class' => NULL , 'children_before_depth' => array() , 'children_after_depth' => array() ) ); if( ( !isset( $zyx_term_groups[$name] ) ) || ( !$zyx_term_groups[$name] ) ){ $zyx_term_group_list[] = $name; $args['name'] = $name; if( !$args['children'] ) $args['children'] = array(); if( !$args['template'] ) $args['template'] = 'term_group-' . $name ; $args['nicename'] = $args['nicename'] ? $args['nicename'] : $name ; if( !$args['checktable_nicename'] ) $args['checktable_nicename'] = $args['nicename']; $args['description'] = $args['description'] ? $args['description'] : $args['nicename'] ; if( !$args['tag_class'] ) $args['tag_class'] = $name . '_term' ; $num_parents = count( $args['parents'] ) ; if( $num_parents ){ for( $i = 0 ; $i < $num_parents ; $i++ ){ if( term_group_exists( $parent_name = $args['parents'][$i] ) ){ if( !$zyx_term_groups[$parent_name]['children'] ) $zyx_term_groups[$parent_name]['children'] = array() ; if( !in_array( $name, $zyx_term_groups[$parent_name]['children'] ) ) $zyx_term_groups[$parent_name]['children'][] = $name ; }; }; } ; $args['count'] = 0 ; $zyx_term_groups[$name] = $args ; if ( $args['add_meta_box'] ) add_term_group_meta_boxes( $name ) ; }; }; ?>