mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-22 07:22:01 +01:00
Introduce documentation for three methods in WP_Widget_Factory
: register()
, unregister()
, _register_widgets()
.
See #30315. Built from https://develop.svn.wordpress.org/trunk@30774 git-svn-id: http://core.svn.wordpress.org/trunk@30764 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
25a65d856b
commit
1f8f2e5ba1
@ -4,7 +4,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.1-beta2-30773';
|
||||
$wp_version = '4.1-beta2-30774';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
@ -548,15 +548,37 @@ class WP_Widget_Factory {
|
||||
add_action( 'widgets_init', array( $this, '_register_widgets' ), 100 );
|
||||
}
|
||||
|
||||
public function register($widget_class) {
|
||||
/**
|
||||
* Register a widget subclass.
|
||||
*
|
||||
* @since 2.8.0
|
||||
* @access public
|
||||
*
|
||||
* @param string $widget_class The name of a {@see WP_Widget} subclass.
|
||||
*/
|
||||
public function register( $widget_class ) {
|
||||
$this->widgets[$widget_class] = new $widget_class();
|
||||
}
|
||||
|
||||
public function unregister($widget_class) {
|
||||
/**
|
||||
* Un-register a widget subclass.
|
||||
*
|
||||
* @since 2.8.0
|
||||
* @access public
|
||||
*
|
||||
* @param string $widget_class The name of a {@see WP_Widget} subclass.
|
||||
*/
|
||||
public function unregister( $widget_class ) {
|
||||
if ( isset($this->widgets[$widget_class]) )
|
||||
unset($this->widgets[$widget_class]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method for adding widgets to the registered widgets global.
|
||||
*
|
||||
* @since 2.8.0
|
||||
* @access public
|
||||
*/
|
||||
public function _register_widgets() {
|
||||
global $wp_registered_widgets;
|
||||
$keys = array_keys($this->widgets);
|
||||
|
Loading…
Reference in New Issue
Block a user