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

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,423 @@
<?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.2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* @var array $VARS
* @var Freemius $fs
*/
$fs = freemius( $VARS['id'] );
$slug = $fs->get_slug();
$edit_text = fs_text_x_inline( 'Edit', 'verb', 'edit', $slug );
$update_text = fs_text_x_inline( 'Update', 'verb', 'update', $slug );
$billing = $fs->_fetch_billing();
$has_billing = ( $billing instanceof FS_Billing );
if ( ! $has_billing ) {
$billing = new FS_Billing();
}
?>
<!-- Billing -->
<div class="postbox">
<div id="fs_billing">
<h3><span class="dashicons dashicons-portfolio"></span> <?php fs_esc_html_echo_inline( 'Billing', 'billing', $slug ) ?></h3>
<table id="fs_billing_address"<?php if ( $has_billing ) {
echo ' class="fs-read-mode"';
} ?>>
<tr>
<td><label><span><?php fs_esc_html_echo_inline( 'Business name', 'business-name', $slug ) ?>:</span> <input id="business_name" value="<?php echo $billing->business_name ?>" placeholder="<?php fs_esc_attr_echo_inline( 'Business name', 'business-name', $slug ) ?>"></label></td>
<td><label><span><?php fs_esc_html_echo_inline( 'Tax / VAT ID', 'tax-vat-id', $slug ) ?>:</span> <input id="tax_id" value="<?php echo $billing->tax_id ?>" placeholder="<?php fs_esc_attr_echo_inline( 'Tax / VAT ID', 'tax-vat-id', $slug ) ?>"></label></td>
</tr>
<tr>
<td><label><span><?php printf( fs_esc_html_inline( 'Address Line %d', 'address-line-n', $slug ), 1 ) ?>:</span> <input id="address_street" value="<?php echo $billing->address_street ?>" placeholder="<?php printf( fs_esc_attr_inline( 'Address Line %d', 'address-line-n', $slug ), 1 ) ?>"></label></td>
<td><label><span><?php printf( fs_esc_html_inline( 'Address Line %d', 'address-line-n', $slug ), 2 ) ?>:</span> <input id="address_apt" value="<?php echo $billing->address_apt ?>" placeholder="<?php printf( fs_esc_attr_inline( 'Address Line %d', 'address-line-n', $slug ), 2 ) ?>"></label></td>
</tr>
<tr>
<td><label><span><?php fs_esc_html_echo_inline( 'City', 'city', $slug ) ?> / <?php fs_esc_html_echo_inline( 'Town', 'town', $slug ) ?>:</span> <input id="address_city" value="<?php echo $billing->address_city ?>" placeholder="<?php fs_esc_attr_echo_inline( 'City', 'city', $slug ) ?> / <?php fs_esc_attr_echo_inline( 'Town', 'town', $slug ) ?>"></label></td>
<td><label><span><?php fs_esc_html_echo_inline( 'ZIP / Postal Code', 'zip-postal-code', $slug ) ?>:</span> <input id="address_zip" value="<?php echo $billing->address_zip ?>" placeholder="<?php fs_esc_attr_echo_inline( 'ZIP / Postal Code', 'zip-postal-code', $slug ) ?>"></label></td>
</tr>
<tr>
<?php $countries = array(
'AF' => 'Afghanistan',
'AX' => 'Aland Islands',
'AL' => 'Albania',
'DZ' => 'Algeria',
'AS' => 'American Samoa',
'AD' => 'Andorra',
'AO' => 'Angola',
'AI' => 'Anguilla',
'AQ' => 'Antarctica',
'AG' => 'Antigua and Barbuda',
'AR' => 'Argentina',
'AM' => 'Armenia',
'AW' => 'Aruba',
'AU' => 'Australia',
'AT' => 'Austria',
'AZ' => 'Azerbaijan',
'BS' => 'Bahamas',
'BH' => 'Bahrain',
'BD' => 'Bangladesh',
'BB' => 'Barbados',
'BY' => 'Belarus',
'BE' => 'Belgium',
'BZ' => 'Belize',
'BJ' => 'Benin',
'BM' => 'Bermuda',
'BT' => 'Bhutan',
'BO' => 'Bolivia',
'BQ' => 'Bonaire, Saint Eustatius and Saba',
'BA' => 'Bosnia and Herzegovina',
'BW' => 'Botswana',
'BV' => 'Bouvet Island',
'BR' => 'Brazil',
'IO' => 'British Indian Ocean Territory',
'VG' => 'British Virgin Islands',
'BN' => 'Brunei',
'BG' => 'Bulgaria',
'BF' => 'Burkina Faso',
'BI' => 'Burundi',
'KH' => 'Cambodia',
'CM' => 'Cameroon',
'CA' => 'Canada',
'CV' => 'Cape Verde',
'KY' => 'Cayman Islands',
'CF' => 'Central African Republic',
'TD' => 'Chad',
'CL' => 'Chile',
'CN' => 'China',
'CX' => 'Christmas Island',
'CC' => 'Cocos Islands',
'CO' => 'Colombia',
'KM' => 'Comoros',
'CK' => 'Cook Islands',
'CR' => 'Costa Rica',
'HR' => 'Croatia',
'CU' => 'Cuba',
'CW' => 'Curacao',
'CY' => 'Cyprus',
'CZ' => 'Czech Republic',
'CD' => 'Democratic Republic of the Congo',
'DK' => 'Denmark',
'DJ' => 'Djibouti',
'DM' => 'Dominica',
'DO' => 'Dominican Republic',
'TL' => 'East Timor',
'EC' => 'Ecuador',
'EG' => 'Egypt',
'SV' => 'El Salvador',
'GQ' => 'Equatorial Guinea',
'ER' => 'Eritrea',
'EE' => 'Estonia',
'ET' => 'Ethiopia',
'FK' => 'Falkland Islands',
'FO' => 'Faroe Islands',
'FJ' => 'Fiji',
'FI' => 'Finland',
'FR' => 'France',
'GF' => 'French Guiana',
'PF' => 'French Polynesia',
'TF' => 'French Southern Territories',
'GA' => 'Gabon',
'GM' => 'Gambia',
'GE' => 'Georgia',
'DE' => 'Germany',
'GH' => 'Ghana',
'GI' => 'Gibraltar',
'GR' => 'Greece',
'GL' => 'Greenland',
'GD' => 'Grenada',
'GP' => 'Guadeloupe',
'GU' => 'Guam',
'GT' => 'Guatemala',
'GG' => 'Guernsey',
'GN' => 'Guinea',
'GW' => 'Guinea-Bissau',
'GY' => 'Guyana',
'HT' => 'Haiti',
'HM' => 'Heard Island and McDonald Islands',
'HN' => 'Honduras',
'HK' => 'Hong Kong',
'HU' => 'Hungary',
'IS' => 'Iceland',
'IN' => 'India',
'ID' => 'Indonesia',
'IR' => 'Iran',
'IQ' => 'Iraq',
'IE' => 'Ireland',
'IM' => 'Isle of Man',
'IL' => 'Israel',
'IT' => 'Italy',
'CI' => 'Ivory Coast',
'JM' => 'Jamaica',
'JP' => 'Japan',
'JE' => 'Jersey',
'JO' => 'Jordan',
'KZ' => 'Kazakhstan',
'KE' => 'Kenya',
'KI' => 'Kiribati',
'XK' => 'Kosovo',
'KW' => 'Kuwait',
'KG' => 'Kyrgyzstan',
'LA' => 'Laos',
'LV' => 'Latvia',
'LB' => 'Lebanon',
'LS' => 'Lesotho',
'LR' => 'Liberia',
'LY' => 'Libya',
'LI' => 'Liechtenstein',
'LT' => 'Lithuania',
'LU' => 'Luxembourg',
'MO' => 'Macao',
'MK' => 'Macedonia',
'MG' => 'Madagascar',
'MW' => 'Malawi',
'MY' => 'Malaysia',
'MV' => 'Maldives',
'ML' => 'Mali',
'MT' => 'Malta',
'MH' => 'Marshall Islands',
'MQ' => 'Martinique',
'MR' => 'Mauritania',
'MU' => 'Mauritius',
'YT' => 'Mayotte',
'MX' => 'Mexico',
'FM' => 'Micronesia',
'MD' => 'Moldova',
'MC' => 'Monaco',
'MN' => 'Mongolia',
'ME' => 'Montenegro',
'MS' => 'Montserrat',
'MA' => 'Morocco',
'MZ' => 'Mozambique',
'MM' => 'Myanmar',
'NA' => 'Namibia',
'NR' => 'Nauru',
'NP' => 'Nepal',
'NL' => 'Netherlands',
'NC' => 'New Caledonia',
'NZ' => 'New Zealand',
'NI' => 'Nicaragua',
'NE' => 'Niger',
'NG' => 'Nigeria',
'NU' => 'Niue',
'NF' => 'Norfolk Island',
'KP' => 'North Korea',
'MP' => 'Northern Mariana Islands',
'NO' => 'Norway',
'OM' => 'Oman',
'PK' => 'Pakistan',
'PW' => 'Palau',
'PS' => 'Palestinian Territory',
'PA' => 'Panama',
'PG' => 'Papua New Guinea',
'PY' => 'Paraguay',
'PE' => 'Peru',
'PH' => 'Philippines',
'PN' => 'Pitcairn',
'PL' => 'Poland',
'PT' => 'Portugal',
'PR' => 'Puerto Rico',
'QA' => 'Qatar',
'CG' => 'Republic of the Congo',
'RE' => 'Reunion',
'RO' => 'Romania',
'RU' => 'Russia',
'RW' => 'Rwanda',
'BL' => 'Saint Barthelemy',
'SH' => 'Saint Helena',
'KN' => 'Saint Kitts and Nevis',
'LC' => 'Saint Lucia',
'MF' => 'Saint Martin',
'PM' => 'Saint Pierre and Miquelon',
'VC' => 'Saint Vincent and the Grenadines',
'WS' => 'Samoa',
'SM' => 'San Marino',
'ST' => 'Sao Tome and Principe',
'SA' => 'Saudi Arabia',
'SN' => 'Senegal',
'RS' => 'Serbia',
'SC' => 'Seychelles',
'SL' => 'Sierra Leone',
'SG' => 'Singapore',
'SX' => 'Sint Maarten',
'SK' => 'Slovakia',
'SI' => 'Slovenia',
'SB' => 'Solomon Islands',
'SO' => 'Somalia',
'ZA' => 'South Africa',
'GS' => 'South Georgia and the South Sandwich Islands',
'KR' => 'South Korea',
'SS' => 'South Sudan',
'ES' => 'Spain',
'LK' => 'Sri Lanka',
'SD' => 'Sudan',
'SR' => 'Suriname',
'SJ' => 'Svalbard and Jan Mayen',
'SZ' => 'Swaziland',
'SE' => 'Sweden',
'CH' => 'Switzerland',
'SY' => 'Syria',
'TW' => 'Taiwan',
'TJ' => 'Tajikistan',
'TZ' => 'Tanzania',
'TH' => 'Thailand',
'TG' => 'Togo',
'TK' => 'Tokelau',
'TO' => 'Tonga',
'TT' => 'Trinidad and Tobago',
'TN' => 'Tunisia',
'TR' => 'Turkey',
'TM' => 'Turkmenistan',
'TC' => 'Turks and Caicos Islands',
'TV' => 'Tuvalu',
'VI' => 'U.S. Virgin Islands',
'UG' => 'Uganda',
'UA' => 'Ukraine',
'AE' => 'United Arab Emirates',
'GB' => 'United Kingdom',
'US' => 'United States',
'UM' => 'United States Minor Outlying Islands',
'UY' => 'Uruguay',
'UZ' => 'Uzbekistan',
'VU' => 'Vanuatu',
'VA' => 'Vatican',
'VE' => 'Venezuela',
'VN' => 'Vietnam',
'WF' => 'Wallis and Futuna',
'EH' => 'Western Sahara',
'YE' => 'Yemen',
'ZM' => 'Zambia',
'ZW' => 'Zimbabwe',
) ?>
<td><label><span><?php fs_esc_html_echo_inline( 'Country', 'country', $slug ) ?>:</span> <select id="address_country_code">
<?php if ( empty( $billing->address_country_code ) ) : ?>
<option value="" selected><?php fs_esc_html_echo_inline( 'Select Country', 'select-country', $slug ) ?></option>
<?php endif ?>
<?php foreach ( $countries as $code => $country ) : ?>
<option
value="<?php echo $code ?>" <?php selected( $billing->address_country_code, $code ) ?>><?php echo $country ?></option>
<?php endforeach ?>
</select></label></td>
<td><label><span><?php fs_esc_html_echo_inline( 'State', 'state', $slug ) ?> / <?php fs_esc_html_echo_inline( 'Province', 'province', $slug ) ?>:</span>
<input id="address_state" value="<?php echo $billing->address_state ?>" placeholder="<?php fs_esc_html_echo_inline( 'State', 'state', $slug ) ?> / <?php fs_esc_html_echo_inline( 'Province', 'province', $slug ) ?>"></label></td>
</tr>
<tr>
<td colspan="2">
<button
class="button"><?php echo esc_html( $has_billing ?
$edit_text :
$update_text
) ?></button>
</td>
</tr>
</table>
</div>
</div>
<!--/ Billing -->
<script type="text/javascript">
(function($){
var $billingAddress = $('#fs_billing_address'),
$billingInputs = $billingAddress.find('input, select');
var setPrevValues = function () {
$billingInputs.each(function () {
$(this).attr('data-val', $(this).val());
});
};
setPrevValues();
var hasBillingChanged = function () {
for (var i = 0, len = $billingInputs.length; i < len; i++){
var $this = $($billingInputs[i]);
if ($this.attr('data-val') !== $this.val()) {
return true;
}
}
return false;
};
var isEditAllFieldsMode = false;
$billingAddress.find('.button').click(function(){
$billingAddress.toggleClass('fs-read-mode');
var isEditMode = !$billingAddress.hasClass('fs-read-mode');
$(this)
.html(isEditMode ? '<?php echo esc_js( $update_text ) ?>' : '<?php echo esc_js( $edit_text ) ?>')
.toggleClass('button-primary');
if (isEditMode) {
$('#business_name').focus().select();
isEditAllFieldsMode = true;
} else {
isEditAllFieldsMode = false;
if (!hasBillingChanged())
return;
var billing = {};
$billingInputs.each(function(){
if ($(this).attr('data-val') !== $(this).val()) {
billing[$(this).attr('id')] = $(this).val();
}
});
$.ajax({
url : ajaxurl,
method : 'POST',
data : {
action : '<?php echo $fs->get_ajax_action( 'update_billing' ) ?>',
security : '<?php echo $fs->get_ajax_security( 'update_billing' ) ?>',
module_id: '<?php echo $fs->get_id() ?>',
billing : billing
},
success: function (resultObj) {
if (resultObj.success) {
setPrevValues();
} else {
alert(resultObj.error);
}
}
});
}
});
$billingInputs
// Get into edit mode upon selection.
.focus(function () {
var isEditMode = !$billingAddress.hasClass('fs-read-mode');
if (isEditMode) {
return;
}
$billingAddress.toggleClass('fs-read-mode');
$billingAddress.find('.button')
.html('<?php echo esc_js( $update_text ) ?>')
.toggleClass('button-primary');
})
// If blured after editing only one field without changes, exit edit mode.
.blur(function () {
if (!isEditAllFieldsMode && !hasBillingChanged()) {
$billingAddress.toggleClass('fs-read-mode');
$billingAddress.find('.button')
.html('<?php echo esc_js( $edit_text ) ?>')
.toggleClass('button-primary');
}
});
})(jQuery);
</script>

View File

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

View File

@ -0,0 +1,54 @@
<?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;
}
/**
* @var array $VARS
* @var Freemius $fs
* @var FS_Plugin_License $available_license
* @var string $slug
*/
$fs = $VARS['freemius'];
$available_license = $VARS['license'];
$premium_plan = $VARS['plan'];
$slug = $VARS['slug'];
$blog_id = ! empty( $VARS['blog_id'] ) && is_numeric( $VARS['blog_id'] ) ?
$VARS['blog_id'] :
'';
$install_id = ! empty( $VARS['install_id'] ) && FS_Site::is_valid_id( $VARS['install_id'] ) ?
$VARS['install_id'] :
'';
$activate_plan_text = fs_text_inline( 'Activate %s Plan', 'activate-x-plan', $slug );
$action = 'activate_license';
?>
<form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST">
<input type="hidden" name="fs_action" value="<?php echo $action ?>">
<?php wp_nonce_field( trim("{$action}:{$blog_id}:{$install_id}", ':') ) ?>
<input type="hidden" name="install_id" value="<?php echo $install_id ?>">
<input type="hidden" name="blog_id" value="<?php echo $blog_id ?>">
<input type="hidden" name="license_id" value="<?php echo $available_license->id ?>">
<input type="submit" class="fs-activate-license button<?php echo ! empty( $VARS['class'] ) ? ' ' . $VARS['class'] : '' ?>"
value="<?php echo esc_attr( sprintf(
$activate_plan_text . '%s',
$premium_plan->title,
( $VARS['is_localhost'] && $available_license->is_free_localhost ) ?
' [' . fs_text_inline( 'Localhost', 'localhost', $slug ) . ']' :
( $available_license->is_single_site() ?
'' :
' [' . ( 1 < $available_license->left() ?
sprintf( fs_text_x_inline( '%s left', 'as 5 licenses left', 'x-left', $slug ), $available_license->left() ) :
strtolower( fs_text_inline( 'Last license', 'last-license', $slug ) ) ) . ']'
)
) ) ?> ">
</form>

View File

@ -0,0 +1,451 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* @var array $VARS
* @var Freemius $fs
*/
$fs = $VARS['parent_fs'];
$addon_id = $VARS['addon_id'];
$odd = $VARS['odd'];
$slug = $fs->get_slug();
$fs_blog_id = $VARS['fs_blog_id'];
$active_plugins_directories_map = $VARS['active_plugins_directories_map'];
$addon_info = $VARS['addon_info'];
$is_addon_activated = $fs->is_addon_activated( $addon_id );
$is_addon_connected = $addon_info['is_connected'];
$is_addon_installed = $VARS['is_addon_installed'];
$fs_addon = ( $is_addon_connected && $is_addon_installed ) ?
freemius( $addon_id ) :
false;
// Aliases.
$download_latest_text = fs_text_x_inline( 'Download Latest', 'as download latest version', 'download-latest', $slug );
$downgrading_plan_text = fs_text_inline( 'Downgrading your plan', 'downgrading-plan', $slug );
$cancelling_subscription_text = fs_text_inline( 'Cancelling the subscription', 'cancelling-subscription', $slug );
/* translators: %1$s: Either 'Downgrading your plan' or 'Cancelling the subscription' */
$downgrade_x_confirm_text = fs_text_inline( '%1$s will immediately stop all future recurring payments and your %s plan license will expire in %s.', 'downgrade-x-confirm', $slug );
$prices_increase_text = fs_text_inline( 'Please note that we will not be able to grandfather outdated pricing for renewals/new subscriptions after a cancellation. If you choose to renew the subscription manually in the future, after a price increase, which typically occurs once a year, you will be charged the updated price.', 'pricing-increase-warning', $slug );
$cancel_trial_confirm_text = fs_text_inline( 'Cancelling the trial will immediately block access to all premium features. Are you sure?', 'cancel-trial-confirm', $slug );
$after_downgrade_non_blocking_text = fs_text_inline( 'You can still enjoy all %s features but you will not have access to %s security & feature updates, nor support.', 'after-downgrade-non-blocking', $slug );
$after_downgrade_blocking_text = fs_text_inline( 'Once your license expires you can still use the Free version but you will NOT have access to the %s features.', 'after-downgrade-blocking', $slug );
/* translators: %s: Plan title (e.g. "Professional") */
$activate_plan_text = fs_text_inline( 'Activate %s Plan', 'activate-x-plan', $slug );
$version_text = fs_text_x_inline( 'Version', 'product version', 'version', $slug );
/* translators: %s: Time period (e.g. Auto renews in "2 months") */
$renews_in_text = fs_text_inline( 'Auto renews in %s', 'renews-in', $slug );
/* translators: %s: Time period (e.g. Expires in "2 months") */
$expires_in_text = fs_text_inline( 'Expires in %s', 'expires-in', $slug );
$cancel_trial_text = fs_text_inline( 'Cancel Trial', 'cancel-trial', $slug );
$change_plan_text = fs_text_inline( 'Change Plan', 'change-plan', $slug );
$upgrade_text = fs_text_x_inline( 'Upgrade', 'verb', 'upgrade', $slug );
$addons_text = fs_text_inline( 'Add-Ons', 'add-ons', $slug );
$downgrade_text = fs_text_x_inline( 'Downgrade', 'verb', 'downgrade', $slug );
$trial_text = fs_text_x_inline( 'Trial', 'trial period', 'trial', $slug );
$free_text = fs_text_inline( 'Free', 'free', $slug );
$activate_text = fs_text_inline( 'Activate', 'activate', $slug );
$plan_text = fs_text_x_inline( 'Plan', 'as product pricing plan', 'plan', $slug );
// Defaults.
$plan = null;
$is_paid_trial = false;
/**
* @var FS_Plugin_License $license
*/
$license = null;
$site = null;
$is_active_subscription = false;
$subscription = null;
$is_paying = false;
$show_upgrade = false;
$is_whitelabeled = $VARS['is_whitelabeled'];
if ( is_object( $fs_addon ) ) {
$is_paying = $fs_addon->is_paying();
$user = $fs_addon->get_user();
$site = $fs_addon->get_site();
$license = $fs_addon->_get_license();
$subscription = ( is_object( $license ) ?
$fs_addon->_get_subscription( $license->id ) :
null );
$plan = $fs_addon->get_plan();
$plan_name = $plan->name;
$plan_title = $plan->title;
$is_paid_trial = $fs_addon->is_paid_trial();
$version = $fs_addon->get_plugin_version();
$is_whitelabeled = (
$fs_addon->is_whitelabeled( true ) &&
! $fs_addon->get_parent_instance()->is_data_debug_mode()
);
$show_upgrade = (
! $is_whitelabeled &&
$fs_addon->has_paid_plan() &&
! $is_paying &&
! $is_paid_trial &&
! $fs_addon->_has_premium_license()
);
} else if ( $is_addon_connected ) {
if (
empty( $addon_info ) ||
! isset( $addon_info['site'] )
) {
$is_addon_connected = false;
} else {
/**
* @var FS_Site $site
*/
$site = $addon_info['site'];
$version = $addon_info['version'];
$plan_name = isset( $addon_info['plan_name'] ) ?
$addon_info['plan_name'] :
'';
$plan_title = isset( $addon_info['plan_title'] ) ?
$addon_info['plan_title'] :
'';
if ( isset( $addon_info['license'] ) ) {
$license = $addon_info['license'];
}
if ( isset( $addon_info['subscription'] ) ) {
$subscription = $addon_info['subscription'];
}
$has_valid_and_active_license = (
is_object( $license ) &&
$license->is_active() &&
$license->is_valid()
);
$is_paid_trial = (
$site->is_trial() &&
$has_valid_and_active_license &&
( $site->trial_plan_id == $license->plan_id )
);
$is_whitelabeled = $addon_info['is_whitelabeled'];
}
}
$has_feature_enabled_license = (
is_object( $license ) &&
$license->is_features_enabled()
);
$is_active_subscription = ( is_object( $subscription ) && $subscription->is_active() );
$show_delete_install_button = ( ! $is_paying && WP_FS__DEV_MODE && ! $is_whitelabeled );
?>
<tr<?php if ( $odd ) {
echo ' class="alternate"';
} ?>>
<td>
<!-- Title -->
<?php echo $addon_info['title'] ?>
</td>
<?php if ( $is_addon_connected ) : ?>
<!-- ID -->
<td><?php echo $site->id ?></td>
<!--/ ID -->
<!-- Version -->
<td><?php echo $version ?></td>
<!--/ Version -->
<!-- Plan Title -->
<td><?php echo strtoupper( is_string( $plan_name ) ? $plan_title : $free_text ) ?></td>
<!--/ Plan Title -->
<!-- Expiration -->
<td>
<?php if ( $site->is_trial() || is_object( $license ) ) : ?>
<?php
$tags = array();
if ( $site->is_trial() ) {
$tags[] = array( 'label' => $trial_text, 'type' => 'success' );
$tags[] = array(
'label' => sprintf(
( $is_paid_trial ?
$renews_in_text :
$expires_in_text ),
human_time_diff( time(), strtotime( $site->trial_ends ) )
),
'type' => ( $is_paid_trial ? 'success' : 'warn' )
);
} else {
if ( is_object( $license ) ) {
if ( $license->is_cancelled ) {
$tags[] = array(
'label' => fs_text_inline( 'Cancelled', 'cancelled', $slug ),
'type' => 'error'
);
} else if ( $license->is_expired() ) {
$tags[] = array(
'label' => fs_text_inline( 'Expired', 'expired', $slug ),
'type' => 'error'
);
} else if ( $license->is_lifetime() ) {
$tags[] = array(
'label' => fs_text_inline( 'No expiration', 'no-expiration', $slug ),
'type' => 'success'
);
} else if ( ! $is_active_subscription && ! $license->is_first_payment_pending() ) {
$tags[] = array(
'label' => sprintf( $expires_in_text, human_time_diff( time(), strtotime( $license->expiration ) ) ),
'type' => 'warn'
);
} else if ( $is_active_subscription && ! $subscription->is_first_payment_pending() ) {
$tags[] = array(
'label' => sprintf( $renews_in_text, human_time_diff( time(), strtotime( $subscription->next_payment ) ) ),
'type' => 'success'
);
}
}
}
foreach ( $tags as $t ) {
printf( '<label class="fs-tag fs-%s">%s</label>' . "\n", $t['type'], $t['label'] );
}
?>
<?php endif ?>
</td>
<!--/ Expiration -->
<?php
$buttons = array();
$is_license_activation_added = false;
if ( $is_addon_activated ) {
if ( ! $is_whitelabeled ) {
if ( $is_paying ) {
$buttons[] = fs_ui_get_action_button(
$fs->get_id(),
'account',
'deactivate_license',
fs_text_inline( 'Deactivate License', 'deactivate-license', $slug ),
'',
array( 'plugin_id' => $addon_id ),
false,
true
);
$human_readable_license_expiration = human_time_diff( time(), strtotime( $license->expiration ) );
$downgrade_confirmation_message = sprintf(
$downgrade_x_confirm_text,
( $fs_addon->is_only_premium() ? $cancelling_subscription_text : $downgrading_plan_text ),
$plan->title,
$human_readable_license_expiration
);
$after_downgrade_message = ! $license->is_block_features ?
sprintf( $after_downgrade_non_blocking_text, $plan->title, $fs_addon->get_module_label( true ) ) :
sprintf( $after_downgrade_blocking_text, $plan->title );
if ( ! $license->is_lifetime() && $is_active_subscription ) {
$buttons[] = fs_ui_get_action_button(
$fs->get_id(),
'account',
'downgrade_account',
esc_html( $fs_addon->is_only_premium() ? fs_text_inline( 'Cancel Subscription', 'cancel-subscription', $slug ) : $downgrade_text ),
'',
array( 'plugin_id' => $addon_id ),
false,
false,
false,
( $downgrade_confirmation_message . ' ' . $after_downgrade_message . ' ' . $prices_increase_text ),
'POST'
);
}
} else if ( $is_paid_trial ) {
$buttons[] = fs_ui_get_action_button(
$fs->get_id(),
'account',
'cancel_trial',
esc_html( $cancel_trial_text ),
'',
array( 'plugin_id' => $addon_id ),
false,
false,
'dashicons dashicons-download',
$cancel_trial_confirm_text,
'POST'
);
} else if ( ! $has_feature_enabled_license ) {
$premium_licenses = $fs_addon->get_available_premium_licenses();
if ( ! empty( $premium_licenses ) ) {
$premium_license = $premium_licenses[0];
$has_multiple_premium_licenses = ( 1 < count( $premium_licenses ) );
if ( ! $has_multiple_premium_licenses ) {
$premium_plan = $fs_addon->_get_plan_by_id( $premium_license->plan_id );
$site = $fs_addon->get_site();
$buttons[] = fs_ui_get_action_button(
$fs->get_id(),
'account',
'activate_license',
esc_html( sprintf( $activate_plan_text, $premium_plan->title, ( $site->is_localhost() && $premium_license->is_free_localhost ) ? '[localhost]' : ( 1 < $premium_license->left() ? $premium_license->left() . ' left' : '' ) ) ),
($has_multiple_premium_licenses ?
'activate-license-trigger ' . $fs_addon->get_unique_affix() :
''),
array(
'plugin_id' => $addon_id,
'license_id' => $premium_license->id,
),
true,
true
);
$is_license_activation_added = true;
}
}
}
}
// if ( 0 == count( $buttons ) ) {
if ( $fs_addon->is_premium() && ! $is_license_activation_added ) {
$fs_addon->_add_license_activation_dialog_box();
$buttons[] = fs_ui_get_action_button(
$fs->get_id(),
'account',
'activate_license',
( ! $has_feature_enabled_license ) ?
fs_esc_html_inline( 'Activate License', 'activate-license', $slug ) :
fs_esc_html_inline( 'Change License', 'change-license', $slug ),
'activate-license-trigger ' . $fs_addon->get_unique_affix(),
array(
'plugin_id' => $addon_id,
),
(! $has_feature_enabled_license),
true
);
$is_license_activation_added = true;
}
if ( $fs_addon->has_paid_plan() ) {
// Add sync license only if non of the other CTAs are visible.
$buttons[] = fs_ui_get_action_button(
$fs->get_id(),
'account',
$fs->get_unique_affix() . '_sync_license',
fs_esc_html_x_inline( 'Sync', 'as synchronize', 'sync', $slug ),
'',
array( 'plugin_id' => $addon_id ),
false,
true
);
}
// }
} else if ( ! $show_upgrade ) {
if ( $fs->is_addon_installed( $addon_id ) ) {
$addon_file = $fs->get_addon_basename( $addon_id );
if ( ! isset( $active_plugins_directories_map[ dirname( $addon_file ) ] ) ) {
$buttons[] = sprintf(
'<a class="button button-primary edit" href="%s" title="%s">%s</a>',
wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . $addon_file, 'activate-plugin_' . $addon_file ),
fs_esc_attr_inline( 'Activate this add-on', 'activate-this-addon', $slug ),
$activate_text
);
}
} else {
if ( $fs->is_allowed_to_install() ) {
$buttons[] = sprintf(
'<a class="button button-primary edit" href="%s">%s</a>',
wp_nonce_url( self_admin_url( 'update.php?' . ( ( isset( $addon_info['has_paid_plan'] ) && $addon_info['has_paid_plan'] ) ? 'fs_allow_updater_and_dialog=true&' : '' ) . 'action=install-plugin&plugin=' . $addon_info['slug'] ), 'install-plugin_' . $addon_info['slug'] ),
fs_text_inline( 'Install Now', 'install-now', $slug )
);
} else {
$buttons[] = sprintf(
'<a target="_blank" rel="noopener" class="button button-primary edit" href="%s">%s</a>',
$fs->_get_latest_download_local_url( $addon_id ),
esc_html( $download_latest_text )
);
}
}
}
if ( $show_upgrade ) {
$buttons[] = sprintf( '<a href="%s" class="thickbox button button-small button-primary" aria-label="%s" data-title="%s"><i class="dashicons dashicons-cart"></i> %s</a>',
esc_url( network_admin_url( 'plugin-install.php?fs_allow_updater_and_dialog=true' . ( ! empty( $fs_blog_id ) ? '&fs_blog_id=' . $fs_blog_id : '' ) . '&tab=plugin-information&parent_plugin_id=' . $fs->get_id() . '&plugin=' . $addon_info['slug'] .
'&TB_iframe=true&width=600&height=550' ) ),
esc_attr( sprintf( fs_text_inline( 'More information about %s', 'more-information-about-x', $slug ), $addon_info['title'] ) ),
esc_attr( $addon_info['title'] ),
( $fs_addon->has_free_plan() ?
$upgrade_text :
fs_text_x_inline( 'Purchase', 'verb', 'purchase', $slug ) )
);
}
$buttons_count = count( $buttons );
?>
<!-- Actions -->
<td><?php if ( $buttons_count > 1 ) : ?>
<div class="button-group"><?php endif ?>
<?php foreach ( $buttons as $button ) {
echo $button;
} ?>
<?php if ( $buttons_count > 1 ) : ?></div><?php endif ?></td>
<!--/ Actions -->
<?php else : ?>
<?php // Add-on NOT Installed or was never connected.
$is_addon_installed_by_filesystem = $fs->is_addon_installed( $addon_id );
?>
<!-- Action -->
<td colspan="<?php echo ( $is_addon_installed_by_filesystem || $show_delete_install_button ) ? '5' : '4' ?>">
<?php if ( $is_addon_installed_by_filesystem ) : ?>
<?php $addon_file = $fs->get_addon_basename( $addon_id ) ?>
<?php if ( ! isset( $active_plugins_directories_map[ dirname( $addon_file ) ] ) ) : ?>
<a class="button button-primary"
href="<?php echo wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . $addon_file, 'activate-plugin_' . $addon_file ) ?>"
title="<?php fs_esc_attr_echo_inline( 'Activate this add-on', 'activate-this-addon', $slug ) ?>"
class="edit"><?php echo esc_html( $activate_text ) ?></a>
<?php endif ?>
<?php else : ?>
<?php if ( $fs->is_allowed_to_install() ) : ?>
<a class="button button-primary"
href="<?php echo wp_nonce_url( self_admin_url( 'update.php?' . ( ( isset( $addon_info['has_paid_plan'] ) && $addon_info['has_paid_plan'] ) ? 'fs_allow_updater_and_dialog=true&' : '' ) . 'action=install-plugin&plugin=' . $addon_info['slug'] ), 'install-plugin_' . $addon_info['slug'] ) ?>"><?php fs_esc_html_echo_inline( 'Install Now', 'install-now', $slug ) ?></a>
<?php else : ?>
<a target="_blank" rel="noopener" class="button button-primary"
href="<?php echo $fs->_get_latest_download_local_url( $addon_id ) ?>"><?php echo esc_html( $download_latest_text ) ?></a>
<?php endif ?>
<?php endif ?>
</td>
<!--/ Action -->
<?php endif ?>
<?php if ( $show_delete_install_button ) : ?>
<!-- Optional Delete Action -->
<td>
<?php
if ( $is_addon_activated ) {
fs_ui_action_button(
$fs->get_id(), 'account',
'delete_account',
fs_text_x_inline( 'Delete', 'verb', 'delete', $slug ),
'',
array( 'plugin_id' => $addon_id ),
false,
$show_upgrade
);
}
?>
</td>
<!--/ Optional Delete Action -->
<?php endif ?>
</tr>

