예제 #1
0
 /**
  * Initiate the class properties.
  * @access public
  */
 public function __construct()
 {
     $this->dir = $this->current_dir();
     $this->options = Revisr::get_options();
     $this->branch = $this->current_branch();
     $this->remote = $this->current_remote();
     $this->hash = $this->current_commit();
 }
예제 #2
0
 /**
  * Initiates the class and it's properties.
  * @access public
  */
 public function __construct()
 {
     // Necessary for execution of Revisr.
     $this->current_dir = getcwd();
     $this->is_repo = true;
     $this->options = Revisr::get_options();
     $this->git_path = $this->get_git_path();
     $this->git_dir = $this->get_git_dir();
     // Load up information about the current repository.
     if ($this->is_repo) {
         $this->branch = $this->current_branch();
         $this->remote = $this->current_remote();
         $this->current_commit = $this->current_commit();
     }
 }
예제 #3
0
 /**
  * Initiate the class.
  * @access public
  * @param  string $path Optional, overrides the saved setting (for testing).
  */
 public function __construct($path = '')
 {
     global $wpdb;
     $this->wpdb = $wpdb;
     $this->git = new Revisr_Git();
     $this->current_dir = getcwd();
     $this->upload_dir = wp_upload_dir();
     $this->options = Revisr::get_options();
     $get_path = $this->git->config_revisr_path('mysql');
     if (is_array($get_path)) {
         $this->path = $get_path[0];
     } else {
         $this->path = '';
     }
     $this->setup_env();
 }
예제 #4
0
 /**
  * Registers the menus used by Revisr.
  * @access public
  */
 public function menus()
 {
     $cap = Revisr::get_capability();
     $icon_svg = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAxOC4xLjAsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4NCjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iTGF5ZXJfMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeD0iMHB4IiB5PSIwcHgiDQo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uNywyMS43LTE1LjUNCglDMzMxLjIsNDM4LjEsMzI5LjksNDE3LjQsMzE4LjMsNDAzLjN6IE0zMDQuOCw0MDMuM2MtMy44LDAtNi45LTMuMS02LjktNi45czMuMS02LjksNi45LTYuOXM2LjksMy4xLDYuOSw2LjkNCglTMzA4LjcsNDAzLjMsMzA0LjgsNDAzLjN6Ii8+DQo8L3N2Zz4=';
     if (!Revisr_Admin::is_doing_setup()) {
         $this->page_hooks['menu'] = add_menu_page(__('Dashboard', 'revisr'), __('Revisr', 'revisr'), $cap, 'revisr', array($this, 'include_page'), $icon_svg);
         $this->page_hooks['dashboard'] = add_submenu_page('revisr', __('Revisr - Dashboard', 'revisr'), __('Dashboard', 'revisr'), $cap, 'revisr', array($this, 'include_page'));
         $this->page_hooks['commits'] = add_submenu_page('revisr', __('Revisr - Commits', 'revisr'), __('Commits', 'revisr'), $cap, 'revisr_commits', array($this, 'include_page'));
         $this->page_hooks['new_commit'] = add_submenu_page(NULL, __('Revisr - New Commit', 'revisr'), __('New Commit', 'revisr'), $cap, 'revisr_new_commit', array($this, 'include_page'));
         $this->page_hooks['view_commit'] = add_submenu_page(NULL, __('Revisr - View Commit', 'revisr'), __('View Commit', 'revisr'), $cap, 'revisr_view_commit', array($this, 'include_page'));
         $this->page_hooks['branches'] = add_submenu_page('revisr', __('Revisr - Branches', 'revisr'), __('Branches', 'revisr'), $cap, 'revisr_branches', array($this, 'include_page'));
         $this->page_hooks['settings'] = add_submenu_page('revisr', __('Revisr - Settings', 'revisr'), __('Settings', 'revisr'), $cap, 'revisr_settings', array($this, 'include_page'));
         $this->page_hooks['setup'] = add_submenu_page(NULL, __('Revisr - Setup', 'revisr'), 'Revisr', $cap, 'revisr_setup', array($this, 'include_page'));
     } else {
         $this->page_hooks['setup'] = add_menu_page(__('Revisr Setup', 'revisr'), __('Revisr', 'revisr'), $cap, 'revisr_setup', array($this, 'include_page'), $icon_svg);
         $this->page_hooks['dashboard'] = add_submenu_page(null, __('Revisr - Dashboard', 'revisr'), __('Dashboard', 'revisr'), $cap, 'revisr', array($this, 'include_page'));
         $this->page_hooks['branches'] = add_submenu_page(NULL, __('Revisr - Branches', 'revisr'), __('Branches', 'revisr'), $cap, 'revisr_branches', array($this, 'include_page'));
         $this->page_hooks['settings'] = add_submenu_page(NULL, __('Revisr - Settings', 'revisr'), __('Settings', 'revisr'), $cap, 'revisr_settings', array($this, 'include_page'));
     }
 }
