: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
// Pending activation, add message.
return $this->set_pending_confirmation(
( isset( $decoded->email ) ?
! empty( $params['trial_plan_id'] ),
isset( $decoded->is_suspicious_email ) && $decoded->is_suspicious_email
} else if ( isset( $decoded->install_secret_key ) ) {
return $this->install_with_new_user(
$decoded->user_public_key,
$decoded->user_secret_key,
( isset( $decoded->is_marketing_allowed ) && ! is_null( $decoded->is_marketing_allowed ) ?
$decoded->is_marketing_allowed :
( isset( $decoded->is_extensions_tracking_allowed ) && ! is_null( $decoded->is_extensions_tracking_allowed ) ?
$decoded->is_extensions_tracking_allowed :
( isset( $decoded->is_diagnostic_tracking_allowed ) && ! is_null( $decoded->is_diagnostic_tracking_allowed ) ?
$decoded->is_diagnostic_tracking_allowed :
$decoded->install_public_key,
$decoded->install_secret_key,
} else if ( is_array( $decoded->installs ) ) {
return $this->install_many_with_new_user(
$decoded->user_public_key,
$decoded->user_secret_key,
( isset( $decoded->is_marketing_allowed ) && ! is_null( $decoded->is_marketing_allowed ) ?
$decoded->is_marketing_allowed :
( isset( $decoded->is_extensions_tracking_allowed ) && ! is_null( $decoded->is_extensions_tracking_allowed ) ?
$decoded->is_extensions_tracking_allowed :
( isset( $decoded->is_diagnostic_tracking_allowed ) && ! is_null( $decoded->is_diagnostic_tracking_allowed ) ?
$decoded->is_diagnostic_tracking_allowed :
* Set user and site identities.
* @author Vova Feldman (@svovaf)
* @param bool $auto_install Since 1.2.1.7 If `true` and setting up an account with a valid license, will
* redirect (or return a URL) to the account page with a special parameter to
* trigger the auto installation processes.
* @return string If redirect is `false`, returns the next page the user should be redirected to.
return $this->setup_network_account(
* Set user and site identities.
* @author Vova Feldman (@svovaf)
* @param FS_Site[] $installs
* @param bool $auto_install Since 1.2.1.7 If `true` and setting up an account with a valid license, will redirect (or return a URL) to the account page with a special parameter to trigger the auto installation processes.
* @param bool $is_network_level_opt_in
* @return string If redirect is `false`, returns the next page the user should be redirected to.
function setup_network_account(
$is_network_level_opt_in = true
$first_install = $installs[0];
$this->_site = $first_install;
if ( $this->_storage->handle_gdpr_admin_notice &&
$this->should_handle_gdpr_admin_notice() &&
FS_GDPR_Manager::instance()->should_show_opt_in_notice()
* Clear user lock after an opt-in.
require_once WP_FS__DIR_INCLUDES . '/class-fs-user-lock.php';
FS_User_Lock::instance()->unlock();
if ( 1 < count( $installs ) ) {
// Only network level opt-in can have more than one install.
$is_network_level_opt_in = true;
$this->update_connectivity_info( true );
// $is_network_level_opt_in = self::is_ajax_action_static( 'network_activate', $this->_module_id );
// If Freemius was OFF before, turn it on.
$this->handle_account_connection(
( ! $this->_is_network_active || ! $is_network_level_opt_in )
if ( is_numeric( $first_install->license_id ) ) {
$this->set_license( $this->_get_license_by_id( $first_install->license_id ) );
$this->_admin_notices->remove_sticky( 'connect_account' );
if ( $this->is_pending_activation() || ! $this->has_settings_menu() ) {
$this->clear_pending_activation_mode();
if ( ! $this->is_paying_or_trial() ) {
$this->_admin_notices->add_sticky(
sprintf( $this->get_text_inline( '%s opt-in was successfully completed.', 'plugin-x-activation-message' ), '<b>' . $this->get_plugin_name() . '</b>' ),
if ( $this->is_paying_or_trial() ) {
if ( ! $this->is_premium() ||
! $this->has_premium_version() ||
! $this->has_settings_menu()
if ( $this->is_paying() ) {
$this->add_complete_upgrade_instructions_notice(
$this->get_text_inline( 'Your account was successfully activated with the %s plan.', 'activation-with-plan-x-message' ),
$trial_plan = $this->get_trial_plan();
$this->add_complete_upgrade_instructions_notice(
$this->get_text_inline( 'Your trial has been successfully started.', 'trial-started-message' ),
'<i>' . $this->get_plugin_name() . '</i>'
$this->_admin_notices->remove_sticky( array(
$plugin_id = fs_request_get( 'plugin_id', false );
// Store activation time ONLY for plugins & themes (not add-ons).
if ( ! is_numeric( $plugin_id ) || ( $plugin_id == $this->_plugin->id ) ) {
if ( empty( $this->_storage->activation_timestamp ) ) {
$this->_storage->activation_timestamp = WP_FS__SCRIPT_START_TIME;
$extra['auto_install'] = 'true';
if ( is_numeric( $plugin_id ) ) {
* @author Leo Fajardo (@leorw)
* Also sync the license after an anonymous user subscribes.
if ( $this->is_anonymous() || $plugin_id != $this->_plugin->id ) {
// Add-on was installed - sync license right after install.
$next_page = $this->_get_sync_license_url( $plugin_id, true, $extra );
* @author Vova Feldman (@svovaf)
* @since 1.1.9 If site installed with a valid license, sync license.
if ( $this->is_paying() ) {
$this->_sync_plugin_license(
// Installs data is already synced in the beginning of this method directly or via _set_account().
// Reload the page with the keys.
$next_page = $this->is_anonymous() ?
// If user previously skipped, redirect to account page.
$this->get_account_url( false, $extra ) :
$this->get_after_activation_url( 'after_connect_url', array(), $is_network_level_opt_in );
if ( ! empty( $next_page ) && $redirect ) {
fs_redirect( $next_page );
* Install plugin with new user information after approval.
* @author Vova Feldman (@svovaf)
function _install_with_new_user() {
$this->_logger->entrance();
if ( $this->is_registered() ) {
$has_pending_activation_confirmation_param = fs_request_has( 'pending_activation' );
$this->update_license_required_permissions_if_anonymous();
if ( ( $this->is_plugin() && fs_request_is_action( $this->get_unique_affix() . '_activate_new' ) ) ||
// @todo This logic should be improved because it's executed on every load of a theme.
// check_admin_referer( $this->_slug . '_activate_new' );
if ( fs_request_has( 'user_secret_key' ) ) {
if ( fs_is_network_admin() && isset( $this->_storage->pending_sites_info ) ) {
$pending_sites_info = $this->_storage->pending_sites_info;
$this->install_many_pending_with_user(
fs_request_get( 'user_id' ),
fs_request_get_raw( 'user_public_key' ),
fs_request_get_raw( 'user_secret_key' ),
fs_request_get_bool( 'is_marketing_allowed', null ),
fs_request_get_bool( 'is_extensions_tracking_allowed', null ),
fs_request_get_bool( 'is_diagnostic_tracking_allowed', null ),
$pending_sites_info['blog_ids'],
$pending_sites_info['license_key'],
$pending_sites_info['trial_plan_id']
$this->install_with_new_user(
fs_request_get( 'user_id' ),
fs_request_get_raw( 'user_public_key' ),
fs_request_get_raw( 'user_secret_key' ),
fs_request_get_bool( 'is_marketing_allowed', null ),
fs_request_get_bool( 'is_extensions_tracking_allowed', null ),
fs_request_get_bool( 'is_diagnostic_tracking_allowed', null ),
fs_request_get( 'install_id' ),
fs_request_get_raw( 'install_public_key' ),
fs_request_get_raw( 'install_secret_key' ),
fs_request_get_bool( 'auto_install' )
} else if ( $has_pending_activation_confirmation_param ) {
$this->set_pending_confirmation(
fs_request_get( 'user_email' ),
fs_request_get_bool( 'is_suspicious_email' ),
fs_request_get_bool( 'has_upgrade_context' ),
fs_request_get( 'support_email_address' )
* @author Vova Feldman (@svovaf)
* @param string $public_key
* @param string $secret_key
private function setup_user( $id, $public_key, $secret_key ) {
$user = self::_get_user_by_id( $id );
if ( is_object( $user ) ) {
$user->public_key = $public_key;
$user->secret_key = $secret_key;
$user_result = $this->get_api_user_scope()->get();
$user = new FS_User( $user_result );
* Install plugin with new user.
* @author Vova Feldman (@svovaf)
* @param string $user_public_key
* @param string $user_secret_key
* @param bool|null $is_marketing_allowed
* @param bool|null $is_extensions_tracking_allowed Since 2.3.2
* @param bool|null $is_diagnostic_tracking_allowed Since 2.5.0.2
* @param number $install_id
* @param string $install_public_key
* @param string $install_secret_key
* @param bool $auto_install Since 1.2.1.7 If `true` and setting up an account with a valid license, will redirect (or return a URL) to the account page with a special parameter to trigger the auto installation processes.
* @return string If redirect is `false`, returns the next page the user should be redirected to.
private function install_with_new_user(
$is_extensions_tracking_allowed,
$is_diagnostic_tracking_allowed,
* This method is also executed after opting in with a license key since the
* license can be potentially associated with a different owner.
$user = self::_get_user_by_id( $user_id );
if ( ! is_object( $user ) ) {
$user->public_key = $user_public_key;
$user->secret_key = $user_secret_key;
$user_result = $this->get_api_user_scope()->get();
$user = new FS_User( $user_result );
$site->public_key = $install_public_key;
$site->secret_key = $install_secret_key;
$site_result = $this->get_api_site_scope( true )->get();
$site = new FS_Site( $site_result );
if ( ! is_null( $is_marketing_allowed ) ) {
$this->disable_opt_in_notice_and_lock_user();
FS_Permission_Manager::instance( $this )->update_permissions_tracking_flag( array(
FS_Permission_Manager::PERMISSION_DIAGNOSTIC => $is_diagnostic_tracking_allowed,
FS_Permission_Manager::PERMISSION_EXTENSIONS => $is_extensions_tracking_allowed,
return $this->setup_account(
* Install plugin with user.
* @author Leo Fajardo (@leorw)
* @param string $user_public_key
* @param string $user_secret_key
* @param bool|null $is_marketing_allowed
* @param bool|null $is_extensions_tracking_allowed Since 2.3.2
* @param bool|null $is_diagnostic_tracking_allowed Since 2.5.0.2
* @param bool $license_key
* @param bool $trial_plan_id
private function install_many_pending_with_user(
$is_extensions_tracking_allowed,
$is_diagnostic_tracking_allowed,
$user = $this->setup_user( $user_id, $user_public_key, $user_secret_key );
if ( ! is_null( $is_marketing_allowed ) ) {
$this->disable_opt_in_notice_and_lock_user();
FS_Permission_Manager::instance( $this )->update_permissions_tracking_flag( array(
FS_Permission_Manager::PERMISSION_DIAGNOSTIC => $is_diagnostic_tracking_allowed,
FS_Permission_Manager::PERMISSION_EXTENSIONS => $is_extensions_tracking_allowed,
foreach ( $site_ids as $site_id ) {
$sites[] = $this->get_site_info( array( 'blog_id' => $site_id ) );
$this->install_with_user( $user, $license_key, $trial_plan_id, $redirect, true, $sites );
* Multi-site install with a new user.
* @author Vova Feldman (@svovaf)
* @param string $user_public_key
* @param string $user_secret_key
* @param bool|null $is_marketing_allowed
* @param bool|null $is_extensions_tracking_allowed Since 2.3.2
* @param bool|null $is_diagnostic_tracking_allowed Since 2.5.0.2
* @param object[] $installs
* @param bool $auto_install Since 1.2.1.7 If `true` and setting up an account with a valid license, will redirect (or return a URL) to the account page with a special parameter to trigger the auto installation processes.
* @return string If redirect is `false`, returns the next page the user should be redirected to.
private function install_many_with_new_user(
$is_extensions_tracking_allowed,
$is_diagnostic_tracking_allowed,