Skip to content

Commit

Permalink
Merge pull request Freemius#455 from Freemius/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
vovafeldman authored Oct 16, 2020
2 parents 1c7e0bc + 5be2f2a commit 4f60bf8
Show file tree
Hide file tree
Showing 38 changed files with 6,387 additions and 5,893 deletions.
2 changes: 1 addition & 1 deletion assets/css/admin/account.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions assets/scss/admin/account.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
@import "../start";
@import "tag";

.fs-notice[data-id="license_not_whitelabeled"], .fs-notice[data-id="license_whitelabeled"] {
&.success {
color: inherit;
border-left-color: #00a0d2;

label.fs-plugin-title {
display: none;
}
}
}

#fs_account
{
.postbox,
Expand Down
5 changes: 4 additions & 1 deletion config.php
Original file line number Diff line number Diff line change
Expand Up @@ -385,4 +385,7 @@

if ( ! defined( 'WP_FS__DEMO_MODE' ) ) {
define( 'WP_FS__DEMO_MODE', false );
}
}
if ( ! defined( 'FS_SDK__SSLVERIFY' ) ) {
define( 'FS_SDK__SSLVERIFY', false );
}
113 changes: 107 additions & 6 deletions includes/class-freemius.php
Original file line number Diff line number Diff line change
Expand Up @@ -1674,6 +1674,7 @@ private function register_constructor_hooks() {
$this->add_ajax_action( 'update_billing', array( &$this, '_update_billing_ajax_action' ) );
$this->add_ajax_action( 'start_trial', array( &$this, '_start_trial_ajax_action' ) );
$this->add_ajax_action( 'set_data_debug_mode', array( &$this, '_set_data_debug_mode' ) );
$this->add_ajax_action( 'toggle_whitelabel_mode', array( &$this, '_toggle_whitelabel_mode_ajax_handler' ) );

if ( $this->_is_network_active && fs_is_network_admin() ) {
$this->add_ajax_action( 'network_activate', array( &$this, '_network_activate_ajax_action' ) );
Expand Down Expand Up @@ -7736,7 +7737,10 @@ function _activate_plugin_event_hook() {
* @author Leo Fajardo (@leorw)
* @since 1.2.2
*/
if ( is_plugin_active( $other_version_basename ) ) {
if (
is_plugin_active( $other_version_basename ) &&
$this->apply_filters( 'deactivate_on_activation', true )
) {
deactivate_plugins( $other_version_basename );
}
}
Expand Down Expand Up @@ -9021,12 +9025,25 @@ private function get_plugins_data_for_api() {
'is_uninstalled' => false,
);

$plugins_update_data[] = $new_plugin;
$network_plugins_cache->plugins[ $basename ] = $new_plugin;

$is_site_level_active = (
isset( $site_active_plugins[ $basename ] ) &&
$site_active_plugins[ $basename ]['is_active']
);

/**
* If not network active, set the activity status based on the site-level plugin status.
*/
if ( ! $new_plugin['is_active'] ) {
$new_plugin['is_active'] = $is_site_level_active;
}

$plugins_update_data[] = $new_plugin;

if ( isset( $site_active_plugins[ $basename ] ) ) {
$site_active_plugins_cache->plugins[ $basename ] = $new_plugin;
$site_active_plugins_cache->plugins[ $basename ]['is_active'] = true;
$site_active_plugins_cache->plugins[ $basename ]['is_active'] = $is_site_level_active;
}
}
}
Expand Down Expand Up @@ -13130,6 +13147,61 @@ function _add_premium_version_upgrade_selection() {
}
}

/**
* @author Edgar Melkonyan
* @since 2.4.1
*
* @throws Freemius_Exception
*/
function _toggle_whitelabel_mode_ajax_handler() {
$this->_logger->entrance();

$this->check_ajax_referer( 'toggle_whitelabel_mode' );

if ( ! $this->is_user_admin() ) {
// Only for admins.
self::shoot_ajax_failure();
}

$license = $this->get_api_user_scope()->call(
"/licenses/{$this->_site->license_id}.json",
'put',
array( 'is_whitelabeled' => ! $this->_license->is_whitelabeled )
);

if ( ! $this->is_api_result_entity( $license ) ) {
self::shoot_ajax_failure(
FS_Api::is_api_error_object( $license ) ?
$license->error->message :
fs_text_inline( "An unknown error has occurred while trying to toggle the license's white-label mode.", 'unknown-error-occurred', $this->get_slug() )
);
}

$this->_license->is_whitelabeled = $license->is_whitelabeled;
$this->_store_licenses();

$this->_sync_license();

if ( ! $license->is_whitelabeled ) {
$this->_admin_notices->remove_sticky( 'license_whitelabeled' );
} else {
$this->_admin_notices->add_sticky(
sprintf(
$this->get_text_inline(
'Your %s license was flagged as white-labeled to hide sensitive information from the WP Admin (e.g. your email, license key, prices, billing address & invoices). If you ever wish to revert it back, you can easily do it through your %s. If this was a mistake you can also %s.',
'license_whitelabeled'
),
"<strong>{$this->get_plugin_title()}</strong>",
sprintf( '<a href="https://users.freemius.com" target="_blank">%s</a>', $this->get_text_inline( 'User Dashboard', 'user-dashboard' ) ),
sprintf( '<a href="#" class="fs-toggle-whitelabel-mode">%s</a>', $this->get_text_inline( 'revert it now', 'revert-it-now' ) )
),
'license_whitelabeled'
);
}

self::shoot_ajax_response( array( 'success' => true ) );
}

/**
* @author Leo Fajardo (@leorw)
* @since 2.3.0
Expand Down Expand Up @@ -20679,6 +20751,13 @@ private function _sync_plugin_license(
}

if ( 'none' !== $plan_change ) {
if (
! is_object( $this->_license ) ||
! $this->_license->is_whitelabeled
) {
$this->_admin_notices->remove_sticky( 'license_whitelabeled' );
}

$this->do_action( 'after_license_change', $plan_change, $this->get_plan() );
}
}
Expand Down Expand Up @@ -22293,6 +22372,26 @@ function fs_addons_body_class( $classes ) {

$this->_handle_account_edits();

if (
is_object( $this->_license ) &&
$this->_license->user_id == $this->_user->id &&
! $this->is_whitelabeled( true )
) {
$this->_admin_notices->add(
sprintf(
$this->get_text_inline( "Is this your client's site? %s if you wish to hide sensitive info like your email, license key, prices, billing address & invoices from the WP Admin.", 'license_not_whitelabeled' ),
sprintf(
'<a href="#" class="fs-toggle-whitelabel-mode">%s</a>',
$this->get_text_inline( 'Click here', 'click-here' )
)
),
'',
'success',
false,
'license_not_whitelabeled'
);
}

$this->do_action( 'account_page_load_before_departure' );
}

Expand Down Expand Up @@ -23453,10 +23552,12 @@ function get_after_plugin_activation_redirect_url() {
* @since 1.0.3
*/
function _redirect_on_activation_hook() {
$url = $this->get_after_plugin_activation_redirect_url();
if ( $this->apply_filters( 'redirect_on_activation', true ) ) {
$url = $this->get_after_plugin_activation_redirect_url();

if ( is_string( $url ) ) {
fs_redirect( $url );
if ( is_string( $url ) ) {
fs_redirect( $url );
}
}
}

Expand Down
Loading

0 comments on commit 4f60bf8

Please sign in to comment.