Example #1
0
 /**
  * Set up the instance so we can run our tests.
  */
 function setUp()
 {
     $this->revisr = revisr();
     $this->revisr->git = new Revisr_Git();
     $this->revisr->db = new Revisr_DB();
     $this->revisr->admin = new Revisr_Admin();
 }
Example #2
0
 /**
  * Processes the "auto-pull" functionality.
  * @access public
  */
 public function run_autopull()
 {
     revisr()->git = new Revisr_Git();
     // If auto-pull isn't enabled, we definitely don't want to do this.
     if (revisr()->git->get_config('revisr', 'auto-pull') !== 'true') {
         wp_die(__('Cheatin’ uh?', 'revisr'));
     }
     // Verify the provided token matches the token stored locally.
     $remote = new Revisr_Remote();
     $remote->check_token();
     // If we're still running at this point, we've successfully authenticated.
     revisr()->git->reset();
     revisr()->git->fetch();
     // Grab the commits that need to be pulled.
     $commits_since = revisr()->git->run('log', array(revisr()->git->branch . '..' . revisr()->git->remote . '/' . revisr()->git->branch, '--pretty=oneline'));
     // Maybe backup the database.
     if (revisr()->git->get_config('revisr', 'import-pulls') === 'true') {
         revisr()->db = new Revisr_DB();
         revisr()->db->backup();
         $undo_hash = revisr()->git->current_commit();
         revisr()->git->set_config('revisr', 'last-db-backup', $undo_hash);
     }
     // Pull the changes or return an error on failure.
     revisr()->git->pull($commits_since);
 }
Example #3
0
 /**
  * Sets up the unit tests for this class.
  * @access public
  */
 public function setUp()
 {
     $this->revisr = revisr();
     $this->revisr->git = new Revisr_Git();
     $this->revisr->db = new Revisr_DB();
     $this->import = new Revisr_DB_Import();
 }
Example #4
0
 /**
  * Sets up the unit tests for this class.
  * @access public
  */
 public function setUp()
 {
     $this->revisr = revisr();
     $this->revisr->git = new Revisr_Git();
     $this->revisr->db = new Revisr_DB();
     $this->backup = new Revisr_DB_Backup();
 }
Example #5
0
 /**
  * Constructs the class.
  * @access public
  */
 public function __construct()
 {
     // Make WPDB available to the class.
     global $wpdb;
     $this->wpdb = $wpdb;
     $this->revisr = revisr();
     $upload_dir = wp_upload_dir();
     $this->backup_dir = $upload_dir['basedir'] . '/revisr-backups/';
     // Set up the "revisr_backups" directory if necessary.
     $this->setup_env();
 }
 /**
  * Initiate the class and add necessary action hooks.
  * @access public
  */
 public function __construct()
 {
     // Prevent PHP notices from breaking AJAX.
     if (defined('DOING_AJAX') && DOING_AJAX) {
         error_reporting(~E_NOTICE & ~E_STRICT);
     }
     // Grab the instance and load the parent class on the appropriate hook.
     $this->revisr = revisr();
     add_action('load-toplevel_page_revisr', array($this, 'load'));
     add_action('wp_ajax_revisr_get_custom_list', array($this, 'ajax_callback'));
     add_filter('set-screen-option', array($this, 'set_screen_option'), 10, 3);
 }
Example #7
0
 /**
  * Sends a new HTTP request to the live site.
  * @access public
  */
 public function send_request()
 {
     $body = array('action' => 'revisr_update');
     $args = array('method' => 'POST', 'timeout' => '30', 'redirection' => '5', 'httpversion' => '1.0', 'blocking' => true, 'headers' => array(), 'body' => $body);
     // Get the URL and send the request.
     $get_url = revisr()->git->get_config('revisr', 'webhook-url');
     if ($get_url !== false) {
         $webhook = urldecode($get_url);
         $request = wp_remote_post($webhook, $args);
         if (is_wp_error($request)) {
             Revisr_Admin::log(__('Error contacting webhook URL.', 'revisr'), 'error');
         } else {
             Revisr_Admin::log(__('Sent update request to the webhook.', 'revisr'), 'push');
         }
     }
 }
