Changeset 37329 for trunk/src/wp-includes/class-wp-widget-factory.php
- Timestamp:
- 04/29/2016 06:48:27 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-widget-factory.php
r37063 r37329 50 50 * 51 51 * @since 2.8.0 52 * @since 4.6.0 The `$widget` param can also be an instance object of `WP_Widget` instead of just a `WP_Widget` subclass name. 52 53 * @access public 53 54 * 54 * @param string $widget_class The name of a WP_Widgetsubclass.55 * @param string|WP_Widget $widget Either the name of a `WP_Widget` subclass or an instance of a `WP_Widget` subclass. 55 56 */ 56 public function register( $widget_class ) { 57 $this->widgets[$widget_class] = new $widget_class(); 57 public function register( $widget ) { 58 if ( $widget instanceof WP_Widget ) { 59 $this->widgets[ spl_object_hash( $widget ) ] = $widget; 60 } else { 61 $this->widgets[ $widget ] = new $widget(); 62 } 58 63 } 59 64 … … 62 67 * 63 68 * @since 2.8.0 69 * @since 4.6.0 The `$widget` param can also be an instance object of `WP_Widget` instead of just a `WP_Widget` subclass name. 64 70 * @access public 65 71 * 66 * @param string $widget_class The name of a WP_Widgetsubclass.72 * @param string|WP_Widget $widget Either the name of a `WP_Widget` subclass or an instance of a `WP_Widget` subclass. 67 73 */ 68 public function unregister( $widget_class ) { 69 unset( $this->widgets[ $widget_class ] ); 74 public function unregister( $widget ) { 75 if ( $widget instanceof WP_Widget ) { 76 unset( $this->widgets[ spl_object_hash( $widget ) ] ); 77 } else { 78 unset( $this->widgets[ $widget ] ); 79 } 70 80 } 71 81
Note: See TracChangeset
for help on using the changeset viewer.