66 ) |
66 ) |
67 ); |
67 ); |
68 |
68 |
69 get_current_screen()->set_help_sidebar( |
69 get_current_screen()->set_help_sidebar( |
70 '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . |
70 '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . |
71 '<p>' . __( '<a href="https://wordpress.org/support/article/appearance-widgets-screen/">Documentation on Widgets</a>' ) . '</p>' . |
71 '<p>' . __( '<a href="https://wordpress.org/documentation/article/appearance-widgets-screen-classic-editor/">Documentation on Widgets</a>' ) . '</p>' . |
72 '<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>' |
72 '<p>' . __( '<a href="https://wordpress.org/support/forums/">Support forums</a>' ) . '</p>' |
73 ); |
73 ); |
74 |
74 |
75 // These are the widgets grouped by sidebar. |
75 // These are the widgets grouped by sidebar. |
76 $sidebars_widgets = wp_get_sidebars_widgets(); |
76 $sidebars_widgets = wp_get_sidebars_widgets(); |
77 |
77 |
270 |
270 |
271 // Show the widget form. |
271 // Show the widget form. |
272 $width = ' style="width:' . max( $control['width'], 350 ) . 'px"'; |
272 $width = ' style="width:' . max( $control['width'], 350 ) . 'px"'; |
273 $key = isset( $_GET['key'] ) ? (int) $_GET['key'] : 0; |
273 $key = isset( $_GET['key'] ) ? (int) $_GET['key'] : 0; |
274 |
274 |
275 require_once ABSPATH . 'wp-admin/admin-header.php'; ?> |
275 require_once ABSPATH . 'wp-admin/admin-header.php'; |
|
276 ?> |
276 <div class="wrap"> |
277 <div class="wrap"> |
277 <h1><?php echo esc_html( $title ); ?></h1> |
278 <h1><?php echo esc_html( $title ); ?></h1> |
278 <div class="editwidget"<?php echo $width; ?>> |
279 <div class="editwidget"<?php echo $width; ?>> |
279 <h2> |
280 <h2> |
280 <?php |
281 <?php |
298 <div class="widget-position"> |
299 <div class="widget-position"> |
299 <table class="widefat"><thead><tr><th><?php _e( 'Sidebar' ); ?></th><th><?php _e( 'Position' ); ?></th></tr></thead><tbody> |
300 <table class="widefat"><thead><tr><th><?php _e( 'Sidebar' ); ?></th><th><?php _e( 'Position' ); ?></th></tr></thead><tbody> |
300 <?php |
301 <?php |
301 foreach ( $wp_registered_sidebars as $sbname => $sbvalue ) { |
302 foreach ( $wp_registered_sidebars as $sbname => $sbvalue ) { |
302 echo "\t\t<tr><td><label><input type='radio' name='sidebar' value='" . esc_attr( $sbname ) . "'" . checked( $sbname, $sidebar, false ) . " /> $sbvalue[name]</label></td><td>"; |
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>"; |
303 if ( 'wp_inactive_widgets' === $sbname || 'orphaned_widgets' === substr( $sbname, 0, 16 ) ) { |
304 if ( 'wp_inactive_widgets' === $sbname || str_starts_with( $sbname, 'orphaned_widgets' ) ) { |
304 echo ' '; |
305 echo ' '; |
305 } else { |
306 } else { |
306 if ( ! isset( $sidebars_widgets[ $sbname ] ) || ! is_array( $sidebars_widgets[ $sbname ] ) ) { |
307 if ( ! isset( $sidebars_widgets[ $sbname ] ) || ! is_array( $sidebars_widgets[ $sbname ] ) ) { |
307 $j = 1; |
308 $j = 1; |
308 $sidebars_widgets[ $sbname ] = array(); |
309 $sidebars_widgets[ $sbname ] = array(); |
309 } else { |
310 } else { |
310 $j = count( $sidebars_widgets[ $sbname ] ); |
311 $j = count( $sidebars_widgets[ $sbname ] ); |
311 if ( isset( $_GET['addnew'] ) || ! in_array( $widget_id, $sidebars_widgets[ $sbname ], true ) ) { |
312 if ( isset( $_GET['addnew'] ) || ! in_array( $widget_id, $sidebars_widgets[ $sbname ], true ) ) { |
312 $j++; |
313 ++$j; |
313 } |
314 } |
314 } |
315 } |
315 $selected = ''; |
316 $selected = ''; |
316 echo "\t\t<select name='{$sbname}_position'>\n"; |
317 echo "\t\t<select name='{$sbname}_position'>\n"; |
317 echo "\t\t<option value=''>" . __( '— Select —' ) . "</option>\n"; |
318 echo "\t\t<option value=''>" . __( '— Select —' ) . "</option>\n"; |
330 </div> |
331 </div> |
331 |
332 |
332 <div class="widget-control-actions"> |
333 <div class="widget-control-actions"> |
333 <div class="alignleft"> |
334 <div class="alignleft"> |
334 <?php if ( ! isset( $_GET['addnew'] ) ) : ?> |
335 <?php if ( ! isset( $_GET['addnew'] ) ) : ?> |
335 <input type="submit" name="removewidget" id="removewidget" class="button-link button-link-delete widget-control-remove" value="<?php _e( 'Delete' ); ?>" /> |
336 <input type="submit" name="removewidget" id="removewidget" class="button-link button-link-delete widget-control-remove" value="<?php esc_attr_e( 'Delete' ); ?>" /> |
336 <span class="widget-control-close-wrapper"> |
337 <span class="widget-control-close-wrapper"> |
337 | <a href="widgets.php" class="button-link widget-control-close"><?php _e( 'Cancel' ); ?></a> |
338 | <a href="widgets.php" class="button-link widget-control-close"><?php _e( 'Cancel' ); ?></a> |
338 </span> |
339 </span> |
339 <?php else : ?> |
340 <?php else : ?> |
340 <a href="widgets.php" class="button-link widget-control-close"><?php _e( 'Cancel' ); ?></a> |
341 <a href="widgets.php" class="button-link widget-control-close"><?php _e( 'Cancel' ); ?></a> |
400 <a id="access-on" href="widgets.php?widgets-access=on&_wpnonce=<?php echo urlencode( $nonce ); ?>"><?php _e( 'Enable accessibility mode' ); ?></a><a id="access-off" href="widgets.php?widgets-access=off&_wpnonce=<?php echo urlencode( $nonce ); ?>"><?php _e( 'Disable accessibility mode' ); ?></a> |
401 <a id="access-on" href="widgets.php?widgets-access=on&_wpnonce=<?php echo urlencode( $nonce ); ?>"><?php _e( 'Enable accessibility mode' ); ?></a><a id="access-off" href="widgets.php?widgets-access=off&_wpnonce=<?php echo urlencode( $nonce ); ?>"><?php _e( 'Disable accessibility mode' ); ?></a> |
401 </div> |
402 </div> |
402 |
403 |
403 <hr class="wp-header-end"> |
404 <hr class="wp-header-end"> |
404 |
405 |
405 <?php if ( isset( $_GET['message'] ) && isset( $messages[ $_GET['message'] ] ) ) { ?> |
406 <?php |
406 <div id="message" class="updated notice is-dismissible"><p><?php echo $messages[ $_GET['message'] ]; ?></p></div> |
407 if ( isset( $_GET['message'] ) && isset( $messages[ $_GET['message'] ] ) ) { |
407 <?php } ?> |
408 wp_admin_notice( |
408 <?php if ( isset( $_GET['error'] ) && isset( $errors[ $_GET['error'] ] ) ) { ?> |
409 $messages[ $_GET['message'] ], |
409 <div id="message" class="error"><p><?php echo $errors[ $_GET['error'] ]; ?></p></div> |
410 array( |
410 <?php } ?> |
411 'id' => 'message', |
411 |
412 'additional_classes' => array( 'updated' ), |
412 <?php |
413 'dismissible' => true, |
|
414 ) |
|
415 ); |
|
416 } |
|
417 if ( isset( $_GET['error'] ) && isset( $errors[ $_GET['error'] ] ) ) { |
|
418 wp_admin_notice( |
|
419 $errors[ $_GET['error'] ], |
|
420 array( |
|
421 'id' => 'message', |
|
422 'additional_classes' => array( 'error' ), |
|
423 'dismissible' => true, |
|
424 ) |
|
425 ); |
|
426 } |
|
427 |
413 /** |
428 /** |
414 * Fires before the Widgets administration page content loads. |
429 * Fires before the Widgets administration page content loads. |
415 * |
430 * |
416 * @since 3.0.0 |
431 * @since 3.0.0 |
417 */ |
432 */ |
421 <div class="widget-liquid-left"> |
436 <div class="widget-liquid-left"> |
422 <div id="widgets-left"> |
437 <div id="widgets-left"> |
423 <div id="available-widgets" class="widgets-holder-wrap"> |
438 <div id="available-widgets" class="widgets-holder-wrap"> |
424 <div class="sidebar-name"> |
439 <div class="sidebar-name"> |
425 <button type="button" class="handlediv hide-if-no-js" aria-expanded="true"> |
440 <button type="button" class="handlediv hide-if-no-js" aria-expanded="true"> |
426 <span class="screen-reader-text"><?php _e( 'Available Widgets' ); ?></span> |
441 <span class="screen-reader-text"> |
|
442 <?php |
|
443 /* translators: Hidden accessibility text. */ |
|
444 _e( 'Available Widgets' ); |
|
445 ?> |
|
446 </span> |
427 <span class="toggle-indicator" aria-hidden="true"></span> |
447 <span class="toggle-indicator" aria-hidden="true"></span> |
428 </button> |
448 </button> |
429 <h2><?php _e( 'Available Widgets' ); ?> <span id="removing-widget"><?php _ex( 'Deactivate', 'removing-widget' ); ?> <span></span></span></h2> |
449 <h2><?php _e( 'Available Widgets' ); ?> <span id="removing-widget"><?php _ex( 'Deactivate', 'removing-widget' ); ?> <span></span></span></h2> |
430 </div> |
450 </div> |
431 <div class="widget-holder"> |
451 <div class="widget-holder"> |
442 |
462 |
443 <?php |
463 <?php |
444 |
464 |
445 $theme_sidebars = array(); |
465 $theme_sidebars = array(); |
446 foreach ( $wp_registered_sidebars as $sidebar => $registered_sidebar ) { |
466 foreach ( $wp_registered_sidebars as $sidebar => $registered_sidebar ) { |
447 if ( false !== strpos( $registered_sidebar['class'], 'inactive-sidebar' ) || 'orphaned_widgets' === substr( $sidebar, 0, 16 ) ) { |
467 if ( str_contains( $registered_sidebar['class'], 'inactive-sidebar' ) || str_starts_with( $sidebar, 'orphaned_widgets' ) ) { |
448 $wrap_class = 'widgets-holder-wrap'; |
468 $wrap_class = 'widgets-holder-wrap'; |
449 if ( ! empty( $registered_sidebar['class'] ) ) { |
469 if ( ! empty( $registered_sidebar['class'] ) ) { |
450 $wrap_class .= ' ' . $registered_sidebar['class']; |
470 $wrap_class .= ' ' . $registered_sidebar['class']; |
451 } |
471 } |
452 |
472 |
456 <div class="widget-holder inactive"> |
476 <div class="widget-holder inactive"> |
457 <?php wp_list_widget_controls( $registered_sidebar['id'], $registered_sidebar['name'] ); ?> |
477 <?php wp_list_widget_controls( $registered_sidebar['id'], $registered_sidebar['name'] ); ?> |
458 |
478 |
459 <?php if ( $is_inactive_widgets ) { ?> |
479 <?php if ( $is_inactive_widgets ) { ?> |
460 <div class="remove-inactive-widgets"> |
480 <div class="remove-inactive-widgets"> |
461 <form action="" method="post"> |
481 <form method="post"> |
462 <p> |
482 <p> |
463 <?php |
483 <?php |
464 $attributes = array( 'id' => 'inactive-widgets-control-remove' ); |
484 $attributes = array( 'id' => 'inactive-widgets-control-remove' ); |
465 |
485 |
466 if ( empty( $sidebars_widgets['wp_inactive_widgets'] ) ) { |
486 if ( empty( $sidebars_widgets['wp_inactive_widgets'] ) ) { |