View File

@ -0,0 +1,36 @@
<?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;
}
/**
* @var array $VARS
* @var Freemius $fs
* @var string $slug
*/
$slug = $VARS['slug'];
$fs = $VARS['freemius'];
$blog_id = ! empty( $VARS['blog_id'] ) && is_numeric( $VARS['blog_id'] ) ?
$VARS['blog_id'] :
'';
$install_id = ! empty( $VARS['install_id'] ) && FS_Site::is_valid_id( $VARS['install_id'] ) ?
$VARS['install_id'] :
'';
$action = 'deactivate_license';
?>
<form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST">
<input type="hidden" name="fs_action" value="<?php echo $action ?>">
<?php wp_nonce_field( trim("{$action}:{$blog_id}:{$install_id}", ':') ) ?>
<input type="hidden" name="install_id" value="<?php echo $install_id ?>">
<input type="hidden" name="blog_id" value="<?php echo $blog_id ?>">
<button type="button" class="fs-deactivate-license button<?php echo ! empty( $VARS['class'] ) ? ' ' . $VARS['class'] : '' ?>"><?php fs_echo_inline( 'Deactivate License', 'deactivate-license', $slug ) ?></button>
</form>

View File

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

View File

@ -0,0 +1,352 @@
<?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;
}
/**
* @var array $VARS
* @var Freemius $fs
* @var FS_Plugin_License $main_license
*/
$fs = $VARS['freemius'];
$slug = $fs->get_slug();
$site = $VARS['site'];
$main_license = $VARS['license'];
$is_data_debug_mode = $fs->is_data_debug_mode();
$is_whitelabeled = $fs->is_whitelabeled();
$has_paid_plan = $fs->has_paid_plan();
$is_premium = $fs->is_premium();
$main_user = $fs->get_user();
$blog_id = $site['blog_id'];
$install = $VARS['install'];
$is_registered = ! empty( $install );
$license = null;
$trial_plan = $fs->get_trial_plan();
$free_text = fs_text_inline( 'Free', 'free', $slug );
if ( $is_whitelabeled && $fs->is_delegated_connection( $blog_id ) ) {
$is_whitelabeled = $fs->is_whitelabeled( true, $blog_id );
}
?>
<tr class="fs-site-details" data-blog-id="<?php echo $blog_id ?>"<?php if ( $is_registered ) : ?> data-install-id="<?php echo $install->id ?>"<?php endif ?>>
<!-- Install ID or Opt-in option -->
<td><?php if ( $is_registered ) : ?>
<?php echo $install->id ?>
<?php else : ?>
<?php $action = 'opt_in' ?>
<form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST">
<input type="hidden" name="fs_action" value="<?php echo $action ?>">
<?php wp_nonce_field( trim( "{$action}:{$blog_id}", ':' ) ) ?>
<input type="hidden" name="blog_id" value="<?php echo $blog_id ?>">
<button class="fs-opt-in button button-small"><?php fs_esc_html_echo_inline( 'Opt In', 'opt-in', $slug ) ?></button>
</form>
<?php endif ?>
</td>
<!--/ Install ID or Opt-in option -->
<!-- Site URL -->
<td class="fs-field-url fs-main-column"><?php echo fs_strip_url_protocol( $site['url'] ) ?></td>
<!--/ Site URL -->
<!-- License Activation / Deactivation -->
<td><?php if ( $has_paid_plan ) {
$view_params = array(
'freemius' => $fs,
'slug' => $slug,
'blog_id' => $blog_id,
'class' => 'button-small',
);
$license = null;
if ( $is_registered ) {
$view_params['install_id'] = $install->id;
$view_params['is_localhost'] = $install->is_localhost();
$has_license = FS_Plugin_License::is_valid_id( $install->license_id );
$license = $has_license ?
$fs->_get_license_by_id( $install->license_id ) :
null;
} else {
$view_params['is_localhost'] = FS_Site::is_localhost_by_address( $site['url'] );
}
if ( ! $is_whitelabeled ) {
if ( is_object( $license ) ) {
$view_params['license'] = $license;
// Show license deactivation button.
fs_require_template( 'account/partials/deactivate-license-button.php', $view_params );
} else {
if ( is_object( $main_license ) && $main_license->can_activate( $view_params['is_localhost'] ) ) {
// Main license is available for activation.
$available_license = $main_license;
} else {
// Try to find any available license for activation.
$available_license = $fs->_get_available_premium_license( $view_params['is_localhost'] );
}
if ( is_object( $available_license ) ) {
$premium_plan = $fs->_get_plan_by_id( $available_license->plan_id );
$view_params['license'] = $available_license;
$view_params['class'] .= ' button-primary';
$view_params['plan'] = $premium_plan;
fs_require_template( 'account/partials/activate-license-button.php', $view_params );
}
}
}
} ?></td>
<!--/ License Activation / Deactivation -->
<!-- Plan -->
<td><?php if ( $is_registered ) : ?>
<?php
if ( ! $has_paid_plan ) {
$plan_title = $free_text;
} else {
if ( $install->is_trial() ) {
if ( is_object( $trial_plan ) && $trial_plan->id == $install->trial_plan_id ) {
$plan_title = is_string( $trial_plan->name ) ?
strtoupper( $trial_plan->title ) :
fs_text_inline( 'Trial', 'trial', $slug );
} else {
$plan_title = fs_text_inline( 'Trial', 'trial', $slug );
}
} else {
$plan = $fs->_get_plan_by_id( $install->plan_id );
$plan_title = strtoupper( is_string( $plan->title ) ?
$plan->title :
strtoupper( $free_text )
);
}
}
?>
<code><?php echo $plan_title ?></code>
<?php endif ?></td>
<!--/ Plan -->
<!-- More details button -->
<td><?php if ( $is_registered ) : ?>
<button class="fs-show-install-details button button-small">More details <i
class="dashicons dashicons-arrow-right-alt2"></i>
</button><?php endif ?></td>
<!--/ More details button -->
</tr>
<?php if ( $is_registered ) : ?>
<!-- More details -->
<tr class="fs-install-details" data-install-id="<?php echo $install->id ?>" style="display: none">
<td colspan="5">
<table class="widefat fs-key-value-table">
<tbody>
<?php $row_index = 0 ?>
<!-- Blog ID -->
<tr <?php if ( 1 == $row_index % 2 ) {
echo ' class="alternate"';
} ?>>
<td>
<nobr><?php fs_esc_html_echo_inline( 'Blog ID', 'blog-id', $slug ) ?>:</nobr>
</td>
<td><code><?php echo $blog_id ?></code></td>
<td><?php if ( ! FS_Plugin_License::is_valid_id( $install->license_id ) ) : ?>
<!-- Toggle Usage Tracking -->
<?php $action = 'toggle_tracking' ?>
<form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST">
<input type="hidden" name="fs_action" value="<?php echo $action ?>">
<?php wp_nonce_field( trim( "{$action}:{$blog_id}:{$install->id}", ':' ) ) ?>
<input type="hidden" name="install_id" value="<?php echo $install->id ?>">
<input type="hidden" name="blog_id" value="<?php echo $blog_id ?>">
<button class="fs-toggle-tracking button button-small<?php if ( $install->is_disconnected ) {
echo ' button-primary';
} ?>" data-is-disconnected="<?php echo $install->is_disconnected ? 'true' : 'false' ?>"><?php $install->is_disconnected ? fs_esc_html_echo_inline( 'Opt In', 'opt-in', $slug ) : fs_esc_html_echo_inline( 'Opt Out', 'opt-out', $slug ) ?></button>
</form>
<!--/ Toggle Usage Tracking -->
<?php endif ?></td>
</tr>
<?php $row_index ++ ?>
<!--/ Blog ID -->
<?php if ( $is_registered && $install->user_id != $main_user->id ) : ?>
<?php
/**
* @var FS_User $user
*/
$user = Freemius::_get_user_by_id( $install->user_id ) ?>
<?php if ( is_object( $user ) ) : ?>
<!-- User Name -->
<tr <?php if ( 1 == $row_index % 2 ) {
echo ' class="alternate"';
} ?>>
<td>
<nobr><?php fs_esc_html_echo_inline( 'Owner Name', 'owner-name', $slug ) ?>:</nobr>
</td>
<td colspan="2"><code><?php echo htmlspecialchars( $user->get_name() ) ?></code></td>
</tr>
<?php $row_index ++ ?>
<!--/ User Name -->
<!-- User Email -->
<tr <?php if ( 1 == $row_index % 2 ) {
echo ' class="alternate"';
} ?>>
<td>
<nobr><?php fs_esc_html_echo_inline( 'Owner Email', 'owner-email', $slug ) ?>:</nobr>
</td>
<td colspan="2"><code><?php echo htmlspecialchars( $user->email ) ?></code></td>
</tr>
<?php $row_index ++ ?>
<!--/ User Email -->
<!-- User ID -->
<tr <?php if ( 1 == $row_index % 2 ) {
echo ' class="alternate"';
} ?>>
<td>
<nobr><?php fs_esc_html_echo_inline( 'Owner ID', 'owner-id', $slug ) ?>:</nobr>
</td>
<td colspan="2"><code><?php echo $user->id ?></code></td>
</tr>
<?php $row_index ++ ?>
<!--/ User ID -->
<?php endif ?>
<?php endif ?>
<!-- Public Key -->
<tr <?php if ( 1 == $row_index % 2 ) {
echo ' class="alternate"';
} ?>>
<td>
<nobr><?php fs_esc_html_echo_inline( 'Public Key', 'public-key', $slug ) ?>:</nobr>
</td>
<td colspan="2"><code><?php echo htmlspecialchars( $install->public_key ) ?></code></td>
</tr>
<?php $row_index ++ ?>
<!--/ Public Key -->
<!-- Secret Key -->
<tr <?php if ( 1 == $row_index % 2 ) {
echo ' class="alternate"';
} ?>>
<td>
<nobr><?php fs_esc_html_echo_inline( 'Secret Key', 'secret-key', $slug ) ?>:</nobr>
</td>
<td>
<code><?php echo FS_Plugin_License::mask_secret_key_for_html( $install->secret_key ) ?></code>
<?php if ( ! $is_whitelabeled ) : ?>
<input type="text" value="<?php echo htmlspecialchars( $install->secret_key ) ?>"
style="display: none" readonly/></td>
<?php endif ?>
<?php if ( ! $is_whitelabeled ) : ?>
<td><button class="button button-small fs-toggle-visibility"><?php fs_esc_html_echo_x_inline( 'Show', 'verb', 'show', $slug ) ?></button></td>
<?php endif ?>
</tr>
<?php $row_index ++ ?>
<!--/ Secret Key -->
<?php if ( is_object( $license ) ) : ?>
<!-- License Key -->
<tr <?php if ( 1 == $row_index % 2 ) {
echo ' class="alternate"';
} ?>>
<td>
<nobr><?php fs_esc_html_echo_inline( 'License Key', 'license-key', $slug ) ?>:</nobr>
</td>
<td>
<code><?php echo $license->get_html_escaped_masked_secret_key() ?></code>
<?php if ( ! $is_whitelabeled ) : ?>
<input type="text" value="<?php echo htmlspecialchars( $license->secret_key ) ?>"
style="display: none" readonly/></td>
<?php endif ?>
<?php if ( ! $is_whitelabeled ) : ?>
<td>
<button class="button button-small fs-toggle-visibility"><?php fs_esc_html_echo_x_inline( 'Show', 'verb', 'show', $slug ) ?></button>
<button class="button button-small activate-license-trigger <?php echo $fs->get_unique_affix() ?>"><?php fs_esc_html_echo_inline( 'Change License', 'change-license', $slug ) ?></button>
</td>
<?php endif ?>
</tr>
<?php $row_index ++ ?>
<!--/ License Key -->
<?php if ( ! is_object( $main_license ) || $main_license->id != $license->id ) : ?>
<?php $subscription = $fs->_get_subscription( $license->id ) ?>
<?php if ( ! $license->is_lifetime() && is_object( $subscription ) ) : ?>
<!-- Subscription -->
<tr <?php if ( 1 == $row_index % 2 ) {
echo ' class="alternate"';
} ?>>
<td>
<nobr><?php fs_esc_html_echo_inline( 'Subscription', 'subscription', $slug ) ?>:</nobr>
</td>
<?php
$is_active_subscription = $subscription->is_active();
$renews_in_text = fs_text_inline( 'Auto renews in %s', 'renews-in', $slug );
/* translators: %s: Time period (e.g. Expires in "2 months") */
$expires_in_text = fs_text_inline( 'Expires in %s', 'expires-in', $slug );
?>
<td>
<code><?php echo $subscription->id ?> - <?php
echo ( 12 == $subscription->billing_cycle ?
_fs_text_inline( 'Annual', 'annual', $slug ) :
_fs_text_inline( 'Monthly', 'monthly', $slug )
);
?>
</code>
<?php if ( ! $is_active_subscription && ! $license->is_first_payment_pending() ) : ?>
<label class="fs-tag fs-warn"><?php echo esc_html( sprintf( $expires_in_text, human_time_diff( time(), strtotime( $license->expiration ) ) ) ) ?></label>
<?php elseif ( $is_active_subscription && ! $subscription->is_first_payment_pending() ) : ?>
<label class="fs-tag fs-success"><?php echo esc_html( sprintf( $renews_in_text, human_time_diff( time(), strtotime( $subscription->next_payment ) ) ) ) ?></label>
<?php endif ?>
</td>
<td><?php if ( $is_active_subscription ) : ?>
<?php
$downgrading_plan_text = fs_text_inline( 'Downgrading your plan', 'downgrading-plan', $slug );
$cancelling_subscription_text = fs_text_inline( 'Cancelling the subscription', 'cancelling-subscription', $slug );
/* translators: %1$s: Either 'Downgrading your plan' or 'Cancelling the subscription' */
$downgrade_x_confirm_text = fs_text_inline( '%1$s will immediately stop all future recurring payments and your %2$s plan license will expire in %3$s.', 'downgrade-x-confirm', $slug );
$prices_increase_text = fs_text_inline( 'Please note that we will not be able to grandfather outdated pricing for renewals/new subscriptions after a cancellation. If you choose to renew the subscription manually in the future, after a price increase, which typically occurs once a year, you will be charged the updated price.', 'pricing-increase-warning', $slug );
$after_downgrade_non_blocking_text = fs_text_inline( 'You can still enjoy all %s features but you will not have access to %s security & feature updates, nor support.', 'after-downgrade-non-blocking', $slug );
$after_downgrade_blocking_text = fs_text_inline( 'Once your license expires you can still use the Free version but you will NOT have access to the %s features.', 'after-downgrade-blocking', $slug );
$downgrade_text = fs_text_x_inline( 'Downgrade', 'verb', 'downgrade', $slug );
$human_readable_license_expiration = human_time_diff( time(), strtotime( $license->expiration ) );
$downgrade_confirmation_message = sprintf(
$downgrade_x_confirm_text,
( $fs->is_only_premium() ? $cancelling_subscription_text : $downgrading_plan_text ),
$plan->title,
$human_readable_license_expiration
);
$after_downgrade_message = ! $license->is_block_features ?
sprintf( $after_downgrade_non_blocking_text, $plan->title, $fs->get_module_label( true ) ) :
sprintf( $after_downgrade_blocking_text, $plan->title );
?>
<?php $action = 'downgrade_account' ?>
<form id="fs_downgrade" action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST">
<input type="hidden" name="fs_action" value="<?php echo $action ?>">
<?php wp_nonce_field( trim( "{$action}:{$blog_id}", ':' ) ) ?>
<input type="hidden" name="blog_id" value="<?php echo $blog_id ?>">
<button class="button button-small" onclick="if (confirm('<?php echo esc_attr( $downgrade_confirmation_message . ' ' . $after_downgrade_message . ' ' . $prices_increase_text ) ?>')) { this.parentNode.submit(); } else { return false; }"><?php echo $downgrade_text ?></button>
</form>
<?php endif ?></td>
</tr>
<?php $row_index ++ ?>
<?php endif ?>
<!--/ Subscription -->
<?php endif ?>
<?php endif ?>
</tbody>
</table>
</td>
</tr>
<!--/ More details -->
<?php endif ?>

View File

@ -0,0 +1,59 @@
<?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.2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* @var array $VARS
* @var Freemius $fs
*/
$fs = freemius( $VARS['id'] );
$slug = $fs->get_slug();
$payments = $fs->_fetch_payments();
$show_payments = ( is_array( $payments ) && 0 < count( $payments ) );
if ( $show_payments ) :
?>
<div class="postbox">
<div id="fs_payments">
<h3><span class="dashicons dashicons-paperclip"></span> <?php fs_esc_html_echo_inline( 'Payments', 'payments', $slug ) ?></h3>
<div class="inside">
<table class="widefat">
<thead>
<tr>
<th><?php fs_esc_html_echo_inline( 'ID', 'id', $slug ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Date', 'date', $slug ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Amount', 'amount', $slug ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Invoice', 'invoice', $slug ) ?></th>
</tr>
</thead>
<tbody>
<?php $odd = true ?>
<?php foreach ( $payments as $payment ) : ?>
<tr<?php echo $odd ? ' class="alternate"' : '' ?>>
<td><?php echo $payment->id ?></td>
<td><?php echo date( 'M j, Y', strtotime( $payment->created ) ) ?></td>
<td><?php echo $payment->formatted_gross() ?></td>
<td><?php if (! $payment->is_migrated() ) : ?><a href="<?php echo $fs->_get_invoice_api_url( $payment->id ) ?>"
class="button button-small"
target="_blank" rel="noopener"><?php fs_esc_html_echo_inline( 'Invoice', 'invoice', $slug ) ?></a><?php endif ?></td>
</tr>
<?php $odd = ! $odd; endforeach ?>
</tbody>
</table>
</div>
</div>
</div>
<?php
endif;

View File

@ -0,0 +1,502 @@
<?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;
}
/**
* @var array $VARS
* @var Freemius
*/
$fs = freemius( $VARS['id'] );
$slug = $fs->get_slug();
$open_addon_slug = fs_request_get( 'slug' );
$open_addon = false;
$is_data_debug_mode = $fs->is_data_debug_mode();
$is_whitelabeled = $fs->is_whitelabeled();
/**
* @var FS_Plugin[]
*/
$addons = $fs->get_addons();
$has_addons = ( is_array( $addons ) && 0 < count( $addons ) );
$account_addon_ids = $fs->get_updated_account_addons();
$download_latest_text = fs_text_x_inline( 'Download Latest', 'as download latest version', 'download-latest', $slug );
$view_details_text = fs_text_inline( 'View details', 'view-details', $slug );
$has_tabs = $fs->_add_tabs_before_content();
$fs_blog_id = ( is_multisite() && ! is_network_admin() ) ?
get_current_blog_id() :
0;
?>
<div id="fs_addons" class="wrap fs-section">
<?php if ( ! $has_tabs ) : ?>
<h2><?php echo esc_html( sprintf( fs_text_inline( 'Add Ons for %s', 'add-ons-for-x', $slug ), $fs->get_plugin_name() ) ) ?></h2>
<?php endif ?>
<?php $fs->do_action( 'addons/after_title' ) ?>
<div id="poststuff">
<?php if ( ! $has_addons ) : ?>
<h3><?php echo esc_html( sprintf(
'%s... %s',
fs_text_x_inline( 'Oops', 'exclamation', 'oops', $slug ),
fs_text_inline( 'We couldn\'t load the add-ons list. It\'s probably an issue on our side, please try to come back in few minutes.', 'add-ons-missing', $slug )
) ) ?></h3>
<?php endif ?>
<ul class="fs-cards-list">
<?php if ( $has_addons ) : ?>
<?php
$plans_and_pricing_by_addon_id = $fs->_get_addons_plans_and_pricing_map_by_id();
$active_plugins_directories_map = Freemius::get_active_plugins_directories_map( $fs_blog_id );
?>
<?php
$hide_all_addons_data = false;
if ( $fs->is_whitelabeled_by_flag() ) {
$hide_all_addons_data = true;
$addon_ids = $fs->get_updated_account_addons();
$installed_addons = $fs->get_installed_addons();
foreach ( $installed_addons as $fs_addon ) {
$addon_ids[] = $fs_addon->get_id();
}
if ( ! empty( $addon_ids ) ) {
$addon_ids = array_unique( $addon_ids );
}
foreach ( $addon_ids as $addon_id ) {
$addon = $fs->get_addon( $addon_id );
if ( ! is_object( $addon ) ) {
continue;
}
$addon_storage = FS_Storage::instance( WP_FS__MODULE_TYPE_PLUGIN, $addon->slug );
if ( ! $addon_storage->is_whitelabeled ) {
$hide_all_addons_data = false;
break;
}
if ( $is_data_debug_mode ) {
$is_whitelabeled = false;
}
}
}
?>
<?php foreach ( $addons as $addon ) : ?>
<?php
$basename = $fs->get_addon_basename( $addon->id );
$is_addon_installed = file_exists( fs_normalize_path( WP_PLUGIN_DIR . '/' . $basename ) );
if ( ! $is_addon_installed && $hide_all_addons_data ) {
continue;
}
$is_addon_activated = $is_addon_installed ?
$fs->is_addon_activated( $addon->id ) :
false;
$is_plugin_active = (
$is_addon_activated ||
isset( $active_plugins_directories_map[ dirname( $basename ) ] )
);
$open_addon = ( $open_addon || ( $open_addon_slug === $addon->slug ) );
$price = 0;
$has_trial = false;
$has_free_plan = false;
$has_paid_plan = false;
if ( isset( $plans_and_pricing_by_addon_id[$addon->id] ) ) {
$plans = $plans_and_pricing_by_addon_id[$addon->id];
if ( is_array( $plans ) && 0 < count( $plans ) ) {
foreach ( $plans as $plan ) {
if ( ! isset( $plan->pricing ) ||
! is_array( $plan->pricing ) ||
0 == count( $plan->pricing )
) {
// No pricing means a free plan.
$has_free_plan = true;
continue;
}
$has_paid_plan = true;
$has_trial = $has_trial || ( is_numeric( $plan->trial_period ) && ( $plan->trial_period > 0 ) );
$min_price = 999999;
foreach ( $plan->pricing as $pricing ) {
$pricing = new FS_Pricing( $pricing );
if ( ! $pricing->is_usd() ) {
/**
* Skip non-USD pricing.
*
* @author Leo Fajardo (@leorw)
* @since 2.3.1
*/
continue;
}
if ( $pricing->has_annual() ) {
$min_price = min( $min_price, $pricing->annual_price );
} else if ( $pricing->has_monthly() ) {
$min_price = min( $min_price, 12 * $pricing->monthly_price );
}
}
if ( $min_price < 999999 ) {
$price = $min_price;
}
}
}
if ( ! $has_paid_plan && ! $has_free_plan ) {
continue;
}
}
?>
<li class="fs-card fs-addon" data-slug="<?php echo $addon->slug ?>">
<?php
$view_details_link = sprintf( '<a href="%s" aria-label="%s" data-title="%s"',
esc_url( network_admin_url( 'plugin-install.php?fs_allow_updater_and_dialog=true' . ( ! empty( $fs_blog_id ) ? '&fs_blog_id=' . $fs_blog_id : '' ) . '&tab=plugin-information&parent_plugin_id=' . $fs->get_id() . '&plugin=' . $addon->slug .
'&TB_iframe=true&width=600&height=550' ) ),
esc_attr( sprintf( fs_text_inline( 'More information about %s', 'more-information-about-x', $slug ), $addon->title ) ),
esc_attr( $addon->title )
) . ' class="thickbox%s">%s</a>';
echo sprintf(
$view_details_link,
/**
* Additional class.
*
* @author Leo Fajardo (@leorw)
* @since 2.2.4
*/
' fs-overlay',
/**
* Set the view details link text to an empty string since it is an overlay that
* doesn't really need a text and whose purpose is to open the details dialog when
* the card is clicked.
*
* @author Leo Fajardo (@leorw)
* @since 2.2.4
*/
''
);
?>
<?php
if ( is_null( $addon->info ) ) {
$addon->info = new stdClass();
}
if ( ! isset( $addon->info->card_banner_url ) ) {
$addon->info->card_banner_url = '//dashboard.freemius.com/assets/img/marketing/blueprint-300x100.jpg';
}
if ( ! isset( $addon->info->short_description ) ) {
$addon->info->short_description = 'What\'s the one thing your add-on does really, really well?';
}
?>
<div class="fs-inner">
<ul>
<li class="fs-card-banner"
style="background-image: url('<?php echo $addon->info->card_banner_url ?>');"><?php
if ( $is_plugin_active || $is_addon_installed ) {
echo sprintf(
'<span class="fs-badge fs-installed-addon-badge">%s</span>',
esc_html( $is_plugin_active ?
fs_text_x_inline( 'Active', 'active add-on', 'active-addon', $slug ) :
fs_text_x_inline( 'Installed', 'installed add-on', 'installed-addon', $slug )
)
);
}
?></li>
<!-- <li class="fs-tag"></li> -->
<li class="fs-title"><?php echo $addon->title ?></li>
<li class="fs-offer">
<span
class="fs-price"><?php
if ( $is_whitelabeled ) {
echo '&nbsp;';
} else {
$descriptors = array();
if ($has_free_plan)
$descriptors[] = fs_text_inline( 'Free', 'free', $slug );
if ($has_paid_plan && $price > 0)
$descriptors[] = '$' . number_format( $price, 2 );
if ($has_trial)
$descriptors[] = fs_text_x_inline( 'Trial', 'trial period', 'trial', $slug );
echo implode(' - ', $descriptors);
} ?></span>
</li>
<li class="fs-description"><?php echo ! empty( $addon->info->short_description ) ? $addon->info->short_description : 'SHORT DESCRIPTION' ?></li>
<?php
$is_free_only_wp_org_compliant = ( ! $has_paid_plan && $addon->is_wp_org_compliant );
$is_allowed_to_install = (
$fs->is_allowed_to_install() ||
$is_free_only_wp_org_compliant
);
$show_premium_activation_or_installation_action = true;
if ( ! in_array( $addon->id, $account_addon_ids ) ) {
$show_premium_activation_or_installation_action = false;
} else if ( $is_addon_installed ) {
/**
* If any add-on's version (free or premium) is installed, check if the
* premium version can be activated and show the relevant action. Otherwise,
* show the relevant action for the free version.
*
* @author Leo Fajardo (@leorw)
* @since 2.4.5
*/
$fs_addon = $is_addon_activated ?
$fs->get_addon_instance( $addon->id ) :
null;
$premium_plugin_basename = is_object( $fs_addon ) ?
$fs_addon->premium_plugin_basename() :
"{$addon->premium_slug}/{$addon->slug}.php";
if (
( $is_addon_activated && $fs_addon->is_premium() ) ||
file_exists( fs_normalize_path( WP_PLUGIN_DIR . '/' . $premium_plugin_basename ) )
) {
$basename = $premium_plugin_basename;
}
$show_premium_activation_or_installation_action = (
( ! $is_addon_activated || ! $fs_addon->is_premium() ) &&
/**
* This check is needed for cases when an active add-on doesn't have an
* associated Freemius instance.
*
* @author Leo Fajardo (@leorw)
* @since 2.4.5
*/
( ! $is_plugin_active )
);
}
?>
<?php if ( ! $show_premium_activation_or_installation_action ) : ?>
<li class="fs-cta"><a class="button"><?php echo esc_html( $view_details_text ) ?></a></li>
<?php else : ?>
<?php
$latest_download_local_url = $is_free_only_wp_org_compliant ?
null :
$fs->_get_latest_download_local_url( $addon->id );
?>
<li class="fs-cta fs-dropdown">
<div class="button-group">
<?php if ( $is_allowed_to_install ) : ?>
<?php
if ( ! $is_addon_installed ) {
echo sprintf(
'<a class="button button-primary" href="%s">%s</a>',
wp_nonce_url( self_admin_url( 'update.php?' . ( ( $has_paid_plan || ! $addon->is_wp_org_compliant ) ? 'fs_allow_updater_and_dialog=true&' : '' ) . 'action=install-plugin&plugin=' . $addon->slug ), 'install-plugin_' . $addon->slug ),
fs_esc_html_inline( 'Install Now', 'install-now', $slug )
);
} else {
echo sprintf(
'<a class="button button-primary edit" href="%s" title="%s" target="_parent">%s</a>',
wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . $basename, 'activate-plugin_' . $basename ),
fs_esc_attr_inline( 'Activate this add-on', 'activate-this-addon', $addon->slug ),
fs_text_inline( 'Activate', 'activate', $addon->slug )
);
}
?>
<?php else : ?>
<a target="_blank" rel="noopener" class="button button-primary" href="<?php echo $latest_download_local_url ?>"><?php echo esc_html( $download_latest_text ) ?></a>
<?php endif ?>
<div class="button button-primary fs-dropdown-arrow-button"><span class="fs-dropdown-arrow"></span><ul class="fs-dropdown-list" style="display: none">
<?php if ( $is_allowed_to_install && ! empty( $latest_download_local_url ) ) : ?>
<li><a target="_blank" rel="noopener" href="<?php echo $latest_download_local_url ?>"><?php echo esc_html( $download_latest_text ) ?></a></li>
<?php endif ?>
<li><?php
echo sprintf(
$view_details_link,
/**
* No additional class.
*
* @author Leo Fajardo (@leorw)
* @since 2.2.4
*/
'',
/**
* Set the view details link text to a non-empty string since it is an
* item in the dropdown list and the text should be visible.
*
* @author Leo Fajardo (@leorw)
* @since 2.2.4
*/
esc_html( $view_details_text )
);
?></li>
</ul></div>
</div>
</li>
<?php endif ?>
</ul>
</div>
</li>
<?php endforeach ?>
<?php endif ?>
</ul>
</div>
<?php $fs->do_action( 'addons/after_addons' ) ?>
</div>
<script type="text/javascript">
(function( $, undef ) {
<?php if ( $open_addon ) : ?>
var interval = setInterval(function () {
// Open add-on information page.
<?php
/**
* @author Vova Feldman
*
* This code does NOT expose an XSS vulnerability because:
* 1. This page only renders for admins, so if an attacker manage to get
* admin access, they can do more harm.
* 2. This code won't be rendered unless $open_addon_slug matches any of
* the plugin's add-ons slugs.
*/
?>
$('.fs-card[data-slug=<?php echo $open_addon_slug ?>] a').click();
if ($('#TB_iframeContent').length > 0) {
clearInterval(interval);
interval = null;
}
}, 200);
<?php else : ?>
$( '.fs-card.fs-addon' )
.mouseover(function() {
var $this = $( this );
$this.find( '.fs-cta .button' ).addClass( 'button-primary' );
if ( 0 === $this.find( '.fs-dropdown-arrow-button.active' ).length ) {
/**
* When hovering over a card, close the dropdown on any other card.
*
* @author Leo Fajardo (@leorw)
* @since 2.2.4
*/
toggleDropdown();
}
}).mouseout(function( evt ) {
var $relatedTarget = $( evt.relatedTarget );
if ( 0 !== $relatedTarget.parents( '.fs-addon' ).length ) {
return true;
}
var $this = $( this );
/**
* Set the color of the "View details" button to "secondary".
*
* @author Leo Fajardo (@leorw)
* @since 2.2.4
*/
$this.find( '.fs-cta .button' ).filter(function() {
/**
* Keep the "primary" color of the dropdown arrow button, "Install Now" button, and
* "Download Latest" button.
* @author Leo Fajardo (@leorw)
* @since 2.2.4
*/
return $( this ).parent().is( ':not(.button-group)' );
}).removeClass('button-primary');
toggleDropdown( $this.find( '.fs-dropdown' ), false );
}).find( 'a.thickbox, .button:not(.fs-dropdown-arrow-button)' ).click(function() {
toggleDropdown();
});
<?php endif ?>
var $dropdowns = $( '.fs-dropdown' );
if ( 0 !== $dropdowns.length ) {
$dropdowns.find( '.fs-dropdown-arrow-button' ).click(function() {
var $this = $( this ),
$dropdown = $this.parents( '.fs-dropdown' );
toggleDropdown( $dropdown, ! $dropdown.hasClass( 'active' ) );
});
}
/**
* Returns the default state of the dropdown arrow button and hides the dropdown list.
*
* @author Leo Fajardo (@leorw)
* @since 2.2.4
*
* @param {(Object|undefined)} [$dropdown]
* @param {(Boolean|undefined)} [state]
*/
function toggleDropdown( $dropdown, state ) {
if ( undef === $dropdown ) {
var $activeDropdown = $dropdowns.find( '.active' );
if ( 0 !== $activeDropdown.length ) {
$dropdown = $activeDropdown;
}
}
if ( undef === $dropdown ) {
return;
}
if ( undef === state ) {
state = false;
}
$dropdown.toggleClass( 'active', state );
$dropdown.find( '.fs-dropdown-list' ).toggle( state );
$dropdown.find( '.fs-dropdown-arrow-button' ).toggleClass( 'active', state );
}
})( jQuery );
</script>
<?php
if ( $has_tabs ) {
$fs->_add_tabs_after_content();
}
$params = array(
'page' => 'addons',
'module_id' => $fs->get_id(),
'module_type' => $fs->get_module_type(),
'module_slug' => $slug,
'module_version' => $fs->get_plugin_version(),
);
fs_require_template( 'powered-by.php', $params );

View File

@ -0,0 +1,31 @@
<?php
/**
* Add "&trial=true" to pricing menu item href when running in trial
* promotion context.
*
* @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.2.1.5
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* @var Freemius $fs
*/
$fs = freemius( $VARS['id'] );
?>
<script type="text/javascript">
(function ($) {
$(document).ready(function () {
var $pricingMenu = $('.fs-submenu-item.<?php echo $fs->get_unique_affix() ?>.pricing'),
$pricingMenuLink = $pricingMenu.parents('a');
// Add trial querystring param.
$pricingMenuLink.attr('href', $pricingMenuLink.attr('href') + '&trial=true');
});
})(jQuery);
</script>

View File

