<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[12937] trunk:
Allow registering a meta box callback for setting up meta boxes when creating the edit form for a custom post type
.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/12937">12937</a></dd>
<dt>Author</dt> <dd>ryan</dd>
<dt>Date</dt> <dd>2010-02-03 18:54:42 +0000 (Wed, 03 Feb 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre> Allow registering a meta box callback for setting up meta boxes when creating the edit form for a custom post type. see <a href="http://trac.wordpress.org/ticket/9674">#9674</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadmineditformadvancedphp">trunk/wp-admin/edit-form-advanced.php</a></li>
<li><a href="#trunkwpincludespostphp">trunk/wp-includes/post.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadmineditformadvancedphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/edit-form-advanced.php (12936 => 12937)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/edit-form-advanced.php        2010-02-03 18:19:56 UTC (rev 12936)
+++ trunk/wp-admin/edit-form-advanced.php        2010-02-03 18:54:42 UTC (rev 12937)
</span><span class="lines">@@ -139,6 +139,9 @@
</span><span class="cx"> if ( post_type_supports($post_type, 'revisions') && 0 < $post_ID && wp_get_post_revisions( $post_ID ) )
</span><span class="cx">         add_meta_box('revisionsdiv', __('Revisions'), 'post_revisions_meta_box', $post_type, 'normal', 'core');
</span><span class="cx">
</span><ins>+do_action('add_meta_boxes', $post_type, $post);
+do_action('add_meta_boxes_' . $post_type, $post);
+
</ins><span class="cx"> do_action('do_meta_boxes', $post_type, 'normal', $post);
</span><span class="cx"> do_action('do_meta_boxes', $post_type, 'advanced', $post);
</span><span class="cx"> do_action('do_meta_boxes', $post_type, 'side', $post);
</span></span></pre></div>
<a id="trunkwpincludespostphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/post.php (12936 => 12937)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/post.php        2010-02-03 18:19:56 UTC (rev 12936)
+++ trunk/wp-includes/post.php        2010-02-03 18:54:42 UTC (rev 12937)
</span><span class="lines">@@ -708,6 +708,7 @@
</span><span class="cx"> * delete_cap - The capability that controls deleting a particular object of this post type. Defaults to "delete_$capability_type" (delete_post).
</span><span class="cx"> * hierarchical - Whether the post type is hierarchical. Defaults to false.
</span><span class="cx"> * supports - An alias for calling add_post_type_support() directly. See add_post_type_support() for Documentation. Defaults to none.
</span><ins>+ * 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.
</ins><span class="cx"> *
</span><span class="cx"> * @package WordPress
</span><span class="cx"> * @subpackage Post
</span><span class="lines">@@ -724,7 +725,7 @@
</span><span class="cx">                 $wp_post_types = array();
</span><span class="cx">
</span><span class="cx">         // Args prefixed with an underscore are reserved for internal use.
</span><del>-        $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());
</del><ins>+        $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);
</ins><span class="cx">         $args = wp_parse_args($args, $defaults);
</span><span class="cx">         $args = (object) $args;
</span><span class="cx">
</span><span class="lines">@@ -783,6 +784,9 @@
</span><span class="cx">                 $wp_rewrite->add_permastruct($post_type, "/{$args->rewrite['slug']}/%$post_type%", $args->rewrite['with_front']);
</span><span class="cx">         }
</span><span class="cx">
</span><ins>+        if ( $args->register_meta_box_cb )
+                add_action('add_meta_boxes_' . $post_type, $args->register_meta_box_cb, 10, 1);
+
</ins><span class="cx">         $wp_post_types[$post_type] = $args;
</span><span class="cx">
</span><span class="cx">         return $args;
</span></span></pre>
</div>
</div>
</body>
</html>