예제 #5
0
파일: revisr.php 프로젝트: acchs/test
 /**
  * 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');
 }
예제 #6
0
 /**
  * Downloads the system info.
  * @access public
  */
 public function download_sysinfo()
 {
     Revisr_Admin::verify_nonce($_REQUEST['revisr_info_nonce'], 'process_download_sysinfo');
     if (!current_user_can(Revisr::get_capability())) {
         return;
     }
     nocache_headers();
     header('Content-Type: text/plain');
     header('Content-Disposition: attachment; filename="revisr-system-info.txt"');
     echo wp_strip_all_tags($_POST['revisr-sysinfo']);
     die;
 }
예제 #7
0
 /**
  * Tests get_table_name().
  */
 function test_get_table_name()
 {
     $revisr_table_name = Revisr::get_table_name();
     $this->assertContains('revisr', $revisr_table_name);
 }
예제 #8
0
파일: test-revisr.php 프로젝트: E-2/Revisr
 /**
  * Tests the database installation.
  */
 function test_install()
 {
     Revisr::install();
     global $wpdb;
     $table_name = $wpdb->prefix . 'revisr';
     $table_check = $wpdb->get_var("SHOW TABLES LIKE '{$table_name}'");
     $this->assertEquals($table_name, $table_check);
 }
예제 #9
0
 /**
  * Notifies the admin if notifications are enabled.
  * @access private
  * @param  string $subject The subject line of the email.
  * @param  string $message The message for the email.
  */
 public static function notify($subject, $message)
 {
     $options = Revisr::get_options();
     $url = get_admin_url() . 'admin.php?page=revisr';
     if (isset($options['notifications'])) {
         $email = $options['email'];
         $message .= '<br><br>';
         $message .= sprintf(__('<a href="%s">Click here</a> for more details.', 'revisr'), $url);
         $headers = "Content-Type: text/html; charset=ISO-8859-1\r\n";
         wp_mail($email, $subject, $message, $headers);
     }
 }
 /**
  * Initialize the class.
  * @access public
  */
 public function __construct()
 {
     $this->git = new Revisr_Git();
     $this->options = Revisr::get_options();
 }
예제 #11
0
파일: bootstrap.php 프로젝트: E-2/Revisr
<?php

$_tests_dir = getenv('WP_TESTS_DIR');
if (!$_tests_dir) {
    $_tests_dir = '/tmp/wordpress-tests-lib';
}
require_once $_tests_dir . '/includes/functions.php';
function _manually_load_plugin()
{
    require dirname(__FILE__) . '/../revisr.php';
}
tests_add_filter('muplugins_loaded', '_manually_load_plugin');
require $_tests_dir . '/includes/bootstrap.php';
//define( 'REVISR_GIT_DIR', '/tmp/wordpress' );
// Activate & install the plugin
Revisr::install();
예제 #12
0
 /**
  * Prepares the data for display.
  * @access public
  */
 public function prepare_items()
 {
     global $wpdb;
     $table = Revisr::get_table_name();
     // Number of items per page.
     $per_page = $this->get_items_per_page('edit_revisr_events_per_page', 15);
     // Set up the custom columns.
     $columns = $this->get_columns();
     $hidden = array();
     $sortable = $this->get_sortable_columns();
     // Builds the list of column headers.
     $this->_column_headers = array($columns, $hidden, $sortable);
     // Run any custom filters.
     $where = $this->create_where();
     // Get the data to populate into the table.
     $data = $wpdb->get_results("SELECT message, time, user FROM {$table} {$where}", ARRAY_A);
     // Handle sorting of the data.
     function usort_reorder($a, $b)
     {
         // Default to time for default sort.
         $orderby = isset($_REQUEST['orderby']) ? $_REQUEST['orderby'] : 'time';
         // Default to descending for default sort order.
         $order = isset($_REQUEST['order']) ? $_REQUEST['order'] : 'desc';
         // Determine the sort order and send to usort.
         $result = strcmp($a[$orderby], $b[$orderby]);
         return $order === 'asc' ? $result : -$result;
     }
     usort($data, 'usort_reorder');
     // Pagination.
     $current_page = $this->get_pagenum();
     $total_items = count($data);
     $data = array_slice($data, ($current_page - 1) * $per_page, $per_page);
     $this->items = $data;
     $this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $per_page, 'total_pages' => ceil($total_items / $per_page), 'orderby' => isset($_REQUEST['orderby']) ? $_REQUEST['orderby'] : 'time', 'order' => isset($_REQUEST['order']) ? $_REQUEST['order'] : 'desc'));
 }
