← All changes
|
vendor/codeinwp/themeisle-sdk/src/Modules/Rollback.php
+16
-8
3.1.3
→
3.5.1
View file →
| @@ -119,9 +119,11 @@ | ||
| 119 | 119 | $url = $this->get_versions_api_url(); |
| 120 | 120 | if ( empty( $url ) ) { |
| 121 | 121 | return []; |
| 122 | 122 | } |
| 123 | - $response = wp_remote_get( $url ); | |
| 123 | + $response = function_exists( 'wp_remote_get_wp_remote_get' ) | |
| 124 | + ? wp_remote_get_wp_remote_get( $url ) | |
| 125 | + : wp_remote_get( $url ); //phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.wp_remote_get_wp_remote_get | |
| 124 | 126 | if ( is_wp_error( $response ) ) { |
| 125 | 127 | return array(); |
| 126 | 128 | } |
| 127 | 129 | $response = wp_remote_retrieve_body( $response ); |
| @@ -166,9 +168,9 @@ | ||
| 166 | 168 | if ( $this->product->requires_license() && strlen( $license ) < 10 ) { |
| 167 | 169 | return ''; |
| 168 | 170 | } |
| 169 | 171 | |
| 170 | - return sprintf( '%s?edd_action=get_versions&name=%s&url=%s&license=%s', $this->product->get_store_url(), urlencode( $this->product->get_name() ), urlencode( get_site_url() ), $license ); | |
| 172 | + return sprintf( '%slicense/versions/%s/%s/%s/%s', Product::API_URL, rawurlencode( $this->product->get_name() ), $license, urlencode( get_site_url() ), $this->product->get_version() ); | |
| 171 | 173 | } |
| 172 | 174 | |
| 173 | 175 | /** |
| 174 | 176 | * Show the rollback links in the plugin page. |
| @@ -190,9 +192,9 @@ | ||
| 190 | 192 | /** |
| 191 | 193 | * Start the rollback operation. |
| 192 | 194 | */ |
| 193 | 195 | public function start_rollback() { |
| 194 | - if ( ! isset( $_GET['_wpnonce'] ) || ! wp_verify_nonce( $_GET['_wpnonce'], $this->product->get_key() . '_rollback' ) ) { | |
| 196 | + if ( ! isset( $_GET['_wpnonce'] ) || ! wp_verify_nonce( $_GET['_wpnonce'], $this->product->get_key() . '_rollback' ) ) { //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 195 | 197 | wp_nonce_ays( '' ); |
| 196 | 198 | } |
| 197 | 199 | |
| 198 | 200 | if ( $this->product->is_plugin() ) { |
| @@ -227,11 +229,14 @@ | ||
| 227 | 229 | set_site_transient( 'update_plugins', $plugin_transient ); |
| 228 | 230 | |
| 229 | 231 | $transient = get_transient( $this->product->get_key() . '_warning_rollback' ); |
| 230 | 232 | |
| 233 | + // Style fix for the api link that gets outside the content. | |
| 234 | + echo '<style>body#error-page{word-break:break-word;}</style>'; | |
| 235 | + | |
| 231 | 236 | if ( false === $transient ) { |
| 232 | 237 | set_transient( $this->product->get_key() . '_warning_rollback', 'in progress', 30 ); |
| 233 | - require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); | |
| 238 | + require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; | |
| 234 | 239 | $title = sprintf( apply_filters( $this->product->get_key() . '_rollback_message', 'Rolling back %s to v%s' ), $this->product->get_name(), $version ); |
| 235 | 240 | $plugin = $plugin_folder . '/' . $plugin_file; |
| 236 | 241 | $nonce = 'upgrade-plugin_' . $plugin; |
| 237 | 242 | $url = 'update.php?action=upgrade-plugin&plugin=' . urlencode( $plugin ); |
| @@ -240,9 +245,9 @@ | ||
| 240 | 245 | $upgrader->upgrade( $plugin ); |
| 241 | 246 | delete_transient( $this->product->get_key() . '_warning_rollback' ); |
| 242 | 247 | wp_die( |
| 243 | 248 | '', |
| 244 | - $title, | |
| 249 | + esc_attr( $title ), | |
| 245 | 250 | array( |
| 246 | 251 | 'response' => 200, |
| 247 | 252 | ) |
| 248 | 253 | ); |
| @@ -267,11 +272,14 @@ | ||
| 267 | 272 | set_site_transient( 'update_themes', $transient ); |
| 268 | 273 | |
| 269 | 274 | $transient = get_transient( $this->product->get_key() . '_warning_rollback' ); |
| 270 | 275 | |
| 276 | + // Style fix for the api link that gets outside the content. | |
| 277 | + echo '<style>body#error-page{word-break:break-word;}</style>'; | |
| 278 | + | |
| 271 | 279 | if ( false === $transient ) { |
| 272 | 280 | set_transient( $this->product->get_key() . '_warning_rollback', 'in progress', 30 ); |
| 273 | - require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); | |
| 281 | + require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; | |
| 274 | 282 | $title = sprintf( apply_filters( $this->product->get_key() . '_rollback_message', 'Rolling back %s to v%s' ), $this->product->get_name(), $version ); |
| 275 | 283 | $theme = $folder . '/style.css'; |
| 276 | 284 | $nonce = 'upgrade-theme_' . $theme; |
| 277 | 285 | $url = 'update.php?action=upgrade-theme&theme=' . urlencode( $theme ); |
| @@ -280,9 +288,9 @@ | ||
| 280 | 288 | $upgrader->upgrade( $theme ); |
| 281 | 289 | delete_transient( $this->product->get_key() . '_warning_rollback' ); |
| 282 | 290 | wp_die( |
| 283 | 291 | '', |
| 284 | - $title, | |
| 292 | + esc_attr( $title ), | |
| 285 | 293 | array( |
| 286 | 294 | 'response' => 200, |
| 287 | 295 | ) |
| 288 | 296 | ); |
| @@ -334,9 +342,9 @@ | ||
| 334 | 342 | * |
| 335 | 343 | * @return bool Which version is greater? |
| 336 | 344 | */ |
| 337 | 345 | public function sort_rollback_array( $a, $b ) { |
| 338 | - return version_compare( $a['version'], $b['version'], '<' ) > 0; | |
| 346 | + return version_compare( $b['version'], $a['version'] ); | |
| 339 | 347 | } |
| 340 | 348 | |
| 341 | 349 | /** |
| 342 | 350 | * Load module logic. |