PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.4.2
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.4.2
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 +9 -33 3.10.03.4.2 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 );
@@ -168,9 +166,9 @@
168 166 if ( $this->product->requires_license() && strlen( $license ) < 10 ) {
169 167 return '';
170 168 }
171 169
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() );
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 );
173 171 }
174 172
175 173 /**
176 174 * Show the rollback links in the plugin page.
@@ -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,14 +267,11 @@
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 );
@@ -288,9 +280,9 @@
288 280 $upgrader->upgrade( $theme );
289 281 delete_transient( $this->product->get_key() . '_warning_rollback' );
290 282 wp_die(
291 283 '',
292 - esc_attr( $title ),
284 + $title,
293 285 array(
294 286 'response' => 200,
295 287 )
296 288 );
@@ -342,9 +334,9 @@
342 334 *
343 335 * @return bool Which version is greater?
344 336 */
345 337 public function sort_rollback_array( $a, $b ) {
346 - return version_compare( $b['version'], $a['version'] );
338 + return version_compare( $a['version'], $b['version'], '<' ) > 0;
347 339 }
348 340
349 341 /**
350 342 * Load module logic.
@@ -374,27 +366,11 @@
374 366 );
375 367 }
376 368
377 369 /**
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 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.
391 371 */
392 372 public function add_hooks() {
393 373 add_action( 'admin_post_' . $this->product->get_key() . '_rollback', array( $this, 'start_rollback' ) );
394 374 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 375 }
400 376 }