← All changes
|
freemius/includes/managers/class-fs-clone-manager.php
+16
-6
2.5.3
→
5.0.1
View file →
| @@ -332,9 +332,9 @@ | ||
| 332 | 332 | return null; |
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | if ( ! isset( $this->all_installs ) ) { |
| 336 | - $this->all_installs = Freemius::get_all_modules_sites(); | |
| 336 | + $this->all_installs = FS_DebugManager::get_all_modules_sites(); | |
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | // Check if there's another blog that has the same site. |
| 340 | 340 | $module_type = $instance->get_module_type(); |
| @@ -411,14 +411,14 @@ | ||
| 411 | 411 | * |
| 412 | 412 | * @author Vova Feldman (@svovaf) |
| 413 | 413 | * @since 2.5.0 |
| 414 | 414 | * |
| 415 | - * @param Freemius $instance | |
| 416 | - * @param string|false $license_key | |
| 415 | + * @param Freemius $instance | |
| 416 | + * @param FS_Plugin_License|null $license | |
| 417 | 417 | * |
| 418 | 418 | * @return bool TRUE if successfully connected. FALSE if failed and had to restore install from backup. |
| 419 | 419 | */ |
| 420 | - private function delete_install_and_connect( Freemius $instance, $license_key = false ) { | |
| 420 | + private function delete_install_and_connect( Freemius $instance, $license = null ) { | |
| 421 | 421 | $user = Freemius::_get_user_by_id( $instance->get_site()->user_id ); |
| 422 | 422 | |
| 423 | 423 | $instance->delete_current_install( true ); |
| 424 | 424 | |
| @@ -429,8 +429,11 @@ | ||
| 429 | 429 | // Find the relevant FS user by email address. |
| 430 | 430 | $user = Freemius::_get_user_by_email( $current_user->user_email ); |
| 431 | 431 | } |
| 432 | 432 | |
| 433 | + $license_key = ( is_object( $license ) ? $license->secret_key : false ); | |
| 434 | + $license_owner_id = ( is_object( $license ) ? $license->user_id : null ); | |
| 435 | + | |
| 433 | 436 | if ( is_object( $user ) ) { |
| 434 | 437 | // When a clone is found, we prefer to use the same user of the original install for the opt-in. |
| 435 | 438 | $instance->install_with_user( $user, $license_key, false, false ); |
| 436 | 439 | } else { |
| @@ -438,9 +441,16 @@ | ||
| 438 | 441 | $instance->opt_in( |
| 439 | 442 | false, |
| 440 | 443 | false, |
| 441 | 444 | false, |
| 442 | - $license_key | |
| 445 | + $license_key, | |
| 446 | + false, | |
| 447 | + false, | |
| 448 | + false, | |
| 449 | + null, | |
| 450 | + array(), | |
| 451 | + true, | |
| 452 | + $license_owner_id | |
| 443 | 453 | ); |
| 444 | 454 | } |
| 445 | 455 | |
| 446 | 456 | if ( is_object( $instance->get_site() ) ) { |
| @@ -504,9 +514,9 @@ | ||
| 504 | 514 | } |
| 505 | 515 | } |
| 506 | 516 | |
| 507 | 517 | // If the site is a clone of another subsite in the network, or a localhost one, try to auto activate the license. |
| 508 | - return $this->delete_install_and_connect( $instance, $license->secret_key ); | |
| 518 | + return $this->delete_install_and_connect( $instance, $license ); | |
| 509 | 519 | } |
| 510 | 520 | |
| 511 | 521 | /** |
| 512 | 522 | * @author Leo Fajardo (@leorw) |