/**
  * to_json()
  * 
  * You can use this method to modify the field properties that are added to the JSON object.
  * The JSON object is used by the Backbone Model and the Underscore template.
  * 
  * @param bool $load  Should the value be loaded from the database or use the value from the current instance.
  * @return array
  */
 function to_json($load)
 {
     $field_data = parent::to_json($load);
     // do not delete
     $field_data = array_merge($field_data, array('example_property' => $this->example_property));
     return $field_data;
 }
Example #2
0
 /**
  * Returns an array that holds the field data, suitable for JSON representation.
  * This data will be available in the Underscore template and the Backbone Model.
  *
  * @param bool $load  Should the value be loaded from the database or use the value from the current instance.
  * @return array
  */
 public function to_json($load)
 {
     $field_data = parent::to_json($load);
     $url = '';
     $thumb_url = '';
     $default_thumb_url = includes_url('/images/media/default.png');
     $file_ext = '';
     $file_type = '';
     $value = $this->get_value();
     if ($value) {
         $url = is_numeric($value) ? wp_get_attachment_url($value) : $value;
         $filetype = wp_check_filetype($url);
         $file_ext = $filetype['ext'];
         // png, mp3, etc..
         $file_type = preg_replace('~\\/.+$~', '', $filetype['type']);
         // image, video, etc..
         if ($file_type == 'image') {
             $thumb_url = $url;
             if ($this->value_type == 'id') {
                 $thumb_src = wp_get_attachment_image_src($value, 'thumbnail');
                 $thumb_url = $thumb_src[0];
             }
         } else {
             $thumb_url = $default_thumb_url;
         }
     }
     $field_data = array_merge($field_data, array('url' => (string) $url, 'thumb_url' => $thumb_url, 'default_thumb_url' => $default_thumb_url, 'file_ext' => $file_ext, 'file_type' => $file_type, 'button_label' => $this->button_label, 'window_button_label' => $this->window_button_label, 'window_label' => $this->window_label, 'type_filter' => $this->field_type, 'value_type' => $this->value_type));
     return $field_data;
 }
Example #3
0
 /**
  * Returns an array that holds the field data, suitable for JSON representation.
  * This data will be available in the Underscore template and the Backbone Model.
  * 
  * @param bool $load  Should the value be loaded from the database or use the value from the current instance.
  * @return array
  */
 public function to_json($load)
 {
     $field_data = parent::to_json($load);
     $this->load_options();
     $field_data = array_merge($field_data, array('limit_options' => $this->limit_options, 'options' => $this->parse_options($this->options)));
     return $field_data;
 }
Example #4
0
 /**
  * You can use this method to modify the field properties that are added to the JSON object.
  * The JSON object is used by the Backbone Model and the Underscore template.
  *
  * @param bool $load  Should the value be loaded from the database or use the value from the current instance.
  * @return array
  */
 public function to_json($load)
 {
     $field_data = parent::to_json($load);
     $field_data = array_merge($field_data, array('timepicker_type' => $this->timepicker_type, 'time_format' => $this->get_time_format(), 'interval_step' => $this->get_interval_step(), 'restraints' => $this->get_restraints(), 'timepicker_options' => $this->get_timepicker_options()));
     return $field_data;
 }
Example #5
0
 /**
  * Returns an array that holds the field data, suitable for JSON representation.
  * This data will be available in the Underscore template and the Backbone Model.
  * 
  * @param bool $load  Should the value be loaded from the database or use the value from the current instance.
  * @return array
  */
 public function to_json($load)
 {
     $field_data = parent::to_json($load);
     $field_data = array_merge($field_data, array('lat' => is_float($this->lat) ? $this->lat : $this->default_lat, 'lng' => is_float($this->lng) ? $this->lng : $this->default_lng, 'zoom' => is_int($this->zoom) ? $this->zoom : $this->default_zoom, 'address' => $this->address));
     return $field_data;
 }
 /**
  * Returns an array that holds the field data, suitable for JSON representation.
  * In addition to default data, option value and label are added.
  * This data will be available in the Underscore template and the Backbone Model.
  *
  * @param bool $load  Should the value be loaded from the database or use the value from the current instance.
  * @return array
  */
 public function to_json($load)
 {
     $field_data = parent::to_json($load);
     $field_data = array_merge($field_data, array('option_value' => $this->option_value, 'option_label' => parent::get_label()));
     return $field_data;
 }
Example #7
0
 /**
  * Returns an array that holds the field data, suitable for JSON representation.
  * This data will be available in the Underscore template and the Backbone Model.
  *
  * @param bool $load  Should the value be loaded from the database or use the value from the current instance.
  * @return array
  */
 public function to_json($load)
 {
     $field_data = parent::to_json($load);
     if (!empty($field_data['value'])) {
         $value = array();
         $field_data['value'] = maybe_unserialize($field_data['value']);
         foreach ($field_data['value'] as $single_value) {
             $post_type = get_post_type($single_value);
             $value[] = array('id' => $single_value, 'title' => $this->get_title_by_type($single_value, 'post', $post_type), 'type' => 'post', 'subtype' => $post_type, 'label' => $this->get_item_label($single_value, 'post', $post_type), 'is_trashed' => get_post_status($single_value) == 'trash');
         }
         $field_data['value'] = $value;
     }
     $field_data = array_merge($field_data, array('options' => $this->get_options(), 'max' => $this->max, 'allow_duplicates' => $this->allow_duplicates));
     return $field_data;
 }
Example #8
0
 /**
  * Returns an array that holds the field data, suitable for JSON representation.
  * This data will be available in the Underscore template and the Backbone Model.
  *
  * @param bool $load  Should the value be loaded from the database or use the value from the current instance.
  * @return array
  */
 public function to_json($load)
 {
     $field_data = parent::to_json($load);
     $field_data = array_merge($field_data, array('html' => $this->field_html));
     return $field_data;
 }
Example #9
0
 /**
  * Returns an array that holds the field data, suitable for JSON representation.
  * This data will be available in the Underscore template and the Backbone Model.
  *
  * @param bool $load  Should the value be loaded from the database or use the value from the current instance.
  * @return array
  */
 public function to_json($load)
 {
     $field_data = parent::to_json($load);
     $field_data = array_merge($field_data, array('options' => $this->datepicker_options));
     return $field_data;
 }
 /**
  * Returns an array that holds the field data, suitable for JSON representation.
  * This data will be available in the Underscore template and the Backbone Model.
  *
  * @param bool $load  Should the value be loaded from the database or use the value from the current instance.
  * @return array
  */
 public function to_json($load)
 {
     $field_data = parent::to_json($load);
     $field_data = array_merge($field_data, array('rows' => $this->rows, 'height' => $this->height));
     return $field_data;
 }
 /**
  * Convert the field data into JSON representation.
  * @param  bool $load Whether to load data from the datastore.
  * @return mixed      The JSON field data.
  */
 public function to_json($load)
 {
     $field_data = Field::to_json($load);
     $field_data = array_merge($field_data, array('options' => $this->get_options(), 'max' => $this->max, 'allow_duplicates' => $this->allow_duplicates));
     return $field_data;
 }