[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/customize/ -> class-wp-widget-form-customize-control.php (source)

   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          if ( ! isset( $widget['params'][0] ) ) {
 103              $widget['params'][0] = array();
 104          }
 105  
 106          $args = array(
 107              'widget_id'   => $widget['id'],
 108              'widget_name' => $widget['name'],
 109          );
 110  
 111          $args                 = wp_list_widget_controls_dynamic_sidebar(
 112              array(
 113                  0 => $args,
 114                  1 => $widget['params'][0],
 115              )
 116          );
 117          $widget_control_parts = $this->manager->widgets->get_widget_control_parts( $args );
 118  
 119          $this->json['widget_control'] = $widget_control_parts['control'];
 120          $this->json['widget_content'] = $widget_control_parts['content'];
 121      }
 122  
 123      /**
 124       * Override render_content to be no-op since content is exported via to_json for deferred embedding.
 125       *
 126       * @since 3.9.0
 127       */
 128  	public function render_content() {}
 129  
 130      /**
 131       * Whether the current widget is rendered on the page.
 132       *
 133       * @since 4.0.0
 134       *
 135       * @return bool Whether the widget is rendered.
 136       */
 137  	public function active_callback() {
 138          return $this->manager->widgets->is_widget_rendered( $this->widget_id );
 139      }
 140  }


Generated : Thu Apr 25 08:20:02 2024 Cross-referenced by PHPXref