Make WordPress Core


Ignore:
Timestamp:
08/22/2008 06:58:42 PM (18 years ago)
Author:
ryan
Message:

First cut of 'Show on screen' metabox show/hide. Needs styling. see #7552

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/template.php

    r8699 r8712  
    12551255        do_action('do_meta_boxes', $page, $context, $object);
    12561256
     1257        $hidden = get_user_option( "meta-box-hidden_$page" );
     1258
    12571259        echo "<div id='$context-sortables' class='meta-box-sortables'>\n";
    12581260
     
    12711273                        break;
    12721274
    1273 
    12741275                foreach ( array('high', 'sorted', 'core', 'default', 'low') as $priority ) {
    12751276                        foreach ( (array) $wp_meta_boxes[$page][$context][$priority] as $box ) {
     
    12771278                                        continue;
    12781279                                $i++;
    1279                                 echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes($box['id'], $page) . '">' . "\n";
     1280                                $style = '';
     1281                                if ( in_array($box['id'], $hidden) )
     1282                                        $style = 'style="display:none;"';
     1283                                echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes($box['id'], $page) . '" ' . $style . '>' . "\n";
    12801284                                echo "<h3><span class='hndle'>{$box['title']}</span></h3>\n";
    12811285                                echo '<div class="inside">' . "\n";
     
    13161320}
    13171321
     1322function meta_box_prefs($page) {
     1323        global $wp_meta_boxes;
     1324
     1325        if ( empty($wp_meta_boxes[$page]) )
     1326                return;
     1327
     1328        $hidden = get_user_option( "meta-box-hidden_$page" );
     1329
     1330        echo '<ul class="metabox-prefs">';
     1331        foreach ( array_keys($wp_meta_boxes[$page]) as $context ) {
     1332                foreach ( array_keys($wp_meta_boxes[$page][$context]) as $priority ) {
     1333                        foreach ( $wp_meta_boxes[$page][$context][$priority] as $box ) {
     1334                                if ( false == $box || ! $box['title'] )
     1335                                        continue;
     1336                                $box_id = $box['id'];
     1337                                echo '<label for="' . $box_id . '-hide">';
     1338                                echo '<input class="hide-postbox-tog" name="' . $box_id . '-hide" type="checkbox" id="' . $box_id . '-hide" value="' . $box_id . '"' . (! in_array($box_id, $hidden) ? ' checked="checked"' : '') . ' />';
     1339                                echo "{$box['title']}</label>";
     1340                        }
     1341                }
     1342        }
     1343        echo '</ul>';
     1344}
    13181345?>
Note: See TracChangeset for help on using the changeset viewer.