This commit is contained in:
2026-04-26 23:47:49 +02:00
parent 1b95f03d1e
commit b073e009d8
5288 changed files with 1112699 additions and 55536 deletions

View File

@@ -0,0 +1,9 @@
[main]
host = https://www.transifex.com
[password-protected.password-protected]
file_filter = languages/password-protected-<lang>.po
source_file = languages/password-protected.pot
source_lang = en_US
type = PO
minimum_perc = 20

View File

@@ -0,0 +1,332 @@
# Change Log
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
## 2.7.1 2024-03-27
- Fixed - Disabled activity report by default.
## 2.7 - 2024-03-26
- New: Added Password Activity Report to provide weekly insights on access attempts to your protected sites.
- New: Added Categoric Tabs and Sub-Tabs User Interface for easy navigation and better user experience.
## 2.6.5.1 - 2023-11-20
- Ensured seamless compatibility with the latest WordPress version
## 2.6.5 - 2023-06-17
- Fixed - [Login Designer](https://wp.org/plugins/login-designer) compatibility issues.
## 2.6.4 - 2023-09-22
- Fixed - Added compatibility for PHP version 8.2
## 2.6.3.2 - 2023-07-20
- Update - Feedback library updated
## 2.6.3.1 - 2023-06-26
- Fix - Parse error related to PHP version 7.2
## 2.6.3 - 2023-05-22
- New - Added Freemius SDK integration.
- New - Added functionality to login with transient if the cookies are blocked.
- Fix Fixed Redirect Issue from excluded page to password protected page.
## 2.6.2 - 2023-02-16
- Fix Parse error related to PHP version 7.2
## 2.6.1 - 2023-02-15
- Fix Parse error related to PHP version 7.2
- Update - Link to official Google Re-captcha documentation
## 2.6.0 - 2023-02-13
- Improved admin settings interface and introduced NEW tabs structure.
- NEW: Added Google Recaptcha v2 and v3 to make it more secure.
- NEW: Added Password Protected top-level admin menu for ease.
- NEW: Added option to add text above password Field.
- NEW: Added option to add text below password Field.
## 2.5.3 - 2023-02-06
- Improved Settings HTML structure
- Added Note regarding compatibility with login designer within dashboard
## 2.5.2 - 2022-05-26
Made compatibility with [login designer](https://wp.org/plugins/login-designer); Now you can customize the password-protected screen with the customizer using login designer plugin.
## [2.5] - 2021-09-01
### Fixed
- Deprecate `wp_no_robots` and replace with `wp_robots_no_robots` for WordPress 5.7+
## [2.4] - 2020-09-24
### Fixed
- Add a Nocache header to the login page redirect to prevent the browser from caching the redirect page. Props [De'Yonte W.](https://github.com/rxnlabs)
- Remove password-protected query from redirects on successful login or logout.
- Check "redirect_to" query var is set in hidden form field. Props [Matthias Kittsteiner](https://wordpress.org/support/users/kittmedia/).
- Add favicon to password protected login page.
## [2.3] - 2020-05-17
### Added
- Adds `password_protected_cookie_name` filter for the cookie name. Props [Jose Castaneda](https://github.com/jocastaneda).
- Let developers override the capability needed to see the options page via a `password_protected_options_page_capability` filter. Props [Nicola Peluchetti](https://github.com/nicoladj77).
### Fixed
- Don't use a "testcookie" POST query as it is blocked by Namecheap (and possibly other hosts).
- Fix warnings in W3 validator - script and style “type” attribute not required. Props [@dianamurcia](https://github.com/dianamurcia).
### Changed
- Translations now via [translate.wordpress.org](https://translate.wordpress.org/projects/wp-plugins/password-protected/).
- Updated URL references. Props [Garrett Hyder](https://github.com/garretthyder).
## [2.2.5] - 2019-06-04
### Added
- Added `password_protected_login_password_title` filter to allow customizing the "Password" label on the login form. Props [Jeremy Herve](https://github.com/jeherve).
### Changed
- Fix stray "and" in readme. Props [Viktor Szépe](https://github.com/szepeviktor).
- Update Portuguese translation. Props [Jonathan Hult](https://github.com/jhult).
- Update Russian translation. Props [Alexey Chumakov](https://github.com/achumakov).
## [2.2.4] - 2019-02-22
### Fixed
Check that `$_SERVER['REMOTE_ADDR']` is set.
## [2.2.3] - 2019-01-10
### Fixed
- Restrict REST-API-access only if password protection is active.
### Added
- Added viewport meta tag to login page.
- Added `password_protected_show_login` filter.
### Changed
- Cookie name is not editable in the admin so display just for reference.
- Use default WordPress text domain for “Remember Me” and “Log In” buttons.
## [2.2.2] - 2018-05-29
### Changed
- Change locked admin bar icon to green.
### Fixed
- Fix REST option and always allow access to REST API for logged in users.
## [2.2.1] - 2018-05-27
### Fixed
- Fixed PHP error when calculating cookie expiration date.
## [2.2] - 2018-05-25
### Added
- Admin bar icon to indicate wether password protection is enabled/disabled.
- Option to show "Remember me" checkbox. Props [Christian Güdel](https://github.com/cguedel).
- REST API access disabled if password not entered.
- Admin option to allow REST API access.
### Security
- More robust checking of password hashes.
## [2.1] - 2017-07-27
### Added
- Update caching notes for WP Engine and W3 Total Cache plugin.
- Tested up to WordPress 4.8
## [2.0.3] - 2015-03-23
### Added
- Show user's IP address beside "Allow IP Addresses" admin setting.
- Add CHANGELOG.md and README.md
### Changed
- Declare methods as public or private and use PHP5 constructors.
## [2.0.2] - 2015-10-29
### Added
- Check allowed IP addresses are valid when saving.
### Changed
- Only redirect to [allowed domain names](https://codex.wordpress.org/Plugin_API/Filter_Reference/allowed_redirect_hosts) when logging out.
## [2.0.1] - 2015-07-24
### Changed
- Split logout functionality into separate function.
### Security
- Use a more complex password hash for cookie key. Props Marcin Bury, [Securitum](http://securitum.pl).
## [2.0] - 2015-03-26
### Added
- Added [password_protected_logout_link](https://github.com/benhuson/password-protected/wiki/password_protected_logout_link-Shortcode) shortcode.
- Load 'password-protected-login.css' in theme folder if it exists.
- Added [password_protected_stylesheet_file](https://github.com/benhuson/password-protected/wiki/password_protected_stylesheet_file) filter to specify alternate stylesheet location.
- Added is_user_logged_in(), login_url(), logout_url() and logout_link() methods.
- Added Basque, Czech, Greek, Lithuanian and Norwegian translations.
### Changed
- Better handling of login/out redirects when protection is not active on home page.
## [1.9] - 2014-12-17
### Fixed
- Fixed "Allow Users" functionality with is_user_logged_in(). Props PatRaven.
### Added
- Added option for allowed IP addresses which can bypass the password protection.
- Added 'password_protected_is_active' filter.
## [1.8] - 2014-10-07
### Added
- Support for adding "password-protected-login.php" in theme directory.
- Allow filtering of the 'redirect to' URL via the 'password_protected_login_redirect_url' filter.
- Added 'password_protected_login_messages' action to output errors and messages in template.
- Updated translations.
### Changed
- Use current_time( 'timestamp' ) instead of time() to take into account site timezone.
- Check login earlier in the template_redirect action.
## [1.7.2] - 2014-06-05
### Fixed
- Fix always allow access to robots.txt.
### Added
- Added 'password_protected_login_redirect' filter.
- Updated translations.
## [1.7.1] - 2014-03-17
### Fixed
- Fix login template compatibility for WordPress 3.9
## [1.7] - 2014-02-27
### Fixed
- Remove JavaScript that disables admin RSS checkbox.
### Added
- Added 'password_protected_theme_file' filter to allow custom login templates.
- Add option to allow logged in users.
## [1.6.2] - 2014-01-10
### Changed
- Set login page not to index if privacy setting is on.
- Allow redirection to a different URL when logging out using 'redirect_to' query and full URL.
## [1.6.1] - 2013-11-13
### Added
- Language updates by wp-translations.org (Arabic, Dutch, French, Persian, Russian).
## [1.6] - 2013-07-04
### Fixed
- Robots.txt is now always accessible.
### Added
- Added support for Uber Login Logo plugin.
## [1.5] - 2013-02-21
### Added
- Added note about WP Engine compatibility to readme.txt
### Changed
- Requires WordPress 3.1+
- Settings now have their own page.
### Security
- Fixed an open redirect vulnerability. Props Chris Campbell.
## [1.4] - 2013-02-10
### Added
- Add option to allow administrators to use the site without logging in.
- Use DONOTCACHEPAGE to try to prevent some caching issues.
- Added a contextual help tab for WordPress 3.3+.
### Changed
- Updated login screen styling for WordPress 3.5 compatibility.
- Options are now on the 'Reading' settings page in WordPress 3.5
## [1.3] - 2012-10-01
### Added
- Added checkbox to allow access to feeds when protection is enabled.
- Prepare for WordPress 3.5 Settings API changes.
- Added 'password_protected_before_login_form' and 'password_protected_after_login_form' actions.
- Added 'password_protected_process_login' filter to make it possible to extend login functionality.
- Now possible to use 'pre_update_option_password_protected_password' filter to use password before it is encrypted and saved.
- Ready for [translations](http://codex.wordpress.org/I18n_for_WordPress_Developers).
## [1.2.2] - 2012-07-30
### Added
- Show login error messages.
### Security
- Escape 'redirect_to' attribute. Props A. Alagha.
## [1.2.1] - 2012-05-25
### Added
- Added a "How to log out?" FAQ.
### Changed
- Only disable feeds when protection is active.
## [1.2] - 2012-04-14
### Changed
- Use cookies instead of sessions.
## [1.1] - 2012-02-12
### Security
- Encrypt passwords in database.
## [1.0] - 2012-02-01
### Added
- First Release. If you spot any bugs or issues please [log them here](https://github.com/benhuson/password-protected/issues).
[Unreleased]: https://github.com/benhuson/password-protected/compare/2.5...HEAD
[2.4]: https://github.com/benhuson/password-protected/compare/2.4...2.5
[2.4]: https://github.com/benhuson/password-protected/compare/2.3...2.4
[2.3]: https://github.com/benhuson/password-protected/compare/2.2.5...2.3
[2.2.5]: https://github.com/benhuson/password-protected/compare/2.2.4...2.2.5
[2.2.4]: https://github.com/benhuson/password-protected/compare/2.2.3...2.2.4
[2.2.3]: https://github.com/benhuson/password-protected/compare/2.2.2...2.2.3
[2.2.2]: https://github.com/benhuson/password-protected/compare/2.2.1...2.2.2
[2.2.1]: https://github.com/benhuson/password-protected/compare/2.2...2.2.1
[2.2]: https://github.com/benhuson/password-protected/compare/2.1...2.2
[2.1]: https://github.com/benhuson/password-protected/compare/2.0.3...2.1
[2.0.3]: https://github.com/benhuson/password-protected/compare/2.0.2...2.0.3
[2.0.2]: https://github.com/benhuson/password-protected/compare/2.0.1...2.0.2
[2.0.1]: https://github.com/benhuson/password-protected/compare/2.0...2.0.1
[2.0]: https://github.com/benhuson/password-protected/compare/1.9...2.0
[1.9]: https://github.com/benhuson/password-protected/compare/1.8...1.9
[1.8]: https://github.com/benhuson/password-protected/compare/1.7.2...1.8
[1.7.2]: https://github.com/benhuson/password-protected/compare/1.7.1...1.7.2
[1.7.1]: https://github.com/benhuson/password-protected/compare/1.7...1.7.1
[1.7]: https://github.com/benhuson/password-protected/compare/1.6.2...1.7
[1.6.2]: https://github.com/benhuson/password-protected/compare/1.6.1...1.6.2
[1.6.1]: https://github.com/benhuson/password-protected/compare/1.6...1.6.1
[1.6]: https://github.com/benhuson/password-protected/compare/1.5...1.6
[1.5]: https://github.com/benhuson/password-protected/compare/1.4...1.5
[1.4]: https://github.com/benhuson/password-protected/compare/1.3...1.4
[1.3]: https://github.com/benhuson/password-protected/compare/1.2.2...1.3
[1.2.2]: https://github.com/benhuson/password-protected/compare/1.2.1...1.2.2
[1.2.1]: https://github.com/benhuson/password-protected/compare/1.2...1.2.1
[1.2]: https://github.com/benhuson/password-protected/compare/1.1...0.7.11.2
[1.1]: https://github.com/benhuson/password-protected/compare/1.0...1.1
[1.0]: https://github.com/benhuson/password-protected/tree/1.0

View File

@@ -0,0 +1,163 @@
Password Protected
==================
A very simple way to quickly password protect your WordPress site with a single password.
This plugin only protects your WordPress generated content. It **does not protect images or uploaded files** so if you enter and exact URL to in image file it will still be accessible.
Features include:
- Password protect your WordPress site with a single password.
- Option to allow access to feeds.
- Option to allow administrators access without entering password.
- *New* 👉 Now you can customize the whole password protected screen including the background, font, logo, color e.t.c.
> Please note, this plugin works by setting a cookie to allow access to the site. If you are using a caching plugin or web hosting such as WP Engine that has in-built caching, you will need to configure the caching service to be disabled if the Password Protected cookie is set.
Translations
------------
If you would like to translate this plugin you can easily contribute at the [Translating WordPress](https://translate.wordpress.org/projects/wp-plugins/password-protected/) page. The stable plugin needs to be 95% translated for a language file to be available to download/update via WordPress.
Installation
------------
To install and configure this plugin...
1. Upload or install the plugin through your WordPress admin.
1. Activate the plugin via the 'Plugins' admin menu.
1. Configure the password options in the Password Protected settings.
Upgrading
---------
If you are upgrading manually via FTP rather that through the WordPress automatic upgrade link, please de-activate and re-activate the plugin to ensure the plugin upgrades correctly.
Frequently Asked Questions
--------------------------
__How can I change the WordPress logo to a different image?__
Install and configure the [Login Logo](https://wordpress.org/plugins/login-logo/) plugin by Mark Jaquith or the [Uber Login Logo](https://wordpress.org/plugins/uber-login-logo/) plugin. This will change the logo on your password entry page AND also your admin login page.
__How can I enable feeds while the site is password protected?__
In the settings, check the 'Allow Feeds' checkbox.
__Can I prevent administrators having to enter password?__
In the settings, check the 'Allow Administrators' checkbox.
__I cannot preview my changes in the Theme Customizer__
You must be an administrator (have the manage_options capability) and in the Password Protected settings, check the 'Allow Administrators' checkbox.
__How can I log out?__
Just add a "password-protected=logout" query to your URL.
eg. http://www.example.com/?password-protected=logout
__I have forgotten the password. How can I disable the plugin?__
If you go to your WordPress admin login page `/wp-login.php` and it shows the admin login fields, you should still be able to login and disable the plugin.
If the admin login screen insteads shows the Password Protected field, you will need to access your site via SFTP/SSH and delete the Password Protected plugin folder in the plugins folder `wp-content/plugins/password-protected`.
__How can I redirect to a different domain name when logging out?__
If passing a redirect URL using 'redirect_to' when logging out you need you may need to use the [allowed domain names](https://codex.wordpress.org/Plugin_API/Filter_Reference/allowed_redirect_hosts) filter to allow redirecting to an external domain.
__Where can I report bugs and issues?__
Please log issues and bugs on the plugin's [GitHub page](https://github.com/benhuson/password-protected/issues).
You can also submit suggested enhancements if you like.
__How can I contribute?__
If you can, please [fork the code](https://github.com/benhuson/password-protected) and submit a pull request via GitHub. If you're not comfortable using Git, then please just submit it to the issues link above.
__How can I translate this plugin?__
If you would like to translate this plugin you can easily contribute at the [Translating WordPress](https://translate.wordpress.org/projects/wp-plugins/password-protected/) page. The stable plugin needs to be 95% translated for a language file to be available to download/update via WordPress.
Upgrade Notice
--------------
### 2.5.3
- Improved Settings HTML structure
- Added Note regarding compatibility with login designer within dashboard
### 2.5.2
Made compatibility with [login designer](https://wp.org/plugins/login-designer); Now you can customize the password-protected screen with the customizer using login designer plugin.
### 2.5
Fixes robots tag for WordPress 5.7+
### 2.4
Fixes to help with caching issues and favicon on login page.
### 2.3
Fixed an issue with "testcookie" on some hosts. Added `password_protected_cookie_name` and `password_protected_options_page_capability` filters.
### 2.2.5
Added `password_protected_login_password_title` filter to allow customizing the "Password" label on the login form.
### 2.2.4
Check that `$_SERVER['REMOTE_ADDR']` is set.
### 2.2.3
Restrict REST-API-access only if password protection is active. Added viewport meta tag to login page.
### 2.2.2
Fix REST option and always allow access to REST API for logged in users. Change locked admin bar icon to green.
### 2.2.1
Fixed PHP error when calculating cookie expiration date.
### 2.2
Added admin bar icon to indicate wether password protection is enabled/disabled. Options to enable REST API access and show "Remember me" checkbox.
### 2.1
Update caching notes for WP Engine and W3 Total Cache plugin.
### 2.0.3
Show user's IP address beside "Allow IP Addresses" admin setting. Declare methods as public or private and use PHP5 constructors.
### 2.0.2
Only redirect to [allowed domain names](https://codex.wordpress.org/Plugin_API/Filter_Reference/allowed_redirect_hosts) when logging out.
### 2.0.1
Security fix: Use a more complex password hash for cookie key.
### 2.0
Added 'password_protected_logout_link' shortcode and use 'password-protected-login.css' in theme folder if it exists.
### 1.9
Fixed "Allow Users" functionality and added option to allowed IP addresses which can bypass the password protection.
### 1.8
Support for adding "password-protected-login.php" in theme directory and allow filtering of the 'redirect to' URL via the 'password_protected_login_redirect_url' filter.
### 1.7.2
Added 'password_protected_login_redirect' filter.
### 1.7.1
Fix login template compatibility for WordPress 3.9
### 1.7
Added 'password_protected_theme_file' filter and option to allow logged in users.
### 1.6.2
Allow redirection to a different URL when logging out.
### 1.6
Added support for Uber Login Logo plugin.
### 1.5
Fixes an open redirect vulnerability. Settings now have own page.
### 1.4
Administrators can use the site without logging in. WordPress 3.5 compatible.
### 1.3
Allow access to feeds. Ready for translation.
### 1.2
Use cookies instead of sessions.
### 1.1
Passwords saved encrypted.
Changelog
---------
View a list of all plugin changes in [CHANGELOG.md](https://github.com/wpexpertsio/password-protected/blob/master/CHANGELOG.md).

View File

@@ -0,0 +1,137 @@
<?php
/**
* @package Password Protected
* @subpackage Admin Bar
*
* Adds an indicator in the admin if Password Protection is enabled.
*/
namespace Password_Protected;
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
add_action( 'plugins_loaded', array( 'Password_Protected\Admin_Bar', 'load' ), 15 );
class Admin_Bar {
/**
* Load
*
* @internal Private. Called via `plugins_loaded` actions.
*/
public static function load() {
add_action( 'wp_head', array( get_class(), 'styles' ) );
add_action( 'admin_head', array( get_class(), 'styles' ) );
add_action( 'wp_before_admin_bar_render', array( get_class(), 'toolbar_item' ) );
}
/**
* Toolbar Item
*
* @internal Private. Called via `wp_before_admin_bar_render` actions.
*/
public static function toolbar_item() {
global $wp_admin_bar;
if ( self::allow_current_user() ) {
$wp_admin_bar->add_menu( array(
'id' => 'password_protected',
'title' => '',
'href' => self::get_toolbar_item_url(),
'meta' => array(
'title' => self::get_toolbar_item_title()
)
) );
}
}
/**
* Get Toolbar Item URL
*
* @return string
*/
private static function get_toolbar_item_url() {
if ( current_user_can( 'manage_options' ) ) {
return admin_url( 'options-general.php?page=password-protected' );
}
return '';
}
/**
* Get Toolbar Item Title
*
* @return string
*/
private static function get_toolbar_item_title() {
if ( self::is_enabled() ) {
return __( 'Password Protection is enabled.', 'password-protected' );
}
return __( 'Password Protection is disabled.', 'password-protected' );
}
/**
* Styles
*
* @internal Private. Called via `wp_head` and `admin_head` actions.
*/
public static function styles() {
if ( self::allow_current_user() ) {
if ( self::is_enabled() ) {
$icon = '\f160'; // Locked
$background = '#46b450';
} else {
$icon = '\f528'; // Unlocked
$background = 'transparent';
}
?>
<style type="text/css">
#wp-admin-bar-password_protected { background-color: <?php echo $background; ?> !important; }
#wp-admin-bar-password_protected > .ab-item { color: #fff !important; }
#wp-admin-bar-password_protected > .ab-item:before { content: "<?php echo $icon; ?>"; top: 2px; color: #fff !important; margin-right: 0px; }
#wp-admin-bar-password_protected:hover > .ab-item { background-color: <?php echo $background; ?> !important; color: #fff; }
</style>
<?php
}
}
/**
* Allow Current User
*
* @return boolean
*/
private static function allow_current_user() {
return is_user_logged_in();
}
/**
* Is Enabled
*
* @return boolean
*/
private static function is_enabled() {
return (bool) get_option( 'password_protected_status' );
}
}

View File

@@ -0,0 +1,178 @@
<?php
/**
* @package Password Protected
* @subpackage Admin Caching
*
* @since 2.1
*/
class Password_Protected_Admin_Caching {
/**
* Plugin
*
* @since 2.1
*
* @var Password_Protected|null
*/
private $plugin = null;
/**
* Constructor
*
* @since 2.1
*
* @internal Private. This class should only be instantiated once by the plugin.
*/
public function __construct( $plugin ) {
$this->plugin = $plugin;
add_action( 'admin_init', array( $this, 'cache_settings_info' ) );
}
/**
* Cache Settings Info
*
* Displays information on the settings page for helping
* to configure Password Protected to work with caching setups.
*
* @since 2.1
*/
public function cache_settings_info() {
// Caching Section
add_settings_section(
'password_protected_compat_caching',
__( 'Having issue with Caching?', 'password-protected' ),
array( $this, 'section_caching' ),
'password-protected-compat'
);
// Cookies
add_settings_field(
'password_protected_compat_caching_cookie',
__( 'Cookie Name', 'password-protected' ),
array( $this, 'field_cookies' ),
'password-protected-compat',
'password_protected_compat_caching'
);
add_settings_field(
'password_protected_documentation',
__( 'Documentation', 'password-protected' ),
array( $this, 'documentation' ),
'password-protected-compat',
'password_protected_compat_caching'
);
// WP Engine Hosting
if ( $this->test_wp_engine() ) {
add_settings_field(
'password_protected_compat_caching_wp_engine',
__( 'WP Engine Hosting', 'password-protected' ),
array( $this, 'field_wp_engine' ),
'password-protected-compat',
'password_protected_compat_caching'
);
}
// W3 Total Cache
if ( $this->test_w3_total_cache() ) {
add_settings_field(
'password_protected_compat_caching_w3_total_cache',
__( 'W3 Total Cache', 'password-protected' ),
array( $this, 'field_w3_total_cache' ),
'password-protected-compat',
'password_protected_compat_caching'
);
}
}
/**
* Caching Section
*
* @since 2.1
*/
public function section_caching() {
echo '<p>' . __( 'Password Protected does not always work well with sites that use caching.', 'password-protected' ) . '<br />
' . __( 'If your site uses a caching plugin or your web hosting uses server-side caching, you may need to configure your caching setup to disable caching for the Password Protected cookie:', 'password-protected' ) . '</p>';
}
/**
* Password Protection Status Field
*
* @since 2.1
*/
public function field_cookies() {
echo '<p><code>' . esc_html( $this->plugin->cookie_name() ) . '</code></p>';
echo '<p class="description">' . __( 'Can be changed using the `password_protected_cookie_name` filter.', 'password-protected' ) . '</p>';
}
public function documentation() {
echo '<a href="https://passwordprotectedwp.com/documentation?utm_source=documentation&utm_medium=help-tab">Documentation</a>';
}
/**
* WP Engine Hosting
*
* @since 2.1
*/
public function field_wp_engine() {
echo '<p>' . __( 'We have detected your site may be running on WP Engine hosting.', 'password-protected' ) . '<br />
' . __( 'In order for Password Protected to work with WP Engine\'s caching configuration you must ask them to disable caching for the Password Protected cookie.', 'password-protected' ) . '</p>';
}
/**
* W3 Total Cache Plugin
*
* @since 2.1
*/
public function field_w3_total_cache() {
echo '<p>' . __( 'It looks like you may be using the W3 Total Cache plugin?', 'password-protected' ) . '<br />
' . __( 'In order for Password Protected to work with W3 Total Cache you must disable caching when the Password Protected cookie is set.', 'password-protected' ) . '
' . sprintf( __( 'You can adjust the cookie settings for W3 Total Cache under <a href="%s">Performance > Page Cache > Advanced > Rejected Cookies</a>.', 'password-protected' ), admin_url( '/admin.php?page=w3tc_pgcache#advanced' ) ) . '</p>';
}
/**
* Test: WP Engine
*
* @since 2.1
*
* @return boolean
*/
private function test_wp_engine() {
return ( function_exists( 'is_wpe' ) && is_wpe() ) || ( function_exists( 'is_wpe_snapshot' ) && is_wpe_snapshot() );
}
/**
* Test: W3 Total Cache
*
* @since 2.1
*
* @return boolean
*/
private function test_w3_total_cache() {
return defined( 'W3TC' ) && W3TC;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,650 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
* @package Password Protected
* @subpackage reCAPTCHA
*
* @since 2.6
*/
class Password_Protected_reCAPTCHA {
public $options_group = 'password-protected-recaptcha';
public $options_name = 'password_protected_recaptcha';
public $tab = 'password-protected&tab=advanced';
public $settings = array();
/**
* Constructor
*
* @since 2.6
*
* @internal public. This class should only be instantiated once by the plugin.
*/
public function __construct() {
$options = get_option( $this->options_name );
if ( empty( $options ) || ! $options ) {
$this->settings = $this->get_default_reCAPTCHA_settings();
} else {
$this->settings = get_option( $this->options_name );
}
add_action( 'admin_init', array( $this, 'register_reCAPTCHA_settings' ), 6 );
add_action( 'password_protected_after_password_field', array( $this, 'add_recaptcha' ) );
add_filter( 'password_protected_verify_recaptcha', array( $this, 'verify_recaptcha' ) );
}
/**
* reCAPTCHA Default Settings
*
* @return array
* @since 2.6
*/
private function get_default_reCAPTCHA_settings(): array {
return array(
'enable' => 0,
'version' => 'google_recaptcha_v2',
'v2_site_key' => null,
'v3_site_key' => null,
'v2_secret_key' => null,
'v3_secret_key' => null,
'v3_score' => 0.3,
'v3_badge' => 'bottomright',
'v2_theme' => 'light',
);
}
/**
* reCAPTCHA Settings Info
*
* Displays information on the settings page for helping
* to configure Password Protected to work with Google reCAPTCHA v2 and v3.
*
* @since 2.6
*/
public function register_reCAPTCHA_settings() {
// reCAPTCHA Section
add_settings_section(
$this->options_group,
__( 'Google reCAPTCHA', 'password-protected' ),
array( $this, 'reCAPTCHA_section' ),
$this->tab
);
// Enable reCAPTCHA
add_settings_field(
'password_protected_enable_recaptcha',
__( 'Enable reCAPTCHA ', 'password-protected' ),
array( $this, 'reCAPTCHA_enable' ),
$this->tab,
$this->options_group
);
// reCAPTCHA version v2/v3
add_settings_field(
'password_protected_recaptcha_settings',
__( 'Captcha Settings', 'password-protected' ),
array( $this, 'reCAPTCHA_setting' ),
$this->tab,
$this->options_group
);
// reCAPTCHA v2/v3 sitekey
add_settings_field(
'password_protected_recaptcha_v2_site_key',
__( 'Site Key', 'password-protected' ),
array( $this, 'reCAPTCHA_site_key' ),
$this->tab,
$this->options_group
);
// reCAPTCHA v2/v3 secretkey
add_settings_field(
'password_protected_recaptcha_v2_secret_key',
__( 'Secret Key', 'password-protected' ),
array( $this, 'reCAPTCHA_secret_key' ),
$this->tab,
$this->options_group
);
// reCAPTCHA v3 score
add_settings_field(
'password_protected_recaptcha_score',
__( 'Score', 'password-protected' ),
array( $this, 'reCAPTCHA_score' ),
$this->tab,
$this->options_group
);
// reCAPTCHA v3 badgeposition
add_settings_field(
'password_protected_recaptcha_badge_position',
__( 'Badge Position', 'password-protected' ),
array( $this, 'reCAPTCHA_badge_position' ),
$this->tab,
$this->options_group
);
// reCAPTCHA v2 theme
add_settings_field(
'password_protected_recaptcha_theme',
__( 'Theme', 'password-protected' ),
array( $this, 'reCAPTCHA_theme' ),
$this->tab,
$this->options_group
);
// register settings in an array group.
register_setting( 'password-protected-advanced', $this->options_name, array( 'type' => 'array' ) );
}
/**
* reCAPTCHA Screen
*
* @since 2.6
*
* @return void password protected reCAPTCHA settings
*/
public static function recpatcha_screen() {
do_settings_sections( 'password-protected&tab=advanced' );
submit_button();
}
/**
* reCAPTCHA Section
*
* @return void password protected reCAPTCHA section
*/
public function reCAPTCHA_section() {
return 1;
}
/**
* ENable reCAPTCHA
*
* @since 2.6
*
* @return void password protected reCAPTCHA status field
*/
public function reCAPTCHA_enable() {
echo '<label>
<input
name="' . esc_attr( $this->options_name ) . '[enable]"
id="pp_enable_recaptcha"
type="checkbox"
value="1" ' . checked( 1, @$this->settings['enable'], false ) . '
/> ' .
__( 'Enabled', 'password-protected' ) . '
</label>';
}
/**
* reCAPTCHA Version
*
* @since 2.6
*
* @return void password protected reCAPTCHA version field
*/
public function reCAPTCHA_setting() {
echo '<label>
<input
' . checked( 'google_recaptcha_v2', $this->settings['version'], false ) . '
type="radio"
name="' . esc_attr( $this->options_name ) . '[version]"
value="google_recaptcha_v2"
/>
<span>Google reCAPTCHA Version 2</span>
</label>
<br />
<label>
<input
' . checked( 'google_recaptcha_v3', $this->settings['version'], false ) . '
type="radio"
name="' . esc_attr( $this->options_name ) . '[version]"
value="google_recaptcha_v3"
/>
<span>Google reCAPTCHA Version 3</span>
</label>';
}
/**
* reCAPTCHA Site Key
*
* @since 2.6
*
* @return void password protected v2/v3 sitekey field
*/
public function reCAPTCHA_site_key() {
echo '<div>
<input
name="' . esc_attr( $this->options_name ) . '[v2_site_key]"
type="text"
id="pp_google_recaptcha_v2_site_key"
value="' . esc_attr( $this->settings['v2_site_key'] ) . '"
class="regular-text"
/>
<p class="description">
Enter Google reCAPTCHA v2 Site Key.&nbsp;
<a target="_blank" href="https://developers.google.com/recaptcha/intro#recaptcha-overview">
Click Here
</a>
</p>
</div>';
echo '<div>
<input
name="' . esc_attr( $this->options_name ) . '[v3_site_key]"
type="text"
id="pp_google_recaptcha_v3_site_key"
value="' . esc_attr( $this->settings['v3_site_key'] ) . '"
class="regular-text"
/>
<p class="description">
Enter Google reCAPTCHA v3 Site Key.&nbsp;
<a target="_blank" href="https://developers.google.com/recaptcha/intro#recaptcha-overview">
Click Here
</a>
</p>
</div>';
}
/**
* reCAPTCHA Secret Key
*
* @since 2.6
*
* @return void password protected v2/v3 secretkey field
*/
public function reCAPTCHA_secret_key() {
echo '<div>
<input
name="' . esc_attr( $this->options_name ) . '[v2_secret_key]"
type="text"
id="pp_google_recaptcha_v2_secret_key"
value="' . esc_attr( $this->settings['v2_secret_key'] ) . '"
class="regular-text"
/>
<p class="description">
Enter Google reCAPTCHA v2 Secret Key.&nbsp;
<a target="_blank" href="https://developers.google.com/recaptcha/intro#recaptcha-overview">
Click Here
</a>
</p>
</div>';
echo '<div>
<input
name="' . esc_attr( $this->options_name ) . '[v3_secret_key]"
type="text"
id="pp_google_recaptcha_v3_secret_key"
value="' . esc_attr( $this->settings['v3_secret_key'] ) . '"
class="regular-text"
/>
<p class="description">
Enter Google reCAPTCHA v3 Secret Key.&nbsp;
<a target="_blank" href="https://developers.google.com/recaptcha/intro#recaptcha-overview">
Click Here
</a>
</p>
</div>';
}
/**
* reCAPTCHA V3 Score
*
* @since 2.6
*
* @return void password protected v3 score field
*/
public function reCAPTCHA_score() {
echo '<fieldset id="pp_google_recpatcha_v3_score">
<label>
<input
type="radio"
name="' . esc_attr( $this->options_name ) . '[v3_score]"
value="0.1"
' . checked( 0.1, $this->settings['v3_score'], false ) . '
/>
<span>0.1</span>
</label>
&nbsp;
<label>
<input
type="radio"
name="' . esc_attr( $this->options_name ) . '[v3_score]"
value="0.2"
' . checked( 0.2, $this->settings['v3_score'], false ) . '
/>
<span>0.2</span>
</label>
&nbsp;
<label>
<input
type="radio"
name="' . esc_attr( $this->options_name ) . '[v3_score]"
value="0.3"
' . checked( 0.3, $this->settings['v3_score'], false ) . '
/>
<span>0.3</span>
</label>
&nbsp;
<label>
<input
type="radio"
name="' . esc_attr( $this->options_name ) . '[v3_score]"
value="0.4"
' . checked( 0.4, $this->settings['v3_score'], false ) . '
/>
<span>0.4</span>
</label>
&nbsp;
<label>
<input
type="radio"
name="' . esc_attr( $this->options_name ) . '[v3_score]"
value="0.5"
' . checked( 0.5, $this->settings['v3_score'], false ) . '
/>
<span>0.5</span>
</label>
&nbsp;
<p class="description">Select Google Version 3 Score.</p>
</fieldset>';
}
/**
* reCAPTCHA V3 Badge Position
*
* @since 2.6
*
* @return void password protected v3 badgeposition field
*/
public function reCAPTCHA_badge_position() {
echo '<fieldset id="pp_google_recpatcha_v3_badge">
<label>
<input
type="radio"
name="' . esc_attr( $this->options_name ) . '[v3_badge]"
value="inline"
' . checked( 'inline', $this->settings['v3_badge'], false ) . '
/>
<span>Inline</span>
</label>
&nbsp;&nbsp;
<label>
<input
type="radio"
name="' . esc_attr( $this->options_name ) . '[v3_badge]"
value="bottomleft"
' . checked( 'bottomleft', $this->settings['v3_badge'], false ) . '
/>
<span>Bottom - Left</span>
</label>
&nbsp;&nbsp;
<label>
<input
type="radio"
name="' . esc_attr( $this->options_name ) . '[v3_badge]"
value="bottomright"
' . checked( 'bottomright', $this->settings['v3_badge'], false ) . '
/>
<span>Bottom - Right</span>
</label>
</fieldset>';
}
/**
* reCAPTCHA V2 Theme
*
* @since 2.6
*
* @return void password protected v2 theme field
*/
public function reCAPTCHA_theme() {
echo '<label>
<input
checked="checked"
type="radio"
name="' . esc_attr( $this->options_name ) . '[v2_theme]"
value="light"
' . checked( 'light', $this->settings['v2_theme'], false ) . '
/>
<span>Light</span>
</label>
<br />
<label>
<input
type="radio"
name="' . esc_attr( $this->options_name ) . '[v2_theme]"
value="dark"
' . checked( 'dark', $this->settings['v2_theme'], false ) . '
/>
<span>Dark</span>
</label>
<p class="description">Select Google reCAPTCHA Version 2 Theme.</p>';
}
/**
* Add reCAPTCHA on Password Protected Form
*
* @since 2.6
*
* @return void password protected reCAPTCHA v2 OR v3
*/
public function add_recaptcha() {
if ( ! @$this->settings['enable'] ) {
return; // recpatcha is disabled
}
if ( $this->settings['version'] === 'google_recaptcha_v2' ) {
$this->display_recaptcha_v2();
}
if ( $this->settings['version'] === 'google_recaptcha_v3' ) {
$this->display_recaptcha_v3();
}
}
/**
* Diaplay reCAPTCHA V2
*
* @since 2.6
*
* @return void password protected reCAPTCHA v2 field
*/
public function display_recaptcha_v2() {
wp_enqueue_style( 'pp-recaptcha-style', plugin_dir_url( __DIR__ ) . 'assets/css/recaptcha.css', array(), '2.6.2' );
wp_enqueue_script( 'pp-recaptcha-api-v2', esc_url( 'https://www.google.com/recaptcha/api.js' ), array(), null );
echo '<div
class="g-recaptcha"
data-sitekey="' . esc_attr( $this->settings['v2_site_key'] ) . '"
data-theme="' . esc_attr( $this->settings['v2_theme'] ) . '"
>
</div>';
}
/**
* Diaplay reCAPTCHA V3
*
* @since 2.6
*
* @return void password protected reCAPTCHA v3 field
*/
public function display_recaptcha_v3() {
$grecaptcha_v3_site_key = isset( $this->settings['v3_site_key'] ) ? esc_attr( $this->settings['v3_site_key'] ) : '';
$grecaptcha_v3_badge = isset( $this->settings['v3_badge'] ) ? esc_attr( $this->settings['v3_badge'] ) : 'bottomright';
$script = <<<EOT
if('function' !== typeof pprecaptcha) {
function pprecaptcha() {
grecaptcha.ready(function() {
[].forEach.call(document.querySelectorAll('.pp-g-recaptcha'), function(el) {
const action = el.getAttribute('data-action');
const form = el.form;
form.addEventListener('submit', function(e) {
e.preventDefault();
grecaptcha.execute('$grecaptcha_v3_site_key', {action: action}).then(function(token) {
el.setAttribute('value', token);
const button = form.querySelector('[type="submit"]');
if(button) {
const input = document.createElement('input');
input.type = 'hidden';
input.name = button.getAttribute('name');
input.value = button.value;
input.classList.add('pp-submit-input');
var inputEls = document.querySelectorAll('.pp-submit-input');
[].forEach.call(inputEls, function(inputEl) {
inputEl.remove();
});
form.appendChild(input);
}
HTMLFormElement.prototype.submit.call(form);
});
});
});
});
}
}
EOT;
wp_enqueue_script( 'recaptcha-api-v3', ( 'https://www.google.com/recaptcha/api.js?onload=pprecaptcha&render=' . esc_attr( $grecaptcha_v3_site_key ) . '&badge=' . esc_attr( $grecaptcha_v3_badge ) ), array(), null );
wp_add_inline_script( 'recaptcha-api-v3', $script ); ?>
<input type="hidden" name="g-recaptcha-response" id="g-recaptcha-response-password_protected" class="pp-g-recaptcha" data-action="password_protected">
<?php
}
/**
* Verify reCAPTCHA
* process reCAPTCHA
*
* @since 2.6
*
* @return object WP_Error
*/
public function verify_recaptcha( $errors ) {
if ( ! @$this->settings['enable'] ) {
return $errors; // return errors
}
if ( $this->settings['version'] === 'google_recaptcha_v2' ) {
$grecaptcha_v2_site_key = isset( $this->settings['v2_site_key'] ) ? esc_attr( $this->settings['v2_site_key'] ) : '';
$grecaptcha_v2_secret_key = isset( $this->settings['v2_secret_key'] ) ? esc_attr( $this->settings['v2_secret_key'] ) : '';
if ( empty( $grecaptcha_v2_site_key ) || empty( $grecaptcha_v2_secret_key ) ) {
$errors->add( 001, 'Google reCaptcha keys not found.' );
}
if ( isset( $_POST['g-recaptcha-response'] ) && ! empty( $_POST['g-recaptcha-response'] ) ) {
$response = wp_remote_post(
'https://www.google.com/recaptcha/api/siteverify',
array(
'body' => array(
'secret' => $grecaptcha_v2_secret_key,
'response' => sanitize_text_field( $_POST['g-recaptcha-response'] ),
),
)
);
$data = wp_remote_retrieve_body( $response );
$data = json_decode( $data );
if ( isset( $data->{'error-codes'} ) && is_array( $data->{'error-codes'} ) && count( $data->{'error-codes'} ) ) {
foreach ( $data->{'error-codes'} as $index => $error_code ) {
$errors->add( $index, $error_code );
}
}
if ( isset( $data->success ) && true === $data->success ) {
return $errors;
}
}
$error_message = wp_kses( __( '<strong>ERROR:</strong> Please confirm you are not a robot.', 'password-protected' ), array( 'strong' => array() ) );
$errors->add( 'captcha_invalid', $error_message );
return $errors;
} elseif ( $this->settings['version'] === 'google_recaptcha_v3' ) {
$grecaptcha_v3_site_key = isset( $this->settings['v3_site_key'] ) ? esc_attr( $this->settings['v3_site_key'] ) : '';
$grecaptcha_v3_secret_key = isset( $this->settings['v3_secret_key'] ) ? esc_attr( $this->settings['v3_secret_key'] ) : '';
$grecaptcha_v3_score = isset( $this->settings['v3_score'] ) ? esc_attr( $this->settings['v3_score'] ) : '0.3';
if ( empty( $grecaptcha_v3_site_key ) || empty( $grecaptcha_v3_secret_key ) ) {
$errors->add( 001, 'Google reCaptcha keys not found.' );
}
if ( isset( $_POST['g-recaptcha-response'] ) && ! empty( $_POST['g-recaptcha-response'] ) ) {
$response = wp_remote_post(
'https://www.google.com/recaptcha/api/siteverify',
array(
'body' => array(
'secret' => $grecaptcha_v3_secret_key,
'response' => sanitize_text_field( $_POST['g-recaptcha-response'] ),
'remoteip' => self::get_ip_address(),
),
)
);
$data = wp_remote_retrieve_body( $response );
$data = json_decode( $data );
if ( isset( $data->{'error-codes'} ) && is_array( $data->{'error-codes'} ) && count( $data->{'error-codes'} ) ) {
foreach ( $data->{'error-codes'} as $index => $error_code ) {
$errors->add( $index, $error_code );
}
}
if ( isset( $data->success ) && true === $data->success ) {
$grecaptcha_v3_score = (float) $grecaptcha_v3_score;
if ( isset( $data->action ) && ( 'password_protected' === $data->action ) && isset( $data->score ) && $data->score >= $grecaptcha_v3_score ) {
return $errors;
} else {
$error_message = wp_kses( __( '<strong>ERROR:</strong> Low Score ', 'password-protected' ) . ':' . esc_html( $data->score ), array( 'strong' => array() ) );
$errors->add( 002, $error_message );
}
}
}
return $errors;
}
}
/**
* Get IP Address
*
* @since 2.6
*
* @return string client IP address
*/
private static function get_ip_address() {
$ipaddress = '';
if ( isset( $_SERVER['HTTP_CLIENT_IP'] ) ) {
$ipaddress = sanitize_text_field( $_SERVER['HTTP_CLIENT_IP'] );
} elseif ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
$ipaddress = sanitize_text_field( $_SERVER['HTTP_X_FORWARDED_FOR'] );
} elseif ( isset( $_SERVER['HTTP_X_FORWARDED'] ) ) {
$ipaddress = sanitize_text_field( $_SERVER['HTTP_X_FORWARDED'] );
} elseif ( isset( $_SERVER['HTTP_FORWARDED_FOR'] ) ) {
$ipaddress = sanitize_text_field( $_SERVER['HTTP_FORWARDED_FOR'] );
} elseif ( isset( $_SERVER['HTTP_FORWARDED'] ) ) {
$ipaddress = sanitize_text_field( $_SERVER['HTTP_FORWARDED'] );
} elseif ( isset( $_SERVER['REMOTE_ADDR'] ) ) {
$ipaddress = sanitize_text_field( $_SERVER['REMOTE_ADDR'] );
} else {
$ipaddress = 'UNKNOWN';
}
return $ipaddress;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

View File

@@ -0,0 +1,666 @@
#help-notice {
margin-top: 10px;
margin-bottom: 10px;
}
#help-notice, #pp-sidebar-box {
background: white;
padding: 0px 20px;
}
.wrap-col-70 {
flex: 0 0 70%;
width: 70%;
}
.wrap-col-25 {
flex: 0 1 25%;
}
.wrap-row {
display: flex;
justify-content: space-between;
}
h2.nav-tab-wrapper {
display: inline-block;
}
div#pp-sidebar-box {
border: 3px solid #fff;
/*border-radius: 10px;*/
margin-top: 9px;
}
#pp-sidebar-box {
line-height: 1.5;
word-spacing: 2px;
}
#pp-sidebar-box img.image {
width: 100%;
}
.pro-features {
font-size: 14px;
font-weight: 500;
}
#pp-sidebar-box h3 {
font-weight: 400;
}
.pro-tab-content {
color: #384d48;
position: relative;
background: #FFF;
padding: 20px;
margin: 20px 0;
border-radius: 6px;
box-shadow: 0px 0px 8px -2px rgb(0 0 0 / 30%);
-webkit-box-shadow: 0px 0px 8px -2px rgb(0 0 0 / 30%);
-moz-box-shadow: 0px 0px 8px -2px rgba(0,0,0, 0.3);
-ms-box-shadow: 0px 0px 8px -2px rgba(0,0,0, 0.3);
-o-box-shadow: 0px 0px 8px -2px rgba(0,0,0, 0.3);
}
a.get_pro_btn {
margin-top: 20px;
display: block;
background: #ff8900;
padding: 10px 20px;
color: #FFF;
text-decoration: none;
font-weight: bold;
font-size: 16px;
width: 105px;
text-align: center;
}
.pp-pro-try {
background-color: #ff8900 !important;
border-color: #ff8900 !important;
outline-color: #ff8900 !important;
}
.pro_container p {
margin: 0;
font-size: 14px;
}
a.nav-tab.getpro.nav-tab {
background: #ffab4a;
color: white;
border-color: #ffab4a;
}
input#password_protected_password_new, input#password_protected_password_confirm, input#password_protected_remember_me_lifetime, textarea#password_protected_allowed_ip_addresses {
width: 50% !important;
}
.template-container {
width: 100%;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background: #000;
}
.banner {
margin-top: 15px;
width: 860px;
/*height: 480px;*/
/*background-image: url("images/PPP-ads-14.png");*/
background-color: rgb( 255, 255, 255 );
background-position: center;
background-repeat: no-repeat;
padding: 30px 50px;
}
.banner-header {
margin-bottom: 2.5em;
}
.banner-header h2, .banner-header h1 {
font-weight: 700;
color: #000;
}
.banner-col-2 {
width: 50%;
float: left;
}
.password-protected-feature {
width: 100%;
font-size: 16px;
color: #fff;
position: relative;
padding-left: 35px;
padding-bottom: 25px;
}
.password-protected-feature img {
position: absolute;
top: -3px;
left: 0;
}
.banner-footer {
margin-top: 1.5em;
}
.banner-button {
background: #fda84e;
color: #000;
display: inline-block;
text-align: center;
height: 50px;
line-height: 50px;
border-radius: 5px;
text-decoration: none;
font-weight: 500;
padding: 0 15px;
font-size: 15px;
}
.sidebar-widget {
margin-top: 15px;
margin-bottom: 15px;
background: rgb( 255, 255, 255 );
padding: 5px 15px;
}
.sidebar-widget .password-protected-feature {
padding-bottom: 15px;
font-size: 15px;
}
.sidebar-widget .banner-button {
font-size: 12px;
font-weight: 500;
padding: 0 10px;
height: 35px;
line-height: 35px;
}
.clearfix {
clear: both;
display: table;
}
.password-protected-feature a:hover {
text-decoration: underline;
}
.password-protected-feature a {
text-decoration: none;
color: #000;
}
.sidebar-widget .banner-body {
width: calc( 100% - 25px );
}
.password-protected-datatable {
width: 100%;
}
.password-protected-datatable thead tr th,
.password-protected-datatable tfoot tr th {
cursor: pointer;
border: 1px solid #dcdcde;
background: #fff;
padding: 15px 0;
}
.password-protected-datatable tbody tr td {
padding: 15px 0;
border: 1px solid #dcdcde;
}
.pp-help-notice {
margin-top: 15px;
margin-bottom: 15px;
background: #EBEDF1;
padding: 10px;
border: 1px solid #d9dce3;
border-radius: 5px;
color: #000;
}
.pp-help-notice p {
font-size: 14px;
font-weight: 500;
margin: 0;
}
/*
tabs UI styling
*/
.pp-wrapper {
margin-top: 15px;
width: 100%;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
background: #fff;
}
.pp-nav-wrapper {
width: 100%;
background: #efeff0;
}
.pp-nav-tab {
border-top-left-radius: 5px;
border-top-right-radius: 5px;
display: inline-block;
border-right: 1px solid #d9dce3;
background: #f6f6f6;
}
.pp-nav-tab a {
font-size: 14px;
font-weight: 600;
color: #707578;
text-decoration: none;
padding: 8px 14px;
display: block;
line-height: 32px;
}
.pp-nav-tab span {
line-height: 32px;
display: inline-block;
font-size: 21px;
font-weight: 600;
}
.pp-nav-tab-active {
background: #fff;
}
.pp-nav-tab-active a {
color: #8076ff;
}
.pp-nav-tab:hover {
background: #fff;
}
.pp-nav-tab a:hover {
color: #8076ff;
}
.pp-sub-tabs-wrapper {
width: calc( 100% - 15px );
height: 45px;
background: #fff;
border-bottom: 1px solid #f7f8fa;
}
.pp-sub-tabs-wrapper .pp-subtabs-links {
height: 45px;
display: inline-block;
border-bottom: 3px solid #f7f8fa;
position: relative;
}
.pp-subtabs-links a {
line-height: 45px;
text-decoration: none;
font-weight: 600;
color: #707578;
font-size: 14px;
padding: 0 15px;
height: calc( 100% - 1px );
display: inline-block;
}
.pp-subtabs-links a.active {
border-bottom: 3px solid #8076ff;
color: #8076ff;
}
.pp-subtabs-links a:hover {
color: #8076ff;
}
.pp-subtabs-links a:focus, .pp-nav-tab a:focus {
outline: none;
box-shadow: none;
}
.pp-settings-wrapper {
width: calc( 100% - 30px );
background: transparent;
border-top: none;
}
.pp-content-wrapper {
padding: 20px;
box-shadow: 0 0 20px #00000012;
}
.pp-content-wrapper:has( input[type="submit"].button.button-primary ) {
padding-bottom: 0;
}
/**
* Creating a toggle switch
*/
.pp-toggle-wrapper {
position: relative;
overflow: hidden;
display: inline-block;
transform: scale( 0.8 );
transform-origin: left;
font-size: 10px;
color: #707578;
}
.pp-toggle-wrapper input {
position: absolute;
left: -99em;
}
.pp-toggle-wrapper .pp-toggle {
cursor: pointer;
display: inline-block;
position: relative;
width: 50px;
height: 30px;
border-radius: 20px;
font-weight: 600;
border: 1px solid #e4e8ec;
transition: all 200ms cubic-bezier( 0.445, 0.05, 0.55, 0.95);
}
.pp-toggle-wrapper .pp-toggle:before {
content: "";
left: 18px;
color: #fff;
}
.pp-toggle-wrapper .pp-toggle-slider {
display: inline-block;
position: relative;
z-index: 1;
width: 25px;
height: 25px;
top: 3px;
left: 3px;
transition: all 200ms cubic-bezier(0.445, 0.05, 0.55, 0.95);
border-radius: 20px;
background: #bbbbbb;
}
.pp-toggle-wrapper input:checked + .pp-toggle .pp-toggle-slider {
width: 25px;
transform: translateX(20px);
background: #8076ff;
}
.pp-toggle-wrapper input:checked + .pp-toggle:before {
color: #23282d;
}
.pp-toggle-wrapper input:checked + .pp-toggle {
background: transparent;
}
.pp-pro-tab {
background: #8076ff;
}
.pp-pro-tab.pp-nav-tab-active {
background: #8076ff;
}
.pp-pro-tab a,
.pp-pro-tab a:hover {
background: #8076ff;
color: #fff;
}
.pp-pro-tab span {
color: #fcc045;
margin-right: 10px;
font-size: 30px;
}
/**
* Adding css for pro banner
*/
.pp-pro-banner {
width: 800px;
height: 484px;
background-image: url( "../images/banner-background.png" );
}
.pp-pro-banner * {
color: #2D3748;
}
.pp-pro-banner .pp-container {
padding: 20px;
}
.pp-wrapper:has( .pp-pro-banner ) {
}
.pp-content-wrapper:has( .pp-pro-banner ) {
padding: 20px 20px 20px 20px;
}
.pp-pro-banner .pp-container .heading-1 {
font-size: 16px;
font-weight: 400;
padding: 0;
margin: 0;
}
.pp-pro-banner .pp-container .heading-2 {
font-size: 24px;
font-weight: 700;
padding: 0;
margin: 0;
}
.pp-pro-banner .pp-container .heading-2 span {
color: #8076FF;
}
.pp-banner-body {
margin: 20px 0;
width: 100%;
}
.pp-cols {
width: 50%;
float: left;
}
.pp-cols div {
font-size: 14px;
font-weight: 400;
margin-bottom: 25px;
color: #2D3748;
}
.pp-cols div a {
text-decoration: none;
color: #2D3748;
}
.pp-cols div a:hover {
text-decoration: underline;
text-decoration-color: #2D3748;
}
.pp-cols.pp-cols-section-2 div {
/*margin-bottom: 35px;*/
}
.pp-cols div img {
margin-bottom: -4px;
}
.pp-clearfix {
clear: both;
display: table;
}
.pp-sidebar-footer a,
.pp-banner-footer a {
display: inline-block;
background: #8076FF;
padding: 10px 20px;
border-radius: 50px;
font-size: 14px;
font-weight: 600;
color: #fff;
text-decoration: none;
}
.pp-sidebar-footer a {
font-size: 12px;
}
.pp-sidebar-widget {
float: right;
margin-top: 15px;
position: relative;
width: 250px;
background: linear-gradient(180deg, #dad7ff 0%, #fff 100%);
background-position-x: right;
background-position-y: bottom;
border-radius: 8px;
border: 1px solid #DAD7FF;
}
.pp-sidebar-widget .pp-container {
padding: 20px;
}
.pp-sidebar-header .heading-1 {
font-size: 16px;
font-weight: 400;
padding: 0;
margin: 0;
}
.pp-sidebar-header .heading-2 {
font-size: 24px;
font-weight: 700;
padding: 0;
margin: 0;
}
.pp-sidebar-header .heading-2 img {
margin-bottom: -15px;
margin-left: 8px;
}
.pp-sidebar-header .heading-2 span {
color: #8076FF;
}
.pp-sidebar-body {
margin: 20px 0;
width: 100%;
}
.pp-sidebar-body ul li img {
margin-bottom: -4px;
}
.pp-sidebar-body ul li a {
text-decoration: none;
color: #2D3748;
}
.pp-sidebar-body ul li a:hover {
text-decoration: underline;
text-decoration-color: #2D3748;
}
.pp-sidebar-body ul li {
font-weight: 400;
font-size: 14px;
margin-bottom: 15px;
}
.pp-sidebar-footer {
text-align: center;
width: 100%;
}
.pp-docs-link {
padding: 0 5px;
border-radius: 5px;
display: inline-block;
background: #ffffff;
font-size: 10px;
font-weight: 600;
}
.pp-docs-link a {
color: #8076ff !important;
}
.pro-badge {
border: 1px solid #1d2327;
border-radius: 5px;
padding: 0 5px;
background: #8674f6;
height: 25px;
display: inline-block;
}
.pro-badge a {
color: #fff;
font-weight: 600;
text-decoration: none;
font-size: 13px;
padding: 0;margin: 0;
line-height: 25px;
display: block;
}
.pp-pro-branding *[disabled] {
background: #f7f7f7;
color: #b3b3b3;
}
@media screen and ( max-width: 1589px ) {
.pp-nav-tab a {
padding: 8px 10px;
}
}
@media screen and ( max-width: 1496px ) {
.pp-nav-tab a {
padding: 8px 8px;
font-size: 10px;
}
.pp-nav-tab a span {
font-size: 19px;
}
.pp-nav-tab span {
margin-right: 0;
}
}
@media screen and ( max-width: 1272px ) {
.wrap-row {
display: block;
}
.wrap-col-70 {
display: block;
width: 100%;
}
.wrap-col-25 {
display: block;
width: 100%;
}
}
.sidebar-body-image-container {
width: 25px;
display: inline-block;
float: left;
}
.sidebar-body-text-container {
width: calc( 100% - 25px );
display: inline-block;
float: left;
}
.pp-sidebar-widget li:has( .sidebar-body-text-container ), .pp-sidebar-widget li:has( .sidebar-body-image-container ) {
clear: both;
display: table;
}

View File

@@ -0,0 +1,8 @@
.g-recaptcha {
display: inline-block;
-webkit-transform: scale(.9);
transform: scale(.9);
-webkit-transform-origin: 0 0;
transform-origin: 0 0;
margin-bottom: 0.3rem;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 254 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 367 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 546 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 585 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 624 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 587 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 356 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 494 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 566 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 442 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 487 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 464 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 592 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 404 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 613 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 935 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@@ -0,0 +1,52 @@
jQuery( document ).ready(function( $ ) {
toggle_recaptcha_version( $ );
set_recaptcha_version_fields( $ );
} );
function set_recaptcha_version_fields( $ ) {
var selected_version = $("input[name='password_protected_recaptcha[version]']:checked").val();
if( selected_version == 'google_recaptcha_v2' ) {
hide_recaptcha_v3_fields( $ );
} else {
hide_recaptcha_v2_fields( $ );
}
}
function toggle_recaptcha_version( $ ) {
$("input[name='password_protected_recaptcha[version]']").on('change', function() {
if( $(this).val() === 'google_recaptcha_v2' ) {
// hide v3 fields
hide_recaptcha_v3_fields( $ );
// show v2 fields
$("#pp_google_recaptcha_v2_site_key").parent('div').fadeIn();
$("#pp_google_recaptcha_v2_secret_key").parent('div').fadeIn();
$("input[name='password_protected_recaptcha[v2_theme]']").parent('label').parent('td').parent('tr').fadeIn();
} else {
// show v3 fields
$("#pp_google_recaptcha_v3_site_key").parent('div').fadeIn();
$("#pp_google_recaptcha_v3_secret_key").parent('div').fadeIn();
$("#pp_google_recpatcha_v3_score").parent('td').parent('tr').fadeIn();
$("#pp_google_recpatcha_v3_badge").parent('td').parent('tr').fadeIn();
// hide v2 fields
hide_recaptcha_v2_fields( $ );
}
});
}
function hide_recaptcha_v2_fields( $ ) {
$("#pp_google_recaptcha_v2_site_key").parent('div').hide();
$("#pp_google_recaptcha_v2_secret_key").parent('div').hide();
$("input[name='password_protected_recaptcha[v2_theme]']").parent('label').parent('td').parent('tr').hide();
}
function hide_recaptcha_v3_fields( $ ) {
$("#pp_google_recaptcha_v3_site_key").parent('div').hide();
$("#pp_google_recaptcha_v3_secret_key").parent('div').hide();
$("#pp_google_recpatcha_v3_score").parent('td').parent('tr').hide();
$("#pp_google_recpatcha_v3_badge").parent('td').parent('tr').hide();
}

View File

@@ -0,0 +1,14 @@
( function( $, data ) {
if ( ! data ) {
data = function( agent, data ) {
agent = detect.parse( agent );
data = `${agent.browser.family} ${agent.os.name} ${agent.device.type}`;
return data;
}
}
$( document ).ready( function( $ ) {
$( "input[name='password_protected_user_agent']" ).val( data( navigator.userAgent ) );
} );
} )( jQuery );

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

View File

@@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
{one line to give the program's name and a brief idea of what it does.}
Copyright (C) {year} {name of author}
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
{project} Copyright (C) {year} {fullname}
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

View File

@@ -0,0 +1,282 @@
Freemius WordPress SDK
======================
Welcome to the official repository for the Freemius SDK! Adding the SDK to your WordPress plugin, theme, or add-ons, enables all the benefits that come with using the [Freemius platform](https://freemius.com) such as:
* [Software Licensing](https://freemius.com/wordpress/software-licensing/)
* [Secure Checkout](https://freemius.com/wordpress/checkout/)
* [Subscriptions](https://freemius.com/wordpress/recurring-payments-subscriptions/)
* [Automatic Updates](https://freemius.com/wordpress/automatic-software-updates/)
* [Seamless EU VAT](https://freemius.com/wordpress/collecting-eu-vat-europe/)
* [Cart Abandonment Recovery](https://freemius.com/wordpress/cart-abandonment-recovery/)
* [Affiliate Platform](https://freemius.com/wordpress/affiliate-platform/)
* [Analytics & Usage Tracking](https://freemius.com/wordpress/insights/)
* [User Dashboard](https://freemius.com/wordpress/user-dashboard/)
* [Monetization](https://freemius.com/wordpress/)
* [Analytics](https://freemius.com/wordpress/insights/)
* [More...](https://freemius.com/wordpress/features-comparison/)
Freemius truly empowers developers to create prosperous subscription-based businesses.
If you're new to Freemius then we recommend taking a look at our [Getting Started](https://freemius.com/help/documentation/getting-started/) guide first.
If you're a WordPress plugin or theme developer and are interested in monetizing with Freemius then you can [sign-up for a FREE account](https://dashboard.freemius.com/register/):
https://dashboard.freemius.com/register/
Once you have your account setup and are familiar with how it all works you're ready to begin [integrating Freemius](https://freemius.com/help/documentation/wordpress-sdk/integrating-freemius-sdk/) into your WordPress product
You can see some of the existing WordPress.org plugins & themes that are already utilizing the power of Freemius here:
* https://profiles.wordpress.org/freemius/#content-plugins
* https://includewp.com/freemius/#focus
## Code Documentation
You can find the SDK's documentation here:
https://freemius.com/help/documentation/wordpress-sdk/
## Integrating & Initializing the SDK
As part of the integration process, you'll need to [add the latest version](https://freemius.com/help/documentation/getting-started/#add_the_latest_wordpress_sdk_into_your_product) of the Freemius SDK into your WordPress project.
Then, when you've completed the [SDK integration form](https://freemius.com/help/documentation/getting-started/#fill_out_the_sdk_integration_form) a snippet of code is generated which you'll need to copy and paste into the top of your main plugin's PHP file, right after the plugin's header comment.
Note: For themes, this will be in the root `functions.php` file instead.
A typical SDK snippet will look similar to the following (your particular snippet may differ slightly depending on your integration):
```php
if ( ! function_exists( 'my_prefix_fs' ) ) {
// 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-new-plugin',
'premium_slug' => 'my-new-plugin-premium',
'type' => 'plugin',
'public_key' => 'pk_bAEfta69seKymZzmf2xtqq8QXHz9y',
'is_premium' => true,
// If your plugin is a serviceware, set this option to false.
'has_premium_version' => true,
'has_paid_plans' => true,
'is_org_compliant' => true,
'menu' => array(
'slug' => 'my-new-plugin',
'parent' => array(
'slug' => 'options-general.php',
),
),
// Set the SDK to work in a sandbox mode (for development & testing).
// IMPORTANT: MAKE SURE TO REMOVE SECRET KEY BEFORE DEPLOYMENT.
'secret_key' => 'sk_ubb4yN3mzqGR2x8#P7r5&@*xC$utE',
) );
}
return $my_prefix_fs;
}
// Init Freemius.
my_prefix_fs();
// Signal that SDK was initiated.
do_action( 'my_prefix_fs_loaded' );
}
```
## Usage example
You can call anySDK methods by prefixing them with the shortcode function for your particular plugin/theme (specified when completing the SDK integration form in the Developer Dashboard):
```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();
?>
```
There are many other SDK methods available that you can use to enhance the functionality of your WordPress product. Some of the more common use-cases are covered in the [Freemius SDK Gists](https://freemius.com/help/documentation/wordpress-sdk/gists/) documentation.
## 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](https://freemius.com/help/documentation/wordpress-sdk/software-licensing/#excluding_files_and_folders_from_the_free_plugin_version) 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 types of files, not only PHP.
2. Add `@fs_premium_only` a special 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 ...
?>
```
In the example plugin header above, 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 use [some of the other methods](https://freemius.com/help/documentation/wordpress-sdk/software-licensing/) provided by the SDK to exclude premium features & files from the free version.
## Deployment
Zip your Freemius products root folder and [upload it in the Deployment section](https://freemius.com/help/documentation/selling-with-freemius/deployment/) in the *Freemius Developer's Dashboard*.
The plugin/theme will automatically 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 compliant 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.
## License
Copyright (c) Freemius®, Inc.
Licensed under the GNU general public license (version 3).

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
#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}

View File

@@ -0,0 +1 @@
@media screen and (max-width: 782px){#wpbody-content{padding-bottom:0 !important}}

View File

@@ -0,0 +1 @@
.fs-notice[data-id^=clone_resolution_options_notice]{padding:0;color:inherit !important}.fs-notice[data-id^=clone_resolution_options_notice] .fs-notice-body{padding:0;margin-bottom:0}.fs-notice[data-id^=clone_resolution_options_notice] .fs-notice-header{padding:5px 10px}.fs-notice[data-id^=clone_resolution_options_notice] ol{margin-top:0;margin-bottom:0}.fs-notice[data-id^=clone_resolution_options_notice] .fs-clone-resolution-options-container{display:flex;flex-direction:row;padding:0 10px 10px}@media(max-width: 750px){.fs-notice[data-id^=clone_resolution_options_notice] .fs-clone-resolution-options-container{flex-direction:column}}.fs-notice[data-id^=clone_resolution_options_notice] .fs-clone-resolution-option{border:1px solid #ccc;padding:10px 10px 15px 10px;flex:auto;margin:5px}.fs-notice[data-id^=clone_resolution_options_notice] .fs-clone-resolution-option:first-child{margin-left:0}.fs-notice[data-id^=clone_resolution_options_notice] .fs-clone-resolution-option:last-child{margin-right:0}.fs-notice[data-id^=clone_resolution_options_notice] .fs-clone-resolution-option strong{font-size:1.2em;padding:2px;line-height:1.5em}.fs-notice[data-id^=clone_resolution_options_notice] a{text-decoration:none}.fs-notice[data-id^=clone_resolution_options_notice] .button{margin-right:10px}.rtl .fs-notice[data-id^=clone_resolution_options_notice] .button{margin-right:0;margin-left:10px}.fs-notice[data-id^=clone_resolution_options_notice] .fs-clone-documentation-container{padding:0 10px 15px}.fs-notice[data-id=temporary_duplicate_notice] #fs_clone_resolution_error_message{border:1px solid #d3135a;background:#fee;color:#d3135a;padding:10px}.fs-notice[data-id=temporary_duplicate_notice] ol{margin-top:0}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
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-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}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
.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}

View File

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

View File

@@ -0,0 +1 @@
.fs-tooltip-trigger{position:relative}.fs-tooltip-trigger:not(a){cursor:help}.fs-tooltip-trigger .dashicons{float:none !important}.fs-tooltip-trigger .fs-tooltip{opacity:0;visibility:hidden;-moz-transition:opacity .3s ease-in-out;-o-transition:opacity .3s ease-in-out;-ms-transition:opacity .3s ease-in-out;-webkit-transition:opacity .3s ease-in-out;transition:opacity .3s ease-in-out;position:absolute;background:rgba(0,0,0,.8);color:#fff !important;font-family:"arial",serif;font-size:12px;padding:10px;z-index:999999;bottom:100%;margin-bottom:5px;left:-17px;right:0;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;-moz-box-shadow:1px 1px 1px rgba(0,0,0,.2);-webkit-box-shadow:1px 1px 1px rgba(0,0,0,.2);box-shadow:1px 1px 1px rgba(0,0,0,.2);line-height:1.3em;font-weight:bold;text-align:left;text-transform:none !important}.rtl .fs-tooltip-trigger .fs-tooltip{text-align:right;left:auto;right:-17px}.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,.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-permissions .fs-permission.fs-disabled{color:#aaa}.fs-permissions .fs-permission.fs-disabled .fs-permission-description span{color:#aaa}.fs-permissions .fs-permission .fs-switch-feedback{position:absolute;right:15px;top:52px}.fs-permissions ul{height:0;overflow:hidden;margin:0}.fs-permissions ul li{padding:17px 15px;margin:0;position:relative}.fs-permissions ul li>i.dashicons{float:left;font-size:30px;width:30px;height:30px;padding:5px}.fs-permissions ul li .fs-switch{float:right}.fs-permissions ul li .fs-permission-description{margin-left:55px}.fs-permissions ul li .fs-permission-description span{font-size:14px;font-weight:500;color:#23282d}.fs-permissions ul li .fs-permission-description .fs-tooltip{font-size:13px;font-weight:bold}.fs-permissions ul li .fs-permission-description .fs-tooltip-trigger .dashicons{margin:-1px 2px 0 2px}.fs-permissions ul li .fs-permission-description p{margin:2px 0 0 0}.fs-permissions.fs-open{background:#fff}.fs-permissions.fs-open ul{overflow:initial;height:auto;margin:20px 0 10px 0}.fs-permissions .fs-switch-feedback .fs-ajax-spinner{margin-right:10px}.fs-permissions .fs-switch-feedback.success{color:#71ae00}.rtl .fs-permissions .fs-switch-feedback{right:auto;left:15px}.rtl .fs-permissions .fs-switch-feedback .fs-ajax-spinner{margin-left:10px;margin-right:0}.rtl .fs-permissions ul li .fs-permission-description{margin-right:55px;margin-left:0}.rtl .fs-permissions ul li .fs-switch{float:left}.rtl .fs-permissions ul li i.dashicons{float:right}.fs-modal-opt-out .fs-modal-footer .fs-opt-out-button{line-height:30px;margin-right:10px}.fs-modal-opt-out .fs-permissions{margin-top:0 !important}.fs-modal-opt-out .fs-permissions .fs-permissions-section--header .fs-group-opt-out-button{float:right;line-height:1.1em}.fs-modal-opt-out .fs-permissions .fs-permissions-section--header .fs-switch-feedback{float:right;line-height:1.1em;margin-right:10px}.fs-modal-opt-out .fs-permissions .fs-permissions-section--header .fs-switch-feedback .fs-ajax-spinner{margin:-2px 0 0}.fs-modal-opt-out .fs-permissions .fs-permissions-section--header-title{font-size:1.1em;font-weight:600;text-transform:uppercase;display:block;line-height:1.1em;margin:.5em 0}.fs-modal-opt-out .fs-permissions .fs-permissions-section--desc{margin-top:0}.fs-modal-opt-out .fs-permissions hr{border:0;border-top:#eee solid 1px;margin:25px 0 20px 0}.fs-modal-opt-out .fs-permissions ul{border:1px solid #c3c4c7;border-radius:3px;margin:10px 0 0 0;box-shadow:0 1px 1px rgba(0,0,0,.04)}.fs-modal-opt-out .fs-permissions ul li{border-bottom:1px solid #d7dde1;border-left:4px solid #72aee6}.rtl .fs-modal-opt-out .fs-permissions ul li{border-left:none;border-right:4px solid #72aee6}.fs-modal-opt-out .fs-permissions ul li.fs-disabled{border-left-color:rgba(114,174,230,0)}.fs-modal-opt-out .fs-permissions ul li:last-child{border-bottom:none}

View File

@@ -0,0 +1 @@
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}

View File

@@ -0,0 +1 @@
#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 .3s ease-in-out;-o-transition:opacity .3s ease-in-out;-ms-transition:opacity .3s ease-in-out;-webkit-transition:opacity .3s ease-in-out;transition:opacity .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,.2);-webkit-box-shadow:1px 1px 1px rgba(0,0,0,.2);box-shadow:1px 1px 1px rgba(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}

View File

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

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

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

View File

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

View File

@@ -0,0 +1,140 @@
/*!
* 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;
}

View File

@@ -0,0 +1,12 @@
/*
* 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};

View File

@@ -0,0 +1,135 @@
(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);

View File

@@ -0,0 +1,391 @@
<?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;
}
if ( ! defined( 'WP_FS__SLUG' ) ) {
define( 'WP_FS__SLUG', 'freemius' );
}
if ( ! defined( 'WP_FS__DEV_MODE' ) ) {
define( 'WP_FS__DEV_MODE', false );
}
#--------------------------------------------------------------------------------
#region API Connectivity Issues Simulation
#--------------------------------------------------------------------------------
if ( ! defined( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY' ) ) {
define( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY', false );
}
if ( ! defined( 'WP_FS__SIMULATE_NO_CURL' ) ) {
define( 'WP_FS__SIMULATE_NO_CURL', false );
}
if ( ! defined( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE' ) ) {
define( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE', false );
}
if ( ! defined( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL' ) ) {
define( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL', false );
}
if ( WP_FS__SIMULATE_NO_CURL ) {
define( 'FS_SDK__SIMULATE_NO_CURL', true );
}
if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE ) {
define( 'FS_SDK__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE', true );
}
if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL ) {
define( 'FS_SDK__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL', true );
}
#endregion
if ( ! defined( 'WP_FS__SIMULATE_FREEMIUS_OFF' ) ) {
define( 'WP_FS__SIMULATE_FREEMIUS_OFF', false );
}
if ( ! defined( 'WP_FS__PING_API_ON_IP_OR_HOST_CHANGES' ) ) {
/**
* @since 1.1.7.3
* @author Vova Feldman (@svovaf)
*
* I'm not sure if shared servers periodically change IP, or the subdomain of the
* admin dashboard. Also, I've seen sites that have strange loop of switching
* between domains on a daily basis. Therefore, to eliminate the risk of
* multiple unwanted connectivity test pings, temporary ignore domain or
* server IP changes.
*/
define( 'WP_FS__PING_API_ON_IP_OR_HOST_CHANGES', false );
}
/**
* If your dev environment supports custom public network IP setup
* like VVV, please update WP_FS__LOCALHOST_IP with your public IP
* and uncomment it during dev.
*/
if ( ! defined( 'WP_FS__LOCALHOST_IP' ) ) {
// VVV default public network IP.
define( 'WP_FS__VVV_DEFAULT_PUBLIC_IP', '192.168.50.4' );
// define( 'WP_FS__LOCALHOST_IP', WP_FS__VVV_DEFAULT_PUBLIC_IP );
}
/**
* If true and running with secret key, the opt-in process
* will skip the email activation process which is invoked
* when the email of the context user already exist in Freemius
* database (as a security precaution, to prevent sharing user
* secret with unauthorized entity).
*
* IMPORTANT:
* AS A SECURITY PRECAUTION, WE VALIDATE THE TIMESTAMP OF THE OPT-IN REQUEST.
* THEREFORE, MAKE SURE THAT WHEN USING THIS PARAMETER,YOUR TESTING ENVIRONMENT'S
* CLOCK IS SYNCED.
*/
if ( ! defined( 'WP_FS__SKIP_EMAIL_ACTIVATION' ) ) {
define( 'WP_FS__SKIP_EMAIL_ACTIVATION', false );
}
#--------------------------------------------------------------------------------
#region Directories
#--------------------------------------------------------------------------------
if ( ! defined( 'WP_FS__DIR' ) ) {
define( 'WP_FS__DIR', dirname( __FILE__ ) );
}
if ( ! defined( 'WP_FS__DIR_INCLUDES' ) ) {
define( 'WP_FS__DIR_INCLUDES', WP_FS__DIR . '/includes' );
}
if ( ! defined( 'WP_FS__DIR_TEMPLATES' ) ) {
define( 'WP_FS__DIR_TEMPLATES', WP_FS__DIR . '/templates' );
}
if ( ! defined( 'WP_FS__DIR_ASSETS' ) ) {
define( 'WP_FS__DIR_ASSETS', WP_FS__DIR . '/assets' );
}
if ( ! defined( 'WP_FS__DIR_CSS' ) ) {
define( 'WP_FS__DIR_CSS', WP_FS__DIR_ASSETS . '/css' );
}
if ( ! defined( 'WP_FS__DIR_JS' ) ) {
define( 'WP_FS__DIR_JS', WP_FS__DIR_ASSETS . '/js' );
}
if ( ! defined( 'WP_FS__DIR_IMG' ) ) {
define( 'WP_FS__DIR_IMG', WP_FS__DIR_ASSETS . '/img' );
}
if ( ! defined( 'WP_FS__DIR_SDK' ) ) {
define( 'WP_FS__DIR_SDK', WP_FS__DIR_INCLUDES . '/sdk' );
}
#endregion
/**
* Domain / URL / Address
*/
define( 'WP_FS__ROOT_DOMAIN_PRODUCTION', 'freemius.com' );
define( 'WP_FS__DOMAIN_PRODUCTION', 'wp.freemius.com' );
define( 'WP_FS__ADDRESS_PRODUCTION', 'https://' . WP_FS__DOMAIN_PRODUCTION );
if ( ! defined( 'WP_FS__DOMAIN_LOCALHOST' ) ) {
define( 'WP_FS__DOMAIN_LOCALHOST', 'wp.freemius' );
}
if ( ! defined( 'WP_FS__ADDRESS_LOCALHOST' ) ) {
define( 'WP_FS__ADDRESS_LOCALHOST', 'http://' . WP_FS__DOMAIN_LOCALHOST . ':8080' );
}
if ( ! defined( 'WP_FS__TESTING_DOMAIN' ) ) {
define( 'WP_FS__TESTING_DOMAIN', 'fswp' );
}
#--------------------------------------------------------------------------------
#region HTTP
#--------------------------------------------------------------------------------
if ( ! defined( 'WP_FS__IS_HTTP_REQUEST' ) ) {
define( 'WP_FS__IS_HTTP_REQUEST', isset( $_SERVER['HTTP_HOST'] ) && isset( $_SERVER['REQUEST_METHOD'] ) );
}
if ( ! defined( 'WP_FS__IS_HTTPS' ) ) {
define( 'WP_FS__IS_HTTPS', ( WP_FS__IS_HTTP_REQUEST &&
// Checks if CloudFlare's HTTPS (Flexible SSL support).
isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) &&
'https' === strtolower( $_SERVER['HTTP_X_FORWARDED_PROTO'] )
) ||
// Check if HTTPS request.
( isset( $_SERVER['HTTPS'] ) && 'on' == $_SERVER['HTTPS'] ) ||
( isset( $_SERVER['SERVER_PORT'] ) && 443 == $_SERVER['SERVER_PORT'] )
);
}
if ( ! defined( 'WP_FS__IS_POST_REQUEST' ) ) {
define( 'WP_FS__IS_POST_REQUEST', ( WP_FS__IS_HTTP_REQUEST &&
strtoupper( $_SERVER['REQUEST_METHOD'] ) == 'POST' ) );
}
if ( ! defined( 'WP_FS__REMOTE_ADDR' ) ) {
define( 'WP_FS__REMOTE_ADDR', fs_get_ip() );
}
if ( ! defined( 'WP_FS__IS_LOCALHOST' ) ) {
if ( defined( 'WP_FS__LOCALHOST_IP' ) ) {
define( 'WP_FS__IS_LOCALHOST', ( WP_FS__LOCALHOST_IP === WP_FS__REMOTE_ADDR ) );
} else {
define( 'WP_FS__IS_LOCALHOST', WP_FS__IS_HTTP_REQUEST &&
is_string( WP_FS__REMOTE_ADDR ) &&
( substr( WP_FS__REMOTE_ADDR, 0, 4 ) === '127.' ||
WP_FS__REMOTE_ADDR === '::1' )
);
}
}
if ( ! defined( 'WP_FS__IS_LOCALHOST_FOR_SERVER' ) ) {
define( 'WP_FS__IS_LOCALHOST_FOR_SERVER', ( ! WP_FS__IS_HTTP_REQUEST ||
false !== strpos( $_SERVER['HTTP_HOST'], 'localhost' ) ) );
}
#endregion
if ( ! defined( 'WP_FS__IS_PRODUCTION_MODE' ) ) {
// By default, run with Freemius production servers.
define( 'WP_FS__IS_PRODUCTION_MODE', true );
}
if ( ! defined( 'WP_FS__ADDRESS' ) ) {
define( 'WP_FS__ADDRESS', ( WP_FS__IS_PRODUCTION_MODE ? WP_FS__ADDRESS_PRODUCTION : WP_FS__ADDRESS_LOCALHOST ) );
}
#--------------------------------------------------------------------------------
#region API
#--------------------------------------------------------------------------------
if ( ! defined( 'WP_FS__API_ADDRESS_LOCALHOST' ) ) {
define( 'WP_FS__API_ADDRESS_LOCALHOST', 'http://api.freemius-local.com:8080' );
}
if ( ! defined( 'WP_FS__API_SANDBOX_ADDRESS_LOCALHOST' ) ) {
define( 'WP_FS__API_SANDBOX_ADDRESS_LOCALHOST', 'http://sandbox-api.freemius:8080' );
}
// Set API address for local testing.
if ( ! WP_FS__IS_PRODUCTION_MODE ) {
if ( ! defined( 'FS_API__ADDRESS' ) ) {
define( 'FS_API__ADDRESS', WP_FS__API_ADDRESS_LOCALHOST );
}
if ( ! defined( 'FS_API__SANDBOX_ADDRESS' ) ) {
define( 'FS_API__SANDBOX_ADDRESS', WP_FS__API_SANDBOX_ADDRESS_LOCALHOST );
}
}
#endregion
#--------------------------------------------------------------------------------
#region Checkout
#--------------------------------------------------------------------------------
if ( ! defined( 'FS_CHECKOUT__ADDRESS_PRODUCTION' ) ) {
define( 'FS_CHECKOUT__ADDRESS_PRODUCTION', 'https://checkout.freemius.com' );
}
if ( ! defined( 'FS_CHECKOUT__ADDRESS_LOCALHOST' ) ) {
define( 'FS_CHECKOUT__ADDRESS_LOCALHOST', 'http://checkout.freemius-local.com:8080' );
}
if ( ! defined( 'FS_CHECKOUT__ADDRESS' ) ) {
define( 'FS_CHECKOUT__ADDRESS', ( WP_FS__IS_PRODUCTION_MODE ? FS_CHECKOUT__ADDRESS_PRODUCTION : FS_CHECKOUT__ADDRESS_LOCALHOST ) );
}
#endregion
define( 'WP_FS___OPTION_PREFIX', 'fs' . ( WP_FS__IS_PRODUCTION_MODE ? '' : '_dbg' ) . '_' );
if ( ! defined( 'WP_FS__ACCOUNTS_OPTION_NAME' ) ) {
define( 'WP_FS__ACCOUNTS_OPTION_NAME', WP_FS___OPTION_PREFIX . 'accounts' );
}
if ( ! defined( 'WP_FS__API_CACHE_OPTION_NAME' ) ) {
define( 'WP_FS__API_CACHE_OPTION_NAME', WP_FS___OPTION_PREFIX . 'api_cache' );
}
if ( ! defined( 'WP_FS__GDPR_OPTION_NAME' ) ) {
define( 'WP_FS__GDPR_OPTION_NAME', WP_FS___OPTION_PREFIX . 'gdpr' );
}
define( 'WP_FS__OPTIONS_OPTION_NAME', WP_FS___OPTION_PREFIX . 'options' );
/**
* Module types
*
* @since 1.2.2
*/
define( 'WP_FS__MODULE_TYPE_PLUGIN', 'plugin' );
define( 'WP_FS__MODULE_TYPE_THEME', 'theme' );
/**
* Billing Frequencies
*/
define( 'WP_FS__PERIOD_ANNUALLY', 'annual' );
define( 'WP_FS__PERIOD_MONTHLY', 'monthly' );
define( 'WP_FS__PERIOD_LIFETIME', 'lifetime' );
/**
* Plans
*/
define( 'WP_FS__PLAN_DEFAULT_PAID', false );
define( 'WP_FS__PLAN_FREE', 'free' );
define( 'WP_FS__PLAN_TRIAL', 'trial' );
/**
* Times in seconds
*/
if ( ! defined( 'WP_FS__TIME_5_MIN_IN_SEC' ) ) {
define( 'WP_FS__TIME_5_MIN_IN_SEC', 300 );
}
if ( ! defined( 'WP_FS__TIME_10_MIN_IN_SEC' ) ) {
define( 'WP_FS__TIME_10_MIN_IN_SEC', 600 );
}
// define( 'WP_FS__TIME_15_MIN_IN_SEC', 900 );
if ( ! defined( 'WP_FS__TIME_12_HOURS_IN_SEC' ) ) {
define( 'WP_FS__TIME_12_HOURS_IN_SEC', 43200 );
}
if ( ! defined( 'WP_FS__TIME_24_HOURS_IN_SEC' ) ) {
define( 'WP_FS__TIME_24_HOURS_IN_SEC', WP_FS__TIME_12_HOURS_IN_SEC * 2 );
}
if ( ! defined( 'WP_FS__TIME_WEEK_IN_SEC' ) ) {
define( 'WP_FS__TIME_WEEK_IN_SEC', 7 * WP_FS__TIME_24_HOURS_IN_SEC );
}
#--------------------------------------------------------------------------------
#region Debugging
#--------------------------------------------------------------------------------
if ( ! defined( 'WP_FS__DEBUG_SDK' ) ) {
$debug_mode = get_option( 'fs_debug_mode', null );
if ( $debug_mode === null ) {
$debug_mode = false;
add_option( 'fs_debug_mode', $debug_mode );
}
define( 'WP_FS__DEBUG_SDK', is_numeric( $debug_mode ) ? ( 0 < $debug_mode ) : WP_FS__DEV_MODE );
}
if ( ! defined( 'WP_FS__ECHO_DEBUG_SDK' ) ) {
define( 'WP_FS__ECHO_DEBUG_SDK', WP_FS__DEV_MODE && ! empty( $_GET['fs_dbg_echo'] ) );
}
if ( ! defined( 'WP_FS__LOG_DATETIME_FORMAT' ) ) {
define( 'WP_FS__LOG_DATETIME_FORMAT', 'Y-m-d H:i:s' );
}
if ( ! defined( 'FS_API__LOGGER_ON' ) ) {
define( 'FS_API__LOGGER_ON', WP_FS__DEBUG_SDK );
}
if ( WP_FS__ECHO_DEBUG_SDK ) {
error_reporting( E_ALL );
}
#endregion
if ( ! defined( 'WP_FS__SCRIPT_START_TIME' ) ) {
define( 'WP_FS__SCRIPT_START_TIME', time() );
}
if ( ! defined( 'WP_FS__DEFAULT_PRIORITY' ) ) {
define( 'WP_FS__DEFAULT_PRIORITY', 10 );
}
if ( ! defined( 'WP_FS__LOWEST_PRIORITY' ) ) {
define( 'WP_FS__LOWEST_PRIORITY', 999999999 );
}
#--------------------------------------------------------------------------------
#region Multisite Network
#--------------------------------------------------------------------------------
/**
* Do not use this define directly, it will have the wrong value
* during plugin uninstall/deletion when the inclusion of the plugin
* is triggered due to registration with register_uninstall_hook().
*
* Instead, use fs_is_network_admin().
*
* @author Vova Feldman (@svovaf)
*/
if ( ! defined( 'WP_FS__IS_NETWORK_ADMIN' ) ) {
define( 'WP_FS__IS_NETWORK_ADMIN',
is_multisite() &&
( is_network_admin() ||
( ( defined( 'DOING_AJAX' ) && DOING_AJAX &&
( isset( $_REQUEST['_fs_network_admin'] ) && 'true' === $_REQUEST['_fs_network_admin'] /*||
( ! empty( $_REQUEST['action'] ) && 'delete-plugin' === $_REQUEST['action'] )*/ )
) ||
// Plugin uninstall.
defined( 'WP_UNINSTALL_PLUGIN' ) )
)
);
}
/**
* Do not use this define directly, it will have the wrong value
* during plugin uninstall/deletion when the inclusion of the plugin
* is triggered due to registration with register_uninstall_hook().
*
* Instead, use fs_is_blog_admin().
*
* @author Vova Feldman (@svovaf)
*/
if ( ! defined( 'WP_FS__IS_BLOG_ADMIN' ) ) {
define( 'WP_FS__IS_BLOG_ADMIN', is_blog_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX && isset( $_REQUEST['_fs_blog_admin'] ) ) );
}
if ( ! defined( 'WP_FS__SHOW_NETWORK_EVEN_WHEN_DELEGATED' ) ) {
// Set to true to show network level settings even if delegated to site admins.
define( 'WP_FS__SHOW_NETWORK_EVEN_WHEN_DELEGATED', false );
}
#endregion
if ( ! defined( 'WP_FS__DEMO_MODE' ) ) {
define( 'WP_FS__DEMO_MODE', false );
}
if ( ! defined( 'FS_SDK__SSLVERIFY' ) ) {
define( 'FS_SDK__SSLVERIFY', false );
}

View File

@@ -0,0 +1,538 @@
<?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.7
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* - Each instance of Freemius class represents a single plugin
* install by a single user (the installer of the plugin).
*
* - Each website can only have one install of the same plugin.
*
* - Install entity is only created after a user connects his account with Freemius.
*
* Class Freemius_Abstract
*/
abstract class Freemius_Abstract {
#----------------------------------------------------------------------------------
#region Identity
#----------------------------------------------------------------------------------
/**
* Check if user has connected his account (opted-in).
*
* Note:
* If the user opted-in and opted-out on a later stage,
* this will still return true. If you want to check if the
* user is currently opted-in, use:
* `$fs->is_registered() && $fs->is_tracking_allowed()`
*
* @since 1.0.1
*
* @param bool $ignore_anonymous_state Since 2.5.1
*
* @return bool
*/
abstract function is_registered( $ignore_anonymous_state = false );
/**
* Check if the user skipped connecting the account with Freemius.
*
* @since 1.0.7
*
* @return bool
*/
abstract function is_anonymous();
/**
* Check if the user currently in activation mode.
*
* @since 1.0.7
*
* @return bool
*/
abstract function is_activation_mode();
#endregion
#----------------------------------------------------------------------------------
#region Module Type
#----------------------------------------------------------------------------------
/**
* Checks if the plugin's type is "plugin". The other type is "theme".
*
* @author Leo Fajardo (@leorw)
* @since 1.2.2
*
* @return bool
*/
abstract function is_plugin();
/**
* Checks if the module type is "theme". The other type is "plugin".
*
* @author Leo Fajardo (@leorw)
* @since 1.2.2
*
* @return bool
*/
function is_theme() {
return ( ! $this->is_plugin() );
}
#endregion
#----------------------------------------------------------------------------------
#region Permissions
#----------------------------------------------------------------------------------
/**
* Check if plugin must be WordPress.org compliant.
*
* @since 1.0.7
*
* @return bool
*/
abstract function is_org_repo_compliant();
/**
* Check if plugin is allowed to install executable files.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.5
*
* @return bool
*/
function is_allowed_to_install() {
return ( $this->is_premium() || ! $this->is_org_repo_compliant() );
}
#endregion
/**
* Check if user in trial or in free plan (not paying).
*
* @author Vova Feldman (@svovaf)
* @since 1.0.4
*
* @return bool
*/
function is_not_paying() {
return ( $this->is_trial() || $this->is_free_plan() );
}
/**
* Check if the user has an activated and valid paid license on current plugin's install.
*
* @since 1.0.9
*
* @return bool
*/
abstract function is_paying();
/**
* Check if the user is paying or in trial.
*
* @since 1.0.9
*
* @return bool
*/
function is_paying_or_trial() {
return ( $this->is_paying() || $this->is_trial() );
}
/**
* Check if user in a trial or have feature enabled license.
*
* @author Vova Feldman (@svovaf)
* @since 1.1.7
*
* @return bool
*/
abstract function can_use_premium_code();
#----------------------------------------------------------------------------------
#region Premium Only
#----------------------------------------------------------------------------------
/**
* All logic wrapped in methods with "__premium_only()" suffix will be only
* included in the premium code.
*
* Example:
* if ( freemius()->is__premium_only() ) {
* ...
* }
*/
/**
* Returns true when running premium plugin code.
*
* @since 1.0.9
*
* @return bool
*/
function is__premium_only() {
return $this->is_premium();
}
/**
* Check if the user has an activated and valid paid license on current plugin's install.
*
* @since 1.0.9
*
* @return bool
*
*/
function is_paying__premium_only() {
return ( $this->is__premium_only() && $this->is_paying() );
}
/**
* All code wrapped in this statement will be only included in the premium code.
*
* @since 1.0.9
*
* @param string $plan Plan name.
* @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
*
* @return bool
*/
function is_plan__premium_only( $plan, $exact = false ) {
return ( $this->is_premium() && $this->is_plan( $plan, $exact ) );
}
/**
* Check if plan matches active license' plan or active trial license' plan.
*
* All code wrapped in this statement will be only included in the premium code.
*
* @since 1.0.9
*
* @param string $plan Plan name.
* @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
*
* @return bool
*/
function is_plan_or_trial__premium_only( $plan, $exact = false ) {
return ( $this->is_premium() && $this->is_plan_or_trial( $plan, $exact ) );
}
/**
* Check if the user is paying or in trial.
*
* All code wrapped in this statement will be only included in the premium code.
*
* @since 1.0.9
*
* @return bool
*/
function is_paying_or_trial__premium_only() {
return $this->is_premium() && $this->is_paying_or_trial();
}
/**
* Check if the user has an activated and valid paid license on current plugin's install.
*
* @since 1.0.4
*
* @return bool
*
* @deprecated Method name is confusing since it's not clear from the name the code will be removed.
* @using Alias to is_paying__premium_only()
*/
function is_paying__fs__() {
return $this->is_paying__premium_only();
}
/**
* Check if user in a trial or have feature enabled license.
*
* All code wrapped in this statement will be only included in the premium code.
*
* @author Vova Feldman (@svovaf)
* @since 1.1.9
*
* @return bool
*/
function can_use_premium_code__premium_only() {
return $this->is_premium() && $this->can_use_premium_code();
}
#endregion
#----------------------------------------------------------------------------------
#region Trial
#----------------------------------------------------------------------------------
/**
* Check if the user in a trial.
*
* @since 1.0.3
*
* @return bool
*/
abstract function is_trial();
/**
* Check if trial already utilized.
*
* @since 1.0.9
*
* @return bool
*/
abstract function is_trial_utilized();
#endregion
#----------------------------------------------------------------------------------
#region Plans
#----------------------------------------------------------------------------------
/**
* Check if the user is on the free plan of the product.
*
* @since 1.0.4
*
* @return bool
*/
abstract function is_free_plan();
/**
* @since 1.0.2
*
* @param string $plan Plan name.
* @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
*
* @return bool
*/
abstract function is_plan( $plan, $exact = false );
/**
* Check if plan based on trial. If not in trial mode, should return false.
*
* @since 1.0.9
*
* @param string $plan Plan name.
* @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
*
* @return bool
*/
abstract function is_trial_plan( $plan, $exact = false );
/**
* Check if plan matches active license' plan or active trial license' plan.
*
* @since 1.0.9
*
* @param string $plan Plan name.
* @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
*
* @return bool
*/
function is_plan_or_trial( $plan, $exact = false ) {
return $this->is_plan( $plan, $exact ) ||
$this->is_trial_plan( $plan, $exact );
}
/**
* Check if plugin has any paid plans.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.7
*
* @return bool
*/
abstract function has_paid_plan();
/**
* 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
*
* @return bool
*/
abstract function has_free_plan();
/**
* Check if plugin is premium only (no free plans).
*
* NOTE: is__premium_only() is very different method, don't get confused.
*
* @author Vova Feldman (@svovaf)
* @since 1.1.9
*
* @return bool
*/
abstract function is_only_premium();
/**
* Check if module has a premium code version.
*
* Serviceware module might be freemium without any
* premium code version, where the paid features
* are all part of the service.
*
* @author Vova Feldman (@svovaf)
* @since 1.2.1.6
*
* @return bool
*/
abstract function has_premium_version();
/**
* Check if module has any release on Freemius,
* or all plugin's code is on WordPress.org (Serviceware).
*
* @return bool
*/
function has_release_on_freemius() {
return ! $this->is_org_repo_compliant() ||
$this->has_premium_version();
}
/**
* Checks if it's a freemium plugin.
*
* @author Vova Feldman (@svovaf)
* @since 1.1.9
*
* @return bool
*/
function is_freemium() {
return $this->has_paid_plan() &&
$this->has_free_plan();
}
/**
* Check if module has only one plan.
*
* @author Vova Feldman (@svovaf)
* @since 1.2.1.7
*
* @return bool
*/
abstract function is_single_plan();
#endregion
/**
* Check if running payments in sandbox mode.
*
* @since 1.0.4
*
* @return bool
*/
abstract function is_payments_sandbox();
/**
* Check if running test vs. live plugin.
*
* @since 1.0.5
*
* @return bool
*/
abstract function is_live();
/**
* Check if running premium plugin code.
*
* @since 1.0.5
*
* @return bool
*/
abstract function is_premium();
/**
* Get upgrade URL.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.2
*
* @param string $period Billing cycle.
*
* @return string
*/
abstract function get_upgrade_url( $period = WP_FS__PERIOD_ANNUALLY );
/**
* Check if Freemius was first added in a plugin update.
*
* @author Vova Feldman (@svovaf)
* @since 1.1.5
*
* @return bool
*/
function is_plugin_update() {
return ! $this->is_plugin_new_install();
}
/**
* Check if Freemius was part of the plugin when the user installed it first.
*
* @author Vova Feldman (@svovaf)
* @since 1.1.5
*
* @return bool
*/
abstract function is_plugin_new_install();
#----------------------------------------------------------------------------------
#region Marketing
#----------------------------------------------------------------------------------
/**
* Check if current user purchased any other plugins before.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.9
*
* @return bool
*/
abstract function has_purchased_before();
/**
* Check if current user classified as an agency.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.9
*
* @return bool
*/
abstract function is_agency();
/**
* Check if current user classified as a developer.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.9
*
* @return bool
*/
abstract function is_developer();
/**
* Check if current user classified as a business.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.9
*
* @return bool
*/
abstract function is_business();
#endregion
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,353 @@
<?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.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* WP Admin notices manager both for site level and network level.
*
* Class FS_Admin_Notices
*/
class FS_Admin_Notices {
/**
* @since 1.2.2
*
* @var string
*/
protected $_module_unique_affix;
/**
* @var string
*/
protected $_id;
/**
* @var string
*/
protected $_title;
/**
* @var FS_Admin_Notice_Manager
*/
protected $_notices;
/**
* @var FS_Admin_Notice_Manager
*/
protected $_network_notices;
/**
* @var int The ID of the blog that is associated with the current site level options.
*/
private $_blog_id = 0;
/**
* @var bool
*/
private $_is_multisite;
/**
* @var FS_Admin_Notices[]
*/
private static $_instances = array();
/**
* @param string $id
* @param string $title
* @param string $module_unique_affix
* @param bool $is_network_and_blog_admins Whether or not the message should be shown both on network and
* blog admin pages.
*
* @return FS_Admin_Notices
*/
static function instance( $id, $title = '', $module_unique_affix = '', $is_network_and_blog_admins = false ) {
if ( ! isset( self::$_instances[ $id ] ) ) {
self::$_instances[ $id ] = new FS_Admin_Notices( $id, $title, $module_unique_affix, $is_network_and_blog_admins );
}
return self::$_instances[ $id ];
}
/**
* @param string $id
* @param string $title
* @param string $module_unique_affix
* @param bool $is_network_and_blog_admins Whether or not the message should be shown both on network and
* blog admin pages.
*/
protected function __construct( $id, $title = '', $module_unique_affix = '', $is_network_and_blog_admins = false ) {
$this->_id = $id;
$this->_title = $title;
$this->_module_unique_affix = $module_unique_affix;
$this->_is_multisite = is_multisite();
if ( $this->_is_multisite ) {
$this->_blog_id = get_current_blog_id();
$this->_network_notices = FS_Admin_Notice_Manager::instance(
$id,
$title,
$module_unique_affix,
$is_network_and_blog_admins,
true
);
}
$this->_notices = FS_Admin_Notice_Manager::instance(
$id,
$title,
$module_unique_affix,
false,
$this->_blog_id
);
}
/**
* Add admin message to admin messages queue, and hook to admin_notices / all_admin_notices if not yet hooked.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.4
*
* @param string $message
* @param string $title
* @param string $type
* @param bool $is_sticky
* @param string $id Message ID
* @param bool $store_if_sticky
* @param int|null $network_level_or_blog_id
*
* @uses add_action()
*/
function add(
$message,
$title = '',
$type = 'success',
$is_sticky = false,
$id = '',
$store_if_sticky = true,
$network_level_or_blog_id = null,
$is_dimissible = null
) {
$notices = $this->get_site_or_network_notices( $id, $network_level_or_blog_id );
$notices->add(
$message,
$title,
$type,
$is_sticky,
$id,
$store_if_sticky,
null,
null,
false,
$is_dimissible
);
}
/**
* @author Vova Feldman (@svovaf)
* @since 1.0.7
*
* @param string|string[] $ids
* @param int|null $network_level_or_blog_id
* @param bool $store
*/
function remove_sticky( $ids, $network_level_or_blog_id = null, $store = true ) {
if ( ! is_array( $ids ) ) {
$ids = array( $ids );
}
if ( $this->should_use_network_notices( $ids[0], $network_level_or_blog_id ) ) {
$notices = $this->_network_notices;
} else {
$notices = $this->get_site_notices( $network_level_or_blog_id );
}
return $notices->remove_sticky( $ids, $store );
}
/**
* Check if sticky message exists by id.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.9
*
* @param string $id
* @param int|null $network_level_or_blog_id
*
* @return bool
*/
function has_sticky( $id, $network_level_or_blog_id = null ) {
$notices = $this->get_site_or_network_notices( $id, $network_level_or_blog_id );
return $notices->has_sticky( $id );
}
/**
* Adds sticky admin notification.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.7
*
* @param string $message
* @param string $id Message ID
* @param string $title
* @param string $type
* @param int|null $network_level_or_blog_id
* @param number|null $wp_user_id
* @param string|null $plugin_title
* @param bool $is_network_and_blog_admins Whether or not the message should be shown both on network and
* blog admin pages.
* @param bool $is_dismissible
*/
function add_sticky(
$message,
$id,
$title = '',
$type = 'success',
$network_level_or_blog_id = null,
$wp_user_id = null,
$plugin_title = null,
$is_network_and_blog_admins = false,
$is_dismissible = true,
$data = array()
) {
$notices = $this->get_site_or_network_notices( $id, $network_level_or_blog_id );
$notices->add_sticky( $message, $id, $title, $type, $wp_user_id, $plugin_title, $is_network_and_blog_admins, $is_dismissible, $data );
}
/**
* Retrieves the data of a sticky notice.
*
* @author Leo Fajardo (@leorw)
* @since 2.4.3
*
* @param string $id
* @param int|null $network_level_or_blog_id
*
* @return array|null
*/
function get_sticky( $id, $network_level_or_blog_id ) {
$notices = $this->get_site_or_network_notices( $id, $network_level_or_blog_id );
return $notices->get_sticky( $id );
}
/**
* Clear all sticky messages.
*
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @param int|null $network_level_or_blog_id
* @param bool $is_temporary
*/
function clear_all_sticky( $network_level_or_blog_id = null, $is_temporary = false ) {
if ( ! $this->_is_multisite ||
false === $network_level_or_blog_id ||
0 == $network_level_or_blog_id ||
is_null( $network_level_or_blog_id )
) {
$notices = $this->get_site_notices( $network_level_or_blog_id );
$notices->clear_all_sticky( $is_temporary );
}
if ( $this->_is_multisite &&
( true === $network_level_or_blog_id || is_null( $network_level_or_blog_id ) )
) {
$this->_network_notices->clear_all_sticky( $is_temporary );
}
}
/**
* Add admin message to all admin messages queue, and hook to all_admin_notices if not yet hooked.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.4
*
* @param string $message
* @param string $title
* @param string $type
* @param bool $is_sticky
* @param string $id Message ID
*/
function add_all( $message, $title = '', $type = 'success', $is_sticky = false, $id = '' ) {
$this->add( $message, $title, $type, $is_sticky, true, $id );
}
#--------------------------------------------------------------------------------
#region Helper Methods
#--------------------------------------------------------------------------------
/**
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @param int $blog_id
*
* @return FS_Admin_Notice_Manager
*/
private function get_site_notices( $blog_id = 0 ) {
if ( 0 == $blog_id || $blog_id == $this->_blog_id ) {
return $this->_notices;
}
return FS_Admin_Notice_Manager::instance(
$this->_id,
$this->_title,
$this->_module_unique_affix,
false,
$blog_id
);
}
/**
* Check if the network notices should be used.
*
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @param string $id
* @param null|bool|int $network_level_or_blog_id When an integer, use the given blog storage. When `true` use the multisite notices (if there's a network). When `false`, use the current context blog notices. When `null`, the decision which notices manager to use (MS vs. Current S) will be handled internally and determined based on the $id and the context admin (blog admin vs. network level admin).
*
* @return bool
*/
private function should_use_network_notices( $id = '', $network_level_or_blog_id = null ) {
if ( ! $this->_is_multisite ) {
// Not a multisite environment.
return false;
}
if ( is_numeric( $network_level_or_blog_id ) ) {
// Explicitly asked to use a specified blog storage.
return false;
}
if ( is_bool( $network_level_or_blog_id ) ) {
// Explicitly specified whether should use the network or blog level storage.
return $network_level_or_blog_id;
}
return fs_is_network_admin();
}
/**
* Retrieves an instance of FS_Admin_Notice_Manager.
*
* @author Leo Fajardo (@leorw)
* @since 2.5.0
*
* @param string $id
* @param int|null $network_level_or_blog_id
*
* @return FS_Admin_Notice_Manager
*/
private function get_site_or_network_notices( $id, $network_level_or_blog_id ) {
return $this->should_use_network_notices( $id, $network_level_or_blog_id ) ?
$this->_network_notices :
$this->get_site_notices( $network_level_or_blog_id );
}
#endregion
}

View File

@@ -0,0 +1,719 @@
<?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_Api
*
* Wraps Freemius API SDK to handle:
* 1. Clock sync.
* 2. Fallback to HTTP when HTTPS fails.
* 3. Adds caching layer to GET requests.
* 4. Adds consistency for failed requests by using last cached version.
*/
class FS_Api {
/**
* @var FS_Api[]
*/
private static $_instances = array();
/**
* @var FS_Option_Manager Freemius options, options-manager.
*/
private static $_options;
/**
* @var FS_Cache_Manager API Caching layer
*/
private static $_cache;
/**
* @var int Clock diff in seconds between current server to API server.
*/
private static $_clock_diff;
/**
* @var Freemius_Api_WordPress
*/
private $_api;
/**
* @var string
*/
private $_slug;
/**
* @var FS_Logger
* @since 1.0.4
*/
private $_logger;
/**
* @author Leo Fajardo (@leorw)
* @since 2.3.0
*
* @var string
*/
private $_sdk_version;
/**
* @author Leo Fajardo (@leorw)
* @since 2.5.0
*
* @var string
*/
private $_url;
/**
* @param string $slug
* @param string $scope 'app', 'developer', 'user' or 'install'.
* @param number $id Element's id.
* @param string $public_key Public key.
* @param bool $is_sandbox
* @param bool|string $secret_key Element's secret key.
* @param null|string $sdk_version
* @param null|string $url
*
* @return FS_Api
*/
static function instance(
$slug,
$scope,
$id,
$public_key,
$is_sandbox,
$secret_key = false,
$sdk_version = null,
$url = null
) {
$identifier = md5( $slug . $scope . $id . $public_key . ( is_string( $secret_key ) ? $secret_key : '' ) . json_encode( $is_sandbox ) );
if ( ! isset( self::$_instances[ $identifier ] ) ) {
self::_init();
self::$_instances[ $identifier ] = new FS_Api( $slug, $scope, $id, $public_key, $secret_key, $is_sandbox, $sdk_version, $url );
}
return self::$_instances[ $identifier ];
}
private static function _init() {
if ( isset( self::$_options ) ) {
return;
}
if ( ! class_exists( 'Freemius_Api_WordPress' ) ) {
require_once WP_FS__DIR_SDK . '/FreemiusWordPress.php';
}
self::$_options = FS_Option_Manager::get_manager( WP_FS__OPTIONS_OPTION_NAME, true, true );
self::$_cache = FS_Cache_Manager::get_manager( WP_FS__API_CACHE_OPTION_NAME );
self::$_clock_diff = self::$_options->get_option( 'api_clock_diff', 0 );
Freemius_Api_WordPress::SetClockDiff( self::$_clock_diff );
if ( self::$_options->get_option( 'api_force_http', false ) ) {
Freemius_Api_WordPress::SetHttp();
}
}
/**
* @param string $slug
* @param string $scope 'app', 'developer', 'user' or 'install'.
* @param number $id Element's id.
* @param string $public_key Public key.
* @param bool|string $secret_key Element's secret key.
* @param bool $is_sandbox
* @param null|string $sdk_version
* @param null|string $url
*/
private function __construct(
$slug,
$scope,
$id,
$public_key,
$secret_key,
$is_sandbox,
$sdk_version,
$url
) {
$this->_api = new Freemius_Api_WordPress( $scope, $id, $public_key, $secret_key, $is_sandbox );
$this->_slug = $slug;
$this->_sdk_version = $sdk_version;
$this->_url = $url;
$this->_logger = FS_Logger::get_logger( WP_FS__SLUG . '_' . $slug . '_api', WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
}
/**
* Find clock diff between server and API server, and store the diff locally.
*
* @param bool|int $diff
*
* @return bool|int False if clock diff didn't change, otherwise returns the clock diff in seconds.
*/
private function _sync_clock_diff( $diff = false ) {
$this->_logger->entrance();
// Sync clock and store.
$new_clock_diff = ( false === $diff ) ?
Freemius_Api_WordPress::FindClockDiff() :
$diff;
if ( $new_clock_diff === self::$_clock_diff ) {
return false;
}
self::$_clock_diff = $new_clock_diff;
// Update API clock's diff.
Freemius_Api_WordPress::SetClockDiff( self::$_clock_diff );
// Store new clock diff in storage.
self::$_options->set_option( 'api_clock_diff', self::$_clock_diff, true );
return $new_clock_diff;
}
/**
* Override API call to enable retry with servers' clock auto sync method.
*
* @param string $path
* @param string $method
* @param array $params
* @param bool $in_retry Is in retry or first call attempt.
*
* @return array|mixed|string|void
*/
private function _call( $path, $method = 'GET', $params = array(), $in_retry = false ) {
$this->_logger->entrance( $method . ':' . $path );
$force_http = ( ! $in_retry && self::$_options->get_option( 'api_force_http', false ) );
if ( self::is_temporary_down() ) {
$result = $this->get_temporary_unavailable_error();
} else {
/**
* @since 2.3.0 Include the SDK version with all API requests that going through the API manager. IMPORTANT: Only pass the SDK version if the caller didn't include it yet.
*/
if ( ! empty( $this->_sdk_version ) ) {
if ( false === strpos( $path, 'sdk_version=' ) &&
! isset( $params['sdk_version'] )
) {
// Always add the sdk_version param in the querystring. DO NOT INCLUDE IT IN THE BODY PARAMS, OTHERWISE, IT MAY LEAD TO AN UNEXPECTED PARAMS PARSING IN CASES WHERE THE $params IS A REGULAR NON-ASSOCIATIVE ARRAY.
$path = add_query_arg( 'sdk_version', $this->_sdk_version, $path );
}
}
/**
* @since 2.5.0 Include the site's URL, if available, in all API requests that are going through the API manager.
*/
if ( ! empty( $this->_url ) ) {
if ( false === strpos( $path, 'url=' ) &&
! isset( $params['url'] )
) {
$path = add_query_arg( 'url', $this->_url, $path );
}
}
$result = $this->_api->Api( $path, $method, $params );
if (
! $in_retry &&
null !== $result &&
isset( $result->error ) &&
isset( $result->error->code )
) {
$retry = false;
if ( 'request_expired' === $result->error->code ) {
$diff = isset( $result->error->timestamp ) ?
( time() - strtotime( $result->error->timestamp ) ) :
false;
// Try to sync clock diff.
if ( false !== $this->_sync_clock_diff( $diff ) ) {
// Retry call with new synced clock.
$retry = true;
}
} else if (
Freemius_Api_WordPress::IsHttps() &&
FS_Api::is_ssl_error_response( $result )
) {
$force_http = true;
$retry = true;
}
if ( $retry ) {
if ( $force_http ) {
$this->toggle_force_http( true );
}
$result = $this->_call( $path, $method, $params, true );
}
}
}
if ( self::is_api_error( $result ) ) {
if ( $this->_logger->is_on() ) {
// Log API errors.
$this->_logger->api_error( $result );
}
if ( $force_http ) {
$this->toggle_force_http( false );
}
}
return $result;
}
/**
* Override API call to wrap it in servers' clock sync method.
*
* @param string $path
* @param string $method
* @param array $params
*
* @return array|mixed|string|void
* @throws Freemius_Exception
*/
function call( $path, $method = 'GET', $params = array() ) {
return $this->_call( $path, $method, $params );
}
/**
* Get API request URL signed via query string.
*
* @param string $path
*
* @return string
*/
function get_signed_url( $path ) {
return $this->_api->GetSignedUrl( $path );
}
/**
* @param string $path
* @param bool $flush
* @param int $expiration (optional) Time until expiration in seconds from now, defaults to 24 hours
*
* @return stdClass|mixed
*/
function get( $path = '/', $flush = false, $expiration = WP_FS__TIME_24_HOURS_IN_SEC ) {
$this->_logger->entrance( $path );
$cache_key = $this->get_cache_key( $path );
// Always flush during development.
if ( WP_FS__DEV_MODE || $this->_api->IsSandbox() ) {
$flush = true;
}
$cached_result = self::$_cache->get( $cache_key );
if ( $flush || ! self::$_cache->has_valid( $cache_key, $expiration ) ) {
$result = $this->call( $path );
if ( ! is_object( $result ) || isset( $result->error ) ) {
// Api returned an error.
if ( is_object( $cached_result ) &&
! isset( $cached_result->error )
) {
// If there was an error during a newer data fetch,
// fallback to older data version.
$result = $cached_result;
if ( $this->_logger->is_on() ) {
$this->_logger->warn( 'Fallback to cached API result: ' . var_export( $cached_result, true ) );
}
} else {
if ( is_object( $result ) && isset( $result->error->http ) && 404 == $result->error->http ) {
/**
* If the response code is 404, cache the result for half of the `$expiration`.
*
* @author Leo Fajardo (@leorw)
* @since 2.2.4
*/
$expiration /= 2;
} else {
// If no older data version and the response code is not 404, return result without
// caching the error.
return $result;
}
}
}
self::$_cache->set( $cache_key, $result, $expiration );
$cached_result = $result;
} else {
$this->_logger->log( 'Using cached API result.' );
}
return $cached_result;
}
/**
* @todo Remove this method after migrating Freemius::safe_remote_post() to FS_Api::call().
*
* @author Leo Fajardo (@leorw)
* @since 2.5.4
*
* @param string $url
* @param array $remote_args
*
* @return array|WP_Error The response array or a WP_Error on failure.
*/
static function remote_request( $url, $remote_args ) {
if ( ! class_exists( 'Freemius_Api_WordPress' ) ) {
require_once WP_FS__DIR_SDK . '/FreemiusWordPress.php';
}
if ( method_exists( 'Freemius_Api_WordPress', 'RemoteRequest' ) ) {
return Freemius_Api_WordPress::RemoteRequest( $url, $remote_args );
}
// The following is for backward compatibility when a modified PHP SDK version is in use and the `Freemius_Api_WordPress:RemoteRequest()` method doesn't exist.
$response = wp_remote_request( $url, $remote_args );
if (
is_array( $response ) &&
(
empty( $response['headers'] ) ||
empty( $response['headers']['x-api-server'] )
)
) {
// API is considered blocked if the response doesn't include the `x-api-server` header. When there's no error but this header doesn't exist, the response is usually not in the expected form (e.g., cannot be JSON-decoded).
$response = new WP_Error( 'api_blocked', htmlentities( $response['body'] ) );
}
return $response;
}
/**
* Check if there's a cached version of the API request.
*
* @author Vova Feldman (@svovaf)
* @since 1.2.1
*
* @param string $path
* @param string $method
* @param array $params
*
* @return bool
*/
function is_cached( $path, $method = 'GET', $params = array() ) {
$cache_key = $this->get_cache_key( $path, $method, $params );
return self::$_cache->has_valid( $cache_key );
}
/**
* Invalidate a cached version of the API request.
*
* @author Vova Feldman (@svovaf)
* @since 1.2.1.5
*
* @param string $path
* @param string $method
* @param array $params
*/
function purge_cache( $path, $method = 'GET', $params = array() ) {
$this->_logger->entrance( "{$method}:{$path}" );
$cache_key = $this->get_cache_key( $path, $method, $params );
self::$_cache->purge( $cache_key );
}
/**
* Invalidate a cached version of the API request.
*
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @param string $path
* @param int $expiration
* @param string $method
* @param array $params
*/
function update_cache_expiration( $path, $expiration = WP_FS__TIME_24_HOURS_IN_SEC, $method = 'GET', $params = array() ) {
$this->_logger->entrance( "{$method}:{$path}:{$expiration}" );
$cache_key = $this->get_cache_key( $path, $method, $params );
self::$_cache->update_expiration( $cache_key, $expiration );
}
/**
* @param string $path
* @param string $method
* @param array $params
*
* @return string
* @throws \Freemius_Exception
*/
private function get_cache_key( $path, $method = 'GET', $params = array() ) {
$canonized = $this->_api->CanonizePath( $path );
// $exploded = explode('/', $canonized);
// return $method . '_' . array_pop($exploded) . '_' . md5($canonized . json_encode($params));
return strtolower( $method . ':' . $canonized ) . ( ! empty( $params ) ? '#' . md5( json_encode( $params ) ) : '' );
}
/**
* @author Leo Fajardo (@leorw)
* @since 2.5.4
*
* @param bool $is_http
*/
private function toggle_force_http( $is_http ) {
self::$_options->set_option( 'api_force_http', $is_http, true );
if ( $is_http ) {
Freemius_Api_WordPress::SetHttp();
} else if ( method_exists( 'Freemius_Api_WordPress', 'SetHttps' ) ) {
Freemius_Api_WordPress::SetHttps();
}
}
/**
* @author Leo Fajardo (@leorw)
* @since 2.5.4
*
* @param mixed $response
*
* @return bool
*/
static function is_blocked( $response ) {
return (
self::is_api_error_object( $response, true ) &&
isset( $response->error->code ) &&
'api_blocked' === $response->error->code
);
}
/**
* Check if API is temporary down.
*
* @author Vova Feldman (@svovaf)
* @since 1.1.6
*
* @return bool
*/
static function is_temporary_down() {
self::_init();
$test = self::$_cache->get_valid( 'ping_test', null );
return ( false === $test );
}
/**
* @author Vova Feldman (@svovaf)
* @since 1.1.6
*
* @return object
*/
private function get_temporary_unavailable_error() {
return (object) array(
'error' => (object) array(
'type' => 'TemporaryUnavailable',
'message' => 'API is temporary unavailable, please retry in ' . ( self::$_cache->get_record_expiration( 'ping_test' ) - WP_FS__SCRIPT_START_TIME ) . ' sec.',
'code' => 'temporary_unavailable',
'http' => 503
)
);
}
/**
* Check if based on the API result we should try
* to re-run the same request with HTTP instead of HTTPS.
*
* @author Vova Feldman (@svovaf)
* @since 1.1.6
*
* @param $result
*
* @return bool
*/
private static function should_try_with_http( $result ) {
if ( ! Freemius_Api_WordPress::IsHttps() ) {
return false;
}
return ( ! is_object( $result ) ||
! isset( $result->error ) ||
! isset( $result->error->code ) ||
! in_array( $result->error->code, array(
'curl_missing',
'cloudflare_ddos_protection',
'maintenance_mode',
'squid_cache_block',
'too_many_requests',
) ) );
}
function get_url( $path = '' ) {
return Freemius_Api_WordPress::GetUrl( $path, $this->_api->IsSandbox() );
}
/**
* Clear API cache.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.9
*/
static function clear_cache() {
self::_init();
self::$_cache = FS_Cache_Manager::get_manager( WP_FS__API_CACHE_OPTION_NAME );
self::$_cache->clear();
}
/**
* @author Leo Fajardo (@leorw)
* @since 2.5.4
*/
static function clear_force_http_flag() {
self::$_options->unset_option( 'api_force_http' );
}
#----------------------------------------------------------------------------------
#region Error Handling
#----------------------------------------------------------------------------------
/**
* @author Vova Feldman (@svovaf)
* @since 1.2.1.5
*
* @param mixed $result
*
* @return bool Is API result contains an error.
*/
static function is_api_error( $result ) {
return ( is_object( $result ) && isset( $result->error ) ) ||
is_string( $result );
}
/**
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @param mixed $result
* @param bool $ignore_message
*
* @return bool Is API result contains an error.
*/
static function is_api_error_object( $result, $ignore_message = false ) {
return (
is_object( $result ) &&
isset( $result->error ) &&
( $ignore_message || isset( $result->error->message ) )
);
}
/**
* @author Leo Fajardo (@leorw)
* @since 2.5.4
*
* @param WP_Error|object|string $response
*
* @return bool
*/
static function is_ssl_error_response( $response ) {
$http_error = null;
if ( $response instanceof WP_Error ) {
if (
isset( $response->errors ) &&
isset( $response->errors['http_request_failed'] )
) {
$http_error = strtolower( $response->errors['http_request_failed'][0] );
}
} else if (
self::is_api_error_object( $response ) &&
! empty( $response->error->message )
) {
$http_error = $response->error->message;
}
return (
! empty( $http_error ) &&
(
false !== strpos( $http_error, 'curl error 35' ) ||
(
false === strpos( $http_error, '</html>' ) &&
false !== strpos( $http_error, 'ssl' )
)
)
);
}
/**
* Checks if given API result is a non-empty and not an error object.
*
* @author Vova Feldman (@svovaf)
* @since 1.2.1.5
*
* @param mixed $result
* @param string|null $required_property Optional property we want to verify that is set.
*
* @return bool
*/
static function is_api_result_object( $result, $required_property = null ) {
return (
is_object( $result ) &&
! isset( $result->error ) &&
( empty( $required_property ) || isset( $result->{$required_property} ) )
);
}
/**
* Checks if given API result is a non-empty entity object with non-empty ID.
*
* @author Vova Feldman (@svovaf)
* @since 1.2.1.5
*
* @param mixed $result
*
* @return bool
*/
static function is_api_result_entity( $result ) {
return self::is_api_result_object( $result, 'id' ) &&
FS_Entity::is_valid_id( $result->id );
}
/**
* Get API result error code. If failed to get code, returns an empty string.
*
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @param mixed $result
*
* @return string
*/
static function get_error_code( $result ) {
if ( is_object( $result ) &&
isset( $result->error ) &&
is_object( $result->error ) &&
! empty( $result->error->code )
) {
return $result->error->code;
}
return '';
}
#endregion
}

View File

@@ -0,0 +1,110 @@
<?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.5.1
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class FS_Lock
*
* @author Vova Feldman (@svovaf)
* @since 2.5.1
*/
class FS_Lock {
/**
* @var int Random ID representing the current PHP thread.
*/
private static $_thread_id;
/**
* @var string
*/
private $_lock_id;
/**
* @param string $lock_id
*/
function __construct( $lock_id ) {
if ( ! fs_starts_with( $lock_id, WP_FS___OPTION_PREFIX ) ) {
$lock_id = WP_FS___OPTION_PREFIX . $lock_id;
}
$this->_lock_id = $lock_id;
if ( ! isset( self::$_thread_id ) ) {
self::$_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.
*
* @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( $this->_lock_id, self::$_thread_id, $expiration );
if ( $this->has_lock() ) {
$this->lock($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( $this->_lock_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( $this->_lock_id ) );
}
/**
* Unlock the lock.
*
* @author Vova Feldman (@svovaf)
* @since 2.1.0
*/
function unlock() {
delete_site_transient( $this->_lock_id );
}
/**
* Checks if lock is currently acquired by the current locker.
*
* @return bool
*/
protected function has_lock() {
return ( self::$_thread_id == get_site_transient( $this->_lock_id ) );
}
}

View File

@@ -0,0 +1,692 @@
<?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_Logger {
private $_id;
private $_on = false;
private $_echo = false;
private $_file_start = 0;
/**
* @var int PHP Process ID.
*/
private static $_processID;
/**
* @var string PHP Script user name.
*/
private static $_ownerName;
/**
* @var bool Is storage logging turned on.
*/
private static $_isStorageLoggingOn;
/**
* @var int ABSPATH length.
*/
private static $_abspathLength;
private static $LOGGERS = array();
private static $LOG = array();
private static $CNT = 0;
private static $_HOOKED_FOOTER = false;
private function __construct( $id, $on = false, $echo = false ) {
$bt = debug_backtrace();
$this->_id = $id;
$caller = $bt[2];
if ( false !== strpos( $caller['file'], 'plugins' ) ) {
$this->_file_start = strpos( $caller['file'], 'plugins' ) + strlen( 'plugins/' );
} else {
$this->_file_start = strpos( $caller['file'], 'themes' ) + strlen( 'themes/' );
}
if ( $on ) {
$this->on();
}
if ( $echo ) {
$this->echo_on();
}
}
/**
* @param string $id
* @param bool $on
* @param bool $echo
*
* @return FS_Logger
*/
public static function get_logger( $id, $on = false, $echo = false ) {
$id = strtolower( $id );
if ( ! isset( self::$_processID ) ) {
self::init();
}
if ( ! isset( self::$LOGGERS[ $id ] ) ) {
self::$LOGGERS[ $id ] = new FS_Logger( $id, $on, $echo );
}
return self::$LOGGERS[ $id ];
}
/**
* Initialize logging global info.
*
* @author Vova Feldman (@svovaf)
* @since 1.2.1.6
*/
private static function init() {
self::$_ownerName = function_exists( 'get_current_user' ) ?
get_current_user() :
'unknown';
self::$_isStorageLoggingOn = ( 1 == get_option( 'fs_storage_logger', 0 ) );
self::$_abspathLength = strlen( ABSPATH );
self::$_processID = mt_rand( 0, 32000 );
// Process ID may be `false` on errors.
if ( ! is_numeric( self::$_processID ) ) {
self::$_processID = 0;
}
}
private static function hook_footer() {
if ( self::$_HOOKED_FOOTER ) {
return;
}
if ( is_admin() ) {
add_action( 'admin_footer', 'FS_Logger::dump', 100 );
} else {
add_action( 'wp_footer', 'FS_Logger::dump', 100 );
}
}
function is_on() {
return $this->_on;
}
function on() {
$this->_on = true;
if ( ! function_exists( 'dbDelta' ) ) {
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
}
self::hook_footer();
}
function echo_on() {
$this->on();
$this->_echo = true;
}
function is_echo_on() {
return $this->_echo;
}
function get_id() {
return $this->_id;
}
function get_file() {
return $this->_file_start;
}
private function _log( &$message, $type, $wrapper = false ) {
if ( ! $this->is_on() ) {
return;
}
$bt = debug_backtrace();
$depth = $wrapper ? 3 : 2;
while ( $depth < count( $bt ) - 1 && 'eval' === $bt[ $depth ]['function'] ) {
$depth ++;
}
$caller = $bt[ $depth ];
/**
* Retrieve the correct call file & line number from backtrace
* when logging from a wrapper method.
*
* @author Vova Feldman
* @since 1.2.1.6
*/
if ( empty( $caller['line'] ) ) {
$depth --;
while ( $depth >= 0 ) {
if ( ! empty( $bt[ $depth ]['line'] ) ) {
$caller['line'] = $bt[ $depth ]['line'];
$caller['file'] = $bt[ $depth ]['file'];
break;
}
}
}
$log = array_merge( $caller, array(
'cnt' => self::$CNT ++,
'logger' => $this,
'timestamp' => microtime( true ),
'log_type' => $type,
'msg' => $message,
) );
if ( self::$_isStorageLoggingOn ) {
$this->db_log( $type, $message, self::$CNT, $caller );
}
self::$LOG[] = $log;
if ( $this->is_echo_on() && ! Freemius::is_ajax() ) {
echo self::format_html( $log ) . "\n";
}
}
function log( $message, $wrapper = false ) {
$this->_log( $message, 'log', $wrapper );
}
function info( $message, $wrapper = false ) {
$this->_log( $message, 'info', $wrapper );
}
function warn( $message, $wrapper = false ) {
$this->_log( $message, 'warn', $wrapper );
}
function error( $message, $wrapper = false ) {
$this->_log( $message, 'error', $wrapper );
}
/**
* Log API error.
*
* @author Vova Feldman (@svovaf)
* @since 1.2.1.5
*
* @param mixed $api_result
* @param bool $wrapper
*/
function api_error( $api_result, $wrapper = false ) {
$message = '';
if ( is_object( $api_result ) &&
! empty( $api_result->error ) &&
! empty( $api_result->error->message )
) {
$message = $api_result->error->message;
} else if ( is_object( $api_result ) ) {
$message = var_export( $api_result, true );
} else if ( is_string( $api_result ) ) {
$message = $api_result;
} else if ( empty( $api_result ) ) {
$message = 'Empty API result.';
}
$message = 'API Error: ' . $message;
$this->_log( $message, 'error', $wrapper );
}
function entrance( $message = '', $wrapper = false ) {
$msg = 'Entrance' . ( empty( $message ) ? '' : ' > ' ) . $message;
$this->_log( $msg, 'log', $wrapper );
}
function departure( $message = '', $wrapper = false ) {
$msg = 'Departure' . ( empty( $message ) ? '' : ' > ' ) . $message;
$this->_log( $msg, 'log', $wrapper );
}
#--------------------------------------------------------------------------------
#region Log Formatting
#--------------------------------------------------------------------------------
private static function format( $log, $show_type = true ) {
return '[' . str_pad( $log['cnt'], strlen( self::$CNT ), '0', STR_PAD_LEFT ) . '] [' . $log['logger']->_id . '] ' . ( $show_type ? '[' . $log['log_type'] . ']' : '' ) . ( ! empty( $log['class'] ) ? $log['class'] . $log['type'] : '' ) . $log['function'] . ' >> ' . $log['msg'] . ( isset( $log['file'] ) ? ' (' . substr( $log['file'], $log['logger']->_file_start ) . ' ' . $log['line'] . ') ' : '' ) . ' [' . $log['timestamp'] . ']';
}
private static function format_html( $log ) {
return '<div style="font-size: 13px; font-family: monospace; color: #7da767; padding: 8px 3px; background: #000; border-bottom: 1px solid #555;">[' . $log['cnt'] . '] [' . $log['logger']->_id . '] [' . $log['log_type'] . '] <b><code style="color: #c4b1e0;">' . ( ! empty( $log['class'] ) ? $log['class'] . $log['type'] : '' ) . $log['function'] . '</code> >> <b style="color: #f59330;">' . esc_html( $log['msg'] ) . '</b></b>' . ( isset( $log['file'] ) ? ' (' . substr( $log['file'], $log['logger']->_file_start ) . ' ' . $log['line'] . ')' : '' ) . ' [' . $log['timestamp'] . ']</div>';
}
#endregion
static function dump() {
?>
<!-- BEGIN: Freemius PHP Console Log -->
<script type="text/javascript">
<?php
foreach ( self::$LOG as $log ) {
echo 'console.' . $log['log_type'] . '(' . json_encode( self::format( $log, false ) ) . ')' . "\n";
}
?>
</script>
<!-- END: Freemius PHP Console Log -->
<?php
}
static function get_log() {
return self::$LOG;
}
#--------------------------------------------------------------------------------
#region Database Logging
#--------------------------------------------------------------------------------
/**
* @author Vova Feldman (@svovaf)
* @since 1.2.1.6
*
* @return bool
*/
public static function is_storage_logging_on() {
if ( ! isset( self::$_isStorageLoggingOn ) ) {
self::$_isStorageLoggingOn = ( 1 == get_option( 'fs_storage_logger', 0 ) );
}
return self::$_isStorageLoggingOn;
}
/**
* Turns on/off database persistent debugging to capture
* multi-session logs to debug complex flows like
* plugin auto-deactivate on premium version activation.
*
* @todo Check if Theme Check has issues with DB tables for themes.
*
* @author Vova Feldman (@svovaf)
* @since 1.2.1.6
*
* @param bool $is_on
*
* @return bool
*/
public static function _set_storage_logging( $is_on = true ) {
global $wpdb;
$table = "{$wpdb->prefix}fs_logger";
if ( $is_on ) {
/**
* Create logging table.
*
* NOTE:
* dbDelta must use KEY and not INDEX for indexes.
*
* @link https://core.trac.wordpress.org/ticket/2695
*/
$result = $wpdb->query( "CREATE TABLE {$table} (
`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`process_id` INT UNSIGNED NOT NULL,
`user_name` VARCHAR(64) NOT NULL,
`logger` VARCHAR(128) NOT NULL,
`log_order` INT UNSIGNED NOT NULL,
`type` ENUM('log','info','warn','error') NOT NULL DEFAULT 'log',
`message` TEXT NOT NULL,
`file` VARCHAR(256) NOT NULL,
`line` INT UNSIGNED NOT NULL,
`function` VARCHAR(256) NOT NULL,
`request_type` ENUM('call','ajax','cron') NOT NULL DEFAULT 'call',
`request_url` VARCHAR(1024) NOT NULL,
`created` DECIMAL(16, 6) NOT NULL,
PRIMARY KEY (`id`),
KEY `process_id` (`process_id` ASC),
KEY `process_logger` (`process_id` ASC, `logger` ASC),
KEY `function` (`function` ASC),
KEY `type` (`type` ASC))" );
} else {
/**
* Drop logging table.
*/
$result = $wpdb->query( "DROP TABLE IF EXISTS $table;" );
}
if ( false !== $result ) {
update_option( 'fs_storage_logger', ( $is_on ? 1 : 0 ) );
}
return ( false !== $result );
}
/**
* @author Vova Feldman (@svovaf)
* @since 1.2.1.6
*
* @param string $type
* @param string $message
* @param int $log_order
* @param array $caller
*
* @return false|int
*/
private function db_log(
&$type,
&$message,
&$log_order,
&$caller
) {
global $wpdb;
$request_type = 'call';
if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
$request_type = 'cron';
} else if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
$request_type = 'ajax';
}
$request_url = WP_FS__IS_HTTP_REQUEST ?
$_SERVER['REQUEST_URI'] :
'';
return $wpdb->insert(
"{$wpdb->prefix}fs_logger",
array(
'process_id' => self::$_processID,
'user_name' => self::$_ownerName,
'logger' => $this->_id,
'log_order' => $log_order,
'type' => $type,
'request_type' => $request_type,
'request_url' => $request_url,
'message' => $message,
'file' => isset( $caller['file'] ) ?
substr( $caller['file'], self::$_abspathLength ) :
'',
'line' => $caller['line'],
'function' => ( ! empty( $caller['class'] ) ? $caller['class'] . $caller['type'] : '' ) . $caller['function'],
'created' => microtime( true ),
)
);
}
/**
* Persistent DB logger columns.
*
* @var array
*/
private static $_log_columns = array(
'id',
'process_id',
'user_name',
'logger',
'log_order',
'type',
'message',
'file',
'line',
'function',
'request_type',
'request_url',
'created',
);
/**
* Create DB logs query.
*
* @author Vova Feldman (@svovaf)
* @since 1.2.1.6
*
* @param bool $filters
* @param int $limit
* @param int $offset
* @param bool $order
* @param bool $escape_eol
*
* @return string
*/
private static function build_db_logs_query(
$filters = false,
$limit = 200,
$offset = 0,
$order = false,
$escape_eol = false
) {
global $wpdb;
$select = '*';
if ( $escape_eol ) {
$select = '';
for ( $i = 0, $len = count( self::$_log_columns ); $i < $len; $i ++ ) {
if ( $i > 0 ) {
$select .= ', ';
}
if ( 'message' !== self::$_log_columns[ $i ] ) {
$select .= self::$_log_columns[ $i ];
} else {
$select .= 'REPLACE(message , \'\n\', \' \') AS message';
}
}
}
$query = "SELECT {$select} FROM {$wpdb->prefix}fs_logger";
if ( is_array( $filters ) ) {
$criteria = array();
if ( ! empty( $filters['type'] ) && 'all' !== $filters['type'] ) {
$filters['type'] = strtolower( $filters['type'] );
switch ( $filters['type'] ) {
case 'warn_error':
$criteria[] = array( 'col' => 'type', 'val' => array( 'warn', 'error' ) );
break;
case 'error':
case 'warn':
$criteria[] = array( 'col' => 'type', 'val' => $filters['type'] );
break;
case 'info':
default:
$criteria[] = array( 'col' => 'type', 'val' => array( 'info', 'log' ) );
break;
}
}
if ( ! empty( $filters['request_type'] ) ) {
$filters['request_type'] = strtolower( $filters['request_type'] );
if ( in_array( $filters['request_type'], array( 'call', 'ajax', 'cron' ) ) ) {
$criteria[] = array( 'col' => 'request_type', 'val' => $filters['request_type'] );
}
}
if ( ! empty( $filters['file'] ) ) {
$criteria[] = array(
'col' => 'file',
'op' => 'LIKE',
'val' => '%' . esc_sql( $filters['file'] ),
);
}
if ( ! empty( $filters['function'] ) ) {
$criteria[] = array(
'col' => 'function',
'op' => 'LIKE',
'val' => '%' . esc_sql( $filters['function'] ),
);
}
if ( ! empty( $filters['process_id'] ) && is_numeric( $filters['process_id'] ) ) {
$criteria[] = array( 'col' => 'process_id', 'val' => $filters['process_id'] );
}
if ( ! empty( $filters['logger'] ) ) {
$criteria[] = array(
'col' => 'logger',
'op' => 'LIKE',
'val' => '%' . esc_sql( $filters['logger'] ) . '%',
);
}
if ( ! empty( $filters['message'] ) ) {
$criteria[] = array(
'col' => 'message',
'op' => 'LIKE',
'val' => '%' . esc_sql( $filters['message'] ) . '%',
);
}
if ( 0 < count( $criteria ) ) {
$query .= "\nWHERE\n";
$first = true;
foreach ( $criteria as $c ) {
if ( ! $first ) {
$query .= "AND\n";
}
if ( is_array( $c['val'] ) ) {
$operator = 'IN';
for ( $i = 0, $len = count( $c['val'] ); $i < $len; $i ++ ) {
$c['val'][ $i ] = "'" . esc_sql( $c['val'][ $i ] ) . "'";
}
$val = '(' . implode( ',', $c['val'] ) . ')';
} else {
$operator = ! empty( $c['op'] ) ? $c['op'] : '=';
$val = "'" . esc_sql( $c['val'] ) . "'";
}
$query .= "`{$c['col']}` {$operator} {$val}\n";
$first = false;
}
}
}
if ( ! is_array( $order ) ) {
$order = array(
'col' => 'id',
'order' => 'desc'
);
}
$query .= " ORDER BY {$order['col']} {$order['order']} LIMIT {$offset},{$limit}";
return $query;
}
/**
* Load logs from DB.
*
* @author Vova Feldman (@svovaf)
* @since 1.2.1.6
*
* @param bool $filters
* @param int $limit
* @param int $offset
* @param bool $order
*
* @return object[]|null
*/
public static function load_db_logs(
$filters = false,
$limit = 200,
$offset = 0,
$order = false
) {
global $wpdb;
$query = self::build_db_logs_query(
$filters,
$limit,
$offset,
$order
);
return $wpdb->get_results( $query );
}
/**
* Load logs from DB.
*
* @author Vova Feldman (@svovaf)
* @since 1.2.1.6
*
* @param bool $filters
* @param string $filename
* @param int $limit
* @param int $offset
* @param bool $order
*
* @return false|string File download URL or false on failure.
*/
public static function download_db_logs(
$filters = false,
$filename = '',
$limit = 10000,
$offset = 0,
$order = false
) {
global $wpdb;
$query = self::build_db_logs_query(
$filters,
$limit,
$offset,
$order,
true
);
$upload_dir = wp_upload_dir();
if ( empty( $filename ) ) {
$filename = 'fs-logs-' . date( 'Y-m-d_H-i-s', WP_FS__SCRIPT_START_TIME ) . '.csv';
}
$filepath = rtrim( $upload_dir['path'], '/' ) . "/{$filename}";
$query .= " INTO OUTFILE '{$filepath}' FIELDS TERMINATED BY '\t' ESCAPED BY '\\\\' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n'";
$columns = '';
for ( $i = 0, $len = count( self::$_log_columns ); $i < $len; $i ++ ) {
if ( $i > 0 ) {
$columns .= ', ';
}
$columns .= "'" . self::$_log_columns[ $i ] . "'";
}
$query = "SELECT {$columns} UNION ALL " . $query;
$result = $wpdb->query( $query );
if ( false === $result ) {
return false;
}
return rtrim( $upload_dir['url'], '/' ) . '/' . $filename;
}
/**
* @author Vova Feldman (@svovaf)
* @since 1.2.1.6
*
* @param string $filename
*
* @return string
*/
public static function get_logs_download_url( $filename = '' ) {
$upload_dir = wp_upload_dir();
if ( empty( $filename ) ) {
$filename = 'fs-logs-' . date( 'Y-m-d_H-i-s', WP_FS__SCRIPT_START_TIME ) . '.csv';
}
return rtrim( $upload_dir['url'], '/' ) . $filename;
}
#endregion
}

View File

@@ -0,0 +1,431 @@
<?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_Options
*
* A wrapper class for handling network level and single site level options.
*/
class FS_Options {
/**
* @var string
*/
private $_id;
/**
* @var array[string]FS_Options {
* @key string
* @value FS_Options
* }
*/
private static $_instances;
/**
* @var FS_Option_Manager Site level options.
*/
private $_options;
/**
* @var FS_Option_Manager Network level options.
*/
private $_network_options;
/**
* @var int The ID of the blog that is associated with the current site level options.
*/
private $_blog_id = 0;
/**
* @var bool
*/
private $_is_multisite;
/**
* @var string[] Lazy collection of params on the site level.
*/
private static $_SITE_OPTIONS_MAP;
/**
* @author Leo Fajardo (@leorw)
* @since 2.0.0
*
* @param string $id
* @param bool $load
*
* @return FS_Options
*/
static function instance( $id, $load = false ) {
if ( ! isset( self::$_instances[ $id ] ) ) {
self::$_instances[ $id ] = new FS_Options( $id, $load );
}
return self::$_instances[ $id ];
}
/**
* @author Leo Fajardo (@leorw)
* @since 2.0.0
*
* @param string $id
* @param bool $load
*/
private function __construct( $id, $load = false ) {
$this->_id = $id;
$this->_is_multisite = is_multisite();
if ( $this->_is_multisite ) {
$this->_blog_id = get_current_blog_id();
$this->_network_options = FS_Option_Manager::get_manager( $id, $load, true );
}
$this->_options = FS_Option_Manager::get_manager( $id, $load, $this->_blog_id );
}
/**
* Switch the context of the site level options manager.
*
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @param $blog_id
*/
function set_site_blog_context( $blog_id ) {
$this->_blog_id = $blog_id;
$this->_options = FS_Option_Manager::get_manager( $this->_id, false, $this->_blog_id );
}
/**
* @author Leo Fajardo (@leorw)
*
* @param string $option
* @param mixed $default
* @param null|bool|int $network_level_or_blog_id When an integer, use the given blog storage. When `true` use the multisite storage (if there's a network). When `false`, use the current context blog storage. When `null`, the decision which storage to use (MS vs. Current S) will be handled internally and determined based on the $option (based on self::$_SITE_LEVEL_PARAMS).
*
* @return mixed
*/
function get_option( $option, $default = null, $network_level_or_blog_id = null ) {
if ( $this->should_use_network_storage( $option, $network_level_or_blog_id ) ) {
return $this->_network_options->get_option( $option, $default );
}
$site_options = $this->get_site_options( $network_level_or_blog_id );
return $site_options->get_option( $option, $default );
}
/**
* @author Leo Fajardo (@leorw)
* @since 2.0.0
*
* @param string $option
* @param mixed $value
* @param bool $flush
* @param null|bool|int $network_level_or_blog_id When an integer, use the given blog storage. When `true` use the multisite storage (if there's a network). When `false`, use the current context blog storage. When `null`, the decision which storage to use (MS vs. Current S) will be handled internally and determined based on the $option (based on self::$_SITE_LEVEL_PARAMS).
*/
function set_option( $option, $value, $flush = false, $network_level_or_blog_id = null ) {
if ( $this->should_use_network_storage( $option, $network_level_or_blog_id ) ) {
$this->_network_options->set_option( $option, $value, $flush );
} else {
$site_options = $this->get_site_options( $network_level_or_blog_id );
$site_options->set_option( $option, $value, $flush );
}
}
/**
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @param string $option
* @param bool $flush
* @param null|bool|int $network_level_or_blog_id When an integer, use the given blog storage. When `true` use the multisite storage (if there's a network). When `false`, use the current context blog storage. When `null`, the decision which storage to use (MS vs. Current S) will be handled internally and determined based on the $option (based on self::$_SITE_LEVEL_PARAMS).
*/
function unset_option( $option, $flush = false, $network_level_or_blog_id = null ) {
if ( $this->should_use_network_storage( $option, $network_level_or_blog_id ) ) {
$this->_network_options->unset_option( $option, $flush );
} else {
$site_options = $this->get_site_options( $network_level_or_blog_id );
$site_options->unset_option( $option, $flush );
}
}
/**
* @author Leo Fajardo (@leorw)
* @since 2.0.0
*
* @param bool $flush
* @param bool $network_level
*/
function load( $flush = false, $network_level = true ) {
if ( $this->_is_multisite && $network_level ) {
$this->_network_options->load( $flush );
} else {
$this->_options->load( $flush );
}
}
/**
* @author Leo Fajardo (@leorw)
* @since 2.0.0
*
* @param null|bool|int $network_level_or_blog_id When an integer, use the given blog storage. When `true` use the multisite storage (if there's a network). When `false`, use the current context blog storage. When `null`, store both network storage and the current context blog storage.
*/
function store( $network_level_or_blog_id = null ) {
if ( ! $this->_is_multisite ||
false === $network_level_or_blog_id ||
0 == $network_level_or_blog_id ||
is_null( $network_level_or_blog_id )
) {
$site_options = $this->get_site_options( $network_level_or_blog_id );
$site_options->store();
}
if ( $this->_is_multisite &&
( is_null( $network_level_or_blog_id ) || true === $network_level_or_blog_id )
) {
$this->_network_options->store();
}
}
/**
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @param int|null|bool $network_level_or_blog_id
* @param bool $flush
*/
function clear( $network_level_or_blog_id = null, $flush = false ) {
if ( ! $this->_is_multisite ||
false === $network_level_or_blog_id ||
is_null( $network_level_or_blog_id ) ||
is_numeric( $network_level_or_blog_id )
) {
$site_options = $this->get_site_options( $network_level_or_blog_id );
$site_options->clear( $flush );
}
if ( $this->_is_multisite &&
( true === $network_level_or_blog_id || is_null( $network_level_or_blog_id ) )
) {
$this->_network_options->clear( $flush );
}
}
/**
* Migration script to the new storage data structure that is network compatible.
*
* IMPORTANT:
* This method should be executed only after it is determined if this is a network
* level compatible product activation.
*
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @param int $blog_id
*/
function migrate_to_network( $blog_id = 0 ) {
if ( ! $this->_is_multisite ) {
return;
}
$updated = false;
$site_options = $this->get_site_options( $blog_id );
$keys = $site_options->get_options_keys();
foreach ( $keys as $option ) {
if ( $this->is_site_option( $option ) ||
// Don't move admin notices to the network storage.
in_array($option, array(
// Don't move admin notices to the network storage.
'admin_notices',
// Don't migrate the module specific data, it will be migrated by the FS_Storage.
'plugin_data',
'theme_data',
))
) {
continue;
}
$option_updated = false;
// Migrate option to the network storage.
$site_option = $site_options->get_option( $option );
if ( ! $this->_network_options->has_option( $option ) ) {
// Option not set on the network level, so just set it.
$this->_network_options->set_option( $option, $site_option, false );
$option_updated = true;
} else {
// Option already set on the network level, so we need to merge it inelegantly.
$network_option = $this->_network_options->get_option( $option );
if ( is_array( $network_option ) && is_array( $site_option ) ) {
// Option is an array.
foreach ( $site_option as $key => $value ) {
if ( ! isset( $network_option[ $key ] ) ) {
$network_option[ $key ] = $value;
$option_updated = true;
} else if ( is_array( $network_option[ $key ] ) && is_array( $value ) ) {
if ( empty( $network_option[ $key ] ) ) {
$network_option[ $key ] = $value;
$option_updated = true;
} else if ( empty( $value ) ) {
// Do nothing.
} else {
reset($value);
$first_key = key($value);
if ( $value[$first_key] instanceof FS_Entity ) {
// Merge entities by IDs.
$network_entities_ids = array();
foreach ( $network_option[ $key ] as $entity ) {
$network_entities_ids[ $entity->id ] = true;
}
foreach ( $value as $entity ) {
if ( ! isset( $network_entities_ids[ $entity->id ] ) ) {
$network_option[ $key ][] = $entity;
$option_updated = true;
}
}
}
}
}
}
}
if ( $option_updated ) {
$this->_network_options->set_option( $option, $network_option, false );
}
}
/**
* Remove the option from site level storage.
*
* IMPORTANT:
* The line below is intentionally commented since we want to preserve the option
* on the site storage level for "downgrade compatibility". Basically, if the user
* will downgrade to an older version of the plugin with the prev storage structure,
* it will continue working.
*
* @todo After a few releases we can remove this.
*/
// $site_options->unset_option($option, false);
if ( $option_updated ) {
$updated = true;
}
}
if ( ! $updated ) {
return;
}
// Update network level storage.
$this->_network_options->store();
// $site_options->store();
}
#--------------------------------------------------------------------------------
#region Helper Methods
#--------------------------------------------------------------------------------
/**
* We don't want to load the map right away since it's not even needed in a non-MS environment.
*
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*/
private static function load_site_options_map() {
self::$_SITE_OPTIONS_MAP = array(
'sites' => true,
'theme_sites' => true,
'unique_id' => true,
'active_plugins' => true,
);
}
/**
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @param string $option
*
* @return bool
*/
private function is_site_option( $option ) {
if ( WP_FS__ACCOUNTS_OPTION_NAME != $this->_id ) {
return false;
}
if ( ! isset( self::$_SITE_OPTIONS_MAP ) ) {
self::load_site_options_map();
}
return isset( self::$_SITE_OPTIONS_MAP[ $option ] );
}
/**
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @param int $blog_id
*
* @return FS_Option_Manager
*/
private function get_site_options( $blog_id = 0 ) {
if ( 0 == $blog_id || $blog_id == $this->_blog_id ) {
return $this->_options;
}
return FS_Option_Manager::get_manager( $this->_id, true, $blog_id );
}
/**
* Check if an option should be stored on the MS network storage.
*
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @param string $option
* @param null|bool|int $network_level_or_blog_id When an integer, use the given blog storage. When `true` use the multisite storage (if there's a network). When `false`, use the current context blog storage. When `null`, the decision which storage to use (MS vs. Current S) will be handled internally and determined based on the $option (based on self::$_SITE_LEVEL_PARAMS).
*
* @return bool
*/
private function should_use_network_storage( $option, $network_level_or_blog_id = null ) {
if ( ! $this->_is_multisite ) {
// Not a multisite environment.
return false;
}
if ( is_numeric( $network_level_or_blog_id ) ) {
// Explicitly asked to use a specified blog storage.
return false;
}
if ( is_bool( $network_level_or_blog_id ) ) {
// Explicitly specified whether should use the network or blog level storage.
return $network_level_or_blog_id;
}
// Determine which storage to use based on the option.
return ! $this->is_site_option( $option );
}
#endregion
}

View File

@@ -0,0 +1,85 @@
<?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 ),
);
}
}

View File

@@ -0,0 +1,558 @@
<?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_Storage
*
* A wrapper class for handling network level and single site level storage.
*
* @property bool $is_network_activation
* @property int $network_install_blog_id
* @property bool|null $is_extensions_tracking_allowed
* @property bool|null $is_diagnostic_tracking_allowed
* @property object $sync_cron
*/
class FS_Storage {
/**
* @var FS_Storage[]
*/
private static $_instances = array();
/**
* @var FS_Key_Value_Storage Site level storage.
*/
private $_storage;
/**
* @var FS_Key_Value_Storage Network level storage.
*/
private $_network_storage;
/**
* @var string
*/
private $_module_type;
/**
* @var string
*/
private $_module_slug;
/**
* @var int The ID of the blog that is associated with the current site level options.
*/
private $_blog_id = 0;
/**
* @var bool
*/
private $_is_multisite;
/**
* @var bool
*/
private $_is_network_active = false;
/**
* @var bool
*/
private $_is_delegated_connection = false;
/**
* @var array {
* @key string Option name.
* @value int If 0 store on the network level. If 1, store on the network level only if module was network level activated. If 2, store on the network level only if network activated and NOT delegated the connection.
* }
*/
private static $_NETWORK_OPTIONS_MAP;
const OPTION_LEVEL_UNDEFINED = -1;
// The option should be stored on the network level.
const OPTION_LEVEL_NETWORK = 0;
// The option should be stored on the network level when the plugin is network-activated.
const OPTION_LEVEL_NETWORK_ACTIVATED = 1;
// The option should be stored on the network level when the plugin is network-activated and the opt-in connection was NOT delegated to the sub-site admin.
const OPTION_LEVEL_NETWORK_ACTIVATED_NOT_DELEGATED = 2;
// The option should be stored on the site level.
const OPTION_LEVEL_SITE = 3;
/**
* @author Leo Fajardo (@leorw)
*
* @param string $module_type
* @param string $slug
*
* @return FS_Storage
*/
static function instance( $module_type, $slug ) {
$key = $module_type . ':' . $slug;
if ( ! isset( self::$_instances[ $key ] ) ) {
self::$_instances[ $key ] = new FS_Storage( $module_type, $slug );
}
return self::$_instances[ $key ];
}
/**
* @author Leo Fajardo (@leorw)
*
* @param string $module_type
* @param string $slug
*/
private function __construct( $module_type, $slug ) {
$this->_module_type = $module_type;
$this->_module_slug = $slug;
$this->_is_multisite = is_multisite();
if ( $this->_is_multisite ) {
$this->_blog_id = get_current_blog_id();
$this->_network_storage = FS_Key_Value_Storage::instance( $module_type . '_data', $slug, true );
}
$this->_storage = FS_Key_Value_Storage::instance( $module_type . '_data', $slug, $this->_blog_id );
}
/**
* Tells this storage wrapper class that the context plugin is network active. This flag will affect how values
* are retrieved/stored from/into the storage.
*
* @author Leo Fajardo (@leorw)
*
* @param bool $is_network_active
* @param bool $is_delegated_connection
*/
function set_network_active( $is_network_active = true, $is_delegated_connection = false ) {
$this->_is_network_active = $is_network_active;
$this->_is_delegated_connection = $is_delegated_connection;
}
/**
* Switch the context of the site level storage manager.
*
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @param int $blog_id
*/
function set_site_blog_context( $blog_id ) {
$this->_storage = $this->get_site_storage( $blog_id );
$this->_blog_id = $blog_id;
}
/**
* @author Leo Fajardo (@leorw)
*
* @param string $key
* @param mixed $value
* @param null|bool|int $network_level_or_blog_id When an integer, use the given blog storage. When `true` use the multisite storage (if there's a network). When `false`, use the current context blog storage. When `null`, the decision which storage to use (MS vs. Current S) will be handled internally and determined based on the $option (based on self::$_BINARY_MAP).
* @param int $option_level Since 2.5.1
* @param bool $flush
*/
function store(
$key,
$value,
$network_level_or_blog_id = null,
$option_level = self::OPTION_LEVEL_UNDEFINED,
$flush = true
) {
if ( $this->should_use_network_storage( $key, $network_level_or_blog_id, $option_level ) ) {
$this->_network_storage->store( $key, $value, $flush );
} else {
$storage = $this->get_site_storage( $network_level_or_blog_id );
$storage->store( $key, $value, $flush );
}
}
/**
* @author Leo Fajardo (@leorw)
*
* @param bool $store
* @param string[] $exceptions Set of keys to keep and not clear.
* @param int|null|bool $network_level_or_blog_id
*/
function clear_all( $store = true, $exceptions = array(), $network_level_or_blog_id = null ) {
if ( ! $this->_is_multisite ||
false === $network_level_or_blog_id ||
is_null( $network_level_or_blog_id ) ||
is_numeric( $network_level_or_blog_id )
) {
$storage = $this->get_site_storage( $network_level_or_blog_id );
$storage->clear_all( $store, $exceptions );
}
if ( $this->_is_multisite &&
( true === $network_level_or_blog_id || is_null( $network_level_or_blog_id ) )
) {
$this->_network_storage->clear_all( $store, $exceptions );
}
}
/**
* @author Leo Fajardo (@leorw)
*
* @param string $key
* @param bool $store
* @param null|bool|int $network_level_or_blog_id When an integer, use the given blog storage. When `true` use the multisite storage (if there's a network). When `false`, use the current context blog storage. When `null`, the decision which storage to use (MS vs. Current S) will be handled internally and determined based on the $option (based on self::$_BINARY_MAP).
*/
function remove( $key, $store = true, $network_level_or_blog_id = null ) {
if ( $this->should_use_network_storage( $key, $network_level_or_blog_id ) ) {
$this->_network_storage->remove( $key, $store );
} else {
$storage = $this->get_site_storage( $network_level_or_blog_id );
$storage->remove( $key, $store );
}
}
/**
* @author Leo Fajardo (@leorw)
*
* @param string $key
* @param mixed $default
* @param null|bool|int $network_level_or_blog_id When an integer, use the given blog storage. When `true` use the multisite storage (if there's a network). When `false`, use the current context blog storage. When `null`, the decision which storage to use (MS vs. Current S) will be handled internally and determined based on the $option (based on self::$_BINARY_MAP).
* @param int $option_level Since 2.5.1
*
* @return mixed
*/
function get(
$key,
$default = false,
$network_level_or_blog_id = null,
$option_level = self::OPTION_LEVEL_UNDEFINED
) {
if ( $this->should_use_network_storage( $key, $network_level_or_blog_id, $option_level ) ) {
return $this->_network_storage->get( $key, $default );
} else {
$storage = $this->get_site_storage( $network_level_or_blog_id );
return $storage->get( $key, $default );
}
}
/**
* Multisite activated:
* true: Save network storage.
* int: Save site specific storage.
* false|0: Save current site storage.
* null: Save network and current site storage.
* Site level activated:
* Save site storage.
*
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @param bool|int|null $network_level_or_blog_id
*/
function save( $network_level_or_blog_id = null ) {
if ( $this->_is_network_active &&
( true === $network_level_or_blog_id || is_null( $network_level_or_blog_id ) )
) {
$this->_network_storage->save();
}
if ( ! $this->_is_network_active || true !== $network_level_or_blog_id ) {
$storage = $this->get_site_storage( $network_level_or_blog_id );
$storage->save();
}
}
/**
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @return string
*/
function get_module_slug() {
return $this->_module_slug;
}
/**
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @return string
*/
function get_module_type() {
return $this->_module_type;
}
/**
* Migration script to the new storage data structure that is network compatible.
*
* IMPORTANT:
* This method should be executed only after it is determined if this is a network
* level compatible product activation.
*
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*/
function migrate_to_network() {
if ( ! $this->_is_multisite ) {
return;
}
$updated = false;
if ( ! isset( self::$_NETWORK_OPTIONS_MAP ) ) {
self::load_network_options_map();
}
foreach ( self::$_NETWORK_OPTIONS_MAP as $option => $storage_level ) {
if ( ! $this->is_multisite_option( $option ) ) {
continue;
}
if ( isset( $this->_storage->{$option} ) && ! isset( $this->_network_storage->{$option} ) ) {
// Migrate option to the network storage.
$this->_network_storage->store( $option, $this->_storage->{$option}, false );
$updated = true;
}
}
if ( ! $updated ) {
return;
}
// Update network level storage.
$this->_network_storage->save();
// $this->_storage->save();
}
#--------------------------------------------------------------------------------
#region Helper Methods
#--------------------------------------------------------------------------------
/**
* We don't want to load the map right away since it's not even needed in a non-MS environment.
*
* Example:
* array(
* 'option1' => 0, // Means that the option should always be stored on the network level.
* 'option2' => 1, // Means that the option should be stored on the network level only when the module was network level activated.
* 'option2' => 2, // Means that the option should be stored on the network level only when the module was network level activated AND the connection was NOT delegated.
* 'option3' => 3, // Means that the option should always be stored on the site level.
* )
*
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*/
private static function load_network_options_map() {
self::$_NETWORK_OPTIONS_MAP = array(
// Network level options.
'affiliate_application_data' => self::OPTION_LEVEL_NETWORK,
'beta_data' => self::OPTION_LEVEL_NETWORK,
'connectivity_test' => self::OPTION_LEVEL_NETWORK,
'handle_gdpr_admin_notice' => self::OPTION_LEVEL_NETWORK,
'has_trial_plan' => self::OPTION_LEVEL_NETWORK,
'install_sync_timestamp' => self::OPTION_LEVEL_NETWORK,
'install_sync_cron' => self::OPTION_LEVEL_NETWORK,
'is_anonymous_ms' => self::OPTION_LEVEL_NETWORK,
'is_network_activated' => self::OPTION_LEVEL_NETWORK,
'is_on' => self::OPTION_LEVEL_NETWORK,
'is_plugin_new_install' => self::OPTION_LEVEL_NETWORK,
'network_install_blog_id' => self::OPTION_LEVEL_NETWORK,
'pending_sites_info' => self::OPTION_LEVEL_NETWORK,
'plugin_last_version' => self::OPTION_LEVEL_NETWORK,
'plugin_main_file' => self::OPTION_LEVEL_NETWORK,
'plugin_version' => self::OPTION_LEVEL_NETWORK,
'sdk_downgrade_mode' => self::OPTION_LEVEL_NETWORK,
'sdk_last_version' => self::OPTION_LEVEL_NETWORK,
'sdk_upgrade_mode' => self::OPTION_LEVEL_NETWORK,
'sdk_version' => self::OPTION_LEVEL_NETWORK,
'sticky_optin_added_ms' => self::OPTION_LEVEL_NETWORK,
'subscriptions' => self::OPTION_LEVEL_NETWORK,
'sync_timestamp' => self::OPTION_LEVEL_NETWORK,
'sync_cron' => self::OPTION_LEVEL_NETWORK,
'was_plugin_loaded' => self::OPTION_LEVEL_NETWORK,
'network_user_id' => self::OPTION_LEVEL_NETWORK,
'plugin_upgrade_mode' => self::OPTION_LEVEL_NETWORK,
'plugin_downgrade_mode' => self::OPTION_LEVEL_NETWORK,
'is_network_connected' => self::OPTION_LEVEL_NETWORK,
/**
* Special flag that is used when a super-admin upgrades to the new version of the SDK that supports network level integration, when the connection decision wasn't made for all the sites in the network.
*/
'is_network_activation' => self::OPTION_LEVEL_NETWORK,
'license_migration' => self::OPTION_LEVEL_NETWORK,
// When network activated, then network level.
'install_timestamp' => self::OPTION_LEVEL_NETWORK_ACTIVATED,
'prev_is_premium' => self::OPTION_LEVEL_NETWORK_ACTIVATED,
'require_license_activation' => self::OPTION_LEVEL_NETWORK_ACTIVATED,
// If not network activated OR delegated, then site level.
'activation_timestamp' => self::OPTION_LEVEL_NETWORK_ACTIVATED_NOT_DELEGATED,
'expired_license_notice_shown' => self::OPTION_LEVEL_NETWORK_ACTIVATED_NOT_DELEGATED,
'is_whitelabeled' => self::OPTION_LEVEL_NETWORK_ACTIVATED_NOT_DELEGATED,
'last_license_key' => self::OPTION_LEVEL_NETWORK_ACTIVATED_NOT_DELEGATED,
'last_license_user_id' => self::OPTION_LEVEL_NETWORK_ACTIVATED_NOT_DELEGATED,
'prev_user_id' => self::OPTION_LEVEL_NETWORK_ACTIVATED_NOT_DELEGATED,
'sticky_optin_added' => self::OPTION_LEVEL_NETWORK_ACTIVATED_NOT_DELEGATED,
'uninstall_reason' => self::OPTION_LEVEL_NETWORK_ACTIVATED_NOT_DELEGATED,
'is_pending_activation' => self::OPTION_LEVEL_NETWORK_ACTIVATED_NOT_DELEGATED,
'pending_license_key' => self::OPTION_LEVEL_NETWORK_ACTIVATED_NOT_DELEGATED,
// Site level options.
'is_anonymous' => self::OPTION_LEVEL_SITE,
'clone_id' => self::OPTION_LEVEL_SITE,
);
}
/**
* This method will and should only be executed when is_multisite() is true.
*
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @param string $key
* @param int $option_level Since 2.5.1
*
* @return bool
*/
private function is_multisite_option( $key, $option_level = self::OPTION_LEVEL_UNDEFINED ) {
if ( ! isset( self::$_NETWORK_OPTIONS_MAP ) ) {
self::load_network_options_map();
}
if (
self::OPTION_LEVEL_UNDEFINED === $option_level &&
isset( self::$_NETWORK_OPTIONS_MAP[ $key ] )
) {
$option_level = self::$_NETWORK_OPTIONS_MAP[ $key ];
}
if ( self::OPTION_LEVEL_UNDEFINED === $option_level ) {
// Option not found -> use site level storage.
return false;
}
if ( self::OPTION_LEVEL_NETWORK === $option_level ) {
// Option found and set to always use the network level storage on a multisite.
return true;
}
if ( self::OPTION_LEVEL_SITE === $option_level ) {
// Option found and set to always use the site level storage on a multisite.
return false;
}
if ( ! $this->_is_network_active ) {
return false;
}
if ( self::OPTION_LEVEL_NETWORK_ACTIVATED === $option_level ) {
// Network activated.
return true;
}
if (
self::OPTION_LEVEL_NETWORK_ACTIVATED_NOT_DELEGATED === $option_level &&
! $this->_is_delegated_connection
) {
// Network activated and not delegated.
return true;
}
return false;
}
/**
* @author Leo Fajardo
*
* @param string $key
* @param null|bool|int $network_level_or_blog_id When an integer, use the given blog storage. When `true` use the multisite storage (if there's a network). When `false`, use the current context blog storage. When `null`, the decision which storage to use (MS vs. Current S) will be handled internally and determined based on the $option (based on self::$_BINARY_MAP).
* @param int $option_level Since 2.5.1
*
* @return bool
*/
private function should_use_network_storage(
$key,
$network_level_or_blog_id = null,
$option_level = self::OPTION_LEVEL_UNDEFINED
) {
if ( ! $this->_is_multisite ) {
// Not a multisite environment.
return false;
}
if ( is_numeric( $network_level_or_blog_id ) ) {
// Explicitly asked to use a specified blog storage.
return false;
}
if ( is_bool( $network_level_or_blog_id ) ) {
// Explicitly specified whether it should use the network or blog level storage.
return $network_level_or_blog_id;
}
// Determine which storage to use based on the option.
return $this->is_multisite_option( $key, $option_level );
}
/**
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @param int $blog_id
*
* @return \FS_Key_Value_Storage
*/
private function get_site_storage( $blog_id = 0 ) {
if ( ! is_numeric( $blog_id ) ||
$blog_id == $this->_blog_id ||
0 == $blog_id
) {
return $this->_storage;
}
return FS_Key_Value_Storage::instance(
$this->_module_type . '_data',
$this->_storage->get_secondary_id(),
$blog_id
);
}
#endregion
#--------------------------------------------------------------------------------
#region Magic methods
#--------------------------------------------------------------------------------
function __set( $k, $v ) {
if ( $this->should_use_network_storage( $k ) ) {
$this->_network_storage->{$k} = $v;
} else {
$this->_storage->{$k} = $v;
}
}
function __isset( $k ) {
return $this->should_use_network_storage( $k ) ?
isset( $this->_network_storage->{$k} ) :
isset( $this->_storage->{$k} );
}
function __unset( $k ) {
if ( $this->should_use_network_storage( $k ) ) {
unset( $this->_network_storage->{$k} );
} else {
unset( $this->_storage->{$k} );
}
}
function __get( $k ) {
return $this->should_use_network_storage( $k ) ?
$this->_network_storage->{$k} :
$this->_storage->{$k};
}
#endregion
}

View File

@@ -0,0 +1,90 @@
<?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;
}
require_once WP_FS__DIR_INCLUDES . '/class-fs-lock.php';
/**
* Class FS_User_Lock
*/
class FS_User_Lock {
/**
* @var FS_Lock
*/
private $_lock;
#--------------------------------------------------------------------------------
#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() {
$current_user_id = Freemius::get_current_wp_user_id();
$this->_lock = new FS_Lock( "locked_{$current_user_id}" );
}
/**
* 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 ) {
return $this->_lock->try_lock( $expiration );
}
/**
* 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 ) {
$this->_lock->lock( $expiration );
}
/**
* Unlock the lock.
*
* @author Vova Feldman (@svovaf)
* @since 2.1.0
*/
function unlock() {
$this->_lock->unlock();
}
}

View File

@@ -0,0 +1,102 @@
<?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" rel="noopener noreferrer">{{ data.contact.label }} </a>
<# } #>
<# if ( data.support ) { #>
<a class="button" href="{{ data.support.url }}" target="_blank" rel="noopener noreferrer">{{ data.support.label }} </a>
<# } #>
<# if ( data.contact && data.support ) { #>
</div>
<# } #>
</h3>
</li>
<?php
}
}

View File

@@ -0,0 +1,161 @@
<?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 }
}

View File

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

View File

@@ -0,0 +1,64 @@
<?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
}
}

View File

@@ -0,0 +1,52 @@
<?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' );

View File

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

View File

@@ -0,0 +1,132 @@
<?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;
/**
* @var string $plugin_title Title of the plugin. This is used in case we are showing affiliate form for a Bundle instead of the `plugin` in context.
*/
public $plugin_title;
#endregion Properties
/**
* @author Leo Fajardo (@leorw)
*
* @return string
*/
function get_formatted_commission()
{
return ( 'dollar' === $this->commission_type ) ?
( '$' . $this->commission ) :
( $this->commission . '%' );
}
/**
* @author Leo Fajardo (@leorw)
*
* @return bool
*/
function has_lifetime_commission() {
return ( 0 !== $this->future_payments_days );
}
/**
* @author Leo Fajardo (@leorw)
*
* @return bool
*/
function is_session_cookie() {
return ( 0 == $this->cookie_days );
}
/**
* @author Leo Fajardo (@leorw)
*
* @return bool
*/
function has_renewals_commission() {
return ( is_null( $this->commission_renewals_days ) || $this->commission_renewals_days > 0 );
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,64 @@
<?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 $requires_programming_language_version;
/**
* @var string
*/
public $tested_up_to_version;
/**
* @var bool
*/
public $has_free;
/**
* @var bool
*/
public $has_premium;
/**
* @var string One of the following: `pending`, `beta`, `unreleased`.
*/
public $release_mode;
function __construct( $tag = false ) {
parent::__construct( $tag );
}
static function get_type() {
return 'tag';
}
/**
* @author Leo Fajardo (@leorw)
* @since 2.3.0
*
* @return bool
*/
function is_beta() {
return ( 'beta' === $this->release_mode );
}
}

View File

@@ -0,0 +1,164 @@
<?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;
/**
* @since 2.5.4
* @var null|array
*/
public $opt_in_moderation;
const AFFILIATE_MODERATION_CUSTOMERS = 'customers';
#endregion Install Specific Properties
/**
* @param stdClass|bool $plugin
*/
function __construct( $plugin = false ) {
parent::__construct( $plugin );
$this->is_premium = false;
$this->is_live = true;
if ( empty( $this->premium_slug ) && ! empty( $plugin->slug ) ) {
$this->premium_slug = "{$this->slug}-premium";
}
if ( empty( $this->premium_suffix ) ) {
$this->premium_suffix = '(Premium)';
}
if ( isset( $plugin->info ) && is_object( $plugin->info ) ) {
$this->info = new FS_Plugin_Info( $plugin->info );
}
}
/**
* Check if plugin is an add-on (has parent).
*
* @author Vova Feldman (@svovaf)
* @since 1.0.6
*
* @return bool
*/
function is_addon() {
return isset( $this->parent_plugin_id ) && is_numeric( $this->parent_plugin_id );
}
/**
* @author Leo Fajardo (@leorw)
* @since 1.2.3
*
* @return bool
*/
function has_affiliate_program() {
return ( ! empty( $this->affiliate_moderation ) );
}
static function get_type() {
return 'plugin';
}
}

View File

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

Some files were not shown because too many files have changed in this diff Show More