WP Downgrade | Specific Core Version - Version 1.2.0

Version Description

  • Advanced option: You are now able to manually edit the download link, if necessary. This allows, for example, a change of language. Or you can get the release from another source.
  • Notes improved a little.
  • compatibility with WordPress 5.0.2
Download this release

Release Info

Developer Reisetiger
Plugin Icon 128x128 WP Downgrade | Specific Core Version
Version 1.2.0
Comparing to
See all releases

Code changes from version 1.1.4 to 1.2.0

Files changed (2) hide show
  1. readme.txt +8 -1
  2. wp-downgrade.php +81 -18
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: Reisetiger
3
  Donate link: http://www.reisetiger.net
4
  Tags: Downgrade, Core, WP-Core, Version, Rollback, Upgrade, Update, Release, Versionskontrolle
5
  Requires at least: 3.0.1
6
- Tested up to: 5.0.1
7
  Stable tag: trunk
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -24,6 +24,8 @@ The user Gahapati describes it so much better than I can. (Thank you!)
24
 
25
  > For security reasons I think this is a must-have plugin for anyone running a "seasoned" WP installation, and it actually should be a Core feature to be able to update not to the *latest* WP release exclusively but instead to have a choice among *secure* releases.
26
 
 
 
27
  **DE:** Das Plugin "WP Downgrade" zwingt die WordPress-interne Update-Funktion, ein **bestimmtes** WordPress-Release zu installieren. Das definierte Core-Release wird **wie ein reguläres Update** von wordpress.org bezogen und direkt installiert.
28
  Das klappt wie gewohnt per Update-Button im Admin-Bereich oder per Auto-Update. Die Versionsnummer kann sowohl **höher** als auch **niedriger** sein als die aktuell installierte Version. Somit ist also auch ein Rollback auf frühere Releases möglich. Dein WordPress wird solange auf dieser Version bleiben, bis du eine neue Versionsnummer in WP-Downgrade hinterlegst (oder bis du die Versionsnummer leerst oder das Plugin deaktivierst).
29
 
@@ -63,6 +65,11 @@ A: Weil es bisher keine Fragen gab! :-)
63
 
64
 
65
  == Changelog ==
 
 
 
 
 
66
  = 1.1.4 =
67
  * Improved access to the settings page (link from plugin overview)
68
  * compatibility with WordPress 4.7.1
3
  Donate link: http://www.reisetiger.net
4
  Tags: Downgrade, Core, WP-Core, Version, Rollback, Upgrade, Update, Release, Versionskontrolle
5
  Requires at least: 3.0.1
6
+ Tested up to: 5.0.2
7
  Stable tag: trunk
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
24
 
25
  > For security reasons I think this is a must-have plugin for anyone running a "seasoned" WP installation, and it actually should be a Core feature to be able to update not to the *latest* WP release exclusively but instead to have a choice among *secure* releases.
26
 
27
+ New advanced option: You are now able to manually edit the download link, if necessary. This allows, for example, a change of language for wp-core. Or you can get the release from another source.
28
+
29
  **DE:** Das Plugin "WP Downgrade" zwingt die WordPress-interne Update-Funktion, ein **bestimmtes** WordPress-Release zu installieren. Das definierte Core-Release wird **wie ein reguläres Update** von wordpress.org bezogen und direkt installiert.
30
  Das klappt wie gewohnt per Update-Button im Admin-Bereich oder per Auto-Update. Die Versionsnummer kann sowohl **höher** als auch **niedriger** sein als die aktuell installierte Version. Somit ist also auch ein Rollback auf frühere Releases möglich. Dein WordPress wird solange auf dieser Version bleiben, bis du eine neue Versionsnummer in WP-Downgrade hinterlegst (oder bis du die Versionsnummer leerst oder das Plugin deaktivierst).
31
 
65
 
66
 
67
  == Changelog ==
68
+ = 1.2.0 =
69
+ * Advanced option: You are now able to manually edit the download link, if necessary. This allows, for example, a change of language. Or you can get the release from another source.
70
+ * Notes improved a little.
71
+ * compatibility with WordPress 5.0.2
72
+
73
  = 1.1.4 =
74
  * Improved access to the settings page (link from plugin overview)
75
  * compatibility with WordPress 4.7.1
