r->getLicense(); if ( $license->canReceiveProductUpdates() ) { return $result; } } $status = $license->getStatus(); $messages = array( 'no_license_yet' => "Please enter your license key to enable plugin updates.", 'expired' => sprintf( 'Your access to %s updates has expired. Please renew your license.', apply_filters('wslm_product_name-' . $this->slug, $this->slug) ) ); $result = new WP_Error( 'wslm_update_not_available', isset($messages[$status]) ? $messages[$status] : 'Update not available. Please (re)enter your license key.', '[' . $status . ']' ); //This bit is important. At least in WP 4.3, the return value will be lost or replaced with a generic //"download failed" error unless you also set it on the upgrader skin. $upgrader->skin->set_result($result); return $result; } public function autoActivateLicense() { $doingCron = defined('DOING_CRON') && DOING_CRON; if ( !$this->currentUserCanManageLicense() && !$doingCron ) { return; } $license = $this->licenseManager->getLicense(); if ( $license->isValid() ) { return; } $failureFlag = self::ACTIVATION_FAILURE_FLAG . $this->slug; $state = get_site_option($failureFlag, null); if ( !is_array($state) || !isset($state['failures']) ) { $state = array( 'failures' => $state ? 1 : 0, 'lastAttemptTime' => 0, ); } if ( ($state['failures'] > $this->maxAutoActivationAttempts) ) { return; } $elapsedTime = time() - $state['lastAttemptTime']; $desiredDelay = $this->calculateLicenseActivationDelay($state['failures']); if ( $elapsedTime < $desiredDelay ) { return; } $state['failures']++; $state['lastAttemptTime'] = time(); update_site_option($failureFlag, $state); $result = null; $tokenHistory = $this->licenseManager->getTokenHistory(); if ( !empty($this->keyConstant) && defined($this->keyConstant) ) { //Attempt to activate the license key that's defined in wp-config.php. $result = $this->licenseManager->licenseThisSite(constant($this->keyConstant)); } else if ( !empty($tokenHistory) ) { //Check if there's a known token that matches the current site URL. Try to activate that token. $possibleToken = array_search($this->licenseManager->getSiteUrl(), array_reverse($tokenHistory, true)); if ( !empty($possibleToken) ) { $result = $this->licenseManager->licenseThisSiteByToken($possibleToken); } } if ( is_wp_error($result) ) { $productName = apply_filters('wslm_product_name-' . $this->slug, $this->slug); if ( is_admin() && !$doingCron ) { printf( '
%1$s tried to automatically activate your license, but it didn\'t work.
Error: %2$s [%3$s]
Please go to the Plugins page and enter your license key.