Ticket #23328: 23328.2.patch
| File 23328.2.patch, 3.6 KB (added by , 10 years ago) |
|---|
-
src/wp-admin/css/widgets.css
332 332 } 333 333 334 334 .editwidget { 335 ma rgin: 0 auto;335 max-width: 40em; /* about 80 characters, for readability */ 336 336 } 337 337 338 .editwidget select { 339 width: 100%; 340 } 341 338 342 .editwidget .widget-inside { 339 343 display: block; 340 344 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 select. 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 $sidebar_widget_id = isset( $sidebars_widgets[$sbname][$index] ) ? $sidebars_widgets[$sbname][$index] : false; 310 311 // If the widget ID is set then get the widget name otherwise set a name for the empty option. 312 $select_option_content = $sidebar_widget_id ? sprintf( __( '(currently set to: %s)' ), $wp_registered_widgets[$sidebar_widget_id]['name'] ) : esc_html_x( '(available position)', 'widget' ); 313 314 if ( in_array( $widget_id, $sidebars_widgets[$sbname], true ) ) { 302 315 $selected = selected( $i, $key + 1, false ); 303 echo "\t\t<option value='$i'$selected> $i </option>\n"; 316 } 317 318 echo "\t\t<option value='$i'$selected>$i $select_option_content</option>\n"; 319 $index++; 304 320 } 305 321 echo "\t\t</select>\n"; 306 322 }