Ticket #24878: 24878.2.diff
File 24878.2.diff, 3.7 KB (added by , 9 years ago) |
---|
-
src/wp-admin/widgets.php
89 89 if ( 'wp_inactive_widgets' == $sidebar_id ) 90 90 continue; 91 91 92 if ( ! isset( $wp_registered_sidebars[ $sidebar_id ]) ) {92 if ( ! is_registered_sidebar( $sidebar_id ) ) { 93 93 if ( ! empty( $widgets ) ) { // register the inactive_widgets area as sidebar 94 94 register_sidebar(array( 95 95 'name' => __( 'Inactive Sidebar (not used)' ), … … 155 155 156 156 /** 157 157 * Fires immediately after a widget has been marked for deletion. 158 * 158 * 159 159 * @since 4.4.0 160 160 * 161 161 * @param string $widget_id ID of the widget marked for deletion. -
src/wp-includes/class-wp-customize-widgets.php
365 365 $sidebar_widget_ids = array(); 366 366 } 367 367 368 $is_registered_sidebar = is set( $wp_registered_sidebars[ $sidebar_id ]);368 $is_registered_sidebar = is_registered_sidebar( $sidebar_id ); 369 369 $is_inactive_widgets = ( 'wp_inactive_widgets' === $sidebar_id ); 370 370 $is_active_sidebar = ( $is_registered_sidebar && ! $is_inactive_widgets ); 371 371 … … 1102 1102 * @since 3.9.0 1103 1103 * @access public 1104 1104 * 1105 * @global array $wp_registered_sidebars1106 *1107 1105 * @param bool $is_active Whether the sidebar is active. 1108 1106 * @param string $sidebar_id Sidebar ID. 1109 1107 * @return bool 1110 1108 */ 1111 1109 public function tally_sidebars_via_is_active_sidebar_calls( $is_active, $sidebar_id ) { 1112 if ( is set( $GLOBALS['wp_registered_sidebars'][$sidebar_id]) ) {1110 if ( is_registered_sidebar( $sidebar_id ) ) { 1113 1111 $this->rendered_sidebars[] = $sidebar_id; 1114 1112 } 1115 1113 /* … … 1130 1128 * @since 3.9.0 1131 1129 * @access public 1132 1130 * 1133 * @global array $wp_registered_sidebars1134 *1135 1131 * @param bool $has_widgets Whether the current sidebar has widgets. 1136 1132 * @param string $sidebar_id Sidebar ID. 1137 1133 * @return bool 1138 1134 */ 1139 1135 public function tally_sidebars_via_dynamic_sidebar_calls( $has_widgets, $sidebar_id ) { 1140 if ( is set( $GLOBALS['wp_registered_sidebars'][$sidebar_id]) ) {1136 if ( is_registered_sidebar( $sidebar_id ) ) { 1141 1137 $this->rendered_sidebars[] = $sidebar_id; 1142 1138 } 1143 1139 -
src/wp-includes/widget-functions.php
96 96 if ( isset($args['id']) ) { 97 97 $_args['id'] = $args['id']; 98 98 $n = 2; // Start at -2 for conflicting custom ID's 99 while ( is set($wp_registered_sidebars[$_args['id']]) )99 while ( is_registered_sidebar( $_args['id'] ) ) { 100 100 $_args['id'] = $args['id'] . '-' . $n++; 101 } 101 102 } else { 102 $n = count( $wp_registered_sidebars);103 $n = count( $wp_registered_sidebars ); 103 104 do { 104 105 $_args['id'] = 'sidebar-' . ++$n; 105 } while ( is set($wp_registered_sidebars[$_args['id']]) );106 } while ( is_registered_sidebar( $_args['id'] ) ); 106 107 } 107 108 register_sidebar($_args); 108 109 } … … 206 207 } 207 208 208 209 /** 210 * Checks if a sidebar is registered. 211 * 212 * @since 4.4.0 213 * 214 * @global array $wp_registered_sidebars Registered sidebars. 215 * 216 * @param string $name The ID of the sidebar when it was added. 217 * 218 * @return bool True if the sidebar is registered, false otherwise. 219 */ 220 function is_registered_sidebar( $name ) { 221 global $wp_registered_sidebars; 222 return isset( $wp_registered_sidebars[ $name ] ); 223 } 224 225 /** 209 226 * Register an instance of a widget. 210 227 * 211 228 * The default widget option is 'classname' that can be overridden.