| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Customize API: WP_Widget_Form_Customize_Control class 4 * 5 * @package WordPress 6 * @subpackage Customize 7 * @since 4.4.0 8 */ 9 10 /** 11 * Widget Form Customize Control class. 12 * 13 * @since 3.9.0 14 * 15 * @see WP_Customize_Control 16 */ 17 class WP_Widget_Form_Customize_Control extends WP_Customize_Control { 18 /** 19 * Customize control type. 20 * 21 * @since 3.9.0 22 * @var string 23 */ 24 public $type = 'widget_form'; 25 26 /** 27 * Widget ID. 28 * 29 * @since 3.9.0 30 * @var string 31 */ 32 public $widget_id; 33 34 /** 35 * Widget ID base. 36 * 37 * @since 3.9.0 38 * @var string 39 */ 40 public $widget_id_base; 41 42 /** 43 * Sidebar ID. 44 * 45 * @since 3.9.0 46 * @var string 47 */ 48 public $sidebar_id; 49 50 /** 51 * Widget status. 52 * 53 * @since 3.9.0 54 * @var bool True if new, false otherwise. Default false. 55 */ 56 public $is_new = false; 57 58 /** 59 * Widget width. 60 * 61 * @since 3.9.0 62 * @var int 63 */ 64 public $width; 65 66 /** 67 * Widget height. 68 * 69 * @since 3.9.0 70 * @var int 71 */ 72 public $height; 73 74 /** 75 * Widget mode. 76 * 77 * @since 3.9.0 78 * @var bool True if wide, false otherwise. Default false. 79 */ 80 public $is_wide = false; 81 82 /** 83 * Gather control params for exporting to JavaScript. 84 * 85 * @since 3.9.0 86 * 87 * @global array $wp_registered_widgets 88 */ 89 public function to_json() { 90 global $wp_registered_widgets; 91 92 parent::to_json(); 93 $exported_properties = array( 'widget_id', 'widget_id_base', 'sidebar_id', 'width', 'height', 'is_wide' ); 94 foreach ( $exported_properties as $key ) { 95 $this->json[ $key ] = $this->$key; 96 } 97 98 // Get the widget_control and widget_content. 99 require_once ABSPATH . 'wp-admin/includes/widgets.php'; 100 101 $widget = $wp_registered_widgets[ $this->widget_id ]; 102 $widget['params'][0] ??= array(); 103 104 $args = array( 105 'widget_id' => $widget['id'], 106 'widget_name' => $widget['name'], 107 ); 108 109 $args = wp_list_widget_controls_dynamic_sidebar( 110 array( 111 0 => $args, 112 1 => $widget['params'][0], 113 ) 114 ); 115 $widget_control_parts = $this->manager->widgets->get_widget_control_parts( $args ); 116 117 $this->json['widget_control'] = $widget_control_parts['control']; 118 $this->json['widget_content'] = $widget_control_parts['content']; 119 } 120 121 /** 122 * Override render_content to be no-op since content is exported via to_json for deferred embedding. 123 * 124 * @since 3.9.0 125 */ 126 public function render_content() {} 127 128 /** 129 * Whether the current widget is rendered on the page. 130 * 131 * @since 4.0.0 132 * 133 * @return bool Whether the widget is rendered. 134 */ 135 public function active_callback() { 136 return $this->manager->widgets->is_widget_rendered( $this->widget_id ); 137 } 138 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Sun Nov 22 08:20:01 2026 | Cross-referenced by PHPXref |