Skip to content

Commit a7f8ccc

Browse files
committed
Add PluginData as method param over array.
1 parent c17f2b9 commit a7f8ccc

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/Edd/AbstractLicenceManager.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Dwnload\EddSoftwareLicenseManager\Edd\Models\CheckLicense;
77
use Dwnload\EddSoftwareLicenseManager\Edd\Models\DeactivateLicense;
88
use Dwnload\EddSoftwareLicenseManager\Edd\Models\LicenseStatus;
9+
use Dwnload\EddSoftwareLicenseManager\Edd\Models\PluginData;
910
use Dwnload\WpEmailDownload\EmailDownload;
1011

1112
/**
@@ -100,20 +101,20 @@ protected function deactivateLicense( string $license, string $plugin_slug, int
100101
* Checks if license is valid and gets expire date.
101102
*
102103
* @param string $license The incoming POST license key
103-
* @param array $plugin_args
104+
* @param PluginData $plugin_data
104105
* @param bool $update_option
105106
*
106107
* @return string $message License status message.
107108
*/
108-
protected function checkLicense( string $license = null, array $plugin_args = [], bool $update_option = false ): string {
109+
protected function checkLicense( string $license = null, PluginData $plugin_data, bool $update_option = false ): string {
109110
if ( empty( $license ) ) {
110-
return false;
111+
return $this->getStrings()['enter-key'];
111112
}
112113

113114
$api_params = [
114115
'edd_action' => self::CHECK_LICENCE,
115116
'license' => $license,
116-
'item_id' => $plugin_args['item_id'],
117+
'item_id' => $plugin_data->getItemId(),
117118
];
118119

119120
$response = $this->getCheckLicense( $api_params );
@@ -124,7 +125,7 @@ protected function checkLicense( string $license = null, array $plugin_args = []
124125
}
125126

126127
$expires = date_i18n( get_option( 'date_format' ), strtotime( $response->getExpires() ) );
127-
$renew_link = '<a href="' . esc_url( $this->getRenewalUrl( $license, $plugin_args['download_id'] ) ) . '" target="_blank">' . $this->getStrings()['renew'] . '</a>';
128+
$renew_link = '<a href="' . esc_url( $this->getRenewalUrl( $license, $plugin_data->getItemId() ) ) . '" target="_blank">' . $this->getStrings()['renew'] . '</a>';
128129

129130

130131
// Unlimited ??
@@ -156,12 +157,12 @@ protected function checkLicense( string $license = null, array $plugin_args = []
156157
}
157158

158159
$option = get_option( self::LICENSE_SETTING, [] );
159-
$status = isset( $option[ $plugin_args['id'] ]['status'] ) ? $option[ $plugin_args['id'] ]['status'] : '';
160-
$option[ $plugin_args['id'] ]['status'] = $response->getLicense();
161-
$key = $this->getTransientKey( $plugin_args['id'] . '_license_message' );
160+
$status = isset( $option[$plugin_data->getItemId() ]['status'] ) ? $option[ $plugin_data->getItemId() ]['status'] : '';
161+
$option[ $plugin_data->getItemId() ]['status'] = $response->getLicense();
162+
$key = $this->getTransientKey( $plugin_data->getItemId() . '_license_message' );
162163

163164
if ( $update_option ) {
164-
if ( ! empty( $status ) && $status != $option[ $plugin_args['id'] ]['status'] ) {
165+
if ( ! empty( $status ) && $status != $option[ $plugin_data->getItemId() ]['status'] ) {
165166
update_option( self::LICENSE_SETTING, $option );
166167
delete_transient( $key );
167168
}

0 commit comments

Comments
 (0)