@ -0,0 +1,76 @@
<?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;
}
$dismiss_text = fs_text_x_inline( 'Dismiss', 'as close a window', 'dismiss' );
$slug = '';
$type = '';
if ( ! empty( $VARS['manager_id'] ) ) {
/**
* @var array $VARS
*/
$slug = $VARS['manager_id'];
$type = WP_FS__MODULE_TYPE_PLUGIN;
if ( false !== strpos( $slug, ':' ) ) {
$parts = explode( ':', $slug );
$slug = $parts[0];
$parts_count = count( $parts );
if ( 1 < $parts_count && WP_FS__MODULE_TYPE_THEME == $parts[1] ) {
$type = $parts[1];
}
}
}
?>
<div<?php if ( ! empty( $VARS['id'] ) ) : ?> data-id="<?php echo $VARS['id'] ?>"<?php endif ?><?php if ( ! empty( $VARS['manager_id'] ) ) : ?> data-manager-id="<?php echo $VARS['manager_id'] ?>"<?php endif ?><?php if ( ! empty( $slug ) ) : ?> data-slug="<?php echo $slug ?>"<?php endif ?><?php if ( ! empty( $type ) ) : ?> data-type="<?php echo $type ?>"<?php endif ?>
class="<?php
switch ( $VARS['type'] ) {
case 'error':
echo 'error form-invalid';
break;
case 'promotion':
echo 'updated promotion';
break;
case 'update':
// echo 'update-nag update';
// break;
case 'success':
default:
echo 'updated success';
break;
}
?> fs-notice<?php if ( ! empty( $VARS['sticky'] ) ) {
echo ' fs-sticky';
} ?><?php if ( ! empty( $VARS['plugin'] ) ) {
echo ' fs-has-title';
} ?><?php if ( ! empty( $slug ) ) {
echo " fs-slug-{$slug}";
} ?><?php if ( ! empty( $type ) ) {
echo " fs-type-{$type}";
} ?>"><?php if ( ! empty( $VARS['plugin'] ) ) : ?>
<label class="fs-plugin-title"><?php echo $VARS['plugin'] ?></label>
<?php endif ?>
<?php if ( ! empty( $VARS['sticky'] ) ) : ?>
<div class="fs-close"><i class="dashicons dashicons-no"
title="<?php echo esc_attr( $dismiss_text ) ?>"></i> <span><?php echo esc_html( $dismiss_text ) ?></span>
</div>
<?php endif ?>
<div class="fs-notice-body">
<?php if ( ! empty( $VARS['title'] ) ) : ?><b><?php echo $VARS['title'] ?></b> <?php endif ?>
<?php echo $VARS['message'] ?>
</div>
</div>

View File

@ -0,0 +1,6 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<div class="fs-ajax-loader" style="display: none"><?php for ( $i = 1; $i <= 8; $i ++ ) : ?><div class="fs-ajax-loader-bar fs-ajax-loader-bar-<?php echo $i ?>"></div><?php endfor ?></div>

View File

@ -0,0 +1,249 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.2.1.5
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* @var array $VARS
* @var Freemius $fs
*/
$slug = $VARS['slug'];
$plugin_id = $VARS['target_module_id'];
$fs = freemius( $VARS['id'] );
$action = $fs->is_tracking_allowed() ?
'stop_tracking' :
'allow_tracking';
$title = $fs->get_plugin_title();
if ( $plugin_id != $fs->get_id() ) {
$addon = $fs->get_addon( $plugin_id );
if ( is_object( $addon ) ) {
$title = $addon->title . ' ' . fs_text_inline( 'Add-On', 'addon', $slug );
}
}
$plugin_title = sprintf(
'<strong>%s</strong>',
esc_html( $title )
);
$sec_countdown = 30;
$countdown_html = sprintf(
esc_js(
/* translators: %s: Number of seconds */
fs_text_inline( '%s sec', 'x-sec', $slug )
),
sprintf( '<span class="fs-countdown">%s</span>', $sec_countdown )
);
fs_enqueue_local_style( 'fs_dialog_boxes', '/admin/dialog-boxes.css' );
fs_enqueue_local_style( 'fs_common', '/admin/common.css' );
$params = array();
$loader_html = fs_get_template( 'ajax-loader.php', $params );
// Pass unique auto installation URL if WP_Filesystem is needed.
$install_url = $fs->_get_sync_license_url(
$plugin_id,
true,
array( 'auto_install' => 'true' )
);
ob_start();
$method = ''; // Leave blank so WP_Filesystem can populate it as necessary.
$credentials = request_filesystem_credentials(
esc_url_raw( $install_url ),
$method,
false,
WP_PLUGIN_DIR,
array()
);
$credentials_form = ob_get_clean();
$require_credentials = ! empty( $credentials_form );
?>
<div class="fs-modal fs-modal-auto-install">
<div class="fs-modal-dialog">
<div class="fs-modal-header">
<h4><?php echo esc_js( fs_text_inline( 'Automatic Installation', 'auto-installation', $slug ) ) ?></h4>
</div>
<div class="fs-modal-body">
<div class="fs-notice-error" style="display: none"><p></p></div>
<?php if ( $require_credentials ) : ?>
<div id="request-filesystem-credentials-dialog">
<?php echo $credentials_form ?>
</div>
<?php else : ?>
<p class="fs-installation-notice"><?php echo sprintf(
fs_esc_html_inline( 'An automated download and installation of %s (paid version) from %s will start in %s. If you would like to do it manually - click the cancellation button now.', 'installing-in-n', $slug ),
$plugin_title,
sprintf(
'<a href="%s" target="_blank" rel="noopener">%s</a>',
'https://freemius.com',
'freemius.com'
),
$countdown_html
) ?></p>
<?php endif ?>
<p class="fs-installing"
style="display: none"><?php echo sprintf( fs_esc_html_inline( 'The installation process has started and may take a few minutes to complete. Please wait until it is done - do not refresh this page.', 'installing-module-x', $slug ), $plugin_title ) ?></p>
</div>
<div class="fs-modal-footer">
<?php echo $loader_html ?>
<button
class="button button-secondary button-cancel"><?php fs_esc_html_echo_inline( 'Cancel Installation', 'cancel-installation', $slug ) ?><?php if ( ! $require_credentials ) : ?> (<?php echo $countdown_html ?>)<?php endif ?></button>
<button
class="button button-primary"><?php fs_esc_html_echo_inline( 'Install Now', 'install-now', $slug ) ?></button>
</div>
</div>
</div>'
<script type="text/javascript">
(function ($) {
$(document).ready(function () {
var $modal = $('.fs-modal-auto-install'),
$body = $('body'),
$countdown = $modal.find('.fs-countdown'),
requireCredentials = <?php echo json_encode( $require_credentials ) ?>,
$credentialsForm = $('#request-filesystem-credentials-dialog'),
$errorNotice = $modal.find('.fs-notice-error'),
installing = false;
$modal.appendTo($body);
var startAutoInstall = function () {
if (installing)
return;
installing = true;
// Start auto-install.
$modal.addClass('fs-warn');
if (requireCredentials) {
$credentialsForm.hide();
} else {
$modal.find('.fs-installation-notice').hide();
}
$errorNotice.hide();
$modal.find('.fs-installing').show();
$modal.find('button').hide();
$modal.find('.fs-ajax-loader').show();
var data = {
action : '<?php echo $fs->get_ajax_action( 'install_premium_version' ) ?>',
security : '<?php echo $fs->get_ajax_security( 'install_premium_version' ) ?>',
slug : '<?php echo $slug ?>',
module_id : '<?php echo $fs->get_id() ?>',
target_module_id: '<?php echo $plugin_id ?>'
};
if (requireCredentials) {
// Add filesystem credentials.
data.hostname = $('#hostname').val();
data.username = $('#username').val();
data.password = $('#password').val();
data.connection_type = $('input[name="connection_type"]:checked').val();
data.public_key = $('#public_key').val();
data.private_key = $('#private_key').val();
}
$.ajax({
url : ajaxurl,
method : 'POST',
data : data,
success: function (resultObj) {
var reloadAccount = false;
if (resultObj.success) {
// Reload account page to show new data.
reloadAccount = true;
} else {
switch (resultObj.error.code) {
case 'invalid_module_id':
case 'premium_installed':
reloadAccount = true;
break;
case 'invalid_license':
case 'premium_version_missing':
case 'unable_to_connect_to_filesystem':
default:
$modal.removeClass('fs-warn');
$modal.find('.fs-installing').hide();
$modal.find('.fs-ajax-loader').hide();
$modal.find('.button-cancel').html(<?php fs_json_encode_echo_inline( 'Cancel Installation', 'cancel-installation', $slug ) ?>);
$modal.find('button').show();
$errorNotice.find('p').text(resultObj.error.message);
$errorNotice.addClass('notice notice-alt notice-error').show();
if (requireCredentials) {
$credentialsForm.show();
}
break;
}
}
if (reloadAccount) {
window.location = '<?php echo $fs->get_account_url() ?>';
}
installing = false;
}
});
};
var clearCountdown = function () {
clearInterval(countdownInterval);
countdownInterval = null;
};
var cancelAutoInstall = function () {
$modal.fadeOut(function () {
$modal.remove();
$body.removeClass('has-fs-modal');
});
};
var countdown = <?php echo $sec_countdown ?>,
countdownInterval = requireCredentials ? null : setInterval(function () {
$countdown.html(--countdown);
if (0 == countdown) {
clearCountdown();
startAutoInstall();
}
}, 1000);
$modal.addClass('active');
$body.addClass('has-fs-modal');
$modal.find('.button-primary').click(function () {
clearCountdown();
startAutoInstall();
});
$modal.find('.button-cancel').click(function () {
clearCountdown();
cancelAutoInstall();
});
if (requireCredentials) {
}
});
})(jQuery);
</script>

View File

@ -0,0 +1,337 @@
<?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
*/
/**
* Note for WordPress.org Theme/Plugin reviewer:
* Freemius is an SDK for plugin and theme developers. Since the core
* of the SDK is relevant both for plugins and themes, for obvious reasons,
* we only develop and maintain one code base.
*
* This code (and page) will not run for wp.org themes (only plugins).
*
* In addition, this page loads an i-frame. We intentionally named it 'frame'
* so it will pass the "Theme Check" that is looking for the string "i" . "frame".
*
* UPDATE:
* After ongoing conversations with the WordPress.org TRT we received
* an official approval for including i-frames in the theme's WP Admin setting's
* page tab (the SDK will never add any i-frames on the sitefront). i-frames
* were never against the guidelines, but we wanted to get the team's blessings
* before we move forward. For the record, I got the final approval from
* Ulrich Pogson (@grapplerulrich), a team lead at the TRT during WordCamp
* Europe 2017 (June 16th, 2017).
*
* If you have any questions or need clarifications, please don't hesitate
* pinging me on slack, my username is @svovaf.
*
* @author Vova Feldman (@svovaf)
* @since 1.2.2
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'json2' );
fs_enqueue_local_script( 'postmessage', 'nojquery.ba-postmessage.min.js' );
fs_enqueue_local_script( 'fs-postmessage', 'postmessage.js' );
fs_enqueue_local_style( 'fs_common', '/admin/common.css' );
fs_enqueue_local_style( 'fs_checkout', '/admin/checkout.css' );
/**
* @var array $VARS
* @var Freemius $fs
*/
$fs = freemius( $VARS['id'] );
$slug = $fs->get_slug();
$timestamp = time();
$context_params = array(
'plugin_id' => $fs->get_id(),
'public_key' => $fs->get_public_key(),
'plugin_version' => $fs->get_plugin_version(),
'mode' => 'dashboard',
'trial' => fs_request_get_bool( 'trial' ),
);
$plan_id = fs_request_get( 'plan_id' );
if ( FS_Plugin_Plan::is_valid_id( $plan_id ) ) {
$context_params['plan_id'] = $plan_id;
}
$licenses = fs_request_get( 'licenses' );
if ( $licenses === strval( intval( $licenses ) ) && $licenses > 0 ) {
$context_params['licenses'] = $licenses;
}
$plugin_id = fs_request_get( 'plugin_id' );
if ( ! FS_Plugin::is_valid_id( $plugin_id ) ) {
$plugin_id = $fs->get_id();
}
if ( $plugin_id == $fs->get_id() ) {
$is_premium = $fs->is_premium();
$bundle_id = $fs->get_bundle_id();
if ( ! is_null( $bundle_id ) ) {
$context_params['bundle_id'] = $bundle_id;
}
} else {
// Identify the module code version of the checkout context module.
if ( $fs->is_addon_activated( $plugin_id ) ) {
$fs_addon = Freemius::get_instance_by_id( $plugin_id );
$is_premium = $fs_addon->is_premium();
} else {
// If add-on isn't activated assume the premium version isn't installed.
$is_premium = false;
}
}
// Get site context secure params.
if ( $fs->is_registered() ) {
$site = $fs->get_site();
if ( $plugin_id != $fs->get_id() ) {
if ( $fs->is_addon_activated( $plugin_id ) ) {
$fs_addon = Freemius::get_instance_by_id( $plugin_id );
$addon_site = $fs_addon->get_site();
if ( is_object( $addon_site ) ) {
$site = $addon_site;
}
}
}
$context_params = array_merge( $context_params, FS_Security::instance()->get_context_params(
$site,
$timestamp,
'checkout'
) );
} else {
$current_user = Freemius::_get_current_wp_user();
// Add site and user info to the request, this information
// is NOT being stored unless the user complete the purchase
// and agrees to the TOS.
$context_params = array_merge( $context_params, array(
'user_firstname' => $current_user->user_firstname,
'user_lastname' => $current_user->user_lastname,
'user_email' => $current_user->user_email,
'home_url' => home_url(),
) );
$fs_user = Freemius::_get_user_by_email( $current_user->user_email );
if ( is_object( $fs_user ) && $fs_user->is_verified() ) {
$context_params = array_merge( $context_params, FS_Security::instance()->get_context_params(
$fs_user,
$timestamp,
'checkout'
) );
}
}
if ( $fs->is_payments_sandbox() ) {
// Append plugin secure token for sandbox mode authentication.
$context_params['sandbox'] = FS_Security::instance()->get_secure_token(
$fs->get_plugin(),
$timestamp,
'checkout'
);
/**
* @since 1.1.7.3 Add security timestamp for sandbox even for anonymous user.
*/
if ( empty( $context_params['s_ctx_ts'] ) ) {
$context_params['s_ctx_ts'] = $timestamp;
}
}
$return_url = $fs->_get_sync_license_url( $plugin_id );
$can_user_install = (
( $fs->is_plugin() && current_user_can( 'install_plugins' ) ) ||
( $fs->is_theme() && current_user_can( 'install_themes' ) )
);
$query_params = array_merge( $context_params, $_GET, array(
// Current plugin version.
'plugin_version' => $fs->get_plugin_version(),
'sdk_version' => WP_FS__SDK_VERSION,
'is_premium' => $is_premium ? 'true' : 'false',
'can_install' => $can_user_install ? 'true' : 'false',
'return_url' => $return_url,
) );
$xdebug_session = fs_request_get( 'XDEBUG_SESSION' );
if ( false !== $xdebug_session ) {
$query_params['XDEBUG_SESSION'] = $xdebug_session;
}
$view_params = array(
'id' => $VARS['id'],
'page' => strtolower( $fs->get_text_inline( 'Checkout', 'checkout' ) ) . ' ' . $fs->get_text_inline( 'PCI compliant', 'pci-compliant' ),
);
fs_require_once_template('secure-https-header.php', $view_params);
?>
<div id="fs_checkout" class="wrap fs-section fs-full-size-wrapper">
<div id="fs_frame"></div>
<script type="text/javascript">
// http://stackoverflow.com/questions/4583703/jquery-post-request-not-ajax
jQuery(function ($) {
$.extend({
form: function (url, data, method) {
if (method == null) method = 'POST';
if (data == null) data = {};
var form = $('<form>').attr({
method: method,
action: url
}).css({
display: 'none'
});
var addData = function (name, data) {
if ($.isArray(data)) {
for (var i = 0; i < data.length; i++) {
var value = data[i];
addData(name + '[]', value);
}
} else if (typeof data === 'object') {
for (var key in data) {
if (data.hasOwnProperty(key)) {
addData(name + '[' + key + ']', data[key]);
}
}
} else if (data != null) {
form.append($('<input>').attr({
type : 'hidden',
name : String(name),
value: String(data)
}));
}
};
for (var key in data) {
if (data.hasOwnProperty(key)) {
addData(key, data[key]);
}
}
return form.appendTo('body');
}
});
});
(function ($) {
$(function () {
var
// Keep track of the i-frame height.
frame_height = 800,
base_url = '<?php echo FS_CHECKOUT__ADDRESS ?>',
// Pass the parent page URL into the i-frame in a meaningful way (this URL could be
// passed via query string or hard coded into the child page, it depends on your needs).
src = base_url + '/?<?php echo http_build_query( $query_params ) ?>#' + encodeURIComponent(document.location.href),
// Append the i-frame into the DOM.
frame = $('<i' + 'frame " src="' + src + '" width="100%" height="' + frame_height + 'px" scrolling="no" frameborder="0" style="background: transparent; width: 1px; min-width: 100%;"><\/i' + 'frame>')
.appendTo('#fs_frame');
FS.PostMessage.init(base_url, [frame[0]]);
FS.PostMessage.receiveOnce('height', function (data) {
var h = data.height;
if (!isNaN(h) && h > 0 && h != frame_height) {
frame_height = h;
frame.height(frame_height + 'px');
FS.PostMessage.postScroll(frame[0]);
}
});
FS.PostMessage.receiveOnce('install', function (data) {
var requestData = {
user_id : data.user.id,
user_secret_key : data.user.secret_key,
user_public_key : data.user.public_key,
install_id : data.install.id,
install_secret_key: data.install.secret_key,
install_public_key: data.install.public_key
};
if (true === data.auto_install)
requestData.auto_install = true;
// Post data to activation URL.
$.form('<?php echo fs_nonce_url( $fs->_get_admin_page_url( 'account', array(
'fs_action' => $fs->get_unique_affix() . '_activate_new',
'plugin_id' => $plugin_id
) ), $fs->get_unique_affix() . '_activate_new' ) ?>', requestData).submit();
});
FS.PostMessage.receiveOnce('pending_activation', function (data) {
var requestData = {
user_email: data.user_email
};
if (true === data.auto_install)
requestData.auto_install = true;
$.form('<?php echo fs_nonce_url( $fs->_get_admin_page_url( 'account', array(
'fs_action' => $fs->get_unique_affix() . '_activate_new',
'plugin_id' => $plugin_id,
'pending_activation' => true,
) ), $fs->get_unique_affix() . '_activate_new' ) ?>', requestData).submit();
});
FS.PostMessage.receiveOnce('get_context', function () {
console.debug('receiveOnce', 'get_context');
// If the user didn't connect his account with Freemius,
// once he accepts the Terms of Service and Privacy Policy,
// and then click the purchase button, the context information
// of the user will be shared with Freemius in order to complete the
// purchase workflow and activate the license for the right user.
<?php $install_data = array_merge( $fs->get_opt_in_params(),
array(
'activation_url' => fs_nonce_url( $fs->_get_admin_page_url( '',
array(
'fs_action' => $fs->get_unique_affix() . '_activate_new',
'plugin_id' => $plugin_id,
) ),
$fs->get_unique_affix() . '_activate_new' )
) ) ?>
FS.PostMessage.post('context', <?php echo json_encode( $install_data ) ?>, frame[0]);
});
FS.PostMessage.receiveOnce('purchaseCompleted', <?php echo $fs->apply_filters('checkout/purchaseCompleted', 'function (data) {
console.log("checkout", "purchaseCompleted");
}') ?>);
FS.PostMessage.receiveOnce('get_dimensions', function (data) {
console.debug('receiveOnce', 'get_dimensions');
FS.PostMessage.post('dimensions', {
height : $(document.body).height(),
scrollTop: $(document).scrollTop()
}, frame[0]);
});
var updateHeight = function () {
frame.css('min-height', $(document.body).height() + 'px');
};
$(document).ready(updateHeight);
$(window).resize(updateHeight);
});
})(jQuery);
</script>
</div>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,128 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.0.3
*/
/**
* Note for WordPress.org Theme/Plugin reviewer:
* Freemius is an SDK for plugin and theme developers. Since the core
* of the SDK is relevant both for plugins and themes, for obvious reasons,
* we only develop and maintain one code base.
*
* This code (and page) will not run for wp.org themes (only plugins).
*
* In addition, this page loads an i-frame. We intentionally named it 'frame'
* so it will pass the "Theme Check" that is looking for the string "i" . "frame".
*
* UPDATE:
* After ongoing conversations with the WordPress.org TRT we received
* an official approval for including i-frames in the theme's WP Admin setting's
* page tab (the SDK will never add any i-frames on the sitefront). i-frames
* were never against the guidelines, but we wanted to get the team's blessings
* before we move forward. For the record, I got the final approval from
* Ulrich Pogson (@grapplerulrich), a team lead at the TRT during WordCamp
* Europe 2017 (June 16th, 2017).
*
* If you have any questions or need clarifications, please don't hesitate
* pinging me on slack, my username is @svovaf.
*
* @author Vova Feldman (@svovaf)
* @since 1.2.2
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'json2' );
fs_enqueue_local_script( 'postmessage', 'nojquery.ba-postmessage.min.js' );
fs_enqueue_local_script( 'fs-postmessage', 'postmessage.js' );
fs_enqueue_local_style( 'fs_checkout', '/admin/common.css' );
/**
* @var array $VARS
* @var Freemius $fs
*/
$fs = freemius( $VARS['id'] );
$slug = $fs->get_slug();
$context_params = array(
'plugin_id' => $fs->get_id(),
'plugin_public_key' => $fs->get_public_key(),
'plugin_version' => $fs->get_plugin_version(),
);
// Get site context secure params.
if ( $fs->is_registered() ) {
$context_params = array_merge( $context_params, FS_Security::instance()->get_context_params(
$fs->get_site(),
time(),
'contact'
) );
}
$query_params = array_merge( $_GET, array_merge( $context_params, array(
'plugin_version' => $fs->get_plugin_version(),
'wp_login_url' => wp_login_url(),
'site_url' => get_site_url(),
// 'wp_admin_css' => get_bloginfo('wpurl') . "/wp-admin/load-styles.php?c=1&load=buttons,wp-admin,dashicons",
) ) );
$view_params = array(
'id' => $VARS['id'],
'page' => strtolower( $fs->get_text_inline( 'Contact', 'contact' ) ),
);
fs_require_once_template('secure-https-header.php', $view_params);
$has_tabs = $fs->_add_tabs_before_content();
if ( $has_tabs ) {
$query_params['tabs'] = 'true';
}
?>
<div id="fs_contact" class="wrap fs-section fs-full-size-wrapper">
<div id="fs_frame"></div>
<script type="text/javascript">
(function ($) {
$(function () {
var
// Keep track of the i-frame height.
frame_height = 800,
base_url = '<?php echo WP_FS__ADDRESS ?>',
src = base_url + '/contact/?<?php echo http_build_query($query_params) ?>#' + encodeURIComponent(document.location.href),
// Append the i-frame into the DOM.
frame = $('<i' + 'frame " src="' + src + '" width="100%" height="' + frame_height + 'px" scrolling="no" frameborder="0" style="background: transparent; width: 1px; min-width: 100%;"><\/i' + 'frame>')
.appendTo('#fs_frame');
FS.PostMessage.init(base_url);
FS.PostMessage.receive('height', function (data) {
var h = data.height;
if (!isNaN(h) && h > 0 && h != frame_height) {
frame_height = h;
$('#fs_frame i' + 'frame').height(frame_height + 'px');
}
});
});
})(jQuery);
</script>
</div>
<?php
if ( $has_tabs ) {
$fs->_add_tabs_after_content();
}
$params = array(
'page' => 'contact',
'module_id' => $fs->get_id(),
'module_type' => $fs->get_module_type(),
'module_slug' => $slug,
'module_version' => $fs->get_plugin_version(),
);
fs_require_template( 'powered-by.php', $params );

View File