Example #8
0
 /**
  * Processes a view status request.
  * @access public
  */
 public function view_status()
 {
     Revisr_Admin::verify_nonce($_GET['revisr_status_nonce'], 'revisr_view_status');
     $status = revisr()->git->run('status', array());
     if (is_array($status)) {
         echo '<pre>';
         foreach ($status as $line) {
             echo $line . PHP_EOL;
         }
         echo '</pre>';
     } else {
         _e('Error retrieving the status of the repository.', 'revisr');
     }
 }
Example #9
0
</p>
			<input type="checkbox" id="delete_remote_branch" name="delete_remote_branch">
			<label for="delete_remote_branch"><?php 
    _e('Also delete this branch from the remote repository.', 'revisr');
    ?>
</label>
		<?php 
} else {
    ?>
			<p><?php 
    printf(__('Are you sure you want to delete the remote branch <strong>%s</strong>?', 'revisr'), $branch);
    ?>
</p>
			<input type="hidden" name="delete_remote_only" value="true" />
			<?php 
    $branch = substr($branch, strlen(revisr()->git->current_remote()) + 1);
    ?>
		<?php 
}
?>

	</div>

	<div class="revisr-tb-submit">
		<input type="hidden" name="action" value="process_delete_branch">
		<input type="hidden" name="branch" value="<?php 
echo $branch;
?>
">
		<?php 
wp_nonce_field('process_delete_branch', 'revisr_delete_branch_nonce');
 /**
  * Initialize the class.
  * @access public
  */
 public function __construct()
 {
     $this->revisr = revisr();
 }
