3
* Customize API: WP_Widget_Form_Customize_Control class
6
* @subpackage Customize
11
* Widget Form Customize Control class.
15
* @see WP_Customize_Control
17
class WP_Widget_Form_Customize_Control extends WP_Customize_Control {
18
public $type = 'widget_form';
20
public $widget_id_base;
22
public $is_new = false;
25
public $is_wide = false;
28
* Gather control params for exporting to JavaScript.
30
* @global array $wp_registered_widgets
32
public function to_json() {
33
global $wp_registered_widgets;
36
$exported_properties = array( 'widget_id', 'widget_id_base', 'sidebar_id', 'width', 'height', 'is_wide' );
37
foreach ( $exported_properties as $key ) {
38
$this->json[ $key ] = $this->$key;
41
// Get the widget_control and widget_content.
42
require_once ABSPATH . '/wp-admin/includes/widgets.php';
44
$widget = $wp_registered_widgets[ $this->widget_id ];
45
if ( ! isset( $widget['params'][0] ) ) {
46
$widget['params'][0] = array();
50
'widget_id' => $widget['id'],
51
'widget_name' => $widget['name'],
54
$args = wp_list_widget_controls_dynamic_sidebar( array( 0 => $args, 1 => $widget['params'][0] ) );
55
$widget_control_parts = $this->manager->widgets->get_widget_control_parts( $args );
57
$this->json['widget_control'] = $widget_control_parts['control'];
58
$this->json['widget_content'] = $widget_control_parts['content'];
62
* Override render_content to be no-op since content is exported via to_json for deferred embedding.
64
public function render_content() {}
67
* Whether the current widget is rendered on the page.
72
* @return bool Whether the widget is rendered.
74
public function active_callback() {
75
return $this->manager->widgets->is_widget_rendered( $this->widget_id );