You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
WP_CLI::error( 'Please specify one or more sidebars, or use --all.' );
512
+
// Bail if no arguments and no --all or --inactive flag.
513
+
if ( ! $all && ! $inactive && empty( $args ) ) {
514
+
WP_CLI::error( 'Please specify one or more sidebars, or use --all or --inactive.' );
507
515
}
508
516
509
-
// Fetch all sidebars if all flag is set.
517
+
// Explicitly handle reserved sidebar ID for inactive widgets.
518
+
if ( in_array( 'wp_inactive_widgets', $args, true ) ) {
519
+
WP_CLI::error( "Sidebar 'wp_inactive_widgets' is reserved for inactive widgets and cannot be reset with this command. The --inactive flag only targets widgets from orphaned or unregistered sidebars, not 'wp_inactive_widgets' itself." );
520
+
}
521
+
522
+
// Fetch all registered sidebars if --all flag is set.
510
523
if ( $all ) {
511
524
$args = array_keys( $wp_registered_sidebars );
512
525
}
513
526
514
527
// Sidebar ID wp_inactive_widgets is reserved by WP core for inactive widgets.
515
-
if ( isset( $args['wp_inactive_widgets'] ) ) {
516
-
unset( $args['wp_inactive_widgets'] );
528
+
$args = array_values(
529
+
array_filter(
530
+
$args,
531
+
staticfunction ( $id ) {
532
+
return'wp_inactive_widgets' !== $id;
533
+
}
534
+
)
535
+
);
536
+
537
+
// Collect inactive (unregistered) sidebar IDs if --inactive flag is set.
0 commit comments