Changeset 61187
- Timestamp:
- 11/09/2025 11:01:32 PM (3 months ago)
- File:
-
- 1 edited
-
trunk/src/wp-admin/widgets-form.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/widgets-form.php
r57295 r61187 188 188 // Remove old position. 189 189 if ( ! isset( $_POST['delete_widget'] ) ) { 190 foreach ( $sidebars_widgets as $ key => $sb) {191 if ( is_array( $s b) ) {192 $sidebars_widgets[ $ key ] = array_diff( $sb, array( $widget_id ) );190 foreach ( $sidebars_widgets as $sidebar_id => $sidebar ) { 191 if ( is_array( $sidebar ) ) { 192 $sidebars_widgets[ $sidebar_id ] = array_diff( $sidebar, array( $widget_id ) ); 193 193 } 194 194 } 195 195 196 array_splice( $sidebars_widgets[ $sidebar_id ], $position, 0, $widget_id ); 196 197 } … … 236 237 foreach ( $wp_registered_widget_controls as $control ) { 237 238 if ( $_GET['base'] === $control['id_base'] ) { 238 $control_callback = $control['callback']; 239 $multi_number = (int) $_GET['num']; 240 $control['params'][0]['number'] = -1; 241 $control['id'] = $control['id_base'] . '-' . $multi_number; 242 $widget_id = $control['id']; 239 $control_callback = $control['callback']; 240 $multi_number = (int) $_GET['num']; 241 $control['params'][0]['number'] = -1; 242 $control['id'] = $control['id_base'] . '-' . $multi_number; 243 $widget_id = $control['id']; 244 243 245 $wp_registered_widget_controls[ $control['id'] ] = $control; 244 246 break; … … 300 302 <table class="widefat"><thead><tr><th><?php _e( 'Sidebar' ); ?></th><th><?php _e( 'Position' ); ?></th></tr></thead><tbody> 301 303 <?php 302 foreach ( $wp_registered_sidebars as $sbname => $sbvalue ) { 303 echo "\t\t<tr><td><label><input type='radio' name='sidebar' value='" . esc_attr( $sbname ) . "'" . checked( $sbname, $sidebar, false ) . " /> $sbvalue[name]</label></td><td>"; 304 if ( 'wp_inactive_widgets' === $sbname || str_starts_with( $sbname, 'orphaned_widgets' ) ) { 304 foreach ( $wp_registered_sidebars as $sidebar_name => $sidebar_data ) { 305 echo "\t\t<tr><td><label><input type='radio' name='sidebar' value='" . esc_attr( $sidebar_name ) . "'" . 306 checked( $sidebar_name, $sidebar, false ) . " /> $sidebar_data[name]</label></td><td>"; 307 308 if ( 'wp_inactive_widgets' === $sidebar_name || str_starts_with( $sidebar_name, 'orphaned_widgets' ) ) { 305 309 echo ' '; 306 310 } else { 307 if ( ! isset( $sidebars_widgets[ $sbname ] ) || ! is_array( $sidebars_widgets[ $sbname ] ) ) { 308 $j = 1; 309 $sidebars_widgets[ $sbname ] = array(); 311 if ( ! isset( $sidebars_widgets[ $sidebar_name ] ) || ! is_array( $sidebars_widgets[ $sidebar_name ] ) ) { 312 $widget_count = 1; 313 314 $sidebars_widgets[ $sidebar_name ] = array(); 310 315 } else { 311 $j = count( $sidebars_widgets[ $sbname ] ); 312 if ( isset( $_GET['addnew'] ) || ! in_array( $widget_id, $sidebars_widgets[ $sbname ], true ) ) { 313 ++$j; 316 $widget_count = count( $sidebars_widgets[ $sidebar_name ] ); 317 318 if ( isset( $_GET['addnew'] ) || ! in_array( $widget_id, $sidebars_widgets[ $sidebar_name ], true ) ) { 319 ++$widget_count; 314 320 } 315 321 } 322 316 323 $selected = ''; 317 echo "\t\t<select name='{$sbname}_position'>\n"; 324 325 echo "\t\t<select name='{$sidebar_name}_position'>\n"; 318 326 echo "\t\t<option value=''>" . __( '— Select —' ) . "</option>\n"; 319 for ( $i = 1; $i <= $j; $i++ ) { 320 if ( in_array( $widget_id, $sidebars_widgets[ $sbname ], true ) ) { 327 328 for ( $i = 1; $i <= $widget_count; $i++ ) { 329 if ( in_array( $widget_id, $sidebars_widgets[ $sidebar_name ], true ) ) { 321 330 $selected = selected( $i, $key + 1, false ); 322 331 } 332 323 333 echo "\t\t<option value='$i'$selected> $i </option>\n"; 324 334 } 335 325 336 echo "\t\t</select>\n"; 326 337 } 338 327 339 echo "</td></tr>\n"; 328 340 } … … 513 525 <?php 514 526 515 $ i= 0;527 $sidebar_index = 0; 516 528 $split = 0; 517 529 $single_sidebar_class = ''; … … 536 548 } 537 549 538 if ( $ i> 0 ) {550 if ( $sidebar_index > 0 ) { 539 551 $wrap_class .= ' closed'; 540 552 } 541 553 542 if ( $split && $ i=== $split ) {554 if ( $split && $sidebar_index === $split ) { 543 555 ?> 544 556 </div><div class="sidebars-column-2"> … … 555 567 <?php 556 568 557 ++$ i;569 ++$sidebar_index; 558 570 } 559 571
Note: See TracChangeset
for help on using the changeset viewer.