class-fs-affiliate-terms.php
2 years ago
class-fs-affiliate.php
2 years ago
class-fs-billing.php
2 years ago
class-fs-entity.php
2 years ago
class-fs-payment.php
2 years ago
class-fs-plugin-info.php
2 years ago
class-fs-plugin-license.php
2 years ago
class-fs-plugin-plan.php
2 years ago
class-fs-plugin-tag.php
2 years ago
class-fs-plugin.php
2 years ago
class-fs-pricing.php
2 years ago
class-fs-scope-entity.php
2 years ago
class-fs-site.php
2 years ago
class-fs-subscription.php
2 years ago
class-fs-user.php
2 years ago
index.php
2 years ago
class-fs-plugin.php
164 lines
| 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 | * @since 2.5.4 |
| 109 | * @var null|array |
| 110 | */ |
| 111 | public $opt_in_moderation; |
| 112 | |
| 113 | const AFFILIATE_MODERATION_CUSTOMERS = 'customers'; |
| 114 | |
| 115 | #endregion Install Specific Properties |
| 116 | |
| 117 | /** |
| 118 | * @param stdClass|bool $plugin |
| 119 | */ |
| 120 | function __construct( $plugin = false ) { |
| 121 | parent::__construct( $plugin ); |
| 122 | |
| 123 | $this->is_premium = false; |
| 124 | $this->is_live = true; |
| 125 | |
| 126 | if ( empty( $this->premium_slug ) && ! empty( $plugin->slug ) ) { |
| 127 | $this->premium_slug = "{$this->slug}-premium"; |
| 128 | } |
| 129 | |
| 130 | if ( empty( $this->premium_suffix ) ) { |
| 131 | $this->premium_suffix = '(Premium)'; |
| 132 | } |
| 133 | |
| 134 | if ( isset( $plugin->info ) && is_object( $plugin->info ) ) { |
| 135 | $this->info = new FS_Plugin_Info( $plugin->info ); |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | /** |
| 140 | * Check if plugin is an add-on (has parent). |
| 141 | * |
| 142 | * @author Vova Feldman (@svovaf) |
| 143 | * @since 1.0.6 |
| 144 | * |
| 145 | * @return bool |
| 146 | */ |
| 147 | function is_addon() { |
| 148 | return isset( $this->parent_plugin_id ) && is_numeric( $this->parent_plugin_id ); |
| 149 | } |
| 150 | |
| 151 | /** |
| 152 | * @author Leo Fajardo (@leorw) |
| 153 | * @since 1.2.3 |
| 154 | * |
| 155 | * @return bool |
| 156 | */ |
| 157 | function has_affiliate_program() { |
| 158 | return ( ! empty( $this->affiliate_moderation ) ); |
| 159 | } |
| 160 | |
| 161 | static function get_type() { |
| 162 | return 'plugin'; |
| 163 | } |
| 164 | } |