Make WordPress Core


Ignore:
Timestamp:
05/14/2008 08:22:01 AM (17 years ago)
Author:
ryan
Message:

Add default edit post meta boxes via API. see #6964

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/edit-form-advanced.php

    r7919 r7930  
    226226<?php echo $form_prevstatus ?>
    227227
    228 <div id="tagsdiv" class="postbox <?php echo postbox_classes('tagsdiv', 'post'); ?>">
    229 <h3><?php _e('Tags'); ?></h3>
    230 <div class="inside">
    231 <p id="jaxtag"><label class="hidden" for="newtag"><?php _e('Tags'); ?></label><input type="text" name="tags_input" class="tags-input" id="tags-input" size="40" tabindex="3" value="<?php echo get_tags_to_edit( $post_ID ); ?>" /></p>
     228<?php
     229function post_tags_meta_box($post) {
     230?>
     231<p id="jaxtag"><label class="hidden" for="newtag"><?php _e('Tags'); ?></label><input type="text" name="tags_input" class="tags-input" id="tags-input" size="40" tabindex="3" value="<?php echo get_tags_to_edit( $post->ID ); ?>" /></p>
    232232<div id="tagchecklist"></div>
    233 </div>
    234 </div>
    235 
    236 <div id="categorydiv" class="postbox <?php echo postbox_classes('categorydiv', 'post'); ?>">
    237 <h3><?php _e('Categories') ?></h3>
    238 <div class="inside">
    239 
     233<?php
     234}
     235add_meta_box('tagsdiv', __('Tags'), 'post_tags_meta_box', 'post', 'normal', 'core');
     236
     237function post_categories_meta_box($post) {
     238?>
    240239<div id="category-adder" class="wp-hidden-children">
    241240    <h4><a id="category-add-toggle" href="#category-add" class="hide-if-no-js" tabindex="3"><?php _e( '+ Add New Category' ); ?></a></h4>
     
    262261<div id="categories-all" class="ui-tabs-panel">
    263262    <ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
    264         <?php wp_category_checklist($post_ID) ?>
     263        <?php wp_category_checklist($post->ID) ?>
    265264    </ul>
    266265</div>
    267 
    268 </div>
    269 </div>
     266<?php
     267}
     268add_meta_box('categorydiv', __('Categories'), 'post_categories_meta_box', 'post', 'normal', 'core');
     269?>
    270270
    271271<?php do_meta_boxes('post', 'normal', $post); ?>
     
    275275<h2><?php _e('Advanced Options'); ?></h2>
    276276
    277 <div id="postexcerpt" class="postbox <?php echo postbox_classes('postexcerpt', 'post'); ?>">
    278 <h3><?php _e('Excerpt') ?></h3>
    279 <div class="inside"><label class="hidden" for="excerpt"><?php _e('Excerpt') ?></label><textarea rows="1" cols="40" name="excerpt" tabindex="6" id="excerpt"><?php echo $post->post_excerpt ?></textarea>
     277<?php
     278function post_excerpt_meta_box($post) {
     279?>
     280<label class="hidden" for="excerpt"><?php _e('Excerpt') ?></label><textarea rows="1" cols="40" name="excerpt" tabindex="6" id="excerpt"><?php echo $post->post_excerpt ?></textarea>
    280281<p><?php _e('Excerpts are optional hand-crafted summaries of your content. You can <a href="http://codex.wordpress.org/Template_Tags/the_excerpt" target="_blank">use them in your template</a>'); ?></p>
    281 </div>
    282 </div>
    283 
    284 <div id="trackbacksdiv" class="postbox <?php echo postbox_classes('trackbacksdiv', 'post'); ?>">
    285 <h3><?php _e('Trackbacks') ?></h3>
    286 <div class="inside">
     282<?php
     283}
     284add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', 'post', 'advanced', 'core');
     285
     286function post_trackback_meta_box($post) {
     287?>
    287288<p><label for="trackback"><?php _e('Send trackbacks to:'); ?></label> <?php echo $form_trackback; ?><br /> (<?php _e('Separate multiple URLs with spaces'); ?>)</p>
    288289<p><?php _e('Trackbacks are a way to notify legacy blog systems that you&#8217;ve linked to them. If you link other WordPress blogs they&#8217;ll be notified automatically using <a href="http://codex.wordpress.org/Introduction_to_Blogging#Managing_Comments" target="_blank">pingbacks</a>, no other action necessary.'); ?></p>
     
    290291if ( ! empty($pings) )
    291292    echo $pings;
    292 ?>
    293 </div>
    294 </div>
    295 
    296 <div id="postcustom" class="postbox <?php echo postbox_classes('postcustom', 'post'); ?>">
    297 <h3><?php _e('Custom Fields') ?></h3>
    298 <div class="inside">
     293}
     294add_meta_box('trackbacksdiv', __('Trackbacks'), 'post_trackback_meta_box', 'post', 'advanced', 'core');
     295
     296function post_custom_meta_box($post) {
     297?>
    299298<div id="postcustomstuff">
    300299<table cellpadding="3">
    301300<?php
    302 $metadata = has_meta($post_ID);
     301$metadata = has_meta($post->ID);
    303302list_meta($metadata);
    304303?>
     
    311310</div>
    312311<p><?php _e('Custom fields can be used to add extra metadata to a post that you can <a href="http://codex.wordpress.org/Using_Custom_Fields" target="_blank">use in your theme</a>.'); ?></p>
    313 </div>
    314 </div>
    315 
    316 <?php do_action('dbx_post_advanced'); ?>
    317 
    318 <div id="commentstatusdiv" class="postbox <?php echo postbox_classes('commentstatusdiv', 'post'); ?>">
    319 <h3><?php _e('Comments &amp; Pings') ?></h3>
    320 <div class="inside">
     312<?php
     313}
     314add_meta_box('postcustom', __('Custom Fields'), 'post_custom_meta_box', 'post', 'advanced', 'core');
     315
     316do_action('dbx_post_advanced');
     317
     318function post_comment_status_meta_box($post) {
     319?>
    321320<input name="advanced_view" type="hidden" value="1" />
    322321<p><label for="comment_status" class="selectit">
     
    325324<p><label for="ping_status" class="selectit"><input name="ping_status" type="checkbox" id="ping_status" value="open" <?php checked($post->ping_status, 'open'); ?> /> <?php _e('Allow Pings') ?></label></p>
    326325<p><?php _e('These settings apply to this post only. &#8220;Pings&#8221; are <a href="http://codex.wordpress.org/Introduction_to_Blogging#Managing_Comments" target="_blank">trackbacks and pingbacks</a>.'); ?></p>
    327 </div>
    328 </div>
    329 
    330 <div id="passworddiv" class="postbox <?php echo postbox_classes('passworddiv', 'post'); ?>">
    331 <h3><?php _e('Password Protect This Post') ?></h3>
    332 <div class="inside">
     326<?php
     327}
     328add_meta_box('commentstatusdiv', __('Comments &amp; Pings'), 'post_comment_status_meta_box', 'post', 'advanced', 'core');
     329
     330function post_password_meta_box($post) {
     331?>
    333332<p><label class="hidden" for="post_password"><?php _e('Password Protect This Post') ?></label><input name="post_password" type="text" size="25" id="post_password" value="<?php echo attribute_escape( $post->post_password ); ?>" /></p>
    334333<p><?php _e('Setting a password will require people who visit your blog to enter the above password to view this post and its comments.'); ?></p>
    335 </div>
    336 </div>
    337 
    338 <div id="slugdiv" class="postbox <?php echo postbox_classes('slugdiv', 'post'); ?>">
    339 <h3><?php _e('Post Slug') ?></h3>
    340 <div class="inside">
     334<?php
     335}
     336add_meta_box('passworddiv', __('Password Protect This Post'), 'post_password_meta_box', 'post', 'advanced', 'core');
     337
     338function post_slug_meta_box($post) {
     339?>
    341340<label class="hidden" for="post_name"><?php _e('Post Slug') ?></label><input name="post_name" type="text" size="13" id="post_name" value="<?php echo attribute_escape( $post->post_name ); ?>" />
    342 </div>
    343 </div>
    344 
    345 <?php
     341<?php
     342}
     343add_meta_box('slugdiv', __('Post Slug'), 'post_slug_meta_box', 'post', 'advanced', 'core');
     344
    346345$authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM
    347346if ( $post->post_author && !in_array($post->post_author, $authors) )
    348347    $authors[] = $post->post_author;
    349348if ( $authors && count( $authors ) > 1 ) :
    350 ?>
    351 <div id="authordiv" class="postbox <?php echo postbox_classes('authordiv', 'post'); ?>">
    352 <h3><?php _e('Post Author'); ?></h3>
    353 <div class="inside">
     349function post_author_meta_box($post) {
     350?>
    354351<label class="hidden" for="post_author_override"><?php _e('Post Author'); ?></label><?php wp_dropdown_users( array('include' => $authors, 'name' => 'post_author_override', 'selected' => empty($post_ID) ? $user_ID : $post->post_author) ); ?>
    355 </div>
    356 </div>
    357 <?php endif; ?>
    358 
    359 <?php if ( isset($post_ID) && 0 < $post_ID && wp_get_post_revisions( $post_ID ) ) : ?>
    360 <div id="revisionsdiv" class="postbox <?php echo postbox_classes('revisionsdiv', 'post'); ?>">
    361 <h3><?php _e('Post Revisions'); ?></h3>
    362 <div class="inside">
    363 <?php wp_list_post_revisions(); ?>
    364 </div>
    365 </div>
    366 <?php endif; ?>
    367 
    368 <?php do_meta_boxes('post', 'advanced', $post); ?>
    369 
    370 <?php do_action('dbx_post_sidebar'); ?>
     352<?php
     353}
     354add_meta_box('authordiv', __('Post Author'), 'post_author_meta_box', 'post', 'advanced', 'core');
     355endif;
     356
     357if ( isset($post_ID) && 0 < $post_ID && wp_get_post_revisions( $post_ID ) ) :
     358function post_revisions_meta_box($post) {
     359    wp_list_post_revisions();
     360}
     361add_meta_box('revisionsdiv', __('Post Revisions'), 'post_revisions_meta_box', 'post', 'advanced', 'core');
     362endif;
     363
     364do_meta_boxes('post', 'advanced', $post);
     365
     366do_action('dbx_post_sidebar');
     367?>
    371368</div>
    372369</div>
Note: See TracChangeset for help on using the changeset viewer.