Example #11
0
 /**
  * Returns the system info.
  * @access public
  * @return string
  */
 public static function get_sysinfo()
 {
     global $wpdb;
     $return = '### Begin System Info ###' . "\n\n";
     // Basic site info
     $return .= '-- WordPress Configuration' . "\n\n";
     $return .= 'Site URL:                 ' . site_url() . "\n";
     $return .= 'Home URL:                 ' . home_url() . "\n";
     $return .= 'Multisite:                ' . (is_multisite() ? 'Yes' : 'No') . "\n";
     $return .= 'Version:                  ' . get_bloginfo('version') . "\n";
     $return .= 'Language:                 ' . (defined('WPLANG') && WPLANG ? WPLANG : 'en_US') . "\n";
     $return .= 'Table Prefix:             ' . 'Length: ' . strlen($wpdb->prefix) . "\n";
     $return .= 'WP_DEBUG:                 ' . (defined('WP_DEBUG') ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set') . "\n";
     $return .= 'Memory Limit:             ' . WP_MEMORY_LIMIT . "\n";
     // Revisr Configuration
     $return .= "\n" . '-- Revisr Configuration' . "\n\n";
     $return .= 'Plugin Version:           ' . REVISR_VERSION . "\n";
     if (isset(revisr()->options['automatic_backups']) && 'none' !== revisr()->options['automatic_backups']) {
         $backups = 'Enabled';
     } else {
         $backups = 'Disabled';
     }
     $return .= 'Automatic Backups:        ' . $backups . "\n";
     if (revisr()->git->get_config('revisr', 'auto-push') === 'true') {
         $auto_push = 'Enabled';
     } else {
         $auto_push = 'Disabled';
     }
     $return .= 'Auto-Push:                ' . $auto_push . "\n";
     if (revisr()->git->get_config('revisr', 'auto-pull') === 'true') {
         $auto_pull = 'Enabled';
     } else {
         $auto_pull = 'Disabled';
     }
     $return .= 'Auto-Pull:                ' . $auto_pull . "\n";
     if (revisr()->git->get_config('revisr', 'import-checkouts') === 'true') {
         $import_checkouts = 'Enabled';
     } else {
         $import_checkouts = 'Disabled';
     }
     $return .= 'Import checkouts:         ' . $import_checkouts . "\n";
     if (revisr()->git->get_config('revisr', 'import-pulls') === 'true') {
         $import_pulls = 'Enabled';
     } else {
         $import_pulls = 'Disabled';
     }
     $return .= 'Import pulls:             ' . $import_pulls . "\n";
     $return .= 'Work Tree:                ' . revisr()->git->get_work_tree() . "\n";
     $return .= 'Git Dir:                  ' . revisr()->git->get_git_dir() . "\n";
     if (revisr()->git->is_repo) {
         $detected = 'true';
     } else {
         $detected = 'false';
     }
     $return .= 'Repository Detected:      ' . $detected . "\n";
     if ('true' === $detected) {
         $return .= 'Repository Writable:      ' . Revisr_Compatibility::server_has_permissions(revisr()->git->get_git_dir()) . "\n";
     }
     // Server Configuration
     $return .= "\n" . '-- Server Configuration' . "\n\n";
     $os = Revisr_Compatibility::get_os();
     $return .= 'Operating System:         ' . $os['name'] . "\n";
     $return .= 'PHP Version:              ' . PHP_VERSION . "\n";
     $return .= 'MySQL Version:            ' . $wpdb->db_version() . "\n";
     $return .= 'Git Version:              ' . revisr()->git->version() . "\n";
     $return .= 'Git Install Path:         ' . Revisr_Compatibility::guess_path('git') . "\n";
     $return .= 'MySQL Install Path:       ' . Revisr_Compatibility::guess_path('mysql') . "\n";
     $return .= 'Server Software:          ' . $_SERVER['SERVER_SOFTWARE'] . "\n";
     $return .= 'Server User:              '******'re getting to the important stuff
     $return .= "\n" . '-- PHP Configuration' . "\n\n";
     $return .= 'Safe Mode:                ' . (ini_get('safe_mode') ? 'Enabled' : 'Disabled' . "\n");
     if (function_exists('exec')) {
         $exec = 'Enabled';
     } else {
         $exec = 'Disabled';
     }
     $return .= 'Exec Enabled:             ' . $exec . "\n";
     $return .= 'Memory Limit:             ' . ini_get('memory_limit') . "\n";
     $return .= 'Upload Max Size:          ' . ini_get('upload_max_filesize') . "\n";
     $return .= 'Post Max Size:            ' . ini_get('post_max_size') . "\n";
     $return .= 'Upload Max Filesize:      ' . ini_get('upload_max_filesize') . "\n";
     $return .= 'Time Limit:               ' . ini_get('max_execution_time') . "\n";
     $return .= 'Max Input Vars:           ' . ini_get('max_input_vars') . "\n";
     $return .= 'Display Errors:           ' . (ini_get('display_errors') ? 'On (' . ini_get('display_errors') . ')' : 'N/A') . "\n";
     // WordPress active plugins
     $return .= "\n" . '-- WordPress Active Plugins' . "\n\n";
     $plugins = get_plugins();
     $active_plugins = get_option('active_plugins', array());
     foreach ($plugins as $plugin_path => $plugin) {
         if (!in_array($plugin_path, $active_plugins)) {
             continue;
         }
         $return .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n";
     }
     // WordPress inactive plugins
     $return .= "\n" . '-- WordPress Inactive Plugins' . "\n\n";
     foreach ($plugins as $plugin_path => $plugin) {
         if (in_array($plugin_path, $active_plugins)) {
             continue;
         }
         $return .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n";
     }
     if (is_multisite()) {
         // WordPress Multisite active plugins
         $return .= "\n" . '-- Network Active Plugins' . "\n\n";
         $plugins = wp_get_active_network_plugins();
         $active_plugins = get_site_option('active_sitewide_plugins', array());
         foreach ($plugins as $plugin_path) {
             $plugin_base = plugin_basename($plugin_path);
             if (!array_key_exists($plugin_base, $active_plugins)) {
                 continue;
             }
             $plugin = get_plugin_data($plugin_path);
             $return .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n";
         }
     }
     $return .= "\n" . '### End System Info ###';
     return $return;
 }
Example #12
0
    /**
     * Displays the "Save Commit" meta box in the sidebar.
     * @access public
     */
    public function save_commit_meta()
    {
        ?>

		<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 
        _e('Pending', 'revisr');
        ?>
</strong></span>
				</div>

				<div class="misc-pub-section revisr-pub-branch">
					<label for="revisr-branch" class="revisr-octicon-label"><?php 
        _e('Branch:', 'revisr');
        ?>
</label>
					<span><strong><?php 
        echo revisr()->git->branch;
        ?>
</strong></span>
				</div>

				<div class="misc-pub-section revisr-backup-cb">
					<span><input id="revisr-backup-cb" type="checkbox" name="backup_db" /></span>
					<label for="revisr-backup-cb"><?php 
        _e('Backup database?', 'revisr');
        ?>
</label>
				</div>

				<div class="misc-pub-section revisr-push-cb">
					<?php 
        if (revisr()->git->get_config('revisr', 'auto-push') == 'true') {
            ?>
						<input type="hidden" name="autopush_enabled" value="true" />
						<span><input id="revisr-push-cb" type="checkbox" name="auto_push" checked /></span>
					<?php 
        } else {
            ?>
						<span><input id="revisr-push-cb" type="checkbox" name="auto_push" /></span>
					<?php 
        }
        ?>
					<label for="revisr-push-cb"><?php 
        _e('Push changes?', 'revisr');
        ?>
</label>
				</div>

			</div><!-- /#misc-publishing-actions -->
		</div>

		<div id="major-publishing-actions">
			<div id="delete-action"></div>
			<div id="publishing-action">
				<span id="revisr-spinner" class="spinner"></span>
				<?php 
        wp_nonce_field('process_commit', 'revisr_commit_nonce');
        ?>
				<input type="submit" name="publish" id="commit" class="button button-primary button-large" value="<?php 
        _e('Commit Changes', 'revisr');
        ?>
" onclick="commit_files();" accesskey="p">
			</div>
			<div class="clear"></div>
		</div>

		<?php 
    }
Example #13
0
            break;
        case "delete_fail":
            $msg = sprintf(esc_html__('Failed to delete branch: %s.', 'revisr'), $_GET['branch']);
            echo '<div id="revisr-alert" class="error" style="margin-top:20px;"><p>' . $msg . '</p></div>';
        default:
            // Do nothing.
    }
}
?>

	<div id="col-container" class="revisr-col-container">

		<div id="col-right">
			<form id="revisr-branch-form">
				<?php 
