Ejemplo n.º 1
0
 /**
  * Save meta value
  * If field is cloneable, value is saved as a single entry in DB
  * Otherwise value is saved as multiple entries (for backward compatibility)
  *
  * @param $new
  * @param $old
  * @param $post_id
  * @param $field
  *
  * @return void
  */
 static function save($new, $old, $post_id, $field)
 {
     if (!$field['clone']) {
         parent::save($new, $old, $post_id, $field);
         return;
     }
     if (empty($new)) {
         delete_post_meta($post_id, $field['id']);
     } else {
         update_post_meta($post_id, $field['id'], $new);
     }
 }
Ejemplo n.º 2
0
 /**
  * Get the field value
  * The difference between this function and 'meta' function is 'meta' function always returns the escaped value
  * of the field saved in the database, while this function returns more meaningful value of the field
  *
  * @param  array    $field   Field parameters
  * @param  array    $args    Not used for this field
  * @param  int|null $post_id Post ID. null for current post. Optional.
  *
  * @return mixed Array(latitude, longitude, zoom)
  */
 static function get_value($field, $args = array(), $post_id = null)
 {
     $value = parent::get_value($field, $args, $post_id);
     list($latitude, $longitude, $zoom) = explode(',', $value . ',,');
     return compact('latitude', 'longitude', 'zoom');
 }
Ejemplo n.º 3
0
 /**
  * Output the field value
  * Display option name instead of option value
  *
  * @use self::meta()
  *
  * @param  array    $field   Field parameters
  * @param  array    $args    Additional arguments. Rarely used. See specific fields for details
  * @param  int|null $post_id Post ID. null for current post. Optional.
  *
  * @return mixed Field value
  */
 static function the_value($field, $args = array(), $post_id = null)
 {
     $value = parent::get_value($field, $args, $post_id);
     return empty($value) ? '' : $field['options'][$value];
 }