| @@ -9,12 +9,12 @@ | ||
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * Allows plugins to use their own update API. |
| 13 | - * Modified version with 'polylang' text domain and comments for translators. | |
| 13 | + * Modified version with 'polylang' text domain and comments for translators | |
| 14 | 14 | * |
| 15 | 15 | * @author Easy Digital Downloads |
| 16 | - * @version 1.8.0 | |
| 16 | + * @version 1.7.1 | |
| 17 | 17 | */ |
| 18 | 18 | class PLL_Plugin_Updater { |
| 19 | 19 | |
| 20 | 20 | private $api_url = ''; |
| @@ -111,52 +111,49 @@ | ||
| 111 | 111 | if ( ! empty( $_transient_data->response ) && ! empty( $_transient_data->response[ $this->name ] ) && false === $this->wp_override ) { |
| 112 | 112 | return $_transient_data; |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - $current = $this->get_repo_api_data(); | |
| 116 | - if ( false !== $current && is_object( $current ) && isset( $current->new_version ) ) { | |
| 117 | - if ( version_compare( $this->version, $current->new_version, '<' ) ) { | |
| 118 | - $_transient_data->response[ $this->name ] = $current; | |
| 119 | - } else { | |
| 120 | - // Populating the no_update information is required to support auto-updates in WordPress 5.5. | |
| 121 | - $_transient_data->no_update[ $this->name ] = $current; | |
| 122 | - } | |
| 115 | + $version_info = $this->get_cached_version_info(); | |
| 116 | + | |
| 117 | + if ( false === $version_info ) { | |
| 118 | + $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) ); | |
| 119 | + | |
| 120 | + $this->set_version_info_cache( $version_info ); | |
| 121 | + | |
| 123 | 122 | } |
| 124 | - $_transient_data->last_checked = time(); | |
| 125 | - $_transient_data->checked[ $this->name ] = $this->version; | |
| 126 | 123 | |
| 127 | - return $_transient_data; | |
| 128 | - } | |
| 124 | + if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) { | |
| 129 | 125 | |
| 130 | - /** | |
| 131 | - * Get repo API data from store. | |
| 132 | - * Save to cache. | |
| 133 | - * | |
| 134 | - * @return \stdClass | |
| 135 | - */ | |
| 136 | - public function get_repo_api_data() { | |
| 137 | - $version_info = $this->get_cached_version_info(); | |
| 126 | + $no_update = false; | |
| 127 | + if ( version_compare( $this->version, $version_info->new_version, '<' ) ) { | |
| 138 | 128 | |
| 139 | - if ( false === $version_info ) { | |
| 140 | - $version_info = $this->api_request( | |
| 141 | - 'plugin_latest_version', | |
| 142 | - array( | |
| 143 | - 'slug' => $this->slug, | |
| 144 | - 'beta' => $this->beta, | |
| 145 | - ) | |
| 146 | - ); | |
| 147 | - if ( ! $version_info ) { | |
| 148 | - return false; | |
| 129 | + $_transient_data->response[ $this->name ] = $version_info; | |
| 130 | + | |
| 131 | + // Make sure the plugin property is set to the plugin's name/location. See issue 1463 on Software Licensing's GitHub repo. | |
| 132 | + $_transient_data->response[ $this->name ]->plugin = $this->name; | |
| 133 | + | |
| 134 | + } else { | |
| 135 | + $no_update = new stdClass(); | |
| 136 | + $no_update->id = ''; | |
| 137 | + $no_update->slug = $this->slug; | |
| 138 | + $no_update->plugin = $this->name; | |
| 139 | + $no_update->new_version = $version_info->new_version; | |
| 140 | + $no_update->url = $version_info->homepage; | |
| 141 | + $no_update->package = isset( $version_info->package ) ? $version_info->package : ''; #modified# | |
| 142 | + $no_update->icons = $version_info->icons; | |
| 143 | + $no_update->banners = $version_info->banners; | |
| 144 | + $no_update->banners_rtl = array(); | |
| 149 | 145 | } |
| 150 | 146 | |
| 151 | - // This is required for your plugin to support auto-updates in WordPress 5.5. | |
| 152 | - $version_info->plugin = $this->name; | |
| 153 | - $version_info->id = $this->name; | |
| 147 | + $_transient_data->last_checked = time(); | |
| 148 | + $_transient_data->checked[ $this->name ] = $this->version; | |
| 154 | 149 | |
| 155 | - $this->set_version_info_cache( $version_info ); | |
| 150 | + if ( $no_update ) { | |
| 151 | + $_transient_data->no_update[ $this->name ] = $no_update; | |
| 152 | + } | |
| 156 | 153 | } |
| 157 | 154 | |
| 158 | - return $version_info; | |
| 155 | + return $_transient_data; | |
| 159 | 156 | } |
| 160 | 157 | |
| 161 | 158 | /** |
| 162 | 159 | * show update nofication row -- needed for multisite subsites, because WP won't tell you otherwise! |
| @@ -190,9 +187,9 @@ | ||
| 190 | 187 | $update_cache = is_object( $update_cache ) ? $update_cache : new stdClass(); |
| 191 | 188 | |
| 192 | 189 | if ( empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) { |
| 193 | 190 | |
| 194 | - $version_info = $this->get_repo_api_data(); | |
| 191 | + $version_info = $this->get_cached_version_info(); | |
| 195 | 192 | |
| 196 | 193 | if ( false === $version_info ) { |
| 197 | 194 | $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) ); |
| 198 | 195 | |
| @@ -219,16 +216,31 @@ | ||
| 219 | 216 | if ( ! is_object( $version_info ) ) { |
| 220 | 217 | return; |
| 221 | 218 | } |
| 222 | 219 | |
| 220 | + $no_update = false; | |
| 223 | 221 | if ( version_compare( $this->version, $version_info->new_version, '<' ) ) { |
| 222 | + | |
| 224 | 223 | $update_cache->response[ $this->name ] = $version_info; |
| 224 | + | |
| 225 | 225 | } else { |
| 226 | - $update_cache->no_update[ $this->name ] = $version_info; | |
| 226 | + $no_update = new stdClass(); | |
| 227 | + $no_update->id = ''; | |
| 228 | + $no_update->slug = $this->slug; | |
| 229 | + $no_update->plugin = $this->name; | |
| 230 | + $no_update->new_version = $version_info->new_version; | |
| 231 | + $no_update->url = $version_info->homepage; | |
| 232 | + $no_update->package = isset( $version_info->package ) ? $version_info->package : ''; #modified# | |
| 233 | + $no_update->icons = $version_info->icons; | |
| 234 | + $no_update->banners = $version_info->banners; | |
| 235 | + $no_update->banners_rtl = array(); | |
| 227 | 236 | } |
| 228 | 237 | |
| 229 | 238 | $update_cache->last_checked = time(); |
| 230 | 239 | $update_cache->checked[ $this->name ] = $this->version; |
| 240 | + if ( $no_update ) { | |
| 241 | + $update_cache->no_update[ $this->name ] = $no_update; | |
| 242 | + } | |
| 231 | 243 | |
| 232 | 244 | set_site_transient( 'update_plugins', $update_cache ); |
| 233 | 245 | |
| 234 | 246 | } else { |
| @@ -432,18 +444,18 @@ | ||
| 432 | 444 | } |
| 433 | 445 | } |
| 434 | 446 | |
| 435 | 447 | if ( false === $edd_plugin_url_available[ $store_hash ] ) { |
| 436 | - return false; | |
| 448 | + return; | |
| 437 | 449 | } |
| 438 | 450 | |
| 439 | 451 | $data = array_merge( $this->api_data, $_data ); |
| 440 | 452 | |
| 441 | 453 | if ( $data['slug'] != $this->slug ) { |
| 442 | - return false; | |
| 454 | + return; | |
| 443 | 455 | } |
| 444 | 456 | |
| 445 | - if ( $this->api_url == trailingslashit ( home_url() ) ) { | |
| 457 | + if( $this->api_url == trailingslashit ( home_url() ) ) { | |
| 446 | 458 | return false; // Don't allow a plugin to ping itself |
| 447 | 459 | } |
| 448 | 460 | |
| 449 | 461 | $api_params = array( |
| @@ -477,9 +489,9 @@ | ||
| 477 | 489 | if ( $request && isset( $request->icons ) ) { |
| 478 | 490 | $request->icons = maybe_unserialize( $request->icons ); |
| 479 | 491 | } |
| 480 | 492 | |
| 481 | - if ( ! empty( $request->sections ) ) { | |
| 493 | + if( ! empty( $request->sections ) ) { | |
| 482 | 494 | foreach( $request->sections as $key => $section ) { |
| 483 | 495 | $request->$key = (array) $section; |
| 484 | 496 | } |
| 485 | 497 | } |
| @@ -621,4 +633,5 @@ | ||
| 621 | 633 | return (bool) apply_filters( 'edd_sl_api_request_verify_ssl', true, $this ); |
| 622 | 634 | } |
| 623 | 635 | |
| 624 | 636 | } |
| 637 | + | |