mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
Introduce a meta_box_cb argument for register_taxonomy().
The specified callback function is used as the meta box callback for the taxonomy. props garyc40, helen. fixes #14206. Built from https://develop.svn.wordpress.org/trunk@25572 git-svn-id: http://core.svn.wordpress.org/trunk@25489 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
b07e886ed4
commit
5febb6045f
@ -140,16 +140,18 @@ if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post_type,
|
|||||||
|
|
||||||
// all taxonomies
|
// all taxonomies
|
||||||
foreach ( get_object_taxonomies( $post ) as $tax_name ) {
|
foreach ( get_object_taxonomies( $post ) as $tax_name ) {
|
||||||
$taxonomy = get_taxonomy($tax_name);
|
$taxonomy = get_taxonomy( $tax_name );
|
||||||
if ( ! $taxonomy->show_ui )
|
if ( ! $taxonomy->show_ui )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
$label = $taxonomy->labels->name;
|
$label = $taxonomy->labels->name;
|
||||||
|
|
||||||
if ( !is_taxonomy_hierarchical($tax_name) )
|
if ( ! is_taxonomy_hierarchical( $tax_name ) )
|
||||||
add_meta_box('tagsdiv-' . $tax_name, $label, 'post_tags_meta_box', null, 'side', 'core', array( 'taxonomy' => $tax_name ));
|
$tax_meta_box_id = 'tagsdiv-' . $tax_name;
|
||||||
else
|
else
|
||||||
add_meta_box($tax_name . 'div', $label, 'post_categories_meta_box', null, 'side', 'core', array( 'taxonomy' => $tax_name ));
|
$tax_meta_box_id = $tax_name . 'div';
|
||||||
|
|
||||||
|
add_meta_box( $tax_meta_box_id, $label, $taxonomy->meta_box_cb, null, 'side', 'core', array( 'taxonomy' => $tax_name ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( post_type_supports($post_type, 'page-attributes') )
|
if ( post_type_supports($post_type, 'page-attributes') )
|
||||||
|
@ -1139,8 +1139,8 @@ function get_post_types( $args = array(), $output = 'names', $operator = 'and' )
|
|||||||
* - map_meta_cap - Whether to use the internal default meta capability handling. Defaults to false.
|
* - map_meta_cap - Whether to use the internal default meta capability handling. Defaults to false.
|
||||||
* - supports - An alias for calling add_post_type_support() directly. Defaults to title and editor.
|
* - supports - An alias for calling add_post_type_support() directly. Defaults to title and editor.
|
||||||
* * See {@link add_post_type_support()} for documentation.
|
* * See {@link add_post_type_support()} for documentation.
|
||||||
* - register_meta_box_cb - Provide a callback function that will be called when setting up the
|
* - register_meta_box_cb - Provide a callback function that sets up the meta boxes
|
||||||
* meta boxes for the edit form. Do remove_meta_box() and add_meta_box() calls in the callback.
|
* for the edit form. Do remove_meta_box() and add_meta_box() calls in the callback.
|
||||||
* - taxonomies - An array of taxonomy identifiers that will be registered for the post type.
|
* - taxonomies - An array of taxonomy identifiers that will be registered for the post type.
|
||||||
* * Default is no taxonomies.
|
* * Default is no taxonomies.
|
||||||
* * Taxonomies can be registered later with register_taxonomy() or register_taxonomy_for_object_type().
|
* * Taxonomies can be registered later with register_taxonomy() or register_taxonomy_for_object_type().
|
||||||
|
@ -289,6 +289,8 @@ function is_taxonomy_hierarchical($taxonomy) {
|
|||||||
* * If not set, the default is inherited from public.
|
* * If not set, the default is inherited from public.
|
||||||
* - show_tagcloud - Whether to list the taxonomy in the Tag Cloud Widget.
|
* - show_tagcloud - Whether to list the taxonomy in the Tag Cloud Widget.
|
||||||
* * If not set, the default is inherited from show_ui.
|
* * If not set, the default is inherited from show_ui.
|
||||||
|
* - meta_box_cb - Provide a callback function for the meta box display. Defaults to
|
||||||
|
* post_categories_meta_box for hierarchical taxonomies and post_tags_meta_box for non-hierarchical.
|
||||||
* - capabilities - Array of capabilities for this taxonomy.
|
* - capabilities - Array of capabilities for this taxonomy.
|
||||||
* * You can see accepted values in this function.
|
* * You can see accepted values in this function.
|
||||||
* - rewrite - Triggers the handling of rewrites for this taxonomy. Defaults to true, using $taxonomy as slug.
|
* - rewrite - Triggers the handling of rewrites for this taxonomy. Defaults to true, using $taxonomy as slug.
|
||||||
@ -332,6 +334,7 @@ function register_taxonomy( $taxonomy, $object_type, $args = array() ) {
|
|||||||
'show_in_menu' => null,
|
'show_in_menu' => null,
|
||||||
'show_in_nav_menus' => null,
|
'show_in_nav_menus' => null,
|
||||||
'show_tagcloud' => null,
|
'show_tagcloud' => null,
|
||||||
|
'meta_box_cb' => null,
|
||||||
'capabilities' => array(),
|
'capabilities' => array(),
|
||||||
'rewrite' => true,
|
'rewrite' => true,
|
||||||
'query_var' => $taxonomy,
|
'query_var' => $taxonomy,
|
||||||
@ -401,6 +404,14 @@ function register_taxonomy( $taxonomy, $object_type, $args = array() ) {
|
|||||||
$args['labels'] = get_taxonomy_labels( (object) $args );
|
$args['labels'] = get_taxonomy_labels( (object) $args );
|
||||||
$args['label'] = $args['labels']->name;
|
$args['label'] = $args['labels']->name;
|
||||||
|
|
||||||
|
// If not set, use the default meta box
|
||||||
|
if ( null === $args['meta_box_cb'] ) {
|
||||||
|
if ( $args['hierarchical'] )
|
||||||
|
$args['meta_box_cb'] = 'post_categories_meta_box';
|
||||||
|
else
|
||||||
|
$args['meta_box_cb'] = 'post_tags_meta_box';
|
||||||
|
}
|
||||||
|
|
||||||
$wp_taxonomies[ $taxonomy ] = (object) $args;
|
$wp_taxonomies[ $taxonomy ] = (object) $args;
|
||||||
|
|
||||||
// register callback handling for metabox
|
// register callback handling for metabox
|
||||||
|
Loading…
Reference in New Issue
Block a user