/**
  * Handle reciprocal postmeta and post parents
  * @param int $value
  * @return string
  */
 public function presave(Fieldmanager_Field $field, $value, $current_value)
 {
     if (empty($value)) {
         return;
     }
     $value = intval($value);
     if (!empty($this->publish_with_parent) || !empty($this->reciprocal)) {
         // There are no permissions in cron, but no changes are coming from a user either
         if (!defined('DOING_CRON') || !DOING_CRON) {
             $post_type_obj = get_post_type_object(get_post_type($value));
             if (empty($post_type_obj->cap->edit_post) || !current_user_can($post_type_obj->cap->edit_post, $value)) {
                 wp_die(esc_html(sprintf(__('Tried to alter %s %d through field "%s", which user is not permitted to edit.', 'fieldmanager'), $post_type_obj->name, $value, $field->name)));
             }
         }
         $this->presave_status_transition($field, $value);
         if ($this->reciprocal) {
             add_post_meta($value, $this->reciprocal, $field->data_id);
         }
     }
     if ($this->save_to_post_parent && 1 == $field->limit && 'post' == $field->data_type) {
         if (!wp_is_post_revision($field->data_id)) {
             Fieldmanager_Context_Post::safe_update_post(array('ID' => $field->data_id, 'post_parent' => $value));
         }
         if ($this->only_save_to_post_parent) {
             return array();
         }
     }
     return $value;
 }
 /**
  * Helper for fieldmanager internals to save a post without worrying about infinite loops
  */
 public static function safe_update_post($args)
 {
     self::$doing_internal_update = true;
     $ret = wp_update_post($args);
     self::$doing_internal_update = false;
     return $ret;
 }