WordPress.org

Make WordPress Core

Changeset 8219


Ignore:
Timestamp:
06/30/2008 11:33:02 PM (12 years ago)
Author:
mdawaffe
Message:

First pass at draggable meta boxes. Meta boxes must now be defined before the first call to do_meta_boxes(). Meta boxes can be dragged from any set of meta boxes to any set of meta boxes on the same page, including the sidebar. Some funkiness with Opera. Untested in IE

Location:
branches/crazyhorse
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/crazyhorse/wp-admin/admin-ajax.php

    r8011 r8219  
    594594    die(get_sample_permalink_html($post_id, $title, $slug));
    595595break;
     596case 'meta-box-order':
     597    check_ajax_referer( 'meta-box-order' );
     598    update_user_option( $GLOBALS['current_user']->ID, "meta-box-order_$_POST[page]", $_POST['order'] );
     599    die('1');
     600    break;
    596601default :
    597602    do_action( 'wp_ajax_' . $_POST['action'] );
  • branches/crazyhorse/wp-admin/edit-form-advanced.php

    r8124 r8219  
    3434<div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
    3535<?php endif; ?>
     36
     37<?php
     38
     39// All meta boxes should be defined and added before the first do_meta_boxes() call (or potentially during the do_meta_boxes action).
     40
     41function post_tags_meta_box($post) {
     42?>
     43<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>
     44<div id="tagchecklist"></div>
     45<?php
     46}
     47add_meta_box('tagsdiv', __('Tags'), 'post_tags_meta_box', 'post', 'normal', 'core');
     48
     49function post_categories_meta_box($post) {
     50?>
     51<div id="category-adder" class="wp-hidden-children">
     52    <h4><a id="category-add-toggle" href="#category-add" class="hide-if-no-js" tabindex="3"><?php _e( '+ Add New Category' ); ?></a></h4>
     53    <p id="category-add" class="wp-hidden-child">
     54        <label class="hidden" for="newcat"><?php _e( 'Add New Category' ); ?></label><input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php _e( 'New category name' ); ?>" tabindex="3" aria-required="true"/>
     55        <label class="hidden" for="newcat_parent"><?php _e('Parent category'); ?>:</label><?php wp_dropdown_categories( array( 'hide_empty' => 0, 'name' => 'newcat_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __('Parent category'), 'tab_index' => 3 ) ); ?>
     56        <input type="button" id="category-add-sumbit" class="add:categorychecklist:category-add button" value="<?php _e( 'Add' ); ?>" tabindex="3" />
     57        <?php wp_nonce_field( 'add-category', '_ajax_nonce', false ); ?>
     58        <span id="category-ajax-response"></span>
     59    </p>
     60</div>
     61
     62<ul id="category-tabs">
     63    <li class="ui-tabs-selected"><a href="#categories-all" tabindex="3"><?php _e( 'All Categories' ); ?></a></li>
     64    <li class="wp-no-js-hidden"><a href="#categories-pop" tabindex="3"><?php _e( 'Most Used' ); ?></a></li>
     65</ul>
     66
     67<div id="categories-pop" class="ui-tabs-panel" style="display: none;">
     68    <ul id="categorychecklist-pop" class="categorychecklist form-no-clear" >
     69        <?php $popular_ids = wp_popular_terms_checklist('category'); ?>
     70    </ul>
     71</div>
     72
     73<div id="categories-all" class="ui-tabs-panel">
     74    <ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
     75        <?php wp_category_checklist($post->ID, false, false, $popular_ids) ?>
     76    </ul>
     77</div>
     78<?php
     79}
     80add_meta_box('categorydiv', __('Categories'), 'post_categories_meta_box', 'post', 'normal', 'core');
     81
     82function post_excerpt_meta_box($post) {
     83?>
     84<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>
     85<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>
     86<?php
     87}
     88add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', 'post', 'advanced', 'core');
     89
     90function post_trackback_meta_box($post) {
     91    $form_trackback = '<input type="text" name="trackback_url" style="width: 415px" id="trackback" tabindex="7" value="'. attribute_escape( str_replace("\n", ' ', $post->to_ping) ) .'" />';
     92    if ('' != $post->pinged) {
     93        $pings = '<p>'. __('Already pinged:') . '</p><ul>';
     94        $already_pinged = explode("\n", trim($post->pinged));
     95        foreach ($already_pinged as $pinged_url) {
     96            $pings .= "\n\t<li>" . wp_specialchars($pinged_url) . "</li>";
     97        }
     98        $pings .= '</ul>';
     99    }
     100
     101?>
     102<p><label for="trackback"><?php _e('Send trackbacks to:'); ?></label> <?php echo $form_trackback; ?><br /> (<?php _e('Separate multiple URLs with spaces'); ?>)</p>
     103<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>
     104<?php
     105if ( ! empty($pings) )
     106    echo $pings;
     107}
     108add_meta_box('trackbacksdiv', __('Trackbacks'), 'post_trackback_meta_box', 'post', 'advanced', 'core');
     109
     110function post_custom_meta_box($post) {
     111?>
     112<div id="postcustomstuff">
     113<table cellpadding="3">
     114<?php
     115$metadata = has_meta($post->ID);
     116list_meta($metadata);
     117?>
     118
     119</table>
     120<?php
     121    meta_form();
     122?>
     123<div id="ajax-response"></div>
     124</div>
     125<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>
     126<?php
     127}
     128add_meta_box('postcustom', __('Custom Fields'), 'post_custom_meta_box', 'post', 'advanced', 'core');
     129
     130do_action('dbx_post_advanced');
     131
     132function post_comment_status_meta_box($post) {
     133?>
     134<input name="advanced_view" type="hidden" value="1" />
     135<p><label for="comment_status" class="selectit">
     136<input name="comment_status" type="checkbox" id="comment_status" value="open" <?php checked($post->comment_status, 'open'); ?> />
     137<?php _e('Allow Comments') ?></label></p>
     138<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>
     139<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>
     140<?php
     141}
     142add_meta_box('commentstatusdiv', __('Comments &amp; Pings'), 'post_comment_status_meta_box', 'post', 'advanced', 'core');
     143
     144function post_password_meta_box($post) {
     145?>
     146<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>
     147<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>
     148<?php
     149}
     150add_meta_box('passworddiv', __('Password Protect This Post'), 'post_password_meta_box', 'post', 'advanced', 'core');
     151
     152function post_slug_meta_box($post) {
     153?>
     154<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 ); ?>" />
     155<?php
     156}
     157add_meta_box('slugdiv', __('Post Slug'), 'post_slug_meta_box', 'post', 'advanced', 'core');
     158
     159$authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM
     160if ( $post->post_author && !in_array($post->post_author, $authors) )
     161    $authors[] = $post->post_author;
     162if ( $authors && count( $authors ) > 1 ) :
     163function post_author_meta_box($post) {
     164    global $current_user, $user_ID;
     165    $authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM
     166    if ( $post->post_author && !in_array($post->post_author, $authors) )
     167        $authors[] = $post->post_author;
     168?>
     169<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) ); ?>
     170<?php
     171}
     172add_meta_box('authordiv', __('Post Author'), 'post_author_meta_box', 'post', 'advanced', 'core');
     173endif;
     174
     175if ( isset($post_ID) && 0 < $post_ID && wp_get_post_revisions( $post_ID ) ) :
     176function post_revisions_meta_box($post) {
     177    wp_list_post_revisions();
     178}
     179add_meta_box('revisionsdiv', __('Post Revisions'), 'post_revisions_meta_box', 'post', 'advanced', 'core');
     180endif;
     181
     182?>
    36183
    37184<form name="post" action="post.php" method="post" id="post">
     
    81228
    82229<div id="poststuff">
     230
     231<div id="side-info-column">
    83232
    84233<div class="submitbox" id="submitpost">
     
    173322</p>
    174323
     324</div>
     325
    175326<div class="side-info">
    176327<h5><?php _e('Related') ?></h5>
     
    193344
    194345<?php do_action('submitpost_box'); ?>
     346
     347<?php do_meta_boxes('post', 'side', $post); ?>
     348
    195349</div>
    196350
     
    218372<?php wp_nonce_field( 'getpermalink', 'getpermalinknonce', false ); ?>
    219373<?php wp_nonce_field( 'samplepermalink', 'samplepermalinknonce', false ); ?>
     374<?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
    220375</div>
    221376
     
    223378<?php echo $form_prevstatus ?>
    224379
    225 <?php
    226 function post_tags_meta_box($post) {
    227 ?>
    228 <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>
    229 <div id="tagchecklist"></div>
    230 <?php
    231 }
    232 add_meta_box('tagsdiv', __('Tags'), 'post_tags_meta_box', 'post', 'normal', 'core');
    233 
    234 function post_categories_meta_box($post) {
    235 ?>
    236 <div id="category-adder" class="wp-hidden-children">
    237     <h4><a id="category-add-toggle" href="#category-add" class="hide-if-no-js" tabindex="3"><?php _e( '+ Add New Category' ); ?></a></h4>
    238     <p id="category-add" class="wp-hidden-child">
    239         <label class="hidden" for="newcat"><?php _e( 'Add New Category' ); ?></label><input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php _e( 'New category name' ); ?>" tabindex="3" aria-required="true"/>
    240         <label class="hidden" for="newcat_parent"><?php _e('Parent category'); ?>:</label><?php wp_dropdown_categories( array( 'hide_empty' => 0, 'name' => 'newcat_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __('Parent category'), 'tab_index' => 3 ) ); ?>
    241         <input type="button" id="category-add-sumbit" class="add:categorychecklist:category-add button" value="<?php _e( 'Add' ); ?>" tabindex="3" />
    242         <?php wp_nonce_field( 'add-category', '_ajax_nonce', false ); ?>
    243         <span id="category-ajax-response"></span>
    244     </p>
    245 </div>
    246 
    247 <ul id="category-tabs">
    248     <li class="ui-tabs-selected"><a href="#categories-all" tabindex="3"><?php _e( 'All Categories' ); ?></a></li>
    249     <li class="wp-no-js-hidden"><a href="#categories-pop" tabindex="3"><?php _e( 'Most Used' ); ?></a></li>
    250 </ul>
    251 
    252 <div id="categories-pop" class="ui-tabs-panel" style="display: none;">
    253     <ul id="categorychecklist-pop" class="categorychecklist form-no-clear" >
    254         <?php $popular_ids = wp_popular_terms_checklist('category'); ?>
    255     </ul>
    256 </div>
    257 
    258 <div id="categories-all" class="ui-tabs-panel">
    259     <ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
    260         <?php wp_category_checklist($post->ID, false, false, $popular_ids) ?>
    261     </ul>
    262 </div>
    263 <?php
    264 }
    265 add_meta_box('categorydiv', __('Categories'), 'post_categories_meta_box', 'post', 'normal', 'core');
    266 ?>
    267 
    268380<?php do_meta_boxes('post', 'normal', $post); ?>
    269381
     
    273385
    274386<?php
    275 function post_excerpt_meta_box($post) {
    276 ?>
    277 <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>
    278 <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>
    279 <?php
    280 }
    281 add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', 'post', 'advanced', 'core');
    282 
    283 function post_trackback_meta_box($post) {
    284     $form_trackback = '<input type="text" name="trackback_url" style="width: 415px" id="trackback" tabindex="7" value="'. attribute_escape( str_replace("\n", ' ', $post->to_ping) ) .'" />';
    285     if ('' != $post->pinged) {
    286         $pings = '<p>'. __('Already pinged:') . '</p><ul>';
    287         $already_pinged = explode("\n", trim($post->pinged));
    288         foreach ($already_pinged as $pinged_url) {
    289             $pings .= "\n\t<li>" . wp_specialchars($pinged_url) . "</li>";
    290         }
    291         $pings .= '</ul>';
    292     }
    293 
    294 ?>
    295 <p><label for="trackback"><?php _e('Send trackbacks to:'); ?></label> <?php echo $form_trackback; ?><br /> (<?php _e('Separate multiple URLs with spaces'); ?>)</p>
    296 <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>
    297 <?php
    298 if ( ! empty($pings) )
    299     echo $pings;
    300 }
    301 add_meta_box('trackbacksdiv', __('Trackbacks'), 'post_trackback_meta_box', 'post', 'advanced', 'core');
    302 
    303 function post_custom_meta_box($post) {
    304 ?>
    305 <div id="postcustomstuff">
    306 <table cellpadding="3">
    307 <?php
    308 $metadata = has_meta($post->ID);
    309 list_meta($metadata);
    310 ?>
    311 
    312 </table>
    313 <?php
    314     meta_form();
    315 ?>
    316 <div id="ajax-response"></div>
    317 </div>
    318 <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>
    319 <?php
    320 }
    321 add_meta_box('postcustom', __('Custom Fields'), 'post_custom_meta_box', 'post', 'advanced', 'core');
    322 
    323 do_action('dbx_post_advanced');
    324 
    325 function post_comment_status_meta_box($post) {
    326 ?>
    327 <input name="advanced_view" type="hidden" value="1" />
    328 <p><label for="comment_status" class="selectit">
    329 <input name="comment_status" type="checkbox" id="comment_status" value="open" <?php checked($post->comment_status, 'open'); ?> />
    330 <?php _e('Allow Comments') ?></label></p>
    331 <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>
    332 <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>
    333 <?php
    334 }
    335 add_meta_box('commentstatusdiv', __('Comments &amp; Pings'), 'post_comment_status_meta_box', 'post', 'advanced', 'core');
    336 
    337 function post_password_meta_box($post) {
    338 ?>
    339 <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>
    340 <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>
    341 <?php
    342 }
    343 add_meta_box('passworddiv', __('Password Protect This Post'), 'post_password_meta_box', 'post', 'advanced', 'core');
    344 
    345 function post_slug_meta_box($post) {
    346 ?>
    347 <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 ); ?>" />
    348 <?php
    349 }
    350 add_meta_box('slugdiv', __('Post Slug'), 'post_slug_meta_box', 'post', 'advanced', 'core');
    351 
    352 $authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM
    353 if ( $post->post_author && !in_array($post->post_author, $authors) )
    354     $authors[] = $post->post_author;
    355 if ( $authors && count( $authors ) > 1 ) :
    356 function post_author_meta_box($post) {
    357     global $current_user, $user_ID;
    358     $authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM
    359     if ( $post->post_author && !in_array($post->post_author, $authors) )
    360         $authors[] = $post->post_author;
    361 ?>
    362 <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) ); ?>
    363 <?php
    364 }
    365 add_meta_box('authordiv', __('Post Author'), 'post_author_meta_box', 'post', 'advanced', 'core');
    366 endif;
    367 
    368 if ( isset($post_ID) && 0 < $post_ID && wp_get_post_revisions( $post_ID ) ) :
    369 function post_revisions_meta_box($post) {
    370     wp_list_post_revisions();
    371 }
    372 add_meta_box('revisionsdiv', __('Post Revisions'), 'post_revisions_meta_box', 'post', 'advanced', 'core');
    373 endif;
    374387
    375388do_meta_boxes('post', 'advanced', $post);
    376389
    377390do_action('dbx_post_sidebar');
     391
    378392?>
    379393</div>
  • branches/crazyhorse/wp-admin/includes/template.php

    r8147 r8219  
    11351135    global $wp_meta_boxes;
    11361136
    1137    
    11381137    if  ( !isset($wp_meta_boxes) )
    11391138        $wp_meta_boxes = array();
     
    11431142        $wp_meta_boxes[$page][$context] = array();
    11441143
     1144    foreach ( array_keys($wp_meta_boxes[$page]) as $a_context ) {
    11451145    foreach ( array('high', 'core', 'default', 'low') as $a_priority ) {
    1146         if ( !isset($wp_meta_boxes[$page][$context][$a_priority][$id]) )
     1146        if ( !isset($wp_meta_boxes[$page][$a_context][$a_priority][$id]) )
    11471147            continue;
     1148
    11481149        // If a core box was previously added or removed by a plugin, don't add.
    11491150        if ( 'core' == $priority ) {
    11501151            // If core box previously deleted, don't add
    1151             if ( false === $wp_meta_boxes[$page][$context][$a_priority][$id] )
     1152            if ( false === $wp_meta_boxes[$page][$a_context][$a_priority][$id] )
    11521153                return;
    11531154            // If box was added with default priority, give it core priority to maintain sort order
    11541155            if ( 'default' == $a_priority ) {
    1155                 $wp_meta_boxes[$page][$context]['core'][$id] = $wp_meta_boxes[$page][$context]['default'][$id];
    1156                 unset($wp_meta_boxes[$page][$context]['default'][$id]);
     1156                $wp_meta_boxes[$page][$a_context]['core'][$id] = $wp_meta_boxes[$page][$a_context]['default'][$id];
     1157                unset($wp_meta_boxes[$page][$a_context]['default'][$id]);
    11571158            }
    11581159            return;
    11591160        }
    11601161        // If no priority given and id already present, use existing priority
    1161         if ( empty($priority) )
     1162        if ( empty($priority) ) {
    11621163            $priority = $a_priority;
    1163         // An id can be in only one priority
    1164         if ( $priority != $a_priority )
    1165             unset($wp_meta_boxes[$page][$context][$a_priority][$id]);
     1164        // else if we're adding to the sorted priortiy, we don't know the title or callback.  Glab them from the previously added context/priority.
     1165        } elseif ( 'sorted' == $priority ) {
     1166            $title = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['title'];
     1167            $callback = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['callback'];
     1168        }
     1169        // An id can be in only one priority and one context
     1170        if ( $priority != $a_priority || $context != $a_context )
     1171            unset($wp_meta_boxes[$page][$a_context][$a_priority][$id]);
     1172    }
    11661173    }
    11671174
    11681175    if ( empty($priority) )
    1169         $priority = low;
     1176        $priority = 'low';
    11701177
    11711178    if ( !isset($wp_meta_boxes[$page][$context][$priority]) )
     
    11771184function do_meta_boxes($page, $context, $object) {
    11781185    global $wp_meta_boxes;
     1186    static $already_sorted = false;
    11791187
    11801188    do_action('do_meta_boxes', $page, $context, $object);
    11811189
    1182     if ( !isset($wp_meta_boxes) || !isset($wp_meta_boxes[$page]) || !isset($wp_meta_boxes[$page][$context]) )
    1183         return;
    1184 
    1185     foreach ( array('high', 'core', 'default', 'low') as $priority ) {
    1186         foreach ( (array) $wp_meta_boxes[$page][$context][$priority] as $box ) {
    1187             if ( false === $box )
    1188                 continue;
    1189             echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes($box['id'], $page) . '">' . "\n";
    1190             echo "<h3>{$box['title']}</h3>\n";
    1191             echo '<div class="inside">' . "\n";
    1192             call_user_func($box['callback'], $object, $box);
    1193             echo "</div>\n";
    1194             echo "</div>\n";
    1195         }
    1196     }
     1190    echo "<div id='$context-sortables' class='meta-box-sortables'>\n";
     1191
     1192    do {
     1193        // Grab the ones the user has manually sorted.  Pull them out of their previous context/priority and into the one the user chose
     1194        if ( !$already_sorted && $sorted = get_user_option( "meta-box-order_$page" ) ) {
     1195            foreach ( $sorted as $box_context => $ids )
     1196                foreach ( explode(',', $ids) as $id )
     1197                    if ( $id )
     1198                        add_meta_box( $id, null, null, $page, $box_context, 'sorted' );
     1199        }
     1200        $already_sorted = true;
     1201
     1202        if ( !isset($wp_meta_boxes) || !isset($wp_meta_boxes[$page]) || !isset($wp_meta_boxes[$page][$context]) )
     1203            break;
     1204
     1205
     1206        foreach ( array('high', 'sorted', 'core', 'default', 'low') as $priority ) {
     1207            foreach ( (array) $wp_meta_boxes[$page][$context][$priority] as $box ) {
     1208                if ( false === $box )
     1209                    continue;
     1210                echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes($box['id'], $page) . '">' . "\n";
     1211                echo "<h3>{$box['title']}</h3>\n";
     1212                echo '<div class="inside">' . "\n";
     1213                call_user_func($box['callback'], $object, $box);
     1214                echo "</div>\n";
     1215                echo "</div>\n";
     1216            }
     1217        }
     1218    } while(0);
     1219
     1220    echo "</div>";
     1221
    11971222}
    11981223
  • branches/crazyhorse/wp-admin/js/post.js

    r7956 r8219  
    7171    // postboxes
    7272    add_postbox_toggles('post');
     73
     74    var postingMetaBox = false; // post once, not once per sortable
     75    jQuery('.meta-box-sortables').sortable( {
     76        connectWith: [ '.meta-box-sortables' ],
     77        handle: 'h3',
     78        update: function() {
     79            if ( postingMetaBox ) {
     80                return;
     81            }
     82            postingMetaBox = true;
     83            var postVars = {
     84                action: 'meta-box-order',
     85                _ajax_nonce: jQuery('#meta-box-order-nonce').val(),
     86                page: 'post'
     87            }
     88            jQuery('.meta-box-sortables').each( function() {
     89                postVars["order[" + this.id.split('-')[0] + "]"] = jQuery(this).sortable( 'toArray' ).join(',');
     90            } );
     91            jQuery.post( postboxL10n.requestFile, postVars, function() {
     92                postingMetaBox = false;
     93            } );
     94        }
     95    } );
    7396
    7497    // Editable slugs
  • branches/crazyhorse/wp-admin/js/postbox.js

    r7290 r8219  
    11function add_postbox_toggles(page) {
    2     jQuery('.postbox h3').prepend('<a class="togbox">+</a> ');
    3     jQuery('.postbox h3').click( function() { jQuery(jQuery(this).parent().get(0)).toggleClass('closed'); save_postboxes_state(page); } );
     2    jQuery('.postbox h3').before('<a class="togbox">+</a> ');
     3    jQuery('.postbox a.togbox').click( function() { jQuery(jQuery(this).parent().get(0)).toggleClass('closed'); save_postboxes_state(page); } );
    44}
    55
  • branches/crazyhorse/wp-admin/wp-admin.css

    r8124 r8219  
    931931/* Post Screen */
    932932
     933.meta-box-sortables {
     934    min-height: 50px;
     935}
     936
     937.postbox {
     938    position: relative;
     939}
     940
    933941#tagsdiv #newtag {
    934942    margin-right: 5px;
     
    11341142    display: block;
    11351143    height: 37px;
    1136     margin-left: -21px;
    1137     margin-top: -10px;
     1144    margin-left: -14px;
     1145    margin-top: -3px;
    11381146    overflow: hidden;
    11391147    position: absolute;
     
    11621170}
    11631171
    1164 .submitbox {
     1172#side-info-column {
    11651173    width: 220px;
    11661174    float: right;
  • branches/crazyhorse/wp-includes/script-loader.php

    r8151 r8219  
    127127        $scripts->add( 'xfn', '/wp-admin/js/xfn.js', false, '3517' );
    128128        $scripts->add( 'upload', '/wp-admin/js/upload.js', array('jquery'), '20070518' );
    129         $scripts->add( 'postbox', '/wp-admin/js/postbox.js', array('jquery'), '20080128' );
     129        $scripts->add( 'postbox', '/wp-admin/js/postbox.js', array('jquery'), '20080630' );
    130130        $scripts->localize( 'postbox', 'postboxL10n', array(
    131131            'requestFile' => admin_url('admin-ajax.php'),
     
    137137            'cancel' => __('Cancel'),
    138138        ) );
    139         $scripts->add( 'post', '/wp-admin/js/post.js', array('suggest', 'jquery-ui-tabs', 'wp-lists', 'postbox', 'slug'), '20080519' );
     139        $scripts->add( 'post', '/wp-admin/js/post.js', array('suggest', 'jquery-ui-tabs', 'jquery-ui-sortable', 'wp-lists', 'postbox', 'slug'), '20080630' );
    140140        $scripts->localize( 'post', 'postL10n', array(
    141141            'tagsUsed' =>  __('Tags used on this post:'),
Note: See TracChangeset for help on using the changeset viewer.