This commit is contained in:
2024-05-20 15:37:46 +03:00
commit 00b7dbd0b7
10404 changed files with 3285853 additions and 0 deletions

View File

@ -0,0 +1,128 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.2.3
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class FS_AffiliateTerms extends FS_Scope_Entity {
#region Properties
/**
* @var bool
*/
public $is_active;
/**
* @var string Enum: `affiliation` or `rewards`. Defaults to `affiliation`.
*/
public $type;
/**
* @var string Enum: `payout` or `credit`. Defaults to `payout`.
*/
public $reward_type;
/**
* If `first`, the referral will be attributed to the first visited source containing the affiliation link that
* was clicked.
*
* @var string Enum: `first` or `last`. Defaults to `first`.
*/
public $referral_attribution;
/**
* @var int Defaults to `30`, `0` for session cookie, and `null` for endless cookie (until cookies are cleaned).
*/
public $cookie_days;
/**
* @var int
*/
public $commission;
/**
* @var string Enum: `percentage` or `dollar`. Defaults to `percentage`.
*/
public $commission_type;
/**
* @var null|int Defaults to `0` (affiliate only on first payment). `null` for commission for all renewals. If
* greater than `0`, affiliate will get paid for all renewals for `commission_renewals_days` days after
* the initial upgrade/purchase.
*/
public $commission_renewals_days;
/**
* @var int Only cents and no percentage. In US cents, e.g.: 100 = $1.00. Defaults to `null`.
*/
public $install_commission;
/**
* @var string Required default target link, e.g.: pricing page.
*/
public $default_url;
/**
* @var string One of the following: 'all', 'new_customer', 'new_user'.
* If 'all' - reward for any user type.
* If 'new_customer' - reward only for new customers.
* If 'new_user' - reward only for new users.
*/
public $reward_customer_type;
/**
* @var int Defaults to `0` (affiliate only on directly affiliated links). `null` if an affiliate will get
* paid for all customers' lifetime payments. If greater than `0`, an affiliate will get paid for all
* customer payments for `future_payments_days` days after the initial payment.
*/
public $future_payments_days;
/**
* @var bool If `true`, allow referrals from social sites.
*/
public $is_social_allowed;
/**
* @var bool If `true`, allow conversions without HTTP referrer header at all.
*/
public $is_app_allowed;
/**
* @var bool If `true`, allow referrals from any site.
*/
public $is_any_site_allowed;
#endregion Properties
/**
* @author Leo Fajardo (@leorw)
*
* @return string
*/
function get_formatted_commission()
{
return ( 'dollar' === $this->commission_type ) ?
( '$' . $this->commission ) :
( $this->commission . '%' );
}
/**
* @author Leo Fajardo (@leorw)
*
* @return bool
*/
function has_lifetime_commission() {
return ( 0 !== $this->future_payments_days );
}
/**
* @author Leo Fajardo (@leorw)
*
* @return bool
*/
function is_session_cookie() {
return ( 0 == $this->cookie_days );
}
/**
* @author Leo Fajardo (@leorw)
*
* @return bool
*/
function has_renewals_commission() {
return ( is_null( $this->commission_renewals_days ) || $this->commission_renewals_days > 0 );
}
}

View File

@ -0,0 +1,84 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.2.3
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class FS_Affiliate extends FS_Scope_Entity {
#region Properties
/**
* @var string
*/
public $paypal_email;
/**
* @var number
*/
public $custom_affiliate_terms_id;
/**
* @var boolean
*/
public $is_using_custom_terms;
/**
* @var string status Enum: `pending`, `rejected`, `suspended`, or `active`. Defaults to `pending`.
*/
public $status;
/**
* @var string
*/
public $domain;
#endregion Properties
/**
* @author Leo Fajardo
*
* @return bool
*/
function is_active() {
return ( 'active' === $this->status );
}
/**
* @author Leo Fajardo
*
* @return bool
*/
function is_pending() {
return ( 'pending' === $this->status );
}
/**
* @author Leo Fajardo
*
* @return bool
*/
function is_suspended() {
return ( 'suspended' === $this->status );
}
/**
* @author Leo Fajardo
*
* @return bool
*/
function is_rejected() {
return ( 'rejected' === $this->status );
}
/**
* @author Leo Fajardo
*
* @return bool
*/
function is_blocked() {
return ( 'blocked' === $this->status );
}
}

View File

