wp_get_widget_defaults example

get_current_screen()->set_help_sidebar(
    '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
    '<p>' . __( '<a href="https://wordpress.org/documentation/article/appearance-widgets-screen-classic-editor/">Documentation on Widgets</a>' ) . '</p>' .
    '<p>' . __( '<a href="https://wordpress.org/support/forums/">Support forums</a>' ) . '</p>'
);

// These are the widgets grouped by sidebar. $sidebars_widgets = wp_get_sidebars_widgets();

if ( empty( $sidebars_widgets ) ) {
    $sidebars_widgets = wp_get_widget_defaults();
}

foreach ( $sidebars_widgets as $sidebar_id => $widgets ) {
    if ( 'wp_inactive_widgets' === $sidebar_id ) {
        continue;
    }

    if ( ! is_registered_sidebar( $sidebar_id ) ) {
        if ( ! empty( $widgets ) ) { // Register the inactive_widgets area as sidebar.             register_sidebar(
                array(
                    
Home | Imprint | This part of the site doesn't use cookies.