| @@ -1,94 +1,164 @@ | ||
| 1 | 1 | <?php |
| 2 | - /** | |
| 3 | - * @package Freemius | |
| 4 | - * @copyright Copyright (c) 2015, Freemius, Inc. | |
| 5 | - * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License | |
| 6 | - * @since 1.0.3 | |
| 7 | - */ | |
| 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 | 8 | |
| 9 | - if ( ! defined( 'ABSPATH' ) ) { | |
| 10 | - exit; | |
| 11 | - } | |
| 9 | + if ( ! defined( 'ABSPATH' ) ) { | |
| 10 | + exit; | |
| 11 | + } | |
| 12 | 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 | - * @var string 'plugin' or 'theme' | |
| 29 | - */ | |
| 30 | - public $type; | |
| 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; | |
| 31 | 59 | |
| 32 | - #region Install Specific Properties | |
| 60 | + #region Install Specific Properties | |
| 33 | 61 | |
| 34 | - /** | |
| 35 | - * @var string | |
| 36 | - */ | |
| 37 | - public $file; | |
| 38 | - /** | |
| 39 | - * @var string | |
| 40 | - */ | |
| 41 | - public $version; | |
| 42 | - /** | |
| 43 | - * @var bool | |
| 44 | - */ | |
| 45 | - public $auto_update; | |
| 46 | - /** | |
| 47 | - * @var FS_Plugin_Info | |
| 48 | - */ | |
| 49 | - public $info; | |
| 50 | - /** | |
| 51 | - * @since 1.0.9 | |
| 52 | - * | |
| 53 | - * @var bool | |
| 54 | - */ | |
| 55 | - public $is_premium; | |
| 56 | - /** | |
| 57 | - * @since 1.0.9 | |
| 58 | - * | |
| 59 | - * @var bool | |
| 60 | - */ | |
| 61 | - public $is_live; | |
| 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; | |
| 62 | 112 | |
| 63 | - #endregion Install Specific Properties | |
| 113 | + const AFFILIATE_MODERATION_CUSTOMERS = 'customers'; | |
| 64 | 114 | |
| 65 | - /** | |
| 66 | - * @param stdClass|bool $plugin | |
| 67 | - */ | |
| 68 | - function __construct( $plugin = false ) { | |
| 69 | - parent::__construct( $plugin ); | |
| 115 | + #endregion Install Specific Properties | |
| 70 | 116 | |
| 71 | - $this->is_premium = false; | |
| 72 | - $this->is_live = true; | |
| 117 | + /** | |
| 118 | + * @param stdClass|bool $plugin | |
| 119 | + */ | |
| 120 | + function __construct( $plugin = false ) { | |
| 121 | + parent::__construct( $plugin ); | |
| 73 | 122 | |
| 74 | - if ( isset( $plugin->info ) && is_object( $plugin->info ) ) { | |
| 75 | - $this->info = new FS_Plugin_Info( $plugin->info ); | |
| 76 | - } | |
| 77 | - } | |
| 123 | + $this->is_premium = false; | |
| 124 | + $this->is_live = true; | |
| 78 | 125 | |
| 79 | - /** | |
| 80 | - * Check if plugin is an add-on (has parent). | |
| 81 | - * | |
| 82 | - * @author Vova Feldman (@svovaf) | |
| 83 | - * @since 1.0.6 | |
| 84 | - * | |
| 85 | - * @return bool | |
| 86 | - */ | |
| 87 | - function is_addon() { | |
| 88 | - return isset( $this->parent_plugin_id ) && is_numeric( $this->parent_plugin_id ); | |
| 89 | - } | |
| 126 | + if ( empty( $this->premium_slug ) && ! empty( $plugin->slug ) ) { | |
| 127 | + $this->premium_slug = "{$this->slug}-premium"; | |
| 128 | + } | |
| 90 | 129 | |
| 91 | - static function get_type() { | |
| 92 | - return 'plugin'; | |
| 93 | - } | |
| 94 | - } | |
| 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 | + } | |