Ticket #23328: 23328.patch
File 23328.patch, 3.5 KB (added by , 8 years ago) |
---|
-
src/wp-admin/css/widgets.css
335 335 } 336 336 337 337 .editwidget { 338 ma rgin: 0 auto;338 max-width: 40em; /* about 80 characters, for readability */ 339 339 } 340 340 341 .editwidget select { 342 width: 100%; 343 } 344 341 345 .editwidget .widget-inside { 342 346 display: block; 343 347 padding: 0 15px; -
src/wp-admin/widgets.php
259 259 $id_base = isset($control['id_base']) ? $control['id_base'] : $control['id']; 260 260 261 261 // Show the widget form. 262 $width = ' style="width:' . max($control['width'], 350) . 'px"';263 262 $key = isset($_GET['key']) ? (int) $_GET['key'] : 0; 264 263 265 264 require_once( ABSPATH . 'wp-admin/admin-header.php' ); ?> 266 265 <div class="wrap"> 267 266 <h1><?php echo esc_html( $title ); ?></h1> 268 <div class="editwidget" <?php echo $width; ?>>267 <div class="editwidget"> 269 268 <h2><?php printf( __( 'Widget %s' ), $name ); ?></h2> 270 269 271 270 <form action="widgets.php" method="post"> … … 279 278 280 279 <p class="describe"><?php _e('Select both the sidebar for this widget and the position of the widget in that sidebar.'); ?></p> 281 280 <div class="widget-position"> 282 <table class="widefat"><thead><tr><th><?php _e('Sidebar'); ?></th><th><?php _e( 'Position'); ?></th></tr></thead><tbody>281 <table class="widefat"><thead><tr><th><?php _e('Sidebar'); ?></th><th><?php _e( 'Widget position' ); ?></th></tr></thead><tbody> 283 282 <?php 284 283 foreach ( $wp_registered_sidebars as $sbname => $sbvalue ) { 285 284 echo "\t\t<tr><td><label><input type='radio' name='sidebar' value='" . esc_attr($sbname) . "'" . checked( $sbname, $sidebar, false ) . " /> $sbvalue[name]</label></td><td>"; … … 291 290 $sidebars_widgets[$sbname] = array(); 292 291 } else { 293 292 $j = count($sidebars_widgets[$sbname]); 294 if ( isset($_GET['addnew']) || !in_array($widget_id, $sidebars_widgets[$sbname], true) ) 293 // When adding a new widget or the edited widget is not in this sidebar, add one more cycle to the loop below. 294 if ( isset($_GET['addnew']) || !in_array($widget_id, $sidebars_widgets[$sbname], true) ) { 295 295 $j++; 296 } 296 297 } 297 298 $selected = ''; 299 $index = 0; 298 300 echo "\t\t<select name='{$sbname}_position'>\n"; 299 301 echo "\t\t<option value=''>" . __('— Select —') . "</option>\n"; 302 /* 303 * When adding a new widget or the edited widget is not in this sidebar, this loop runs 304 * one cycle more than the actual widgets count to build an empty option in the selects. 305 */ 300 306 for ( $i = 1; $i <= $j; $i++ ) { 301 if ( in_array($widget_id, $sidebars_widgets[$sbname], true) ) 307 308 // Get the ID of the widget in the loop. Set it to false when running the additional loop cycle. 309 $wid = isset( $sidebars_widgets[$sbname][$index] ) ? $sidebars_widgets[$sbname][$index] : false; 310 // If the widget ID is set then get the widget name otherwise set a name for the empty option. 311 $wname = $wid ? sprintf( __( '(currently set to: %s)' ), $wp_registered_widgets[$wid]['name'] ) : esc_html_x( '(available position)', 'widget' ); 312 313 if ( in_array( $widget_id, $sidebars_widgets[$sbname], true ) ) { 302 314 $selected = selected( $i, $key + 1, false ); 303 echo "\t\t<option value='$i'$selected> $i </option>\n"; 315 } 316 317 echo "\t\t<option value='$i'$selected>$i $wname</option>\n"; 318 $index++; 304 319 } 305 320 echo "\t\t</select>\n"; 306 321 }