Commit 82bd8fba by Manzar Hussain

add mathematics captcha

parent 7b564c39
<?php
/**
* Plugin Name: Easy Math Captcha for CF7
* Plugin URI: https://wordpress.org/plugins/easy-match-captcha-cf7/
* Description: Easy Math Captcha for Contact Form 7 is allows you to add simple math captcha to your form. this way you will get the spam protection.
* Version: 1.0.0
* Author: AlphaBPO
* Author URI: http://www.alphabpo.com
* Text Domain: cf7emc
* Domain Path: languages
*
* License: GPLv2 or later
* Domain Path: languages
*
* @package Easy Math Captcha for CF7
* @category Core
* @author Alpha BPO
*/
if( ! function_exists( 'cf7emc_fs' ) ) {
// Create a helper function for easy SDK access.
function cf7emc_fs() {
global $cf7emc_fs;
if( ! isset( $cf7emc_fs ) ) {
// Include Freemius SDK.
require_once dirname(__FILE__) . '/freemius/start.php';
$cf7emc_fs = fs_dynamic_init( array(
'id' => '5265',
'slug' => 'cf7-easy-math-captcha',
'type' => 'plugin',
'public_key' => 'pk_25474bcfc3636e193cd4cf6344468',
'is_premium' => false,
'has_addons' => false,
'has_paid_plans' => false,
'menu' => array(
'first-path' => 'plugins.php',
'account' => false,
'contact' => false,
'support' => false,
),
) );
}
return $cf7emc_fs;
}
// Init Freemius.
cf7emc_fs();
// Signal that SDK was initiated.
do_action( 'cf7emc_fs_loaded' );
}
/**
* Basic plugin definitions
*/
if( !defined( 'CF7EMC_VERSION' ) ) {
define( 'CF7EMC_VERSION', '1.0.0' ); // plugin version
}
if( !defined( 'CF7EMC_PLUGIN_DIR' ) ) {
define( 'CF7EMC_PLUGIN_DIR', dirname( __FILE__ ) ); // plugin dir
}
if( !defined( 'CF7EMC_ADMIN_DIR' ) ) {
define( 'CF7EMC_ADMIN_DIR', CF7EMC_PLUGIN_DIR . '/includes/admin' ); // plugin admin dir
}
if( !defined( 'CF7EMC_PLUGIN_URL' ) ) {
define( 'CF7EMC_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); // plugin url
}
/**
* Load Text Domain
*/
function cf7emc_load_plugin_textdomain() {
$locale = apply_filters( 'plugin_locale', get_locale(), 'cf7emc' );
load_textdomain( 'cf7emc', WP_LANG_DIR . '/cf7-easy-math-captcha/cf7emc-' . $locale . '.mo' );
load_plugin_textdomain( 'cf7emc', false, CF7EMC_PLUGIN_DIR . '/languages' );
}
add_action( 'load_plugins', 'cf7emc_load_plugin_textdomain' );
/**
* Activation hook
* Register plugin activation hook.
*/
register_activation_hook( __FILE__, 'cf7emc_plugin_install' );
/**
* Deactivation hook
* Register plugin deactivation hook.
*/
register_deactivation_hook( __FILE__, 'cf7emc_plugin_uninstall' );
/**
* Plugin Setup Activation hook call back
*
* Initial setup of the plugin setting default options
* and database tables creations.
*/
function cf7emc_plugin_install() {
global $wpdb, $cf7emc_settings;
$epvs_version = get_option( 'cf7emc_version' );
if( empty($epvs_version) ) {
}
}
/**
* Plugin Setup (On Deactivation)
*
* Does the drop tables in the database and
* delete plugin options.
*/
function cf7emc_plugin_uninstall() {
global $wpdb;
}
/**
* Load functionalities,
* in plugin loaded hook
*/
add_action( 'plugins_loaded', 'cf7emc_plugin_loaded', 20 );
function cf7emc_plugin_loaded() {
// Check if contact form plugin is active
if( defined('WPCF7_VERSION') ) {
/**
* Include require files
*/
// Includes plugin functions
require_once ( CF7EMC_PLUGIN_DIR . '/includes/cf7emc-misc-functions.php');
// Captcha field to manage captcha codes
require_once ( CF7EMC_PLUGIN_DIR . '/includes/class-cf7emc-captcha.php');
// Includes public class file
require_once ( CF7EMC_PLUGIN_DIR . '/includes/class-cf7emc-public.php');
// Include admin side functionalities
if( is_admin() ) {
require_once( CF7EMC_ADMIN_DIR . '/class-cf7emc-admin.php' );
}
} else {
function cf7emc_admin_warning() {
echo '<div class="error">';
echo "<p><strong>" . esc_html__( 'Easy Math Captcha for CF7 Extension needs the Contact Form 7 plugin installed and activated!', 'cf7emc' ) . "</strong></p>";
echo '</div>';
}
add_action( 'admin_notices', 'cf7emc_admin_warning' );
}
}
\ No newline at end of file
Freemius WordPress SDK
======================
[Monetization](https://freemius.com/wordpress/), [analytics](https://freemius.com/wordpress/insights/), and marketing automation platform for plugin & theme developers. Freemius empower developers to create prosperous subscription based businesses.
You can see some of the WordPress.org plugins & themes that are utilizing the power of Freemius here:
https://includewp.com/freemius/#focus
If you are a WordPress plugin or theme developer and you are interested to monetize with Freemius you can [sign-up here for free](https://dashboard.freemius.com/register/):
https://dashboard.freemius.com/register/
**Below you'll find the integration instructions for our WordPress SDK.**
## Code Documentation
You can find the SDK's documentation here:
https://freemius.com/help/documentation/wordpress-sdk/
## Initializing the SDK
Copy the code below and paste it into the top of your main plugin's PHP file, right after the plugin's header comment:
```php
<?php
// Create a helper function for easy SDK access.
function my_prefix_fs() {
global $my_prefix_fs;
if ( ! isset( $my_prefix_fs ) ) {
// Include Freemius SDK.
require_once dirname(__FILE__) . '/freemius/start.php';
$my_prefix_fs = fs_dynamic_init( array(
'id' => '1234',
'slug' => 'my-plugin-slug',
'menu_slug' => 'my_menu_slug', // You can also use __FILE__
'public_key' => 'pk_MY_PUBLIC_KEY',
'is_live' => true,
'is_premium' => true,
'has_addons' => false,
'has_paid_plans' => false,
// Set the SDK to work in a sandbox mode (for development & testing).
// IMPORTANT: MAKE SURE TO REMOVE SECRET KEY BEFORE DEPLOYMENT.
'secret_key' => 'sk_MY_SECRET_KEY',
) );
}
return $my_prefix_fs;
}
// Init Freemius.
my_prefix_fs();
?>
```
- **1234** - Replace with your plugin's ID.
- **pk_MY_PUBLIC_KEY** - Replace with your plugin's public key.
- **sk_MY_SECRET_KEY** - Replace with your plugin's secret key.
- **my-plugin-slug** - Replace with your plugin's WordPress.org slug.
- **my_menu_slug** - Replace with your admin dashboard settings menu slug.
## Usage example
You can call the SDK by using the shortcode function:
```php
<?php my_prefix_fs()->get_upgrade_url(); ?>
```
Or when calling Freemius multiple times in a scope, it's recommended to use it with the global variable:
```php
<?php
global $my_prefix_fs;
$my_prefix_fs->get_account_url();
?>
```
## Adding license based logic examples
Add marketing content to encourage your users to upgrade for your paid version:
```php
<?php
if ( my_prefix_fs()->is_not_paying() ) {
echo '<section><h1>' . esc_html__('Awesome Premium Features', 'my-plugin-slug') . '</h1>';
echo '<a href="' . my_prefix_fs()->get_upgrade_url() . '">' .
esc_html__('Upgrade Now!', 'my-plugin-slug') .
'</a>';
echo '</section>';
}
?>
```
Add logic which will only be available in your premium plugin version:
```php
<?php
// This "if" block will be auto removed from the Free version.
if ( my_prefix_fs()->is__premium_only() ) {
// ... premium only logic ...
}
?>
```
To add a function which will only be available in your premium plugin version, simply add __premium_only as the suffix of the function name. Just make sure that all lines that call that method directly or by hooks, are also wrapped in premium only logic:
```php
<?php
class My_Plugin {
function init() {
...
// This "if" block will be auto removed from the free version.
if ( my_prefix_fs()->is__premium_only() ) {
// Init premium version.
$this->admin_init__premium_only();
add_action( 'admin_init', array( &$this, 'admin_init_hook__premium_only' );
}
...
}
// This method will be only included in the premium version.
function admin_init__premium_only() {
...
}
// This method will be only included in the premium version.
function admin_init_hook__premium_only() {
...
}
}
?>
```
Add logic which will only be executed for customers in your 'professional' plan:
```php
<?php
if ( my_prefix_fs()->is_plan('professional', true) ) {
// .. logic related to Professional plan only ...
}
?>
```
Add logic which will only be executed for customers in your 'professional' plan or higher plans:
```php
<?php
if ( my_prefix_fs()->is_plan('professional') ) {
// ... logic related to Professional plan and higher plans ...
}
?>
```
Add logic which will only be available in your premium plugin version AND will only be executed for customers in your 'professional' plan (and higher plans):
```php
<?php
// This "if" block will be auto removed from the Free version.
if ( my_prefix_fs()->is_plan__premium_only('professional') ) {
// ... logic related to Professional plan and higher plans ...
}
?>
```
Add logic only for users in trial:
```php
<?php
if ( my_prefix_fs()->is_trial() ) {
// ... logic for users in trial ...
}
?>
```
Add logic for specified paid plan:
```php
<?php
// This "if" block will be auto removed from the Free version.
if ( my_prefix_fs()->is__premium_only() ) {
if ( my_prefix_fs()->is_plan( 'professional', true ) ) {
// ... logic related to Professional plan only ...
} else if ( my_prefix_fs()->is_plan( 'business' ) ) {
// ... logic related to Business plan and higher plans ...
}
}
?>
```
## Excluding files and folders from the free plugin version
There are two ways to exclude files from your free version.
1. Add `__premium_only` just before the file extension. For example, functions__premium_only.php will be only included in the premium plugin version. This works for all type of files, not only PHP.
2. Add `@fs_premium_only` a sepcial meta tag to the plugin's main PHP file header. Example:
```php
<?php
/**
* Plugin Name: My Very Awesome Plugin
* Plugin URI: http://my-awesome-plugin.com
* Description: Create and manage Awesomeness right in WordPress.
* Version: 1.0.0
* Author: Awesomattic
* Author URI: http://my-awesome-plugin.com/me/
* License: GPLv2
* Text Domain: myplugin
* Domain Path: /langs
*
* @fs_premium_only /lib/functions.php, /premium-files/
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// ... my code ...
?>
```
The file `/lib/functions.php` and the directory `/premium-files/` will be removed from the free plugin version.
# WordPress.org Compliance
Based on [WordPress.org Guidelines](https://wordpress.org/plugins/about/guidelines/) you are not allowed to submit a plugin that has premium code in it:
> All code hosted by WordPress.org servers must be free and fully-functional. If you want to sell advanced features for a plugin (such as a "pro" version), then you must sell and serve that code from your own site, we will not host it on our servers.
Therefore, if you want to deploy your free plugin's version to WordPress.org, make sure you wrap all your premium code with `if ( my_prefix_fs()->{{ method }}__premium_only() )` or the other methods provided to exclude premium features & files from the free version.
## Deployment
Zip your plugin's root folder and upload it in the Deployment section in the *Freemius Developer's Dashboard*.
The plugin will be scanned and processed by a custom developed *PHP Processor* which will auto-generate two versions of your plugin:
1. **Premium version**: Identical to your uploaded version, including all code (except your `secret_key`). Will be enabled for download ONLY for your paying or in trial customers.
2. **Free version**: The code stripped from all your paid features (based on the logic added wrapped in `{ method }__premium_only()`).
The free version is the one that you should give your users to download. Therefore, download the free generated version and upload to your site. Or, if your plugin was WordPress.org complaint and you made sure to exclude all your premium code with the different provided techniques, you can deploy the downloaded free version to the .org repo.
## Reporting Bugs
Email dev [at] freemius [dot] com
## FAQ
## Copyright
Freemius, Inc.
label.fs-tag,span.fs-tag{background:#ffba00;color:#fff;display:inline-block;border-radius:3px;padding:5px;font-size:11px;line-height:11px;vertical-align:baseline}label.fs-tag.fs-warn,span.fs-tag.fs-warn{background:#ffba00}label.fs-tag.fs-info,span.fs-tag.fs-info{background:#00a0d2}label.fs-tag.fs-success,span.fs-tag.fs-success{background:#46b450}label.fs-tag.fs-error,span.fs-tag.fs-error{background:#dc3232}#fs_account .postbox,#fs_account .widefat{max-width:800px}#fs_account h3{font-size:1.3em;padding:12px 15px;margin:0 0 12px 0;line-height:1.4;border-bottom:1px solid #F1F1F1}#fs_account h3 .dashicons{width:26px;height:26px;font-size:1.3em}#fs_account i.dashicons{font-size:1.2em;height:1.2em;width:1.2em}#fs_account .dashicons{vertical-align:middle}#fs_account .fs-header-actions{position:absolute;top:17px;right:15px;font-size:0.9em}#fs_account .fs-header-actions ul{margin:0}#fs_account .fs-header-actions li{float:left}#fs_account .fs-header-actions li form{display:inline-block}#fs_account .fs-header-actions li a{text-decoration:none}#fs_account_details .button-group{float:right}.rtl #fs_account .fs-header-actions{left:15px;right:auto}.fs-key-value-table{width:100%}.fs-key-value-table form{display:inline-block}.fs-key-value-table tr td:first-child{text-align:right}.fs-key-value-table tr td:first-child nobr{font-weight:bold}.fs-key-value-table tr td:first-child form{display:block}.fs-key-value-table tr td.fs-right{text-align:right}.fs-key-value-table tr.fs-odd{background:#ebebeb}.fs-key-value-table td,.fs-key-value-table th{padding:10px}.fs-key-value-table code{line-height:28px}.fs-key-value-table var,.fs-key-value-table code,.fs-key-value-table input[type="text"]{color:#0073AA;font-size:16px;background:none}.fs-key-value-table input[type="text"]{width:100%;font-weight:bold}.fs-field-beta_program label{margin-left:7px}label.fs-tag{background:#ffba00;color:#fff;display:inline-block;border-radius:3px;padding:5px;font-size:11px;line-height:11px;vertical-align:baseline}label.fs-tag.fs-warn{background:#ffba00}label.fs-tag.fs-success{background:#46b450}label.fs-tag.fs-error{background:#dc3232}#fs_sites .fs-scrollable-table .fs-table-body{max-height:200px;overflow:auto;border:1px solid #e5e5e5}#fs_sites .fs-scrollable-table .fs-table-body>table.widefat{border:none !important}#fs_sites .fs-scrollable-table .fs-main-column{width:100%}#fs_sites .fs-scrollable-table .fs-site-details td:first-of-type{text-align:right;color:grey;width:1px}#fs_sites .fs-scrollable-table .fs-site-details td:last-of-type{text-align:right}#fs_sites .fs-scrollable-table .fs-install-details table tr td{width:1px;white-space:nowrap}#fs_sites .fs-scrollable-table .fs-install-details table tr td:last-of-type{width:auto}#fs_addons h3{border:none;margin-bottom:0;padding:4px 5px}#fs_addons td{vertical-align:middle}#fs_addons thead{white-space:nowrap}#fs_addons td:first-child,#fs_addons th:first-child{text-align:left;font-weight:bold}#fs_addons td:last-child,#fs_addons th:last-child{text-align:right}#fs_addons th{font-weight:bold}#fs_billing_address{width:100%}#fs_billing_address tr td{width:50%;padding:5px}#fs_billing_address tr:first-of-type td{padding-top:0}#fs_billing_address span{font-weight:bold}#fs_billing_address input,#fs_billing_address select{display:block;width:100%;margin-top:5px}#fs_billing_address input::-moz-placeholder,#fs_billing_address select::-moz-placeholder{color:transparent;opacity:1}#fs_billing_address input:-ms-input-placeholder,#fs_billing_address select:-ms-input-placeholder{color:transparent}#fs_billing_address input::-webkit-input-placeholder,#fs_billing_address select::-webkit-input-placeholder{color:transparent}#fs_billing_address input.fs-read-mode,#fs_billing_address select.fs-read-mode{border-color:transparent;color:#777;border-bottom:1px dashed #ccc;padding-left:0;background:none}#fs_billing_address.fs-read-mode td span{display:none}#fs_billing_address.fs-read-mode input,#fs_billing_address.fs-read-mode select{border-color:transparent;color:#777;border-bottom:1px dashed #ccc;padding-left:0;background:none}#fs_billing_address.fs-read-mode input::-moz-placeholder,#fs_billing_address.fs-read-mode select::-moz-placeholder{color:#ccc;opacity:1}#fs_billing_address.fs-read-mode input:-ms-input-placeholder,#fs_billing_address.fs-read-mode select:-ms-input-placeholder{color:#ccc}#fs_billing_address.fs-read-mode input::-webkit-input-placeholder,#fs_billing_address.fs-read-mode select::-webkit-input-placeholder{color:#ccc}#fs_billing_address button{display:block;width:100%}
@charset "UTF-8";#fs_affiliation_content_wrapper #messages{margin-top:25px}#fs_affiliation_content_wrapper h3{font-size:24px;padding:0;margin-left:0}#fs_affiliation_content_wrapper ul li{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box;list-style-type:none}#fs_affiliation_content_wrapper ul li:before{content:'✓';margin-right:10px;font-weight:bold}#fs_affiliation_content_wrapper p:not(.description),#fs_affiliation_content_wrapper li,#fs_affiliation_content_wrapper label{font-size:16px !important;line-height:26px !important}#fs_affiliation_content_wrapper .button{margin-top:20px;margin-bottom:7px;line-height:35px;height:40px;font-size:16px}#fs_affiliation_content_wrapper .button#cancel_button{margin-right:5px}#fs_affiliation_content_wrapper form .input-container{margin-bottom:15px}#fs_affiliation_content_wrapper form .input-container .input-label{font-weight:bold;display:block;width:100%}#fs_affiliation_content_wrapper form .input-container.input-container-text label,#fs_affiliation_content_wrapper form .input-container.input-container-text input,#fs_affiliation_content_wrapper form .input-container.input-container-text textarea{display:block}#fs_affiliation_content_wrapper form .input-container #add_domain,#fs_affiliation_content_wrapper form .input-container .remove-domain{text-decoration:none;display:inline-block;margin-top:3px}#fs_affiliation_content_wrapper form .input-container #add_domain:focus,#fs_affiliation_content_wrapper form .input-container .remove-domain:focus{box-shadow:none}#fs_affiliation_content_wrapper form .input-container #add_domain.disabled,#fs_affiliation_content_wrapper form .input-container .remove-domain.disabled{color:#aaa;cursor:default}#fs_affiliation_content_wrapper form #extra_domains_container .description{margin-top:0;position:relative;top:-4px}#fs_affiliation_content_wrapper form #extra_domains_container .extra-domain-input-container{margin-bottom:15px}#fs_affiliation_content_wrapper form #extra_domains_container .extra-domain-input-container .domain{display:inline-block;margin-right:5px}#fs_affiliation_content_wrapper form #extra_domains_container .extra-domain-input-container .domain:last-of-type{margin-bottom:0}
@media screen and (max-width: 782px){#wpbody-content{padding-bottom:0 !important}}
.fs-badge{position:absolute;top:10px;right:0;background:#71ae00;color:white;text-transform:uppercase;padding:5px 10px;-moz-border-radius:3px 0 0 3px;-webkit-border-radius:3px 0 0 3px;border-radius:3px 0 0 3px;font-weight:bold;border-right:0;-moz-box-shadow:0 2px 1px -1px rgba(0,0,0,0.3);-webkit-box-shadow:0 2px 1px -1px rgba(0,0,0,0.3);box-shadow:0 2px 1px -1px rgba(0,0,0,0.3)}.theme-browser .theme .fs-premium-theme-badge-container{position:absolute;right:0;top:0}.theme-browser .theme .fs-premium-theme-badge-container .fs-badge{position:relative;top:0;margin-top:10px;text-align:center}.theme-browser .theme .fs-premium-theme-badge-container .fs-badge.fs-premium-theme-badge{font-size:1.1em}.theme-browser .theme .fs-premium-theme-badge-container .fs-badge.fs-beta-theme-badge{background:#00a0d2}.fs-switch{position:relative;display:inline-block;color:#ccc;text-shadow:0 1px 1px rgba(255,255,255,0.8);height:18px;padding:6px 6px 5px 6px;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.2);background:#ececec;box-shadow:0 0 4px rgba(0,0,0,0.1),inset 0 1px 3px 0 rgba(0,0,0,0.1);cursor:pointer}.fs-switch span{display:inline-block;width:35px;text-transform:uppercase}.fs-switch .fs-toggle{position:absolute;top:1px;width:37px;height:25px;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.3);border-radius:4px;background:#fff;background-color:#fff;background-image:-webkit-gradient(linear, left top, left bottom, color-stop(0, #ececec), color-stop(1, #fff));background-image:-webkit-linear-gradient(top, #ececec, #fff);background-image:-moz-linear-gradient(top, #ececec, #fff);background-image:-ms-linear-gradient(top, #ececec, #fff);background-image:-o-linear-gradient(top, #ececec, #fff);background-image:linear-gradient(top, bottom, #ececec, #fff);box-shadow:inset 0 1px 0 0 rgba(255,255,255,0.5);z-index:999;-moz-transition:0.4s cubic-bezier(0.54, 1.6, 0.5, 1);-o-transition:0.4s cubic-bezier(0.54, 1.6, 0.5, 1);-ms-transition:0.4s cubic-bezier(0.54, 1.6, 0.5, 1);-webkit-transition:0.4s cubic-bezier(0.54, 1.6, 0.5, 1);transition:0.4s cubic-bezier(0.54, 1.6, 0.5, 1)}.fs-switch.fs-off .fs-toggle{left:2%}.fs-switch.fs-on .fs-toggle{left:54%}.fs-switch.fs-round{top:8px;padding:4px 25px;-moz-border-radius:24px;-webkit-border-radius:24px;border-radius:24px}.fs-switch.fs-round .fs-toggle{top:0;width:24px;height:24px;-moz-border-radius:24px;-webkit-border-radius:24px;border-radius:24px}.fs-switch.fs-round.fs-off .fs-toggle{left:-1px}.fs-switch.fs-round.fs-on{background:#0085ba}.fs-switch.fs-round.fs-on .fs-toggle{left:25px}.fs-switch.fs-small.fs-round{padding:1px 19px}.fs-switch.fs-small.fs-round .fs-toggle{top:0;width:18px;height:18px;-moz-border-radius:18px;-webkit-border-radius:18px;border-radius:18px}.fs-switch.fs-small.fs-round.fs-on .fs-toggle{left:19px}.fs-switch-feedback{margin-left:10px}.fs-switch-feedback.success{color:#71ae00}.rtl .fs-switch-feedback{margin-left:0;margin-right:10px}#fs_frame{line-height:0;font-size:0}.fs-full-size-wrapper{margin:40px 0 -65px -20px}@media (max-width: 600px){.fs-full-size-wrapper{margin:0 0 -65px -10px}}
.fs-notice{position:relative}.fs-notice.fs-has-title{margin-bottom:30px !important}.fs-notice.success{color:green}.fs-notice.promotion{border-color:#00a0d2 !important;background-color:#f2fcff !important}.fs-notice .fs-notice-body{margin:.5em 0;padding:2px}.fs-notice .fs-close{cursor:pointer;color:#aaa;float:right}.fs-notice .fs-close:hover{color:#666}.fs-notice .fs-close>*{margin-top:7px;display:inline-block}.fs-notice label.fs-plugin-title{background:rgba(0,0,0,0.3);color:#fff;padding:2px 10px;position:absolute;top:100%;bottom:auto;right:auto;-moz-border-radius:0 0 3px 3px;-webkit-border-radius:0 0 3px 3px;border-radius:0 0 3px 3px;left:10px;font-size:12px;font-weight:bold;cursor:auto}div.fs-notice.updated,div.fs-notice.success,div.fs-notice.promotion{display:block !important}.rtl .fs-notice .fs-close{float:left}.fs-secure-notice{position:fixed;top:32px;left:160px;right:0;background:#ebfdeb;padding:10px 20px;color:green;z-index:9999;-moz-box-shadow:0 2px 2px rgba(6,113,6,0.3);-webkit-box-shadow:0 2px 2px rgba(6,113,6,0.3);box-shadow:0 2px 2px rgba(6,113,6,0.3);opacity:0.95;filter:alpha(opacity=95)}.fs-secure-notice:hover{opacity:1;filter:alpha(opacity=100)}.fs-secure-notice a.fs-security-proof{color:green;text-decoration:none}@media screen and (max-width: 960px){.fs-secure-notice{left:36px}}@media screen and (max-width: 600px){.fs-secure-notice{display:none}}@media screen and (max-width: 500px){#fs_promo_tab{display:none}}@media screen and (max-width: 782px){.fs-secure-notice{left:0;top:46px;text-align:center}}span.fs-submenu-item.fs-sub:before{content:'\21B3';padding:0 5px}.rtl span.fs-submenu-item.fs-sub:before{content:'\21B2'}.fs-submenu-item.pricing.upgrade-mode{color:greenyellow}.fs-submenu-item.pricing.trial-mode{color:#83e2ff}#adminmenu .update-plugins.fs-trial{background-color:#00b9eb}.fs-ajax-spinner{border:0;width:20px;height:20px;margin-right:5px;vertical-align:sub;display:inline-block;background:url("/wp-admin/images/wpspin_light-2x.gif");background-size:contain;margin-bottom:-2px}.wrap.fs-section h2{text-align:left}.plugins p.fs-upgrade-notice{border:0;background-color:#d54e21;padding:10px;color:#f9f9f9;margin-top:10px}
#fs_connect{width:480px;-moz-box-shadow:0px 1px 2px rgba(0,0,0,0.3);-webkit-box-shadow:0px 1px 2px rgba(0,0,0,0.3);box-shadow:0px 1px 2px rgba(0,0,0,0.3);margin:20px 0}@media screen and (max-width: 479px){#fs_connect{-moz-box-shadow:none;-webkit-box-shadow:none;box-shadow:none;width:auto;margin:0 0 0 -10px}}#fs_connect .fs-content{background:#fff;padding:15px 20px}#fs_connect .fs-content .fs-error{background:snow;color:#d3135a;border:1px solid #d3135a;-moz-box-shadow:0 1px 1px 0 rgba(0,0,0,0.1);-webkit-box-shadow:0 1px 1px 0 rgba(0,0,0,0.1);box-shadow:0 1px 1px 0 rgba(0,0,0,0.1);text-align:center;padding:5px;margin-bottom:10px}#fs_connect .fs-content p{margin:0;padding:0;font-size:1.2em}#fs_connect .fs-license-key-container{position:relative;width:280px;margin:10px auto 0 auto}#fs_connect .fs-license-key-container input{width:100%}#fs_connect .fs-license-key-container .dashicons{position:absolute;top:5px;right:5px}#fs_connect.require-license-key .fs-sites-list-container td{cursor:pointer}#fs_connect #delegate_to_site_admins{margin-right:15px;float:right;height:26px;vertical-align:middle;line-height:37px;font-weight:bold;border-bottom:1px dashed;text-decoration:none}#fs_connect #delegate_to_site_admins.rtl{margin-left:15px;margin-right:0}#fs_connect .fs-actions{padding:10px 20px;background:#C0C7CA}#fs_connect .fs-actions .button{padding:0 10px 1px;line-height:35px;height:37px;font-size:16px;margin-bottom:0}#fs_connect .fs-actions .button .dashicons{font-size:37px;margin-left:-8px;margin-right:12px}#fs_connect .fs-actions .button.button-primary{padding-right:15px;padding-left:15px}#fs_connect .fs-actions .button.button-primary:after{content:' \279C'}#fs_connect .fs-actions .button.button-primary.fs-loading:after{content:''}#fs_connect .fs-actions .button.button-secondary{float:right}#fs_connect.fs-anonymous-disabled .fs-actions .button.button-primary{width:100%}#fs_connect .fs-permissions{padding:10px 20px;background:#FEFEFE;-moz-transition:background 0.5s ease;-o-transition:background 0.5s ease;-ms-transition:background 0.5s ease;-webkit-transition:background 0.5s ease;transition:background 0.5s ease}#fs_connect .fs-permissions .fs-license-sync-disclaimer{text-align:center;margin-top:0}#fs_connect .fs-permissions .fs-trigger{font-size:0.9em;text-decoration:none;text-align:center;display:block}#fs_connect .fs-permissions ul{height:0;overflow:hidden;margin:0}#fs_connect .fs-permissions ul li{margin-bottom:12px}#fs_connect .fs-permissions ul li:last-child{margin-bottom:0}#fs_connect .fs-permissions ul li i.dashicons{float:left;font-size:40px;width:40px;height:40px}#fs_connect .fs-permissions ul li .fs-switch{float:right}#fs_connect .fs-permissions ul li .fs-permission-description{margin-left:55px}#fs_connect .fs-permissions ul li .fs-permission-description span{font-weight:bold;text-transform:uppercase;color:#23282d}#fs_connect .fs-permissions ul li .fs-permission-description p{margin:2px 0 0 0}#fs_connect .fs-permissions.fs-open{background:#fff}#fs_connect .fs-permissions.fs-open ul{height:auto;margin:20px 20px 10px 20px}@media screen and (max-width: 479px){#fs_connect .fs-permissions{background:#fff}#fs_connect .fs-permissions .fs-trigger{display:none}#fs_connect .fs-permissions ul{height:auto;margin:20px}}#fs_connect .fs-freemium-licensing{padding:8px;background:#777;color:#fff}#fs_connect .fs-freemium-licensing p{text-align:center;display:block;margin:0;padding:0}#fs_connect .fs-freemium-licensing a{color:#C2EEFF;text-decoration:underline}#fs_connect .fs-visual{padding:12px;line-height:0;background:#fafafa;height:80px;position:relative}#fs_connect .fs-visual .fs-site-icon{position:absolute;left:20px;top:10px}#fs_connect .fs-visual .fs-connect-logo{position:absolute;right:20px;top:10px}#fs_connect .fs-visual .fs-plugin-icon{position:absolute;top:10px;left:50%;margin-left:-40px}#fs_connect .fs-visual .fs-plugin-icon,#fs_connect .fs-visual .fs-site-icon,#fs_connect .fs-visual img,#fs_connect .fs-visual object{width:80px;height:80px}#fs_connect .fs-visual .dashicons-wordpress{font-size:64px;background:#01749a;color:#fff;width:64px;height:64px;padding:8px}#fs_connect .fs-visual .dashicons-plus{position:absolute;top:50%;font-size:30px;margin-top:-10px;color:#bbb}#fs_connect .fs-visual .dashicons-plus.fs-first{left:28%}#fs_connect .fs-visual .dashicons-plus.fs-second{left:65%}#fs_connect .fs-visual .fs-plugin-icon,#fs_connect .fs-visual .fs-connect-logo,#fs_connect .fs-visual .fs-site-icon{border:1px solid #ccc;padding:1px;background:#fff}#fs_connect .fs-terms{text-align:center;font-size:0.85em;padding:5px;background:rgba(0,0,0,0.05)}#fs_connect .fs-terms,#fs_connect .fs-terms a{color:#999}#fs_connect .fs-terms a{text-decoration:none}.fs-multisite-options-container{margin-top:10px;border:1px solid #ccc;padding:5px}.fs-multisite-options-container a{text-decoration:none}.fs-multisite-options-container a:focus{box-shadow:none}.fs-multisite-options-container a.selected{font-weight:bold}.fs-multisite-options-container.fs-apply-on-all-sites{border:0 none;padding:0}.fs-multisite-options-container.fs-apply-on-all-sites .fs-all-sites-options{border-spacing:0}.fs-multisite-options-container.fs-apply-on-all-sites .fs-all-sites-options td:not(:first-child){display:none}.fs-multisite-options-container .fs-sites-list-container{display:none;overflow:auto}.fs-multisite-options-container .fs-sites-list-container table td{border-top:1px solid #ccc;padding:4px 2px}.fs-tooltip-trigger{position:relative}.fs-tooltip-trigger:not(a){cursor:help}.fs-tooltip-trigger .fs-tooltip{opacity:0;visibility:hidden;-moz-transition:opacity 0.3s ease-in-out;-o-transition:opacity 0.3s ease-in-out;-ms-transition:opacity 0.3s ease-in-out;-webkit-transition:opacity 0.3s ease-in-out;transition:opacity 0.3s ease-in-out;position:absolute;background:rgba(0,0,0,0.8);color:#fff;font-family:'arial', serif;font-size:12px;padding:10px;z-index:999999;bottom:100%;margin-bottom:5px;left:0;right:0;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;-moz-box-shadow:1px 1px 1px rgba(0,0,0,0.2);-webkit-box-shadow:1px 1px 1px rgba(0,0,0,0.2);box-shadow:1px 1px 1px rgba(0,0,0,0.2);line-height:1.3em;font-weight:bold;text-align:left}.rtl .fs-tooltip-trigger .fs-tooltip{text-align:right}.fs-tooltip-trigger .fs-tooltip::after{content:' ';display:block;width:0;height:0;border-style:solid;border-width:5px 5px 0 5px;border-color:rgba(0,0,0,0.8) transparent transparent transparent;position:absolute;top:100%;left:21px}.rtl .fs-tooltip-trigger .fs-tooltip::after{right:21px;left:auto}.fs-tooltip-trigger:hover .fs-tooltip{visibility:visible;opacity:1}#fs_marketing_optin{display:none;margin-top:10px;border:1px solid #ccc;padding:10px;line-height:1.5em}#fs_marketing_optin .fs-message{display:block;margin-bottom:5px;font-size:1.05em;font-weight:600}#fs_marketing_optin.error{border:1px solid #d3135a;background:#fee}#fs_marketing_optin.error .fs-message{color:#d3135a}#fs_marketing_optin .fs-input-container{margin-top:5px}#fs_marketing_optin .fs-input-container label{margin-top:5px;display:block}#fs_marketing_optin .fs-input-container label input{float:left;margin:1px 0 0 0}#fs_marketing_optin .fs-input-container label:first-child{display:block;margin-bottom:2px}#fs_marketing_optin .fs-input-label{display:block;margin-left:20px}#fs_marketing_optin .fs-input-label .underlined{text-decoration:underline}.rtl #fs_marketing_optin .fs-input-container label input{float:right}.rtl #fs_marketing_optin .fs-input-label{margin-left:0;margin-right:20px}.rtl #fs_connect .fs-actions{padding:10px 20px;background:#C0C7CA}.rtl #fs_connect .fs-actions .button .dashicons{font-size:37px;margin-left:-8px;margin-right:12px}.rtl #fs_connect .fs-actions .button.button-primary:after{content:' \000bb'}.rtl #fs_connect .fs-actions .button.button-primary.fs-loading:after{content:''}.rtl #fs_connect .fs-actions .button.button-secondary{float:left}.rtl #fs_connect .fs-permissions ul li .fs-permission-description{margin-right:55px;margin-left:0}.rtl #fs_connect .fs-permissions ul li .fs-switch{float:left}.rtl #fs_connect .fs-permissions ul li i.dashicons{float:right}.rtl #fs_connect .fs-visual .fs-site-icon{right:20px;left:auto}.rtl #fs_connect .fs-visual .fs-connect-logo{right:auto;left:20px}#fs_theme_connect_wrapper{position:fixed;top:0;height:100%;width:100%;z-index:99990;background:rgba(0,0,0,0.75);text-align:center;overflow-y:auto}#fs_theme_connect_wrapper:before{content:"";display:inline-block;vertical-align:middle;height:100%}#fs_theme_connect_wrapper>button.close{color:white;cursor:pointer;height:40px;width:40px;position:absolute;right:0;border:0;background-color:transparent;top:32px}#fs_theme_connect_wrapper #fs_connect{top:0;text-align:left;display:inline-block;vertical-align:middle;margin-top:52px;margin-bottom:20px}#fs_theme_connect_wrapper #fs_connect .fs-terms{background:rgba(140,140,140,0.64)}#fs_theme_connect_wrapper #fs_connect .fs-terms,#fs_theme_connect_wrapper #fs_connect .fs-terms a{color:#c5c5c5}.wp-pointer-content #fs_connect{margin:0;-moz-box-shadow:none;-webkit-box-shadow:none;box-shadow:none}.fs-opt-in-pointer .wp-pointer-content{padding:0}.fs-opt-in-pointer.wp-pointer-top .wp-pointer-arrow{border-bottom-color:#dfdfdf}.fs-opt-in-pointer.wp-pointer-top .wp-pointer-arrow-inner{border-bottom-color:#fafafa}.fs-opt-in-pointer.wp-pointer-bottom .wp-pointer-arrow{border-top-color:#dfdfdf}.fs-opt-in-pointer.wp-pointer-bottom .wp-pointer-arrow-inner{border-top-color:#fafafa}.fs-opt-in-pointer.wp-pointer-left .wp-pointer-arrow{border-right-color:#dfdfdf}.fs-opt-in-pointer.wp-pointer-left .wp-pointer-arrow-inner{border-right-color:#fafafa}.fs-opt-in-pointer.wp-pointer-right .wp-pointer-arrow{border-left-color:#dfdfdf}.fs-opt-in-pointer.wp-pointer-right .wp-pointer-arrow-inner{border-left-color:#fafafa}
.fs-switch-label{font-size:20px;line-height:31px;margin:0 5px}#fs_log_book table{font-family:Consolas,Monaco,monospace;font-size:12px}#fs_log_book table th{color:#ccc}#fs_log_book table tr{background:#232525}#fs_log_book table tr.alternate{background:#2b2b2b}#fs_log_book table tr td.fs-col--logger{color:#5a7435}#fs_log_book table tr td.fs-col--type{color:#ffc861}#fs_log_book table tr td.fs-col--function{color:#a7b7b1;font-weight:bold}#fs_log_book table tr td.fs-col--message,#fs_log_book table tr td.fs-col--message a{color:#9a73ac !important}#fs_log_book table tr td.fs-col--file{color:#d07922}#fs_log_book table tr td.fs-col--timestamp{color:#6596be}
.fs-notice[data-id^="gdpr_optin_actions"] .underlined{text-decoration:underline}.fs-notice[data-id^="gdpr_optin_actions"] ul .button,.fs-notice[data-id^="gdpr_optin_actions"] ul .action-description{vertical-align:middle}.fs-notice[data-id^="gdpr_optin_actions"] ul .action-description{display:inline-block;margin-left:3px}
<?php
// Silence is golden.
// Hide file structure from users on unprotected servers.
\ No newline at end of file
label.fs-tag,span.fs-tag{background:#ffba00;color:#fff;display:inline-block;border-radius:3px;padding:5px;font-size:11px;line-height:11px;vertical-align:baseline}label.fs-tag.fs-warn,span.fs-tag.fs-warn{background:#ffba00}label.fs-tag.fs-info,span.fs-tag.fs-info{background:#00a0d2}label.fs-tag.fs-success,span.fs-tag.fs-success{background:#46b450}label.fs-tag.fs-error,span.fs-tag.fs-error{background:#dc3232}.wp-list-table.plugins .plugin-title span.fs-tag{display:inline-block;margin-left:5px;line-height:10px}
#fs_customizer_upsell .fs-customizer-plan{padding:10px 20px 20px 20px;border-radius:3px;background:#fff}#fs_customizer_upsell .fs-customizer-plan h2{position:relative;margin:0;line-height:2em;text-transform:uppercase}#fs_customizer_upsell .fs-customizer-plan h2 .button-link{top:-2px}#fs_customizer_upsell .fs-feature{position:relative}#fs_customizer_upsell .dashicons-yes{color:#0085ba;font-size:2em;vertical-align:bottom;margin-left:-7px;margin-right:10px}.rtl #fs_customizer_upsell .dashicons-yes{margin-left:10px;margin-right:-7px}#fs_customizer_upsell .dashicons-editor-help{color:#bbb;cursor:help}#fs_customizer_upsell .dashicons-editor-help .fs-feature-desc{opacity:0;visibility:hidden;-moz-transition:opacity 0.3s ease-in-out;-o-transition:opacity 0.3s ease-in-out;-ms-transition:opacity 0.3s ease-in-out;-webkit-transition:opacity 0.3s ease-in-out;transition:opacity 0.3s ease-in-out;position:absolute;background:#000;color:#fff;font-family:'arial', serif;font-size:12px;padding:10px;z-index:999999;bottom:100%;margin-bottom:5px;left:0;right:0;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;-moz-box-shadow:1px 1px 1px rgba(0,0,0,0.2);-webkit-box-shadow:1px 1px 1px rgba(0,0,0,0.2);box-shadow:1px 1px 1px rgba(0,0,0,0.2);line-height:1.3em;font-weight:bold;text-align:left}.rtl #fs_customizer_upsell .dashicons-editor-help .fs-feature-desc{text-align:right}#fs_customizer_upsell .dashicons-editor-help .fs-feature-desc::after{content:' ';display:block;width:0;height:0;border-style:solid;border-width:5px 5px 0 5px;border-color:#000 transparent transparent transparent;position:absolute;top:100%;left:21px}.rtl #fs_customizer_upsell .dashicons-editor-help .fs-feature-desc::after{right:21px;left:auto}#fs_customizer_upsell .dashicons-editor-help:hover .fs-feature-desc{visibility:visible;opacity:1}#fs_customizer_upsell .button-primary{display:block;text-align:center;margin-top:10px}#fs_customizer_support{display:block !important}#fs_customizer_support .button{float:right}#fs_customizer_support .button-group{width:100%;display:block;margin-top:10px}#fs_customizer_support .button-group .button{float:none;width:50%;text-align:center}#customize-theme-controls #accordion-section-freemius_upsell{border-top:1px solid #0085ba !important;border-bottom:1px solid #0085ba !important}#customize-theme-controls #accordion-section-freemius_upsell h3.accordion-section-title{color:#fff;background-color:#0085ba;border-left:4px solid #0085ba;transition:.15s background-color ease-in-out, .15s border-color ease-in-out;outline:none;border-bottom:none !important}#customize-theme-controls #accordion-section-freemius_upsell h3.accordion-section-title:hover{background-color:#008ec2;border-left-color:#0073aa}#customize-theme-controls #accordion-section-freemius_upsell h3.accordion-section-title:after{color:#fff}#customize-theme-controls #accordion-section-freemius_upsell .rtl h3.accordion-section-title{border-left:none;border-right:4px solid #0085ba}#customize-theme-controls #accordion-section-freemius_upsell .rtl h3.accordion-section-title:hover{border-right-color:#0073aa}
<?php
// Silence is golden.
// Hide file structure from users on unprotected servers.
\ No newline at end of file
<?php
// Silence is golden.
// Hide file structure from users on unprotected servers.
\ No newline at end of file
<?php
// Silence is golden.
// Hide file structure from users on unprotected servers.
\ No newline at end of file
<?php
// Silence is golden.
// Hide file structure from users on unprotected servers.
\ No newline at end of file
/*!
* jQuery postMessage - v0.5 - 9/11/2009
* http://benalman.com/projects/jquery-postmessage-plugin/
*
* Copyright (c) 2009 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*
* Non-jQuery fork by Jeff Lee
*
* This fork consists of the following changes:
* 1. Basic code cleanup and restructuring, for legibility.
* 2. The `postMessage` and `receiveMessage` functions can be bound arbitrarily,
* in terms of both function names and object scope. Scope is specified by
* the the "this" context of NoJQueryPostMessageMixin();
* 3. I've removed the check for Opera 9.64, which used `$.browser`. There were
* at least three different GitHub users requesting the removal of this
* "Opera sniff" on the original project's Issues page, so I figured this
* would be a relatively safe change.
* 4. `postMessage` no longer uses `$.param` to serialize messages that are not
* strings. I actually prefer this structure anyway. `receiveMessage` does
* not implement a corresponding deserialization step, and as such it seems
* cleaner and more symmetric to leave both data serialization and
* deserialization to the client.
* 5. The use of `$.isFunction` is replaced by a functionally-identical check.
* 6. The `$:nomunge` YUI option is no longer necessary.
*/
function NoJQueryPostMessageMixin(postBinding, receiveBinding) {
var setMessageCallback, unsetMessageCallback, currentMsgCallback,
intervalId, lastHash, cacheBust = 1;
if (window.postMessage) {
if (window.addEventListener) {
setMessageCallback = function(callback) {
window.addEventListener('message', callback, false);
}
unsetMessageCallback = function(callback) {
window.removeEventListener('message', callback, false);
}
} else {
setMessageCallback = function(callback) {
window.attachEvent('onmessage', callback);
}
unsetMessageCallback = function(callback) {
window.detachEvent('onmessage', callback);
}
}
this[postBinding] = function(message, targetUrl, target) {
if (!targetUrl) {
return;
}
// The browser supports window.postMessage, so call it with a targetOrigin
// set appropriately, based on the targetUrl parameter.
target.postMessage( message, targetUrl.replace( /([^:]+:\/\/[^\/]+).*/, '$1' ) );
}
// Since the browser supports window.postMessage, the callback will be
// bound to the actual event associated with window.postMessage.
this[receiveBinding] = function(callback, sourceOrigin, delay) {
// Unbind an existing callback if it exists.
if (currentMsgCallback) {
unsetMessageCallback(currentMsgCallback);
currentMsgCallback = null;
}
if (!callback) {
return false;
}
// Bind the callback. A reference to the callback is stored for ease of
// unbinding.
currentMsgCallback = setMessageCallback(function(e) {
switch(Object.prototype.toString.call(sourceOrigin)) {
case '[object String]':
if (sourceOrigin !== e.origin) {
return false;
}
break;
case '[object Function]':
if (sourceOrigin(e.origin)) {
return false;
}
break;
}
callback(e);
});
};
} else {
this[postBinding] = function(message, targetUrl, target) {
if (!targetUrl) {
return;
}
// The browser does not support window.postMessage, so set the location
// of the target to targetUrl#message. A bit ugly, but it works! A cache
// bust parameter is added to ensure that repeat messages trigger the
// callback.
target.location = targetUrl.replace( /#.*$/, '' ) + '#' + (+new Date) + (cacheBust++) + '&' + message;
}
// Since the browser sucks, a polling loop will be started, and the
// callback will be called whenever the location.hash changes.
this[receiveBinding] = function(callback, sourceOrigin, delay) {
if (intervalId) {
clearInterval(intervalId);
intervalId = null;
}
if (callback) {
delay = typeof sourceOrigin === 'number'
? sourceOrigin
: typeof delay === 'number'
? delay
: 100;
intervalId = setInterval(function(){
var hash = document.location.hash,
re = /^#?\d+&/;
if ( hash !== lastHash && re.test( hash ) ) {
lastHash = hash;
callback({ data: hash.replace( re, '' ) });
}
}, delay );
}
};
}
return this;
}
\ No newline at end of file
/*
* nojquery-postmessage by Jeff Lee
* a non-jQuery fork of:
*
* jQuery postMessage - v0.5 - 9/11/2009
* http://benalman.com/projects/jquery-postmessage-plugin/
*
* Copyright (c) 2009 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
function NoJQueryPostMessageMixin(g,a){var b,h,e,d,f,c=1;if(window.postMessage){if(window.addEventListener){b=function(i){window.addEventListener("message",i,false)};h=function(i){window.removeEventListener("message",i,false)}}else{b=function(i){window.attachEvent("onmessage",i)};h=function(i){window.detachEvent("onmessage",i)}}this[g]=function(i,k,j){if(!k){return}j.postMessage(i,k.replace(/([^:]+:\/\/[^\/]+).*/,"$1"))};this[a]=function(k,j,i){if(e){h(e);e=null}if(!k){return false}e=b(function(l){switch(Object.prototype.toString.call(j)){case"[object String]":if(j!==l.origin){return false}break;case"[object Function]":if(j(l.origin)){return false}break}k(l)})}}else{this[g]=function(i,k,j){if(!k){return}j.location=k.replace(/#.*$/,"")+"#"+(+new Date)+(c++)+"&"+i};this[a]=function(k,j,i){if(d){clearInterval(d);d=null}if(k){i=typeof j==="number"?j:typeof i==="number"?i:100;d=setInterval(function(){var m=document.location.hash,l=/^#?\d+&/;if(m!==f&&l.test(m)){f=m;k({data:m.replace(l,"")})}},i)}}}return this};
\ No newline at end of file
(function ($, undef) {
var global = this;
// Namespace.
global.FS = global.FS || {};
global.FS.PostMessage = function ()
{
var
_is_child = false,
_postman = new NoJQueryPostMessageMixin('postMessage', 'receiveMessage'),
_callbacks = {},
_base_url,
_parent_url = decodeURIComponent(document.location.hash.replace(/^#/, '')),
_parent_subdomain = _parent_url.substring(0, _parent_url.indexOf('/', ('https://' === _parent_url.substring(0, ('https://').length)) ? 8 : 7)),
_init = function () {
_postman.receiveMessage(function (e) {
var data = JSON.parse(e.data);
if (_callbacks[data.type]) {
for (var i = 0; i < _callbacks[data.type].length; i++) {
// Execute type callbacks.
_callbacks[data.type][i](data.data);
}
}
}, _base_url);
},
_hasParent = ('' !== _parent_url),
$window = $(window),
$html = $('html');
return {
init : function (url, iframes)
{
_base_url = url;
_init();
// Automatically receive forward messages.
FS.PostMessage.receiveOnce('forward', function (data){
window.location = data.url;
});
iframes = iframes || [];
if (iframes.length > 0) {
$window.on('scroll', function () {
for (var i = 0; i < iframes.length; i++) {
FS.PostMessage.postScroll(iframes[i]);
}
});
}
},
init_child : function ()
{
this.init(_parent_subdomain);
_is_child = true;
// Post height of a child right after window is loaded.
$(window).bind('load', function () {
FS.PostMessage.postHeight();
// Post message that window was loaded.
FS.PostMessage.post('loaded');
});
},
hasParent : function ()
{
return _hasParent;
},
postHeight : function (diff, wrapper) {
diff = diff || 0;
wrapper = wrapper || '#wrap_section';
this.post('height', {
height: diff + $(wrapper).outerHeight(true)
});
},
postScroll : function (iframe) {
this.post('scroll', {
top: $window.scrollTop(),
height: ($window.height() - parseFloat($html.css('paddingTop')) - parseFloat($html.css('marginTop')))
}, iframe);
},
post : function (type, data, iframe)
{
console.debug('PostMessage.post', type);
if (iframe)
{
// Post to iframe.
_postman.postMessage(JSON.stringify({
type: type,
data: data
}), iframe.src, iframe.contentWindow);
}
else {
// Post to parent.
_postman.postMessage(JSON.stringify({
type: type,
data: data
}), _parent_url, window.parent);
}
},
receive: function (type, callback)
{
console.debug('PostMessage.receive', type);
if (undef === _callbacks[type])
_callbacks[type] = [];
_callbacks[type].push(callback);
},
receiveOnce: function (type, callback)
{
if (this.is_set(type))
return;
this.receive(type, callback);
},
// Check if any callbacks assigned to a specified message type.
is_set: function (type)
{
return (undef != _callbacks[type]);
},
parent_url: function ()
{
return _parent_url;
},
parent_subdomain: function ()
{
return _parent_subdomain;
}
};
}();
})(jQuery);
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
<?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;
}
define( 'WP_FS__SECURITY_PARAMS_PREFIX', 's_' );
/**
* Class FS_Security
*/
class FS_Security {
/**
* @var FS_Security
* @since 1.0.3
*/
private static $_instance;
/**
* @var FS_Logger
* @since 1.0.3
*/
private static $_logger;
/**
* @return \FS_Security
*/
public static function instance() {
if ( ! isset( self::$_instance ) ) {
self::$_instance = new FS_Security();
self::$_logger = FS_Logger::get_logger(
WP_FS__SLUG,
WP_FS__DEBUG_SDK,
WP_FS__ECHO_DEBUG_SDK
);
}
return self::$_instance;
}
private function __construct() {
}
/**
* @param \FS_Scope_Entity $entity
* @param int $timestamp
* @param string $action
*
* @return string
*/
function get_secure_token( FS_Scope_Entity $entity, $timestamp, $action = '' ) {
return md5(
$timestamp .
$entity->id .
$entity->secret_key .
$entity->public_key .
$action
);
}
/**
* @param \FS_Scope_Entity $entity
* @param int|bool $timestamp
* @param string $action
*
* @return array
*/
function get_context_params( FS_Scope_Entity $entity, $timestamp = false, $action = '' ) {
if ( false === $timestamp ) {
$timestamp = time();
}
return array(
's_ctx_type' => $entity->get_type(),
's_ctx_id' => $entity->id,
's_ctx_ts' => $timestamp,
's_ctx_secure' => $this->get_secure_token( $entity, $timestamp, $action ),
);
}
}
<?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 2.1.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class FS_User_Lock
*/
class FS_User_Lock {
/**
* @var int
*/
private $_wp_user_id;
/**
* @var int
*/
private $_thread_id;
#--------------------------------------------------------------------------------
#region Singleton
#--------------------------------------------------------------------------------
/**
* @var FS_User_Lock
*/
private static $_instance;
/**
* @author Vova Feldman (@svovaf)
* @since 2.1.0
*
* @return FS_User_Lock
*/
static function instance() {
if ( ! isset( self::$_instance ) ) {
self::$_instance = new self();
}
return self::$_instance;
}
#endregion
private function __construct() {
$this->_wp_user_id = Freemius::get_current_wp_user_id();
$this->_thread_id = mt_rand( 0, 32000 );
}
/**
* Try to acquire lock. If the lock is already set or is being acquired by another locker, don't do anything.
*
* @author Vova Feldman (@svovaf)
* @since 2.1.0
*
* @param int $expiration
*
* @return bool TRUE if successfully acquired lock.
*/
function try_lock( $expiration = 0 ) {
if ( $this->is_locked() ) {
// Already locked.
return false;
}
set_site_transient( "locked_{$this->_wp_user_id}", $this->_thread_id, $expiration );
if ( $this->has_lock() ) {
set_site_transient( "locked_{$this->_wp_user_id}", true, $expiration );
return true;
}
return false;
}
/**
* Acquire lock regardless if it's already acquired by another locker or not.
*
* @author Vova Feldman (@svovaf)
* @since 2.1.0
*
* @param int $expiration
*/
function lock( $expiration = 0 ) {
set_site_transient( "locked_{$this->_wp_user_id}", true, $expiration );
}
/**
* Checks if lock is currently acquired.
*
* @author Vova Feldman (@svovaf)
* @since 2.1.0
*
* @return bool
*/
function is_locked() {
return ( false !== get_site_transient( "locked_{$this->_wp_user_id}" ) );
}
/**
* Unlock the lock.
*
* @author Vova Feldman (@svovaf)
* @since 2.1.0
*/
function unlock() {
delete_site_transient( "locked_{$this->_wp_user_id}" );
}
/**
* Checks if lock is currently acquired by the current locker.
*
* @return bool
*/
private function has_lock() {
return ( $this->_thread_id == get_site_transient( "locked_{$this->_wp_user_id}" ) );
}
}
\ No newline at end of file
<?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.2.7
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class Zerif_Customizer_Theme_Info_Main
*
* @since 1.0.0
* @access public
*/
class FS_Customizer_Support_Section extends WP_Customize_Section {
function __construct( $manager, $id, $args = array() ) {
$manager->register_section_type( 'FS_Customizer_Support_Section' );
parent::__construct( $manager, $id, $args );
}
/**
* The type of customize section being rendered.
*
* @since 1.0.0
* @access public
* @var string
*/
public $type = 'freemius-support-section';
/**
* @var Freemius
*/
public $fs = null;
/**
* Add custom parameters to pass to the JS via JSON.
*
* @since 1.0.0
*/
public function json() {
$json = parent::json();
$is_contact_visible = $this->fs->is_page_visible( 'contact' );
$is_support_visible = $this->fs->is_page_visible( 'support' );
$json['theme_title'] = $this->fs->get_plugin_name();
if ( $is_contact_visible && $is_support_visible ) {
$json['theme_title'] .= ' ' . $this->fs->get_text_inline( 'Support', 'support' );
}
if ( $is_contact_visible ) {
$json['contact'] = array(
'label' => $this->fs->get_text_inline( 'Contact Us', 'contact-us' ),
'url' => $this->fs->contact_url(),
);
}
if ( $is_support_visible ) {
$json['support'] = array(
'label' => $this->fs->get_text_inline( 'Support Forum', 'support-forum' ),
'url' => $this->fs->get_support_forum_url()
);
}
return $json;
}
/**
* Outputs the Underscore.js template.
*
* @since 1.0.0
*/
protected function render_template() {
?>
<li id="fs_customizer_support"
class="accordion-section control-section control-section-{{ data.type }} cannot-expand">
<h3 class="accordion-section-title">
<span>{{ data.theme_title }}</span>
<# if ( data.contact && data.support ) { #>
<div class="button-group">
<# } #>
<# if ( data.contact ) { #>
<a class="button" href="{{ data.contact.url }}" target="_blank">{{ data.contact.label }} </a>
<# } #>
<# if ( data.support ) { #>
<a class="button" href="{{ data.support.url }}" target="_blank">{{ data.support.label }} </a>
<# } #>
<# if ( data.contact && data.support ) { #>
</div>
<# } #>
</h3>
</li>
<?php
}
}
\ No newline at end of file
<?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.2.7
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class FS_Customizer_Upsell_Control
*/
class FS_Customizer_Upsell_Control extends WP_Customize_Control {
/**
* Control type
*
* @var string control type
*/
public $type = 'freemius-upsell-control';
/**
* @var Freemius
*/
public $fs = null;
/**
* @param WP_Customize_Manager $manager the customize manager class.
* @param string $id id.
* @param array $args customizer manager parameters.
*/
public function __construct( WP_Customize_Manager $manager, $id, array $args ) {
$manager->register_control_type( 'FS_Customizer_Upsell_Control' );
parent::__construct( $manager, $id, $args );
}
/**
* Enqueue resources for the control.
*/
public function enqueue() {
fs_enqueue_local_style( 'fs_customizer', 'customizer.css' );
}
/**
* Json conversion
*/
public function to_json() {
$pricing_cta = esc_html( $this->fs->get_pricing_cta_label() ) . '&nbsp;&nbsp;' . ( is_rtl() ? '&#x2190;' : '&#x27a4;' );
parent::to_json();
$this->json['button_text'] = $pricing_cta;
$this->json['button_url'] = $this->fs->is_in_trial_promotion() ?
$this->fs->get_trial_url() :
$this->fs->get_upgrade_url();
$api = FS_Plugin::is_valid_id( $this->fs->get_bundle_id() ) ?
$this->fs->get_api_bundle_scope() :
$this->fs->get_api_plugin_scope();
// Load features.
$pricing = $api->get( $this->fs->add_show_pending( "pricing.json" ) );
if ( $this->fs->is_api_result_object( $pricing, 'plans' ) ) {
// Add support features.
if ( is_array( $pricing->plans ) && 0 < count( $pricing->plans ) ) {
$support_features = array(
'kb' => 'Help Center',
'forum' => 'Support Forum',
'email' => 'Priority Email Support',
'phone' => 'Phone Support',
'skype' => 'Skype Support',
'is_success_manager' => 'Personal Success Manager',
);
for ( $i = 0, $len = count( $pricing->plans ); $i < $len; $i ++ ) {
if ( 'free' == $pricing->plans[$i]->name ) {
continue;
}
if ( ! isset( $pricing->plans[ $i ]->features ) ||
! is_array( $pricing->plans[ $i ]->features ) ) {
$pricing->plans[$i]->features = array();
}
foreach ( $support_features as $key => $label ) {
$key = ( 'is_success_manager' !== $key ) ?
"support_{$key}" :
$key;
if ( ! empty( $pricing->plans[ $i ]->{$key} ) ) {
$support_feature = new stdClass();
$support_feature->title = $label;
$pricing->plans[ $i ]->features[] = $support_feature;
}
}
}
}
}
$this->json['plans'] = $pricing->plans;
$this->json['strings'] = array(
'plan' => $this->fs->get_text_x_inline( 'Plan', 'as product pricing plan', 'plan' ),
);
}
/**
* Control content
*/
public function content_template() {
?>
<div id="fs_customizer_upsell">
<# if ( data.plans ) { #>
<ul class="fs-customizer-plans">
<# for (i in data.plans) { #>
<# if ( 'free' != data.plans[i].name && (null != data.plans[i].features && 0 < data.plans[i].features.length) ) { #>
<li class="fs-customizer-plan">
<div class="fs-accordion-section-open">
<h2 class="fs-accordion-section-title menu-item">
<span>{{ data.plans[i].title }}</span>
<button type="button" class="button-link item-edit" aria-expanded="true">
<span class="screen-reader-text">Toggle section: {{ data.plans[i].title }} {{ data.strings.plan }}</span>
<span class="toggle-indicator" aria-hidden="true"></span>
</button>
</h2>
<div class="fs-accordion-section-content">
<# if ( data.plans[i].description ) { #>
<h3>{{ data.plans[i].description }}</h3>
<# } #>
<# if ( data.plans[i].features ) { #>
<ul>
<# for ( j in data.plans[i].features ) { #>
<li><div class="fs-feature">
<span class="dashicons dashicons-yes"></span><span><# if ( data.plans[i].features[j].value ) { #>{{ data.plans[i].features[j].value }} <# } #>{{ data.plans[i].features[j].title }}</span>
<# if ( data.plans[i].features[j].description ) { #>
<span class="dashicons dashicons-editor-help"><span class="fs-feature-desc">{{ data.plans[i].features[j].description }}</span></span>
<# } #>
</div></li>
<# } #>
</ul>
<# } #>
<# if ( 'free' != data.plans[i].name ) { #>
<a href="{{ data.button_url }}" class="button button-primary" target="_blank">{{{ data.button_text }}}</a>
<# } #>
</div>
</div>
</li>
<# } #>
<# } #>
</ul>
<# } #>
</div>
<?php }
}
\ No newline at end of file
<?php
// Silence is golden.
// Hide file structure from users on unprotected servers.
\ No newline at end of file
<?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.1.7.3
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Extends Debug Bar plugin by adding a panel to show all Freemius API requests.
*
* @author Vova Feldman (@svovaf)
* @since 1.1.7.3
*
* Class Freemius_Debug_Bar_Panel
*/
class Freemius_Debug_Bar_Panel extends Debug_Bar_Panel {
function init() {
$this->title( 'Freemius' );
}
static function requests_count() {
if ( class_exists( 'Freemius_Api_WordPress' ) ) {
$logger = Freemius_Api_WordPress::GetLogger();
} else {
$logger = array();
}
return number_format( count( $logger ) );
}
static function total_time() {
if ( class_exists( 'Freemius_Api_WordPress' ) ) {
$logger = Freemius_Api_WordPress::GetLogger();
} else {
$logger = array();
}
$total_time = .0;
foreach ( $logger as $l ) {
$total_time += $l['total'];
}
return number_format( 100 * $total_time, 2 ) . ' ' . fs_text_x_inline( 'ms', 'milliseconds' );
}
function render() {
?>
<div id='debug-bar-php'>
<?php fs_require_template( '/debug/api-calls.php' ) ?>
<br>
<?php fs_require_template( '/debug/scheduled-crons.php' ) ?>
<br>
<?php fs_require_template( '/debug/plugins-themes-sync.php' ) ?>
<br>
<?php fs_require_template( '/debug/logger.php' ) ?>
</div>
<?php
}
}
<?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.1.7.3
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! WP_FS__DEBUG_SDK ) {
return;
}
/**
* Initialize Freemius custom debug panels.
*
* @param array $panels Debug bar panels objects
*
* @return array Debug bar panels with your custom panels
*/
function fs_custom_panels_init( $panels ) {
if ( class_exists( 'Debug_Bar_Panel' ) ) {
if ( FS_API__LOGGER_ON ) {
require_once dirname( __FILE__ ) . '/class-fs-debug-bar-panel.php';
$panels[] = new Freemius_Debug_Bar_Panel();
}
}
return $panels;
}
function fs_custom_status_init( $statuses ) {
if ( class_exists( 'Debug_Bar_Panel' ) ) {
if ( FS_API__LOGGER_ON ) {
require_once dirname( __FILE__ ) . '/class-fs-debug-bar-panel.php';
$statuses[] = array(
'fs_api_requests',
fs_text_inline( 'Freemius API' ),
Freemius_Debug_Bar_Panel::requests_count() . ' ' . fs_text_inline( 'Requests' ) .
' (' . Freemius_Debug_Bar_Panel::total_time() . ')'
);
}
}
return $statuses;
}
add_filter( 'debug_bar_panels', 'fs_custom_panels_init' );
add_filter( 'debug_bar_statuses', 'fs_custom_status_init' );
\ No newline at end of file
<?php
// Silence is golden.
// Hide file structure from users on unprotected servers.
\ No newline at end of file
<?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 );
}
}
\ No newline at end of file
<?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 );
}
}
\ No newline at end of file
<?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';
}
}
\ No newline at end of file
<?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();
}
}
\ No newline at end of file
<?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 => '£',
self::CURRENCY_EUR => '€',
);
}
return self::$CURRENCY_2_SYMBOL[ $this->currency ];
}
}
\ No newline at end of file
<?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';
}
}
\ No newline at end of file
<?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;
/**
* @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 ) )
);
}
}
<?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 );
}
}
\ No newline at end of file
<?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 );
}
}
\ No newline at end of file
<?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';
}
}
\ No newline at end of file
<?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 );
}
}
\ No newline at end of file
<?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 );
}
}
\ No newline at end of file
<?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;
/**
* @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' ) ||
// 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' )
);
}
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();
}
}
\ No newline at end of file
<?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 );
}
}
\ No newline at end of file
<?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;
/**
* @author Leo Fajardo (@leorw)
* @since 2.3.0
*
* @var bool
*/
public $is_beta;
/**
* @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 );
}
/**
* @author Leo Fajardo (@leorw)
* @since 2.3.0
*
* @return bool
*/
function is_beta() {
return ( isset( $this->is_beta ) && true === $this->is_beta );
}
static function get_type() {
return 'user';
}
}
\ No newline at end of file
<?php
// Silence is golden.
// Hide file structure from users on unprotected servers.
\ No newline at end of file
<?php
// Silence is golden.
// Hide file structure from users on unprotected servers.
\ No newline at end of file
<?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.1.6
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Retrieve the translation of $text.
*
* @since 1.2.1.6
*
* @param string $text
*
* @return string
*/
function _fs_text( $text ) {
// Avoid misleading Theme Check warning.
$fn = 'translate';
return $fn( $text, 'freemius' );
}
/**
* Retrieve translated string with gettext context.
*
* Quite a few times, there will be collisions with similar translatable text
* found in more than two places, but with different translated context.
*
* By including the context in the pot file, translators can translate the two
* strings differently.
*
* @since 1.2.1.6
*
* @param string $text
* @param string $context
*
* @return string
*/
function _fs_x( $text, $context ) {
// Avoid misleading Theme Check warning.
$fn = 'translate_with_gettext_context';
return $fn( $text, $context, 'freemius' );
}
<?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.1.6
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class FS_Cache_Manager {
/**
* @var FS_Option_Manager
*/
private $_options;
/**
* @var FS_Logger
*/
private $_logger;
/**
* @var FS_Cache_Manager[]
*/
private static $_MANAGERS = array();
/**
* @author Vova Feldman (@svovaf)
* @since 1.1.3
*
* @param string $id
*/
private function __construct( $id ) {
$this->_logger = FS_Logger::get_logger( WP_FS__SLUG . '_cach_mngr_' . $id, WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
$this->_logger->entrance();
$this->_logger->log( 'id = ' . $id );
$this->_options = FS_Option_Manager::get_manager( $id, true, true, false );
}
/**
* @author Vova Feldman (@svovaf)
* @since 1.1.6
*
* @param $id
*
* @return FS_Cache_Manager
*/
static function get_manager( $id ) {
$id = strtolower( $id );
if ( ! isset( self::$_MANAGERS[ $id ] ) ) {
self::$_MANAGERS[ $id ] = new FS_Cache_Manager( $id );
}
return self::$_MANAGERS[ $id ];
}
/**
* @author Vova Feldman (@svovaf)
* @since 1.1.6
*
* @return bool
*/
function is_empty() {
$this->_logger->entrance();
return $this->_options->is_empty();
}
/**
* @author Vova Feldman (@svovaf)
* @since 1.1.6
*/
function clear() {
$this->_logger->entrance();
$this->_options->clear( true );
}
/**
* Delete cache manager from DB.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.9
*/
function delete() {
$this->_options->delete();
}
/**
* Check if there's a cached item.
*
* @author Vova Feldman (@svovaf)
* @since 1.1.6
*
* @param string $key
*
* @return bool
*/
function has( $key ) {
$cache_entry = $this->_options->get_option( $key, false );
return ( is_object( $cache_entry ) &&
isset( $cache_entry->timestamp ) &&
is_numeric( $cache_entry->timestamp )
);
}
/**
* Check if there's a valid cached item.
*
* @author Vova Feldman (@svovaf)
* @since 1.1.6
*
* @param string $key
* @param null|int $expiration Since 1.2.2.7
*
* @return bool
*/
function has_valid( $key, $expiration = null ) {
$cache_entry = $this->_options->get_option( $key, false );
$is_valid = ( is_object( $cache_entry ) &&
isset( $cache_entry->timestamp ) &&
is_numeric( $cache_entry->timestamp ) &&
$cache_entry->timestamp > WP_FS__SCRIPT_START_TIME
);
if ( $is_valid &&
is_numeric( $expiration ) &&
isset( $cache_entry->created ) &&
is_numeric( $cache_entry->created ) &&
$cache_entry->created + $expiration < WP_FS__SCRIPT_START_TIME
) {
/**
* Even if the cache is still valid, since we are checking for validity
* with an explicit expiration period, if the period has past, return
* `false` as if the cache is invalid.
*
* @since 1.2.2.7
*/
$is_valid = false;
}
return $is_valid;
}
/**
* @author Vova Feldman (@svovaf)
* @since 1.1.6
*
* @param string $key
* @param mixed $default
*
* @return mixed
*/
function get( $key, $default = null ) {
$this->_logger->entrance( 'key = ' . $key );
$cache_entry = $this->_options->get_option( $key, false );
if ( is_object( $cache_entry ) &&
isset( $cache_entry->timestamp ) &&
is_numeric( $cache_entry->timestamp )
) {
return $cache_entry->result;
}
return is_object( $default ) ? clone $default : $default;
}
/**
* @author Vova Feldman (@svovaf)
* @since 1.1.6
*
* @param string $key
* @param mixed $default
*
* @return mixed
*/
function get_valid( $key, $default = null ) {
$this->_logger->entrance( 'key = ' . $key );
$cache_entry = $this->_options->get_option( $key, false );
if ( is_object( $cache_entry ) &&
isset( $cache_entry->timestamp ) &&
is_numeric( $cache_entry->timestamp ) &&
$cache_entry->timestamp > WP_FS__SCRIPT_START_TIME
) {
return $cache_entry->result;
}
return is_object( $default ) ? clone $default : $default;
}
/**
* @author Vova Feldman (@svovaf)
* @since 1.1.6
*
* @param string $key
* @param mixed $value
* @param int $expiration
* @param int $created Since 2.0.0 Cache creation date.
*/
function set( $key, $value, $expiration = WP_FS__TIME_24_HOURS_IN_SEC, $created = WP_FS__SCRIPT_START_TIME ) {
$this->_logger->entrance( 'key = ' . $key );
$cache_entry = new stdClass();
$cache_entry->result = $value;
$cache_entry->created = $created;
$cache_entry->timestamp = $created + $expiration;
$this->_options->set_option( $key, $cache_entry, true );
}
/**
* Get cached record expiration, or false if not cached or expired.
*
* @author Vova Feldman (@svovaf)
* @since 1.1.7.3
*
* @param string $key
*
* @return bool|int
*/
function get_record_expiration( $key ) {
$this->_logger->entrance( 'key = ' . $key );
$cache_entry = $this->_options->get_option( $key, false );
if ( is_object( $cache_entry ) &&
isset( $cache_entry->timestamp ) &&
is_numeric( $cache_entry->timestamp ) &&
$cache_entry->timestamp > WP_FS__SCRIPT_START_TIME
) {
return $cache_entry->timestamp;
}
return false;
}
/**
* Purge cached item.
*
* @author Vova Feldman (@svovaf)
* @since 1.1.6
*
* @param string $key
*/
function purge( $key ) {
$this->_logger->entrance( 'key = ' . $key );
$this->_options->unset_option( $key, true );
}
/**
* Extend cached item caching period.
*
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @param string $key
* @param int $expiration
*
* @return bool
*/
function update_expiration( $key, $expiration = WP_FS__TIME_24_HOURS_IN_SEC ) {
$this->_logger->entrance( 'key = ' . $key );
$cache_entry = $this->_options->get_option( $key, false );
if ( ! is_object( $cache_entry ) ||
! isset( $cache_entry->timestamp ) ||
! is_numeric( $cache_entry->timestamp )
) {
return false;
}
$this->set( $key, $cache_entry->result, $expiration, $cache_entry->created );
return true;
}
/**
* Set cached item as expired.
*
* @author Vova Feldman (@svovaf)
* @since 1.2.2.7
*
* @param string $key
*/
function expire( $key ) {
$this->_logger->entrance( 'key = ' . $key );
$cache_entry = $this->_options->get_option( $key, false );
if ( is_object( $cache_entry ) &&
isset( $cache_entry->timestamp ) &&
is_numeric( $cache_entry->timestamp )
) {
// Set to expired.
$cache_entry->timestamp = WP_FS__SCRIPT_START_TIME;
$this->_options->set_option( $key, $cache_entry, true );
}
}
#--------------------------------------------------------------------------------
#region Migration
#--------------------------------------------------------------------------------
/**
* Migrate options from site level.
*
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*/
function migrate_to_network() {
$this->_options->migrate_to_network();
}
#endregion
}
\ No newline at end of file
<?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 2.1.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class FS_GDPR_Manager {
/**
* @var FS_Option_Manager
*/
private $_storage;
/**
* @var array {
* @type bool $required Are GDPR rules apply on the current context admin.
* @type bool $show_opt_in_notice Should the marketing and offers opt-in message be shown to the admin or not. If not set, defaults to `true`.
* @type int $notice_shown_at Last time the special GDPR opt-in message was shown to the current admin.
* }
*/
private $_data;
/**
* @var int
*/
private $_wp_user_id;
/**
* @var string
*/
private $_option_name;
/**
* @var FS_Admin_Notices
*/
private $_notices;
#--------------------------------------------------------------------------------
#region Singleton
#--------------------------------------------------------------------------------
/**
* @var FS_GDPR_Manager
*/
private static $_instance;
/**
* @return FS_GDPR_Manager
*/
public static function instance() {
if ( ! isset( self::$_instance ) ) {
self::$_instance = new self();
}
return self::$_instance;
}
#endregion
private function __construct() {
$this->_storage = FS_Option_Manager::get_manager( WP_FS__GDPR_OPTION_NAME, true, true );
$this->_wp_user_id = Freemius::get_current_wp_user_id();
$this->_option_name = "u{$this->_wp_user_id}";
$this->_data = $this->_storage->get_option( $this->_option_name, array() );
$this->_notices = FS_Admin_Notices::instance( 'all_admins', '', '', true );
if ( ! is_array( $this->_data ) ) {
$this->_data = array();
}
}
/**
* Update a GDPR option for the current admin and store it.
*
* @author Vova Feldman (@svovaf)
* @since 2.1.0
*
* @param string $name
* @param mixed $value
*/
private function update_option( $name, $value ) {
$this->_data[ $name ] = $value;
$this->_storage->set_option( $this->_option_name, $this->_data, true );
}
/**
* @author Leo Fajardo (@leorw)
* @since 2.1.0
*
* @return bool|null
*/
public function is_required() {
return isset( $this->_data['required'] ) ?
$this->_data['required'] :
null;
}
/**
* @author Leo Fajardo (@leorw)
* @since 2.1.0
*
* @param bool $is_required
*/
public function store_is_required( $is_required ) {
$this->update_option( 'required', $is_required );
}
/**
* Checks if the GDPR opt-in sticky notice is currently shown.
*
* @author Vova Feldman (@svovaf)
* @since 2.1.0
*
* @return bool
*/
public function is_opt_in_notice_shown() {
return $this->_notices->has_sticky( "gdpr_optin_actions_{$this->_wp_user_id}", true );
}
/**
* Remove the GDPR opt-in sticky notice.
*
* @author Vova Feldman (@svovaf)
* @since 2.1.0
*/
public function remove_opt_in_notice() {
$this->_notices->remove_sticky( "gdpr_optin_actions_{$this->_wp_user_id}", true );
$this->disable_opt_in_notice();
}
/**
* Prevents the opt-in message from being added/shown.
*
* @author Leo Fajardo (@leorw)
* @since 2.1.0
*/
public function disable_opt_in_notice() {
$this->update_option( 'show_opt_in_notice', false );
}
/**
* Checks if a GDPR opt-in message needs to be shown to the current admin.
*
* @author Vova Feldman (@svovaf)
* @since 2.1.0
*
* @return bool
*/
public function should_show_opt_in_notice() {
return (
! isset( $this->_data['show_opt_in_notice'] ) ||
true === $this->_data['show_opt_in_notice']
);
}
/**
* Get the last time the GDPR opt-in notice was shown.
*
* @author Vova Feldman (@svovaf)
* @since 2.1.0
*
* @return false|int
*/
public function last_time_notice_was_shown() {
return isset( $this->_data['notice_shown_at'] ) ?
$this->_data['notice_shown_at'] :
false;
}
/**
* Update the timestamp of the last time the GDPR opt-in message was shown to now.
*
* @author Vova Feldman (@svovaf)
* @since 2.1.0
*/
public function notice_was_just_shown() {
$this->update_option( 'notice_shown_at', WP_FS__SCRIPT_START_TIME );
}
/**
* @param string $message
* @param string|null $plugin_title
*
* @author Vova Feldman (@svovaf)
* @since 2.1.0
*/
public function add_opt_in_sticky_notice( $message, $plugin_title = null ) {
$this->_notices->add_sticky(
$message,
"gdpr_optin_actions_{$this->_wp_user_id}",
'',
'promotion',
true,
$this->_wp_user_id,
$plugin_title,
true
);
}
}
\ No newline at end of file
<?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.6
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class FS_License_Manager /*extends FS_Abstract_Manager*/
{
//
//
// /**
// * @var FS_License_Manager[]
// */
// private static $_instances = array();
//
// static function instance( Freemius $fs ) {
// $slug = strtolower( $fs->get_slug() );
//
// if ( ! isset( self::$_instances[ $slug ] ) ) {
// self::$_instances[ $slug ] = new FS_License_Manager( $slug, $fs );
// }
//
// return self::$_instances[ $slug ];
// }
//
//// private function __construct($slug) {
//// parent::__construct($slug);
//// }
//
// function entry_id() {
// return 'licenses';
// }
//
// function sync( $id ) {
//
// }
//
// /**
// * @author Vova Feldman (@svovaf)
// * @since 1.0.5
// * @uses FS_Api
// *
// * @param number|bool $plugin_id
// *
// * @return FS_Plugin_License[]|stdClass Licenses or API error.
// */
// function api_get_user_plugin_licenses( $plugin_id = false ) {
// $api = $this->_fs->get_api_user_scope();
//
// if ( ! is_numeric( $plugin_id ) ) {
// $plugin_id = $this->_fs->get_id();
// }
//
// $result = $api->call( "/plugins/{$plugin_id}/licenses.json" );
//
// if ( ! isset( $result->error ) ) {
// for ( $i = 0, $len = count( $result->licenses ); $i < $len; $i ++ ) {
// $result->licenses[ $i ] = new FS_Plugin_License( $result->licenses[ $i ] );
// }
//
// $result = $result->licenses;
// }
//
// return $result;
// }
//
// function api_get_many() {
//
// }
//
// function api_activate( $id ) {
//
// }
//
// function api_deactivate( $id ) {
//
// }
/**
* @param FS_Plugin_License[] $licenses
*
* @return bool
*/
static function has_premium_license( $licenses ) {
if ( is_array( $licenses ) ) {
foreach ( $licenses as $license ) {
/**
* @var FS_Plugin_License $license
*/
if ( ! $license->is_utilized() && $license->is_features_enabled() ) {
return true;
}
}
}
return false;
}
}
\ No newline at end of file
<?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.6
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class FS_Plan_Manager {
/**
* @var FS_Plan_Manager
*/
private static $_instance;
/**
* @return FS_Plan_Manager
*/
static function instance() {
if ( ! isset( self::$_instance ) ) {
self::$_instance = new FS_Plan_Manager();
}
return self::$_instance;
}
private function __construct() {
}
/**
* @param FS_Plugin_License[] $licenses
*
* @return bool
*/
function has_premium_license( $licenses ) {
if ( is_array( $licenses ) ) {
/**
* @var FS_Plugin_License[] $licenses
*/
foreach ( $licenses as $license ) {
if ( ! $license->is_utilized() && $license->is_features_enabled() ) {
return true;
}
}
}
return false;
}
/**
* Check if plugin has any paid plans.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.7
*
* @param FS_Plugin_Plan[] $plans
*
* @return bool
*/
function has_paid_plan( $plans ) {
if ( ! is_array( $plans ) || 0 === count( $plans ) ) {
return false;
}
/**
* @var FS_Plugin_Plan[] $plans
*/
for ( $i = 0, $len = count( $plans ); $i < $len; $i ++ ) {
if ( ! $plans[ $i ]->is_free() ) {
return true;
}
}
return false;
}
/**
* Check if plugin has any free plan, or is it premium only.
*
* Note: If no plans configured, assume plugin is free.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.7
*
* @param FS_Plugin_Plan[] $plans
*
* @return bool
*/
function has_free_plan( $plans ) {
if ( ! is_array( $plans ) || 0 === count( $plans ) ) {
return true;
}
/**
* @var FS_Plugin_Plan[] $plans
*/
for ( $i = 0, $len = count( $plans ); $i < $len; $i ++ ) {
if ( $plans[ $i ]->is_free() ) {
return true;
}
}
return false;
}
/**
* Find all plans that have trial.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.9
*
* @param FS_Plugin_Plan[] $plans
*
* @return FS_Plugin_Plan[]
*/
function get_trial_plans( $plans ) {
$trial_plans = array();
if ( is_array( $plans ) && 0 < count( $plans ) ) {
/**
* @var FS_Plugin_Plan[] $plans
*/
for ( $i = 0, $len = count( $plans ); $i < $len; $i ++ ) {
if ( $plans[ $i ]->has_trial() ) {
$trial_plans[] = $plans[ $i ];
}
}
}
return $trial_plans;
}
/**
* Check if plugin has any trial plan.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.9
*
* @param FS_Plugin_Plan[] $plans
*
* @return bool
*/
function has_trial_plan( $plans ) {
if ( ! is_array( $plans ) || 0 === count( $plans ) ) {
return true;
}
/**
* @var FS_Plugin_Plan[] $plans
*/
for ( $i = 0, $len = count( $plans ); $i < $len; $i ++ ) {
if ( $plans[ $i ]->has_trial() ) {
return true;
}
}
return false;
}
}
\ No newline at end of file
<?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.6
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class FS_Plugin_Manager {
/**
* @since 1.2.2
*
* @var string|number
*/
protected $_module_id;
/**
* @since 1.2.2
*
* @var FS_Plugin
*/
protected $_module;
/**
* @var FS_Plugin_Manager[]
*/
private static $_instances = array();
/**
* @var FS_Logger
*/
protected $_logger;
/**
* Option names
*
* @author Leo Fajardo (@leorw)
* @since 1.2.2
*/
const OPTION_NAME_PLUGINS = 'plugins';
const OPTION_NAME_THEMES = 'themes';
/**
* @param string|number $module_id
*
* @return FS_Plugin_Manager
*/
static function instance( $module_id ) {
$key = 'm_' . $module_id;
if ( ! isset( self::$_instances[ $key ] ) ) {
self::$_instances[ $key ] = new FS_Plugin_Manager( $module_id );
}
return self::$_instances[ $key ];
}
/**
* @param string|number $module_id
*/
protected function __construct( $module_id ) {
$this->_logger = FS_Logger::get_logger( WP_FS__SLUG . '_' . $module_id . '_' . 'plugins', WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
$this->_module_id = $module_id;
$this->load();
}
protected function get_option_manager() {
return FS_Option_Manager::get_manager( WP_FS__ACCOUNTS_OPTION_NAME, true, true );
}
/**
* @author Leo Fajardo (@leorw)
* @since 1.2.2
*
* @param string|bool $module_type "plugin", "theme", or "false" for all modules.
*
* @return array
*/
protected function get_all_modules( $module_type = false ) {
$option_manager = $this->get_option_manager();
if ( false !== $module_type ) {
return fs_get_entities( $option_manager->get_option( $module_type . 's', array() ), FS_Plugin::get_class_name() );
}
return array(
self::OPTION_NAME_PLUGINS => fs_get_entities( $option_manager->get_option( self::OPTION_NAME_PLUGINS, array() ), FS_Plugin::get_class_name() ),
self::OPTION_NAME_THEMES => fs_get_entities( $option_manager->get_option( self::OPTION_NAME_THEMES, array() ), FS_Plugin::get_class_name() ),
);
}
/**
* Load plugin data from local DB.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.6
*/
function load() {
$all_modules = $this->get_all_modules();
if ( ! is_numeric( $this->_module_id ) ) {
unset( $all_modules[ self::OPTION_NAME_THEMES ] );
}
foreach ( $all_modules as $modules ) {
/**
* @since 1.2.2
*
* @var $modules FS_Plugin[]
*/
foreach ( $modules as $module ) {
$found_module = false;
/**
* If module ID is not numeric, it must be a plugin's slug.
*
* @author Leo Fajardo (@leorw)
* @since 1.2.2
*/
if ( ! is_numeric( $this->_module_id ) ) {
if ( $this->_module_id === $module->slug ) {
$this->_module_id = $module->id;
$found_module = true;
}
} else if ( $this->_module_id == $module->id ) {
$found_module = true;
}
if ( $found_module ) {
$this->_module = $module;
break;
}
}
}
}
/**
* Store plugin on local DB.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.6
*
* @param bool|FS_Plugin $module
* @param bool $flush
*
* @return bool|\FS_Plugin
*/
function store( $module = false, $flush = true ) {
if ( false !== $module ) {
$this->_module = $module;
}
$all_modules = $this->get_all_modules( $this->_module->type );
$all_modules[ $this->_module->slug ] = $this->_module;
$options_manager = $this->get_option_manager();
$options_manager->set_option( $this->_module->type . 's', $all_modules, $flush );
return $this->_module;
}
/**
* Update local plugin data if different.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.6
*
* @param \FS_Plugin $plugin
* @param bool $store
*
* @return bool True if plugin was updated.
*/
function update( FS_Plugin $plugin, $store = true ) {
if ( ! ($this->_module instanceof FS_Plugin ) ||
$this->_module->slug != $plugin->slug ||
$this->_module->public_key != $plugin->public_key ||
$this->_module->secret_key != $plugin->secret_key ||
$this->_module->parent_plugin_id != $plugin->parent_plugin_id ||
$this->_module->title != $plugin->title
) {
$this->store( $plugin, $store );
return true;
}
return false;
}
/**
* @author Vova Feldman (@svovaf)
* @since 1.0.6
*
* @param FS_Plugin $plugin
* @param bool $store
*/
function set( FS_Plugin $plugin, $store = false ) {
$this->_module = $plugin;
if ( $store ) {
$this->store();
}
}
/**
* @author Vova Feldman (@svovaf)
* @since 1.0.6
*
* @return bool|\FS_Plugin
*/
function get() {
return isset( $this->_module ) ?
$this->_module :
false;
}
}
\ No newline at end of file
<?php
// Silence is golden.
// Hide file structure from users on unprotected servers.
\ No newline at end of file
<?php
if ( ! class_exists( 'Freemius_InvalidArgumentException' ) ) {
exit;
}
if ( ! class_exists( 'Freemius_ArgumentNotExistException' ) ) {
class Freemius_ArgumentNotExistException extends Freemius_InvalidArgumentException {
}
}
\ No newline at end of file
<?php
if ( ! class_exists( 'Freemius_InvalidArgumentException' ) ) {
exit;
}
if ( ! class_exists( 'Freemius_EmptyArgumentException' ) ) {
class Freemius_EmptyArgumentException extends Freemius_InvalidArgumentException {
}
}
\ No newline at end of file
<?php
if ( ! class_exists( 'Freemius_Exception' ) ) {
/**
* Thrown when an API call returns an exception.
*
*/
class Freemius_Exception extends Exception {
protected $_result;
protected $_type;
protected $_code;
/**
* Make a new API Exception with the given result.
*
* @param array $result The result from the API server.
*/
public function __construct( $result ) {
$this->_result = $result;
$code = 0;
$message = 'Unknown error, please check GetResult().';
$type = '';
if ( isset( $result['error'] ) && is_array( $result['error'] ) ) {
if ( isset( $result['error']['code'] ) ) {
$code = $result['error']['code'];
}
if ( isset( $result['error']['message'] ) ) {
$message = $result['error']['message'];
}
if ( isset( $result['error']['type'] ) ) {
$type = $result['error']['type'];
}
}
$this->_type = $type;
$this->_code = $code;
parent::__construct( $message, is_numeric( $code ) ? $code : 0 );
}
/**
* Return the associated result object returned by the API server.
*
* @return array The result from the API server
*/
public function getResult() {
return $this->_result;
}
public function getStringCode() {
return $this->_code;
}
public function getType() {
return $this->_type;
}
/**
* To make debugging easier.
*
* @return string The string representation of the error
*/
public function __toString() {
$str = $this->getType() . ': ';
if ( $this->code != 0 ) {
$str .= $this->getStringCode() . ': ';
}
return $str . $this->getMessage();
}
}
}
\ No newline at end of file
<?php
if ( ! class_exists( 'Freemius_Exception' ) ) {
exit;
}
if ( ! class_exists( 'Freemius_InvalidArgumentException' ) ) {
class Freemius_InvalidArgumentException extends Freemius_Exception { }
}
\ No newline at end of file
<?php
if ( ! class_exists( 'Freemius_Exception' ) ) {
exit;
}
if ( ! class_exists( 'Freemius_OAuthException' ) ) {
class Freemius_OAuthException extends Freemius_Exception {
public function __construct( $pResult ) {
parent::__construct( $pResult );
}
}
}
\ No newline at end of file
<?php
// Silence is golden.
// Hide file structure from users on unprotected servers.
\ No newline at end of file
<?php
/**
* Copyright 2014 Freemius, Inc.
*
* Licensed under the GPL v2 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://choosealicense.com/licenses/gpl-v2/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
if ( ! defined( 'FS_API__VERSION' ) ) {
define( 'FS_API__VERSION', '1' );
}
if ( ! defined( 'FS_SDK__PATH' ) ) {
define( 'FS_SDK__PATH', dirname( __FILE__ ) );
}
if ( ! defined( 'FS_SDK__EXCEPTIONS_PATH' ) ) {
define( 'FS_SDK__EXCEPTIONS_PATH', FS_SDK__PATH . '/Exceptions/' );
}
if ( ! function_exists( 'json_decode' ) ) {
throw new Exception( 'Freemius needs the JSON PHP extension.' );
}
// Include all exception files.
$exceptions = array(
'Exception',
'InvalidArgumentException',
'ArgumentNotExistException',
'EmptyArgumentException',
'OAuthException'
);
foreach ( $exceptions as $e ) {
require_once FS_SDK__EXCEPTIONS_PATH . $e . '.php';
}
if ( class_exists( 'Freemius_Api_Base' ) ) {
return;
}
abstract class Freemius_Api_Base {
const VERSION = '1.0.4';
const FORMAT = 'json';
protected $_id;
protected $_public;
protected $_secret;
protected $_scope;
protected $_isSandbox;
/**
* @param string $pScope 'app', 'developer', 'plugin', 'user' or 'install'.
* @param number $pID Element's id.
* @param string $pPublic Public key.
* @param string $pSecret Element's secret key.
* @param bool $pIsSandbox Whether or not to run API in sandbox mode.
*/
public function Init( $pScope, $pID, $pPublic, $pSecret, $pIsSandbox = false ) {
$this->_id = $pID;
$this->_public = $pPublic;
$this->_secret = $pSecret;
$this->_scope = $pScope;
$this->_isSandbox = $pIsSandbox;
}
public function IsSandbox() {
return $this->_isSandbox;
}
function CanonizePath( $pPath ) {
$pPath = trim( $pPath, '/' );
$query_pos = strpos( $pPath, '?' );
$query = '';
if ( false !== $query_pos ) {
$query = substr( $pPath, $query_pos );
$pPath = substr( $pPath, 0, $query_pos );
}
// Trim '.json' suffix.
$format_length = strlen( '.' . self::FORMAT );
$start = $format_length * ( - 1 ); //negative
if ( substr( strtolower( $pPath ), $start ) === ( '.' . self::FORMAT ) ) {
$pPath = substr( $pPath, 0, strlen( $pPath ) - $format_length );
}
switch ( $this->_scope ) {
case 'app':
$base = '/apps/' . $this->_id;
break;
case 'developer':
$base = '/developers/' . $this->_id;
break;
case 'user':
$base = '/users/' . $this->_id;
break;
case 'plugin':
$base = '/plugins/' . $this->_id;
break;
case 'install':
$base = '/installs/' . $this->_id;
break;
default:
throw new Freemius_Exception( 'Scope not implemented.' );
}
return '/v' . FS_API__VERSION . $base .
( ! empty( $pPath ) ? '/' : '' ) . $pPath .
( ( false === strpos( $pPath, '.' ) ) ? '.' . self::FORMAT : '' ) . $query;
}
abstract function MakeRequest( $pCanonizedPath, $pMethod = 'GET', $pParams = array() );
/**
* @param string $pPath
* @param string $pMethod
* @param array $pParams
*
* @return object[]|object|null
*/
private function _Api( $pPath, $pMethod = 'GET', $pParams = array() ) {
$pMethod = strtoupper( $pMethod );
try {
$result = $this->MakeRequest( $pPath, $pMethod, $pParams );
} catch ( Freemius_Exception $e ) {
// Map to error object.
$result = (object) $e->getResult();
} catch ( Exception $e ) {
// Map to error object.
$result = (object) array(
'error' => array(
'type' => 'Unknown',
'message' => $e->getMessage() . ' (' . $e->getFile() . ': ' . $e->getLine() . ')',
'code' => 'unknown',
'http' => 402
)
);
}
return $result;
}
public function Api( $pPath, $pMethod = 'GET', $pParams = array() ) {
return $this->_Api( $this->CanonizePath( $pPath ), $pMethod, $pParams );
}
/**
* Base64 decoding that does not need to be urldecode()-ed.
*
* Exactly the same as PHP base64 encode except it uses
* `-` instead of `+`
* `_` instead of `/`
* No padded =
*
* @param string $input Base64UrlEncoded() string
*
* @return string
*/
protected static function Base64UrlDecode( $input ) {
/**
* IMPORTANT NOTE:
* This is a hack suggested by @otto42 and @greenshady from
* the theme's review team. The usage of base64 for API
* signature encoding was approved in a Slack meeting
* held on Tue (10/25 2016).
*
* @todo Remove this hack once the base64 error is removed from the Theme Check.
*
* @since 1.2.2
* @author Vova Feldman (@svovaf)
*/
$fn = 'base64' . '_decode';
return $fn( strtr( $input, '-_', '+/' ) );
}
/**
* Base64 encoding that does not need to be urlencode()ed.
*
* Exactly the same as base64 encode except it uses
* `-` instead of `+
* `_` instead of `/`
*
* @param string $input string
*
* @return string Base64 encoded string
*/
protected static function Base64UrlEncode( $input ) {
/**
* IMPORTANT NOTE:
* This is a hack suggested by @otto42 and @greenshady from
* the theme's review team. The usage of base64 for API
* signature encoding was approved in a Slack meeting
* held on Tue (10/25 2016).
*
* @todo Remove this hack once the base64 error is removed from the Theme Check.
*
* @since 1.2.2
* @author Vova Feldman (@svovaf)
*/
$fn = 'base64' . '_encode';
$str = strtr( $fn( $input ), '+/', '-_' );
$str = str_replace( '=', '', $str );
return $str;
}
}
<?php
// Silence is golden.
// Hide file structure from users on unprotected servers.
\ No newline at end of file
<?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.1.7
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Find the plugin main file path based on any given file inside the plugin's folder.
*
* @author Vova Feldman (@svovaf)
* @since 1.1.7.1
*
* @param string $file Absolute path to a file inside a plugin's folder.
*
* @return string
*/
function fs_find_direct_caller_plugin_file( $file ) {
/**
* All the code below will be executed once on activation.
* If the user changes the main plugin's file name, the file_exists()
* will catch it.
*/
$all_plugins = fs_get_plugins( true );
$file_real_path = fs_normalize_path( realpath( $file ) );
// Get active plugin's main files real full names (might be symlinks).
foreach ( $all_plugins as $relative_path => $data ) {
if ( 0 === strpos( $file_real_path, fs_normalize_path( dirname( realpath( WP_PLUGIN_DIR . '/' . $relative_path ) ) ) ) ) {
if ( '.' !== dirname( trailingslashit( $relative_path ) ) ) {
return $relative_path;
}
}
}
return null;
}
<?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 2.2.1
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! function_exists( 'fs_get_plugins' ) ) {
/**
* @author Leo Fajardo (@leorw)
* @since 2.2.1
*
* @param bool $delete_cache
*
* @return array
*/
function fs_get_plugins( $delete_cache = false ) {
$cached_plugins = wp_cache_get( 'plugins', 'plugins' );
if ( ! is_array( $cached_plugins ) ) {
$cached_plugins = array();
}
$plugin_folder = '';
if ( isset( $cached_plugins[ $plugin_folder ] ) ) {
$plugins = $cached_plugins[ $plugin_folder ];
} else {
if ( ! function_exists( 'get_plugins' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$plugins = get_plugins();
if ( $delete_cache && is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
wp_cache_delete( 'plugins', 'plugins' );
}
}
return $plugins;
}
}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment