save() public static méthode

Save meta value
public static save ( $new, $old, $post_id, $field )
$new
$old
$post_id
$field
Exemple #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)
  *
  * TODO: A good way to ALWAYS save values in single entry in DB, while maintaining backward compatibility
  *
  * @param $new
  * @param $old
  * @param $post_id
  * @param $field
  */
 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);
     }
 }
Exemple #2
0
 /**
  * Save meta value
  *
  * @param $new
  * @param $old
  * @param $post_id
  * @param $field
  */
 static function save($new, $old, $post_id, $field)
 {
     delete_post_meta($post_id, $field['id']);
     parent::save($new, array(), $post_id, $field);
 }