mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
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: http://svn.automattic.com/wordpress/trunk@12937 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
d1069acd38
commit
d45311c9fb
@ -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);
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user