revisr()->branch_table->display();
?>
			</form>
		</div><!-- /#col-right -->

		<div id="col-left">
			
			<div id="revisr-add-branch-box" class="postbox">
				<h3><?php 
_e('Add New Branch', 'revisr');
?>
</h3>
				<div class="inside">
					<form id="revisr-add-branch-form" method="post" action="<?php 
echo get_admin_url() . 'admin-post.php';
?>
Example #14
0
 /**
  * Displays the number of files changed in the admin bar.
  * @access public
  */
 public function admin_bar($wp_admin_bar)
 {
     if (revisr()->git->is_repo) {
         $untracked = revisr()->git->count_untracked();
         if ($untracked != 0) {
             $text = sprintf(_n('%d Untracked File', '%d Untracked Files', $untracked, 'revisr'), $untracked);
             $args = array('id' => 'revisr', 'title' => $text, 'href' => get_admin_url() . 'admin.php?page=revisr_new_commit', 'meta' => array('class' => 'revisr_commits'));
             $wp_admin_bar->add_node($args);
         }
         $wp_admin_bar->add_menu(array('id' => 'revisr-new-commit', 'title' => __('Commit', 'revisr'), 'parent' => 'new-content', 'href' => get_admin_url() . 'admin.php?page=revisr_new_commit'));
     }
 }
