WordPress.org

Make WordPress Core


Ignore:
Timestamp:
11/20/2013 04:44:21 AM (6 years ago)
Author:
azaozz
Message:

Widgets: split the sidebars in two containers so there are no empty spaces when they are shown in two columns and some are open, other closed. See #25952.

File:
1 edited

Legend:

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

    r26271 r26285  
    346346
    347347<?php
     348
     349$theme_sidebars = array();
    348350foreach ( $wp_registered_sidebars as $sidebar => $registered_sidebar ) {
    349351    if ( false !== strpos( $registered_sidebar['class'], 'inactive-sidebar' ) || 'orphaned_widgets' == substr( $sidebar, 0, 16 ) ) {
     
    352354            $wrap_class .= ' ' . $registered_sidebar['class'];
    353355
    354 ?>
    355 
     356        ?>
    356357        <div class="<?php echo esc_attr( $wrap_class ); ?>">
    357358            <div class="sidebar-name">
    358359                <div class="sidebar-name-arrow"><br /></div>
    359                 <h3><?php echo esc_html( $registered_sidebar['name'] ); ?>
    360                     <span class="spinner"></span>
    361                 </h3>
     360                <h3><?php echo esc_html( $registered_sidebar['name'] ); ?> <span class="spinner"></span></h3>
    362361            </div>
    363362            <div class="widget-holder inactive">
     
    366365            </div>
    367366        </div>
    368 <?php
     367        <?php
     368    } else {
     369        $theme_sidebars[$sidebar] = $registered_sidebar;
    369370    }
    370371}
     
    376377<div class="widget-liquid-right">
    377378<div id="widgets-right">
    378 <?php
    379 $i = 0;
    380 foreach ( $wp_registered_sidebars as $sidebar => $registered_sidebar ) {
    381     if ( false !== strpos( $registered_sidebar['class'], 'inactive-sidebar' ) || 'orphaned_widgets' == substr( $sidebar, 0, 16 ) )
    382         continue;
    383 
     379<div class="sidebars-column-1">
     380<?php
     381
     382$i = $split = 0;
     383$sidebars_count = count( $theme_sidebars );
     384
     385if ( $sidebars_count > 2 )
     386    $split = ceil( $sidebars_count / 2 );
     387
     388foreach ( $theme_sidebars as $sidebar => $registered_sidebar ) {
    384389    $wrap_class = 'widgets-holder-wrap';
    385390    if ( !empty( $registered_sidebar['class'] ) )
    386391        $wrap_class .= ' sidebar-' . $registered_sidebar['class'];
    387392
    388     if ( $i )
    389         $wrap_class .= ' closed'; ?>
    390 
     393    if ( $i > 0 )
     394        $wrap_class .= ' closed';
     395
     396    if ( $split && $i == $split ) {
     397        ?>
     398        </div><div class="sidebars-column-2">
     399        <?php
     400    }
     401
     402    ?>
    391403    <div class="<?php echo esc_attr( $wrap_class ); ?>">
    392     <div class="sidebar-name">
    393     <div class="sidebar-name-arrow"><br /></div>
    394     <h3><?php echo esc_html( $registered_sidebar['name'] ); ?>
    395     <span class="spinner"></span></h3></div>
    396     <?php wp_list_widget_controls( $sidebar ); // Show the control forms for each of the widgets in this sidebar ?>
    397     </div>
    398 <?php
     404        <div class="sidebar-name">
     405            <div class="sidebar-name-arrow"><br /></div>
     406            <h3><?php echo esc_html( $registered_sidebar['name'] ); ?>  <span class="spinner"></span></h3>
     407        </div>
     408        <?php wp_list_widget_controls( $sidebar ); // Show the control forms for each of the widgets in this sidebar ?>
     409    </div>
     410    <?php
     411
    399412    $i++;
    400 } ?>
     413}
     414
     415?>
     416</div>
    401417</div>
    402418</div>
Note: See TracChangeset for help on using the changeset viewer.