wp-downgrade.php CHANGED
@@ -2,8 +2,8 @@
2
  /*
3
  Plugin Name: WP Downgrade | Specific Core Version
4
  Plugin URI: https://www.reisetiger.net
5
- Description: WP Downgrade allows you to either downgrade or update WordPress Core to an arbitrary version of your choice. The version you choose is downloaded directly from wordpress.org and installed just like any regular update. The target version WordPress allows you to update to remains constant until you enter a different one or deactivate the plugin either completely or by leaving the target version field empty.
6
- Version: 1.1.4
7
  Author: Reisetiger
8
  Author URI: https://www.reisetiger.net
9
  License: GPL2
@@ -36,6 +36,8 @@ function wp_downgrade_create_menu() {
36
  function register_wp_downgrade_settings() {
37
  //register our settings
38
  register_setting( 'wpdg-settings-group', 'wpdg_specific_version_name' );
 
 
39
  // register_setting( 'wpdg-settings-group', 'some_other_option' );
40
  }
41
 
@@ -48,32 +50,78 @@ function wp_downgrade_action_links( $links ) {
48
  function wp_downgrade_settings_page() {
49
  ?>
50
  <div class="wrap">
51
- <h2><?php _e('WP Downgrade', 'wp-downgrade'); ?>: <?php if (get_option('wpdg_specific_version_name')) { ?><span style="color: green;"><?php _e('Active', 'wp-downgrade'); ?> (<?php _e('WP', 'wp-downgrade'); ?> <?php echo get_option('wpdg_specific_version_name'); ?> <?php _e('is set as target version', 'wp-downgrade'); ?>)</span><?php } else {; ?><span style="color: red;"><?php _e('Inactive', 'wp-downgrade'); ?></span><?php }; ?></h2>
 
 
52
 
53
  <p><?php _e('WARNING! You are using this plugin entirely at your own risk! DO MAKE SURE you have a current backup of both your files and database, since a manual version change is deeply affecting your WP installation!', 'wp-downgrade'); ?></p>
54
 
55
  <h3><?php _e('Which WordPress version would you like to up-/downgrade to?', 'wp-downgrade'); ?></h3>
56
 
57
- <?php global $wp_version; ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
 
59
  <form method="post" action="options.php">
60
  <?php settings_fields( 'wpdg-settings-group' ); ?>
61
  <?php do_settings_sections( __FILE__ ); ?>
62
  <table class="form-table">
 
 
63
  <tr valign="top">
64
  <th scope="row"><?php _e('WordPress Target Version', 'wp-downgrade'); ?>:</th>
65
- <td><input type="text" maxlength="6" pattern="[-+]?[0-9]*[.]?[0-9]?[.]?[0-9]+" placeholder="<?php echo $wp_version; ?>" name="wpdg_specific_version_name" value="<?php echo esc_attr( get_option('wpdg_specific_version_name') ); ?>" /> (<?php _e('Exact version number from', 'wp-downgrade'); ?> <a href="https://de.wordpress.org/releases/" target="_blank"><?php _e('WP Releases', 'wp-downgrade'); ?></a>, <?php _e('e.g. "4.4.3". Leave empty to deactivate.', 'wp-downgrade'); ?>)</td>
 
66
  </tr>
67
 
68
  <tr valign="top">
69
  <th scope="row"><?php _e('Current WP Version', 'wp-downgrade'); ?>:</th>
70
  <td><?php echo $wp_version; ?></td>
 
71
  </tr>
72
 
73
  <tr valign="top">
74
  <th scope="row"><?php _e('Language Detected', 'wp-downgrade'); ?>:</th>
75
  <td><?php echo get_locale() ?></td>
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  </tr>
 
 
77
  </table>
78
 
79
 
@@ -82,15 +130,24 @@ function wp_downgrade_settings_page() {
82
 
83
  </form>
84
 
85
- <?php if (get_option('wpdg_specific_version_name')) { ?>
86
-
87
- <p><strong><?php _e('In order to perform the upgrade/downgrade to WP', 'wp-downgrade'); ?> <?php echo get_option('wpdg_specific_version_name'); ?> <?php _e('please go to', 'wp-downgrade'); ?> <a href="<?php echo get_admin_url( null, '/update-core.php' ) ;?>"><?php _e('Update Core', 'wp-downgrade'); ?></a>. </strong></p>
88
- <p><a href="<?php echo get_admin_url( null, '/update-core.php' ) ;?>" class="button"><?php _e('Up-/Downgrade Core', 'wp-downgrade'); ?></a></p>
 
 
 
 
 
 
 
89
 
90
  <?php if (wpdg_urlcheck(wpdg_get_url(get_option('wpdg_specific_version_name'))) == false){ ?>
 
91
  <span style="color: red;"> <?php _e('Attention! The target version does not seem to exist!', 'wp-downgrade'); ?> </span><br>
92
  <span style="color: red;"> URL: <?php echo wpdg_get_url(get_option('wpdg_specific_version_name')); ?></span><br>
93
- <span style="color: red;"> <?php _e('The update could fail. Are you sure that the version number is correct?', 'wp-downgrade'); echo " <strong>". get_option('wpdg_specific_version_name'); ?> </strong></span><br>
 
94
  <?php }
95
 
96
  //echo wpdg_get_url(get_option('wpdg_specific_version_name'));
@@ -117,11 +174,13 @@ if ($dg_version < 1)
117
 
118
  global $wp_version;
119
  // If current version is target version then stop
 
120
  if ( version_compare( $wp_version, $dg_version ) == 0 ) {
121
  return;
122
  } //https://downloads.wordpress.org/release/de_DE/wordpress-4.5.zip
123
- $updates->updates[0]->download = 'https://downloads.wordpress.org/release/'.$sprache.'wordpress-'.$dg_version.'.zip';
124
- $updates->updates[0]->packages->full = 'https://downloads.wordpress.org/release/'.$sprache.'wordpress-'.$dg_version.'.zip';
 
125
  $updates->updates[0]->packages->no_content = '';
126
  $updates->updates[0]->packages->new_bundled = '';
127
  $updates->updates[0]->current = $dg_version;
@@ -140,12 +199,16 @@ function wpdg_urlcheck($url) {
140
  }
141
 
142
  function wpdg_get_url($version) {
143
- $sprache = get_locale().'/';
144
- if ($sprache == 'en_US/'){
145
- $sprache = '';
146
- };
147
- $url = "https://downloads.wordpress.org/release/".$sprache."wordpress-".$version.".zip";
148
- return $url;
 
 
 
 
149
  }
150
 
151
  ?>
2
  /*
3
  Plugin Name: WP Downgrade | Specific Core Version
4
  Plugin URI: https://www.reisetiger.net
5
+ Description: WP Downgrade allows you to either downgrade or update WordPress Core to an arbitrary version of your choice. The version you choose is downloaded directly from wordpress.org and installed just like any regular release update. The target version WordPress allows you to update to remains constant until you enter a different one or deactivate the plugin either completely or by leaving the target version field empty.
6
+ Version: 1.2.0
7
  Author: Reisetiger
8
  Author URI: https://www.reisetiger.net
9
  License: GPL2
36
  function register_wp_downgrade_settings() {
37
  //register our settings
38
  register_setting( 'wpdg-settings-group', 'wpdg_specific_version_name' );
39
+ register_setting( 'wpdg-settings-group', 'wpdg_download_url' );
40
+ register_setting( 'wpdg-settings-group', 'wpdg_edit_download_url' );
41
  // register_setting( 'wpdg-settings-group', 'some_other_option' );
42
  }
43
 
50
  function wp_downgrade_settings_page() {
51
  ?>
52
  <div class="wrap">
53
+ <h2>WP Downgrade Options</h2>
54
+
55
+ <h3><?php _e('WP Downgrade', 'wp-downgrade'); ?>: <?php if (get_option('wpdg_specific_version_name')) { ?><span style="color: green;"><?php _e('Active', 'wp-downgrade'); ?> (<?php _e('WP', 'wp-downgrade'); ?> <?php echo get_option('wpdg_specific_version_name'); ?> <?php _e('is set as target version', 'wp-downgrade'); ?>)</span><?php } else {; ?><span style="color: red;"><?php _e('Inactive', 'wp-downgrade'); ?></span><?php }; ?></h3>
56
 
57
  <p><?php _e('WARNING! You are using this plugin entirely at your own risk! DO MAKE SURE you have a current backup of both your files and database, since a manual version change is deeply affecting your WP installation!', 'wp-downgrade'); ?></p>
58
 
59
  <h3><?php _e('Which WordPress version would you like to up-/downgrade to?', 'wp-downgrade'); ?></h3>
60
 
61
+ <script>
62
+ function myFunction() {
63
+ var checkBox = document.getElementById("myCheck");
64
+ var text = document.getElementById("download-url-text");
65
+ var field = document.getElementById("download-url");
66
+ if (checkBox.checked == true){
67
+ text.style.display = "inline";
68
+ field.style.display = "inline";
69
+ } else {
70
+ text.style.display = "none";
71
+ field.style.display = "none";
72
+ }
73
+ }
74
+ </script>
75
+
76
+
77
+ <?php global $wp_version;
78
+
79
+ // ein paar wichtige Sprachversionen, ansonsten international
80
+ if(get_locale() == 'de_DE')
81
+ $release_link = 'https://de.wordpress.org/releases/';
82
+ else if(get_locale() == 'es_ES')
83
+ $release_link = 'https://de.wordpress.org/releases/';
84
+ else
85
+ $release_link = 'https://wordpress.org/download/releases/';
86
+ ?>
87
 
88
  <form method="post" action="options.php">
89
  <?php settings_fields( 'wpdg-settings-group' ); ?>
90
  <?php do_settings_sections( __FILE__ ); ?>
91
  <table class="form-table">
92
+ <col width="180px">
93
+ <col width="180px">
94
  <tr valign="top">
95
  <th scope="row"><?php _e('WordPress Target Version', 'wp-downgrade'); ?>:</th>
96
+ <td><input type="text" maxlength="6" pattern="[-+]?[0-9]*[.]?[0-9]?[.]?[0-9]+" placeholder="<?php echo $wp_version; ?>" name="wpdg_specific_version_name" value="<?php echo esc_attr( get_option('wpdg_specific_version_name') ); ?>" /> </td>
97
+ <td><?php _e('Exact version number from', 'wp-downgrade'); ?> <a href="<?php echo $release_link; ?>" target="_blank"><?php _e('WP Releases', 'wp-downgrade'); ?></a>, <?php _e('for example "4.9.8". Leave empty to disable.', 'wp-downgrade'); ?></td>
98
  </tr>
99
 
100
  <tr valign="top">
101
  <th scope="row"><?php _e('Current WP Version', 'wp-downgrade'); ?>:</th>
102
  <td><?php echo $wp_version; ?></td>
103
+ <td></td>
104
  </tr>
105
 
106
  <tr valign="top">
107
  <th scope="row"><?php _e('Language Detected', 'wp-downgrade'); ?>:</th>
108
  <td><?php echo get_locale() ?></td>
109
+ <td></td>
110
+ </tr>
111
+
112
+ <?php if (get_option('wpdg_specific_version_name') AND version_compare($wp_version, get_option('wpdg_specific_version_name') ) <> 0 ){
113
+ if(filter_var(get_option('wpdg_download_url'), FILTER_VALIDATE_URL) AND get_option('wpdg_edit_download_url'))
114
+ $wpdg_download_url = get_option('wpdg_download_url');
115
+ else
116
+ $wpdg_download_url = wpdg_get_url(get_option('wpdg_specific_version_name'));
117
+ ?>
118
+ <tr valign="top">
119
+ <td><input type="checkbox" id="myCheck" onclick="myFunction()" name="wpdg_edit_download_url" <?php if (get_option('wpdg_edit_download_url')){ echo 'checked';} ?>> <?php _e('edit download URL', 'wp-downgrade'); ?> </td>
120
+ <td> <span id="download-url" style="display:<?php if (get_option('wpdg_edit_download_url')){ echo 'inline';} else {echo 'none';} ?>"><input type="url" pattern="https?://.+" name="wpdg_download_url" id="download-url" value="<?php echo esc_attr( $wpdg_download_url ); ?>" /> </span></td>
121
+ <td> <span id="download-url-text" style="display:<?php if (get_option('wpdg_edit_download_url')){ echo 'inline';} else {echo 'none';} ?>"><?php _e('Usually you <strong>do not</strong> need to change this. But you can, if necessary. Must be a valid URL to a WordPress ZIP. <strong>Be careful!</strong> The content will not be verified! Wordpress will use what ever you give here, even if it does not contain release ', 'wp-downgrade'); echo get_option('wpdg_specific_version_name').' or for example a wrong language. After your special update is done, you need to check for success yourself. And after that, you should turn off this option.'; ?></span></td>
122
  </tr>
123
+ <?php } ?>
124
+
125
  </table>
126
 
127
 
130
 
131
  </form>
132
 
133
+ <?php if (get_option('wpdg_specific_version_name')) {
134
+ if (version_compare($wp_version, get_option('wpdg_specific_version_name') ) == 0 ) { ?>
135
+ <div style="border: 2px solid green; padding: 5px;">
136
+ <?php _e('<strong>All fine!</strong> You are currently on your desired release. And it will stay like that. <br>If you ever want to <strong>reinstall</strong> ', 'wp-downgrade'); ?> <?php echo get_option('wpdg_specific_version_name').', you have to switch to another version and come back. If you want to return to the regular update channel, you need to empty the version number above and go to '; ?> <a href="<?php echo get_admin_url( null, '/update-core.php' ) ;?>"><?php _e('Update Core', 'wp-downgrade'); ?></a>.
137
+ </div>
138
+ <?php } else { ?>
139
+ <div style="border: 2px solid orange; padding: 5px;">
140
+ <p><strong><?php _e('In order to perform the upgrade/downgrade to WP', 'wp-downgrade'); ?> <?php echo get_option('wpdg_specific_version_name'); ?> <?php _e('please go to', 'wp-downgrade'); ?> <a href="<?php echo get_admin_url( null, '/update-core.php' ) ;?>"><?php _e('Update Core', 'wp-downgrade'); ?></a>. </strong></p>
141
+ <p><a href="<?php echo get_admin_url( null, '/update-core.php' ) ;?>" class="button"><?php _e('Up-/Downgrade Core', 'wp-downgrade'); ?></a></p>
142
+ </div>
143
+ <?php } ?>
144
 
145
  <?php if (wpdg_urlcheck(wpdg_get_url(get_option('wpdg_specific_version_name'))) == false){ ?>
146
+ <div style="border: 2px solid red; padding: 5px;">
147
  <span style="color: red;"> <?php _e('Attention! The target version does not seem to exist!', 'wp-downgrade'); ?> </span><br>
148
  <span style="color: red;"> URL: <?php echo wpdg_get_url(get_option('wpdg_specific_version_name')); ?></span><br>
149
+ <span style="color: red;"> <?php _e('The update could fail. Are you sure that the version number is correct? You can also manually edit the download URL if needed.', 'wp-downgrade'); echo " <strong>". get_option('wpdg_specific_version_name'); ?> </strong></span><br>
150
+ </div>
151
  <?php }
152
 
153
  //echo wpdg_get_url(get_option('wpdg_specific_version_name'));
174
 
175
  global $wp_version;
176
  // If current version is target version then stop
177
+
178
  if ( version_compare( $wp_version, $dg_version ) == 0 ) {
179
  return;
180
  } //https://downloads.wordpress.org/release/de_DE/wordpress-4.5.zip
181
+
182
+ $updates->updates[0]->download = wpdg_get_url($dg_version);
183
+ $updates->updates[0]->packages->full = wpdg_get_url($dg_version);
184
  $updates->updates[0]->packages->no_content = '';
185
  $updates->updates[0]->packages->new_bundled = '';
186
  $updates->updates[0]->current = $dg_version;
199
  }
200
 
201
  function wpdg_get_url($version) {
202
+ if(get_option('wpdg_edit_download_url') AND filter_var(get_option('wpdg_download_url'), FILTER_VALIDATE_URL)){
203
+ $url = get_option('wpdg_download_url');
204
+ } else {
205
+ $sprache = get_locale().'/';
206
+ if ($sprache == 'en_US/' OR $sprache == 'en'){
207
+ $sprache = '';
208
+ };
209
+ $url = "https://downloads.wordpress.org/release/".$sprache."wordpress-".$version.".zip";
210
+ }
211
+ return $url;
212
  }
213
 
214
  ?>