class-fs-entity.php
10 years ago
class-fs-plugin-info.php
10 years ago
class-fs-plugin-license.php
10 years ago
class-fs-plugin-plan.php
10 years ago
class-fs-plugin-tag.php
10 years ago
class-fs-plugin.php
10 years ago
class-fs-scope-entity.php
10 years ago
class-fs-site.php
10 years ago
class-fs-subscription.php
10 years ago
class-fs-user.php
10 years ago
class-fs-plugin-plan.php
71 lines
| 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.5 |
| 7 | */ |
| 8 | |
| 9 | if ( ! defined( 'ABSPATH' ) ) { |
| 10 | exit; |
| 11 | } |
| 12 | |
| 13 | class FS_Plugin_Plan extends FS_Entity { |
| 14 | |
| 15 | #region Properties |
| 16 | |
| 17 | /** |
| 18 | * @var string |
| 19 | */ |
| 20 | public $title; |
| 21 | /** |
| 22 | * @var string |
| 23 | */ |
| 24 | public $name; |
| 25 | /** |
| 26 | * @var int Trial days. |
| 27 | */ |
| 28 | public $trial_period; |
| 29 | /** |
| 30 | * @var string If true, require payment for trial. |
| 31 | */ |
| 32 | public $is_require_subscription; |
| 33 | |
| 34 | #endregion Properties |
| 35 | |
| 36 | /** |
| 37 | * @param object|bool $plan |
| 38 | */ |
| 39 | function __construct( $plan = false ) { |
| 40 | parent::__construct( $plan ); |
| 41 | |
| 42 | if ( is_object( $plan ) ) { |
| 43 | $this->name = strtolower( $plan->name ); |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | static function get_type() { |
| 48 | return 'plan'; |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * @author Vova Feldman (@svovaf) |
| 53 | * @since 1.0.9 |
| 54 | * |
| 55 | * @return bool |
| 56 | */ |
| 57 | function is_free() { |
| 58 | return ( 'free' === $this->name ); |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * @author Vova Feldman (@svovaf) |
| 63 | * @since 1.0.9 |
| 64 | * |
| 65 | * @return bool |
| 66 | */ |
| 67 | function has_trial() { |
| 68 | return ! $this->is_free() && |
| 69 | is_numeric( $this->trial_period ) && ( $this->trial_period > 0 ); |
| 70 | } |
| 71 | } |