Allow registering a meta box callback for setting up meta boxes when creating the edit form for a custom post type. see #9674

git-svn-id: https://develop.svn.wordpress.org/trunk@12937 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2010-02-03 18:54:42 +00:00
parent 012732f59d
commit 5bc5965535
2 changed files with 8 additions and 1 deletions

View File

@ -139,6 +139,9 @@ if ( $authors && count( $authors ) > 1 )
if ( post_type_supports($post_type, 'revisions') && 0 < $post_ID && wp_get_post_revisions( $post_ID ) )
add_meta_box('revisionsdiv', __('Revisions'), 'post_revisions_meta_box', $post_type, 'normal', 'core');
do_action('add_meta_boxes', $post_type, $post);
do_action('add_meta_boxes_' . $post_type, $post);
do_action('do_meta_boxes', $post_type, 'normal', $post);
do_action('do_meta_boxes', $post_type, 'advanced', $post);
do_action('do_meta_boxes', $post_type, 'side', $post);

View File

@ -708,6 +708,7 @@ function get_post_types( $args = array(), $output = 'names' ) {
* delete_cap - The capability that controls deleting a particular object of this post type. Defaults to "delete_$capability_type" (delete_post).
* hierarchical - Whether the post type is hierarchical. Defaults to false.
* supports - An alias for calling add_post_type_support() directly. See add_post_type_support() for Documentation. Defaults to none.
* register_meta_box_cb - Provide a callback function that will be called when setting up the meta boxes for the edit form. Do remove_meta_box() and add_meta_box() calls in the callback.
*
* @package WordPress
* @subpackage Post
@ -724,7 +725,7 @@ function register_post_type($post_type, $args = array()) {
$wp_post_types = array();
// Args prefixed with an underscore are reserved for internal use.
$defaults = array('label' => false, 'publicly_queryable' => null, 'exclude_from_search' => null, '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'hierarchical' => false, 'public' => false, '_show' => false, 'rewrite' => true, 'query_var' => true, 'supports' => array());
$defaults = array('label' => false, 'publicly_queryable' => null, 'exclude_from_search' => null, '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'hierarchical' => false, 'public' => false, '_show' => false, 'rewrite' => true, 'query_var' => true, 'supports' => array(), 'register_meta_box_cb' => null);
$args = wp_parse_args($args, $defaults);
$args = (object) $args;
@ -783,6 +784,9 @@ function register_post_type($post_type, $args = array()) {
$wp_rewrite->add_permastruct($post_type, "/{$args->rewrite['slug']}/%$post_type%", $args->rewrite['with_front']);
}
if ( $args->register_meta_box_cb )
add_action('add_meta_boxes_' . $post_type, $args->register_meta_box_cb, 10, 1);
$wp_post_types[$post_type] = $args;
return $args;