@ -0,0 +1,95 @@
<?php
/**
* @package Freemius for EDD Add-On
* @copyright Copyright (c) 2016, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class FS_Billing extends FS_Entity {
#region Properties
/**
* @var int
*/
public $entity_id;
/**
* @var string (Enum) Linked entity type. One of: developer, plugin, user, install
*/
public $entity_type;
/**
* @var string
*/
public $business_name;
/**
* @var string
*/
public $first;
/**
* @var string
*/
public $last;
/**
* @var string
*/
public $email;
/**
* @var string
*/
public $phone;
/**
* @var string
*/
public $website;
/**
* @var string Tax or VAT ID.
*/
public $tax_id;
/**
* @var string
*/
public $address_street;
/**
* @var string
*/
public $address_apt;
/**
* @var string
*/
public $address_city;
/**
* @var string
*/
public $address_country;
/**
* @var string Two chars country code.
*/
public $address_country_code;
/**
* @var string
*/
public $address_state;
/**
* @var number Numeric ZIP code (cab be with leading zeros).
*/
public $address_zip;
#endregion Properties
/**
* @param object|bool $event
*/
function __construct( $event = false ) {
parent::__construct( $event );
}
static function get_type() {
return 'billing';
}
}

View File

@ -0,0 +1,159 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.0.3
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Get object's public variables.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.0
*
* @param object $object
*
* @return array
*/
function fs_get_object_public_vars( $object ) {
return get_object_vars( $object );
}
class FS_Entity {
/**
* @var number
*/
public $id;
/**
* @var string Datetime value in 'YYYY-MM-DD HH:MM:SS' format.
*/
public $updated;
/**
* @var string Datetime value in 'YYYY-MM-DD HH:MM:SS' format.
*/
public $created;
/**
* @param bool|object $entity
*/
function __construct( $entity = false ) {
if ( ! ( $entity instanceof stdClass ) && ! ( $entity instanceof FS_Entity ) ) {
return;
}
$props = fs_get_object_public_vars( $this );
foreach ( $props as $key => $def_value ) {
$this->{$key} = isset( $entity->{$key} ) ?
$entity->{$key} :
$def_value;
}
}
static function get_type() {
return 'type';
}
/**
* @author Vova Feldman (@svovaf)
* @since 1.0.6
*
* @param FS_Entity $entity1
* @param FS_Entity $entity2
*
* @return bool
*/
static function equals( $entity1, $entity2 ) {
if ( is_null( $entity1 ) && is_null( $entity2 ) ) {
return true;
} else if ( is_object( $entity1 ) && is_object( $entity2 ) ) {
return ( $entity1->id == $entity2->id );
} else if ( is_object( $entity1 ) ) {
return is_null( $entity1->id );
} else {
return is_null( $entity2->id );
}
}
private $_is_updated = false;
/**
* Update object property.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.9
*
* @param string|array[string]mixed $key
* @param string|bool $val
*
* @return bool
*/
function update( $key, $val = false ) {
if ( ! is_array( $key ) ) {
$key = array( $key => $val );
}
$is_updated = false;
foreach ( $key as $k => $v ) {
if ( $this->{$k} === $v ) {
continue;
}
if ( ( is_string( $this->{$k} ) && is_numeric( $v ) ||
( is_numeric( $this->{$k} ) && is_string( $v ) ) ) &&
$this->{$k} == $v
) {
continue;
}
// Update value.
$this->{$k} = $v;
$is_updated = true;
}
$this->_is_updated = $is_updated;
return $is_updated;
}
/**
* Checks if entity was updated.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.9
*
* @return bool
*/
function is_updated() {
return $this->_is_updated;
}
/**
* @param $id
*
* @author Vova Feldman (@svovaf)
* @since 1.1.2
*
* @return bool
*/
static function is_valid_id($id){
return is_numeric($id);
}
/**
* @author Leo Fajardo (@leorw)
* @since 2.3.1
*
* @return string
*/
public static function get_class_name() {
return get_called_class();
}
}

View File

@ -0,0 +1,168 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2016, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class FS_Payment extends FS_Entity {
#region Properties
/**
* @var number
*/
public $plugin_id;
/**
* @var number
*/
public $user_id;
/**
* @var number
*/
public $install_id;
/**
* @var number
*/
public $subscription_id;
/**
* @var number
*/
public $plan_id;
/**
* @var number
*/
public $license_id;
/**
* @var float
*/
public $gross;
/**
* @author Leo Fajardo (@leorw)
* @since 2.3.0
*
* @var string One of the following: `usd`, `gbp`, `eur`.
*/
public $currency;
/**
* @var number
*/
public $bound_payment_id;
/**
* @var string
*/
public $external_id;
/**
* @var string
*/
public $gateway;
/**
* @var string ISO 3166-1 alpha-2 - two-letter country code.
*
* @link http://www.wikiwand.com/en/ISO_3166-1_alpha-2
*/
public $country_code;
/**
* @var string
*/
public $vat_id;
/**
* @var float Actual Tax / VAT in $$$
*/
public $vat;
/**
* @var int Payment source.
*/
public $source = 0;
#endregion Properties
const CURRENCY_USD = 'usd';
const CURRENCY_GBP = 'gbp';
const CURRENCY_EUR = 'eur';
/**
* @param object|bool $payment
*/
function __construct( $payment = false ) {
parent::__construct( $payment );
}
static function get_type() {
return 'payment';
}
/**
* @author Vova Feldman (@svovaf)
* @since 1.0.0
*
* @return bool
*/
function is_refund() {
return ( parent::is_valid_id( $this->bound_payment_id ) && 0 > $this->gross );
}
/**
* Checks if the payment was migrated from another platform.
*
* @author Vova Feldman (@svovaf)
* @since 2.0.2
*
* @return bool
*/
function is_migrated() {
return ( 0 != $this->source );
}
/**
* Returns the gross in this format:
* `{symbol}{amount | 2 decimal digits} {currency | uppercase}`
*
* Examples: £9.99 GBP, -£9.99 GBP.
*
* @author Leo Fajardo (@leorw)
* @since 2.3.0
*
* @return string
*/
function formatted_gross()
{
return (
( $this->gross < 0 ? '-' : '' ) .
$this->get_symbol() .
number_format( abs( $this->gross ), 2, '.', ',' ) . ' ' .
strtoupper( $this->currency )
);
}
/**
* A map between supported currencies with their symbols.
*
* @var array<string,string>
*/
static $CURRENCY_2_SYMBOL;
/**
* @author Leo Fajardo (@leorw)
* @since 2.3.0
*
* @return string
*/
private function get_symbol() {
if ( ! isset( self::$CURRENCY_2_SYMBOL ) ) {
// Lazy load.
self::$CURRENCY_2_SYMBOL = array(
self::CURRENCY_USD => '$',
self::CURRENCY_GBP => '&pound;',
self::CURRENCY_EUR => '&euro;',
);
}
return self::$CURRENCY_2_SYMBOL[ $this->currency ];
}
}

View File

@ -0,0 +1,34 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.0.3
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class FS_Plugin_Info extends FS_Entity {
public $plugin_id;
public $description;
public $short_description;
public $banner_url;
public $card_banner_url;
public $selling_point_0;
public $selling_point_1;
public $selling_point_2;
public $screenshots;
/**
* @param stdClass|bool $plugin_info
*/
function __construct( $plugin_info = false ) {
parent::__construct( $plugin_info );
}
static function get_type() {
return 'plugin';
}
}

View File