Example #15
0
    {
        global $wpdb;
        return esc_sql($wpdb->prefix . 'revisr');
    }
    /**
     * Installs the database table.
     * @access public
     */
    public static function install()
    {
        $table_name = Revisr::get_table_name();
        $sql = "CREATE TABLE {$table_name} (\n\t\t\tid mediumint(9) NOT NULL AUTO_INCREMENT,\n\t\t\ttime datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,\n\t\t\tmessage TEXT,\n\t\t\tevent VARCHAR(42) NOT NULL,\n\t\t\tuser VARCHAR(60),\n\t\t\tUNIQUE KEY id (id)\n\t\t\t);";
        require_once ABSPATH . 'wp-admin/includes/upgrade.php';
        dbDelta($sql);
        update_option('revisr_db_version', '2.0');
    }
}
/**
 * Returns a single instance of the Revisr plugin.
 *
 * @since 	1.8.2
 * @return 	object
 */
function revisr()
{
    return Revisr::get_instance();
}
// Let's go!
revisr();
// Register the activation hook.
register_activation_hook(__FILE__, array('Revisr', 'install'));
    /**
     * Displays/updates the "Reset DB" settings field.
     * @access public
     */
    public function reset_db_callback()
    {
        if (isset($_GET['settings-updated'])) {
            if (isset(revisr()->options['reset_db'])) {
                revisr()->git->set_config('revisr', 'import-checkouts', 'true');
            } else {
                revisr()->git->run('config', array('--unset-all', 'revisr.import-checkouts'));
            }
            if (isset(revisr()->options['import_db'])) {
                revisr()->git->set_config('revisr', 'import-pulls', 'true');
            } else {
                revisr()->git->run('config', array('--unset-all', 'revisr.import-pulls'));
            }
        }
        printf('<input type="checkbox" id="reset_db" name="revisr_database_settings[reset_db]" %s /><label for="reset_db">%s</label><br><br>
			<input type="checkbox" id="import_db" name="revisr_database_settings[import_db]" %s /><label for="import_db">%s</label><br><br>
			<p class="description revisr-description">%s</p>', checked(revisr()->git->get_config('revisr', 'import-checkouts'), 'true', false), __('Import database when changing branches?', 'revisr'), checked(revisr()->git->get_config('revisr', 'import-pulls'), 'true', false), __('Import database when pulling commits?', 'revisr'), __('If checked, Revisr will automatically import the above tracked tables while pulling from or checking out a branch. The tracked tables will be backed up beforehand to provide a restore point immediately prior to the import. Use this feature with caution and only after verifying that you have a full backup of your website.', 'revisr'));
    }
/**
 * pull-remote-form.php
 *
 * Displays the form to delete a branch.
 *
 * @package   	Revisr
 * @license   	GPLv3
 * @link      	https://revisr.io
 * @copyright 	Expanded Fronts, LLC
 */
// Disallow direct access.
if (!defined('ABSPATH')) {
    exit;
}
$styles_url = REVISR_URL . "assets/css/thickbox.css?v=02162015";
$revisr = revisr();
$tables = $revisr->db->get_tables_not_in_db();
?>

<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">
		<p><?php 
Example #18
0
 /**
  * Extra table navigation.
  * @access public
  * @param  string $which
  * @return string
  */
 public function extra_tablenav($which)
 {
     if ('top' != $which && revisr()->git->has_remote()) {
         if (isset($_GET['branches']) && $_GET['branches'] == 'remote') {
             $url = esc_url(add_query_arg(array('branches' => 'local')));
             printf('<a href="%s">%s</a>', $url, __('Local Branches', 'revisr'));
         } else {
             $url = esc_url(add_query_arg(array('branches' => 'remote')));
             printf('<a href="%s">%s</a>', $url, __('Remote Branches', 'revisr'));
         }
     }
 }
Example #19
0
 /**
  * Processes the results and alerts the user as necessary.
  * @access public
  * @param  array $args An array containing the results of the backup.
  * @return boolean
  */
 public function callback($args)
 {
     if (in_array(false, $args)) {
         // There were one or more errors with the import.
         $msg = __('Error importing the database.', 'revisr');
         Revisr_Admin::log($msg, 'error');
         Revisr_Admin::alert($msg, true);
     } else {
         // Everything imported properly.
         $get_hash = revisr()->git->run('config', array('revisr.last-db-backup'));
         $revert_link = '';
         if (is_array($get_hash)) {
             $undo_hash = $get_hash[0];
             $undo_url = get_admin_url() . 'admin-post.php?action=process_revert&revert_type=db&db_hash=' . $undo_hash;
             $undo_nonced = wp_nonce_url($undo_url, 'revisr_revert_nonce', 'revisr_revert_nonce');
             $revert_link = '<a href="' . $undo_nonced . '">' . __('Undo', 'revisr') . '</a>';
             revisr()->git->run('config', array('--unset', 'revisr.last-db-backup'));
         }
         // Alert the user.
         $msg = sprintf(__('Successfully imported the database. %s', 'revisr'), $revert_link);
         Revisr_Admin::log($msg, 'import');
         Revisr_Admin::alert($msg);
         // Fires after a successful database import.
         do_action('revisr_post_db_import');
         return true;
     }
     return false;
 }
Example #20
0
 /**
  * Updates the .gitignore file, and removes files from version control,
  * making sure to keep the physical copies of the files on the server.
  * @access public
  */
 public function update_gitignore()
 {
     // Store the content in the .gitignore.
     file_put_contents($this->work_tree . DIRECTORY_SEPARATOR . '.gitignore', revisr()->options['gitignore']);
     // Add the .gitignore.
     $this->run('add', array('.gitignore'));
     // Convert the .gitignore into an array we can work with.
     $files = explode(PHP_EOL, revisr()->options['gitignore']);
     foreach ($files as $file) {
         if ('' == $file || '!' === $file[0]) {
             // Don't do anything.
             continue;
         } else {
             /**
              * Remove the cached version of the file,
              * leaving it intact in the working directory.
              */
             $this->run('rm', array('--cached', $file));
         }
     }
     // Commit the updates.
     $commit_msg = __('Updated .gitignore.', 'revisr');
     $this->run('commit', array('-m', $commit_msg));
     $this->auto_push();
 }
Example #21
0
                printf('<tr><td><strong>%s</strong></td><td width="70"><a class="button disabled branch-btn" onlick="preventDefault()" href="#">%s</a></td></tr>', $branch, __('Checked Out', 'revisr'));
            } else {
                $branch_url = wp_nonce_url($admin_url . "admin-post.php?action=process_checkout&branch={$branch}", 'process_checkout', 'revisr_checkout_nonce');
                printf('<tr><td>%s</td><td width="70"><a class="button branch-btn" href="%s">%s</a></td></tr>', $branch, $branch_url, __('Checkout', 'revisr'));
            }
        }
    } else {
        printf('<tr><td>%s</td></tr>', __('No branches found.', 'revisr'));
    }
    ?>
									</table>
								</div>

								<div id="tags" class="tabs-panel" style="display: none;">
									<?php 
    $refs = revisr()->git->run('show-ref', array('--tags', '-d', '--abbrev=7'));
    $tags = array();
    if (is_array($refs)) {
        foreach ($refs as $ref) {
            $tmp = explode(' ', $ref);
            $tag = explode('/', $tmp[1]);
            $tag = end($tag);
            $tags[$tag] = $tmp[0];
        }
    }
    if (is_array($tags) && !empty($tags)) {
        echo '<ul id="tags-list">';
        foreach ($tags as $tag => $commit_hash) {
            $tag = esc_attr($tag);
            $url = esc_url(get_admin_url() . 'admin.php?page=revisr_view_commit&commit=' . $commit_hash);
            echo '<li class="revisr-tag"><a href="' . $url . '">' . $tag . '</a></li>';
Example #22
0
File: help.php Project: acchs/test
<p><?php 
_e('Found a bug or have a feature request? Please open an issue on <a href="https://github.com/ExpandedFronts/revisr" target="_blank">GitHub</a>!', 'revisr');
?>
</p>
</form>
<form class="revisr-settings-form" action="<?php 
echo esc_url(admin_url('admin-post.php'));
?>
" method="post">
	<textarea readonly="readonly" onclick="this.focus(); this.select()" style="width:750px;height:500px;font-family:Menlo,Monaco,monospace;" name='revisr-sysinfo'><?php 
echo Revisr_Compatibility::get_sysinfo();
?>
</textarea>
	<p class="submit">
		<input type="hidden" name="action" value="revisr_download_sysinfo" />
		<?php 
wp_nonce_field('process_download_sysinfo', 'revisr_info_nonce');
?>
		<?php 
submit_button('Download System Info', 'primary', 'revisr-download-sysinfo', false);
?>
		<?php 
if (revisr()->git->is_repo) {
    $status_text = __('View Status', 'revisr');
    $status_nonce = wp_create_nonce('revisr_view_status');
    printf('<a href="%s" title="%s" class="button thickbox">%s</a>', get_admin_url() . 'admin-post.php?action=process_view_status&revisr_status_nonce=' . $status_nonce . '&TB_iframe=true', $status_text, $status_text);
}
?>
	</p>
</form>
Example #23
0
 /**
  * Initialize the Git object.
  */
 function setUp()
 {
     $this->revisr = revisr();
     $this->revisr->git = new Revisr_Git();
 }
Example #24
0
 /**
  * Displays the "subsubsub" list.
  * @access public
  */
 public function render_views()
 {
     $branches = revisr()->git->get_branches();
     $views = array();
     $base_url = get_admin_url() . 'admin.php?page=revisr_commits';
     if (is_array($branches) && !empty($branches)) {
         foreach ($branches as $branch) {
             if (substr($branch, 0, 2) === '* ') {
                 $branch = substr($branch, 2);
                 $count = revisr()->git->run('rev-list', array('--count', $branch));
                 $count = is_array($count) ? absint($count[0]) : 0;
                 if (!isset($_GET['branch']) || $_GET['branch'] === $branch) {
                     $views[$branch] = '<a class="current" href="#">' . $branch . ' <span class="count">(' . $count . ')</span></a>';
                 } else {
                     $views[$branch] = '<a href="' . $base_url . '&branch=' . $branch . '">' . $branch . ' <span class="count">(' . $count . ')</span></a>';
                 }
             } else {
                 $branch = trim($branch);
                 $count = revisr()->git->run('rev-list', array('--count', $branch));
                 $count = is_array($count) ? absint($count[0]) : 0;
                 if (isset($_GET['branch']) && $_GET['branch'] === $branch) {
                     $views[$branch] = '<a class="current" href="#">' . $branch . ' <span class="count">(' . $count . ')</span></a>';
                 } elseif (isset($_GET['branch']) && 'all' === $branch) {
                     $views[$branch] = '<a href="' . $base_url . '&branch=' . $branch . '">' . $branch . '</a>';
                 } else {
                     $views[$branch] = '<a href="' . $base_url . '&branch=' . $branch . '">' . $branch . ' <span class="count">(' . $count . ')</span></a>';
                 }
             }
         }
     }
     // Start outputting the list.
     echo '<ul class="subsubsub">';
     foreach ($views as $class => $view) {
         $views[$class] = "\t<li class='{$class}'>{$view}";
     }
     // Render the "All" link.
     $all_class = isset($_GET['branch']) && 'all' === $_GET['branch'] ? 'current' : '';
     $all_count = revisr()->git->run('rev-list', array('--count', '--all'));
     $all_count = is_array($all_count) ? absint($all_count[0]) : 0;
     echo '<li class="all"><a class="' . $all_class . '" href="' . $base_url . '&branch=all">' . __('All', 'revisr') . ' <span class="count">(' . $all_count . ')</span></a> |</li>';
     // Render the branches.
     echo implode(" |</li>\n", $views) . "</li>\n";
     echo '</ul>';
 }
Example #25
0
	<h1><?php 
_e('Commits', 'revisr');
?>
 <a href="<?php 
echo get_admin_url();
?>
admin.php?page=revisr_new_commit" class="page-title-action"><?php 
_e('Add New', 'revisr');
?>
</a></h1>

	<?php 
revisr()->commits_table->render_views();
?>

	<form id="revisr-commits-filter" action="<?php 
echo get_admin_url();
?>
admin.php">
		<input type="hidden" name="page" value="revisr_commits" />
		<?php 
revisr()->commits_table->render_search();
?>
		<?php 
revisr()->commits_table->display();
?>
	</form>

</div><!-- /.wrap -->
Example #26
0
 /**
  * Tests the revisr() method.
  */
 function test_revisr()
 {
     revisr();
     $this->assertClassHasStaticAttribute('instance', 'Revisr');
 }
Example #27
0
 * uninstall.php
 *
 * Fired when the plugin is deleted.
 *
 * @package   	Revisr
 * @license   	GPLv3
 * @link      	https://revisr.io
 * @copyright 	Expanded Fronts, LLC
 */
// Exit if uninstall not called from WP.
if (!defined('WP_UNINSTALL_PLUGIN')) {
    exit;
}
// Load main plugin file.
include_once 'revisr.php';
if (revisr()->options['uninstall_on_delete']) {
    // Remove any set crons.
    wp_clear_scheduled_hook('revisr_cron');
    // Remove any set options.
    delete_option('revisr_settings');
    delete_option('revisr_general_settings');
    delete_option('revisr_remote_settings');
    delete_option('revisr_database_settings');
    // Remove any set transients.
    delete_transient('revisr_error_details');
    delete_transient('revisr_error');
    delete_transient('revisr_alert');
    delete_transient('revisr_skip_setup');
    // Delete any commits.
    $commits = get_posts(array('post_type' => 'revisr_commits', 'post_status' => 'any', 'number_posts' => -1, 'fields' => 'ids'));
    foreach ($commits as $commit) {
Example #28
0
</p>
		<input id="import_db" type="checkbox" name="import_db" <?php 
checked(revisr()->git->get_config('revisr', 'import-checkouts'), 'true');
?>
 />
		<label for="import_db"><?php 
_e('Import tracked database tables', 'revisr');
?>
</label>
	</div>

	<div class="revisr-tb-submit">
		<input type="hidden" name="action" value="process_checkout" />

		<?php 
if (!revisr()->git->is_branch($local)) {
    ?>
			<input type="hidden" name="new_branch" value="true" />
		<?php 
}
?>

		<input type="hidden" name="echo_redirect" value="true" />
		<input type="hidden" name="branch" value="<?php 
echo esc_attr($local);
?>
" />
		<?php 
wp_nonce_field('process_checkout', 'revisr_checkout_nonce');
?>
		<button id="merge-btn" class="revisr-tb-btn revisr-tb-danger"><?php 
Example #29
0
<div class="wrap">

    <h1><?php 
_e('View Commit', 'revisr');
?>
 <a href="<?php 
echo get_admin_url();
?>
admin.php?page=revisr_new_commit" class="page-title-action"><?php 
_e('Add New', 'revisr');
?>
</a></h1>

    <?php 
if (isset($_GET['success'])) {
    $msg = sprintf(__('Committed files on branch <strong>%s</strong>.', 'revisr'), revisr()->git->branch);
    echo '<div class="revisr-alert updated"><p>' . $msg . '</p></div>';
}
?>

    <form id="revisr-commit-form" method="post" action="<?php 
echo get_admin_url();
?>
admin-post.php">

        <input type="hidden" name="action" value="process_commit">
        <?php 
wp_nonce_field('process_commit', 'revisr_commit_nonce');
// Save metabox order, state
wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
Example #30
0
/**
 * pull-remote-form.php
 *
 * Displays the form to delete a branch.
 *
 * @package   	Revisr
 * @license   	GPLv3
 * @link      	https://revisr.io
 * @copyright 	Expanded Fronts, LLC
 */
// Disallow direct access.
if (!defined('ABSPATH')) {
    exit;
}
$styles_url = REVISR_URL . "assets/css/thickbox.css?v=" . REVISR_VERSION;
$tables = revisr()->db->get_tables_not_in_db();
?>

<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">
		<p><?php 
_e('The following new tables were added to the repository, but not automatically imported due to your tracking settings. Check any tables that you\'d like to import and click "Import" to continue.', 'revisr');