Make WordPress Core

Ticket #20542: 20542.2.diff

File 20542.2.diff, 1.1 KB (added by cmmarslender, 11 years ago)

Adds underscore between class name and hash when there are args

  • src/wp-includes/widgets.php

     
    409409                add_action( 'widgets_init', array( $this, '_register_widgets' ), 100 );
    410410        }
    411411
    412         function register($widget_class) {
    413                 $this->widgets[$widget_class] = new $widget_class();
     412        function register( $widget_class, $args = null ) {
     413                $widget_key = $widget_class;
     414
     415                if ( ! empty( $args ) ) {
     416                        $widget_key .= '_' . md5( maybe_serialize( $args ) );
     417                }
     418
     419                $this->widgets[ $widget_key ] = new $widget_class( $args );
    414420        }
    415421
    416422        function unregister($widget_class) {
     
    513519 * @uses WP_Widget_Factory
    514520 *
    515521 * @param string $widget_class The name of a class that extends WP_Widget
     522 * @param mixed $args Args to pass to the widget constructor
    516523 */
    517 function register_widget($widget_class) {
     524function register_widget( $widget_class, $args = null ) {
    518525        global $wp_widget_factory;
    519526
    520         $wp_widget_factory->register($widget_class);
     527        $wp_widget_factory->register( $widget_class, $args );
    521528}
    522529
    523530/**