PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.4.9
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.4.9
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 -26 3.10.13.4.9 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() ) {
@@ -234,9 +232,9 @@
234 232 echo '<style>body#error-page{word-break:break-word;}</style>';
235 233
236 234 if ( false === $transient ) {
237 235 set_transient( $this->product->get_key() . '_warning_rollback', 'in progress', 30 );
238 - require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
236 + require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
239 237 $title = sprintf( apply_filters( $this->product->get_key() . '_rollback_message', 'Rolling back %s to v%s' ), $this->product->get_name(), $version );
240 238 $plugin = $plugin_folder . '/' . $plugin_file;
241 239 $nonce = 'upgrade-plugin_' . $plugin;
242 240 $url = 'update.php?action=upgrade-plugin&plugin=' . urlencode( $plugin );
@@ -245,9 +243,9 @@
245 243 $upgrader->upgrade( $plugin );
246 244 delete_transient( $this->product->get_key() . '_warning_rollback' );
247 245 wp_die(
248 246 '',
249 - esc_attr( $title ),
247 + $title,
250 248 array(
251 249 'response' => 200,
252 250 )
253 251 );
@@ -277,9 +275,9 @@
277 275 echo '<style>body#error-page{word-break:break-word;}</style>';
278 276
279 277 if ( false === $transient ) {
280 278 set_transient( $this->product->get_key() . '_warning_rollback', 'in progress', 30 );
281 - require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
279 + require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
282 280 $title = sprintf( apply_filters( $this->product->get_key() . '_rollback_message', 'Rolling back %s to v%s' ), $this->product->get_name(), $version );
283 281 $theme = $folder . '/style.css';
284 282 $nonce = 'upgrade-theme_' . $theme;
285 283 $url = 'update.php?action=upgrade-theme&theme=' . urlencode( $theme );
@@ -288,9 +286,9 @@
288 286 $upgrader->upgrade( $theme );
289 287 delete_transient( $this->product->get_key() . '_warning_rollback' );
290 288 wp_die(
291 289 '',
292 - esc_attr( $title ),
290 + $title,
293 291 array(
294 292 'response' => 200,
295 293 )
296 294 );
@@ -342,9 +340,9 @@
342 340 *
343 341 * @return bool Which version is greater?
344 342 */
345 343 public function sort_rollback_array( $a, $b ) {
346 - return version_compare( $b['version'], $a['version'] );
344 + return version_compare( $a['version'], $b['version'], '<' ) > 0;
347 345 }
348 346
349 347 /**
350 348 * Load module logic.
@@ -374,27 +372,11 @@
374 372 );
375 373 }
376 374
377 375 /**
378 - * Fires after the option has been updated.
379 - *
380 - * @param mixed $old_value The old option value.
381 - * @param mixed $value The new option value.
382 - * @param string $option Option name.
383 - */
384 - public function update_active_plugins_action( $old_value, $value, $option ) {
385 - delete_site_transient( 'update_plugins' );
386 - wp_cache_delete( 'plugins', 'plugins' );
387 - }
388 -
389 - /**
390 376 * 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.
391 377 */
392 378 public function add_hooks() {
393 379 add_action( 'admin_post_' . $this->product->get_key() . '_rollback', array( $this, 'start_rollback' ) );
394 380 add_action( 'admin_footer', array( $this, 'add_footer' ) );
395 -
396 - // This hook will be invoked after the plugin activation.
397 - // We use this to force an update of the cache so that Update is present immediate after a rollback.
398 - add_action( 'update_option_active_plugins', array( $this, 'update_active_plugins_action' ), 10, 3 );
399 381 }
400 382 }