/** * Tests the Revisr_Admin::get_commit_details() method. */ function test_get_commit_details() { $commit = Revisr_Admin::get_commit_details(42); $this->assertArrayHasKey('branch', $commit); $this->assertArrayHasKey('commit_hash', $commit); $this->assertArrayHasKey('db_hash', $commit); $this->assertArrayHasKey('db_backup_method', $commit); $this->assertArrayHasKey('files_changed', $commit); $this->assertArrayHasKey('committed_files', $commit); $this->assertArrayHasKey('tag', $commit); }
/** * Displays the "Commit Details" meta box on a previous commit. * @access public */ public function view_commit_meta() { $post_id = get_the_ID(); $commit = Revisr_Admin::get_commit_details($post_id); $revert_url = get_admin_url() . "admin-post.php?action=revert_form&commit_id=" . $post_id . "&TB_iframe=true&width=350&height=200"; $time_format = __('M j, Y @ G:i'); $timestamp = sprintf(__('Committed on: <strong>%s</strong>', 'revisr'), date_i18n($time_format, get_the_time('U'))); if (false !== $commit['error_details']) { $details = ' <a class="thickbox" title="' . __('Error Details', 'revisr') . '" href="' . wp_nonce_url(admin_url('admin-post.php?action=revisr_view_error&post_id=' . $post_id . '&TB_iframe=true&width=350&height=300'), 'revisr_view_error', 'revisr_error_nonce') . '">View Details</a>'; $revert_btn = '<a class="button button-primary disabled" href="#">' . __('Revert to this Commit', 'revisr') . '</a>'; } else { $revert_btn = '<a class="button button-primary thickbox" href="' . $revert_url . '" title="' . __('Revert', 'revisr') . '">' . __('Revert to this Commit', 'revisr') . '</a>'; $details = ''; } ?> <div id="minor-publishing"> <div id="misc-publishing-actions"> <div class="misc-pub-section revisr-pub-status"> <label for="post_status"><?php _e('Status:', 'revisr'); ?> </label> <span><strong><?php echo $commit['status'] . $details; ?> </strong></span> </div> <div class="misc-pub-section revisr-pub-branch"> <label for="revisr-branch"><?php _e('Branch:', 'revisr'); ?> </label> <span><strong><?php echo $commit['branch']; ?> </strong></span> </div> <div class="misc-pub-section curtime misc-pub-curtime"> <span id="timestamp" class="revisr-timestamp"><?php echo $timestamp; ?> </span> </div> <?php if ($commit['tag'] !== '') { ?> <div class="misc-pub-section revisr-git-tag"> <label for="revisr-tag"><?php _e('Tagged:', 'revisr'); ?> </label> <span><strong><?php echo $commit['tag']; ?> </strong></span> </div> <?php } ?> </div><!-- /#misc-publishing-actions --> </div> <div id="major-publishing-actions"> <div id="delete-action"></div> <div id="publishing-action"> <span class="spinner"></span> <?php echo $revert_btn; ?> </div> <div class="clear"></div> </div> <?php }
/** * revert-form.php * * Displays the form to revert to a specific commit. * * @package Revisr * @license GPLv3 * @link https://revisr.io * @copyright Expanded Fronts, LLC */ // Disallow direct access. if (!defined('ABSPATH')) { exit; } $commit = Revisr_Admin::get_commit_details($_GET['commit_id']); $styles_url = REVISR_URL . 'assets/css/thickbox.css?02162015'; ?> <link href="<?php echo $styles_url; ?> " rel="stylesheet" type="text/css"> <form action="<?php echo get_admin_url() . 'admin-post.php'; ?> " method="post"> <div class="revisr-tb-description">