/**
  * Callback for successful branch deletion.
  * @access public
  */
 public function success_delete_branch($output = '', $args = '')
 {
     $branch = $args;
     $msg = sprintf(__('Deleted branch %s.', 'revisr'), $branch);
     $email_msg = sprintf(__('The branch "%s" on the repository for %s was deleted.', 'revisr'), $branch, get_bloginfo());
     Revisr_Admin::log($msg, 'branch');
     Revisr_Admin::notify(get_bloginfo() . __(' - Branch Deleted', 'revisr'), $email_msg);
     _e('Branch deleted successfully. Redirecting...', 'revisr');
     echo "<script>\n\t\t\t\twindow.top.location.href = '" . get_admin_url() . "admin.php?page=revisr_branches&status=delete_success&branch={$branch}'\n\t\t</script>";
 }
Esempio n. 2
0
 /**
  * Processes the request to revert to an earlier commit.
  * @access public
  */
 public function revert_files($redirect = true)
 {
     Revisr_Admin::verify_nonce($_REQUEST['revisr_revert_nonce'], 'revisr_revert_nonce');
     $commit = $_REQUEST['commit_hash'];
     $commit_msg = sprintf(__('Reverted to commit: #%s.', 'revisr'), $commit);
     revisr()->git->reset('--hard', 'HEAD', true);
     revisr()->git->reset('--hard', $commit);
     revisr()->git->reset('--soft', 'HEAD@{1}');
     revisr()->git->run('add', array('-A'));
     revisr()->git->commit($commit_msg);
     revisr()->git->auto_push();
     $commit_url = get_admin_url() . 'admin.php?page=revisr_view_commit&commit=' . $commit;
     $msg = sprintf(__('Reverted to commit <a href="%s">#%s</a>.', 'revisr'), $commit_url, $commit);
     $email_msg = sprintf(__('%s was reverted to commit #%s', 'revisr'), get_bloginfo(), $commit);
     Revisr_Admin::log($msg, 'revert');
     Revisr_Admin::notify(get_bloginfo() . __(' - Commit Reverted', 'revisr'), $email_msg);
     if (true === $redirect) {
         Revisr_Admin::redirect();
     }
 }
 /**
  * Processes the request to revert to an earlier commit.
  * @access public
  */
 public function process_revert_files($redirect = true)
 {
     if (!wp_verify_nonce($_REQUEST['revisr_revert_nonce'], 'revisr_revert_nonce')) {
         wp_die(__('Cheatin&#8217; uh?', 'revisr'));
     }
     $branch = $_REQUEST['branch'];
     $commit = $_REQUEST['commit_hash'];
     $commit_msg = sprintf(__('Reverted to commit: #%s.', 'revisr'), $commit);
     if ($branch != $this->revisr->git->branch) {
         $this->revisr->git->checkout($branch);
     }
     $this->revisr->git->reset('--hard', 'HEAD', true);
     $this->revisr->git->reset('--hard', $commit);
     $this->revisr->git->reset('--soft', 'HEAD@{1}');
     $this->revisr->git->run('add', array('-A'));
     $this->revisr->git->commit($commit_msg);
     $this->revisr->git->auto_push();
     $post_url = get_admin_url() . "post.php?post=" . $_REQUEST['post_id'] . "&action=edit";
     $msg = sprintf(__('Reverted to commit <a href="%s">#%s</a>.', 'revisr'), $post_url, $commit);
     $email_msg = sprintf(__('%s was reverted to commit #%s', 'revisr'), get_bloginfo(), $commit);
     Revisr_Admin::log($msg, 'revert');
     Revisr_Admin::notify(get_bloginfo() . __(' - Commit Reverted', 'revisr'), $email_msg);
     if (true === $redirect) {
         $redirect = get_admin_url() . "admin.php?page=revisr";
         wp_safe_redirect($redirect);
     }
 }
 /**
  * Processes the request to revert to an earlier commit.
  * @access public
  */
 public function process_revert()
 {
     if (isset($_GET['revert_nonce']) && wp_verify_nonce($_GET['revert_nonce'], 'revert')) {
         $branch = $_GET['branch'];
         $commit = $_GET['commit_hash'];
         $commit_msg = sprintf(__('Reverted to commit: #%s.', 'revisr'), $commit);
         if ($branch != $this->git->branch) {
             $this->git->checkout($branch);
         }
         $this->git->reset('--hard', 'HEAD', true);
         $this->git->reset('--hard', $commit);
         $this->git->reset('--soft', 'HEAD@{1}');
         $this->git->run('add -A');
         $this->git->commit($commit_msg);
         $this->git->auto_push();
         $post_url = get_admin_url() . "post.php?post=" . $_GET['post_id'] . "&action=edit";
         $msg = sprintf(__('Reverted to commit <a href="%s">#%s</a>.', 'revisr'), $post_url, $commit);
         $email_msg = sprintf(__('%s was reverted to commit #%s', 'revisr'), get_bloginfo(), $commit);
         Revisr_Admin::log($msg, 'revert');
         Revisr_Admin::notify(get_bloginfo() . __(' - Commit Reverted', 'revisr'), $email_msg);
         $redirect = get_admin_url() . "admin.php?page=revisr";
         wp_redirect($redirect);
     } else {
         wp_die(__('You are not authorized to access this page.', 'revisr'));
     }
 }
