C:\xampp\htdocs\landing\wp-includes\class-wp-widget-factory.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
/**
 * Widget API: WP_Widget_Factory class
 *
 * @package WordPress
 * @subpackage Widgets
 * @since 4.4.0
 */

/**
 * Singleton that registers and instantiates WP_Widget classes.
 *
 * @since 2.8.0
 * @since 4.4.0 Moved to its own file from wp-includes/widgets.php
 */
class WP_Widget_Factory {

    
/**
     * Widgets array.
     *
     * @since 2.8.0
     * @var array
     */
    
public $widgets = array();

    
/**
     * PHP5 constructor.
     *
     * @since 4.3.0
     */
    
public function __construct() {
        
add_action'widgets_init', array( $this'_register_widgets' ), 100 );
    }

    
/**
     * PHP4 constructor.
     *
     * @since 2.8.0
     * @deprecated 4.3.0 Use __construct() instead.
     *
     * @see WP_Widget_Factory::__construct()
     */
    
public function WP_Widget_Factory() {
        
_deprecated_constructor'WP_Widget_Factory''4.3.0' );
        
self::__construct();
    }

    
/**
     * Registers a widget subclass.
     *
     * @since 2.8.0
     * @since 4.6.0 Updated the `$widget` parameter to also accept a WP_Widget instance object
     *              instead of simply a `WP_Widget` subclass name.
     *
     * @param string|WP_Widget $widget Either the name of a `WP_Widget` subclass or an instance of a `WP_Widget` subclass.
     */
    
public function register$widget ) {
        if ( 
$widget instanceof WP_Widget ) {
            
$this->widgetsspl_object_hash$widget ) ] = $widget;
        } else {
            
$this->widgets$widget ] = new $widget();
        }
    }

    
/**
     * Un-registers a widget subclass.
     *
     * @since 2.8.0
     * @since 4.6.0 Updated the `$widget` parameter to also accept a WP_Widget instance object
     *              instead of simply a `WP_Widget` subclass name.
     *
     * @param string|WP_Widget $widget Either the name of a `WP_Widget` subclass or an instance of a `WP_Widget` subclass.
     */
    
public function unregister$widget ) {
        if ( 
$widget instanceof WP_Widget ) {
            unset( 
$this->widgetsspl_object_hash$widget ) ] );
        } else {
            unset( 
$this->widgets$widget ] );
        }
    }

    
/**
     * Serves as a utility method for adding widgets to the registered widgets global.
     *
     * @since 2.8.0
     *
     * @global array $wp_registered_widgets
     */
    
public function _register_widgets() {
        global 
$wp_registered_widgets;
        
$keys       array_keys$this->widgets );
        
$registered array_keys$wp_registered_widgets );
        
$registered array_map'_get_widget_id_base'$registered );

        foreach ( 
$keys as $key ) {
            
// Don't register new widget if old widget with the same id is already registered.
            
if ( in_array$this->widgets$key ]->id_base$registeredtrue ) ) {
                unset( 
$this->widgets$key ] );
                continue;
            }

            
$this->widgets$key ]->_register();
        }
    }
}
x

Windows NT KPTV 6.2 build 9200 (Windows Server 2012 Datacenter Edition) i586