/**
  * Refresh the parameters passed to the JavaScript via JSON.
  *
  * @uses WP_Fields_API_Control::json()
  */
 public function json()
 {
     $json = parent::json();
     $json['statuses'] = $this->statuses;
     $json['defaultValue'] = $this->setting->default;
     return $json;
 }
 /**
  * Refresh the parameters passed to the JavaScript via JSON.
  *
  * @see WP_Fields_API_Control::to_json()
  */
 public function json()
 {
     $json = parent::json();
     $json['mime_type'] = $this->mime_type;
     $json['button_labels'] = $this->button_labels;
     $json['canUpload'] = current_user_can('upload_files');
     $value = $this->value();
     if (is_object($this->field)) {
         if ($this->field->default) {
             // Fake an attachment model - needs all fields used by template.
             // Note that the default value must be a URL, NOT an attachment ID.
             $type = 'document';
             if (in_array(substr($this->field->default, -3), array('jpg', 'png', 'gif', 'bmp'))) {
                 $type = 'image';
             }
             $default_attachment = array('id' => 1, 'url' => $this->field->default, 'type' => $type, 'icon' => wp_mime_type_icon($type), 'title' => basename($this->field->default));
             if ('image' === $type) {
                 $default_attachment['sizes'] = array('full' => array('url' => $this->field->default));
             }
             $json['defaultAttachment'] = $default_attachment;
         }
         if ($value && $this->field->default && $value === $this->field->default) {
             // Set the default as the attachment.
             $json['attachment'] = $json['defaultAttachment'];
         } elseif ($value) {
             $json['attachment'] = wp_prepare_attachment_for_js($value);
         }
     }
     return $json;
 }
 /**
  * Get the data to export to the client via JSON.
  *
  * @since 4.1.0
  *
  * @return array Array of parameters passed to the JavaScript.
  */
 public function json()
 {
     $array = parent::json();
     $array['active'] = $this->active();
     // Backwards compatibility
     $array['panel'] = $array['screen'];
     $array['settings'] = $array['fields'];
     return $array;
 }
 /**
  * Get the data to export to the client via JSON.
  *
  * @return array Array of parameters passed to the JavaScript.
  *
  * @since 3.2.0
  */
 public function json()
 {
     $array = parent::json();
     $array['active'] = $this->active();
     // Backwards compatibility
     $array['panel'] = $array['screen'];
     unset($array['screen']);
 }