@ -0,0 +1,330 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.0.5
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class FS_Plugin_License
*/
class FS_Plugin_License extends FS_Entity {
#region Properties
/**
* @var number
*/
public $plugin_id;
/**
* @var number
*/
public $user_id;
/**
* @var number
*/
public $plan_id;
/**
* @author Leo Fajardo (@leorw)
* @since 2.3.0
*
* @var string
*/
public $parent_plan_name;
/**
* @author Leo Fajardo (@leorw)
* @since 2.3.0
*
* @var string
*/
public $parent_plan_title;
/**
* @author Leo Fajardo (@leorw)
* @since 2.3.0
*
* @var number
*/
public $parent_license_id;
/**
* @author Leo Fajardo (@leorw)
* @since 2.4.0
*
* @var array
*/
public $products;
/**
* @var number
*/
public $pricing_id;
/**
* @var int|null
*/
public $quota;
/**
* @var int
*/
public $activated;
/**
* @var int
*/
public $activated_local;
/**
* @var string
*/
public $expiration;
/**
* @var string
*/
public $secret_key;
/**
* @var bool
*/
public $is_whitelabeled;
/**
* @var bool $is_free_localhost Defaults to true. If true, allow unlimited localhost installs with the same
* license.
*/
public $is_free_localhost;
/**
* @var bool $is_block_features Defaults to true. If false, don't block features after license expiry - only
* block updates and support.
*/
public $is_block_features;
/**
* @var bool
*/
public $is_cancelled;
#endregion Properties
/**
* @param stdClass|bool $license
*/
function __construct( $license = false ) {
parent::__construct( $license );
}
/**
* Get entity type.
*
* @return string
*/
static function get_type() {
return 'license';
}
/**
* Check how many site activations left.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.5
*
* @return int
*/
function left() {
if ( ! $this->is_features_enabled() ) {
return 0;
}
if ( $this->is_unlimited() ) {
return 999;
}
return ( $this->quota - $this->activated - ( $this->is_free_localhost ? 0 : $this->activated_local ) );
}
/**
* Check if single site license.
*
* @author Vova Feldman (@svovaf)
* @since 1.1.8.1
*
* @return bool
*/
function is_single_site() {
return ( is_numeric( $this->quota ) && 1 == $this->quota );
}
/**
* @author Vova Feldman (@svovaf)
* @since 1.0.5
*
* @return bool
*/
function is_expired() {
return ! $this->is_lifetime() && ( strtotime( $this->expiration ) < WP_FS__SCRIPT_START_TIME );
}
/**
* Check if license is not expired.
*
* @author Vova Feldman (@svovaf)
* @since 1.2.1
*
* @return bool
*/
function is_valid() {
return ! $this->is_expired();
}
/**
* @author Vova Feldman (@svovaf)
* @since 1.0.6
*
* @return bool
*/
function is_lifetime() {
return is_null( $this->expiration );
}
/**
* @author Vova Feldman (@svovaf)
* @since 1.2.0
*
* @return bool
*/
function is_unlimited() {
return is_null( $this->quota );
}
/**
* Check if license is fully utilized.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.6
*
* @param bool|null $is_localhost
*
* @return bool
*/
function is_utilized( $is_localhost = null ) {
if ( is_null( $is_localhost ) ) {
$is_localhost = WP_FS__IS_LOCALHOST_FOR_SERVER;
}
if ( $this->is_unlimited() ) {
return false;
}
return ! ( $this->is_free_localhost && $is_localhost ) &&
( $this->quota <= $this->activated + ( $this->is_free_localhost ? 0 : $this->activated_local ) );
}
/**
* Check if license can be activated.
*
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @param bool|null $is_localhost
*
* @return bool
*/
function can_activate( $is_localhost = null ) {
return ! $this->is_utilized( $is_localhost ) && $this->is_features_enabled();
}
/**
* Check if license can be activated on a given number of production and localhost sites.
*
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @param int $production_count
* @param int $localhost_count
*
* @return bool
*/
function can_activate_bulk( $production_count, $localhost_count ) {
if ( $this->is_unlimited() ) {
return true;
}
/**
* For simplicity, the logic will work as following: when given X sites to activate the license on, if it's
* possible to activate on ALL of them, do the activation. If it's not possible to activate on ALL of them,
* do NOT activate on any of them.
*/
return ( $this->quota >= $this->activated + $production_count + ( $this->is_free_localhost ? 0 : $this->activated_local + $localhost_count ) );
}
/**
* @author Vova Feldman (@svovaf)
* @since 1.2.1
*
* @return bool
*/
function is_active() {
return ( ! $this->is_cancelled );
}
/**
* Check if license's plan features are enabled.
*
* - Either if plan not expired
* - If expired, based on the configuration to block features or not.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.6
*
* @return bool
*/
function is_features_enabled() {
return $this->is_active() && ( ! $this->is_block_features || ! $this->is_expired() );
}
/**
* Subscription considered to be new without any payments
* if the license expires in less than 24 hours
* from the license creation.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.9
*
* @return bool
*/
function is_first_payment_pending() {
return ( WP_FS__TIME_24_HOURS_IN_SEC >= strtotime( $this->expiration ) - strtotime( $this->created ) );
}
/**
* @return int
*/
function total_activations() {
return ( $this->activated + $this->activated_local );
}
/**
* @author Vova Feldman (@svovaf)
* @since 2.3.1
*
* @return string
*/
function get_html_escaped_masked_secret_key() {
return self::mask_secret_key_for_html( $this->secret_key );
}
/**
* @author Vova Feldman (@svovaf)
* @since 2.3.1
*
* @param string $secret_key
*
* @return string
*/
static function mask_secret_key_for_html( $secret_key ) {
return (
// Initial 6 chars - sk_ABC
htmlspecialchars( substr( $secret_key, 0, 6 ) ) .
// Masking
str_pad( '', ( strlen( $secret_key ) - 9 ) * 6, '&bull;' ) .
// Last 3 chars.
htmlspecialchars( substr( $secret_key, - 3 ) )
);
}
}

