: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
'id' => self::REASON_BROKE_MY_SITE,
'text' => sprintf( $this->get_text_inline( 'The %s broke my site', 'reason-broke-my-site' ), $module_type ),
'input_placeholder' => '',
'internal_message' => $contact_support_template
'id' => self::REASON_SUDDENLY_STOPPED_WORKING,
'text' => sprintf( $this->get_text_inline( 'The %s suddenly stopped working', 'reason-suddenly-stopped-working' ), $module_type ),
'input_placeholder' => '',
'internal_message' => $contact_support_template
if ( $this->is_paying() ) {
$long_term_user_reasons[] = array(
'id' => self::REASON_CANT_PAY_ANYMORE,
'text' => $this->get_text_inline( "I can't pay for it anymore", 'reason-cant-pay-anymore' ),
'input_type' => 'textfield',
'input_placeholder' => $this->get_text_inline( 'What price would you feel comfortable paying?', 'placeholder-comfortable-price' )
$reason_dont_share_info = array(
'id' => self::REASON_DONT_LIKE_TO_SHARE_MY_INFORMATION,
'text' => $this->get_text_inline( "I don't like to share my information with you", 'reason-dont-like-to-share-my-information' ),
'input_placeholder' => ''
* If the current user has selected the "don't share data" reason in the deactivation feedback modal, inform the
* user by showing additional message that he doesn't have to share data and can just choose to skip the opt-in
* (the Skip button is included in the message to show). This message will only be shown if anonymous mode is
* enabled and the user's account is currently not in pending activation state (similar to the way the Skip
* button in the opt-in form is shown/hidden).
if ( $this->is_enable_anonymous() && ! $this->is_pending_activation() ) {
$reason_dont_share_info['internal_message'] = fs_get_template( 'forms/deactivation/retry-skip.php', $internal_message_template_var );
$uninstall_reasons = array(
'long-term' => $long_term_user_reasons,
'non-registered-and-non-anonymous-short-term' => array(
'id' => self::REASON_DIDNT_WORK,
'text' => sprintf( $this->get_text_inline( "The %s didn't work", 'reason-didnt-work' ), $module_type ),
'input_placeholder' => ''
$reason_found_better_plugin
'id' => self::REASON_COULDNT_MAKE_IT_WORK,
'text' => $this->get_text_inline( "I couldn't understand how to make it work", 'reason-couldnt-make-it-work' ),
'input_placeholder' => '',
'internal_message' => $contact_support_template
$reason_found_better_plugin,
'id' => self::REASON_GREAT_BUT_NEED_SPECIFIC_FEATURE,
'text' => sprintf( $this->get_text_inline( "The %s is great, but I need specific feature that you don't support", 'reason-great-but-need-specific-feature' ), $module_type ),
'input_type' => 'textarea',
'input_placeholder' => $this->get_text_inline( 'What feature?', 'placeholder-feature' )
'id' => self::REASON_NOT_WORKING,
'text' => sprintf( $this->get_text_inline( 'The %s is not working', 'reason-not-working' ), $module_type ),
'input_type' => 'textarea',
'input_placeholder' => $this->get_text_inline( "Kindly share what didn't work so we can fix it for future users...", 'placeholder-share-what-didnt-work' )
'id' => self::REASON_NOT_WHAT_I_WAS_LOOKING_FOR,
'text' => $this->get_text_inline( "It's not what I was looking for", 'reason-not-what-i-was-looking-for' ),
'input_type' => 'textarea',
'input_placeholder' => $this->get_text_inline( "What you've been looking for?", 'placeholder-what-youve-been-looking-for' )
'id' => self::REASON_DIDNT_WORK_AS_EXPECTED,
'text' => sprintf( $this->get_text_inline( "The %s didn't work as expected", 'reason-didnt-work-as-expected' ), $module_type ),
'input_type' => 'textarea',
'input_placeholder' => $this->get_text_inline( 'What did you expect?', 'placeholder-what-did-you-expect' )
// Randomize the reasons for the current user type.
shuffle( $uninstall_reasons[ $user_type ] );
// Keep the following reasons as the last items in the list.
$uninstall_reasons[ $user_type ][] = $reason_temporary_deactivation;
$uninstall_reasons[ $user_type ][] = $reason_other;
$uninstall_reasons = $this->apply_filters( 'uninstall_reasons', $uninstall_reasons );
return $uninstall_reasons[ $user_type ];
* Called after the user has submitted his reason for deactivating the plugin.
* @author Leo Fajardo (@leorw)
function _submit_uninstall_reason_action() {
$this->_logger->entrance();
$this->check_ajax_referer( 'submit_uninstall_reason' );
$reason_id = fs_request_get( 'reason_id' );
// Check if the given reason ID is an unsigned integer.
if ( ! ctype_digit( $reason_id ) ) {
$reason_info = trim( fs_request_get( 'reason_info', '' ) );
if ( ! empty( $reason_info ) ) {
$reason_info = substr( $reason_info, 0, 128 );
$reason = (object) array(
'is_anonymous' => fs_request_get_bool( 'is_anonymous' )
$this->_storage->store( 'uninstall_reason', $reason );
if ( self::REASON_TEMPORARY_DEACTIVATION == $reason->id ) {
$snooze_period = fs_request_get( 'snooze_period' );
if ( is_numeric( $snooze_period ) && 0 < $snooze_period ) {
self::snooze_deactivation_form( (int) $snooze_period );
* If the module type is "theme", trigger the uninstall event here (on theme deactivation) since themes do
* not support uninstall hook.
* @author Leo Fajardo (@leorw)
if ( $this->is_theme() ) {
if ( $this->is_premium() && ! $this->has_active_valid_license() ) {
FS_Plugin_Updater::instance( $this )->delete_update_data();
$this->_uninstall_plugin_event( false );
$this->remove_sdk_reference();
// Print '1' for successful operation.
#--------------------------------------------------------------------------------
#region Deactivation Feedback Snoozing
#--------------------------------------------------------------------------------
* @author Vova Feldman (@svovaf)
* @return bool True if the value was set, false otherwise.
private static function snooze_deactivation_form( $period ) {
return ( 0 < $period && self::reset_deactivation_snoozing( $period ) );
* Check if deactivation feedback form is snoozed.
* @author Vova Feldman (@svovaf)
static function is_deactivation_snoozed() {
$is_snoozed = ( ! is_multisite() || fs_is_network_admin() ) ?
get_transient( 'fs_snooze_period' ) :
get_site_transient( 'fs_snooze_period' );
return ( 'true' === $is_snoozed );
* Reset deactivation snoozing. When `$period` is `0` will stop deactivation snoozing by deleting the transients. Otherwise, will set the transients for the selected period.
* @param int $period Period in seconds.
* @author Vova Feldman (@svovaf)
private static function reset_deactivation_snoozing( $period = 0 ) {
$value = ( 0 === $period ) ? null : 'true';
if ( ! is_multisite() || fs_is_network_admin() ) {
return set_transient( 'fs_snooze_period', $value, $period );
return set_site_transient( 'fs_snooze_period', $value, $period );
* The deactivation snooze expiration UNIX timestamp (in sec).
* @author Vova Feldman (@svovaf)
static function deactivation_snooze_expires_at() {
return ( ! is_multisite() || fs_is_network_admin() ) ?
(int) get_option( '_transient_timeout_fs_snooze_period' ) :
(int) get_site_option( '_site_transient_timeout_fs_snooze_period' );
* @author Leo Fajardo (@leorw)
function cancel_subscription_or_trial_ajax_action() {
$this->_logger->entrance();
$this->check_ajax_referer( 'cancel_subscription_or_trial' );
$result = $this->cancel_subscription_or_trial( fs_request_get( 'plugin_id', $this->get_id() ), false );
if ( $this->is_api_error( $result ) ) {
$this->shoot_ajax_failure( $result->error->message );
$this->shoot_ajax_success();
* @author Leo Fajardo (@leorw)
* @param number $plugin_id
private function cancel_subscription_or_trial( $plugin_id ) {
if ( $plugin_id == $this->get_id() ) {
} else if ( $this->is_addon_activated( $plugin_id ) ) {
$fs = self::get_instance_by_id( $plugin_id );
if ( ! is_null( $fs ) ) {
$result = $fs->is_paid_trial() ?
* @author Leo Fajardo (@leorw)
function _delete_theme_update_data_action() {
FS_Plugin_Updater::instance( $this )->delete_update_data();
#----------------------------------------------------------------------------------
#----------------------------------------------------------------------------------
* Main singleton instance.
* @author Vova Feldman (@svovaf)
* @param number $module_id
* @param string|bool $slug
* @param bool $is_init Is initiation sequence.
static function instance( $module_id, $slug = false, $is_init = false ) {
if ( empty( $module_id ) ) {
* Load the essential static data prior to initiating FS_Plugin_Manager since there's an essential MS network migration logic that needs to be executed prior to the initiation.
self::_load_required_static();
if ( ! is_numeric( $module_id ) ) {
if ( ! $is_init && true === $slug ) {
$module = FS_Plugin_Manager::instance( $slug )->get();
if ( is_object( $module ) ) {
$module_id = $module->id;
$key = 'm_' . $module_id;
if ( ! isset( self::$_instances[ $key ] ) ) {
self::$_instances[ $key ] = new Freemius( $module_id, $slug, $is_init );
return self::$_instances[ $key ];
* @author Vova Feldman (@svovaf)
* @param number $addon_id
private static function has_instance( $addon_id ) {
return isset( self::$_instances[ 'm_' . $addon_id ] );
* @author Leo Fajardo (@leorw)
* @param string|number $id_or_slug
* @param string $module_type
private static function get_module_id( $id_or_slug, $module_type = WP_FS__MODULE_TYPE_PLUGIN ) {
if ( is_numeric( $id_or_slug ) ) {
foreach ( self::$_instances as $instance ) {
// Also check the module type since there can be a plugin and a theme with the same slug.
if ( ( $module_type === $instance->get_module_type() ) && ( $id_or_slug === $instance->get_slug() ) ) {
return $instance->get_id();
* @author Vova Feldman (@svovaf)
static function get_instance_by_id( $id ) {
return isset ( self::$_instances[ 'm_' . $id ] ) ?
self::$_instances[ 'm_' . $id ] :
* @author Vova Feldman (@svovaf)
* @param string $plugin_file
* @param string $module_type
static function get_instance_by_file( $plugin_file, $module_type = WP_FS__MODULE_TYPE_PLUGIN ) {
$slug = self::find_slug_by_basename( $plugin_file );
return ( false !== $slug ) ?
self::instance( self::get_module_id( $slug, $module_type ) ) :
* @author Vova Feldman (@svovaf)
function get_parent_instance() {
return self::get_instance_by_id( $this->_plugin->parent_plugin_id );
* @author Vova Feldman (@svovaf)
* @param string|number $id_or_slug
function get_addon_instance( $id_or_slug ) {
$addon_id = self::get_module_id( $id_or_slug );
return self::instance( $addon_id );
static function _get_all_instances() {
return self::$_instances;
#endregion ------------------------------------------------------------------
* @author Vova Feldman (@svovaf)
function is_parent_plugin_installed() {
$is_active = self::has_instance( $this->_plugin->parent_plugin_id );
* Parent module might be a theme. If that's the case, the add-on's FS
* instance will be loaded prior to the theme's FS instance, therefore,
* we need to check if it's active with a "look ahead".
global $fs_active_plugins;
if ( is_object( $fs_active_plugins ) && is_array( $fs_active_plugins->plugins ) ) {
$active_theme = wp_get_theme();
foreach ( $fs_active_plugins->plugins as $sdk => $module ) {
if ( WP_FS__MODULE_TYPE_THEME === $module->type ) {
if ( $module->plugin_path == $active_theme->get_stylesheet() ) {
// Parent module is a theme and it's currently active.
* Check if add-on parent plugin in activation mode.
* @author Vova Feldman (@svovaf)
function is_parent_in_activation() {
$parent_fs = $this->get_parent_instance();
if ( ! is_object( $parent_fs ) ) {
return ( $parent_fs->is_activation_mode() );
* Is plugin in activation mode.
* @author Vova Feldman (@svovaf)
function is_activation_mode( $and_on = true ) {