| @@ -541,25 +541,68 @@ | ||
| 541 | 541 | $this->_update_details = $this->get_update_details( $new_version ); |
| 542 | 542 | } |
| 543 | 543 | } |
| 544 | 544 | |
| 545 | + // Alias. | |
| 546 | + $basename = $this->_fs->premium_plugin_basename(); | |
| 547 | + | |
| 545 | 548 | if ( is_object( $this->_update_details ) ) { |
| 549 | + if ( isset( $transient_data->no_update ) ) { | |
| 550 | + unset( $transient_data->no_update[ $basename ] ); | |
| 551 | + } | |
| 552 | + | |
| 546 | 553 | if ( ! isset( $transient_data->response ) ) { |
| 547 | 554 | $transient_data->response = array(); |
| 548 | 555 | } |
| 549 | 556 | |
| 550 | 557 | // Add plugin to transient data. |
| 551 | - $transient_data->response[ $this->_fs->premium_plugin_basename() ] = $this->_fs->is_plugin() ? | |
| 558 | + $transient_data->response[ $basename ] = $this->_fs->is_plugin() ? | |
| 552 | 559 | $this->_update_details : |
| 553 | 560 | (array) $this->_update_details; |
| 554 | - } else if ( isset( $transient_data->response ) ) { | |
| 561 | + } else { | |
| 562 | + if ( isset( $transient_data->response ) ) { | |
| 563 | + /** | |
| 564 | + * Ensure that there's no update data for the plugin to prevent upgrading the premium version to the latest free version. | |
| 565 | + * | |
| 566 | + * @author Leo Fajardo (@leorw) | |
| 567 | + * @since 2.3.0 | |
| 568 | + */ | |
| 569 | + unset( $transient_data->response[ $basename ] ); | |
| 570 | + } | |
| 571 | + | |
| 572 | + if ( ! isset( $transient_data->no_update ) ) { | |
| 573 | + $transient_data->no_update = array(); | |
| 574 | + } | |
| 575 | + | |
| 555 | 576 | /** |
| 556 | - * Ensure that there's no update data for the plugin to prevent upgrading the premium version to the latest free version. | |
| 577 | + * Add product to no_update transient data to properly integrate with WP 5.5 auto-updates UI. | |
| 557 | 578 | * |
| 558 | - * @author Leo Fajardo (@leorw) | |
| 559 | - * @since 2.3.0 | |
| 579 | + * @since 2.4.1 | |
| 580 | + * @link https://make.wordpress.org/core/2020/07/30/recommended-usage-of-the-updates-api-to-support-the-auto-updates-ui-for-plugins-and-themes-in-wordpress-5-5/ | |
| 560 | 581 | */ |
| 561 | - unset( $transient_data->response[ $this->_fs->premium_plugin_basename() ] ); | |
| 582 | + $transient_data->no_update[ $basename ] = $this->_fs->is_plugin() ? | |
| 583 | + (object) array( | |
| 584 | + 'id' => $basename, | |
| 585 | + 'slug' => $this->_fs->get_slug(), | |
| 586 | + 'plugin' => $basename, | |
| 587 | + 'new_version' => $this->_fs->get_plugin_version(), | |
| 588 | + 'url' => '', | |
| 589 | + 'package' => '', | |
| 590 | + 'icons' => array(), | |
| 591 | + 'banners' => array(), | |
| 592 | + 'banners_rtl' => array(), | |
| 593 | + 'tested' => '', | |
| 594 | + 'requires_php' => '', | |
| 595 | + 'compatibility' => new stdClass(), | |
| 596 | + ) : | |
| 597 | + array( | |
| 598 | + 'theme' => $basename, | |
| 599 | + 'new_version' => $this->_fs->get_plugin_version(), | |
| 600 | + 'url' => '', | |
| 601 | + 'package' => '', | |
| 602 | + 'requires' => '', | |
| 603 | + 'requires_php' => '', | |
| 604 | + ); | |
| 562 | 605 | } |
| 563 | 606 | |
| 564 | 607 | $slug = $this->_fs->get_slug(); |
| 565 | 608 | |