| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package Freemius |
| 4 |
* @copyright Copyright (c) 2015, Freemius, Inc. |
| 5 |
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3 |
| 6 |
* @since 1.0.3 |
| 7 |
*/ |
| 8 |
|
| 9 |
if ( ! defined( 'ABSPATH' ) ) { |
| 10 |
exit; |
| 11 |
} |
| 12 |
|
| 13 |
class FS_Plugin extends FS_Scope_Entity { |
| 14 |
/** |
| 15 |
* @since 1.0.6 |
| 16 |
* @var null|number |
| 17 |
*/ |
| 18 |
public $parent_plugin_id; |
| 19 |
/** |
| 20 |
* @var string |
| 21 |
*/ |
| 22 |
public $title; |
| 23 |
/** |
| 24 |
* @var string |
| 25 |
*/ |
| 26 |
public $slug; |
| 27 |
/** |
| 28 |
* @author Leo Fajardo (@leorw) |
| 29 |
* @since 2.2.1 |
| 30 |
* |
| 31 |
* @var string |
| 32 |
*/ |
| 33 |
public $premium_slug; |
| 34 |
/** |
| 35 |
* @since 1.2.2 |
| 36 |
* |
| 37 |
* @var string 'plugin' or 'theme' |
| 38 |
*/ |
| 39 |
public $type; |
| 40 |
/** |
| 41 |
* @author Leo Fajardo (@leorw) |
| 42 |
* |
| 43 |
* @since 1.2.3 |
| 44 |
* |
| 45 |
* @var string|false false if the module doesn't have an affiliate program or one of the following: 'selected', 'customers', or 'all'. |
| 46 |
*/ |
| 47 |
public $affiliate_moderation; |
| 48 |
/** |
| 49 |
* @var bool Set to true if the free version of the module is hosted on WordPress.org. Defaults to true. |
| 50 |
*/ |
| 51 |
public $is_wp_org_compliant = true; |
| 52 |
/** |
| 53 |
* @author Leo Fajardo (@leorw) |
| 54 |
* @since 2.2.5 |
| 55 |
* |
| 56 |
* @var int |
| 57 |
*/ |
| 58 |
public $premium_releases_count; |
| 59 |
|
| 60 |
#region Install Specific Properties |
| 61 |
|
| 62 |
/** |
| 63 |
* @var string |
| 64 |
*/ |
| 65 |
public $file; |
| 66 |
/** |
| 67 |
* @var string |
| 68 |
*/ |
| 69 |
public $version; |
| 70 |
/** |
| 71 |
* @var bool |
| 72 |
*/ |
| 73 |
public $auto_update; |
| 74 |
/** |
| 75 |
* @var FS_Plugin_Info |
| 76 |
*/ |
| 77 |
public $info; |
| 78 |
/** |
| 79 |
* @since 1.0.9 |
| 80 |
* |
| 81 |
* @var bool |
| 82 |
*/ |
| 83 |
public $is_premium; |
| 84 |
/** |
| 85 |
* @author Leo Fajardo (@leorw) |
| 86 |
* @since 2.2.1 |
| 87 |
* |
| 88 |
* @var string |
| 89 |
*/ |
| 90 |
public $premium_suffix; |
| 91 |
/** |
| 92 |
* @since 1.0.9 |
| 93 |
* |
| 94 |
* @var bool |
| 95 |
*/ |
| 96 |
public $is_live; |
| 97 |
/** |
| 98 |
* @since 2.2.3 |
| 99 |
* @var null|number |
| 100 |
*/ |
| 101 |
public $bundle_id; |
| 102 |
/** |
| 103 |
* @since 2.3.1 |
| 104 |
* @var null|string |
| 105 |
*/ |
| 106 |
public $bundle_public_key; |
| 107 |
|
| 108 |
const AFFILIATE_MODERATION_CUSTOMERS = 'customers'; |
| 109 |
|
| 110 |
#endregion Install Specific Properties |
| 111 |
|
| 112 |
/** |
| 113 |
* @param stdClass|bool $plugin |
| 114 |
*/ |
| 115 |
function __construct( $plugin = false ) { |
| 116 |
parent::__construct( $plugin ); |
| 117 |
|
| 118 |
$this->is_premium = false; |
| 119 |
$this->is_live = true; |
| 120 |
|
| 121 |
if ( empty( $this->premium_slug ) && ! empty( $plugin->slug ) ) { |
| 122 |
$this->premium_slug = "{$this->slug}-premium"; |
| 123 |
} |
| 124 |
|
| 125 |
if ( empty( $this->premium_suffix ) ) { |
| 126 |
$this->premium_suffix = '(Premium)'; |
| 127 |
} |
| 128 |
|
| 129 |
if ( isset( $plugin->info ) && is_object( $plugin->info ) ) { |
| 130 |
$this->info = new FS_Plugin_Info( $plugin->info ); |
| 131 |
} |
| 132 |
} |
| 133 |
|
| 134 |
/** |
| 135 |
* Check if plugin is an add-on (has parent). |
| 136 |
* |
| 137 |
* @author Vova Feldman (@svovaf) |
| 138 |
* @since 1.0.6 |
| 139 |
* |
| 140 |
* @return bool |
| 141 |
*/ |
| 142 |
function is_addon() { |
| 143 |
return isset( $this->parent_plugin_id ) && is_numeric( $this->parent_plugin_id ); |
| 144 |
} |
| 145 |
|
| 146 |
/** |
| 147 |
* @author Leo Fajardo (@leorw) |
| 148 |
* @since 1.2.3 |
| 149 |
* |
| 150 |
* @return bool |
| 151 |
*/ |
| 152 |
function has_affiliate_program() { |
| 153 |
return ( ! empty( $this->affiliate_moderation ) ); |
| 154 |
} |
| 155 |
|
| 156 |
static function get_type() { |
| 157 |
return 'plugin'; |
| 158 |
} |
| 159 |
} |