Esempio n. 5
0
 /**
  * Callback for successful branch deletion.
  * @access public
  */
 public function success_delete_branch($output = array(), $args = '')
 {
     $branch = $args;
     $msg = sprintf(__('Deleted branch %s.', 'revisr'), $branch);
     $url = get_admin_url() . 'admin.php?page=revisr_branches&status=delete_success&branch=' . $branch;
     $email_msg = sprintf(__('The branch "%s" on the repository for %s was deleted.', 'revisr'), $branch, get_bloginfo());
     Revisr_Admin::log($msg, 'branch');
     Revisr_Admin::notify(get_bloginfo() . __(' - Branch Deleted', 'revisr'), $email_msg);
     Revisr_Admin::redirect($url, true);
 }
Esempio n. 6
0
 /**
  * Reverts to a specified commit.
  * @access public
  */
 public function revert()
 {
     if (isset($_GET['revert_nonce']) && wp_verify_nonce($_GET['revert_nonce'], 'revert')) {
         $branch = $_GET['branch'];
         if ($branch != $this->branch) {
             $this->checkout($branch);
         }
         $commit = $_GET['commit_hash'];
         $esc_commit = escapeshellarg($commit);
         $commit_msg = escapeshellarg("Reverted to commit: #{$commit}");
         Revisr_Git::run('reset --hard HEAD');
         Revisr_Git::run('clean -f -d');
         Revisr_Git::run("reset --hard {$esc_commit}");
         Revisr_Git::run("reset --soft HEAD@{1}");
         Revisr_Git::run("add -A");
         Revisr_Git::run("commit -am {$commit_msg}");
         $this->auto_push();
         $post_url = get_admin_url() . "post.php?post=" . $_GET['post_id'] . "&action=edit";
         $msg = sprintf(__('Reverted to commit <a href="%s">#%s</a>.', 'revisr'), $post_url, $commit);
         $email_msg = sprintf(__('%s was reverted to commit #%s', 'revisr'), get_bloginfo(), $commit);
         Revisr_Admin::log($msg, 'revert');
         Revisr_Admin::notify(get_bloginfo() . __(' - Commit Reverted', 'revisr'), $email_msg);
         $redirect = get_admin_url() . "admin.php?page=revisr&revert=success&commit={$commit}&id=" . $_GET['post_id'];
         wp_redirect($redirect);
     } else {
         wp_die(__('You are not authorized to access this page.', 'revisr'));
     }
 }