Make WordPress Core


Ignore:
Timestamp:
09/03/2011 03:01:11 AM (12 years ago)
Author:
azaozz
Message:

Moves orphaned sidebars to main content area above Inactive Widgets, props aaroncampbell, see #17979

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/widgets.php

    r18630 r18631  
    5151    $sidebars_widgets = wp_get_widget_defaults();
    5252
    53 // register the inactive_widgets area as sidebar
    54 register_sidebar(array(
    55     'name' => __('Inactive Widgets'),
    56     'id' => 'wp_inactive_widgets',
    57     'class' => 'inactive',
    58     'description' => '',
    59     'before_widget' => '',
    60     'after_widget' => '',
    61     'before_title' => '',
    62     'after_title' => '',
    63 ));
    64 
    6553foreach ( $sidebars_widgets as $sidebar_id => $widgets ) {
     54    if ( 'wp_inactive_widgets' == $sidebar_id )
     55        continue;
     56
    6657    if ( empty( $wp_registered_sidebars[ $sidebar_id ] ) && ! empty( $widgets ) ) {
    6758        // register the inactive_widgets area as sidebar
    6859        register_sidebar(array(
    69             'name' => __( 'Inactive Widgets (Previous Theme)' ),
     60            'name' => __( 'Inactive Sidebar (from previous theme)' ),
    7061            'id' => $sidebar_id,
    71             'class' => 'orphaned',
     62            'class' => 'inactive-sidebar orphan-sidebar',
    7263            'description' => __( 'This is a left over sidebar from an old theme and does not show anywhere on your site' ),
    7364            'before_widget' => '',
     
    7869    }
    7970}
     71
     72// register the inactive_widgets area as sidebar
     73register_sidebar(array(
     74    'name' => __('Inactive Widgets'),
     75    'id' => 'wp_inactive_widgets',
     76    'class' => 'inactive-sidebar',
     77    'description' => 'Drag widgets here to remove them from the sidebar but keep their settings.',
     78    'before_widget' => '',
     79    'after_widget' => '',
     80    'before_title' => '',
     81    'after_title' => '',
     82));
    8083
    8184retrieve_widgets();
     
    229232    foreach ( $wp_registered_sidebars as $sbname => $sbvalue ) {
    230233        echo "\t\t<tr><td><label><input type='radio' name='sidebar' value='" . esc_attr($sbname) . "'" . checked( $sbname, $sidebar, false ) . " /> $sbvalue[name]</label></td><td>";
    231         if ( 'wp_inactive_widgets' == $sbname ) {
     234        if ( 'wp_inactive_widgets' == $sbname || 'orphaned_widgets' == substr( $sbname, 0, 16 ) ) {
    232235            echo '&nbsp;';
    233236        } else {
     
    318321    </div>
    319322
    320     <div class="widgets-holder-wrap">
    321         <div class="sidebar-name">
    322         <div class="sidebar-name-arrow"><br /></div>
    323         <h3><?php _e('Inactive Widgets'); ?>
    324         <span><img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-feedback" title="" alt="" /></span></h3></div>
    325         <div class="widget-holder inactive">
    326         <p class="description"><?php _e('Drag widgets here to remove them from the sidebar but keep their settings.'); ?></p>
    327         <?php wp_list_widget_controls('wp_inactive_widgets'); ?>
    328         <br class="clear" />
     323<?php
     324foreach ( $wp_registered_sidebars as $sidebar => $registered_sidebar ) {
     325    if ( 'wp_inactive_widgets' == $sidebar || 'orphaned_widgets' == substr( $sidebar, 0, 16 ) ) {
     326        $wrap_class = 'widgets-holder-wrap';
     327        if ( !empty( $registered_sidebar['class'] ) )
     328            $wrap_class .= ' ' . $registered_sidebar['class'];
     329
     330?>
     331
     332        <div class="<?php esc_attr_e( $wrap_class ); ?>">
     333            <div class="sidebar-name">
     334                <div class="sidebar-name-arrow"><br /></div>
     335                <h3><?php esc_html_e( $registered_sidebar['name'] ); ?>
     336                    <span><img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-feedback" title="" alt="" /></span>
     337                </h3>
     338            </div>
     339            <div class="widget-holder inactive">
     340                <?php wp_list_widget_controls( $registered_sidebar['id'] ); ?>
     341                <br class="clear" />
     342            </div>
    329343        </div>
    330     </div>
     344<?php
     345    }
     346}
     347?>
     348
    331349</div>
    332350</div>
     
    337355$i = 0;
    338356foreach ( $wp_registered_sidebars as $sidebar => $registered_sidebar ) {
    339     if ( 'wp_inactive_widgets' == $sidebar )
     357    if ( 'wp_inactive_widgets' == $sidebar || 'orphaned_widgets' == substr( $sidebar, 0, 16 ) )
    340358        continue;
    341359
Note: See TracChangeset for help on using the changeset viewer.