示例#1
0
 /**
  * Commits the database to the repository and pushes if needed.
  * @access public
  * @param  boolean $insert_post Whether to insert a new commit custom_post_type.
  */
 public function commit_db($insert_post = false)
 {
     $commit_msg = __('Backed up the database with Revisr.', 'revisr');
     $this->git->commit($commit_msg);
     // Insert the corresponding post if necessary.
     if ($insert_post === true) {
         $post = array('post_title' => $commit_msg, 'post_content' => '', 'post_type' => 'revisr_commits', 'post_status' => 'publish');
         $post_id = wp_insert_post($post);
         $commit_hash = $this->git->current_commit();
         add_post_meta($post_id, 'commit_hash', $commit_hash);
         add_post_meta($post_id, 'db_hash', $commit_hash);
         add_post_meta($post_id, 'backup_method', 'tables');
         add_post_meta($post_id, 'branch', $this->git->branch);
         add_post_meta($post_id, 'files_changed', '0');
         add_post_meta($post_id, 'committed_files', array());
     }
     // Push changes if necessary.
     $this->git->auto_push();
 }