本文整理汇总了PHP中Field::to_json方法的典型用法代码示例。如果您正苦于以下问题:PHP Field::to_json方法的具体用法?PHP Field::to_json怎么用?PHP Field::to_json使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Field
的用法示例。
在下文中一共展示了Field::to_json方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
/**
* 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;
}
示例2: to_json
/**
* 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;
}
示例3: to_json
/**
* 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;
}
示例4: 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
*/
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;
}
示例5: to_json
/**
* 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;
}
示例6: to_json
/**
* 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;
}
示例7: to_json
/**
* 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;
}
示例8: to_json
/**
* 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;
}
示例9: to_json
/**
* 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;
}
示例10: to_json
/**
* 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;
}
示例11: to_json
/**
* 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;
}