Permalink
Browse files

enabling rollback

  • Loading branch information...
1 parent 21ff005 commit ec0392187b691c3263f5c6729ac6f2731ccb9a0d @beck beck committed Jun 6, 2011
Showing with 29 additions and 12 deletions.
  1. +18 −1 assets.php
  2. +1 −1 readme.markdown
  3. +10 −10 updater.php
View
@@ -24,7 +24,24 @@ function github_theme_update_row( $theme_key, $theme ) {
printf('Error with Github Theme Updater. %1$s', $r['error']);
} else if(isset($r['up-to-date'])){
echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message-gtu update-ok">';
- printf('Theme is up-to-date! <a href="#">Rollback you say?</a>');
+ echo 'Theme is up-to-date! ';
+ if (current_user_can('update_themes') ){
+ if(count($r['rollback']) > 0){
+ echo "Rollback to: ";
+ // display last three tags
+ for($i=0; $i<3 ; $i++){
+ $tag = array_pop($r['rollback']);
+ if(empty($tag)) break;
+ if($i>0) echo ", ";
+ printf('<a href="%s%s">%s</a>',
+ wp_nonce_url( self_admin_url('update.php?action=upgrade-github-theme&theme=') . $theme_key, 'upgrade-theme_' . $theme_key),
+ '&rollback=' . urlencode($tag),
+ $tag);
+ }
+ } else {
+ echo "No previous tags to rollback to.";
+ }
+ }
} else {
// modified wp
echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message-gtu">';
View
@@ -2,7 +2,7 @@
## Installation & Use
-[Here](https://github.com/beck/Theme-Updater-Demo) is a sample theme. [Download (.zip)](https://github.com/beck/Theme-Updater-Demo/zipball/v1.1.0)
+[Here](https://github.com/UCF/Theme-Updater-Demo) is a sample theme. [Download (.zip)](https://github.com/UCF/Theme-Updater-Demo/zipball/v1.1.0)
### 1- Publish Theme to a public GitHub Repository
View
@@ -72,27 +72,27 @@ function transient_update_themes_filter($data){
// Sort and get latest tag
$tags = array_keys(get_object_vars($response->tags));
usort($tags, "version_compare");
- $newest_tag = array_pop($tags);
+
+
+ // check for rollback
+ if(isset($_GET['rollback'])){
+ $data->response[$theme_key]['package'] = $theme['UpdateURI'] . '/zipball/' . urlencode($_GET['rollback']);
+ continue;
+ }
// check and generate download link
+ $newest_tag = array_pop($tags);
if(version_compare($theme['Version'], $newest_tag, '>=')){
// up-to-date!
$data->response[$theme_key]['up-to-date'] = true;
-
- // give option to rollback to previous two tags
- $rollback = array();
- for($i=0; $i<2; $i++){
- $tag = array_pop($tags);
- if($tag) $rollback[$tag] = $theme['UpdateURI'] . '/zipball/' . $tag;
- }
- $data->response[$theme_key]['rollback'] = $rollback;
+ $data->response[$theme_key]['rollback'] = $tags;
continue;
}
- $download_link = $theme['UpdateURI'] . '/zipball/' . $newest_tag;
// new update available, add to $data
+ $download_link = $theme['UpdateURI'] . '/zipball/' . $newest_tag;
$update = array();
$update['new_version'] = $newest_tag;
$update['url'] = $theme['UpdateURI'];

0 comments on commit ec03921

Please sign in to comment.