WordPress.org

Make WordPress Core

Changeset 7948


Ignore:
Timestamp:
05/18/2008 08:08:18 PM (10 years ago)
Author:
ryan
Message:

add_meta_box() for edit page form. Props DD32. see #6964

Location:
trunk/wp-admin
Files:
2 edited

Legend:

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

    r7930 r7948  
    348348if ( $authors && count( $authors ) > 1 ) :
    349349function post_author_meta_box($post) {
    350 ?>
    351 <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) ); ?>
     350    global $current_user, $user_ID;
     351    $authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM
     352    if ( $post->post_author && !in_array($post->post_author, $authors) )
     353        $authors[] = $post->post_author;
     354?>
     355<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) ); ?>
    352356<?php
    353357}
  • trunk/wp-admin/edit-page-form.php

    r7913 r7948  
    200200<h2><?php _e('Advanced Options'); ?></h2>
    201201
    202 <div id="pagepostcustom" class="postbox <?php echo postbox_classes('pagepostcustom', 'page'); ?>">
    203 <h3><?php _e('Custom Fields') ?></h3>
    204 <div class="inside">
     202
     203<?php
     204function page_custom_meta_box($post){
     205?>
    205206<div id="postcustomstuff">
    206207<table cellpadding="3">
    207208<?php
    208 $metadata = has_meta($post_ID);
     209$metadata = has_meta($post->ID);
    209210list_meta($metadata);
    210211?>
     
    217218</div>
    218219<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>
    219 </div>
    220 </div>
    221 
    222 <div id="pagecommentstatusdiv" class="postbox <?php echo postbox_classes('pagecommentstatusdiv', 'page'); ?>">
    223 <h3><?php _e('Comments &amp; Pings') ?></h3>
    224 <div class="inside">
     220<?php
     221}
     222add_meta_box('pagecustomdiv', __('Custom Fields'), 'page_custom_meta_box', 'page', 'advanced', 'core');
     223
     224function page_comments_status_meta_box($post){
     225?>
    225226<input name="advanced_view" type="hidden" value="1" />
    226227<p><label for="comment_status" class="selectit">
     
    229230<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>
    230231<p><?php _e('These settings apply to this page only. &#8220;Pings&#8221; are <a href="http://codex.wordpress.org/Introduction_to_Blogging#Managing_Comments" target="_blank">trackbacks and pingbacks</a>.'); ?></p>
    231 </div>
    232 </div>
    233 
    234 <div id="pagepassworddiv" class="postbox <?php echo postbox_classes('pagepassworddiv', 'page'); ?>">
    235 <h3><?php _e('Password Protect This Page') ?></h3>
    236 <div class="inside">
     232<?php
     233}
     234add_meta_box('pagecommentstatusdiv', __('Comments &amp; Pings'), 'page_comments_status_meta_box', 'page', 'advanced', 'core');
     235
     236function page_password_meta_box($post){
     237?>
    237238<p><label class="hidden" for="post_password"><?php _e('Password Protect This Page') ?></label><input name="post_password" type="text" size="25" id="post_password" value="<?php echo attribute_escape( $post->post_password ); ?>" /></p>
    238239<p><?php _e('Setting a password will require people who visit your blog to enter the above password to view this page and its comments.'); ?></p>
    239 </div>
    240 </div>
    241 
    242 <div id="pageslugdiv" class="postbox <?php echo postbox_classes('pageslugdiv', 'page'); ?>">
    243 <h3><?php _e('Page Slug') ?></h3>
    244 <div class="inside">
     240<?php
     241}
     242add_meta_box('pagepassworddiv', __('Password Protect This Page'), 'page_password_meta_box', 'page', 'advanced', 'core');
     243
     244function page_slug_meta_box($post){
     245?>
    245246<label class="hidden" for="post_name"><?php _e('Page Slug') ?></label><input name="post_name" type="text" size="13" id="post_name" value="<?php echo attribute_escape( $post->post_name ); ?>" />
    246 </div>
    247 </div>
    248 
    249 <div id="pageparentdiv" class="postbox <?php echo postbox_classes('pageparentdiv', 'page'); ?>">
    250 <h3><?php _e('Page Parent') ?></h3>
    251 <div class="inside">
    252 <label class="hidden" for="parent_id"><?php _e('Page Parent') ?></label><select name="parent_id" id="parent_id">
     247<?php
     248}
     249add_meta_box('pageslugdiv', __('Page Slug'), 'page_slug_meta_box', 'page', 'advanced', 'core');
     250
     251function page_parent_meta_box($post){
     252?>
     253<label class="hidden" for="parent_id"><?php _e('Page Parent') ?></label>
     254<select name="parent_id" id="parent_id">
    253255<option value='0'><?php _e('Main Page (no parent)'); ?></option>
    254256<?php parent_dropdown($post->post_parent); ?>
    255257</select>
    256258<p><?php _e('You can arrange your pages in hierarchies, for example you could have an &#8220;About&#8221; page that has &#8220;Life Story&#8221; and &#8220;My Dog&#8221; pages under it. There are no limits to how deeply nested you can make pages.'); ?></p>
    257 </div>
    258 </div>
    259 
    260 <?php if ( 0 != count( get_page_templates() ) ) { ?>
    261 <div id="pagetemplatediv" class="postbox <?php echo postbox_classes('pagetemplatediv', 'page'); ?>">
    262 <h3><?php _e('Page Template') ?></h3>
    263 <div class="inside">
     259<?php
     260}
     261add_meta_box('pageparentdiv', __('Page Parent'), 'page_parent_meta_box', 'page', 'advanced', 'core');
     262
     263if ( 0 != count( get_page_templates() ) ) {
     264    function page_template_meta_box($post){
     265?>
    264266<label class="hidden" for="page_template"><?php _e('Page Template') ?></label><select name="page_template" id="page_template">
    265267<option value='default'><?php _e('Default Template'); ?></option>
     
    267269</select>
    268270<p><?php _e('Some themes have custom templates you can use for certain pages that might have additional features or custom layouts. If so, you&#8217;ll see them above.'); ?></p>
    269 </div>
    270 </div>
    271 <?php } ?>
    272 
    273 <div id="pageorderdiv" class="postbox <?php echo postbox_classes('pageorderdiv', 'page'); ?>">
    274 <h3><?php _e('Page Order') ?></h3>
    275 <div class="inside">
     271<?php
     272    }
     273    add_meta_box('pagetemplatediv', __('Page Template'), 'page_template_meta_box', 'page', 'advanced', 'core');
     274}
     275
     276function page_order_meta_box($post){
     277?>
    276278<p><label class="hidden" for="menu_order"><?php _e('Page Order') ?></label><input name="menu_order" type="text" size="4" id="menu_order" value="<?php echo $post->menu_order ?>" /></p>
    277279<p><?php _e('Pages are usually ordered alphabetically, but you can put a number above to change the order pages appear in. (We know this is a little janky, it&#8217;ll be better in future releases.)'); ?></p>
    278 </div>
    279 </div>
    280 
    281 <?php
     280<?php
     281}
     282add_meta_box('pageorderdiv', __('Page Order'), 'page_order_meta_box', 'page', 'advanced', 'core');
     283
     284
    282285$authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM
    283286if ( $post->post_author && !in_array($post->post_author, $authors) )
    284287    $authors[] = $post->post_author;
    285 if ( $authors && count( $authors ) > 1 ) :
    286 ?>
    287 <div id="pageauthordiv" class="postbox <?php echo postbox_classes('pageauthordiv', 'page'); ?>">
    288 <h3><?php _e('Page Author'); ?></h3>
    289 <div class="inside">
    290 <label class="hidden" for="post_author_override"><?php _e('Page Author'); ?></label><?php wp_dropdown_users( array('include' => $authors, 'name' => 'post_author_override', 'selected' => empty($post_ID) ? $user_ID : $post->post_author) ); ?>
    291 </div>
    292 </div>
    293 <?php endif; ?>
    294 
    295 <?php if ( isset($post_ID) && 0 < $post_ID && wp_get_post_revisions( $post_ID ) ) : ?>
    296 <div id="revisionsdiv" class="postbox <?php echo postbox_classes('revisionsdiv', 'page'); ?>">
    297 <h3><?php _e('Page Revisions'); ?></h3>
    298 <div class="inside">
    299 <?php wp_list_post_revisions(); ?>
    300 </div>
    301 </div>
    302 <?php endif; ?>
    303 
    304 
    305 <?php do_meta_boxes('page', 'advanced', $post); ?>
     288if ( $authors && count( $authors ) > 1 ) {
     289    function page_author_meta_box($post){
     290        global $current_user, $user_ID;
     291        $authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM
     292        if ( $post->post_author && !in_array($post->post_author, $authors) )
     293            $authors[] = $post->post_author;
     294?>
     295<label class="hidden" for="post_author_override"><?php _e('Page Author'); ?></label><?php wp_dropdown_users( array('include' => $authors, 'name' => 'post_author_override', 'selected' => empty($post->ID) ? $user_ID : $post->post_author) ); ?>
     296<?php
     297    }
     298    add_meta_box('pageauthordiv', __('Page Author'), 'page_author_meta_box', 'page', 'advanced', 'core');
     299}
     300
     301
     302if ( isset($post_ID) && 0 < $post_ID && wp_get_post_revisions( $post_ID ) ) :
     303function page_revisions_meta_box($post) {
     304    wp_list_post_revisions();
     305}
     306add_meta_box('revisionsdiv', __('Page Revisions'), 'page_revisions_meta_box', 'page', 'advanced', 'core');
     307endif;
     308
     309do_meta_boxes('page', 'advanced', $post);
     310?>
    306311
    307312</div>
Note: See TracChangeset for help on using the changeset viewer.