| @@ -1,8 +1,5 @@ | ||
| 1 | 1 | <?php |
| 2 | -/** | |
| 3 | - * @package Polylang | |
| 4 | - */ | |
| 5 | 2 | |
| 6 | 3 | /** |
| 7 | 4 | * A class to easily manage licenses for Polylang Pro and addons |
| 8 | 5 | * |
| @@ -8,62 +5,10 @@ | ||
| 8 | 5 | * |
| 9 | 6 | * @since 1.9 |
| 10 | 7 | */ |
| 11 | 8 | class PLL_License { |
| 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 | |
| 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 | - */ | |
| 9 | + public $id, $name, $license_key, $license_data; | |
| 10 | + private $file, $version, $author; | |
| 66 | 11 | private $api_url = 'https://polylang.pro'; |
| 67 | 12 | |
| 68 | 13 | /** |
| 69 | 14 | * Constructor |
| @@ -108,10 +53,8 @@ | ||
| 108 | 53 | /** |
| 109 | 54 | * Auto updater |
| 110 | 55 | * |
| 111 | 56 | * @since 1.9 |
| 112 | - * | |
| 113 | - * @return void | |
| 114 | 57 | */ |
| 115 | 58 | public function auto_updater() { |
| 116 | 59 | $args = array( |
| 117 | 60 | 'version' => $this->version, |
| @@ -185,9 +128,8 @@ | ||
| 185 | 128 | * |
| 186 | 129 | * @since 1.9 |
| 187 | 130 | * |
| 188 | 131 | * @param string $request check_license | activate_license | deactivate_license |
| 189 | - * @return void | |
| 190 | 132 | */ |
| 191 | 133 | private function api_request( $request ) { |
| 192 | 134 | $licenses = get_option( 'polylang_licenses' ); |
| 193 | 135 | |
| @@ -245,14 +187,13 @@ | ||
| 245 | 187 | if ( ! empty( $this->license_data ) ) { |
| 246 | 188 | $license = $this->license_data; |
| 247 | 189 | } |
| 248 | 190 | |
| 249 | - $class = 'license-null'; | |
| 250 | - $message = ''; | |
| 191 | + $class = 'license-null'; | |
| 251 | 192 | |
| 252 | 193 | $out = sprintf( |
| 253 | 194 | '<td><label for="pll-licenses[%1$s]">%2$s</label></td>' . |
| 254 | - '<td><input name="licenses[%1$s]" id="pll-licenses[%1$s]" type="password" value="%3$s" class="regular-text code" />', | |
| 195 | + '<td><input name="licenses[%1$s]" id="pll-licenses[%1$s]" type="text" value="%3$s" class="regular-text code" />', | |
| 255 | 196 | esc_attr( $this->id ), |
| 256 | 197 | esc_attr( $this->name ), |
| 257 | 198 | esc_html( $this->license_key ) |
| 258 | 199 | ); |
| @@ -275,9 +216,9 @@ | ||
| 275 | 216 | $message = sprintf( |
| 276 | 217 | /* translators: %1$s is a date, %2$s is link start tag, %3$s is link end tag. */ |
| 277 | 218 | esc_html__( 'Your license key expired on %1$s. Please %2$srenew your license key%3$s.', 'polylang' ), |
| 278 | 219 | esc_html( date_i18n( get_option( 'date_format' ), $expiration ) ), |
| 279 | - sprintf( '<a href="%s" target="_blank">', 'https://polylang.pro/account/' ), | |
| 220 | + sprintf( '<a href="%s" target="_blank">', esc_url( 'https://polylang.pro/checkout/?edd_license_key=' . $this->license_key ) ), | |
| 280 | 221 | '</a>' |
| 281 | 222 | ); |
| 282 | 223 | break; |
| 283 | 224 | |
| @@ -289,9 +230,9 @@ | ||
| 289 | 230 | case 'missing': |
| 290 | 231 | $message = sprintf( |
| 291 | 232 | /* translators: %1$s is link start tag, %2$s is link end tag. */ |
| 292 | 233 | esc_html__( 'Invalid license. Please %1$svisit your account page%2$s and verify it.', 'polylang' ), |
| 293 | - sprintf( '<a href="%s" target="_blank">', 'https://polylang.pro/account/' ), | |
| 234 | + sprintf( '<a href="%s" target="_blank">', 'https://polylang.pro/account' ), | |
| 294 | 235 | '</a>' |
| 295 | 236 | ); |
| 296 | 237 | break; |
| 297 | 238 | |
| @@ -300,9 +241,9 @@ | ||
| 300 | 241 | $message = sprintf( |
| 301 | 242 | /* translators: %1$s is a product name, %2$s is link start tag, %3$s is link end tag. */ |
| 302 | 243 | 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' ), |
| 303 | 244 | esc_html( $this->name ), |
| 304 | - sprintf( '<a href="%s" target="_blank">', 'https://polylang.pro/account/' ), | |
| 245 | + sprintf( '<a href="%s" target="_blank">', 'https://polylang.pro/account' ), | |
| 305 | 246 | '</a>' |
| 306 | 247 | ); |
| 307 | 248 | break; |
| 308 | 249 | |
| @@ -314,9 +255,9 @@ | ||
| 314 | 255 | case 'no_activations_left': |
| 315 | 256 | $message = sprintf( |
| 316 | 257 | /* translators: %1$s is link start tag, %2$s is link end tag */ |
| 317 | 258 | esc_html__( 'Your license key has reached its activation limit. %1$sView possible upgrades%2$s now.', 'polylang' ), |
| 318 | - sprintf( '<a href="%s" target="_blank">', 'https://polylang.pro/account/' ), | |
| 259 | + sprintf( '<a href="%s" target="_blank">', 'https://polylang.pro/account' ), | |
| 319 | 260 | '</a>' |
| 320 | 261 | ); |
| 321 | 262 | break; |
| 322 | 263 | } |
| @@ -332,9 +273,9 @@ | ||
| 332 | 273 | $message = sprintf( |
| 333 | 274 | /* translators: %1$s is a date, %2$s is link start tag, %3$s is link end tag. */ |
| 334 | 275 | esc_html__( 'Your license key will expire soon! Precisely, it will expire on %1$s. %2$sRenew your license key today!%3$s.', 'polylang' ), |
| 335 | 276 | esc_html( date_i18n( get_option( 'date_format' ), $expiration ) ), |
| 336 | - sprintf( '<a href="%s" target="_blank">', 'https://polylang.pro/account/' ), | |
| 277 | + sprintf( '<a href="%s" target="_blank">', esc_url( 'https://polylang.pro/checkout/?edd_license_key=' . $this->license_key ) ), | |
| 337 | 278 | '</a>' |
| 338 | 279 | ); |
| 339 | 280 | } else { |
| 340 | 281 | $message = sprintf( |