_wp_block_theme_register_classic_sidebars()WP 6.2.0

Registers the previous theme's sidebars for the block themes.

Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.

No Hooks.

Returns

null. Nothing (null).

Usage

_wp_block_theme_register_classic_sidebars();

Notes

  • Global. Array. $wp_registered_sidebars The registered sidebars.

Changelog

Since 6.2.0 Introduced.

_wp_block_theme_register_classic_sidebars() code WP 6.8.1

function _wp_block_theme_register_classic_sidebars() {
	global $wp_registered_sidebars;

	if ( ! wp_is_block_theme() ) {
		return;
	}

	$classic_sidebars = get_theme_mod( 'wp_classic_sidebars' );
	if ( empty( $classic_sidebars ) ) {
		return;
	}

	// Don't use `register_sidebar` since it will enable the `widgets` support for a theme.
	foreach ( $classic_sidebars as $sidebar ) {
		$wp_registered_sidebars[ $sidebar['id'] ] = $sidebar;
	}
}