View File

@ -0,0 +1,145 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.0.5
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class FS_Plugin_Plan
*
* @property FS_Pricing[] $pricing
*/
class FS_Plugin_Plan extends FS_Entity {
#region Properties
/**
* @var number
*/
public $plugin_id;
/**
* @var string
*/
public $name;
/**
* @var string
*/
public $title;
/**
* @var string
*/
public $description;
/**
* @var bool Defaults to true. If true, allow unlimited localhost installs with the same license.
*/
public $is_free_localhost;
/**
* @var bool Defaults to true. If false, don't block features after license expiry - only block updates and
* support.
*/
public $is_block_features;
/**
* @var int
*/
public $license_type;
/**
* @var bool
*/
public $is_https_support;
/**
* @var int Trial days.
*/
public $trial_period;
/**
* @var string If true, require payment for trial.
*/
public $is_require_subscription;
/**
* @var string Knowledge Base URL.
*/
public $support_kb;
/**
* @var string Support Forum URL.
*/
public $support_forum;
/**
* @var string Support email address.
*/
public $support_email;
/**
* @var string Support phone.
*/
public $support_phone;
/**
* @var string Support skype username.
*/
public $support_skype;
/**
* @var bool Is personal success manager supported with the plan.
*/
public $is_success_manager;
/**
* @var bool Is featured plan.
*/
public $is_featured;
#endregion Properties
/**
* @param object|bool $plan
*/
function __construct( $plan = false ) {
parent::__construct( $plan );
if ( is_object( $plan ) ) {
$this->name = strtolower( $plan->name );
}
}
static function get_type() {
return 'plan';
}
/**
* @author Vova Feldman (@svovaf)
* @since 1.0.9
*
* @return bool
*/
function is_free() {
return ( 'free' === $this->name );
}
/**
* Checks if this plan supports "Technical Support".
*
* @author Leo Fajardo (leorw)
* @since 1.2.0
*
* @return bool
*/
function has_technical_support() {
return ( ! empty( $this->support_email ) ||
! empty( $this->support_skype ) ||
! empty( $this->support_phone ) ||
! empty( $this->is_success_manager )
);
}
/**
* @author Vova Feldman (@svovaf)
* @since 1.0.9
*
* @return bool
*/
function has_trial() {
return ! $this->is_free() &&
is_numeric( $this->trial_period ) && ( $this->trial_period > 0 );
}
}

View File

@ -0,0 +1,60 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2018, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 2.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class FS_Plugin_Tag extends FS_Entity {
/**
* @var string
*/
public $version;
/**
* @var string
*/
public $url;
/**
* @var string
*/
public $requires_platform_version;
/**
* @var string
*/
public $tested_up_to_version;
/**
* @var bool
*/
public $has_free;
/**
* @var bool
*/
public $has_premium;
/**
* @var string One of the following: `pending`, `beta`, `unreleased`.
*/
public $release_mode;
function __construct( $tag = false ) {
parent::__construct( $tag );
}
static function get_type() {
return 'tag';
}
/**
* @author Leo Fajardo (@leorw)
* @since 2.3.0
*
* @return bool
*/
function is_beta() {
return ( 'beta' === $this->release_mode );
}
}

View File

