]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/widgets.php
WordPress 4.2
[autoinstalls/wordpress.git] / wp-includes / widgets.php
index 2e710ccb89cc1dc08ab2868c2efb58e1c4c634e6..a488a90f60100b99c50e3eb9f87d90f347aedfe0 100644 (file)
@@ -6,8 +6,8 @@
  * This functionality was found in a plugin before WordPress 2.2 release which
  * included it in the core from that point on.
  *
- * @link http://codex.wordpress.org/Plugins/WordPress_Widgets WordPress Widgets
- * @link http://codex.wordpress.org/Plugins/WordPress_Widgets_Api Widgets API
+ * @link https://codex.wordpress.org/Plugins/WordPress_Widgets WordPress Widgets
+ * @link https://codex.wordpress.org/Plugins/WordPress_Widgets_Api Widgets API
  *
  * @package WordPress
  * @subpackage Widgets
@@ -166,7 +166,7 @@ class WP_Widget {
 
        /**
         * PHP4 constructor
-        * 
+        *
         * @param string $id_base
         * @param string $name
         * @param array  $widget_options
@@ -803,6 +803,8 @@ function register_sidebar($args = array()) {
 
        $i = count($wp_registered_sidebars) + 1;
 
+       $id_is_empty = empty( $args['id'] );
+
        $defaults = array(
                'name' => sprintf(__('Sidebar %d'), $i ),
                'id' => "sidebar-$i",
@@ -816,6 +818,11 @@ function register_sidebar($args = array()) {
 
        $sidebar = wp_parse_args( $args, $defaults );
 
+       if ( $id_is_empty ) {
+               /* translators: 1: the id argument, 2: sidebar name, 3: recommended id value */
+               _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;
 
        add_theme_support('widgets');
@@ -1552,8 +1559,9 @@ function the_widget( $widget, $instance = array(), $args = array() ) {
        global $wp_widget_factory;
 
        $widget_obj = $wp_widget_factory->widgets[$widget];
-       if ( !is_a($widget_obj, 'WP_Widget') )
+       if ( ! ( $widget_obj instanceof WP_Widget ) ) {
                return;
+       }
 
        $before_widget = sprintf('<div class="widget %s">', $widget_obj->widget_options['classname'] );
        $default_args = array( 'before_widget' => $before_widget, 'after_widget' => "</div>", 'before_title' => '<h2 class="widgettitle">', 'after_title' => '</h2>' );