PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.4.7
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.4.7
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 All 149 releases
← All changes | vendor/codeinwp/themeisle-sdk/src/Modules/Rollback.php +8 -47 3.10.123.4.7 View file →
@@ -97,9 +97,9 @@
97 97 * @return array Array of versions.
98 98 */
99 99 private function get_api_versions() {
100 100
101 - $cache_key = $this->product->get_cache_key();
101 + $cache_key = $this->product->get_key() . '_' . preg_replace( '/[^0-9a-zA-Z ]/m', '', $this->product->get_version() ) . 'versions';
102 102 $cache_versions = get_transient( $cache_key );
103 103 if ( false === $cache_versions ) {
104 104 $versions = $this->get_remote_versions();
105 105 set_transient( $cache_key, $versions, 5 * DAY_IN_SECONDS );
@@ -119,11 +119,9 @@
119 119 $url = $this->get_versions_api_url();
120 120 if ( empty( $url ) ) {
121 121 return [];
122 122 }
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
123 + $response = wp_remote_get( $url );
126 124 if ( is_wp_error( $response ) ) {
127 125 return array();
128 126 }
129 127 $response = wp_remote_retrieve_body( $response );
@@ -192,9 +190,9 @@
192 190 /**
193 191 * Start the rollback operation.
194 192 */
195 193 public function start_rollback() {
196 - if ( ! isset( $_GET['_wpnonce'] ) || ! wp_verify_nonce( $_GET['_wpnonce'], $this->product->get_key() . '_rollback' ) ) { //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
194 + if ( ! isset( $_GET['_wpnonce'] ) || ! wp_verify_nonce( $_GET['_wpnonce'], $this->product->get_key() . '_rollback' ) ) {
197 195 wp_nonce_ays( '' );
198 196 }
199 197
200 198 if ( $this->product->is_plugin() ) {
@@ -229,14 +227,11 @@
229 227 set_site_transient( 'update_plugins', $plugin_transient );
230 228
231 229 $transient = get_transient( $this->product->get_key() . '_warning_rollback' );
232 230
233 - // Style fix for the api link that gets outside the content.
234 - echo '<style>body#error-page{word-break:break-word;}</style>';
235 -
236 231 if ( false === $transient ) {
237 232 set_transient( $this->product->get_key() . '_warning_rollback', 'in progress', 30 );
238 - require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
233 + require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
239 234 $title = sprintf( apply_filters( $this->product->get_key() . '_rollback_message', 'Rolling back %s to v%s' ), $this->product->get_name(), $version );
240 235 $plugin = $plugin_folder . '/' . $plugin_file;
241 236 $nonce = 'upgrade-plugin_' . $plugin;
242 237 $url = 'update.php?action=upgrade-plugin&plugin=' . urlencode( $plugin );
@@ -245,9 +240,9 @@
245 240 $upgrader->upgrade( $plugin );
246 241 delete_transient( $this->product->get_key() . '_warning_rollback' );
247 242 wp_die(
248 243 '',
249 - esc_attr( $title ),
244 + $title,
250 245 array(
251 246 'response' => 200,
252 247 )
253 248 );
@@ -272,40 +267,22 @@
272 267 set_site_transient( 'update_themes', $transient );
273 268
274 269 $transient = get_transient( $this->product->get_key() . '_warning_rollback' );
275 270
276 - // Style fix for the api link that gets outside the content.
277 - echo '<style>body#error-page{word-break:break-word;}</style>';
278 -
279 271 if ( false === $transient ) {
280 272 set_transient( $this->product->get_key() . '_warning_rollback', 'in progress', 30 );
281 - require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
273 + require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
282 274 $title = sprintf( apply_filters( $this->product->get_key() . '_rollback_message', 'Rolling back %s to v%s' ), $this->product->get_name(), $version );
283 275 $theme = $folder . '/style.css';
284 276 $nonce = 'upgrade-theme_' . $theme;
285 277 $url = 'update.php?action=upgrade-theme&theme=' . urlencode( $theme );
286 278
287 - /**
288 - * The rollback will attach a temporary theme for the rollback to the transient.
289 - * However, when executing the upgrade for the attached theme we need to change the slug to the original theme slug.
290 - * This is because it will use the slug to create a temp folder for the theme used during the upgrade.
291 - */
292 - add_filter(
293 - 'upgrader_package_options',
294 - function( $options ) use ( $folder, $theme ) {
295 - if ( isset( $options['hook_extra']['theme'] ) && $options['hook_extra']['theme'] === $theme && isset( $options['hook_extra']['temp_backup']['slug'] ) ) {
296 - $options['hook_extra']['temp_backup']['slug'] = $folder;
297 - }
298 - return $options;
299 - }
300 - );
301 -
302 279 $upgrader = new \Theme_Upgrader( new \Theme_Upgrader_Skin( compact( 'title', 'nonce', 'url', 'theme' ) ) );
303 280 $upgrader->upgrade( $theme );
304 281 delete_transient( $this->product->get_key() . '_warning_rollback' );
305 282 wp_die(
306 283 '',
307 - esc_attr( $title ),
284 + $title,
308 285 array(
309 286 'response' => 200,
310 287 )
311 288 );
@@ -357,9 +334,9 @@
357 334 *
358 335 * @return bool Which version is greater?
359 336 */
360 337 public function sort_rollback_array( $a, $b ) {
361 - return version_compare( $b['version'], $a['version'] );
338 + return version_compare( $a['version'], $b['version'], '<' ) > 0;
362 339 }
363 340
364 341 /**
365 342 * Load module logic.
@@ -389,27 +366,11 @@
389 366 );
390 367 }
391 368
392 369 /**
393 - * Fires after the option has been updated.
394 - *
395 - * @param mixed $old_value The old option value.
396 - * @param mixed $value The new option value.
397 - * @param string $option Option name.
398 - */
399 - public function update_active_plugins_action( $old_value, $value, $option ) {
400 - delete_site_transient( 'update_plugins' );
401 - wp_cache_delete( 'plugins', 'plugins' );
402 - }
403 -
404 - /**
405 370 * Set the rollback hook. Strangely, this does not work if placed in the ThemeIsle_SDK_Rollback class, so it is being called from there instead.
406 371 */
407 372 public function add_hooks() {
408 373 add_action( 'admin_post_' . $this->product->get_key() . '_rollback', array( $this, 'start_rollback' ) );
409 374 add_action( 'admin_footer', array( $this, 'add_footer' ) );
410 -
411 - // This hook will be invoked after the plugin activation.
412 - // We use this to force an update of the cache so that Update is present immediate after a rollback.
413 - add_action( 'update_option_active_plugins', array( $this, 'update_active_plugins_action' ), 10, 3 );
414 375 }
415 376 }