@ -0,0 +1,159 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.0.3
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class FS_Plugin extends FS_Scope_Entity {
/**
* @since 1.0.6
* @var null|number
*/
public $parent_plugin_id;
/**
* @var string
*/
public $title;
/**
* @var string
*/
public $slug;
/**
* @author Leo Fajardo (@leorw)
* @since 2.2.1
*
* @var string
*/
public $premium_slug;
/**
* @since 1.2.2
*
* @var string 'plugin' or 'theme'
*/
public $type;
/**
* @author Leo Fajardo (@leorw)
*
* @since 1.2.3
*
* @var string|false false if the module doesn't have an affiliate program or one of the following: 'selected', 'customers', or 'all'.
*/
public $affiliate_moderation;
/**
* @var bool Set to true if the free version of the module is hosted on WordPress.org. Defaults to true.
*/
public $is_wp_org_compliant = true;
/**
* @author Leo Fajardo (@leorw)
* @since 2.2.5
*
* @var int
*/
public $premium_releases_count;
#region Install Specific Properties
/**
* @var string
*/
public $file;
/**
* @var string
*/
public $version;
/**
* @var bool
*/
public $auto_update;
/**
* @var FS_Plugin_Info
*/
public $info;
/**
* @since 1.0.9
*
* @var bool
*/
public $is_premium;
/**
* @author Leo Fajardo (@leorw)
* @since 2.2.1
*
* @var string
*/
public $premium_suffix;
/**
* @since 1.0.9
*
* @var bool
*/
public $is_live;
/**
* @since 2.2.3
* @var null|number
*/
public $bundle_id;
/**
* @since 2.3.1
* @var null|string
*/
public $bundle_public_key;
const AFFILIATE_MODERATION_CUSTOMERS = 'customers';
#endregion Install Specific Properties
/**
* @param stdClass|bool $plugin
*/
function __construct( $plugin = false ) {
parent::__construct( $plugin );
$this->is_premium = false;
$this->is_live = true;
if ( empty( $this->premium_slug ) && ! empty( $plugin->slug ) ) {
$this->premium_slug = "{$this->slug}-premium";
}
if ( empty( $this->premium_suffix ) ) {
$this->premium_suffix = '(Premium)';
}
if ( isset( $plugin->info ) && is_object( $plugin->info ) ) {
$this->info = new FS_Plugin_Info( $plugin->info );
}
}
/**
* Check if plugin is an add-on (has parent).
*
* @author Vova Feldman (@svovaf)
* @since 1.0.6
*
* @return bool
*/
function is_addon() {
return isset( $this->parent_plugin_id ) && is_numeric( $this->parent_plugin_id );
}
/**
* @author Leo Fajardo (@leorw)
* @since 1.2.3
*
* @return bool
*/
function has_affiliate_program() {
return ( ! empty( $this->affiliate_moderation ) );
}
static function get_type() {
return 'plugin';
}
}

View File

@ -0,0 +1,157 @@
<?php
/**
* @package Freemius for EDD Add-On
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class FS_Pricing extends FS_Entity {
#region Properties
/**
* @var number
*/
public $plan_id;
/**
* @var int
*/
public $licenses;
/**
* @var null|float
*/
public $monthly_price;
/**
* @var null|float
*/
public $annual_price;
/**
* @var null|float
*/
public $lifetime_price;
/**
* @author Leo Fajardo (@leorw)
* @since 2.3.1
*
* @var string One of the following: `usd`, `gbp`, `eur`.
*/
public $currency;
#endregion Properties
/**
* @param object|bool $pricing
*/
function __construct( $pricing = false ) {
parent::__construct( $pricing );
}
static function get_type() {
return 'pricing';
}
/**
* @author Vova Feldman (@svovaf)
* @since 1.1.8
*
* @return bool
*/
function has_monthly() {
return ( is_numeric( $this->monthly_price ) && $this->monthly_price > 0 );
}
/**
* @author Vova Feldman (@svovaf)
* @since 1.1.8
*
* @return bool
*/
function has_annual() {
return ( is_numeric( $this->annual_price ) && $this->annual_price > 0 );
}
/**
* @author Vova Feldman (@svovaf)
* @since 1.1.8
*
* @return bool
*/
function has_lifetime() {
return ( is_numeric( $this->lifetime_price ) && $this->lifetime_price > 0 );
}
/**
* Check if unlimited licenses pricing.
*
* @author Vova Feldman (@svovaf)
* @since 1.1.8
*
* @return bool
*/
function is_unlimited() {
return is_null( $this->licenses );
}
/**
* Check if pricing has more than one billing cycle.
*
* @author Vova Feldman (@svovaf)
* @since 1.1.8
*
* @return bool
*/
function is_multi_cycle() {
$cycles = 0;
if ( $this->has_monthly() ) {
$cycles ++;
}
if ( $this->has_annual() ) {
$cycles ++;
}
if ( $this->has_lifetime() ) {
$cycles ++;
}
return $cycles > 1;
}
/**
* Get annual over monthly discount.
*
* @author Vova Feldman (@svovaf)
* @since 1.1.8
*
* @return int
*/
function annual_discount_percentage() {
return floor( $this->annual_savings() / ( $this->monthly_price * 12 * ( $this->is_unlimited() ? 1 : $this->licenses ) ) * 100 );
}
/**
* Get annual over monthly savings.
*
* @author Vova Feldman (@svovaf)
* @since 1.1.8
*
* @return float
*/
function annual_savings() {
return ( $this->monthly_price * 12 - $this->annual_price ) * ( $this->is_unlimited() ? 1 : $this->licenses );
}
/**
* @author Leo Fajardo (@leorw)
* @since 2.3.1
*
* @return bool
*/
function is_usd() {
return ( 'usd' === $this->currency );
}
}

