Version Description
- Improved code quality
Download this release
Release Info
Developer | Reisetiger |
Plugin | WP Downgrade | Specific Core Version |
Version | 1.2.4 |
Comparing to | |
See all releases |
Code changes from version 1.2.3 to 1.2.4
- readme.txt +4 -1
- wp-downgrade.php +30 -28
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.reisetiger.net/spenden-wp-plugins/
|
|
4 |
Tags: Downgrade, Core, WP-Core, Version, Rollback, Upgrade, Update, Release, Versionskontrolle
|
5 |
Requires at least: 3.0.1
|
6 |
Tested up to: 5.9
|
7 |
-
Stable tag:
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -73,6 +73,9 @@ A: If there is no button for update/reinstall core on /wp-admin/update-core.php,
|
|
73 |
|
74 |
|
75 |
== Changelog ==
|
|
|
|
|
|
|
76 |
= 1.2.3 =
|
77 |
* security fix (Thanks for reporting!)
|
78 |
* testet up to WordPress 5.9
|
4 |
Tags: Downgrade, Core, WP-Core, Version, Rollback, Upgrade, Update, Release, Versionskontrolle
|
5 |
Requires at least: 3.0.1
|
6 |
Tested up to: 5.9
|
7 |
+
Stable tag: 1.2.4
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
73 |
|
74 |
|
75 |
== Changelog ==
|
76 |
+
= 1.2.4 =
|
77 |
+
* Improved code quality
|
78 |
+
|
79 |
= 1.2.3 =
|
80 |
* security fix (Thanks for reporting!)
|
81 |
* testet up to WordPress 5.9
|
wp-downgrade.php
CHANGED
@@ -3,7 +3,7 @@
|
|
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.
|
7 |
Author: Reisetiger
|
8 |
Author URI: https://www.reisetiger.net
|
9 |
License: GPL2
|
@@ -15,33 +15,33 @@ Domain Path: /languages
|
|
15 |
if ( ! defined( 'ABSPATH' ) )
|
16 |
exit;
|
17 |
|
18 |
-
function
|
19 |
$loaded = load_plugin_textdomain( 'wp-downgrade', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
|
20 |
//if ($loaded){ echo 'Success: Textdomain wp-downgrade loaded!'; }else{ echo 'Failed to load textdomain wp-downgrade!'; }
|
21 |
}
|
22 |
-
add_action('plugins_loaded', '
|
23 |
|
24 |
// create custom plugin settings menu
|
25 |
-
add_action('admin_menu', '
|
26 |
|
27 |
-
function
|
28 |
|
29 |
//create new sub-menu
|
30 |
-
add_submenu_page('options-general.php', 'WP Downgrade', 'WP Downgrade', 'administrator', '
|
31 |
|
32 |
//call register settings function
|
33 |
-
add_action( 'admin_init', '
|
34 |
}
|
35 |
|
36 |
-
function
|
37 |
//register our settings
|
38 |
-
register_setting( 'wpdg-settings-group', 'wpdg_specific_version_name', array('sanitize_callback' => '
|
39 |
register_setting( 'wpdg-settings-group', 'wpdg_download_url', array('sanitize_callback' => 'sanitize_url') );
|
40 |
register_setting( 'wpdg-settings-group', 'wpdg_edit_download_url', array('sanitize_callback' => 'sanitize_url') );
|
41 |
// register_setting( 'wpdg-settings-group', 'some_other_option' );
|
42 |
}
|
43 |
|
44 |
-
function
|
45 |
// Sicherstellen, dass eine plausible Versionsnummer eingegeben wurde (andernfalls Sicherheitsrisiko). Ein 'sanitize_text_field' oder sowas w�rde ggf. auch reichen, aber so pr�fen wir genauer, dass der Input wirklich zum pattern passt.
|
46 |
{
|
47 |
if (!preg_match("/^[-+]?[0-9]*[.]?[0-9]?[.]?[0-9]+$/", $userstring) AND $userstring !== ''){
|
@@ -52,13 +52,15 @@ function wp_downgrade_sanitize_version($userstring)
|
|
52 |
}
|
53 |
}
|
54 |
|
55 |
-
add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), '
|
56 |
-
function
|
57 |
-
$links[] = '<a href="'. esc_url( get_admin_url(null, 'options-general.php?page=
|
58 |
return $links;
|
59 |
}
|
60 |
|
61 |
-
function
|
|
|
|
|
62 |
?>
|
63 |
<div class="wrap">
|
64 |
<h2>WP Downgrade Options</h2>
|
@@ -70,7 +72,7 @@ function wp_downgrade_settings_page() {
|
|
70 |
<h3><?php _e('Which WordPress version would you like to up-/downgrade to?', 'wp-downgrade'); ?></h3>
|
71 |
|
72 |
<script>
|
73 |
-
function
|
74 |
var checkBox = document.getElementById("myCheck");
|
75 |
var text = document.getElementById("download-url-text");
|
76 |
var field = document.getElementById("download-url");
|
@@ -91,7 +93,7 @@ function myFunction() {
|
|
91 |
if(get_locale() == 'de_DE')
|
92 |
$release_link = 'https://de.wordpress.org/releases/';
|
93 |
else if(get_locale() == 'es_ES')
|
94 |
-
$release_link = 'https://
|
95 |
else
|
96 |
$release_link = 'https://wordpress.org/download/releases/';
|
97 |
?>
|
@@ -104,18 +106,18 @@ else
|
|
104 |
<col width="180px">
|
105 |
<tr valign="top">
|
106 |
<th scope="row"><?php _e('WordPress Target Version', 'wp-downgrade'); ?>:</th>
|
107 |
-
<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>
|
108 |
-
<td><?php
|
109 |
</tr>
|
110 |
|
111 |
<tr valign="top">
|
112 |
-
<th scope="row"><?php
|
113 |
<td><?php echo $wp_version; ?></td>
|
114 |
<td></td>
|
115 |
</tr>
|
116 |
|
117 |
<tr valign="top">
|
118 |
-
<th scope="row"><?php
|
119 |
<td><?php echo get_locale() ?></td>
|
120 |
<td></td>
|
121 |
</tr>
|
@@ -127,9 +129,9 @@ else
|
|
127 |
$wpdg_download_url = wpdg_get_url(get_option('wpdg_specific_version_name'));
|
128 |
?>
|
129 |
<tr valign="top">
|
130 |
-
<td><input type="checkbox" id="myCheck" onclick="
|
131 |
<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>
|
132 |
-
<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>
|
133 |
</tr>
|
134 |
<?php } ?>
|
135 |
|
@@ -144,20 +146,20 @@ else
|
|
144 |
<?php if (get_option('wpdg_specific_version_name')) {
|
145 |
if (version_compare($wp_version, get_option('wpdg_specific_version_name') ) == 0 ) { ?>
|
146 |
<div style="border: 2px solid green; padding: 5px;">
|
147 |
-
<?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
|
148 |
</div>
|
149 |
<?php } else { ?>
|
150 |
<div style="border: 2px solid orange; padding: 5px;">
|
151 |
-
<p><strong><?php
|
152 |
-
<p><a href="<?php echo get_admin_url( null, '/update-core.php' ) ;?>" class="button"><?php
|
153 |
</div>
|
154 |
<?php } ?>
|
155 |
|
156 |
<?php if (wpdg_urlcheck(wpdg_get_url(get_option('wpdg_specific_version_name'))) == false){ ?>
|
157 |
<div style="border: 2px solid red; padding: 5px;">
|
158 |
-
<span style="color: red;"> <?php
|
159 |
-
<span style="color: red;"> URL: <?php echo wpdg_get_url(get_option('wpdg_specific_version_name')); ?></span><br>
|
160 |
-
<span style="color: red;"> <?php
|
161 |
</div>
|
162 |
<?php }
|
163 |
|
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.4
|
7 |
Author: Reisetiger
|
8 |
Author URI: https://www.reisetiger.net
|
9 |
License: GPL2
|
15 |
if ( ! defined( 'ABSPATH' ) )
|
16 |
exit;
|
17 |
|
18 |
+
function wpdowngrade_load_plugin_textdomain() {
|
19 |
$loaded = load_plugin_textdomain( 'wp-downgrade', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
|
20 |
//if ($loaded){ echo 'Success: Textdomain wp-downgrade loaded!'; }else{ echo 'Failed to load textdomain wp-downgrade!'; }
|
21 |
}
|
22 |
+
add_action('plugins_loaded', 'wpdowngrade_load_plugin_textdomain');
|
23 |
|
24 |
// create custom plugin settings menu
|
25 |
+
add_action('admin_menu', 'wpdowngrade_create_menu');
|
26 |
|
27 |
+
function wpdowngrade_create_menu() {
|
28 |
|
29 |
//create new sub-menu
|
30 |
+
add_submenu_page('options-general.php', 'WP Downgrade', 'WP Downgrade', 'administrator', 'wpdowngrade', 'wpdowngrade_settings_page');
|
31 |
|
32 |
//call register settings function
|
33 |
+
add_action( 'admin_init', 'register_wpdowngrade_settings' );
|
34 |
}
|
35 |
|
36 |
+
function register_wpdowngrade_settings() {
|
37 |
//register our settings
|
38 |
+
register_setting( 'wpdg-settings-group', 'wpdg_specific_version_name', array('sanitize_callback' => 'wpdowngrade_sanitize_version') );
|
39 |
register_setting( 'wpdg-settings-group', 'wpdg_download_url', array('sanitize_callback' => 'sanitize_url') );
|
40 |
register_setting( 'wpdg-settings-group', 'wpdg_edit_download_url', array('sanitize_callback' => 'sanitize_url') );
|
41 |
// register_setting( 'wpdg-settings-group', 'some_other_option' );
|
42 |
}
|
43 |
|
44 |
+
function wpdowngrade_sanitize_version($userstring)
|
45 |
// Sicherstellen, dass eine plausible Versionsnummer eingegeben wurde (andernfalls Sicherheitsrisiko). Ein 'sanitize_text_field' oder sowas w�rde ggf. auch reichen, aber so pr�fen wir genauer, dass der Input wirklich zum pattern passt.
|
46 |
{
|
47 |
if (!preg_match("/^[-+]?[0-9]*[.]?[0-9]?[.]?[0-9]+$/", $userstring) AND $userstring !== ''){
|
52 |
}
|
53 |
}
|
54 |
|
55 |
+
add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'wpdowngrade_action_links' );
|
56 |
+
function wpdowngrade_action_links( $links ) {
|
57 |
+
$links[] = '<a href="'. esc_url( get_admin_url(null, 'options-general.php?page=wpdowngrade') ) .'">Settings</a>';
|
58 |
return $links;
|
59 |
}
|
60 |
|
61 |
+
function wpdowngrade_settings_page() {
|
62 |
+
$allowed_tags = array( 'br' => array(), 'strong' => array() );
|
63 |
+
|
64 |
?>
|
65 |
<div class="wrap">
|
66 |
<h2>WP Downgrade Options</h2>
|
72 |
<h3><?php _e('Which WordPress version would you like to up-/downgrade to?', 'wp-downgrade'); ?></h3>
|
73 |
|
74 |
<script>
|
75 |
+
function wpdgshowhide() {
|
76 |
var checkBox = document.getElementById("myCheck");
|
77 |
var text = document.getElementById("download-url-text");
|
78 |
var field = document.getElementById("download-url");
|
93 |
if(get_locale() == 'de_DE')
|
94 |
$release_link = 'https://de.wordpress.org/releases/';
|
95 |
else if(get_locale() == 'es_ES')
|
96 |
+
$release_link = 'https://es.wordpress.org/releases/';
|
97 |
else
|
98 |
$release_link = 'https://wordpress.org/download/releases/';
|
99 |
?>
|
106 |
<col width="180px">
|
107 |
<tr valign="top">
|
108 |
<th scope="row"><?php _e('WordPress Target Version', 'wp-downgrade'); ?>:</th>
|
109 |
+
<td><input type="text" maxlength="6" pattern="[-+]?[0-9]*[.]?[0-9]?[.]?[0-9]+" placeholder="<?php echo esc_attr($wp_version); ?>" name="wpdg_specific_version_name" value="<?php echo esc_attr( get_option('wpdg_specific_version_name') ); ?>" /> </td>
|
110 |
+
<td><?php esc_html_e('Exact version number from', 'wp-downgrade'); ?> <a href="<?php echo esc_url($release_link); ?>" target="_blank"><?php esc_html_e('WP Releases', 'wp-downgrade'); ?></a>, <?php esc_html_e('for example "4.9.8". Leave empty to disable.', 'wp-downgrade'); ?></td>
|
111 |
</tr>
|
112 |
|
113 |
<tr valign="top">
|
114 |
+
<th scope="row"><?php esc_html_e('Current WP Version', 'wp-downgrade'); ?>:</th>
|
115 |
<td><?php echo $wp_version; ?></td>
|
116 |
<td></td>
|
117 |
</tr>
|
118 |
|
119 |
<tr valign="top">
|
120 |
+
<th scope="row"><?php esc_html_e('Language Detected', 'wp-downgrade'); ?>:</th>
|
121 |
<td><?php echo get_locale() ?></td>
|
122 |
<td></td>
|
123 |
</tr>
|
129 |
$wpdg_download_url = wpdg_get_url(get_option('wpdg_specific_version_name'));
|
130 |
?>
|
131 |
<tr valign="top">
|
132 |
+
<td><input type="checkbox" id="myCheck" onclick="wpdgshowhide()" name="wpdg_edit_download_url" <?php if (get_option('wpdg_edit_download_url')){ echo 'checked';} ?>> <?php esc_html_e('edit download URL', 'wp-downgrade'); ?> </td>
|
133 |
<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>
|
134 |
+
<td> <span id="download-url-text" style="display:<?php if (get_option('wpdg_edit_download_url')){ echo 'inline';} else {echo 'none';} ?>"><?php wp_kses(_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'), $allowed_tags); echo esc_html(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>
|
135 |
</tr>
|
136 |
<?php } ?>
|
137 |
|
146 |
<?php if (get_option('wpdg_specific_version_name')) {
|
147 |
if (version_compare($wp_version, get_option('wpdg_specific_version_name') ) == 0 ) { ?>
|
148 |
<div style="border: 2px solid green; padding: 5px;">
|
149 |
+
<?php wp_kses(_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'), $allowed_tags); ?> <?php echo esc_html(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 esc_url(get_admin_url( null, '/update-core.php' )) ;?>"><?php esc_html_e('Update Core', 'wp-downgrade'); ?></a>.
|
150 |
</div>
|
151 |
<?php } else { ?>
|
152 |
<div style="border: 2px solid orange; padding: 5px;">
|
153 |
+
<p><strong><?php esc_html_e('In order to perform the upgrade/downgrade to WP', 'wp-downgrade'); ?> <?php echo esc_html(get_option('wpdg_specific_version_name')); ?> <?php esc_html_e('please go to', 'wp-downgrade'); ?> <a href="<?php echo esc_url(get_admin_url( null, '/update-core.php' )) ;?>"><?php esc_html_e('Update Core', 'wp-downgrade'); ?></a>. </strong></p>
|
154 |
+
<p><a href="<?php echo esc_url(get_admin_url( null, '/update-core.php' )) ;?>" class="button"><?php esc_html_e('Up-/Downgrade Core', 'wp-downgrade'); ?></a></p>
|
155 |
</div>
|
156 |
<?php } ?>
|
157 |
|
158 |
<?php if (wpdg_urlcheck(wpdg_get_url(get_option('wpdg_specific_version_name'))) == false){ ?>
|
159 |
<div style="border: 2px solid red; padding: 5px;">
|
160 |
+
<span style="color: red;"> <?php esc_html_e('Attention! The target version does not seem to exist!', 'wp-downgrade'); ?> </span><br>
|
161 |
+
<span style="color: red;"> URL: <?php echo esc_url(wpdg_get_url(get_option('wpdg_specific_version_name'))); ?></span><br>
|
162 |
+
<span style="color: red;"> <?php esc_html_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>". esc_html(get_option('wpdg_specific_version_name')); ?> </strong></span><br>
|
163 |
</div>
|
164 |
<?php }
|
165 |
|