| @@ -8,10 +8,62 @@ | ||
| 8 | 8 | * |
| 9 | 9 | * @since 1.9 |
| 10 | 10 | */ |
| 11 | 11 | class PLL_License { |
| 12 | - public $id, $name, $license_key, $license_data; | |
| 13 | - private $file, $version, $author; | |
| 12 | + /** | |
| 13 | + * Sanitized plugin name. | |
| 14 | + * | |
| 15 | + * @var string | |
| 16 | + */ | |
| 17 | + public $id; | |
| 18 | + | |
| 19 | + /** | |
| 20 | + * Plugin name. | |
| 21 | + * | |
| 22 | + * @var string | |
| 23 | + */ | |
| 24 | + public $name; | |
| 25 | + | |
| 26 | + /** | |
| 27 | + * License key. | |
| 28 | + * | |
| 29 | + * @var string | |
| 30 | + */ | |
| 31 | + public $license_key; | |
| 32 | + | |
| 33 | + /** | |
| 34 | + * License data, obtained from the API request. | |
| 35 | + * | |
| 36 | + * @var stdClass|null | |
| 37 | + */ | |
| 38 | + public $license_data; | |
| 39 | + | |
| 40 | + /** | |
| 41 | + * Main plugin file. | |
| 42 | + * | |
| 43 | + * @var string | |
| 44 | + */ | |
| 45 | + private $file; | |
| 46 | + | |
| 47 | + /** | |
| 48 | + * Current plugin version. | |
| 49 | + * | |
| 50 | + * @var string | |
| 51 | + */ | |
| 52 | + private $version; | |
| 53 | + | |
| 54 | + /** | |
| 55 | + * Plugin author. | |
| 56 | + * | |
| 57 | + * @var string | |
| 58 | + */ | |
| 59 | + private $author; | |
| 60 | + | |
| 61 | + /** | |
| 62 | + * API url. | |
| 63 | + * | |
| 64 | + * @var string. | |
| 65 | + */ | |
| 14 | 66 | private $api_url = 'https://polylang.pro'; |
| 15 | 67 | |
| 16 | 68 | /** |
| 17 | 69 | * Constructor |
| @@ -56,8 +108,10 @@ | ||
| 56 | 108 | /** |
| 57 | 109 | * Auto updater |
| 58 | 110 | * |
| 59 | 111 | * @since 1.9 |
| 112 | + * | |
| 113 | + * @return void | |
| 60 | 114 | */ |
| 61 | 115 | public function auto_updater() { |
| 62 | 116 | $args = array( |
| 63 | 117 | 'version' => $this->version, |
| @@ -83,14 +137,14 @@ | ||
| 83 | 137 | return $items; |
| 84 | 138 | } |
| 85 | 139 | |
| 86 | 140 | /** |
| 87 | - * Activate the license key | |
| 141 | + * Activates the license key. | |
| 88 | 142 | * |
| 89 | 143 | * @since 1.9 |
| 90 | 144 | * |
| 91 | - * @param string $license_key activation key | |
| 92 | - * @return object updated $this | |
| 145 | + * @param string $license_key Activation key. | |
| 146 | + * @return PLL_License Updated PLL_License object. | |
| 93 | 147 | */ |
| 94 | 148 | public function activate_license( $license_key ) { |
| 95 | 149 | $this->license_key = $license_key; |
| 96 | 150 | $this->api_request( 'activate_license' ); |
| @@ -101,13 +155,13 @@ | ||
| 101 | 155 | } |
| 102 | 156 | |
| 103 | 157 | |
| 104 | 158 | /** |
| 105 | - * Deactivate the license key | |
| 159 | + * Deactivates the license key. | |
| 106 | 160 | * |
| 107 | 161 | * @since 1.9 |
| 108 | 162 | * |
| 109 | - * @return object updated $this | |
| 163 | + * @return PLL_License Updated PLL_License object. | |
| 110 | 164 | */ |
| 111 | 165 | public function deactivate_license() { |
| 112 | 166 | $this->api_request( 'deactivate_license' ); |
| 113 | 167 | return $this; |
| @@ -113,13 +167,13 @@ | ||
| 113 | 167 | return $this; |
| 114 | 168 | } |
| 115 | 169 | |
| 116 | 170 | /** |
| 117 | - * Check if license key is valid | |
| 171 | + * Checks if the license key is valid. | |
| 118 | 172 | * |
| 119 | 173 | * @since 1.9 |
| 120 | 174 | * |
| 121 | - * @return object updated $this | |
| 175 | + * @return PLL_License Updated PLL_License object. | |
| 122 | 176 | */ |
| 123 | 177 | public function check_license() { |
| 124 | 178 | $this->api_request( 'check_license' ); |
| 125 | 179 | return $this; |
| @@ -131,8 +185,9 @@ | ||
| 131 | 185 | * |
| 132 | 186 | * @since 1.9 |
| 133 | 187 | * |
| 134 | 188 | * @param string $request check_license | activate_license | deactivate_license |
| 189 | + * @return void | |
| 135 | 190 | */ |
| 136 | 191 | private function api_request( $request ) { |
| 137 | 192 | $licenses = get_option( 'polylang_licenses' ); |
| 138 | 193 | |
| @@ -190,13 +245,14 @@ | ||
| 190 | 245 | if ( ! empty( $this->license_data ) ) { |
| 191 | 246 | $license = $this->license_data; |
| 192 | 247 | } |
| 193 | 248 | |
| 194 | - $class = 'license-null'; | |
| 249 | + $class = 'license-null'; | |
| 250 | + $message = ''; | |
| 195 | 251 | |
| 196 | 252 | $out = sprintf( |
| 197 | 253 | '<td><label for="pll-licenses[%1$s]">%2$s</label></td>' . |
| 198 | - '<td><input name="licenses[%1$s]" id="pll-licenses[%1$s]" type="text" value="%3$s" class="regular-text code" />', | |
| 254 | + '<td><input name="licenses[%1$s]" id="pll-licenses[%1$s]" type="password" value="%3$s" class="regular-text code" />', | |
| 199 | 255 | esc_attr( $this->id ), |
| 200 | 256 | esc_attr( $this->name ), |
| 201 | 257 | esc_html( $this->license_key ) |
| 202 | 258 | ); |
| @@ -219,9 +275,9 @@ | ||
| 219 | 275 | $message = sprintf( |
| 220 | 276 | /* translators: %1$s is a date, %2$s is link start tag, %3$s is link end tag. */ |
| 221 | 277 | esc_html__( 'Your license key expired on %1$s. Please %2$srenew your license key%3$s.', 'polylang' ), |
| 222 | 278 | esc_html( date_i18n( get_option( 'date_format' ), $expiration ) ), |
| 223 | - sprintf( '<a href="%s" target="_blank">', esc_url( 'https://polylang.pro/checkout/?edd_license_key=' . $this->license_key ) ), | |
| 279 | + sprintf( '<a href="%s" target="_blank">', 'https://polylang.pro/account/' ), | |
| 224 | 280 | '</a>' |
| 225 | 281 | ); |
| 226 | 282 | break; |
| 227 | 283 | |
| @@ -233,9 +289,9 @@ | ||
| 233 | 289 | case 'missing': |
| 234 | 290 | $message = sprintf( |
| 235 | 291 | /* translators: %1$s is link start tag, %2$s is link end tag. */ |
| 236 | 292 | esc_html__( 'Invalid license. Please %1$svisit your account page%2$s and verify it.', 'polylang' ), |
| 237 | - sprintf( '<a href="%s" target="_blank">', 'https://polylang.pro/account' ), | |
| 293 | + sprintf( '<a href="%s" target="_blank">', 'https://polylang.pro/account/' ), | |
| 238 | 294 | '</a>' |
| 239 | 295 | ); |
| 240 | 296 | break; |
| 241 | 297 | |
| @@ -244,9 +300,9 @@ | ||
| 244 | 300 | $message = sprintf( |
| 245 | 301 | /* translators: %1$s is a product name, %2$s is link start tag, %3$s is link end tag. */ |
| 246 | 302 | esc_html__( 'Your %1$s license key is not active for this URL. Please %2$svisit your account page%3$s to manage your license key URLs.', 'polylang' ), |
| 247 | 303 | esc_html( $this->name ), |
| 248 | - sprintf( '<a href="%s" target="_blank">', 'https://polylang.pro/account' ), | |
| 304 | + sprintf( '<a href="%s" target="_blank">', 'https://polylang.pro/account/' ), | |
| 249 | 305 | '</a>' |
| 250 | 306 | ); |
| 251 | 307 | break; |
| 252 | 308 | |
| @@ -258,9 +314,9 @@ | ||
| 258 | 314 | case 'no_activations_left': |
| 259 | 315 | $message = sprintf( |
| 260 | 316 | /* translators: %1$s is link start tag, %2$s is link end tag */ |
| 261 | 317 | esc_html__( 'Your license key has reached its activation limit. %1$sView possible upgrades%2$s now.', 'polylang' ), |
| 262 | - sprintf( '<a href="%s" target="_blank">', 'https://polylang.pro/account' ), | |
| 318 | + sprintf( '<a href="%s" target="_blank">', 'https://polylang.pro/account/' ), | |
| 263 | 319 | '</a>' |
| 264 | 320 | ); |
| 265 | 321 | break; |
| 266 | 322 | } |
| @@ -274,11 +330,11 @@ | ||
| 274 | 330 | } elseif ( $expiration > $now && $expiration - $now < ( DAY_IN_SECONDS * 30 ) ) { |
| 275 | 331 | $class = 'notice-warning notice-alt'; |
| 276 | 332 | $message = sprintf( |
| 277 | 333 | /* translators: %1$s is a date, %2$s is link start tag, %3$s is link end tag. */ |
| 278 | - esc_html__( 'Your license key will expire soon! Precisely, it will expire on %1$s. %2$sRenew your license key today!%3$s.', 'polylang' ), | |
| 334 | + esc_html__( 'Your license key will expire soon! Precisely, it will expire on %1$s. %2$sRenew your license key today!%3$s', 'polylang' ), | |
| 279 | 335 | esc_html( date_i18n( get_option( 'date_format' ), $expiration ) ), |
| 280 | - sprintf( '<a href="%s" target="_blank">', esc_url( 'https://polylang.pro/checkout/?edd_license_key=' . $this->license_key ) ), | |
| 336 | + sprintf( '<a href="%s" target="_blank">', 'https://polylang.pro/account/' ), | |
| 281 | 337 | '</a>' |
| 282 | 338 | ); |
| 283 | 339 | } else { |
| 284 | 340 | $message = sprintf( |