| 1 |
<?php namespace EmailLog\Addon\License; |
| 2 |
|
| 3 |
defined( 'ABSPATH' ) || exit; // Exit if accessed directly. |
| 4 |
|
| 5 |
/** |
| 6 |
* BundleLicense Object. |
| 7 |
* There can be only one BundleLicence for all the add-ons. |
| 8 |
* |
| 9 |
* @since 2.0.0 |
| 10 |
*/ |
| 11 |
class BundleLicense extends BaseLicense { |
| 12 |
|
| 13 |
/** |
| 14 |
* For Bundle the add-on name is hardcoded. |
| 15 |
* |
| 16 |
* @var string Add-on name. |
| 17 |
*/ |
| 18 |
protected $addon_name = 'Email Log Bundle'; |
| 19 |
|
| 20 |
/** |
| 21 |
* Is the license valid? |
| 22 |
* |
| 23 |
* @return bool True if valid, False otherwise. |
| 24 |
*/ |
| 25 |
public function is_valid() { |
| 26 |
if ( empty( $this->license_data ) ) { |
| 27 |
return false; |
| 28 |
} |
| 29 |
|
| 30 |
return ( 'valid' === $this->license_data->license ); |
| 31 |
} |
| 32 |
|
| 33 |
/** |
| 34 |
* Return bundle license key. |
| 35 |
* |
| 36 |
* @return string Bundle License key, if found. |
| 37 |
*/ |
| 38 |
public function get_license_key() { |
| 39 |
if ( empty( $this->license_data ) ) { |
| 40 |
return parent::get_license_key(); |
| 41 |
} |
| 42 |
|
| 43 |
return $this->license_data->bundle_license_key; |
| 44 |
} |
| 45 |
|
| 46 |
/** |
| 47 |
* The option name in which the bundle license data will be stored. |
| 48 |
* |
| 49 |
* @return string Option name. |
| 50 |
*/ |
| 51 |
protected function get_option_name() { |
| 52 |
return 'el_bundle_license'; |
| 53 |
} |
| 54 |
|
| 55 |
/** |
| 56 |
* Get the license key of an add-on from Bundle. |
| 57 |
* |
| 58 |
* @param string $addon_name Add-on name. |
| 59 |
* |
| 60 |
* @return bool|string False if no license key is found, otherwise license key. |
| 61 |
*/ |
| 62 |
public function get_addon_license_key( $addon_name ) { |
| 63 |
if ( empty( $this->license_data ) ) { |
| 64 |
return false; |
| 65 |
} |
| 66 |
|
| 67 |
if ( ! isset( $this->license_data->bundled_licenses->{$addon_name} ) ) { |
| 68 |
return false; |
| 69 |
} |
| 70 |
|
| 71 |
return $this->license_data->bundled_licenses->{$addon_name}->license_key; |
| 72 |
} |
| 73 |
} |
| 74 |
|