mirror of
https://github.com/WordPress/WordPress.git
synced 2024-09-28 15:17:42 +02:00
Tell developers how to correctly silence register_sidebar()
notices.
* If we just tell them they they should set an `id` parameter, they might set an arbitrary one on an existing (i.e. not in-development) theme, causing widgets to be lost. * This way, we tell them to set it to the auto-generated `id` that the sidebar already has. * Widget content is not lost, and now their sidebar has a concrete handle. fixes #31675 Built from https://develop.svn.wordpress.org/trunk@32110 git-svn-id: http://core.svn.wordpress.org/trunk@32089 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
1da9598c2d
commit
c69315f5d7
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.2-beta4-32109';
|
$wp_version = '4.2-beta4-32110';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
@ -803,10 +803,7 @@ function register_sidebar($args = array()) {
|
|||||||
|
|
||||||
$i = count($wp_registered_sidebars) + 1;
|
$i = count($wp_registered_sidebars) + 1;
|
||||||
|
|
||||||
if ( empty( $args['id'] ) ) {
|
$id_is_empty = empty( $args['id'] );
|
||||||
/* translators: %s: the id argument */
|
|
||||||
_doing_it_wrong( __FUNCTION__, sprintf( __( 'You should set %s in the arguments array.' ), '<code>id</code>' ), '4.2.0' );
|
|
||||||
}
|
|
||||||
|
|
||||||
$defaults = array(
|
$defaults = array(
|
||||||
'name' => sprintf(__('Sidebar %d'), $i ),
|
'name' => sprintf(__('Sidebar %d'), $i ),
|
||||||
@ -821,6 +818,11 @@ function register_sidebar($args = array()) {
|
|||||||
|
|
||||||
$sidebar = wp_parse_args( $args, $defaults );
|
$sidebar = wp_parse_args( $args, $defaults );
|
||||||
|
|
||||||
|
if ( $id_is_empty ) {
|
||||||
|
/* translators: %1$s: the id argument */
|
||||||
|
_doing_it_wrong( __FUNCTION__, sprintf( __( 'No %1$s was set in the arguments array for the "%2$s" sidebar. Defaulting to "%3$s". Manually set the %1$s to "%3$s" to silence this notice and keep existing sidebar content.' ), '<code>id</code>', $sidebar['name'], $sidebar['id'] ), '4.2.0' );
|
||||||
|
}
|
||||||
|
|
||||||
$wp_registered_sidebars[$sidebar['id']] = $sidebar;
|
$wp_registered_sidebars[$sidebar['id']] = $sidebar;
|
||||||
|
|
||||||
add_theme_support('widgets');
|
add_theme_support('widgets');
|
||||||
|
Loading…
Reference in New Issue
Block a user