예제 #13
0
 /**
  * Updates user settings to be compatible with 1.8.
  * @access public
  */
 public function do_upgrade()
 {
     global $wpdb;
     // For users upgrading from 1.7 and older.
     if (get_option('revisr_db_version') === '1.0') {
         // Check for the "auto_push" option and save it to the config.
         if (isset(revisr()->options['auto_push'])) {
             revisr()->git->set_config('revisr', 'auto-push', 'true');
         }
         // Check for the "auto_pull" option and save it to the config.
         if (isset(revisr()->options['auto_pull'])) {
             revisr()->git->set_config('revisr', 'auto-pull', 'true');
         }
         // Check for the "reset_db" option and save it to the config.
         if (isset(revisr()->options['reset_db'])) {
             revisr()->git->set_config('revisr', 'import-checkouts', 'true');
         }
         // Check for the "mysql_path" option and save it to the config.
         if (isset(revisr()->options['mysql_path'])) {
             revisr()->git->set_config('revisr', 'mysql-path', revisr()->options['mysql_path']);
         }
         // Configure the database tracking to use all tables, as this was how it behaved in 1.7.
         revisr()->git->set_config('revisr', 'db_tracking', 'all_tables');
     }
     // Upgrades from the "revisr_commits" custom post type to pure Git.
     $table = Revisr::get_table_name();
     $commits = $wpdb->get_results("SELECT * FROM {$table} WHERE event = 'commit'", ARRAY_A);
     if (is_array($commits) && !empty($commits)) {
         foreach ($commits as $commit) {
             // Get the commit short hash from the message.
             $msg_array = explode('#', $commit['message']);
             $commit_id = substr($msg_array[1], 0, 7);
             // Prepare the new message.
             $new_msg = sprintf(__('Committed <a href="%s">#%s</a> to the local repository.', 'revisr'), get_admin_url() . 'admin.php?page=revisr_view_commit&commit=' . $commit_id, $commit_id);
             // Update the existing message.
             $query = $wpdb->prepare("UPDATE {$table} SET message = %s WHERE id = '%d'", $new_msg, $commit['id']);
             $wpdb->query($query);
         }
     }
     // Update the database schema using dbDelta.
     Revisr::install();
 }
예제 #14
0
<?php

$_tests_dir = getenv('WP_TESTS_DIR');
if (!$_tests_dir) {
    $_tests_dir = '/tmp/wordpress-tests-lib';
}
require_once $_tests_dir . '/includes/functions.php';
function _manually_load_plugin()
{
    require dirname(__FILE__) . '/../revisr.php';
}
tests_add_filter('muplugins_loaded', '_manually_load_plugin');
require $_tests_dir . '/includes/bootstrap.php';
define('REVISR_GIT_DIR', '/tmp/wordpress');
// Activate & install the plugin
Revisr::revisr_install();
예제 #15
0
 */
$dir = plugin_dir_path(__FILE__);
$loader_url = plugins_url('../assets/img/loader.gif', __FILE__);
wp_enqueue_script('revisr_dashboard');
wp_localize_script('revisr_dashboard', 'dashboard_vars', array('ajax_nonce' => wp_create_nonce('dashboard_nonce')));
?>
<div class="wrap">
	
	<div id="icon-options-general" class="icon32"></div>
	<h2><?php 
_e('Revisr - Dashboard', 'revisr');
?>
</h2>
	
	<?php 
$error = Revisr::check_compatibility();
if ($error != '') {
    echo "<div id='revisr_error' class='error'>{$error}</div>";
} else {
    $pending = Revisr_Git::count_pending();
    if (isset($_GET['revert_db']) && $_GET['revert_db'] == 'success') {
        $text = "<p>" . __('Successfully reverted the database.', 'revisr') . "</p>";
    } else {
        if (isset($_GET['checkout']) && $_GET['checkout'] == 'success') {
            $text = sprintf(__('<p>Successfully checked out branch <strong>%s</strong>.</p>', 'revisr'), $_GET['branch']);
        } else {
            if (isset($_GET['revert']) && $_GET['revert'] == 'success') {
                $url = get_admin_url() . "post.php?post={$_GET['id']}&action=edit";
                $text = "<p>Successfully reverted to commit <a href='{$url}'><strong>#{$_GET['commit']}</strong></a>.</p>";
            } else {
                if ($pending != 0) {
예제 #16
0
 /**
  * Tests the settings_link() method.
  */
 function test_settings_link()
 {
     $settings_links = serialize(Revisr::settings_link($links = array()));
     $this->assertContains('revisr', $settings_links);
 }