View File

@ -0,0 +1,29 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.0.4
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class FS_Scope_Entity extends FS_Entity {
/**
* @var string
*/
public $public_key;
/**
* @var string
*/
public $secret_key;
/**
* @param bool|stdClass $scope_entity
*/
function __construct( $scope_entity = false ) {
parent::__construct( $scope_entity );
}
}

View File

@ -0,0 +1,253 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.0.3
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class FS_Site extends FS_Scope_Entity {
/**
* @var number
*/
public $site_id;
/**
* @var number
*/
public $plugin_id;
/**
* @var number
*/
public $user_id;
/**
* @var string
*/
public $title;
/**
* @var string
*/
public $url;
/**
* @var string
*/
public $version;
/**
* @var string E.g. en-GB
*/
public $language;
/**
* @var string E.g. UTF-8
*/
public $charset;
/**
* @var string Platform version (e.g WordPress version).
*/
public $platform_version;
/**
* Freemius SDK version
*
* @author Leo Fajardo (@leorw)
* @since 1.2.2
*
* @var string SDK version (e.g.: 1.2.2)
*/
public $sdk_version;
/**
* @var string Programming language version (e.g PHP version).
*/
public $programming_language_version;
/**
* @var number|null
*/
public $plan_id;
/**
* @var number|null
*/
public $license_id;
/**
* @var number|null
*/
public $trial_plan_id;
/**
* @var string|null
*/
public $trial_ends;
/**
* @since 1.0.9
*
* @var bool
*/
public $is_premium = false;
/**
* @author Leo Fajardo (@leorw)
*
* @since 1.2.1.5
*
* @var bool
*/
public $is_disconnected = false;
/**
* @since 2.0.0
*
* @var bool
*/
public $is_active = true;
/**
* @since 2.0.0
*
* @var bool
*/
public $is_uninstalled = false;
/**
* @author Edgar Melkonyan
*
* @since 2.4.2
*
* @var bool
*/
public $is_beta;
/**
* @param stdClass|bool $site
*/
function __construct( $site = false ) {
parent::__construct( $site );
if ( is_object( $site ) ) {
$this->plan_id = $site->plan_id;
}
if ( ! is_bool( $this->is_disconnected ) ) {
$this->is_disconnected = false;
}
}
static function get_type() {
return 'install';
}
/**
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @param string $url
*
* @return bool
*/
static function is_localhost_by_address( $url ) {
if ( false !== strpos( $url, '127.0.0.1' ) ||
false !== strpos( $url, 'localhost' )
) {
return true;
}
if ( ! fs_starts_with( $url, 'http' ) ) {
$url = 'http://' . $url;
}
$url_parts = parse_url( $url );
$subdomain = $url_parts['host'];
return (
// Starts with.
fs_starts_with( $subdomain, 'local.' ) ||
fs_starts_with( $subdomain, 'dev.' ) ||
fs_starts_with( $subdomain, 'test.' ) ||
fs_starts_with( $subdomain, 'stage.' ) ||
fs_starts_with( $subdomain, 'staging.' ) ||
// Ends with.
fs_ends_with( $subdomain, '.dev' ) ||
fs_ends_with( $subdomain, '.test' ) ||
fs_ends_with( $subdomain, '.staging' ) ||
fs_ends_with( $subdomain, '.local' ) ||
fs_ends_with( $subdomain, '.example' ) ||
fs_ends_with( $subdomain, '.invalid' ) ||
// GoDaddy test/dev.
fs_ends_with( $subdomain, '.myftpupload.com' ) ||
// ngrok tunneling.
fs_ends_with( $subdomain, '.ngrok.io' ) ||
// wpsandbox.
fs_ends_with( $subdomain, '.wpsandbox.pro' ) ||
// SiteGround staging.
fs_starts_with( $subdomain, 'staging' ) ||
// WPEngine staging.
fs_ends_with( $subdomain, '.staging.wpengine.com' ) ||
fs_ends_with( $subdomain, '.dev.wpengine.com' ) ||
fs_ends_with( $subdomain, '.wpengine.com' ) ||
// Pantheon
( fs_ends_with( $subdomain, 'pantheonsite.io' ) &&
( fs_starts_with( $subdomain, 'test-' ) || fs_starts_with( $subdomain, 'dev-' ) ) ) ||
// Cloudways
fs_ends_with( $subdomain, '.cloudwaysapps.com' ) ||
// Kinsta
( fs_starts_with( $subdomain, 'staging-' ) && ( fs_ends_with( $subdomain, '.kinsta.com' ) || fs_ends_with( $subdomain, '.kinsta.cloud' ) ) ) ||
// DesktopServer
fs_ends_with( $subdomain, '.dev.cc' ) ||
// Pressable
fs_ends_with( $subdomain, '.mystagingwebsite.com' )
);
}
function is_localhost() {
return ( WP_FS__IS_LOCALHOST_FOR_SERVER || self::is_localhost_by_address( $this->url ) );
}
/**
* Check if site in trial.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.9
*
* @return bool
*/
function is_trial() {
return is_numeric( $this->trial_plan_id ) && ( strtotime( $this->trial_ends ) > WP_FS__SCRIPT_START_TIME );
}
/**
* Check if user already utilized the trial with the current install.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.9
*
* @return bool
*/
function is_trial_utilized() {
return is_numeric( $this->trial_plan_id );
}
/**
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @return bool
*/
function is_tracking_allowed() {
return ( true !== $this->is_disconnected );
}
/**
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @return bool
*/
function is_tracking_prohibited() {
return ! $this->is_tracking_allowed();
}
/**
* @author Edgar Melkonyan
*
* @return bool
*/
function is_beta() {
return ( isset( $this->is_beta ) && true === $this->is_beta );
}
}