@ -0,0 +1,765 @@
<?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.1
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
global $fs_active_plugins;
$fs_options = FS_Options::instance( WP_FS__ACCOUNTS_OPTION_NAME, true );
$off_text = fs_text_x_inline( 'Off', 'as turned off' );
$on_text = fs_text_x_inline( 'On', 'as turned on' );
?>
<h1><?php echo fs_text_inline( 'Freemius Debug' ) . ' - ' . fs_text_inline( 'SDK' ) . ' v.' . $fs_active_plugins->newest->version ?></h1>
<div>
<!-- Debugging Switch -->
<?php //$debug_mode = get_option( 'fs_debug_mode', null ) ?>
<span class="fs-switch-label"><?php fs_esc_html_echo_x_inline( 'Debugging', 'as code debugging' ) ?></span>
<div class="fs-switch fs-round <?php echo WP_FS__DEBUG_SDK ? 'fs-on' : 'fs-off' ?>">
<div class="fs-toggle"></div>
</div>
<script type="text/javascript">
(function ($) {
$(document).ready(function () {
// Switch toggle
$( '.fs-switch' ).click( function () {
$( this )
.toggleClass( 'fs-on' )
.toggleClass( 'fs-off' );
$.post( ajaxurl, {
action: 'fs_toggle_debug_mode',
// As such we don't need to use `wp_json_encode` method but using it to follow wp.org guideline.
_wpnonce : <?php echo wp_json_encode( wp_create_nonce( 'fs_toggle_debug_mode' ) ); ?>,
is_on : ($(this).hasClass( 'fs-on' ) ? 1 : 0)
}, function ( response ) {
if ( 1 == response ) {
// Refresh page on success.
location.reload();
}
});
});
});
}(jQuery));
</script>
</div>
<h2><?php fs_esc_html_echo_inline( 'Actions', 'actions' ) ?></h2>
<table>
<tbody>
<tr>
<td>
<!-- Delete All Accounts -->
<form action="" method="POST">
<input type="hidden" name="fs_action" value="restart_freemius">
<?php wp_nonce_field( 'restart_freemius' ) ?>
<button class="button button-primary"
onclick="if (confirm('<?php fs_esc_attr_echo_inline( 'Are you sure you want to delete all Freemius data?', 'delete-all-confirm' ) ?>')) this.parentNode.submit(); return false;"><?php fs_esc_html_echo_inline( 'Delete All Accounts' ) ?></button>
</form>
</td>
<td>
<!-- Clear API Cache -->
<form action="" method="POST">
<input type="hidden" name="fs_clear_api_cache" value="true">
<button class="button button-primary"><?php fs_esc_html_echo_inline( 'Clear API Cache' ) ?></button>
</form>
</td>
<td>
<!-- Clear Updates Transients -->
<form action="" method="POST">
<input type="hidden" name="fs_action" value="clear_updates_data">
<?php wp_nonce_field( 'clear_updates_data' ) ?>
<button class="button"><?php fs_esc_html_echo_inline( 'Clear Updates Transients' ) ?></button>
</form>
</td>
<td>
<!-- Sync Data with Server -->
<form action="" method="POST">
<input type="hidden" name="background_sync" value="true">
<button class="button button-primary"><?php fs_esc_html_echo_inline( 'Sync Data From Server' ) ?></button>
</form>
</td>
<?php if ( fs_is_network_admin() && true !== $fs_options->get_option( 'ms_migration_complete', false, true ) ) : ?>
<td>
<!-- Migrate Options to Network -->
<form action="" method="POST">
<input type="hidden" name="fs_action" value="migrate_options_to_network">
<?php wp_nonce_field( 'migrate_options_to_network' ) ?>
<button class="button button-primary"><?php fs_esc_html_echo_inline( 'Migrate Options to Network' ) ?></button>
</form>
</td>
<?php endif ?>
<td>
<button id="fs_load_db_option" class="button"><?php fs_esc_html_echo_inline( 'Load DB Option' ) ?></button>
</td>
<td>
<button id="fs_set_db_option" class="button"><?php fs_esc_html_echo_inline( 'Set DB Option' ) ?></button>
</td>
</tr>
</tbody>
</table>
<script type="text/javascript">
(function ($) {
$('#fs_load_db_option').click(function () {
var optionName = prompt('Please enter the option name:');
if (optionName) {
$.post(ajaxurl, {
action : 'fs_get_db_option',
// As such we don't need to use `wp_json_encode` method but using it to follow wp.org guideline.
_wpnonce : <?php echo wp_json_encode( wp_create_nonce( 'fs_get_db_option' ) ); ?>,
option_name: optionName
}, function (response) {
if (response.data.value)
prompt('The option value is:', response.data.value);
else
alert('Oops... Option does not exist in the DB.');
});
}
});
$('#fs_set_db_option').click(function () {
var optionName = prompt('Please enter the option name:');
if (optionName) {
var optionValue = prompt('Please enter the option value:');
if (optionValue) {
$.post(ajaxurl, {
action : 'fs_set_db_option',
// As such we don't need to use `wp_json_encode` method but using it to follow wp.org guideline.
_wpnonce : <?php echo wp_json_encode( wp_create_nonce( 'fs_set_db_option' ) ); ?>,
option_name : optionName,
option_value: optionValue
}, function () {
alert('Option was successfully set.');
});
}
}
});
})(jQuery);
</script>
<?php
if ( ! defined( 'FS_API__ADDRESS' ) ) {
define( 'FS_API__ADDRESS', '://api.freemius.com' );
}
if ( ! defined( 'FS_API__SANDBOX_ADDRESS' ) ) {
define( 'FS_API__SANDBOX_ADDRESS', '://sandbox-api.freemius.com' );
}
$defines = array(
array(
'key' => 'WP_FS__REMOTE_ADDR',
'val' => WP_FS__REMOTE_ADDR,
),
array(
'key' => 'WP_FS__ADDRESS_PRODUCTION',
'val' => WP_FS__ADDRESS_PRODUCTION,
),
array(
'key' => 'FS_API__ADDRESS',
'val' => FS_API__ADDRESS,
),
array(
'key' => 'FS_API__SANDBOX_ADDRESS',
'val' => FS_API__SANDBOX_ADDRESS,
),
array(
'key' => 'WP_FS__DIR',
'val' => WP_FS__DIR,
),
)
?>
<br>
<table class="widefat">
<thead>
<tr>
<th><?php fs_esc_html_echo_inline( 'Key', 'key' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Value', 'value' ) ?></th>
</tr>
</thead>
<tbody>
<?php $alternate = false;
foreach ( $defines as $p ) : ?>
<tr<?php if ( $alternate ) {
echo ' class="alternate"';
} ?>>
<td><?php echo $p['key'] ?></td>
<td><?php echo $p['val'] ?></td>
</tr>
<?php $alternate = ! $alternate ?>
<?php endforeach ?>
</tbody>
</table>
<h2><?php fs_esc_html_echo_x_inline( 'SDK Versions', 'as software development kit versions', 'sdk-versions' ) ?></h2>
<table id="fs_sdks" class="widefat">
<thead>
<tr>
<th><?php fs_esc_html_echo_x_inline( 'Version', 'product version' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'SDK Path' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Module Path' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Is Active' ) ?></th>
</tr>
</thead>
<tbody>
<?php foreach ( $fs_active_plugins->plugins as $sdk_path => $data ) : ?>
<?php $is_active = ( WP_FS__SDK_VERSION == $data->version ) ?>
<tr<?php if ( $is_active ) {
echo ' style="background: #E6FFE6; font-weight: bold"';
} ?>>
<td><?php echo $data->version ?></td>
<td><?php echo $sdk_path ?></td>
<td><?php echo $data->plugin_path ?></td>
<td><?php echo ( $is_active ) ? 'Active' : 'Inactive' ?></td>
</tr>
<?php endforeach ?>
</tbody>
</table>
<?php
$module_types = array(
WP_FS__MODULE_TYPE_PLUGIN,
WP_FS__MODULE_TYPE_THEME
);
?>
<?php foreach ( $module_types as $module_type ) : ?>
<?php $modules = fs_get_entities( $fs_options->get_option( $module_type . 's' ), FS_Plugin::get_class_name() ) ?>
<?php if ( is_array( $modules ) && count( $modules ) > 0 ) : ?>
<h2><?php echo esc_html( ( WP_FS__MODULE_TYPE_PLUGIN == $module_type ) ? fs_text_inline( 'Plugins', 'plugins' ) : fs_text_inline( 'Themes', 'themes' ) ) ?></h2>
<table id="fs_<?php echo $module_type ?>" class="widefat">
<thead>
<tr>
<th><?php fs_esc_html_echo_inline( 'ID', 'id' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Slug' ) ?></th>
<th><?php fs_esc_html_echo_x_inline( 'Version', 'product version' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Title' ) ?></th>
<th><?php fs_esc_html_echo_x_inline( 'API', 'as application program interface' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Freemius State' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Module Path' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Public Key' ) ?></th>
<?php if ( is_multisite() ) : ?>
<th><?php fs_esc_html_echo_inline( 'Network Blog' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Network User' ) ?></th>
<?php endif ?>
<th><?php fs_esc_html_echo_inline( 'Actions' ) ?></th>
</tr>
</thead>
<tbody>
<?php foreach ( $modules as $slug => $data ) : ?>
<?php
if ( WP_FS__MODULE_TYPE_THEME !== $module_type ) {
$is_active = is_plugin_active( $data->file );
} else {
$current_theme = wp_get_theme();
$is_active = ( $current_theme->stylesheet === $data->file );
if ( ! $is_active && is_child_theme() ) {
$parent_theme = $current_theme->parent();
$is_active = ( ( $parent_theme instanceof WP_Theme ) && $parent_theme->stylesheet === $data->file );
}
}
?>
<?php $fs = $is_active ? freemius( $data->id ) : null ?>
<tr<?php if ( $is_active ) {
if ( $fs->has_api_connectivity() && $fs->is_on() ) {
echo ' style="background: #E6FFE6; font-weight: bold"';
} else {
echo ' style="background: #ffd0d0; font-weight: bold"';
}
} ?>>
<td><?php echo $data->id ?></td>
<td><?php echo $slug ?></td>
<td><?php echo $data->version ?></td>
<td><?php echo $data->title ?></td>
<td<?php if ( $is_active && ! $fs->has_api_connectivity() ) {
echo ' style="color: red; text-transform: uppercase;"';
} ?>><?php if ( $is_active ) {
echo esc_html( $fs->has_api_connectivity() ?
fs_text_x_inline( 'Connected', 'as connection was successful' ) :
fs_text_x_inline( 'Blocked', 'as connection blocked' )
);
} ?></td>
<td<?php if ( $is_active && ! $fs->is_on() ) {
echo ' style="color: red; text-transform: uppercase;"';
} ?>><?php if ( $is_active ) {
echo esc_html( $fs->is_on() ?
$on_text :
$off_text
);
} ?></td>
<td><?php echo $data->file ?></td>
<td><?php echo $data->public_key ?></td>
<?php if ( is_multisite() ) : ?>
<?php
$network_blog_id = null;
$network_user = null;
if ( is_object( $fs ) ) {
$network_blog_id = $fs->get_network_install_blog_id();
$network_user = $fs->get_network_user();
}
?>
<td><?php echo is_numeric( $network_blog_id ) ? $network_blog_id : '' ?></td>
<td><?php if ( is_object( $network_user ) ) {
echo $network_user->email;
} ?></td>
<?php endif ?>
<td>
<?php if ( $is_active ) : ?>
<?php if ( $fs->has_trial_plan() ) : ?>
<form action="" method="POST">
<input type="hidden" name="fs_action" value="simulate_trial">
<input type="hidden" name="module_id" value="<?php echo $fs->get_id() ?>">
<?php wp_nonce_field( 'simulate_trial' ) ?>
<button type="submit" class="button button-primary simulate-trial"><?php fs_esc_html_echo_inline( 'Simulate Trial Promotion' ) ?></button>
</form>
<?php endif ?>
<?php if ( $fs->is_registered() ) : ?>
<a class="button" href="<?php echo $fs->get_account_url() ?>"><?php fs_esc_html_echo_inline( 'Account', 'account' ) ?></a>
<?php endif ?>
<?php if ( fs_is_network_admin() && ! $fs->is_network_upgrade_mode() ) : ?>
<form action="" method="POST">
<input type="hidden" name="fs_action" value="simulate_network_upgrade">
<input type="hidden" name="module_id" value="<?php echo $fs->get_id() ?>">
<?php wp_nonce_field( 'simulate_network_upgrade' ) ?>
<button type="submit" class="button button-small"><?php fs_esc_html_echo_inline( 'Simulate Network Upgrade' ) ?></button>
</form>
<?php endif ?>
<?php endif ?>
</td>
</tr>
<?php endforeach ?>
</tbody>
</table>
<?php endif ?>
<?php endforeach ?>
<?php foreach ( $module_types as $module_type ) : ?>
<?php
/**
* @var array $VARS
* @var array[string]FS_Site|array[string]FS_Site[] $sites_map
*/
$sites_map = $VARS[ $module_type . '_sites' ];
$is_multisite = is_multisite();
$all_plans = false;
?>
<?php if ( is_array( $sites_map ) && count( $sites_map ) > 0 ) : ?>
<h2><?php echo esc_html( sprintf(
/* translators: %s: 'plugin' or 'theme' */
fs_text_inline( '%s Installs', 'module-installs' ),
( WP_FS__MODULE_TYPE_PLUGIN === $module_type ? fs_text_inline( 'Plugin', 'plugin' ) : fs_text_inline( 'Theme', 'theme' ) )
) ) ?> / <?php fs_esc_html_echo_x_inline( 'Sites', 'like websites', 'sites' ) ?></h2>
<table id="fs_<?php echo $module_type ?>_installs" class="widefat">
<thead>
<tr>
<th><?php fs_esc_html_echo_inline( 'ID', 'id' ) ?></th>
<?php if ( $is_multisite ) : ?>
<th><?php fs_esc_html_echo_inline( 'Blog ID' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Address' ) ?></th>
<?php endif ?>
<th><?php fs_esc_html_echo_inline( 'Slug' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'User ID' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'License ID' ) ?></th>
<th><?php fs_esc_html_echo_x_inline( 'Plan', 'as product pricing plan', 'plan' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Public Key' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Secret Key' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Actions' ) ?></th>
</tr>
</thead>
<tbody>
<?php foreach ( $sites_map as $slug => $sites ) : ?>
<?php if ( ! is_array( $sites ) ) {
$sites = array( $sites );
} ?>
<?php foreach ( $sites as $site ) : ?>
<tr>
<td><?php echo $site->id ?></td>
<?php if ( $is_multisite ) : ?>
<td><?php echo $site->blog_id ?></td>
<td><?php echo fs_strip_url_protocol( $site->url ) ?></td>
<?php endif ?>
<td><?php echo $slug ?></td>
<td><?php echo $site->user_id ?></td>
<td><?php echo !empty($site->license_id) ? $site->license_id : '' ?></td>
<td><?php
$plan_name = '';
if ( FS_Plugin_Plan::is_valid_id( $site->plan_id ) ) {
if ( false === $all_plans ) {
$option_name = 'plans';
if ( WP_FS__MODULE_TYPE_PLUGIN !== $module_type ) {
$option_name = $module_type . '_' . $option_name;
}
$all_plans = fs_get_entities( $fs_options->get_option( $option_name, array() ), FS_Plugin_Plan::get_class_name() );
}
foreach ( $all_plans[ $slug ] as $plan ) {
$plan_id = Freemius::_decrypt( $plan->id );
if ( $site->plan_id == $plan_id ) {
$plan_name = Freemius::_decrypt( $plan->name );
break;
}
}
}
echo $plan_name;
?></td>
<td><?php echo $site->public_key ?></td>
<td><?php
$plugin_storage = FS_Storage::instance( $module_type, $slug );
echo $plugin_storage->is_whitelabeled ?
FS_Plugin_License::mask_secret_key_for_html( $site->secret_key ) :
esc_html( $site->secret_key );
?></td>
<td>
<form action="" method="POST">
<input type="hidden" name="fs_action" value="delete_install">
<?php wp_nonce_field( 'delete_install' ) ?>
<input type="hidden" name="module_id" value="<?php echo $site->plugin_id ?>">
<?php if ( $is_multisite ) : ?>
<input type="hidden" name="blog_id" value="<?php echo $site->blog_id ?>">
<?php endif ?>
<input type="hidden" name="module_type" value="<?php echo $module_type ?>">
<input type="hidden" name="slug" value="<?php echo $slug ?>">
<button type="submit" class="button"><?php fs_esc_html_echo_x_inline( 'Delete', 'verb', 'delete' ) ?></button>
</form>
</td>
</tr>
<?php endforeach ?>
<?php endforeach ?>
</tbody>
</table>
<?php endif ?>
<?php endforeach ?>
<?php
$addons = $VARS['addons'];
?>
<?php foreach ( $addons as $plugin_id => $plugin_addons ) : ?>
<h2><?php echo esc_html( sprintf( fs_text_inline( 'Add Ons of module %s', 'addons-of-x' ), $plugin_id ) ) ?></h2>
<table id="fs_addons" class="widefat">
<thead>
<tr>
<th><?php fs_esc_html_echo_inline( 'ID', 'id' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Title' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Slug' ) ?></th>
<th><?php fs_esc_html_echo_x_inline( 'Version', 'product version' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Public Key' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Secret Key' ) ?></th>
</tr>
</thead>
<tbody>
<?php
/**
* @var FS_Plugin[] $plugin_addons
*/
foreach ( $plugin_addons as $addon ) : ?>
<tr>
<td><?php echo $addon->id ?></td>
<td><?php echo $addon->title ?></td>
<td><?php echo $addon->slug ?></td>
<td><?php echo $addon->version ?></td>
<td><?php echo $addon->public_key ?></td>
<td><?php echo esc_html( $addon->secret_key ) ?></td>
</tr>
<?php endforeach ?>
</tbody>
</table>
<?php endforeach ?>
<?php
/**
* @var FS_User[] $users
*/
$users = $VARS['users'];
$users_with_developer_license_by_id = array();
foreach ( $module_types as $module_type ) {
/**
* @var FS_Plugin_License[] $licenses
*/
$licenses = $VARS[ $module_type . '_licenses' ];
foreach ( $licenses as $license ) {
if ( $license->is_whitelabeled ) {
$users_with_developer_license_by_id[ $license->user_id ] = true;
}
}
}
?>
<?php if ( is_array( $users ) && 0 < count( $users ) ) : ?>
<h2><?php fs_esc_html_echo_inline( 'Users' ) ?></h2>
<table id="fs_users" class="widefat">
<thead>
<tr>
<th><?php fs_esc_html_echo_inline( 'ID', 'id' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Name' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Email' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Verified' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Public Key' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Secret Key' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Actions' ) ?></th>
</tr>
</thead>
<tbody>
<?php foreach ( $users as $user_id => $user ) : ?>
<?php $has_developer_license = isset( $users_with_developer_license_by_id[ $user_id ] ) ?>
<tr>
<td><?php echo $user->id ?></td>
<td><?php echo $has_developer_license ? '' : $user->get_name() ?></td>
<td>
<?php if ( ! $has_developer_license ) : ?>
<a href="mailto:<?php echo esc_attr( $user->email ) ?>"><?php echo $user->email ?></a>
<?php endif ?>
</td>
<td><?php echo $has_developer_license ? '' : json_encode( $user->is_verified ) ?></td>
<td><?php echo $user->public_key ?></td>
<td><?php echo $has_developer_license ? FS_Plugin_License::mask_secret_key_for_html($user->secret_key) : esc_html( $user->secret_key ) ?></td>
<td>
<?php if ( ! $has_developer_license ) : ?>
<form action="" method="POST">
<input type="hidden" name="fs_action" value="delete_user">
<?php wp_nonce_field( 'delete_user' ) ?>
<input type="hidden" name="user_id" value="<?php echo $user->id ?>">
<button type="submit" class="button"><?php fs_esc_html_echo_x_inline( 'Delete', 'verb', 'delete' ) ?></button>
</form>
<?php endif ?>
</td>
</tr>
<?php endforeach ?>
</tbody>
</table>
<?php endif ?>
<?php foreach ( $module_types as $module_type ) : ?>
<?php
/**
* @var FS_Plugin_License[] $licenses
*/
$licenses = $VARS[ $module_type . '_licenses' ] ?>
<?php if ( is_array( $licenses ) && count( $licenses ) > 0 ) : ?>
<h2><?php echo esc_html( sprintf( fs_text_inline( '%s Licenses', 'module-licenses' ), ( WP_FS__MODULE_TYPE_PLUGIN === $module_type ? fs_text_inline( 'Plugin', 'plugin' ) : fs_text_inline( 'Theme', 'theme' ) ) ) ) ?></h2>
<table id="fs_<?php echo $module_type ?>_licenses" class="widefat">
<thead>
<tr>
<th><?php fs_esc_html_echo_inline( 'ID', 'id' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Plugin ID' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'User ID' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Plan ID' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Quota' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Activated' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Blocking' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Type' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'License Key' ) ?></th>
<th><?php fs_esc_html_echo_x_inline( 'Expiration', 'as expiration date' ) ?></th>
</tr>
</thead>
<tbody>
<?php foreach ( $licenses as $license ) : ?>
<tr>
<td><?php echo $license->id ?></td>
<td><?php echo $license->plugin_id ?></td>
<td><?php echo $license->user_id ?></td>
<td><?php echo $license->plan_id ?></td>
<td><?php echo $license->is_unlimited() ? 'Unlimited' : ( $license->is_single_site() ? 'Single Site' : $license->quota ) ?></td>
<td><?php echo $license->activated ?></td>
<td><?php echo $license->is_block_features ? 'Blocking' : 'Flexible' ?></td>
<td><?php echo $license->is_whitelabeled ? 'Whitelabeled' : 'Normal' ?></td>
<td><?php
echo $license->is_whitelabeled ?
$license->get_html_escaped_masked_secret_key() :
esc_html( $license->secret_key );
?></td>
<td><?php echo $license->expiration ?></td>
</tr>
<?php endforeach ?>
</tbody>
</table>
<?php endif ?>
<?php endforeach ?>
<?php if ( FS_Logger::is_storage_logging_on() ) : ?>
<h2><?php fs_esc_html_echo_inline( 'Debug Log', 'debug-log' ) ?></h2>
<div id="fs_debug_filters">
<select name="type">
<option value="" selected="selected"><?php fs_esc_html_echo_inline( 'All Types', 'all-types' ) ?></option>
<option value="warn_error">Warnings & Errors</option>
<option value="error">Errors</option>
<option value="warn">Warnings</option>
<option value="info">Info</option>
</select>
<select name="request_type">
<option value="" selected="selected"><?php fs_esc_html_echo_inline( 'All Requests', 'all-requests' ) ?></option>
<option value="call">Sync</option>
<option value="ajax">AJAX</option>
<option value="cron">WP Cron</option>
</select>
<input name="file" type="text" placeholder="<?php fs_esc_attr_echo_inline( 'File' ) ?>"/>
<input name="function" type="text" placeholder="<?php fs_esc_attr_echo_inline( 'Function' ) ?>"/>
<input name="process_id" type="text" placeholder="<?php fs_esc_attr_echo_inline( 'Process ID' ) ?>"/>
<input name="logger" type="text" placeholder="<?php fs_esc_attr_echo_inline( 'Logger' ) ?>"/>
<input name="message" type="text" placeholder="<?php fs_esc_attr_echo_inline( 'Message' ) ?>"/>
<div style="margin: 10px 0">
<button id="fs_filter" class="button" style="float: left"><i class="dashicons dashicons-filter"></i> <?php fs_esc_html_echo_inline( 'Filter', 'filter' ) ?>
</button>
<form action="" method="POST" style="float: left; margin-left: 10px;">
<input type="hidden" name="fs_action" value="download_logs">
<?php wp_nonce_field( 'download_logs' ) ?>
<div class="fs-filters"></div>
<button id="fs_download" class="button" type="submit"><i
class="dashicons dashicons-download"></i> <?php fs_esc_html_echo_inline( 'Download' ) ?></button>
</form>
<div style="clear: both"></div>
</div>
</div>
<div id="fs_log_book" style="height: 300px; overflow: auto;">
<table class="widefat">
<thead>
<tr>
<th>#</th>
<th><?php fs_esc_html_echo_inline( 'Type' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'ID', 'id' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Function' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Message' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'File' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Timestamp' ) ?></th>
</tr>
</thead>
<tbody>
<tr style="display: none">
<td>{$log.log_order}.</td>
<td class="fs-col--type">{$log.type}</td>
<td class="fs-col--logger">{$log.logger}</td>
<td class="fs-col--function">{$log.function}</td>
<td class="fs-col--message">
<a href="#" onclick="jQuery(this).parent().find('div').toggle(); return false;">
<nobr>{$log.message_short}</nobr>
</a>
<div style="display: none;">{$log.message}</div>
</td>
<td class="fs-col--file">{$log.file}:{$log.line}</td>
<td class="fs-col--timestamp">{$log.created}</td>
</tr>
</tbody>
</table>
</div>
<script type="text/javascript">
jQuery(document).ready(function ($) {
var filtersChanged = false,
offset = 0,
limit = 200,
prevFiltersSignature = null;
var getFilters = function () {
var filters = {},
signature = '';
$('#fs_debug_filters').find('select, input').each(function (i, e) {
var $element = $(e);
if ('hidden' === $element.attr('type'))
return;
var val = $element.val();
if ('' !== val.trim()) {
var name = $(e).attr('name');
filters[name] = val;
signature += name + '=' + val + '~';
}
});
if (signature != prevFiltersSignature) {
filtersChanged = true;
prevFiltersSignature = signature;
} else {
filtersChanged = false;
}
return filters;
};
$('#fs_download').parent().submit(function () {
var filters = getFilters(),
hiddenFields = '';
for (var f in filters) {
if (filters.hasOwnProperty(f)) {
hiddenFields += '<input type="hidden" name="filters[' + f + ']" value="' + filters[f] + '" />';
}
}
$(this).find('.fs-filters').html(hiddenFields);
});
var loadLogs = function () {
var $tbody = $('#fs_log_book tbody'),
template = $tbody.find('tr:first-child').html(),
filters = getFilters();
if (!filtersChanged) {
offset += limit;
} else {
// Cleanup table for new filter (only keep template row).
$tbody.find('tr').each(function (i, e) {
if (0 == i)
return;
$(e).remove();
});
offset = 0;
}
$.post(ajaxurl, {
action : 'fs_get_debug_log',
// As such we don't need to use `wp_json_encode` method but using it to follow wp.org guideline.
_wpnonce : <?php echo wp_json_encode( wp_create_nonce( 'fs_get_debug_log' ) ); ?>,
filters: filters,
offset : offset,
limit : limit
}, function (response) {
for (var i = 0; i < response.data.length; i++) {
var templateCopy = template;
response.data[i].message_short = (response.data[i].message.length > 32) ?
response.data[i].message.substr(0, 32) + '...' :
response.data[i].message;
for (var p in response.data[i]) {
if (response.data[i].hasOwnProperty(p)) {
templateCopy = templateCopy.replace('{$log.' + p + '}', response.data[i][p]);
}
}
$tbody.append('<tr' + (i % 2 ? ' class="alternate"' : '') + '>' + templateCopy + '</tr>');
}
});
};
$('#fs_filter').click(function () {
loadLogs();
return false;
});
loadLogs();
});
</script>
<?php endif ?>

View File

@ -0,0 +1,155 @@
<?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 ( class_exists( 'Freemius_Api_WordPress' ) ) {
$logger = Freemius_Api_WordPress::GetLogger();
} else {
$logger = array();
}
$counters = array(
'GET' => 0,
'POST' => 0,
'PUT' => 0,
'DELETE' => 0
);
$show_body = false;
foreach ( $logger as $log ) {
$counters[ $log['method'] ] ++;
if ( ! is_null( $log['body'] ) ) {
$show_body = true;
}
}
$pretty_print = $show_body && defined( 'JSON_PRETTY_PRINT' ) && version_compare( phpversion(), '5.3', '>=' );
/**
* This template is used for debugging, therefore, when possible
* we'd like to prettify the output of a JSON encoded variable.
* This will only be executed when $pretty_print is `true`, and
* the var is `true` only for PHP 5.3 and higher. Due to the
* limitations of the current Theme Check, it throws an error
* that using the "options" parameter (the 2nd param) is not
* supported in PHP 5.2 and lower. Thus, we added this alias
* variable to work around that false-positive.
*
* @author Vova Feldman (@svovaf)
* @since 1.2.2.7
*/
$encode = 'json_encode';
$root_path_len = strlen( ABSPATH );
$ms_text = fs_text_x_inline( 'ms', 'milliseconds' );
?>
<h1><?php fs_echo_inline( 'API' ) ?></h1>
<h2><span>Total Time:</span><?php echo Freemius_Debug_Bar_Panel::total_time() ?></h2>
<h2><span>Total Requests:</span><?php echo Freemius_Debug_Bar_Panel::requests_count() ?></h2>
<?php foreach ( $counters as $method => $count ) : ?>
<h2><span><?php echo $method ?>:</span><?php echo number_format( $count ) ?></h2>
<?php endforeach ?>
<table class="widefat">
<thead>
<tr>
<th>#</th>
<th><?php fs_esc_html_echo_inline( 'Method' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Code' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Length' ) ?></th>
<th><?php fs_esc_html_echo_x_inline( 'Path', 'as file/folder path' ) ?></th>
<?php if ( $show_body ) : ?>
<th><?php fs_esc_html_echo_inline( 'Body' ) ?></th>
<?php endif ?>
<th><?php fs_esc_html_echo_inline( 'Result' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Start' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'End' ) ?></th>
</tr>
</thead>
<tbody>
<?php foreach ( $logger as $log ) : ?>
<tr>
<td><?php echo $log['id'] ?>.</td>
<td><?php echo $log['method'] ?></td>
<td><?php echo $log['code'] ?></td>
<td><?php echo number_format( 100 * $log['total'], 2 ) . ' ' . $ms_text ?></td>
<td>
<?php
printf( '<a href="#" onclick="jQuery(this).parent().find(\'table\').toggle(); return false;">%s</a>',
$log['path']
);
?>
<table class="widefat" style="display: none">
<tbody>
<?php for ( $i = 0, $bt = $log['backtrace'], $len = count( $bt ); $i < $len; $i ++ ) : ?>
<tr>
<td><?php echo( $len - $i ) ?></td>
<td><?php if ( isset( $bt[ $i ]['function'] ) ) {
echo ( isset( $bt[ $i ]['class'] ) ? $bt[ $i ]['class'] . $bt[ $i ]['type'] : '' ) . $bt[ $i ]['function'];
} ?></td>
<td><?php if ( isset( $bt[ $i ]['file'] ) ) {
echo substr( $bt[ $i ]['file'], $root_path_len ) . ':' . $bt[ $i ]['line'];
} ?></td>
</tr>
<?php endfor ?>
</tbody>
</table>
</td>
<?php if ( $show_body ) : ?>
<td>
<?php if ( 'GET' !== $log['method'] ) : ?>
<?php
$body = $log['body'];
printf(
'<a href="#" onclick="jQuery(this).parent().find(\'pre\').toggle(); return false;">%s</a>',
substr( $body, 0, 32 ) . ( 32 < strlen( $body ) ? '...' : '' )
);
if ( $pretty_print ) {
$body = $encode( json_decode( $log['body'] ), JSON_PRETTY_PRINT );
}
?>
<pre style="display: none"><code><?php echo esc_html( $body ) ?></code></pre>
<?php endif ?>
</td>
<?php endif ?>
<td>
<?php
$result = $log['result'];
$is_not_empty_result = ( is_string( $result ) && ! empty( $result ) );
if ( $is_not_empty_result ) {
printf(
'<a href="#" onclick="jQuery(this).parent().find(\'pre\').toggle(); return false;">%s</a>',
substr( $result, 0, 32 ) . ( 32 < strlen( $result ) ? '...' : '' )
);
}
if ( $is_not_empty_result && $pretty_print ) {
$decoded = json_decode( $result );
if ( ! is_null( $decoded ) ) {
$result = $encode( $decoded, JSON_PRETTY_PRINT );
}
} else {
$result = is_string( $result ) ? $result : json_encode( $result );
}
?>
<pre<?php if ( $is_not_empty_result ) : ?> style="display: none"<?php endif ?>><code><?php echo esc_html( $result ) ?></code></pre>
</td>
<td><?php echo number_format( 100 * ( $log['start'] - WP_FS__SCRIPT_START_TIME ), 2 ) . ' ' . $ms_text ?></td>
<td><?php echo number_format( 100 * ( $log['end'] - WP_FS__SCRIPT_START_TIME ), 2 ) . ' ' . $ms_text ?></td>
</tr>
<?php endforeach ?>
</tbody>
</table>

View File

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

View File

@ -0,0 +1,66 @@
<?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;
}
$log_book = FS_Logger::get_log();
?>
<h1><?php fs_echo_inline( 'Log' ) ?></h1>
<table class="widefat" style="font-size: 11px;">
<thead>
<tr>
<th>#</th>
<th><?php fs_esc_html_echo_inline( 'ID', 'id' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Type' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Function' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Message' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'File' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Timestamp' ) ?></th>
</tr>
</thead>
<tbody>
<?php $i = 0;
foreach ( $log_book as $log ) : ?>
<?php
/**
* @var FS_Logger $logger
*/
$logger = $log['logger'];
?>
<tr<?php if ( $i % 2 ) {
echo ' class="alternate"';
} ?>>
<td><?php echo $log['cnt'] ?>.</td>
<td><?php echo $logger->get_id() ?></td>
<td><?php echo $log['log_type'] ?></td>
<td><b><code style="color: blue;"><?php echo ( ! empty( $log['class'] ) ? $log['class'] . $log['type'] : '' ) . $log['function'] ?></code></b></td>
<td>
<?php
printf(
'<a href="#" style="color: darkorange !important;" onclick="jQuery(this).parent().find(\'div\').toggle(); return false;"><nobr>%s</nobr></a>',
esc_html( substr( $log['msg'], 0, 32 ) ) . ( 32 < strlen( $log['msg'] ) ? '...' : '' )
);
?>
<div style="display: none;">
<b style="color: darkorange;"><?php echo esc_html( $log['msg'] ) ?></b>
</div>
</td>
<td><?php
if ( isset( $log['file'] ) ) {
echo substr( $log['file'], $logger->get_file() ) . ':' . $log['line'];
}
?></td>
<td><?php echo number_format( 100 * ( $log['timestamp'] - WP_FS__SCRIPT_START_TIME ), 2 ) . ' ' . fs_text_x_inline( 'ms', 'milliseconds' ) ?></td>
</tr>
<?php $i ++; endforeach ?>
</tbody>
</table>

View File

@ -0,0 +1,76 @@
<?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;
}
$fs_options = FS_Options::instance( WP_FS__ACCOUNTS_OPTION_NAME, true );
$all_plugins = $fs_options->get_option( 'all_plugins' );
$all_themes = $fs_options->get_option( 'all_themes' );
/* translators: %s: time period (e.g. In "2 hours") */
$in_x_text = fs_text_inline( 'In %s', 'in-x' );
/* translators: %s: time period (e.g. "2 hours" ago) */
$x_ago_text = fs_text_inline( '%s ago', 'x-ago' );
$sec_text = fs_text_x_inline( 'sec', 'seconds' );
?>
<h1><?php fs_esc_html_echo_inline( 'Plugins & Themes Sync', 'plugins-themes-sync' ) ?></h1>
<table class="widefat">
<thead>
<tr>
<th></th>
<th><?php fs_esc_html_echo_inline( 'Total', 'total' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Last', 'last' ) ?></th>
</tr>
</thead>
<tbody>
<?php if ( is_object( $all_plugins ) ) : ?>
<tr>
<td><?php fs_esc_html_echo_inline( 'Plugins', 'plugins' ) ?></td>
<td><?php echo count( $all_plugins->plugins ) ?></td>
<td><?php
if ( isset( $all_plugins->timestamp ) && is_numeric( $all_plugins->timestamp ) ) {
$diff = abs( WP_FS__SCRIPT_START_TIME - $all_plugins->timestamp );
$human_diff = ( $diff < MINUTE_IN_SECONDS ) ?
$diff . ' ' . $sec_text :
human_time_diff( WP_FS__SCRIPT_START_TIME, $all_plugins->timestamp );
echo esc_html( sprintf(
( ( WP_FS__SCRIPT_START_TIME < $all_plugins->timestamp ) ?
$in_x_text :
$x_ago_text ),
$human_diff
) );
}
?></td>
</tr>
<?php endif ?>
<?php if ( is_object( $all_themes ) ) : ?>
<tr>
<td><?php fs_esc_html_echo_inline( 'Themes', 'themes' ) ?></td>
<td><?php echo count( $all_themes->themes ) ?></td>
<td><?php
if ( isset( $all_themes->timestamp ) && is_numeric( $all_themes->timestamp ) ) {
$diff = abs( WP_FS__SCRIPT_START_TIME - $all_themes->timestamp );
$human_diff = ( $diff < MINUTE_IN_SECONDS ) ?
$diff . ' ' . $sec_text :
human_time_diff( WP_FS__SCRIPT_START_TIME, $all_themes->timestamp );
echo esc_html( sprintf(
( ( WP_FS__SCRIPT_START_TIME < $all_themes->timestamp ) ?
$in_x_text :
$x_ago_text ),
$human_diff
) );
}
?></td>
</tr>
<?php endif ?>
</tbody>
</table>

View File

@ -0,0 +1,136 @@
<?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;
}
$fs_options = FS_Options::instance( WP_FS__ACCOUNTS_OPTION_NAME, true );
$scheduled_crons = array();
$module_types = array(
WP_FS__MODULE_TYPE_PLUGIN,
WP_FS__MODULE_TYPE_THEME
);
foreach ( $module_types as $module_type ) {
$modules = fs_get_entities( $fs_options->get_option( $module_type . 's' ), FS_Plugin::get_class_name() );
if ( is_array( $modules ) && count( $modules ) > 0 ) {
foreach ( $modules as $slug => $data ) {
if ( WP_FS__MODULE_TYPE_THEME === $module_type ) {
$current_theme = wp_get_theme();
$is_active = ( $current_theme->stylesheet === $data->file );
} else {
$is_active = is_plugin_active( $data->file );
}
/**
* @author Vova Feldman
*
* @since 1.2.1 Don't load data from inactive modules.
*/
if ( $is_active ) {
$fs = freemius( $data->id );
$next_execution = $fs->next_sync_cron();
$last_execution = $fs->last_sync_cron();
if ( false !== $next_execution ) {
$scheduled_crons[ $slug ][] = array(
'name' => $fs->get_plugin_name(),
'slug' => $slug,
'module_type' => $fs->get_module_type(),
'type' => 'sync_cron',
'last' => $last_execution,
'next' => $next_execution,
);
}
$next_install_execution = $fs->next_install_sync();
$last_install_execution = $fs->last_install_sync();
if (false !== $next_install_execution ||
false !== $last_install_execution
) {
$scheduled_crons[ $slug ][] = array(
'name' => $fs->get_plugin_name(),
'slug' => $slug,
'module_type' => $fs->get_module_type(),
'type' => 'install_sync',
'last' => $last_install_execution,
'next' => $next_install_execution,
);
}
}
}
}
}
$sec_text = fs_text_x_inline( 'sec', 'seconds' );
?>
<h1><?php fs_esc_html_echo_inline( 'Scheduled Crons' ) ?></h1>
<table class="widefat">
<thead>
<tr>
<th><?php fs_esc_html_echo_inline( 'Slug' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Module' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Module Type' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Cron Type' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Last' ) ?></th>
<th><?php fs_esc_html_echo_inline( 'Next' ) ?></th>
</tr>
</thead>
<tbody>
<?php
/* translators: %s: time period (e.g. In "2 hours") */
$in_x_text = fs_text_inline( 'In %s', 'in-x' );
/* translators: %s: time period (e.g. "2 hours" ago) */
$x_ago_text = fs_text_inline( '%s ago', 'x-ago' );
?>
<?php foreach ( $scheduled_crons as $slug => $crons ) : ?>
<?php foreach ( $crons as $cron ) : ?>
<tr>
<td><?php echo $slug ?></td>
<td><?php echo $cron['name'] ?></td>
<td><?php echo $cron['module_type'] ?></td>
<td><?php echo $cron['type'] ?></td>
<td><?php
if ( is_numeric( $cron['last'] ) ) {
$diff = abs( WP_FS__SCRIPT_START_TIME - $cron['last'] );
$human_diff = ( $diff < MINUTE_IN_SECONDS ) ?
$diff . ' ' . $sec_text :
human_time_diff( WP_FS__SCRIPT_START_TIME, $cron['last'] );
echo esc_html( sprintf(
( ( WP_FS__SCRIPT_START_TIME < $cron['last'] ) ?
$in_x_text :
$x_ago_text ),
$human_diff
) );
}
?></td>
<td><?php
if ( is_numeric( $cron['next'] ) ) {
$diff = abs( WP_FS__SCRIPT_START_TIME - $cron['next'] );
$human_diff = ( $diff < MINUTE_IN_SECONDS ) ?
$diff . ' ' . $sec_text :
human_time_diff( WP_FS__SCRIPT_START_TIME, $cron['next'] );
echo esc_html( sprintf(
( ( WP_FS__SCRIPT_START_TIME < $cron['next'] ) ?
$in_x_text :
$x_ago_text ),
$human_diff
) );
}
?></td>
</tr>
<?php endforeach ?>
<?php endforeach ?>
</tbody>
</table>

View File

@ -0,0 +1,49 @@
<?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.1
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* @var array $VARS
*/
$sections = $VARS['sections'];
?>
<table>
<?php
foreach ( $sections as $section_id => $section ) {
?>
<thead>
<tr><th colspan="2" style="text-align: left; background: #333; color: #fff; padding: 5px;"><?php echo esc_html($section['title']) ?></th></tr>
</thead>
<tbody>
<?php
foreach ( $section['rows'] as $row_id => $row ) {
$col_count = count( $row );
?>
<tr>
<?php
if ( 1 === $col_count ) { ?>
<td style="vertical-align: top;" colspan="2"><?php echo $row[0] ?></td>
<?php
} else { ?>
<td style="vertical-align: top;"><b><?php echo esc_html($row[0]) ?>:</b></td>
<td><?php echo $row[1]; ?></td>
<?php
}
?>
</tr>
<?php
}
?>
</tbody>
<?php
}
?>
</table>

View File

@ -0,0 +1,63 @@
<?php
/**
* API connectivity issues (CloudFlare's firewall) handler for handling different
* scenarios selected by the user after connectivity issue is detected, by sending
* AJAX call to the server in order to make the actual actions.
*
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.0.9
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<script type="text/javascript">
jQuery( document ).ready(function( $ ) {
$( '#fs_firewall_issue_options a.fs-resolve' ).click(function() {
var
error_type = $( this ).attr( 'data-type' ),
notice = $( this ).parents( '.fs-notice' ),
ajaxActionSuffix = notice.attr( 'data-manager-id' ).replace( ':', '-' );
var data = {
action : 'fs_resolve_firewall_issues_' + ajaxActionSuffix,
// As such we don't need to use `wp_json_encode` method but using it to follow wp.org guideline.
_wpnonce : <?php echo wp_json_encode( wp_create_nonce( 'fs_resolve_firewall_issues' ) ); ?>,
error_type: error_type
};
if ( 'squid' === error_type ) {
data.hosting_company = prompt( 'What is the name or URL of your hosting company?' );
if ( null == data.hosting_company )
return false;
if ( '' === data.hosting_company ) {
alert( 'We won\'t be able to help without knowing your hosting company.' );
return false;
}
}
if ( 'retry_ping' === error_type ) {
data.action = 'fs_retry_connectivity_test_' + ajaxActionSuffix;
// As such we don't need to use `wp_json_encode` method but using it to follow wp.org guideline.
data._wpnonce = <?php echo wp_json_encode( wp_create_nonce( 'fs_retry_connectivity_test' ) ); ?>;
}
$( this ).css({'cursor': 'wait'});
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
$.post( ajaxurl, data, function( response ) {
if ( 1 == response ) {
// Refresh page on success.
location.reload();
} else if ( 'http' === response.substr( 0, 4 ) ) {
// Ping actually worked, redirect.
window.location = response;
}
});
});
});
</script>

View File

@ -0,0 +1,509 @@
<?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;
}
/**
* @var array $VARS
* @var Freemius $fs
*/
$fs = freemius( $VARS['id'] );
$slug = $fs->get_slug();
$user = $fs->get_user();
$affiliate = $fs->get_affiliate();
$affiliate_terms = $fs->get_affiliate_terms();
$plugin_title = $fs->get_plugin_title();
$module_type = $fs->is_plugin() ?
WP_FS__MODULE_TYPE_PLUGIN :
WP_FS__MODULE_TYPE_THEME;
$commission = $affiliate_terms->get_formatted_commission();
$readonly = false;
$is_affiliate = is_object( $affiliate );
$is_pending_affiliate = false;
$email_address = ( is_object( $user ) ?
$user->email :
'' );
$full_name = ( is_object( $user ) ?
$user->get_name() :
'' );
$paypal_email_address = '';
$domain = '';
$extra_domains = array();
$promotion_method_social_media = false;
$promotion_method_mobile_apps = false;
$statistics_information = false;
$promotion_method_description = false;
$members_dashboard_login_url = 'https://members.freemius.com/login/';
$affiliate_application_data = $fs->get_affiliate_application_data();
if ( $is_affiliate && $affiliate->is_pending() ) {
$readonly = 'readonly';
$is_pending_affiliate = true;
$paypal_email_address = $affiliate->paypal_email;
$domain = $affiliate->domain;
$statistics_information = $affiliate_application_data['stats_description'];
$promotion_method_description = $affiliate_application_data['promotion_method_description'];
if ( ! empty( $affiliate_application_data['additional_domains'] ) ) {
$extra_domains = $affiliate_application_data['additional_domains'];
}
if ( ! empty( $affiliate_application_data['promotion_methods'] ) ) {
$promotion_methods = explode( ',', $affiliate_application_data['promotion_methods'] );
$promotion_method_social_media = in_array( 'social_media', $promotion_methods );
$promotion_method_mobile_apps = in_array( 'mobile_apps', $promotion_methods );
}
} else {
$current_user = Freemius::_get_current_wp_user();
$full_name = trim( $current_user->user_firstname . ' ' . $current_user->user_lastname );
$email_address = $current_user->user_email;
$domain = fs_strip_url_protocol( get_site_url() );
}
$affiliate_tracking = 30;
if ( is_object( $affiliate_terms ) ) {
$affiliate_tracking = ( ! is_null( $affiliate_terms->cookie_days ) ?
( $affiliate_terms->cookie_days . '-day' ) :
fs_text_inline( 'Non-expiring', 'non-expiring', $slug ) );
}
$apply_to_become_affiliate_text = fs_text_inline( 'Apply to become an affiliate', 'apply-to-become-an-affiliate', $slug );
$module_id = $fs->get_id();
$affiliate_program_terms_url = "https://freemius.com/plugin/{$module_id}/{$slug}/legal/affiliate-program/";
?>
<div id="fs_affiliation_content_wrapper" class="wrap">
<form method="post" action="">
<div id="poststuff">
<div class="postbox">
<div class="inside">
<div id="messages">
<div id="error_message" class="error" style="display: none">
<p><strong></strong></p>
</div>
<div id="message" class="updated" style="display: none">
<p><strong></strong></p>
</div>
<?php if ( $is_affiliate ) : ?>
<?php if ( $affiliate->is_active() ) : ?>
<div class="updated">
<p><strong><?php
echo sprintf(
fs_esc_html_inline( "Your affiliate application for %s has been accepted! Log in to your affiliate area at: %s.", 'affiliate-application-accepted', $slug ),
$plugin_title,
sprintf(
'<a href="%s" target="_blank" rel="noopener">%s</a>',
$members_dashboard_login_url,
$members_dashboard_login_url
)
);
?></strong></p>
</div>
<?php else : ?>
<?php
$message_text = '';
if ( $is_pending_affiliate ) {
$message_text = fs_text_inline( "Thank you for applying for our affiliate program, we'll review your details during the next 14 days and will get back to you with further information.", 'affiliate-application-thank-you', $slug );
$message_container_class = 'updated';
} else if ( $affiliate->is_suspended() ) {
$message_text = fs_text_inline( 'Your affiliation account was temporarily suspended.', 'affiliate-account-suspended', $slug );
$message_container_class = 'notice notice-warning';
} else if ( $affiliate->is_rejected() ) {
$message_text = fs_text_inline( "Thank you for applying for our affiliate program, unfortunately, we've decided at this point to reject your application. Please try again in 30 days.", 'affiliate-application-rejected', $slug );
$message_container_class = 'error';
} else if ( $affiliate->is_blocked() ) {
$message_text = fs_text_inline( 'Due to violation of our affiliation terms, we decided to temporarily block your affiliation account. If you have any questions, please contact support.', 'affiliate-account-blocked', $slug );
$message_container_class = 'error';
}
?>
<div class="<?php echo $message_container_class ?>">
<p><strong><?php echo esc_html( $message_text ) ?></strong></p>
</div>
<?php endif ?>
<?php endif ?>
</div>
<div class="entry-content">
<?php if ( ! $is_affiliate ) : ?>
<div id="application_messages_container">
<p><?php echo esc_html( sprintf( fs_text_inline( 'Like the %s? Become our ambassador and earn cash ;-)', 'become-an-ambassador', $slug ), $module_type ) ) ?></p>
<p><?php echo esc_html( sprintf( fs_text_inline( 'Refer new customers to our %s and earn %s commission on each successful sale you refer!', 'refer-new-customers', $slug ), $module_type, $commission ) ) ?></p>
</div>
<?php endif ?>
<h3><?php fs_esc_html_echo_inline( 'Program Summary', 'program-summary', $slug ) ?></h3>
<ul>
<li><?php echo esc_html( sprintf( fs_text_inline( '%s commission when a customer purchases a new license.', 'commission-on-new-license-purchase', $slug ), $commission ) ) ?></li>
<?php if ( is_object( $affiliate_terms ) && $affiliate_terms->has_renewals_commission() ) : ?>
<li><?php echo esc_html( sprintf( fs_text_inline( 'Get commission for automated subscription renewals.', 'renewals-commission', $slug ) ) ) ?></li>
<?php endif ?>
<?php if ( is_object( $affiliate_terms ) && ( ! $affiliate_terms->is_session_cookie() ) ) : ?>
<li><?php echo esc_html( sprintf( fs_text_inline( '%s tracking cookie after the first visit to maximize earnings potential.', 'affiliate-tracking', $slug ), $affiliate_tracking ) ) ?></li>
<?php endif ?>
<?php if ( is_object( $affiliate_terms ) && $affiliate_terms->has_lifetime_commission() ) : ?>
<li><?php fs_esc_html_echo_inline( 'Unlimited commissions.', 'unlimited-commissions', $slug ) ?></li>
<?php endif ?>
<li><?php echo esc_html( sprintf( fs_text_inline( '%s minimum payout amount.', 'minimum-payout-amount', $slug ), '$100' ) ) ?></li>
<li><?php fs_esc_html_echo_inline( 'Payouts are in USD and processed monthly via PayPal.', 'payouts-unit-and-processing', $slug ) ?></li>
<li><?php fs_esc_html_echo_inline( 'As we reserve 30 days for potential refunds, we only pay commissions that are older than 30 days.', 'commission-payment', $slug ) ?></li>
</ul>
<div id="application_form_container" <?php echo ( $is_pending_affiliate ) ? '' : 'style="display: none"' ?>>
<h3><?php fs_esc_html_echo_inline( 'Affiliate', 'affiliate', $slug ) ?></h3>
<form>
<div class="input-container input-container-text">
<label class="input-label"><?php fs_esc_html_echo_inline( 'Email address', 'email-address', $slug ) ?></label>
<input id="email_address" type="text" value="<?php echo esc_attr( $email_address ) ?>" class="regular-text" <?php echo ( $readonly || is_object( $user ) ) ? 'readonly' : '' ?>>
</div>
<div class="input-container input-container-text">
<label class="input-label"><?php fs_esc_html_echo_inline( 'Full name', 'full-name', $slug ) ?></label>
<input id="full_name" type="text" value="<?php echo esc_attr( $full_name ) ?>" class="regular-text" <?php echo $readonly ?>>
</div>
<div class="input-container input-container-text">
<label class="input-label"><?php fs_esc_html_echo_inline( 'PayPal account email address', 'paypal-account-email-address', $slug ) ?></label>
<input id="paypal_email" type="text" value="<?php echo esc_attr( $paypal_email_address ) ?>" class="regular-text" <?php echo $readonly ?>>
</div>
<div class="input-container input-container-text">
<label class="input-label"><?php echo esc_html( sprintf( fs_text_inline( 'Where are you going to promote the %s?', 'domain-field-label', $slug ), $module_type ) ) ?></label>
<input id="domain" type="text" value="<?php echo esc_attr( $domain ) ?>" class="domain regular-text" <?php echo $readonly ?>>
<p class="description"><?php echo esc_html( sprintf( fs_text_inline( 'Enter the domain of your website or other websites from where you plan to promote the %s.', 'domain-field-desc', $slug ), $module_type ) ) ?></p>
<?php if ( ! $is_affiliate ) : ?>
<a id="add_domain" href="#" class="disabled">+ <?php fs_esc_html_echo_inline( 'Add another domain', 'add-another-domain', $slug ) ?>...</a>
<?php endif ?>
</div>
<div id="extra_domains_container" class="input-container input-container-text" <?php echo $is_pending_affiliate ? '' : 'style="display: none"' ?>>
<label class="input-label"><?php fs_esc_html_echo_inline( 'Extra Domains', 'extra-domain-fields-label', $slug ) ?></label>
<p class="description"><?php fs_esc_html_echo_inline( 'Extra domains where you will be marketing the product from.', 'extra-domain-fields-desc', $slug ) ?></p>
<?php if ( $is_pending_affiliate && ! empty( $extra_domains ) ) : ?>
<?php foreach ( $extra_domains as $extra_domain ) : ?>
<div class="extra-domain-input-container">
<input type="text" value="<?php echo esc_attr( $extra_domain ) ?>" class="domain regular-text" <?php echo $readonly ?>>
</div>
<?php endforeach ?>
<?php endif ?>
</div>
<div class="input-container">
<label class="input-label"><?php fs_esc_html_echo_inline( 'Promotion methods', 'promotion-methods', $slug ) ?></label>
<div>
<input id="promotion_method_social_media" type="checkbox" <?php checked( $promotion_method_social_media ) ?> <?php disabled( $is_affiliate ) ?>/>
<label for="promotion_method_social_media"><?php fs_esc_html_echo_inline( 'Social media (Facebook, Twitter, etc.)', 'social-media', $slug ) ?></label>
</div>
<div>
<input id="promotion_method_mobile_apps" type="checkbox" <?php checked( $promotion_method_mobile_apps ) ?> <?php disabled( $is_affiliate ) ?>/>
<label for="promotion_method_mobile_apps"><?php fs_esc_html_echo_inline( 'Mobile apps', 'mobile-apps', $slug ) ?></label>
</div>
</div>
<div class="input-container input-container-text">
<label class="input-label"><nobr><?php fs_esc_html_echo_inline( 'Website, email, and social media statistics (optional)', 'statistics-information-field-label', $slug ) ?></nobr></label>
<textarea id="statistics_information" rows="5" <?php echo $readonly ?> class="regular-text"><?php echo $statistics_information ?></textarea>
<?php if ( ! $is_affiliate ) : ?>
<p class="description"><?php fs_esc_html_echo_inline( 'Please feel free to provide any relevant website or social media statistics, e.g. monthly unique site visits, number of email subscribers, followers, etc. (we will keep this information confidential).', 'statistics-information-field-desc', $slug ) ?></p>
<?php endif ?>
</div>
<div class="input-container input-container-text">
<label class="input-label"><?php fs_esc_html_echo_inline( 'How will you promote us?', 'promotion-method-desc-field-label', $slug ) ?></label>
<textarea id="promotion_method_description" rows="5" <?php echo $readonly ?> class="regular-text"><?php echo $promotion_method_description ?></textarea>
<?php if ( ! $is_affiliate ) : ?>
<p class="description"><?php echo esc_html( sprintf( fs_text_inline( 'Please provide details on how you intend to promote %s (please be as specific as possible).', 'promotion-method-desc-field-desc', $slug ), $plugin_title ) ) ?></p>
<?php endif ?>
</div>
<?php if ( ! $is_affiliate ) : ?>
<div>
<input type="checkbox" id="legal_consent_checkbox">
<label for="legal_consent_checkbox">I agree to the <a href="<?php echo $affiliate_program_terms_url ?>" target="_blank" rel="noopener">Referrer Program</a>'s terms & conditions.</label>
</div>
<?php endif ?>
</form>
</div>
<?php if ( ! $is_affiliate ) : ?>
<a id="cancel_button" href="#" class="button button-secondary button-cancel" style="display: none"><?php fs_esc_html_echo_inline( 'Cancel', 'cancel', $slug ) ?></a>
<a id="submit_button" class="button button-primary disabled" href="#" style="display: none"><?php echo esc_html( $apply_to_become_affiliate_text ) ?></a>
<a id="apply_button" class="button button-primary" href="#"><?php fs_esc_html_echo_inline( 'Become an affiliate', 'become-an-affiliate', $slug ) ?></a>
<?php endif ?>
</div>
</div>
</div>
</div>
</form>
<script type="text/javascript">
jQuery(function ($) {
var
$contentWrapper = $('#fs_affiliation_content_wrapper'),
$socialMedia = $('#promotion_method_social_media'),
$mobileApps = $('#promotion_method_mobile_apps'),
$applyButton = $('#apply_button'),
$submitButton = $('#submit_button'),
$cancelButton = $('#cancel_button'),
$applicationFormContainer = $('#application_form_container'),
$errorMessageContainer = $('#error_message'),
$domain = $('#domain'),
$addDomain = $('#add_domain'),
$extraDomainsContainer = $('#extra_domains_container'),
$legalConsentCheckbox = $( '#legal_consent_checkbox' );
$applyButton.click(function (evt) {
evt.preventDefault();
var $this = $(this);
$this.hide();
$applicationFormContainer.show();
$cancelButton.show();
$submitButton.show();
$contentWrapper.find('input[type="text"]:first').focus();
});
$submitButton.click(function (evt) {
evt.preventDefault();
var $this = $(this);
if ($this.hasClass('disabled')) {
return;
}
$errorMessageContainer.hide();
var
$emailAddress = $('#email_address'),
emailAddress = null,
paypalEmailAddress = $('#paypal_email').val().trim();
if (1 === $emailAddress.length) {
emailAddress = $emailAddress.val().trim();
if (0 === emailAddress.length) {
showErrorMessage('<?php fs_esc_js_echo_inline( 'Email address is required.', 'email-address-is-required', $slug ) ?>');
return;
}
}
if (0 === paypalEmailAddress.length) {
showErrorMessage('<?php fs_esc_js_echo_inline( 'PayPal email address is required.', 'paypal-email-address-is-required', $slug ) ?>');
return;
}
var
$extraDomains = $extraDomainsContainer.find('.domain'),
domain = $domain.val().trim().toLowerCase(),
extraDomains = [];
if (0 === domain.length) {
showErrorMessage('<?php fs_esc_js_echo_inline( 'Domain is required.', 'domain-is-required', $slug ) ?>');
return;
} else if ('freemius.com' === domain) {
showErrorMessage('<?php fs_esc_js_echo_inline( 'Invalid domain', 'invalid-domain', $slug ) ?>' + ' [' + domain + '].');
return;
}
if ($extraDomains.length > 0) {
var hasError = false;
$extraDomains.each(function () {
var
$this = $(this),
extraDomain = $this.val().trim().toLowerCase();
if (0 === extraDomain.length || extraDomain === domain) {
return true;
} else if ('freemius.com' === extraDomain) {
showErrorMessage('<?php fs_esc_js_echo_inline( 'Invalid domain', 'invalid-domain', $slug ) ?>' + ' [' + extraDomain + '].');
hasError = true;
return false;
}
extraDomains.push(extraDomain);
});
if (hasError) {
return;
}
}
var
promotionMethods = [],
statisticsInformation = $('#statistics_information').val(),
promotionMethodDescription = $('#promotion_method_description').val();
if ($socialMedia.attr('checked')) {
promotionMethods.push('social_media');
}
if ($mobileApps.attr('checked')) {
promotionMethods.push('mobile_apps');
}
var affiliate = {
full_name : $('#full_name').val().trim(),
paypal_email : paypalEmailAddress,
stats_description : statisticsInformation,
promotion_method_description: promotionMethodDescription
};
if (null !== emailAddress) {
affiliate.email = emailAddress;
}
affiliate.domain = domain;
affiliate.additional_domains = extraDomains;
if (promotionMethods.length > 0) {
affiliate.promotion_methods = promotionMethods.join(',');
}
$.ajax({
url : ajaxurl,
method : 'POST',
data : {
action : '<?php echo $fs->get_ajax_action( 'submit_affiliate_application' ) ?>',
security : '<?php echo $fs->get_ajax_security( 'submit_affiliate_application' ) ?>',
module_id: '<?php echo $module_id ?>',
affiliate: affiliate
},
beforeSend: function () {
$cancelButton.addClass('disabled');
$submitButton.addClass('disabled');
$submitButton.text('<?php fs_esc_js_echo_inline( 'Submitting', 'submitting' ) ?>...');
},
success : function (result) {
if (result.success) {
location.reload();
} else {
if (result.error && result.error.length > 0) {
showErrorMessage(result.error);
}
$cancelButton.removeClass('disabled');
$submitButton.removeClass('disabled');
$submitButton.text('<?php echo esc_js( $apply_to_become_affiliate_text ) ?>')
}
}
});
});
$cancelButton.click(function (evt) {
evt.preventDefault();
var $this = $(this);
if ($this.hasClass('disabled')) {
return;
}
$applicationFormContainer.hide();
$this.hide();
$submitButton.hide();
$applyButton.show();
window.scrollTo(0, 0);
});
$domain.on('input propertychange', onDomainChange);
$addDomain.click(function (evt) {
evt.preventDefault();
var
$this = $(this),
domain = $domain.val().trim();
if ($this.hasClass('disabled') || 0 === domain.length) {
return;
}
$domain.off('input propertychange');
$this.addClass('disabled');
var
$extraDomainInputContainer = $('<div class="extra-domain-input-container"><input type="text" class="domain regular-text"/></div>'),
$extraDomainInput = $extraDomainInputContainer.find('input'),
$removeDomain = $('<a href="#" class="remove-domain"><i class="dashicons dashicons-no" title="<?php fs_esc_js_echo_inline( 'Remove', 'remove', $slug ) ?>"></i></a>');
$extraDomainInputContainer.append($removeDomain);
$extraDomainInput.on('input propertychange', onDomainChange);
$removeDomain.click(function (evt) {
evt.preventDefault();
var
$extraDomainInputs = $('.extra-domain-input-container .domain');
if (1 === $extraDomainInputs.length)
$extraDomainInputs.val('').focus();
else
$(this).parent().remove();
});
$extraDomainsContainer.show();
$extraDomainInputContainer.appendTo($extraDomainsContainer);
$extraDomainInput.focus();
$this.appendTo($extraDomainsContainer);
});
/**
* @author Leo Fajardo (@leorw)
*/
function onDomainChange() {
var
domain = $(this).val().trim();
if (domain.length > 0) {
$addDomain.removeClass('disabled');
} else {
$addDomain.addClass('disabled');
}
}
/**
* @author Leo Fajardo (@leorw)
*
* @param {String} message
*/
function showErrorMessage(message) {
$errorMessageContainer.find('strong').text(message);
$errorMessageContainer.show();
window.scrollTo(0, 0);
}
/**
* @author Xiaheng Chen (@xhchen)
*
* @since 2.4.0
*/
$legalConsentCheckbox.click( function () {
if ( $( this ).prop( 'checked' ) ) {
$submitButton.removeClass( 'disabled' );
} else {
$submitButton.addClass( 'disabled' );
}
} );
});
</script>
</div>
<?php
$params = array(
'page' => 'affiliation',
'module_id' => $module_id,
'module_slug' => $slug,
'module_version' => $fs->get_plugin_version(),
);
fs_require_template( 'powered-by.php', $params );
?>

View File

@ -0,0 +1,23 @@
<?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.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* @var array $VARS
*/
$fs = freemius( $VARS['id'] );
$slug = $fs->get_slug();
echo fs_text_inline( 'Sorry for the inconvenience and we are here to help if you give us a chance.', 'contact-support-before-deactivation', $slug )
. sprintf(" <a href='%s' class='button button-small button-primary'>%s</a>",
$fs->contact_url( 'technical_support' ),
fs_text_inline( 'Contact Support', 'contact-support', $slug )
);

View File

@ -0,0 +1,543 @@
<?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.2
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* @var array $VARS
*/
$fs = freemius( $VARS['id'] );
$slug = $fs->get_slug();
$subscription_cancellation_dialog_box_template_params = $VARS['subscription_cancellation_dialog_box_template_params'];
$show_deactivation_feedback_form = $VARS['show_deactivation_feedback_form'];
$confirmation_message = $VARS['uninstall_confirmation_message'];
$is_anonymous = ( ! $fs->is_registered() );
$anonymous_feedback_checkbox_html = '';
$reasons_list_items_html = '';
if ( $show_deactivation_feedback_form ) {
$reasons = $VARS['reasons'];
foreach ( $reasons as $reason ) {
$list_item_classes = 'reason' . ( ! empty( $reason['input_type'] ) ? ' has-input' : '' );
if ( isset( $reason['internal_message'] ) && ! empty( $reason['internal_message'] ) ) {
$list_item_classes .= ' has-internal-message';
$reason_internal_message = $reason['internal_message'];
} else {
$reason_internal_message = '';
}
$reason_input_type = ( ! empty( $reason['input_type'] ) ? $reason['input_type'] : '' );
$reason_input_placeholder = ( ! empty( $reason['input_placeholder'] ) ? $reason['input_placeholder'] : '' );
$reason_list_item_html = <<< HTML
<li class="{$list_item_classes}"
data-input-type="{$reason_input_type}"
data-input-placeholder="{$reason_input_placeholder}">
<label>
<span>
<input type="radio" name="selected-reason" value="{$reason['id']}"/>
</span>
<span>{$reason['text']}</span>
</label>
<div class="internal-message">{$reason_internal_message}</div>
</li>
HTML;
$reasons_list_items_html .= $reason_list_item_html;
}
if ( $is_anonymous ) {
$anonymous_feedback_checkbox_html = sprintf(
'<label class="anonymous-feedback-label"><input type="checkbox" class="anonymous-feedback-checkbox"> %s</label>',
fs_esc_html_inline( 'Anonymous feedback', 'anonymous-feedback', $slug )
);
}
}
// Aliases.
$deactivate_text = fs_text_inline( 'Deactivate', 'deactivate', $slug );
$theme_text = fs_text_inline( 'Theme', 'theme', $slug );
$activate_x_text = fs_text_inline( 'Activate %s', 'activate-x', $slug );
fs_enqueue_local_style( 'fs_dialog_boxes', '/admin/dialog-boxes.css' );
if ( ! empty( $subscription_cancellation_dialog_box_template_params ) ) {
fs_require_template( 'forms/subscription-cancellation.php', $subscription_cancellation_dialog_box_template_params );
}
?>
<script type="text/javascript">
(function ($) {
var reasonsHtml = <?php echo json_encode( $reasons_list_items_html ) ?>,
modalHtml =
'<div class="fs-modal fs-modal-deactivation-feedback<?php echo empty( $confirmation_message ) ? ' no-confirmation-message' : ''; ?>">'
+ ' <div class="fs-modal-dialog">'
+ ' <div class="fs-modal-header">'
+ ' <h4><?php fs_esc_attr_echo_inline( 'Quick Feedback', 'quick-feedback' , $slug ) ?></h4>'
+ ' </div>'
+ ' <div class="fs-modal-body">'
+ ' <div class="fs-modal-panel" data-panel-id="confirm"><p><?php echo $confirmation_message; ?></p></div>'
+ ' <div class="fs-modal-panel active" data-panel-id="reasons"><h3><strong><?php echo esc_js( sprintf( fs_text_inline( 'If you have a moment, please let us know why you are %s', 'deactivation-share-reason' , $slug ), ( $fs->is_plugin() ? fs_text_inline( 'deactivating', 'deactivating', $slug ) : fs_text_inline( 'switching', 'switching', $slug ) ) ) ) ?>:</strong></h3><ul id="reasons-list">' + reasonsHtml + '</ul></div>'
+ ' </div>'
+ ' <div class="fs-modal-footer">'
+ ' <?php echo $anonymous_feedback_checkbox_html ?>'
+ ' <a href="#" class="button button-secondary button-deactivate"></a>'
+ ' <a href="#" class="button button-secondary button-close"><?php fs_esc_js_echo_inline( 'Cancel', 'cancel', $slug ) ?></a>'
+ ' </div>'
+ ' </div>'
+ '</div>',
$modal = $(modalHtml),
selectedReasonID = false,
redirectLink = '',
$anonymousFeedback = $modal.find( '.anonymous-feedback-label' ),
isAnonymous = <?php echo ( $is_anonymous ? 'true' : 'false' ); ?>,
otherReasonID = <?php echo Freemius::REASON_OTHER; ?>,
dontShareDataReasonID = <?php echo Freemius::REASON_DONT_LIKE_TO_SHARE_MY_INFORMATION; ?>,
deleteThemeUpdateData = <?php echo $fs->is_theme() && $fs->is_premium() && ! $fs->has_any_active_valid_license() ? 'true' : 'false' ?>,
$subscriptionCancellationModal = $( '.fs-modal-subscription-cancellation-<?php echo $fs->get_id() ?>' ),
showDeactivationFeedbackForm = <?php echo ( $show_deactivation_feedback_form ? 'true' : 'false' ) ?>,
$body = $( 'body' );
$modal.appendTo( $body );
if ( 0 !== $subscriptionCancellationModal.length ) {
$subscriptionCancellationModal.on( '<?php echo $fs->get_action_tag( 'subscription_cancellation_action' ) ?>', function( evt, cancelSubscription ) {
var shouldDeactivateModule = ( $modal.hasClass( 'no-confirmation-message' ) && ! showDeactivationFeedbackForm );
if ( false === cancelSubscription ) {
if ( ! shouldDeactivateModule ) {
showModal();
}
$subscriptionCancellationModal.trigger( 'closeModal' );
if ( shouldDeactivateModule ) {
deactivateModule();
}
} else {
var $errorMessage = $subscriptionCancellationModal.find( '.notice-error' );
<?php
$subscription_cancellation_context = $fs->is_paid_trial() ?
fs_text_inline( 'trial', 'trial', $slug ) :
fs_text_inline( 'subscription', 'subscription', $slug );
?>
$.ajax({
url : ajaxurl,
method : 'POST',
data : {
action : '<?php echo $fs->get_ajax_action( 'cancel_subscription_or_trial' ) ?>',
security : '<?php echo $fs->get_ajax_security( 'cancel_subscription_or_trial' ) ?>',
module_id: '<?php echo $fs->get_id() ?>'
},
beforeSend: function() {
$errorMessage.hide();
$subscriptionCancellationModal.find( '.fs-modal-footer .button' ).addClass( 'disabled' );
$subscriptionCancellationModal.find( '.fs-modal-footer .button-primary' ).text( '<?php echo esc_js(
sprintf( fs_text_inline( 'Cancelling %s...', 'cancelling-x' , $slug ), $subscription_cancellation_context )
) ?>' );
},
success: function( result ) {
if ( result.success ) {
$subscriptionCancellationModal.removeClass( 'has-subscription-actions' );
$subscriptionCancellationModal.find( '.fs-modal-footer .button-primary' ).removeClass( 'warn' );
$subscriptionCancellationModal.remove();
if ( ! shouldDeactivateModule ) {
showModal();
} else {
deactivateModule();
}
} else {
$errorMessage.find( '> p' ).html( result.error );
$errorMessage.show();
$subscriptionCancellationModal.find( '.fs-modal-footer .button' ).removeClass( 'disabled' );
$subscriptionCancellationModal.find( '.fs-modal-footer .button-primary' ).html( <?php echo json_encode( sprintf(
fs_text_inline( 'Cancel %s & Proceed', 'cancel-x-and-proceed', $slug ),
ucfirst( $subscription_cancellation_context )
) ) ?> );
}
}
});
}
});
}
registerEventHandlers();
function registerEventHandlers() {
$body.on( 'click', '#the-list .deactivate > a', function ( evt ) {
if ( 0 === $( this ).next( '[data-module-id=<?php echo $fs->get_id() ?>].fs-module-id' ).length ) {
return true;
}
evt.preventDefault();
redirectLink = $(this).attr('href');
if ( 0 == $subscriptionCancellationModal.length ) {
showModal();
} else {
$subscriptionCancellationModal.trigger( 'showModal' );
}
});
<?php
if ( ! $fs->is_plugin() ) {
/**
* For "theme" module type, the modal is shown when the current user clicks on
* the "Activate" button of any other theme. The "Activate" button is actually
* a link to the "Themes" page (/wp-admin/themes.php) containing query params
* that tell WordPress to deactivate the current theme and activate a different theme.
*
* @author Leo Fajardo (@leorw)
* @since 1.2.2
*
* @since 1.2.2.7 Don't trigger the deactivation feedback form if activating the premium version of the theme.
*/
?>
$('body').on('click', '.theme-browser .theme:not([data-slug=<?php echo $fs->get_premium_slug() ?>]) .theme-actions .button.activate', function (evt) {
evt.preventDefault();
redirectLink = $(this).attr('href');
if ( 0 != $subscriptionCancellationModal.length ) {
$subscriptionCancellationModal.trigger( 'showModal' );
} else {
if ( $modal.hasClass( 'no-confirmation-message' ) && ! showDeactivationFeedbackForm ) {
deactivateModule();
} else {
showModal();
}
}
});
<?php
} ?>
$modal.on('input propertychange', '.reason-input input', function () {
if (!isOtherReasonSelected()) {
return;
}
var reason = $(this).val().trim();
/**
* If reason is not empty, remove the error-message class of the message container
* to change the message color back to default.
*/
if (reason.length > 0) {
$('.message').removeClass('error-message');
enableDeactivateButton();
}
});
$modal.on('blur', '.reason-input input', function () {
var $userReason = $(this);
setTimeout(function () {
if (!isOtherReasonSelected()) {
return;
}
/**
* If reason is empty, add the error-message class to the message container
* to change the message color to red.
*/
if (0 === $userReason.val().trim().length) {
$('.message').addClass('error-message');
disableDeactivateButton();
}
}, 150);
});
$modal.on('click', '.fs-modal-footer .button', function (evt) {
evt.preventDefault();
if ($(this).hasClass('disabled')) {
return;
}
var _parent = $(this).parents('.fs-modal:first');
var _this = $(this);
if (_this.hasClass('allow-deactivate')) {
var $radio = $modal.find('input[type="radio"]:checked');
if (0 === $radio.length) {
if ( ! deleteThemeUpdateData ) {
// If no selected reason, just deactivate the plugin.
window.location.href = redirectLink;
} else {
$.ajax({
url : ajaxurl,
method : 'POST',
data : {
action : '<?php echo $fs->get_ajax_action( 'delete_theme_update_data' ) ?>',
security : '<?php echo $fs->get_ajax_security( 'delete_theme_update_data' ) ?>',
module_id: '<?php echo $fs->get_id() ?>'
},
beforeSend: function() {
_parent.find( '.fs-modal-footer .button' ).addClass( 'disabled' );
_parent.find( '.fs-modal-footer .button-secondary' ).text( 'Processing...' );
},
complete : function() {
window.location.href = redirectLink;
}
});
}
return;
}
var $selected_reason = $radio.parents('li:first'),
$input = $selected_reason.find('textarea, input[type="text"]'),
userReason = ( 0 !== $input.length ) ? $input.val().trim() : '';
if (isOtherReasonSelected() && ( '' === userReason )) {
return;
}
$.ajax({
url : ajaxurl,
method : 'POST',
data : {
action : '<?php echo $fs->get_ajax_action( 'submit_uninstall_reason' ) ?>',
security : '<?php echo $fs->get_ajax_security( 'submit_uninstall_reason' ) ?>',
module_id : '<?php echo $fs->get_id() ?>',
reason_id : $radio.val(),
reason_info : userReason,
is_anonymous: isAnonymousFeedback()
},
beforeSend: function () {
_parent.find('.fs-modal-footer .button').addClass('disabled');
_parent.find('.fs-modal-footer .button-secondary').text('Processing...');
},
complete : function () {
// Do not show the dialog box, deactivate the plugin.
window.location.href = redirectLink;
}
});
} else if (_this.hasClass('button-deactivate')) {
// Change the Deactivate button's text and show the reasons panel.
_parent.find('.button-deactivate').addClass('allow-deactivate');
if ( showDeactivationFeedbackForm ) {
showPanel('reasons');
} else {
deactivateModule();
}
}
});
$modal.on('click', 'input[type="radio"]', function () {
var $selectedReasonOption = $( this );
// If the selection has not changed, do not proceed.
if (selectedReasonID === $selectedReasonOption.val())
return;
selectedReasonID = $selectedReasonOption.val();
if ( isAnonymous ) {
if ( isReasonSelected( dontShareDataReasonID ) ) {
$anonymousFeedback.hide();
} else {
$anonymousFeedback.show();
}
}
var _parent = $(this).parents('li:first');
$modal.find('.reason-input').remove();
$modal.find( '.internal-message' ).hide();
$modal.find('.button-deactivate').html('<?php echo esc_js( sprintf(
fs_text_inline( 'Submit & %s', 'deactivation-modal-button-submit' , $slug ),
$fs->is_plugin() ?
$deactivate_text :
sprintf( $activate_x_text, $theme_text )
) ) ?>');
enableDeactivateButton();
if ( _parent.hasClass( 'has-internal-message' ) ) {
_parent.find( '.internal-message' ).show();
}
if (_parent.hasClass('has-input')) {
var inputType = _parent.data('input-type'),
inputPlaceholder = _parent.data('input-placeholder'),
reasonInputHtml = '<div class="reason-input"><span class="message"></span>' + ( ( 'textfield' === inputType ) ? '<input type="text" maxlength="128" />' : '<textarea rows="5" maxlength="128"></textarea>' ) + '</div>';
_parent.append($(reasonInputHtml));
_parent.find('input, textarea').attr('placeholder', inputPlaceholder).focus();
if (isOtherReasonSelected()) {
showMessage('<?php echo esc_js( fs_text_inline( 'Kindly tell us the reason so we can improve.', 'ask-for-reason-message' , $slug ) ); ?>');
disableDeactivateButton();
}
}
});
// If the user has clicked outside the window, cancel it.
$modal.on('click', function (evt) {
var $target = $(evt.target);
// If the user has clicked anywhere in the modal dialog, just return.
if ($target.hasClass('fs-modal-body') || $target.hasClass('fs-modal-footer')) {
return;
}
// If the user has not clicked the close button and the clicked element is inside the modal dialog, just return.
if (
! $target.hasClass( 'button-close' ) &&
( $target.parents( '.fs-modal-body' ).length > 0 || $target.parents( '.fs-modal-footer' ).length > 0 )
) {
return;
}
closeModal();
return false;
});
}
function isAnonymousFeedback() {
if ( ! isAnonymous ) {
return false;
}
return ( isReasonSelected( dontShareDataReasonID ) || $anonymousFeedback.find( 'input' ).prop( 'checked' ) );
}
function isReasonSelected( reasonID ) {
// Get the selected radio input element.
var $selectedReasonOption = $modal.find('input[type="radio"]:checked');
return ( reasonID == $selectedReasonOption.val() );
}
function isOtherReasonSelected() {
return isReasonSelected( otherReasonID );
}
function showModal() {
resetModal();
// Display the dialog box.
$modal.addClass('active');
$('body').addClass('has-fs-modal');
}
function closeModal() {
$modal.removeClass('active');
$('body').removeClass('has-fs-modal');
}
function resetModal() {
selectedReasonID = false;
enableDeactivateButton();
// Uncheck all radio buttons.
$modal.find('input[type="radio"]').prop('checked', false);
// Remove all input fields ( textfield, textarea ).
$modal.find('.reason-input').remove();
$modal.find('.message').hide();
if ( isAnonymous ) {
$anonymousFeedback.find( 'input' ).prop( 'checked', false );
// Hide, since by default there is no selected reason.
$anonymousFeedback.hide();
}
var $deactivateButton = $modal.find('.button-deactivate');
/*
* If the modal dialog has no confirmation message, that is, it has only one panel, then ensure
* that clicking the deactivate button will actually deactivate the plugin.
*/
if ( $modal.hasClass( 'no-confirmation-message' ) ) {
$deactivateButton.addClass( 'allow-deactivate' );
showPanel( 'reasons' );
} else {
$deactivateButton.removeClass( 'allow-deactivate' );
showPanel( 'confirm' );
}
}
function showMessage(message) {
$modal.find('.message').text(message).show();
}
function enableDeactivateButton() {
$modal.find('.button-deactivate').removeClass('disabled');
}
function disableDeactivateButton() {
$modal.find('.button-deactivate').addClass('disabled');
}
function showPanel(panelType) {
$modal.find( '.fs-modal-panel' ).removeClass( 'active' );
$modal.find( '[data-panel-id="' + panelType + '"]' ).addClass( 'active' );
updateButtonLabels();
}
function updateButtonLabels() {
var $deactivateButton = $modal.find( '.button-deactivate' );
// Reset the deactivate button's text.
if ( 'confirm' === getCurrentPanel() ) {
$deactivateButton.text( <?php echo json_encode( sprintf(
fs_text_inline( 'Yes - %s', 'deactivation-modal-button-confirm', $slug ),
$fs->is_plugin() ?
$deactivate_text :
sprintf( $activate_x_text, $theme_text )
) ) ?> );
} else {
$deactivateButton.html( <?php echo json_encode( sprintf(
fs_text_inline('Skip & %s', 'skip-and-x', $slug ),
$fs->is_plugin() ?
$deactivate_text :
sprintf( $activate_x_text, $theme_text )
) ) ?> );
}
}
function getCurrentPanel() {
return $modal.find('.fs-modal-panel.active').attr('data-panel-id');
}
/**
* @author Leo Fajardo (@leorw)
*
* @since 2.3.0
*/
function deactivateModule() {
window.location.href = redirectLink;
}
})(jQuery);
</script>

View File

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

View File

@ -0,0 +1,24 @@
<?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.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* @var array $VARS
*/
$fs = freemius( $VARS['id'] );
$slug = $fs->get_slug();
$skip_url = fs_nonce_url( $fs->_get_admin_page_url( '', array( 'fs_action' => $fs->get_unique_affix() . '_skip_activation' ) ), $fs->get_unique_affix() . '_skip_activation' );
$skip_text = strtolower( fs_text_x_inline( 'Skip', 'verb', 'skip', $slug ) );
$use_plugin_anonymously_text = fs_text_inline( 'Click here to use the plugin anonymously', 'click-here-to-use-plugin-anonymously', $slug );
echo sprintf( fs_text_inline( "You might have missed it, but you don't have to share any data and can just %s the opt-in.", 'dont-have-to-share-any-data', $slug ), "<a href='{$skip_url}'>{$skip_text}</a>" )
. " <a href='{$skip_url}' class='button button-small button-secondary'>{$use_plugin_anonymously_text}</a>";

View File

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

View File

@ -0,0 +1,870 @@
<?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.9
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* @var array $VARS
*
* @var Freemius $fs
*/
$fs = freemius( $VARS['id'] );
$slug = $fs->get_slug();
$unique_affix = $fs->get_unique_affix();
$cant_find_license_key_text = fs_text_inline( "Can't find your license key?", 'cant-find-license-key', $slug );
$message_above_input_field = fs_text_inline( 'Please enter the license key that you received in the email right after the purchase:', 'activate-license-message', $slug );
$message_below_input_field = '';
$header_title = $fs->is_free_plan() ?
fs_text_inline( 'Activate License', 'activate-license', $slug ) :
fs_text_inline( 'Update License', 'update-license', $slug );
if ( $fs->is_registered() ) {
$activate_button_text = $header_title;
} else {
$freemius_site_url = $fs->has_paid_plan() ?
'https://freemius.com/' :
// Insights platform information.
$fs->get_usage_tracking_terms_url();
$freemius_link = '<a href="' . $freemius_site_url . '" target="_blank" rel="noopener" tabindex="0">freemius.com</a>';
$message_below_input_field = sprintf(
fs_text_inline( 'The %1$s will be periodically sending data to %2$s to check for security and feature updates, and verify the validity of your license.', 'license-sync-disclaimer', $slug ),
$fs->get_module_label( true ),
$freemius_link
);
$activate_button_text = fs_text_inline( 'Agree & Activate License', 'agree-activate-license', $slug );
}
$license_key_text = fs_text_inline( 'License key', 'license-key' , $slug );
$is_network_activation = (
$fs->is_network_active() &&
fs_is_network_admin() &&
! $fs->is_delegated_connection()
);
$network_activation_html = '';
$sites_details = array();
if ( $is_network_activation ) {
$all_sites = Freemius::get_sites();
foreach ( $all_sites as $site ) {
$site_details = $fs->get_site_info( $site );
$blog_id = Freemius::get_site_blog_id( $site );
$install = $fs->get_install_by_blog_id($blog_id);
if ( is_object( $install ) && FS_Plugin_License::is_valid_id( $install->license_id ) ) {
$site_details['license_id'] = $install->license_id;
}
$sites_details[] = $site_details;
}
if ( $is_network_activation ) {
$vars = array(
'id' => $fs->get_id(),
'sites' => $sites_details,
'require_license_key' => true
);
$network_activation_html = fs_get_template( 'partials/network-activation.php', $vars );
}
}
$premium_licenses = $fs->get_available_premium_licenses();
$available_licenses = array();
foreach ( $premium_licenses as $premium_license ) {
$activations_left = $premium_license->left();
if ( ! ( $activations_left > 0 ) ) {
continue;
}
$available_licenses[ $activations_left . '_' . $premium_license->id ] = $premium_license;
}
$total_available_licenses = count( $available_licenses );
if ( $total_available_licenses > 0 ) {
$license_input_html = <<< HTML
<div class="fs-license-options-container">
<table>
<tbody>
<tr class="fs-available-license-key-container">
<td><input type="radio" name="license_type" value="available"></td>
<td>
HTML;
if ( $total_available_licenses > 1 ) {
// Sort the licenses by number of activations left in descending order.
krsort( $available_licenses );
$license_input_html .= '<select class="fs-licenses">';
/**
* @var FS_Plugin_License $license
*/
foreach ( $available_licenses as $license ) {
$plan = $fs->_get_plan_by_id( $license->plan_id );
$label = sprintf(
"%s-Site %s License - %s",
( 1 == $license->quota ?
'Single' :
( $license->is_unlimited() ? 'Unlimited' : $license->quota )
),
( is_object( $plan ) ? $plan->title : '' ),
$license->get_html_escaped_masked_secret_key()
);
$license_input_html .= "<option data-id='{$license->id}' value='{$license->secret_key}' data-left='{$license->left()}'>{$label}</option>";
}
$license_input_html .= '</select>';
} else {
$available_licenses = array_values( $available_licenses );
/**
* @var FS_Plugin_License $available_license
*/
$available_license = $available_licenses[0];
$value = sprintf(
"%s-Site %s License - %s",
( 1 == $available_license->quota ?
'Single' :
( $available_license->is_unlimited() ? 'Unlimited' : $available_license->quota )
),
$fs->_get_plan_by_id( $available_license->plan_id )->title,
$available_license->get_html_escaped_masked_secret_key()
);
$license_input_html .= <<< HTML
<input
class="fs-available-license-key"
type="text"
value="{$value}"
data-id="{$available_license->id}"
data-license-key="{$available_license->secret_key}"
data-left="{$available_license->left()}"
readonly />
HTML;
}
$license_input_html .= <<< HTML
</td>
</tr>
<tr>
<td><input type="radio" name="license_type" value="other"></td>
<td class="fs-other-license-key-container">
<label for="other_license_key_{$unique_affix}">Other: </label>
<div>
<input id="other_license_key_{$unique_affix}" class="fs-license-key" type="text" placeholder="Enter license key" tabindex="1">
</div>
</td>
</tr>
</tbody>
</table>
</div>
HTML;
} else {
$license_input_html = "<input class='fs-license-key' type='text' placeholder='{$license_key_text}' tabindex='1' />";
}
$ownership_change_option_text = fs_text_inline( "Associate with the license owner's account.", 'associate-account-with-license-owner', $slug );
$ownership_change_option_html = "<div class='ownership-change-option-container' style='display: none'><label><input type='checkbox' /> <strong>{$ownership_change_option_text}</strong></label></div>";
/**
* IMPORTANT:
* DO NOT ADD MAXLENGTH OR LIMIT THE LICENSE KEY LENGTH SINCE
* WE DO WANT TO ALLOW INPUT OF LONGER KEYS (E.G. WooCommerce Keys)
* FOR MIGRATED MODULES.
*/
$modal_content_html = <<< HTML
<div class="notice notice-error inline license-activation-message"><p></p></div>
<p>{$message_above_input_field}</p>
{$license_input_html}
<a class="show-license-resend-modal show-license-resend-modal-{$fs->get_unique_affix()}" href="!#" tabindex="2">{$cant_find_license_key_text}</a>
{$network_activation_html}
<p>{$message_below_input_field}</p>
{$ownership_change_option_html}
HTML;
/**
* Handle the ownership change option if not an add-on or if no license yet is activated for the
* parent product in case of an add-on.
*
* @author Leo Fajardo (@leorw)
* @since 2.3.2
*/
$is_user_change_supported = ( ! $fs->is_addon() || ! $fs->get_parent_instance()->has_active_valid_license() );
fs_enqueue_local_style( 'fs_dialog_boxes', '/admin/dialog-boxes.css' );
?>
<script type="text/javascript">
(function( $ ) {
$( document ).ready(function() {
var modalContentHtml = <?php echo json_encode($modal_content_html); ?>,
modalHtml =
'<div class="fs-modal fs-modal-license-activation fs-modal-license-activation-<?php echo $unique_affix ?>">'
+ ' <div class="fs-modal-dialog">'
+ ' <div class="fs-modal-header">'
+ ' <h4><?php echo esc_js($header_title) ?></h4>'
+ ' <a href="!#" class="fs-close"><i class="dashicons dashicons-no" title="<?php echo esc_js( fs_text_x_inline( 'Dismiss', 'as close a window', 'dismiss', $slug ) ) ?>"></i></a>'
+ ' </div>'
+ ' <div class="fs-modal-body">'
+ ' <div class="fs-modal-panel active">' + modalContentHtml + '</div>'
+ ' </div>'
+ ' <div class="fs-modal-footer">'
+ ' <button class="button button-secondary button-close" tabindex="4"><?php fs_esc_js_echo_inline( 'Cancel', 'cancel', $slug ) ?></button>'
+ ' <button class="button button-primary button-activate-license" tabindex="3"><?php echo esc_js( $activate_button_text ) ?></button>'
+ ' </div>'
+ ' </div>'
+ '</div>',
$modal = $(modalHtml),
$activateLicenseButton = $modal.find('.button-activate-license'),
$licenseKeyInput = $modal.find( 'input.fs-license-key' ),
$licenseActivationMessage = $modal.find( '.license-activation-message' ),
isNetworkActivation = <?php echo $is_network_activation ? 'true' : 'false' ?>,
isUserChangeSupported = <?php echo $is_user_change_supported ? 'true' : 'false' ?>,
isSingleSiteActivation = false,
$ownershipChangeOptionContainer = $modal.find( '.ownership-change-option-container' ),
$body = $( 'body' );
$modal.appendTo( $body );
var
$licensesDropdown = $modal.find( '.fs-licenses' ),
$licenseTypes = $modal.find( 'input[type="radio"][name="license_type"]' ),
$applyOnAllSites = $modal.find( '.fs-apply-on-all-sites-checkbox' ),
$sitesListContainer = $modal.find( '.fs-sites-list-container' ),
$availableLicenseKey = $modal.find( '.fs-available-license-key' ),
$otherLicenseKey = $modal.find( '#other_license_key_<?php echo $unique_affix ?>' ),
$multisiteOptionsContainer = $modal.find( '.fs-multisite-options-container' ),
$activationsLeft = null,
hasLicensesDropdown = ( $licensesDropdown.length > 0 ),
hasLicenseTypes = ( $licenseTypes.length > 0 ),
maxSitesListHeight = null,
totalSites = <?php echo count( $sites_details ) ?>,
singleBlogID = null;
var
previousLicenseKey = null,
otherLicenseOwnerID = null,
/**
* @author Leo Fajardo (@leorw)
* @since 2.3.2
*/
resetLoadingMode = function () {
// Reset loading mode.
$activateLicenseButton.text( <?php echo json_encode( $activate_button_text ) ?> );
$activateLicenseButton.prop( 'disabled', false );
$( document.body ).css( { 'cursor': 'auto' } );
$( '.fs-loading' ).removeClass( 'fs-loading' );
console.log( 'resetLoadingMode - Primary button was enabled' );
},
/**
* @author Leo Fajardo (@leorw)
* @since 2.3.2
*/
setLoadingMode = function () {
$( document.body ).css( { 'cursor': 'wait' } );
},
/**
* @author Leo Fajardo (@leorw)
* @since 2.3.2
*/
afterLicenseUserDataLoaded = function () {
if (
null !== otherLicenseOwnerID &&
otherLicenseOwnerID != <?php echo $fs->is_registered() ? $fs->get_user()->id : 'null' ?>
) {
$ownershipChangeOptionContainer.show();
} else {
$ownershipChangeOptionContainer.hide();
$activateLicenseButton.focus();
}
},
/**
* @author Leo Fajardo (@leorw)
* @since 2.3.2
*/
fetchLicenseUserData = function () {
var hideAndUncheckUserChangeCheckbox = ( ! isUserChangeSupported ),
otherLicenseKeyIsSelected = isOtherLicenseKeySelected();
if ( ! hideAndUncheckUserChangeCheckbox ) {
// User change is supported only on the site level.
hideAndUncheckUserChangeCheckbox = ( isNetworkActivation || isSingleSiteActivation );
}
if ( ! hideAndUncheckUserChangeCheckbox ) {
hideAndUncheckUserChangeCheckbox = ( hasLicenseTypes && ! otherLicenseKeyIsSelected );
}
var licenseKey = $licenseKeyInput.val().trim();
if ( ! hideAndUncheckUserChangeCheckbox && otherLicenseKeyIsSelected ) {
hideAndUncheckUserChangeCheckbox = ( licenseKey.length < 32 );
}
if ( licenseKey !== previousLicenseKey ) {
// If the license key has not been changed, keep the owner ID in order to prevent another API call.
otherLicenseOwnerID = null;
}
if ( hideAndUncheckUserChangeCheckbox ) {
$ownershipChangeOptionContainer.hide().find( 'input' ).attr( 'checked', false );
return;
}
if ( null !== otherLicenseOwnerID ) {
afterLicenseUserDataLoaded();
return;
}
setLoadingMode();
$activateLicenseButton.addClass( 'fs-loading' );
$activateLicenseButton.attr( 'disabled', 'disabled' );
$activateLicenseButton.html( '<?php fs_esc_js_echo_inline( 'Please wait', 'please-wait', $slug ) ?>...' );
$.ajax( {
url : ajaxurl,
method : 'POST',
data : {
action : '<?php echo $fs->get_ajax_action( 'fetch_is_marketing_required_flag_value' ) ?>',
security : '<?php echo $fs->get_ajax_security( 'fetch_is_marketing_required_flag_value' ) ?>',
license_key: licenseKey,
module_id : '<?php echo $fs->get_id() ?>'
},
success: function ( result ) {
resetLoadingMode();
if ( result.success ) {
result = result.data;
// Cache license owner's ID.
otherLicenseOwnerID = result.license_owner_id;
}
afterLicenseUserDataLoaded();
}
} );
};
function registerEventHandlers() {
var
$otherLicenseKeyContainer = $modal.find( '.fs-other-license-key-container' );
if ( isNetworkActivation ) {
$applyOnAllSites.click(function() {
var applyOnAllSites = $( this ).is( ':checked' );
$multisiteOptionsContainer.toggleClass( 'fs-apply-on-all-sites', applyOnAllSites );
showSites( ! applyOnAllSites );
if ( hasValidLicenseKey() && ( applyOnAllSites || hasSelectedSite() ) ) {
enableActivateLicenseButton();
} else {
disableActivateLicenseButton();
}
});
$sitesListContainer.delegate( 'td:not(:first-child)', 'click', function() {
// If a site row is clicked, trigger a click on the checkbox.
$( this ).parent().find( 'td:first-child input' ).click();
});
$sitesListContainer.delegate( 'input[type="checkbox"]', 'click', function() {
enableDisableSitesSelection();
if ( hasValidLicenseKey() && hasSelectedSite() ) {
enableActivateLicenseButton();
} else {
disableActivateLicenseButton();
}
});
}
if ( hasLicensesDropdown ) {
$licensesDropdown.change(function() {
// When a license is selected, select the associated radio button.
$licenseTypes.filter( '[value="available"]' ).attr( 'checked', true );
if ( ! isNetworkActivation || $modal.hasClass( 'is-single-site-activation' ) ) {
enableActivateLicenseButton();
return true;
}
toggleActivationOnAllSites();
})
}
if ( hasLicenseTypes ) {
$licenseTypes.change(function() {
var
licenseKey = $modal.find( 'input.fs-license-key' ).val().trim(),
otherLicenseKeySelected = isOtherLicenseKeySelected();
if ( ( licenseKey.length > 0 || ( hasLicenseTypes && ! otherLicenseKeySelected ) ) &&
( $modal.hasClass( 'is-single-site-activation' ) || ! isNetworkActivation || hasSelectedSite() )
) {
/**
* If the "other" license is not empty or an available license is selected, enable the activate
* button.
*
* @author Leo Fajardo (@leorw)
*/
enableActivateLicenseButton();
} else {
disableActivateLicenseButton();
}
if ( '' !== licenseKey ) {
fetchLicenseUserData();
}
if ( ! isNetworkActivation ) {
return;
}
if ( otherLicenseKeySelected ) {
$applyOnAllSites.attr( 'disabled', false );
enableDisableSitesSelection();
resetActivateLicenseCheckboxLabel();
} else if ( ! $modal.hasClass( 'is-single-site-activation' ) ) {
toggleActivationOnAllSites();
}
});
if ( ! hasLicensesDropdown ) {
$availableLicenseKey.click(function() {
$licenseTypes.filter( '[value="available"]' ).click();
});
}
$otherLicenseKeyContainer.click(function() {
$licenseTypes.filter( '[value="other"]' ).click();
});
}
$body.on( 'click', 'span.activate-license.<?php echo $unique_affix ?> a, .activate-license-trigger.<?php echo $unique_affix ?>', function (evt) {
evt.preventDefault();
showModal( evt );
});
var licenseTimeout = null;
/**
* Disable activation button when license key is empty.
*
* @author Leo Fajardo (@leorw)
* @since 2.3.2
*/
$modal.on( 'keyup paste delete cut', 'input.fs-license-key', function () {
clearTimeout(licenseTimeout);
licenseTimeout = setTimeout( function () {
var licenseKey = $licenseKeyInput.val().trim();
if ( licenseKey == previousLicenseKey ) {
afterLicenseUserDataLoaded();
return;
}
if ( '' === licenseKey ) {
disableActivateLicenseButton();
$ownershipChangeOptionContainer.hide();
} else {
enableActivateLicenseButton();
if ( 32 <= licenseKey.length ) {
fetchLicenseUserData();
} else {
$ownershipChangeOptionContainer.hide();
}
}
previousLicenseKey = licenseKey;
}, 200 );
} ).focus();
$modal.on('input propertychange', 'input.fs-license-key', function () {
var licenseKey = $(this).val().trim();
/**
* If license key is not empty, enable the license activation button.
*/
if ( licenseKey.length > 0 && ( $modal.hasClass( 'is-single-site-activation' ) || ! isNetworkActivation || hasSelectedSite() ) ) {
enableActivateLicenseButton();
}
});
$modal.on( 'blur', 'input.fs-license-key', function( evt ) {
var
licenseKey = $(this).val().trim(),
$focusedElement = $( evt.relatedTarget ),
hasSelectedAvailableLicense = ( hasLicenseTypes && $focusedElement.parents( '.fs-available-license-key-container' ).length > 0 );
/**
* If license key is empty, disable the license activation button.
*/
if ( ( 0 === licenseKey.length && ( ! hasLicenseTypes || ! hasSelectedAvailableLicense ) ) ||
( isNetworkActivation && ! hasSelectedSite() )
) {
disableActivateLicenseButton();
}
});
$modal.on('click', '.button-activate-license', function (evt) {
evt.preventDefault();
if ($(this).hasClass('disabled')) {
return;
}
var
licenseKey = '';
if ( hasLicenseTypes ) {
if ( isOtherLicenseKeySelected() ) {
licenseKey = $otherLicenseKey.val();
} else {
if ( ! hasLicensesDropdown ) {
licenseKey = $availableLicenseKey.data( 'license-key' );
} else {
licenseKey = $licensesDropdown.val();
}
}
} else {
licenseKey = $licenseKeyInput.val().trim();
}
disableActivateLicenseButton();
if (0 === licenseKey.length) {
return;
}
var data = {
action : '<?php echo $fs->get_ajax_action( 'activate_license' ) ?>',
security : '<?php echo $fs->get_ajax_security( 'activate_license' ) ?>',
license_key: licenseKey,
module_id : '<?php echo $fs->get_id() ?>'
};
if ( isNetworkActivation ) {
var
sites = [];
if ( null === singleBlogID ) {
var
applyOnAllSites = $applyOnAllSites.is( ':checked' );
$sitesListContainer.find( 'tr' ).each(function() {
var
$this = $( this ),
includeSite = ( applyOnAllSites || $this.find( 'input' ).is( ':checked' ) );
if ( ! includeSite )
return;
var site = {
uid : $this.find( '.uid' ).val(),
url : $this.find( '.url' ).val(),
title : $this.find( '.title' ).val(),
language: $this.find( '.language' ).val(),
charset : $this.find( '.charset' ).val(),
blog_id : $this.find( '.blog-id' ).find( 'span' ).text()
};
sites.push( site );
});
} else {
data.blog_id = singleBlogID;
}
data.sites = sites;
}
if ( $ownershipChangeOptionContainer.find( 'input:checked' ).length > 0 ) {
data.user_id = otherLicenseOwnerID;
}
$.ajax({
url: ajaxurl,
method: 'POST',
data: data,
beforeSend: function () {
$activateLicenseButton.text( '<?php fs_esc_js_echo_inline( 'Activating license', 'activating-license', $slug ) ?>...' );
},
success: function( result ) {
var resultObj = $.parseJSON( result );
if ( resultObj.success ) {
closeModal();
// Redirect to the "Account" page and sync the license.
window.location.href = resultObj.next_page;
} else {
showError( resultObj.error.message ? resultObj.error.message : resultObj.error );
resetActivateLicenseButton();
}
}
});
});
// If the user has clicked outside the window, close the modal.
$modal.on('click', '.fs-close, .button-secondary', function () {
closeModal();
return false;
});
}
registerEventHandlers();
$body.trigger('licenseActivationLoaded');
/**
* @author Leo Fajardo (@leorw)
* @since 2.0.0
*/
function enableDisableSitesSelection() {
var
canApplyOnAllSites = $applyOnAllSites.is( ':enabled' ),
disableSitesSelection = null;
if ( ! canApplyOnAllSites ) {
var
selectedSites = $sitesListContainer.find( 'input[type="checkbox"]:checked' ).length,
activationsLeft = Math.max( 0, $activationsLeft.data( 'left' ) - selectedSites );
disableSitesSelection = ( 0 === activationsLeft );
$activationsLeft.text( activationsLeft );
} else {
disableSitesSelection = false;
}
$sitesListContainer
.find( 'input[type="checkbox"]:not(:checked)' )
.attr( 'disabled', disableSitesSelection );
}
/**
* @author Leo Fajardo (@leorw)
* @since 2.0.0
*
* @returns {Boolean}
*/
function isOtherLicenseKeySelected() {
return ( hasLicenseTypes && 'other' === $licenseTypes.filter( ':checked' ).val() );
}
/**
* @author Leo Fajardo (@leorw)
* @since 2.0.0
*
* @returns {Boolean}
*/
function hasValidLicenseKey() {
var licenseKey = '';
if ( hasLicenseTypes ) {
if ( 'available' === $licenseTypes.filter( ':checked' ).val() ) {
return true;
} else {
licenseKey = $otherLicenseKey.val();
}
} else {
licenseKey = $modal.find( 'input.fs-license-key' ).val();
}
return ( licenseKey.trim().length > 0 );
}
/**
* @author Leo Fajardo (@leorw)
* @since 2.0.0
*
* @returns {Boolean}
*/
function hasSelectedSite() {
return ( $applyOnAllSites.is( ':checked' ) ||
$sitesListContainer.find( 'input[type="checkbox"]:checked:not(:disabled)' ).length > 0 );
}
/**
* @author Leo Fajardo (@leorw)
* @since 2.0.0
*/
function toggleActivationOnAllSites() {
var activationsLeft,
licenseID;
if (hasLicensesDropdown) {
var $selectedOption = $licensesDropdown.find( ':selected' );
activationsLeft = $selectedOption.data('left');
licenseID = $selectedOption.data('id');
} else {
activationsLeft = $availableLicenseKey.data('left');
licenseID = $availableLicenseKey.data('id');
}
// Cleanup previously auto-selected site.
$modal.find( '.fs-sites-list-container input[type=checkbox]:disabled' )
.attr('disabled', false)
.attr('checked', false);
var $blogsWithActiveLicense = $modal.find( '.fs-sites-list-container tr[data-license-id=' + licenseID + '] input[type=checkbox]' );
if ($blogsWithActiveLicense.length > 0) {
$blogsWithActiveLicense.attr('checked', true)
.attr('disabled', true);
activationsLeft += $blogsWithActiveLicense.length;
}
if ( activationsLeft >= totalSites ) {
$applyOnAllSites.attr( 'disabled', false );
enableDisableSitesSelection();
resetActivateLicenseCheckboxLabel();
return;
}
$applyOnAllSites.attr( 'checked', false );
$applyOnAllSites.attr( 'disabled', true );
showSites( true );
var
activateLicenseCheckboxLabel = '<?php fs_esc_js_echo_inline( 'Choose up to %s site(s) to activate the license on.', 'choose-up-to-n-sites-to-activate-the-license-on', $slug ) ?>';
activateLicenseCheckboxLabel = activateLicenseCheckboxLabel.replace( '%s', '<span data-left="' + activationsLeft + '" class="activations-left">' + activationsLeft + '</span>' );
// Update the label of the "Activate license on all sites" checkbox.
$applyOnAllSites.parent().find( 'span' ).html( activateLicenseCheckboxLabel );
$activationsLeft = $modal.find( '.activations-left' );
if ( hasSelectedSite() ) {
enableActivateLicenseButton();
enableDisableSitesSelection();
} else {
disableActivateLicenseButton();
}
}
/**
* @author Leo Fajardo (@leorw)
* @since 2.0.0
*/
function resetActivateLicenseCheckboxLabel() {
var activateLicenseCheckboxLabel = '<?php fs_esc_js_echo_inline( 'Activate license on all sites in the network.', 'activate-license-on-all-sites-in-the-network', $slug ) ?>';
$applyOnAllSites.parent().find( 'span' ).text( activateLicenseCheckboxLabel );
}
/**
* @author Leo Fajardo (@leorw)
* @since 2.0.0
*
* @param {Boolean} show
*/
function showSites( show ) {
$sitesListContainer.toggle( show );
if ( show && null === maxSitesListHeight ) {
/**
* Set the visible number of rows to 5 (5 * height of the first row).
*
* @author Leo Fajardo (@leorw)
*/
maxSitesListHeight = ( 5 * $sitesListContainer.find( 'tr:first' ).height() );
$sitesListContainer.css( 'max-height', maxSitesListHeight );
}
}
function showModal( evt ) {
resetModal();
// Display the dialog box.
$modal.addClass('active');
$body.addClass('has-fs-modal');
var
$singleInstallDetails = $( evt.target ).parents( 'tr.fs-install-details' ),
isSingleSiteActivation = ( $singleInstallDetails.length > 0 );
$modal.toggleClass( 'is-single-site-activation', isSingleSiteActivation );
singleBlogID = isSingleSiteActivation ?
$singleInstallDetails.prev().data( 'blog-id' ) :
null;
<?php if ( $fs->apply_filters( 'enable_per_site_activation', true ) ) : ?>
$multisiteOptionsContainer.toggle( isNetworkActivation && ! isSingleSiteActivation );
<?php endif ?>
if ( hasLicenseTypes ) {
$licenseTypes.attr( 'checked', false );
if ( hasLicensesDropdown ) {
$licensesDropdown.find( 'option:first' ).attr( 'selected', true ).trigger( 'change' );
} else {
$licenseTypes.filter( '[value="available"]' ).click();
}
$otherLicenseKey.val( '' );
} else {
$licenseKeyInput.val( '' );
$licenseKeyInput.focus();
}
}
function closeModal() {
$modal.removeClass('active');
$body.removeClass('has-fs-modal');
}
function resetActivateLicenseButton() {
enableActivateLicenseButton();
$activateLicenseButton.text( <?php echo json_encode( $activate_button_text ) ?> );
}
function resetModal() {
hideError();
resetActivateLicenseButton();
}
function enableActivateLicenseButton() {
$activateLicenseButton.removeClass( 'disabled' );
}
function disableActivateLicenseButton() {
$activateLicenseButton.addClass( 'disabled' );
}
function hideError() {
$licenseActivationMessage.hide();
}
function showError( msg ) {
$licenseActivationMessage.find( ' > p' ).html( msg );
$licenseActivationMessage.show();
}
});
})( jQuery );
</script>

View File

@ -0,0 +1,336 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.2.1.5
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* @var array $VARS
* @var Freemius $fs
*/
$fs = freemius( $VARS['id'] );
$slug = $fs->get_slug();
$action = $fs->is_tracking_allowed() ?
'stop_tracking' :
'allow_tracking';
$reconnect_url = $fs->get_activation_url( array(
'nonce' => wp_create_nonce( $fs->get_unique_affix() . '_reconnect' ),
'fs_action' => ( $fs->get_unique_affix() . '_reconnect' ),
) );
$plugin_title = "<strong>{$fs->get_plugin()->title}</strong>";
$opt_out_text = fs_text_x_inline( 'Opt Out', 'verb', 'opt-out', $slug );
$opt_in_text = fs_text_x_inline( 'Opt In', 'verb', 'opt-in', $slug );
if ( $fs->is_premium() ) {
$opt_in_message_appreciation = fs_text_inline( 'Connectivity to the licensing engine was successfully re-established. Automatic security & feature updates are now available through the WP Admin Dashboard.', 'premium-opt-in-message-appreciation', $slug );
$opt_out_message_subtitle = sprintf( fs_text_inline( 'Warning: Opting out will block automatic updates', 'premium-opt-out-message-appreciation', $slug ), $fs->get_module_type() );
$opt_out_message_usage_tracking = sprintf( fs_text_inline( 'Ongoing connectivity with the licensing engine is essential for receiving automatic security & feature updates of the paid product. To receive these updates, data like your license key, %1$s version, and WordPress version, is periodically sent to the server to check for updates. By opting out, you understand that your site won\'t receive automatic updates for %2$s from within the WP Admin Dashboard. This can put your site at risk, and we highly recommend to keep this connection active. If you do choose to opt-out, you\'ll need to check for %1$s updates and install them manually.', 'premium-opt-out-message-usage-tracking', $slug ), $fs->get_module_type(), $plugin_title );
$primary_cta_label = fs_text_inline( 'I\'d like to keep automatic updates', 'premium-opt-out-cancel', $slug );
} else {
$opt_in_message_appreciation = sprintf( fs_text_inline( 'We appreciate your help in making the %s better by letting us track some usage data.', 'opt-in-message-appreciation', $slug ), $fs->get_module_type() );
$opt_out_message_subtitle = $opt_in_message_appreciation;
$opt_out_message_usage_tracking = sprintf( fs_text_inline( "Usage tracking is done in the name of making %s better. Making a better user experience, prioritizing new features, and more good things. We'd really appreciate if you'll reconsider letting us continue with the tracking.", 'opt-out-message-usage-tracking', $slug ), $plugin_title );
$primary_cta_label = fs_text_inline( 'On second thought - I want to continue helping', 'opt-out-cancel', $slug );
}
$opt_out_message_clicking_opt_out = sprintf(
fs_text_inline( 'By clicking "Opt Out", we will no longer be sending any data from %s to %s.', 'opt-out-message-clicking-opt-out', $slug ),
$plugin_title,
sprintf(
'<a href="%s" target="_blank" rel="noopener">%s</a>',
'https://freemius.com',
'freemius.com'
)
);
$admin_notice_params = array(
'id' => '',
'slug' => $fs->get_id(),
'type' => 'success',
'sticky' => false,
'plugin' => $fs->get_plugin()->title,
'message' => $opt_in_message_appreciation
);
$admin_notice_html = fs_get_template( 'admin-notice.php', $admin_notice_params );
$modal_content_html = "
<h2" . ( $fs->is_premium() ? ' style="color: red"' : '' ) . ">{$opt_out_message_subtitle}</h2>
<div class=\"notice notice-error inline opt-out-error-message\"><p></p></div>
<p>{$opt_out_message_usage_tracking}</p>
<p>{$opt_out_message_clicking_opt_out}</p>
<label class=\"fs-permission-extensions\"><div class=\"fs-switch fs-small fs-round fs-" . ( $fs->is_extensions_tracking_allowed() ? 'on' : 'off' ) . "\"><div class=\"fs-toggle\"></div></div> " . fs_text_inline( 'Plugins & themes tracking' ) . " <span class=\"fs-switch-feedback success\"></span></label>";
fs_enqueue_local_style( 'fs_dialog_boxes', '/admin/dialog-boxes.css' );
fs_enqueue_local_style( 'fs_common', '/admin/common.css' );
?>
<script type="text/javascript">
(function( $ ) {
$( document ).ready(function() {
var modalContentHtml = <?php echo json_encode( $modal_content_html ) ?>,
modalHtml =
'<div class="fs-modal fs-modal-opt-out">'
+ ' <div class="fs-modal-dialog">'
+ ' <div class="fs-modal-header">'
+ ' <h4><?php echo esc_js( $opt_out_text ) ?></h4>'
+ ' </div>'
+ ' <div class="fs-modal-body">'
+ ' <div class="fs-modal-panel active">' + modalContentHtml + '</div>'
+ ' </div>'
+ ' <div class="fs-modal-footer">'
+ ' <button class="button <?php echo $fs->is_premium() ? 'button-primary warn' : 'button-secondary' ?> button-opt-out" tabindex="1"><?php echo esc_js( $opt_out_text ) ?></button>'
+ ' <button class="button <?php echo $fs->is_premium() ? 'button-secondary' : 'button-primary' ?> button-close" tabindex="2"><?php echo esc_js( $primary_cta_label ) ?></button>'
+ ' </div>'
+ ' </div>'
+ '</div>',
$modal = $(modalHtml),
$adminNotice = $( <?php echo json_encode( $admin_notice_html ) ?> ),
action = '<?php echo $action ?>',
actionLinkSelector = 'span.opt-in-or-opt-out.<?php echo $slug ?> a',
$optOutButton = $modal.find( '.button-opt-out' ),
$optOutErrorMessage = $modal.find( '.opt-out-error-message' ),
$extensionsTracking = $modal.find( '.fs-permission-extensions' ),
$body = $( 'body' ),
moduleID = '<?php echo $fs->get_id() ?>';
$modal.data( 'action', action );
$modal.appendTo( $body );
function registerActionLinkClick() {
$body.on( 'click', actionLinkSelector, function( evt ) {
evt.preventDefault();
if ( 'stop_tracking' == $modal.data( 'action' ) ) {
showModal();
} else {
optIn();
}
return false;
});
}
function registerEventHandlers() {
registerActionLinkClick();
$modal.on( 'click', '.button-opt-out', function( evt ) {
evt.preventDefault();
if ( $( this ).hasClass( 'disabled' ) ) {
return;
}
disableOptOutButton();
optOut();
});
// If the user has clicked outside the window, close the modal.
$modal.on( 'click', '.fs-close, .button-close', function() {
closeModal();
return false;
});
}
<?php if ( $fs->is_registered() ) : ?>
registerEventHandlers();
<?php endif ?>
function showModal() {
resetModal();
// Display the dialog box.
$modal.addClass( 'active' );
$body.addClass( 'has-fs-modal' );
}
function closeModal() {
$modal.removeClass( 'active' );
$body.removeClass( 'has-fs-modal' );
}
function resetOptOutButton() {
enableOptOutButton();
$optOutButton.text( <?php echo json_encode( $opt_out_text ) ?> );
}
function resetModal() {
hideError();
resetOptOutButton();
}
function optIn() {
sendRequest();
}
function optOut() {
sendRequest();
}
function sendRequest() {
var $actionLink = $( actionLinkSelector );
$.ajax({
url: ajaxurl,
method: 'POST',
data: {
action : ( 'stop_tracking' == action ?
'<?php echo $fs->get_ajax_action( 'stop_tracking' ) ?>' :
'<?php echo $fs->get_ajax_action( 'allow_tracking' ) ?>'
),
security : ( 'stop_tracking' == action ?
'<?php echo $fs->get_ajax_security( 'stop_tracking' ) ?>' :
'<?php echo $fs->get_ajax_security( 'allow_tracking' ) ?>'
),
module_id: moduleID,
_wp_http_referer: '<?php echo $fs->current_page_url() ?>'
},
beforeSend: function() {
if ( 'allow_tracking' == action ) {
$actionLink.text( '<?php fs_esc_js_echo_inline( 'Opting in', 'opting-in', $slug ) ?>...' );
} else {
$optOutButton.text( '<?php fs_esc_js_echo_inline( 'Opting out', 'opting-out', $slug ) ?>...' );
}
},
success: function( resultObj ) {
if ( resultObj.success ) {
if ( 'allow_tracking' == action ) {
action = 'stop_tracking';
$actionLink.text( '<?php echo esc_js( $opt_out_text ) ?>' );
showOptInAppreciationMessageAndScrollToTop();
} else {
action = 'allow_tracking';
$actionLink.text( '<?php echo esc_js( $opt_in_text ) ?>' );
closeModal();
if ( $adminNotice.length > 0 ) {
$adminNotice.remove();
}
}
$modal.data( 'action', action );
} else {
showError( resultObj.error );
resetOptOutButton();
}
}
});
}
var isUpdatingPermission = false;
$extensionsTracking.on('click', function() {
if (isUpdatingPermission) {
return false;
}
isUpdatingPermission = true;
var $switch = $extensionsTracking.find( '.fs-switch' ),
$switchFeedback = $extensionsTracking.find( '.fs-switch-feedback' );
$switch
.toggleClass( 'fs-on' )
.toggleClass( 'fs-off' );
$switchFeedback.html( '<i class="fs-ajax-spinner"></i>' );
$.ajax({
url: ajaxurl,
method: 'POST',
data: {
action : '<?php echo $fs->get_ajax_action( 'update_tracking_permission' ) ?>',
security : '<?php echo $fs->get_ajax_security( 'update_tracking_permission' ) ?>',
module_id : moduleID,
_wp_http_referer: '<?php echo $fs->current_page_url() ?>',
permission: 'extensions',
is_enabled: $switch.hasClass('fs-on')
},
success: function( resultObj ) {
if ( resultObj.success ) {
$switchFeedback.html( '<i class="dashicons dashicons-yes"></i> <?php echo esc_js( fs_text_inline( 'Saved', 'saved', $slug ) ) ?>' )
} else {
$switch
.toggleClass( 'fs-on' )
.toggleClass( 'fs-off' );
}
isUpdatingPermission = false;
}
});
});
function enableOptOutButton() {
$optOutButton.removeClass( 'disabled' );
}
function disableOptOutButton() {
$optOutButton.addClass( 'disabled' );
}
function hideError() {
$optOutErrorMessage.hide();
}
function showOptInAppreciationMessageAndScrollToTop() {
$adminNotice.insertAfter( $( '#wpbody-content' ).find( ' > .wrap > h1' ) );
window.scrollTo(0, 0);
}
function showError( msg ) {
$optOutErrorMessage.find( ' > p' ).html( msg );
$optOutErrorMessage.show();
}
<?php if ( $fs->is_theme() ) : ?>
/**
* Add opt-in/out button to the active theme's buttons collection
* in the theme's extended details overlay.
*
* @author Vova Feldman (@svovaf)
* @since 1.2.2.7
*/
$('.theme-overlay').contentChange(function () {
if (0 === $('.theme-overlay.active').length) {
// Add opt-in/out button only to the currently active theme.
return;
}
if ($('#fs_theme_opt_in_out').length > 0){
// Button already there.
return;
}
var label = (('stop_tracking' == action) ?
'<?php echo esc_js( $opt_out_text ) ?>' :
'<?php echo esc_js( $opt_in_text ) ?>'),
href = (('stop_tracking' != action) ?
'<?php echo ( $fs->is_registered() ? '' : esc_js( $reconnect_url ) ) ?>' :
'');
var $actionLink = $('<a id="fs_theme_opt_in_out" href="' + encodeURI(href) + '" class="button">' + label + '</a>');
actionLinkSelector = '#fs_theme_opt_in_out';
$modal.data( 'action', action );
$('.theme-wrap .theme-actions .active-theme').append($actionLink);
if ('' === href) {
registerActionLinkClick();
}
});
<?php endif ?>
});
})( jQuery );
</script>

View File

@ -0,0 +1,205 @@
<?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.2
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* @var Freemius $fs
*/
$fs = freemius( $VARS['id'] );
$slug = $fs->get_slug();
$plugin_data = $fs->get_plugin_data();
$plugin_name = $plugin_data['Name'];
$plugin_basename = $fs->get_plugin_basename();
$license = $fs->_get_license();
if ( ! is_object( $license ) ) {
$purchase_url = $fs->pricing_url();
} else {
$subscription = $fs->_get_subscription( $license->id );
$purchase_url = $fs->checkout_url(
is_object( $subscription ) ?
( 1 == $subscription->billing_cycle ? WP_FS__PERIOD_MONTHLY : WP_FS__PERIOD_ANNUALLY ) :
WP_FS__PERIOD_LIFETIME,
false,
array( 'licenses' => $license->quota )
);
}
$message = sprintf(
fs_text_inline( 'There is a new version of %s available.', 'new-version-available-message', $slug ) .
fs_text_inline( ' %s to access version %s security & feature updates, and support.', 'x-for-updates-and-support', $slug ),
'<span id="plugin_name"></span>',
sprintf(
'<a id="pricing_url" href="">%s</a>',
is_object( $license ) ?
fs_text_inline( 'Renew your license now', 'renew-license-now', $slug ) :
fs_text_inline( 'Buy a license now', 'buy-license-now', $slug )
),
'<span id="new_version"></span>'
);
$modal_content_html = "<p>{$message}</p>";
$header_title = fs_text_inline( 'New Version Available', 'new-version-available', $slug );
$renew_license_button_text = is_object( $license ) ?
fs_text_inline( 'Renew license', 'renew-license', $slug ) :
fs_text_inline( 'Buy license', 'buy-license', $slug );
fs_enqueue_local_style( 'fs_dialog_boxes', '/admin/dialog-boxes.css' );
?>
<script type="text/javascript">
(function( $ ) {
$( document ).ready(function() {
if ( 0 === $( '.license-expired' ).length ) {
return;
}
var modalContentHtml = <?php echo json_encode( $modal_content_html ) ?>,
modalHtml =
'<div class="fs-modal fs-modal-upgrade-premium-version">'
+ ' <div class="fs-modal-dialog">'
+ ' <div class="fs-modal-header">'
+ ' <h4><?php echo esc_js( $header_title ) ?></h4>'
+ ' <a href="!#" class="fs-close"><i class="dashicons dashicons-no" title="<?php echo esc_js( fs_text_x_inline( 'Dismiss', 'close a window', 'dismiss', $slug ) ) ?>"></i></a>'
+ ' </div>'
+ ' <div class="fs-modal-body">'
+ ' <div class="fs-modal-panel active">' + modalContentHtml + '</div>'
+ ' </div>'
+ ' <div class="fs-modal-footer">'
+ ' <a class="button button-primary button-renew-license" tabindex="3" href="<?php echo $purchase_url ?>"><?php echo esc_js( $renew_license_button_text ) ?></a>'
+ ' <button class="button button-secondary button-close" tabindex="4"><?php fs_esc_js_echo_inline( 'Cancel', 'cancel', $slug ) ?></button>'
+ ' </div>'
+ ' </div>'
+ '</div>',
$modal = $( modalHtml ),
isPluginsPage = <?php echo Freemius::is_plugins_page() ? 'true' : 'false' ?>;
$modal.appendTo( $( 'body' ) );
function registerEventHandlers() {
$( 'body' ).on( 'click', '.license-expired', function( evt ) {
var $this = $( this );
if ( ! $this.is( ':checked' ) ||
(
isPluginsPage &&
'update-selected' !== $( '#bulk-action-selector-top' ).val() &&
'update-selected' !== $( '#bulk-action-selector-bottom' ).val()
)
) {
return true;
}
evt.preventDefault();
evt.stopImmediatePropagation();
showModal( $this );
});
// If the user has clicked outside the window, close the modal.
$modal.on( 'click', '.fs-close, .button-secondary', function() {
closeModal();
return false;
});
if ( isPluginsPage ) {
$( 'body' ).on( 'change', 'select[id*="bulk-action-selector"]', function() {
if ( 'update-selected' === $( this ).val() ) {
setTimeout(function() {
$( '.license-expired' ).prop( 'checked', false );
$( '[id*="select-all"]' ).prop( 'checked', false );
}, 0);
}
});
}
$( 'body' ).on( 'click', '[id*="select-all"]', function( evt ) {
var $this = $( this );
if ( ! $this.is( ':checked' ) ) {
return true;
}
if ( isPluginsPage ) {
if ( 'update-selected' !== $( '#bulk-action-selector-top' ).val() &&
'update-selected' !== $( '#bulk-action-selector-bottom' ).val() ) {
return true;
}
}
var $table = $this.closest( 'table' ),
controlChecked = $this.prop( 'checked' ),
toggle = ( event.shiftKey || $this.data( 'wp-toggle' ) ),
$modules = $table.children( 'tbody' ).filter( ':visible' ).children().children( '.check-column' ).find( ':checkbox' ),
$modulesWithNonActiveLicense = $modules.filter( '.license-expired' );
if ( 0 === $modulesWithNonActiveLicense.length ) {
/**
* It's possible that the context HTML table element doesn't have checkboxes with
* ".license-expired" class if for example only the themes table has such checkboxes and the user
* clicks on a "Select All" checkbox on the plugins table which has no such checkboxes.
*
* @author Leo Fajardo (@leorw)
*/
return true;
} else if ( 1 === $modulesWithNonActiveLicense.length ) {
showModal( $modulesWithNonActiveLicense );
}
/**
* Prevent the default WordPress handler from checking all checkboxes.
*
* @author Leo Fajardo (@leorw)
*/
evt.stopImmediatePropagation();
$modules.filter( ':not(.license-expired)' )
.prop( 'checked', function() {
if ( $( this ).is( ':hidden,:disabled' ) ) {
return false;
}
if ( toggle ) {
return ! $( this ).prop( 'checked' );
} else if ( controlChecked ) {
return true;
}
return false;
});
return false;
});
}
registerEventHandlers();
function showModal( $module ) {
$modal.find( '#plugin_name' ).text( $module.data( 'plugin-name' ) );
$modal.find( '#pricing_url' ).attr( 'href', $module.data( 'pricing-url' ) );
$modal.find( '#new_version' ).text( $module.data( 'new-version' ) );
// Display the dialog box.
$modal.addClass( 'active' );
$( 'body' ).addClass( 'has-fs-modal' );
}
function closeModal() {
$modal.removeClass( 'active' );
$( 'body' ).removeClass( 'has-fs-modal' );
}
});
})( jQuery );
</script>

View File

@ -0,0 +1,47 @@
<?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.2
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* @var Freemius $fs
*/
$fs = freemius( $VARS['id'] );
$license = $fs->_get_license();
if ( ! is_object( $license ) ) {
$purchase_url = $fs->pricing_url();
} else {
$subscription = $fs->_get_subscription( $license->id );
$purchase_url = $fs->checkout_url(
is_object( $subscription ) ?
( 1 == $subscription->billing_cycle ? WP_FS__PERIOD_MONTHLY : WP_FS__PERIOD_ANNUALLY ) :
WP_FS__PERIOD_LIFETIME,
false,
array( 'licenses' => $license->quota )
);
}
$plugin_data = $fs->get_plugin_data();
?>
<script type="text/javascript">
(function( $ ) {
$( document ).ready(function() {
var $premiumVersionCheckbox = $( 'input[type="checkbox"][value="<?php echo $fs->get_plugin_basename() ?>"]' );
$premiumVersionCheckbox.addClass( 'license-expired' );
$premiumVersionCheckbox.data( 'plugin-name', <?php echo json_encode( $plugin_data['Name'] ) ?> );
$premiumVersionCheckbox.data( 'pricing-url', <?php echo json_encode( $purchase_url ) ?> );
$premiumVersionCheckbox.data( 'new-version', <?php echo json_encode( $VARS['new_version'] ) ?> );
});
})( jQuery );
</script>

View File

@ -0,0 +1,247 @@
<?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.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* @var array $VARS
* @var Freemius $fs
*/
$fs = freemius( $VARS['id'] );
$slug = $fs->get_slug();
$send_button_text = fs_text_inline( 'Send License Key', 'send-license-key', $slug );
$cancel_button_text = fs_text_inline( 'Cancel', 'cancel', $slug );
$email_address_placeholder = fs_esc_attr_inline( 'Email address', 'email-address', $slug );
$other_text = fs_text_inline( 'Other', 'other', $slug );
$is_freemium = $fs->is_freemium();
$send_button_text_html = esc_html($send_button_text);
$button_html = <<< HTML
<div class="button-container">
<a href="#" class="button button-primary button-send-license-key" tabindex="2">{$send_button_text_html}</a>
</div>
HTML;
if ( $is_freemium ) {
$current_user = Freemius::_get_current_wp_user();
$email = $current_user->user_email;
$esc_email = esc_attr( $email );
$form_html = <<< HTML
<div class="email-address-container">
<label><input name="email-address" type="radio" checked="checked" tabindex="1" value="{$esc_email}"> {$email}</label>
<label><input name="email-address" type="radio" tabindex="1" value="other">{$other_text}: <input class="email-address" type="text" placeholder="{$email_address_placeholder}"></label>
</div>
{$button_html}
HTML;
} else {
$email = '';
$form_html = <<< HTML
{$button_html}
<div class="email-address-container">
<input class="email-address" type="text" placeholder="{$email_address_placeholder}" tabindex="1">
</div>
HTML;
}
$message_above_input_field = fs_esc_html_inline( "Enter the email address you've used for the upgrade below and we will resend you the license key.", 'ask-for-upgrade-email-address', $slug );
$modal_content_html = <<< HTML
<div class="notice notice-error inline license-resend-message"><p></p></div>
<p>{$message_above_input_field}</p>
<div class="input-container">
{$form_html}
</div>
HTML;
fs_enqueue_local_style( 'fs_dialog_boxes', '/admin/dialog-boxes.css' );
?>
<script type="text/javascript">
(function ($) {
$(document).ready(function () {
var contentHtml = <?php echo json_encode( $modal_content_html ); ?>,
modalHtml =
'<div class="fs-modal fs-modal-license-key-resend <?php echo $is_freemium ? 'fs-freemium' : 'fs-premium' ?>">'
+ ' <div class="fs-modal-dialog">'
+ ' <div class="fs-modal-header">'
+ ' <h4><?php echo esc_js( $send_button_text ) ?></h4>'
+ ' <a href="#!" class="fs-close" tabindex="3" title="Close"><i class="dashicons dashicons-no" title="<?php echo esc_js( fs_text_x_inline( 'Dismiss', 'as close a window', 'dismiss', $slug ) ) ?>"></i></a>'
+ ' </div>'
+ ' <div class="fs-modal-body">'
+ ' <div class="fs-modal-panel active">' + contentHtml + '</div>'
+ ' </div>'
+ ' </div>'
+ '</div>',
$modal = $(modalHtml),
$sendButton = $modal.find('.button-send-license-key'),
$emailInput = $modal.find('input.email-address'),
$feedbackMessage = $modal.find('.license-resend-message'),
isFreemium = <?php echo json_encode( $is_freemium ) ?>,
userEmail = <?php echo json_encode( $email ) ?>,
moduleID = '<?php echo $fs->get_id() ?>',
isChild = false;
$modal.appendTo($('body'));
function registerEventHandlers() {
$('a.show-license-resend-modal-<?php echo $fs->get_unique_affix() ?>').click(function (evt) {
evt.preventDefault();
showModal();
});
if (isFreemium) {
$modal.on('change', 'input[type=radio][name=email-address]', function () {
updateButtonState();
});
$modal.on('focus', 'input.email-address', function () {
// Check custom email radio button on email input focus.
$($modal.find('input[type=radio]')[1]).prop('checked', true);
updateButtonState();
});
}
$modal.on('input propertychange', 'input.email-address', function () {
updateButtonState();
});
$modal.on('blur', 'input.email-address', function () {
updateButtonState();
});
$modal.on('click', '.fs-close', function (){
closeModal();
return false;
});
$modal.on('click', '.button', function (evt) {
evt.preventDefault();
if ($(this).hasClass('disabled')) {
return;
}
var email = getEmail();
disableButton();
if (!(-1 < email.indexOf('@'))) {
return;
}
$.ajax({
url : ajaxurl,
method : 'POST',
data : {
action : '<?php echo $fs->get_ajax_action( 'resend_license_key' ) ?>',
security : '<?php echo $fs->get_ajax_security( 'resend_license_key' ) ?>',
module_id : moduleID,
email : email
},
beforeSend: function () {
$sendButton.text('<?php fs_esc_js_echo_inline( 'Sending license key', 'sending-license-key', $slug ) ?>...');
},
success : function (result) {
var resultObj = $.parseJSON(result);
if (resultObj.success) {
closeModal();
} else {
showError(resultObj.error);
resetButton();
}
}
});
});
}
registerEventHandlers();
resetButton();
function showModal() {
resetModal();
// Display the dialog box.
$modal.addClass('active');
if (!isFreemium)
$emailInput.focus();
var $body = $('body');
isChild = $body.hasClass('has-fs-modal');
if (isChild) {
return;
}
$body.addClass('has-fs-modal');
}
function closeModal() {
$modal.removeClass('active');
// If child modal, do not remove the "has-fs-modal" class of the <body> element to keep its scrollbars hidden.
if (isChild) {
return;
}
$('body').removeClass('has-fs-modal');
}
function resetButton() {
updateButtonState();
$sendButton.text(<?php echo json_encode($send_button_text) ?>);
}
function resetModal() {
hideError();
resetButton();
$emailInput.val('');
}
function getEmail() {
var email = $emailInput.val().trim();
if (isFreemium) {
if ('other' != $modal.find('input[type=radio][name=email-address]:checked').val()) {
email = userEmail;
}
}
return email;
}
function updateButtonState() {
/**
* If email address is not empty, enable the send license key button.
*/
$sendButton.toggleClass('disabled', !( -1 < getEmail().indexOf('@') ));
}
function disableButton() {
$sendButton.addClass('disabled');
}
function hideError() {
$feedbackMessage.hide();
}
function showError(msg) {
$feedbackMessage.find(' > p').html(msg);
$feedbackMessage.show();
}
});
})(jQuery);
</script>

View File

@ -0,0 +1,277 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 2.2.1
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* @var array $VARS
*/
$fs = freemius( $VARS['id'] );
$slug = $fs->get_slug();
/**
* @var FS_Plugin_License $license
*/
$license = $VARS['license'];
$has_trial = $VARS['has_trial'];
$subscription_cancellation_context = $has_trial ?
fs_text_inline( 'trial', 'trial', $slug ) :
fs_text_inline( 'subscription', 'subscription', $slug );
$plan = $fs->get_plan();
$module_label = $fs->get_module_label( true );
if ( $VARS['is_license_deactivation'] ) {
$subscription_cancellation_text = '';
} else {
$subscription_cancellation_text = sprintf(
fs_text_inline(
"Deactivating or uninstalling the %s will automatically disable the license, which you'll be able to use on another site.",
'deactivation-or-uninstall-message',
$slug
),
$module_label
) . ' ';
}
$subscription_cancellation_text .= sprintf(
fs_text_inline(
'In case you are NOT planning on using this %s on this site (or any other site) - would you like to cancel the %s as well?',
'cancel-subscription-message',
$slug
),
( $VARS['is_license_deactivation'] ? fs_text_inline( 'license', 'license', $slug ) : $module_label ),
$subscription_cancellation_context
);
$cancel_subscription_action_label = sprintf(
fs_esc_html_inline(
"Cancel %s - I no longer need any security & feature updates, nor support for %s because I'm not planning to use the %s on this, or any other site.",
'cancel-x',
$slug
),
esc_html( $subscription_cancellation_context ),
sprintf( '<strong>%s</strong>', esc_html( $fs->get_plugin_title() ) ),
esc_html( $module_label )
);
$keep_subscription_active_action_label = esc_html( sprintf(
fs_text_inline(
"Don't cancel %s - I'm still interested in getting security & feature updates, as well as be able to contact support.",
'dont-cancel-x',
$slug
),
$subscription_cancellation_context
) );
$subscription_cancellation_text = esc_html( $subscription_cancellation_text );
$subscription_cancellation_html = <<< HTML
<div class="notice notice-error inline"><p></p></div><p>{$subscription_cancellation_text}</p>
<ul class="subscription-actions">
<li>
<label>
<input type="radio" name="cancel-subscription" value="false"/>
<span>{$keep_subscription_active_action_label}</span>
</label>
</li>
<li>
<label>
<input type="radio" name="cancel-subscription" value="true"/>
<span>{$cancel_subscription_action_label}</span>
</label>
</li>
</ul>
HTML;
$downgrading_plan_text = fs_text_inline( 'Downgrading your plan', 'downgrading-plan', $slug );
$cancelling_subscription_text = fs_text_inline( 'Cancelling the subscription', 'cancelling-subscription', $slug );
/* translators: %1$s: Either 'Downgrading your plan' or 'Cancelling the subscription' */
$downgrade_x_confirm_text = fs_text_inline( '%1$s will immediately stop all future recurring payments and your %2$s plan license will expire in %3$s.', 'downgrade-x-confirm', $slug );
$prices_increase_text = fs_text_inline( 'Please note that we will not be able to grandfather outdated pricing for renewals/new subscriptions after a cancellation. If you choose to renew the subscription manually in the future, after a price increase, which typically occurs once a year, you will be charged the updated price.', 'pricing-increase-warning', $slug );
$after_downgrade_non_blocking_text = fs_text_inline( 'You can still enjoy all %s features but you will not have access to %s security & feature updates, nor support.', 'after-downgrade-non-blocking', $slug );
$after_downgrade_blocking_text = fs_text_inline( 'Once your license expires you can still use the Free version but you will NOT have access to the %s features.', 'after-downgrade-blocking', $slug );
$after_downgrade_blocking_text_premium_only = fs_text_inline( 'Once your license expires you will no longer be able to use the %s, unless you activate it again with a valid premium license.', 'after-downgrade-blocking-premium-only', $slug );
$subscription_cancellation_confirmation_message = $has_trial ?
fs_text_inline( 'Cancelling the trial will immediately block access to all premium features. Are you sure?', 'cancel-trial-confirm', $slug ) :
sprintf(
'%s %s %s %s',
sprintf(
$downgrade_x_confirm_text,
($fs->is_only_premium() ? $cancelling_subscription_text : $downgrading_plan_text ),
$plan->title,
human_time_diff( time(), strtotime( $license->expiration ) )
),
(
$license->is_block_features ?
(
$fs->is_only_premium() ?
sprintf( $after_downgrade_blocking_text_premium_only, $module_label ) :
sprintf( $after_downgrade_blocking_text, $plan->title )
) :
sprintf( $after_downgrade_non_blocking_text, $plan->title, $fs->get_module_label( true ) )
),
$prices_increase_text,
fs_esc_attr_inline( 'Are you sure you want to proceed?', 'proceed-confirmation', $slug )
);
fs_enqueue_local_style( 'fs_dialog_boxes', '/admin/dialog-boxes.css' );
?>
<script type="text/javascript">
(function( $ ) {
var modalHtml =
'<div class="fs-modal fs-modal-subscription-cancellation fs-modal-subscription-cancellation-<?php echo $fs->get_id() ?>">'
+ ' <div class="fs-modal-dialog">'
+ ' <div class="fs-modal-header">'
+ ' <h4><?php echo esc_html( sprintf( fs_text_inline( 'Cancel %s?', 'cancel-x', $slug ), ucfirst( $subscription_cancellation_context ) ) ) ?></h4>'
+ ' </div>'
+ ' <div class="fs-modal-body">'
+ ' <div class="fs-modal-panel active">' + <?php echo json_encode( $subscription_cancellation_html ) ?> + '<p class="fs-price-increase-warning" style="display: none;">' + <?php echo json_encode( $prices_increase_text ) ?> + '</p></div>'
+ ' </div>'
+ ' <div class="fs-modal-footer">'
+ ' <a href="#" class="button button-secondary button-close"><?php fs_esc_attr_echo( 'cancel', $slug ) ?></a>'
+ ' <a href="#" class="button button-primary button-deactivate disabled"><?php fs_esc_attr_echo_inline( 'Proceed', 'proceed', $slug ) ?></a>'
+ ' </div>'
+ ' </div>'
+ '</div>',
$modal = $(modalHtml);
$modal.appendTo($('body'));
registerEventHandlers();
function registerEventHandlers() {
$modal.on( 'showModal', function() {
showModal();
});
$modal.on( 'closeModal', function() {
closeModal();
});
$modal.on('click', '.fs-modal-footer .button', function (evt) {
evt.preventDefault();
if ($(this).hasClass('disabled')) {
return;
}
var _this = $(this),
subscriptionCancellationActionEventName = <?php echo json_encode( $fs->get_action_tag( 'subscription_cancellation_action' ) ) ?>;
if ( _this.hasClass( 'button-primary' ) ) {
if ( 'true' !== $modal.find( 'input[name="cancel-subscription"]:checked' ).val() ) {
$modal.trigger( subscriptionCancellationActionEventName, false );
} else {
if ( confirm( <?php echo json_encode( $subscription_cancellation_confirmation_message ) ?> ) ) {
$modal.trigger( subscriptionCancellationActionEventName, true );
}
}
}
});
$modal.on('click', 'input[type="radio"]', function () {
var
$selectedOption = $( this ),
$primaryButton = $modal.find( '.button-primary' ),
isSelected = ( 'true' === $selectedOption.val() );
if ( isSelected ) {
$primaryButton.html( <?php echo json_encode( sprintf(
fs_text_inline( 'Cancel %s & Proceed', 'cancel-x-and-proceed', $slug ),
ucfirst( $subscription_cancellation_context )
) ) ?> );
$modal.find('.fs-price-increase-warning').show();
} else {
$primaryButton.html( <?php echo fs_json_encode_echo_inline( 'Proceed', 'proceed', $slug ) ?> );
$modal.find('.fs-price-increase-warning').hide();
}
$primaryButton.toggleClass( 'warn', isSelected );
$primaryButton.removeClass( 'disabled' );
});
// If the user has clicked outside the window, cancel it.
$modal.on('click', function (evt) {
var $target = $(evt.target);
// If the user has clicked anywhere in the modal dialog, just return.
if ($target.hasClass('fs-modal-body') || $target.hasClass('fs-modal-footer')) {
return;
}
// If the user has not clicked the close button and the clicked element is inside the modal dialog, just return.
if (
( ! $target.hasClass( 'button-close' ) ) &&
( $target.parents( '.fs-modal-body' ).length > 0 || $target.parents( '.fs-modal-footer' ).length > 0 )
) {
return;
}
closeModal();
return false;
});
}
function showModal() {
resetModal();
// Display the dialog box.
$modal.addClass('active');
$('body').addClass('has-fs-modal');
}
function closeModal() {
var activeModalsCount = $( '.fs-modal.active' ).length;
$modal.removeClass('active');
// If child modal, do not remove the "has-fs-modal" class of the <body> element to keep its scrollbars hidden.
if ( activeModalsCount > 1 ) {
return;
}
$('body').removeClass('has-fs-modal');
}
function resetModal() {
updateButtonLabels();
if ( 0 === $modal.find( '.subscription-actions' ).length ) {
$modal.find('.button-deactivate').removeClass('disabled');
} else {
$modal.find('.button-deactivate').addClass('disabled');
}
$modal.find('.fs-price-increase-warning').hide();
// Uncheck all radio buttons.
$modal.find('input[type="radio"]').prop('checked', false);
$modal.find('.message').hide();
}
function showMessage(message) {
$modal.find('.message').text(message).show();
}
function updateButtonLabels() {
$modal.find('.button-primary').text( <?php fs_json_encode_echo_inline( 'Proceed', 'proceed', $slug ) ?> );
$modal.find('.button-secondary').text( <?php fs_json_encode_echo( 'cancel', $slug ) ?> );
}
})( jQuery );
</script>

View File

@ -0,0 +1,181 @@
<?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.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* @var array $VARS
* @var Freemius $fs
*/
$fs = freemius( $VARS['id'] );
$slug = $fs->get_slug();
$message_header = sprintf(
/* translators: %1$s: Number of trial days; %2$s: Plan name; */
fs_text_inline( 'You are 1-click away from starting your %1$s-day free trial of the %2$s plan.', 'start-trial-prompt-header', $slug ),
'<span class="var-trial_period"></span>',
'<span class="var-plan_title"></span>'
);
$message_content = sprintf(
/* translators: %s: Link to freemius.com */
fs_text_inline( 'For compliance with the WordPress.org guidelines, before we start the trial we ask that you opt in with your user and non-sensitive site information, allowing the %s to periodically send data to %s to check for version updates and to validate your trial.', 'start-trial-prompt-message', $slug ),
$fs->get_module_type(),
sprintf(
'<a href="%s" target="_blank" rel="noopener">%s</a>',
'https://freemius.com',
'freemius.com'
)
);
$modal_content_html = <<< HTML
<div class="notice notice-error inline"><p></p></div>
<h3>{$message_header}</h3>
<p>{$message_content}</p>
HTML;
fs_enqueue_local_style( 'fs_dialog_boxes', '/admin/dialog-boxes.css' );
?>
<script type="text/javascript">
(function ($) {
$(document).ready(function () {
var modalContentHtml = <?php echo json_encode( $modal_content_html ); ?>,
modalHtml =
'<div class="fs-modal fs-modal-license-key-resend">'
+ ' <div class="fs-modal-dialog">'
+ ' <div class="fs-modal-header">'
+ ' <h4><?php echo esc_js( fs_text_x_inline( 'Start free trial', 'call to action', 'start-free-trial', $slug ) ) ?></h4>'
+ ' </div>'
+ ' <div class="fs-modal-body">' + modalContentHtml + '</div>'
+ ' <div class="fs-modal-footer">'
+ ' <button class="button button-secondary button-close">' + <?php fs_json_encode_echo_inline( 'Cancel', 'cancel', $slug ) ?> +'</button>'
+ ' <button class="button button-primary button-connect">' + <?php fs_json_encode_echo_inline( 'Approve & Start Trial', 'approve-start-trial', $slug ) ?> +'</button>'
+ ' </div>'
+ ' </div>'
+ '</div>',
$modal = $( modalHtml ),
trialData;
$modal.appendTo($('body'));
var $errorNotice = $modal.find('.notice-error');
registerEventHandlers();
function registerEventHandlers() {
$modal.on('click', '.button-close', function () {
closeModal();
return false;
});
$modal.on('click', '.button-connect', function (evt) {
evt.preventDefault();
var $button = $(this);
$.ajax({
url : ajaxurl,
method : 'POST',
data : {
action : '<?php echo $fs->get_ajax_action( 'start_trial' ) ?>',
security : '<?php echo $fs->get_ajax_security( 'start_trial' ) ?>',
module_id: '<?php echo $fs->get_id() ?>',
trial : trialData
},
beforeSend: function () {
// Disable all buttons during trial activation.
$modal.find('.button').prop('disabled', true);
$button.text(<?php fs_json_encode_echo_inline( 'Starting trial', 'starting-trial', $slug ) ?> + '...');
setLoadingMode();
},
success : function (resultObj) {
if (resultObj.success) {
$button.text(<?php fs_json_encode_echo_inline( 'Please wait', 'please-wait', $slug ) ?> + '...');
// Redirect to the "Account" page and sync the license.
window.location.href = resultObj.data.next_page;
} else {
$button.text(<?php fs_json_encode_echo( 'approve-start-trial', $slug ) ?>);
resetLoadingMode();
showError(resultObj.error);
}
}
});
});
}
window.openTrialConfirmationModal = function showModal(data) {
resetModal();
// Display the dialog box.
$modal.addClass('active');
trialData = data;
var $modalBody = $modal.find('.fs-modal-body'),
$var;
for (var key in data) {
if (data.hasOwnProperty(key)) {
$var = $modalBody.find('.var-' + key);
if ($var.length > 0)
$var.html(data[key]);
}
}
$('body').addClass('has-fs-modal');
};
function closeModal() {
$modal.removeClass('active');
$('body').removeClass('has-fs-modal');
}
function resetModal() {
hideError();
}
function hideError() {
$errorNotice.hide();
}
function setLoadingMode() {
$modal.find('.button')
// Re-enable all buttons.
.prop('disabled', trialData)
// Stop loading cursor.
.css({'cursor': 'wait'});
// Stop loading cursor.
$(document.body).css({'cursor': 'wait'});
}
function resetLoadingMode() {
$modal.find('.button')
// Re-enable all buttons.
.prop('disabled', false)
// Stop loading cursor.
.css({'cursor': 'initial'});
// Stop loading cursor.
$(document.body).css({'cursor': 'initial'});
}
function showError(msg) {
$errorNotice.find(' > p').html(msg);
$errorNotice.show();
}
});
})(jQuery);
</script>

View File

@ -0,0 +1,66 @@
<?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;
}
/**
* @var array $VARS
*/
$fs = freemius( $VARS['id'] );
?>
<script type="text/javascript">
(function( $ ) {
$( document ).ready(function() {
var $gdprOptinNotice = $( 'div[data-id^="gdpr_optin_actions"]' );
if ( 0 === $gdprOptinNotice.length ) {
return;
}
$gdprOptinNotice.on( 'click', '.button', function() {
var
$this = $( this ),
allowMarketing = $this.hasClass( 'allow-marketing' ),
cursor = $this.css( 'cursor' ),
$products = $gdprOptinNotice.find( 'span[data-plugin-id]' ),
pluginIDs = [];
if ( $products.length > 0 ) {
$products.each(function() {
pluginIDs.push( $( this ).data( 'plugin-id' ) );
});
}
$.ajax({
url : ajaxurl + '?' + $.param({
action : '<?php echo $fs->get_ajax_action( 'gdpr_optin_action' ) ?>',
security : '<?php echo $fs->get_ajax_security( 'gdpr_optin_action' ) ?>',
module_id: '<?php echo $fs->get_id() ?>'
}),
method : 'POST',
data : {
is_marketing_allowed: allowMarketing,
plugin_ids : pluginIDs
},
beforeSend: function() {
$this.text( <?php fs_json_encode_echo_inline( 'Thanks, please wait', 'thanks-please-wait', $fs->get_slug() ) ?> + '...' );
$this.css({'cursor': 'wait'});
$gdprOptinNotice.find( '.button' ).addClass( 'disabled' );
},
complete : function() {
$this.css({'cursor': cursor});
$gdprOptinNotice.remove();
}
});
});
});
})( jQuery );
</script>

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,58 @@
<?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;
}
?>
<script type="text/javascript">
(function ($) {
if ($.fn.contentChange)
return;
/**
* Content change event listener.
*
* @url http://stackoverflow.com/questions/3233991/jquery-watch-div/3234646#3234646
*
* @param {function} callback
*
* @returns {object[]}
*/
$.fn.contentChange = function (callback) {
var elements = $(this);
elements.each(function () {
var element = $(this);
element.data("lastContents", element.html());
window.watchContentChange = window.watchContentChange ?
window.watchContentChange :
[];
window.watchContentChange.push({
"element" : element,
"callback": callback
});
});
return elements;
};
setInterval(function() {
if ( window.watchContentChange ) {
for ( var i in window.watchContentChange ) {
if ( window.watchContentChange[ i ].element.data( 'lastContents' ) !== window.watchContentChange[ i ].element.html() ) {
window.watchContentChange[ i ].callback.apply( undefined, [ false ] );
window.watchContentChange[ i ].element.data( 'lastContents', window.watchContentChange[ i ].element.html() )
}
}
}
}, 500 );
})(jQuery);
</script>

View File

@ -0,0 +1,37 @@
<?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;
}
$license_id = $VARS['license_id'];
?>
<script type="text/javascript">
(function ($) {
var prepareLicenseActivationDialog = function () {
var $dialog = $('.fs-modal-license-activation');
// Trigger the license activation dialog box.
$($('.activate-license-trigger')[0]).click();
// setTimeout(function(){
$dialog.find('select.fs-licenses option[data-id=<?php echo $license_id ?>]')
.prop('selected', true)
.change();
// }, 100);
};
if ($('.fs-modal-license-activation').length > 0) {
prepareLicenseActivationDialog();
} else {
$('body').on('licenseActivationLoaded', function () {
prepareLicenseActivationDialog();
});
}
})(jQuery);
</script>

View File

@ -0,0 +1,53 @@
<?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;
}
/**
* @var array $VARS
* @var Freemius $fs
*/
$fs = freemius( $VARS['id'] );
$slug = $fs->get_slug();
?>
<script type="text/javascript">
(function ($) {
// Select the premium theme version.
var $theme = $('#<?php echo $slug ?>-premium-name').parents('.theme'),
addPremiumMetadata = function (firstCall) {
if (!firstCall) {
// Seems like the original theme element is removed from the DOM,
// so we need to reselect the updated one.
$theme = $('#<?php echo $slug ?>-premium-name').parents('.theme');
}
if (0 === $theme.find('.fs-premium-theme-badge-container').length) {
$theme.addClass('fs-premium');
var $themeBadgeContainer = $( '<div class="fs-premium-theme-badge-container"></div>' );
$themeBadgeContainer.append( '<div class="fs-badge fs-premium-theme-badge">' + <?php echo json_encode( $fs->get_text_inline( 'Premium', 'premium' ) ) ?> + '</div>' );
<?php if ( $fs->is_beta() ) : ?>
$themeBadgeContainer.append( '<div class="fs-badge fs-beta-theme-badge">' + <?php echo json_encode( $fs->get_text_inline( 'Beta', 'beta' ) ) ?> + '</div>' );
<?php endif ?>
$theme.append( $themeBadgeContainer );
}
};
addPremiumMetadata(true);
$theme.contentChange(addPremiumMetadata);
})(jQuery);
</script>

View File

@ -0,0 +1,94 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* @var array $VARS
* @var Freemius $fs
*/
$fs = freemius( $VARS['id'] );
$slug = $fs->get_slug();
$sites = $VARS['sites'];
$require_license_key = $VARS['require_license_key'];
$show_delegation_option = $fs->apply_filters( 'show_delegation_option', true );
$enable_per_site_activation = $fs->apply_filters( 'enable_per_site_activation', true );
?>
<?php $separator = '<td>|</td>' ?>
<div class="fs-multisite-options-container fs-apply-on-all-sites"<?php if ( ! $enable_per_site_activation )
echo ' style="display: none;"' ?>>
<table class="fs-all-sites-options">
<tbody>
<tr>
<td width="600">
<label>
<?php
if ( ! $fs->is_network_upgrade_mode() ) {
$apply_checkbox_label = $require_license_key ?
fs_text_inline( 'Activate license on all sites in the network.', 'activate-license-on-all-sites-in-the-network', $slug ) :
fs_text_inline( 'Apply on all sites in the network.', 'apply-on-all-sites-in-the-network', $slug );
} else {
$apply_checkbox_label = $require_license_key ?
fs_text_inline( 'Activate license on all pending sites.', 'activate-license-on-pending-sites-in-the-network', $slug ) :
fs_text_inline( 'Apply on all pending sites.', 'apply-on-pending-sites-in-the-network', $slug );
}
?>
<input class="fs-apply-on-all-sites-checkbox" type="checkbox" value="true" checked><span><?php echo esc_html( $apply_checkbox_label ) ?></span>
</label>
</td>
<?php if ( ! $require_license_key ) : ?>
<td><a class="action action-allow" data-action-type="allow" href="#"><?php fs_esc_html_echo_inline( 'allow', 'allow', $slug ) ?></a></td>
<?php echo $separator ?>
<?php if ( $show_delegation_option ) : ?>
<td><a class="action action-delegate" data-action-type="delegate" href="#"><?php fs_esc_html_echo_inline( 'delegate', 'delegate', $slug ) ?></a></td>
<?php endif ?>
<?php if ( $fs->is_enable_anonymous() ) : ?>
<?php echo $separator ?>
<td><a class="action action-skip" data-action-type="skip" href="#"><?php echo strtolower( fs_esc_html_inline( 'skip', 'skip', $slug ) ) ?></a></td>
<?php endif ?>
<?php endif ?>
</tr>
</tbody>
</table>
<div class="fs-sites-list-container">
<table cellspacing="0">
<tbody>
<?php $site_props = array('uid', 'url', 'title', 'charset', 'language') ?>
<?php foreach ( $sites as $site ) : ?>
<tr<?php if ( ! empty( $site['license_id'] ) ) {
echo ' data-license-id="' . $site['license_id'] . '"';
} ?>>
<?php if ( $require_license_key ) : ?>
<td><input type="checkbox" value="true" /></td>
<?php endif ?>
<td class="blog-id"><span><?php echo $site['blog_id'] ?></span>.</td>
<td width="600"><span><?php
$url = str_replace( 'http://', '', str_replace( 'https://', '', $site['url'] ) );
echo $url;
?></span>
<?php foreach ($site_props as $prop) : ?>
<input class="<?php echo $prop ?>" type="hidden" value="<?php echo esc_attr($site[$prop]) ?>" />
<?php endforeach ?>
</td>
<?php if ( ! $require_license_key ) : ?>
<td><a class="action action-allow selected" data-action-type="allow" href="#"><?php fs_esc_html_echo_inline( 'allow', 'allow', $slug ) ?></a></td>
<?php echo $separator ?>
<?php if ( $show_delegation_option ) : ?>
<td><a class="action action-delegate" data-action-type="delegate" href="#"><?php fs_esc_html_echo_inline( 'delegate', 'delegate', $slug ) ?></a></td>
<?php endif ?>
<?php if ( $fs->is_enable_anonymous() ) : ?>
<?php echo $separator ?>
<td><a class="action action-skip" data-action-type="skip" href="#"><?php echo strtolower( fs_esc_html_inline( 'skip', 'skip', $slug ) ) ?></a></td>
<?php endif ?>
<?php endif ?>
</tr>
<?php endforeach ?>
</tbody>
</table>
</div>
</div>

View File

@ -0,0 +1,20 @@
<?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.4
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* @var array $VARS
*/
$fs = freemius( $VARS['id'] );
?>
<div class="fs-plugin-icon">
<img src="<?php echo $fs->get_local_icon_url() ?>" width="80" height="80"/>
</div>

View File

@ -0,0 +1,78 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.0.6
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* @var array $VARS
*
* @var FS_Plugin $plugin
*/
$plugin = $VARS['plugin'];
if ( ! empty( $plugin->info->selling_point_0 ) ||
! empty( $plugin->info->selling_point_1 ) ||
! empty( $plugin->info->selling_point_2 )
) : ?>
<div class="fs-selling-points">
<ul>
<?php for ( $i = 0; $i < 3; $i ++ ) : ?>
<?php if ( ! empty( $plugin->info->{'selling_point_' . $i} ) ) : ?>
<li><i class="dashicons dashicons-yes"></i>
<h3><?php echo esc_html( $plugin->info->{'selling_point_' . $i} ) ?></h3></li>
<?php endif ?>
<?php endfor ?>
</ul>
</div>
<?php endif ?>
<div>
<?php
echo wp_kses( $plugin->info->description, array(
'a' => array( 'href' => array(), 'title' => array(), 'target' => array() ),
'b' => array(),
'i' => array(),
'p' => array(),
'blockquote' => array(),
'h2' => array(),
'h3' => array(),
'ul' => array(),
'ol' => array(),
'li' => array()
) );
?>
</div>
<?php if ( ! empty( $plugin->info->screenshots ) ) : ?>
<?php $screenshots = $plugin->info->screenshots ?>
<div class="fs-screenshots clearfix">
<h2><?php fs_esc_html_echo_inline( 'Screenshots', 'screenshots', $plugin->slug ) ?></h2>
<ul>
<?php $i = 0;
foreach ( $screenshots as $s => $url ) : ?>
<?php
// Relative URLs are replaced with WordPress.org base URL
// therefore we need to set absolute URLs.
$url = 'http' . ( WP_FS__IS_HTTPS ? 's' : '' ) . ':' . $url;
?>
<li class="<?php echo ( 0 === $i % 2 ) ? 'odd' : 'even' ?>">
<style>
#section-description .fs-screenshots <?php echo ".fs-screenshot-{$i}" ?>
{
background-image: url('<?php echo $url ?>');
}
</style>
<a href="<?php echo $url ?>"
title="<?php echo esc_attr( sprintf( fs_text_inline( 'Click to view full-size screenshot %d', 'view-full-size-x', $plugin->slug ), $i ) ) ?>"
class="fs-screenshot-<?php echo $i ?>"></a>
</li>
<?php $i ++; endforeach ?>
</ul>
</div>
<?php endif ?>

View File

@ -0,0 +1,114 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.0.6
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* @var array $VARS
*
* @var FS_Plugin $plugin
*/
$plugin = $VARS['plugin'];
$plans = $VARS['plans'];
$features_plan_map = array();
foreach ( $plans as $plan ) {
if (!empty($plan->features) && is_array($plan->features)) {
foreach ( $plan->features as $feature ) {
if ( ! isset( $features_plan_map[ $feature->id ] ) ) {
$features_plan_map[ $feature->id ] = array( 'feature' => $feature, 'plans' => array() );
}
$features_plan_map[ $feature->id ]['plans'][ $plan->id ] = $feature;
}
}
// Add support as a feature.
if ( ! empty( $plan->support_email ) ||
! empty( $plan->support_skype ) ||
! empty( $plan->support_phone ) ||
true === $plan->is_success_manager
) {
if ( ! isset( $features_plan_map['support'] ) ) {
$support_feature = new stdClass();
$support_feature->id = 'support';
$support_feature->title = fs_text_inline( 'Support', $plugin->slug );
$features_plan_map[ $support_feature->id ] = array( 'feature' => $support_feature, 'plans' => array() );
} else {
$support_feature = $features_plan_map['support'];
}
$features_plan_map[ $support_feature->id ]['plans'][ $plan->id ] = $support_feature;
}
}
// Add updates as a feature for all plans.
$updates_feature = new stdClass();
$updates_feature->id = 'updates';
$updates_feature->title = fs_text_inline( 'Unlimited Updates', 'unlimited-updates', $plugin->slug );
$features_plan_map[ $updates_feature->id ] = array( 'feature' => $updates_feature, 'plans' => array() );
foreach ( $plans as $plan ) {
$features_plan_map[ $updates_feature->id ]['plans'][ $plan->id ] = $updates_feature;
}
?>
<div class="fs-features">
<table>
<thead>
<tr>
<th></th>
<?php foreach ( $plans as $plan ) : ?>
<th>
<?php echo $plan->title ?>
<span class="fs-price"><?php
if ( empty( $plan->pricing ) ) {
fs_esc_html_echo_inline( 'Free', 'free', $plugin->slug );
} else {
foreach ( $plan->pricing as $pricing ) {
/**
* @var FS_Pricing $pricing
*/
if ( 1 == $pricing->licenses ) {
if ( $pricing->has_annual() ) {
echo "\${$pricing->annual_price} / " . fs_esc_html_x_inline( 'year', 'as annual period', 'year', $plugin->slug );
} else if ( $pricing->has_monthly() ) {
echo "\${$pricing->monthly_price} / " . fs_esc_html_x_inline( 'mo', 'as monthly period', 'mo', $plugin->slug );
} else {
echo "\${$pricing->lifetime_price}";
}
}
}
}
?></span>
</th>
<?php endforeach ?>
</tr>
</thead>
<tbody>
<?php $odd = true;
foreach ( $features_plan_map as $feature_id => $data ) : ?>
<tr class="fs-<?php echo $odd ? 'odd' : 'even' ?>">
<td><?php echo esc_html( ucfirst( $data['feature']->title ) ) ?></td>
<?php foreach ( $plans as $plan ) : ?>
<td>
<?php if ( isset( $data['plans'][ $plan->id ] ) ) : ?>
<?php if ( ! empty( $data['plans'][ $plan->id ]->value ) ) : ?>
<b><?php echo esc_html( $data['plans'][ $plan->id ]->value ) ?></b>
<?php else : ?>
<i class="dashicons dashicons-yes"></i>
<?php endif ?>
<?php endif ?>
</td>
<?php endforeach ?>
</tr>
<?php $odd = ! $odd; endforeach ?>
</tbody>
</table>
</div>

View File

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

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.6
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* @var array $VARS
*
* @var FS_Plugin $plugin
*/
$plugin = $VARS['plugin'];
$screenshots = $VARS['screenshots'];
?>
<ol>
<?php $i = 0;
foreach ( $screenshots as $s => $url ) : ?>
<?php
// Relative URLs are replaced with WordPress.org base URL
// therefore we need to set absolute URLs.
$url = 'http' . ( WP_FS__IS_HTTPS ? 's' : '' ) . ':' . $url;
?>
<li>
<a href="<?php echo $url ?>" title="<?php echo esc_attr( sprintf( fs_text_inline( 'Click to view full-size screenshot %d', 'view-full-size-x', $plugin->slug ), $i ) ) ?>"><img src="<?php echo $url ?>"></a>
</li>
<?php $i ++; endforeach ?>
</ol>

View File

@ -0,0 +1,61 @@
<?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
*/
/**
* Note for WordPress.org Theme/Plugin reviewer:
* Freemius is an SDK for plugin and theme developers. Since the core
* of the SDK is relevant both for plugins and themes, for obvious reasons,
* we only develop and maintain one code base.
*
* This code will not run for wp.org themes (only plugins)
* since theme admin settings/options are now only allowed in the customizer.
*
* In addition, this page loads an i-frame. We intentionally named it 'frame'
* so it will pass the "Theme Check" that is looking for the string "i" . "frame".
*
* If you have any questions or need clarifications, please don't hesitate
* pinging me on slack, my username is @svovaf.
*
* @author Vova Feldman (@svovaf)
* @since 1.2.2
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$VARS = isset($VARS) ? $VARS : array();
$fs = freemius( $VARS['module_id'] );
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'json2' );
fs_enqueue_local_script( 'postmessage', 'nojquery.ba-postmessage.min.js' );
fs_enqueue_local_script( 'fs-postmessage', 'postmessage.js' );
?>
<?php if ( ! $fs->is_whitelabeled() ) : ?>
<div id="pframe"></div>
<script type="text/javascript">
(function ($) {
$(function () {
var
base_url = '<?php echo WP_FS__ADDRESS ?>',
pframe = $('<i' + 'frame id="fs_promo_tab" src="' + base_url + '/promotional-tab/?<?php echo http_build_query($VARS) ?>#' + encodeURIComponent(document.location.href) + '" height="350" width="60" frameborder="0" style=" background: transparent; position: fixed; top: 20%; right: 0;" scrolling="no"></i' + 'frame>')
.appendTo('#pframe');
FS.PostMessage.init(base_url);
FS.PostMessage.receive('state', function (state) {
if ('closed' === state)
$('#fs_promo_tab').css('width', '60px');
else
$('#fs_promo_tab').css('width', '345px');
});
});
})(jQuery);
</script>
<?php endif ?>

View File

@ -0,0 +1,209 @@
<?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
*/
/**
* Note for WordPress.org Theme/Plugin reviewer:
* Freemius is an SDK for plugin and theme developers. Since the core
* of the SDK is relevant both for plugins and themes, for obvious reasons,
* we only develop and maintain one code base.
*
* This code (and page) will not run for wp.org themes (only plugins).
*
* In addition, this page loads an i-frame. We intentionally named it 'frame'
* so it will pass the "Theme Check" that is looking for the string "i" . "frame".
*
* UPDATE:
* After ongoing conversations with the WordPress.org TRT we received
* an official approval for including i-frames in the theme's WP Admin setting's
* page tab (the SDK will never add any i-frames on the sitefront). i-frames
* were never against the guidelines, but we wanted to get the team's blessings
* before we move forward. For the record, I got the final approval from
* Ulrich Pogson (@grapplerulrich), a team lead at the TRT during WordCamp
* Europe 2017 (June 16th, 2017).
*
* If you have any questions or need clarifications, please don't hesitate
* pinging me on slack, my username is @svovaf.
*
* @author Vova Feldman (@svovaf)
* @since 1.2.2
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'json2' );
fs_enqueue_local_script( 'postmessage', 'nojquery.ba-postmessage.min.js' );
fs_enqueue_local_script( 'fs-postmessage', 'postmessage.js' );
fs_enqueue_local_style( 'fs_common', '/admin/common.css' );
/**
* @var array $VARS
* @var Freemius $fs
*/
$fs = freemius( $VARS['id'] );
$slug = $fs->get_slug();
$timestamp = time();
$context_params = array(
'plugin_id' => $fs->get_id(),
'plugin_public_key' => $fs->get_public_key(),
'plugin_version' => $fs->get_plugin_version(),
);
$bundle_id = $fs->get_bundle_id();
if ( ! is_null( $bundle_id ) ) {
$context_params['bundle_id'] = $bundle_id;
}
// Get site context secure params.
if ( $fs->is_registered() ) {
$context_params = array_merge( $context_params, FS_Security::instance()->get_context_params(
$fs->get_site(),
$timestamp,
'upgrade'
) );
} else {
$context_params['home_url'] = home_url();
}
if ( $fs->is_payments_sandbox() ) // Append plugin secure token for sandbox mode authentication.)
{
$context_params['sandbox'] = FS_Security::instance()->get_secure_token(
$fs->get_plugin(),
$timestamp,
'checkout'
);
}
$query_params = array_merge( $context_params, $_GET, array(
'next' => $fs->_get_sync_license_url( false, false ),
'plugin_version' => $fs->get_plugin_version(),
// Billing cycle.
'billing_cycle' => fs_request_get( 'billing_cycle', WP_FS__PERIOD_ANNUALLY ),
'is_network_admin' => fs_is_network_admin() ? 'true' : 'false',
'currency' => $fs->apply_filters( 'default_currency', 'usd' ),
) );
$use_external_pricing = $fs->should_use_external_pricing();
if ( ! $use_external_pricing ) {
$pricing_js_url = fs_asset_url( $fs->get_pricing_js_path() );
wp_enqueue_script( 'freemius-pricing', $pricing_js_url );
} else {
if ( ! $fs->is_registered() ) {
$template_data = array(
'id' => $fs->get_id(),
);
fs_require_template( 'forms/trial-start.php', $template_data);
}
$view_params = array(
'id' => $VARS['id'],
'page' => strtolower( $fs->get_text_x_inline( 'Pricing', 'noun', 'pricing' ) ),
);
fs_require_once_template('secure-https-header.php', $view_params);
}
$has_tabs = $fs->_add_tabs_before_content();
if ( $has_tabs ) {
$query_params['tabs'] = 'true';
}
?>
<div id="fs_pricing" class="wrap fs-section fs-full-size-wrapper">
<?php if ( ! $use_external_pricing ) : ?>
<div id="fs_pricing_wrapper" data-public-url="<?php echo trailingslashit( dirname( $pricing_js_url ) ) ?>"></div>
<?php
$pricing_config = array_merge( array(
'contact_url' => $fs->contact_url(),
'is_network_admin' => fs_is_network_admin(),
'is_production' => ( defined( 'WP_FS__IS_PRODUCTION_MODE' ) ? WP_FS__IS_PRODUCTION_MODE : null ),
'menu_slug' => $fs->get_menu_slug(),
'mode' => 'dashboard',
'fs_wp_endpoint_url' => WP_FS__ADDRESS,
'request_handler_url' => admin_url(
'admin-ajax.php?' . http_build_query( array(
'module_id' => $fs->get_id(),
'action' => $fs->get_ajax_action( 'pricing_ajax_action' ),
'security' => $fs->get_ajax_security( 'pricing_ajax_action' )
) )
),
'selector' => '#fs_pricing_wrapper',
'unique_affix' => $fs->get_unique_affix(),
), $query_params );
wp_add_inline_script( 'freemius-pricing', 'Freemius.pricing.new( ' . json_encode( $pricing_config ) . ' )' );
?>
<?php else : ?>
<div id="fs_frame"></div>
<form action="" method="POST">
<input type="hidden" name="user_id"/>
<input type="hidden" name="user_email"/>
<input type="hidden" name="site_id"/>
<input type="hidden" name="public_key"/>
<input type="hidden" name="secret_key"/>
<input type="hidden" name="action" value="account"/>
</form>
<script type="text/javascript">
(function ($, undef) {
$(function () {
var
// Keep track of the i-frame height.
frame_height = 800,
base_url = '<?php echo WP_FS__ADDRESS ?>',
// Pass the parent page URL into the i-frame in a meaningful way (this URL could be
// passed via query string or hard coded into the child page, it depends on your needs).
src = base_url + '/pricing/?<?php echo http_build_query( $query_params ) ?>#' + encodeURIComponent(document.location.href),
// Append the I-frame into the DOM.
frame = $('<i' + 'frame " src="' + src + '" width="100%" height="' + frame_height + 'px" scrolling="no" frameborder="0" style="background: transparent; width: 1px; min-width: 100%;"><\/i' + 'frame>')
.appendTo('#fs_frame');
FS.PostMessage.init(base_url, [frame[0]]);
FS.PostMessage.receive('height', function (data) {
var h = data.height;
if (!isNaN(h) && h > 0 && h != frame_height) {
frame_height = h;
frame.height(frame_height + 'px');
FS.PostMessage.postScroll(frame[0]);
}
});
FS.PostMessage.receive('get_dimensions', function (data) {
FS.PostMessage.post('dimensions', {
height : $(document.body).height(),
scrollTop: $(document).scrollTop()
}, frame[0]);
});
FS.PostMessage.receive('start_trial', function (data) {
openTrialConfirmationModal(data);
});
});
})(jQuery);
</script>
<?php endif ?>
</div>
<?php
if ( $has_tabs ) {
$fs->_add_tabs_after_content();
}
$params = array(
'page' => 'pricing',
'module_id' => $fs->get_id(),
'module_type' => $fs->get_module_type(),
'module_slug' => $slug,
'module_version' => $fs->get_plugin_version(),
);
fs_require_template( 'powered-by.php', $params );

View File

@ -0,0 +1,39 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.2.1.8
*
* @var array $VARS
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<div class="fs-secure-notice">
<i class="dashicons dashicons-lock"></i>
<span><?php
if ( ! empty( $VARS['message'] ) ) {
echo esc_html( $VARS['message'] );
} else {
/**
* @var Freemius $fs
*/
$fs = freemius( $VARS['id'] );
echo esc_html( sprintf(
/* translators: %s: Page name */
$fs->get_text_inline( 'Secure HTTPS %s page, running from an external domain', 'secure-x-page-header' ),
$VARS['page']
) ) .
' - ' .
sprintf(
'<a class="fs-security-proof" href="%s" target="_blank" rel="noopener">%s</a>',
'https://www.mcafeesecure.com/verify?host=' . WP_FS__ROOT_DOMAIN_PRODUCTION,
'Freemius Inc. [US]'
);
}
?></span>
</div>

View File

@ -0,0 +1,41 @@
<?php
/**
* Sticky admin notices JavaScript handler for dismissing notice messages
* by sending AJAX call to the server in order to remove the message from the Database.
*
* @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;
}
?>
<script type="text/javascript" >
jQuery( document ).ready(function( $ ) {
$( '.fs-notice.fs-sticky .fs-close' ).click(function() {
var
notice = $( this ).parents( '.fs-notice' ),
id = notice.attr( 'data-id' ),
ajaxActionSuffix = notice.attr( 'data-manager-id' ).replace( ':', '-' );
notice.fadeOut( 'fast', function() {
var data = {
action : 'fs_dismiss_notice_action_' + ajaxActionSuffix,
// As such we don't need to use `wp_json_encode` method but using it to follow wp.org guideline.
_wpnonce : <?php echo wp_json_encode( wp_create_nonce( 'fs_dismiss_notice_action' ) ); ?>,
message_id: id
};
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
$.post( ajaxurl, data, function( response ) {
});
notice.remove();
});
});
});
</script>

View File

@ -0,0 +1,63 @@
<?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;
}
/**
* @var array $VARS
* @var Freemius $fs
*/
$fs = freemius( $VARS['id'] );
$slug = $fs->get_slug();
?>
<script type="text/javascript">
(function ($) {
$(document).ready(function () {
var $wrap = $( '.wrap' );
if ( 0 === $wrap.length ) {
$wrap = $( '<div class="wrap">' );
$wrap.insertBefore( $( '#wpbody-content .clear' ) );
}
$wrap = $wrap.clone().wrap( '<div>' ).parent();
var
settingHtml = $wrap.html(),
tabsPosition = settingHtml.indexOf('nav-tab-wrapper'),
aboveTabsHtml = '';
if (-1 < tabsPosition) {
// Find the tabs HTML beginning exact position.
while ('<' !== settingHtml[tabsPosition] && 0 < tabsPosition) {
tabsPosition--;
}
if (-1 < tabsPosition) {
aboveTabsHtml = settingHtml.substr(0, tabsPosition);
var tabsHtml = $('.wrap .nav-tab-wrapper').clone().wrap('<div>').parent().html();
$.ajax({
url : ajaxurl + '?' + $.param({
action : '<?php echo $fs->get_ajax_action( 'store_tabs' ) ?>',
security : '<?php echo $fs->get_ajax_security( 'store_tabs' ) ?>',
module_id: '<?php echo $fs->get_id() ?>'
}),
method : 'POST',
data : aboveTabsHtml + "\n" + tabsHtml + '</div>',
dataType : 'html',
// Avoid escaping the HTML.
processData: false
});
}
}
});
})(jQuery);
</script>

View File

@ -0,0 +1,190 @@
<?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;
}
/**
* @var array $VARS
* @var Freemius $fs
*/
$fs = freemius( $VARS['id'] );
$slug = $fs->get_slug();
$menu_items = $fs->get_menu_items();
$show_settings_with_tabs = $fs->show_settings_with_tabs();
$tabs = array();
foreach ( $menu_items as $priority => $items ) {
foreach ( $items as $item ) {
if ( ! $item['show_submenu'] ) {
$submenu_name = ('wp-support-forum' === $item['menu_slug']) ?
'support' :
$item['menu_slug'];
if ( 'pricing' === $submenu_name && ! $fs->is_pricing_page_visible() ) {
continue;
}
if ( ! $show_settings_with_tabs || ! $fs->is_submenu_item_visible( $submenu_name, true ) ) {
continue;
}
}
$url = $fs->_get_admin_page_url( $item['menu_slug'] );
$title = $item['menu_title'];
$tab = array(
'label' => $title,
'href' => $url,
'slug' => $item['menu_slug'],
);
if ( 'pricing' === $item['menu_slug'] && $fs->is_in_trial_promotion() ) {
$tab['href'] .= '&trial=true';
}
$tabs[] = $tab;
}
}
?>
<script type="text/javascript">
(function ($) {
$(document).ready(function () {
var $wrap = $('.wrap');
if (0 === $wrap.length) {
$wrap = $('<div class="wrap">');
$wrap.insertBefore($('#wpbody-content .clear'));
}
var
$tabsWrapper = $('.nav-tab-wrapper'),
$tabs = $tabsWrapper.find('.nav-tab'),
$tab = null;
if (0 < $tabs.length) {
// Tries to set $tab to the first inactive tab.
for (var i = 0; i < $tabs.length; i++) {
$tab = $($tabs[i]);
if (!$tab.hasClass('nav-tab-active')) {
break;
}
}
}
<?php if (0 < count( $tabs )) : ?>
if (null == $tab) {
// No tabs found, therefore, create new tabs section if required.
var $h1 = $wrap.find('h1');
$tabsWrapper = $('<h2 class="nav-tab-wrapper"></h2>');
if (0 < $h1.length) {
$tabsWrapper.insertAfter($h1);
} else if (0 < $wrap.length) {
$wrap.prepend($tabsWrapper);
}
$tab = $('<a href="#" class="nav-tab"></a>');
}
// Create a clone.
$tab = $tab.clone();
// Open in current page.
$tab.removeAttr('target');
$tab.removeClass('nav-tab-active');
$tab.addClass('fs-tab');
$tab.addClass('<?php echo $fs->get_unique_affix() ?>');
var $tabClone = null;
<?php $freemius_context_page = null ?>
<?php foreach ($tabs as $tab) : ?>
<?php $is_support_tab = ( 'wp-support-forum' == $tab['slug'] ) ?>
// Add the Freemius tabs.
$tabClone = $tab.clone();
$tabClone.html(<?php echo json_encode( $tab['label'] ) ?>)
.attr('href', '<?php echo $is_support_tab ? $fs->get_support_forum_url() : $tab['href'] ?>')
.appendTo($tabsWrapper)
// Remove any custom click events.
.off('click', '**')
.addClass('<?php echo $tab['slug'] ?>')
// Avoid tab click triggering parent events.
.click(function (e) {
e.stopPropagation();
});
<?php if ($is_support_tab) : ?>
// Open support in a new tab/page.
$tabClone.attr('target', '_blank');
<?php endif ?>
<?php if ($fs->is_admin_page( $tab['slug'] )) : ?>
<?php $freemius_context_page = $tab['slug'] ?>
// Select the relevant Freemius tab.
$tabs.removeClass('nav-tab-active');
$tabClone.addClass('nav-tab-active');
<?php if (in_array( $freemius_context_page, array( 'pricing', 'contact', 'checkout' ) )) : ?>
// Add AJAX loader.
$tabClone.prepend('<i class="fs-ajax-spinner"></i>');
// Hide loader after content fully loaded.
$('.wrap i' + 'frame').load(function () {
$(".fs-ajax-spinner").hide();
});
<?php endif ?>
// Fix URLs that are starting with a hashtag.
$tabs.each(function (j, tab) {
if (0 === $(tab).attr('href').indexOf('#')) {
$(tab).attr('href', '<?php echo esc_js( $fs->main_menu_url() ) ?>' + $(tab).attr('href'));
}
});
<?php endif ?>
<?php endforeach ?>
var selectTab = function ($tab) {
$(window).load(function () {
$tab.click();
// Scroll to the top since the browser will auto scroll to the anchor.
document.body.scrollTop = 0;
document.body.scrollLeft = 0;
// window.scrollTo(0,0);
});
};
// If the URL is loaded with a hashtag, find the context tab and select it.
if (window.location.hash) {
for (var j = 0; j < $tabs.length; j++) {
if (window.location.hash === $($tabs[j]).attr('href')) {
selectTab($($tabs[j]));
break;
}
}
}
<?php if (is_string( $freemius_context_page ) && in_array( $freemius_context_page, array(
'pricing',
'contact',
'checkout'
) )) : ?>
// Add margin to the upper section of the tabs to give extra space for the HTTPS header.
// @todo This code assumes that the wrapper style is fully loaded, if there's a stylesheet that is not loaded via the HTML head, it may cause unpredicted margin-top.
var $tabsWrap = $tabsWrapper.parents('.wrap');
$tabsWrap.css('marginTop', (parseInt($tabsWrap.css('marginTop'), 10) + 30) + 'px');
<?php endif ?>
<?php endif ?>
});
})(jQuery);
</script>