| 1 |
<?php |
| 2 |
/** |
| 3 |
* Core Widget APIs for WP 6.2. |
| 4 |
* |
| 5 |
* @package gutenberg |
| 6 |
*/ |
| 7 |
|
| 8 |
if ( ! function_exists( '_wp_block_theme_register_classic_sidebars' ) ) { |
| 9 |
/** |
| 10 |
* Registers the previous theme's sidebars for the block themes. |
| 11 |
* |
| 12 |
* @since 6.2.0 |
| 13 |
* @access private |
| 14 |
* |
| 15 |
* @global array $wp_registered_sidebars Registered sidebars. |
| 16 |
*/ |
| 17 |
function _wp_block_theme_register_classic_sidebars() { |
| 18 |
global $wp_registered_sidebars; |
| 19 |
|
| 20 |
if ( ! wp_is_block_theme() ) { |
| 21 |
return; |
| 22 |
} |
| 23 |
|
| 24 |
$legacy_sidebars = get_theme_mod( 'wp_classic_sidebars' ); |
| 25 |
if ( empty( $legacy_sidebars ) ) { |
| 26 |
return; |
| 27 |
} |
| 28 |
|
| 29 |
// Don't use `register_sidebar` since it will enable the `widgets` support for a theme. |
| 30 |
foreach ( $legacy_sidebars as $sidebar ) { |
| 31 |
$wp_registered_sidebars[ $sidebar['id'] ] = $sidebar; |
| 32 |
} |
| 33 |
} |
| 34 |
add_action( 'widgets_init', '_wp_block_theme_register_classic_sidebars' ); |
| 35 |
} |
| 36 |
|