/** * Open a new changeset. If one is already open, this does nothing. * @global \WP_User $current_user * @param string $comment * @param boolean $keep_open Whether the changeset should be kept open (and manually closed) after after_save() is called. */ public function open_changeset($comment, $keep_open = null) { global $current_user; if (!is_null($keep_open)) { self::$keep_changeset_open = $keep_open; } if (!self::$current_changeset_id) { $data = array('date_and_time' => date('Y-m-d H:i:s'), 'user_id' => $current_user->ID, 'comment' => $comment); $this->wpdb->insert($this->changesets_name(), $data); self::$current_changeset_id = $this->wpdb->insert_id; } }
/** * Open a new changeset. If one is already open, this does nothing. * @global \WP_User $current_user * @param string $comment * @param boolean $keep_open Whether the changeset should be kept open (and manually closed) after after_save() is called. */ public function open_changeset($comment, $keep_open = null) { global $current_user; if (!is_null($keep_open)) { self::$keep_changeset_open = $keep_open; } if (!self::$current_changeset_id) { $data = array('date_and_time' => date('Y-m-d H:i:s'), 'user_id' => $current_user->ID, 'comment' => $comment); $ret = $this->wpdb->insert(self::changesets_name(), $data); if ($ret === false) { throw new Exception($this->wpdb->last_error . ' -- Unable to open changeset'); } self::$current_changeset_id = $this->wpdb->insert_id; } }