View File

@ -0,0 +1,147 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.0.9
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class FS_Subscription extends FS_Entity {
#region Properties
/**
* @var number
*/
public $user_id;
/**
* @var number
*/
public $install_id;
/**
* @var number
*/
public $plan_id;
/**
* @var number
*/
public $license_id;
/**
* @var float
*/
public $total_gross;
/**
* @var float
*/
public $amount_per_cycle;
/**
* @var int # of months
*/
public $billing_cycle;
/**
* @var float
*/
public $outstanding_balance;
/**
* @var int
*/
public $failed_payments;
/**
* @var string
*/
public $gateway;
/**
* @var string
*/
public $external_id;
/**
* @var string|null
*/
public $trial_ends;
/**
* @var string|null Datetime of the next payment, or null if cancelled.
*/
public $next_payment;
/**
* @since 2.3.1
*
* @var string|null Datetime of the cancellation.
*/
public $canceled_at;
/**
* @var string|null
*/
public $vat_id;
/**
* @var string Two characters country code
*/
public $country_code;
#endregion Properties
/**
* @param object|bool $subscription
*/
function __construct( $subscription = false ) {
parent::__construct( $subscription );
}
static function get_type() {
return 'subscription';
}
/**
* Check if subscription is active.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.9
*
* @return bool
*/
function is_active() {
if ( $this->is_canceled() ) {
return false;
}
return (
! empty( $this->next_payment ) &&
strtotime( $this->next_payment ) > WP_FS__SCRIPT_START_TIME
);
}
/**
* @author Vova Feldman (@svovaf)
* @since 2.3.1
*
* @return bool
*/
function is_canceled() {
return ! is_null( $this->canceled_at );
}
/**
* Subscription considered to be new without any payments
* if the next payment should be made within less than 24 hours
* from the subscription creation.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.9
*
* @return bool
*/
function is_first_payment_pending() {
return ( WP_FS__TIME_24_HOURS_IN_SEC >= strtotime( $this->next_payment ) - strtotime( $this->created ) );
}
/**
* @author Vova Feldman (@svovaf)
* @since 1.1.7
*/
function has_trial() {
return ! is_null( $this->trial_ends );
}
}

View File

@ -0,0 +1,62 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.0.3
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class FS_User extends FS_Scope_Entity {
#region Properties
/**
* @var string
*/
public $email;
/**
* @var string
*/
public $first;
/**
* @var string
*/
public $last;
/**
* @var bool
*/
public $is_verified;
/**
* @var string|null
*/
public $customer_id;
/**
* @var float
*/
public $gross;
#endregion Properties
/**
* @param object|bool $user
*/
function __construct( $user = false ) {
parent::__construct( $user );
}
function get_name() {
return trim( ucfirst( trim( is_string( $this->first ) ? $this->first : '' ) ) . ' ' . ucfirst( trim( is_string( $this->last ) ? $this->last : '' ) ) );
}
function is_verified() {
return ( isset( $this->is_verified ) && true === $this->is_verified );
}
static function get_type() {
return 'user';
}
}

View File

@ -0,0 +1,3 @@
<?php
// Silence is golden.
// Hide file structure from users on unprotected servers.