Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/wp-conte.../plugins/content-.../inc/freemius/includes
File: class-freemius.php
/**
[7500] Fix | Delete
* Delete plugin's plans information.
[7501] Fix | Delete
*
[7502] Fix | Delete
* @param bool $store Flush to Database if true.
[7503] Fix | Delete
* @param bool $keep_associated_plans If set to false, delete all plans, even if a plan is associated with an install.
[7504] Fix | Delete
*
[7505] Fix | Delete
* @author Vova Feldman (@svovaf)
[7506] Fix | Delete
* @since 1.0.9
[7507] Fix | Delete
*/
[7508] Fix | Delete
private function _delete_plans( $store = true, $keep_associated_plans = true ) {
[7509] Fix | Delete
$this->_logger->entrance();
[7510] Fix | Delete
[7511] Fix | Delete
$plans = self::get_all_plans( $this->_module_type );
[7512] Fix | Delete
[7513] Fix | Delete
$plans_to_keep = array();
[7514] Fix | Delete
[7515] Fix | Delete
if ( $keep_associated_plans ) {
[7516] Fix | Delete
$plans_ids_to_keep = $this->get_plans_ids_associated_with_installs();
[7517] Fix | Delete
foreach ( $plans_ids_to_keep as $plan_id ) {
[7518] Fix | Delete
$plan = self::_get_plan_by_id( $plan_id );
[7519] Fix | Delete
if ( is_object( $plan ) ) {
[7520] Fix | Delete
$plans_to_keep[] = self::_encrypt_entity( $plan );
[7521] Fix | Delete
}
[7522] Fix | Delete
}
[7523] Fix | Delete
}
[7524] Fix | Delete
[7525] Fix | Delete
if ( ! empty( $plans_to_keep ) ) {
[7526] Fix | Delete
$plans[ $this->_slug ] = $plans_to_keep;
[7527] Fix | Delete
} else {
[7528] Fix | Delete
unset( $plans[ $this->_slug ] );
[7529] Fix | Delete
}
[7530] Fix | Delete
[7531] Fix | Delete
$this->set_account_option( 'plans', $plans, $store );
[7532] Fix | Delete
}
[7533] Fix | Delete
[7534] Fix | Delete
/**
[7535] Fix | Delete
* Delete all plugin licenses.
[7536] Fix | Delete
*
[7537] Fix | Delete
* @author Vova Feldman (@svovaf)
[7538] Fix | Delete
* @since 1.0.9
[7539] Fix | Delete
*
[7540] Fix | Delete
* @param bool $store
[7541] Fix | Delete
*/
[7542] Fix | Delete
private function _delete_licenses( $store = true ) {
[7543] Fix | Delete
$this->_logger->entrance();
[7544] Fix | Delete
[7545] Fix | Delete
$all_licenses = self::get_all_licenses();
[7546] Fix | Delete
[7547] Fix | Delete
unset( $all_licenses[ $this->_module_id ] );
[7548] Fix | Delete
[7549] Fix | Delete
self::$_accounts->set_option( 'all_licenses', $all_licenses, $store );
[7550] Fix | Delete
}
[7551] Fix | Delete
[7552] Fix | Delete
/**
[7553] Fix | Delete
* Check if Freemius was added on new plugin installation.
[7554] Fix | Delete
*
[7555] Fix | Delete
* @author Vova Feldman (@svovaf)
[7556] Fix | Delete
* @since 1.1.5
[7557] Fix | Delete
*
[7558] Fix | Delete
* @return bool
[7559] Fix | Delete
*/
[7560] Fix | Delete
function is_plugin_new_install() {
[7561] Fix | Delete
return isset( $this->_storage->is_plugin_new_install ) &&
[7562] Fix | Delete
$this->_storage->is_plugin_new_install;
[7563] Fix | Delete
}
[7564] Fix | Delete
[7565] Fix | Delete
/**
[7566] Fix | Delete
* Check if it's the first plugin release that is running Freemius.
[7567] Fix | Delete
*
[7568] Fix | Delete
* @author Vova Feldman (@svovaf)
[7569] Fix | Delete
* @since 1.2.1.5
[7570] Fix | Delete
*
[7571] Fix | Delete
* @return bool
[7572] Fix | Delete
*/
[7573] Fix | Delete
function is_first_freemius_powered_version() {
[7574] Fix | Delete
return empty( $this->_storage->plugin_last_version );
[7575] Fix | Delete
}
[7576] Fix | Delete
[7577] Fix | Delete
/**
[7578] Fix | Delete
* @author Leo Fajardo (@leorw)
[7579] Fix | Delete
* @since 1.2.2
[7580] Fix | Delete
*
[7581] Fix | Delete
* @return bool|string
[7582] Fix | Delete
*/
[7583] Fix | Delete
private function get_previous_theme_slug() {
[7584] Fix | Delete
return isset( $this->_storage->previous_theme ) ?
[7585] Fix | Delete
$this->_storage->previous_theme :
[7586] Fix | Delete
false;
[7587] Fix | Delete
}
[7588] Fix | Delete
[7589] Fix | Delete
/**
[7590] Fix | Delete
* @author Leo Fajardo (@leorw)
[7591] Fix | Delete
* @since 1.2.2
[7592] Fix | Delete
*
[7593] Fix | Delete
* @return bool
[7594] Fix | Delete
*/
[7595] Fix | Delete
private function can_activate_previous_theme() {
[7596] Fix | Delete
return $this->can_activate_theme( $this->get_previous_theme_slug() );
[7597] Fix | Delete
}
[7598] Fix | Delete
[7599] Fix | Delete
/**
[7600] Fix | Delete
* @author Leo Fajardo (@leorw)
[7601] Fix | Delete
* @since 2.5.0
[7602] Fix | Delete
*
[7603] Fix | Delete
* @return bool
[7604] Fix | Delete
*/
[7605] Fix | Delete
private function can_activate_theme( $slug ) {
[7606] Fix | Delete
if ( false !== $slug && current_user_can( 'switch_themes' ) ) {
[7607] Fix | Delete
$theme_instance = wp_get_theme( $slug );
[7608] Fix | Delete
[7609] Fix | Delete
return $theme_instance->exists();
[7610] Fix | Delete
}
[7611] Fix | Delete
[7612] Fix | Delete
return false;
[7613] Fix | Delete
}
[7614] Fix | Delete
[7615] Fix | Delete
/**
[7616] Fix | Delete
* @author Leo Fajardo (@leorw)
[7617] Fix | Delete
* @since 1.2.2
[7618] Fix | Delete
*/
[7619] Fix | Delete
private function activate_previous_theme() {
[7620] Fix | Delete
switch_theme( $this->get_previous_theme_slug() );
[7621] Fix | Delete
unset( $this->_storage->previous_theme );
[7622] Fix | Delete
[7623] Fix | Delete
global $pagenow;
[7624] Fix | Delete
if ( 'themes.php' === $pagenow ) {
[7625] Fix | Delete
/**
[7626] Fix | Delete
* Refresh the active theme information.
[7627] Fix | Delete
*
[7628] Fix | Delete
* @author Leo Fajardo (@leorw)
[7629] Fix | Delete
* @since 1.2.2
[7630] Fix | Delete
*/
[7631] Fix | Delete
fs_redirect( $this->admin_url( $pagenow ) );
[7632] Fix | Delete
}
[7633] Fix | Delete
}
[7634] Fix | Delete
[7635] Fix | Delete
/**
[7636] Fix | Delete
* @author Leo Fajardo (@leorw)
[7637] Fix | Delete
* @since 1.2.2
[7638] Fix | Delete
*
[7639] Fix | Delete
* @return string
[7640] Fix | Delete
*/
[7641] Fix | Delete
function get_previous_theme_activation_url() {
[7642] Fix | Delete
if ( ! $this->can_activate_previous_theme() ) {
[7643] Fix | Delete
return '';
[7644] Fix | Delete
}
[7645] Fix | Delete
[7646] Fix | Delete
/**
[7647] Fix | Delete
* Activation URL
[7648] Fix | Delete
*
[7649] Fix | Delete
* @author Leo Fajardo (@leorw)
[7650] Fix | Delete
* @since 1.2.2
[7651] Fix | Delete
*/
[7652] Fix | Delete
return wp_nonce_url(
[7653] Fix | Delete
$this->admin_url( 'themes.php?action=activate&stylesheet=' . urlencode( $this->get_previous_theme_slug() ) ),
[7654] Fix | Delete
'switch-theme_' . $this->get_previous_theme_slug()
[7655] Fix | Delete
);
[7656] Fix | Delete
}
[7657] Fix | Delete
[7658] Fix | Delete
/**
[7659] Fix | Delete
* Saves the slug of the previous theme if it still exists so that it can be used by the logic in the opt-in
[7660] Fix | Delete
* form that decides whether to add a close button to the opt-in dialog or not. So after a premium-only theme is
[7661] Fix | Delete
* activated, the close button will appear and will reactivate the previous theme if clicked. If the previous
[7662] Fix | Delete
* theme doesn't exist, then there will be no close button.
[7663] Fix | Delete
*
[7664] Fix | Delete
* @author Leo Fajardo (@leorw)
[7665] Fix | Delete
* @since 1.2.2
[7666] Fix | Delete
*
[7667] Fix | Delete
* @param string $slug_or_name Old theme's slug or name.
[7668] Fix | Delete
* @param bool|WP_Theme $old_theme WP_Theme instance of the old theme if it still exists.
[7669] Fix | Delete
*/
[7670] Fix | Delete
function _activate_theme_event_hook( $slug_or_name, $old_theme = false ) {
[7671] Fix | Delete
$this->_storage->previous_theme = ( false !== $old_theme ) ?
[7672] Fix | Delete
$old_theme->get_stylesheet() :
[7673] Fix | Delete
$slug_or_name;
[7674] Fix | Delete
[7675] Fix | Delete
$this->_activate_plugin_event_hook();
[7676] Fix | Delete
}
[7677] Fix | Delete
[7678] Fix | Delete
/**
[7679] Fix | Delete
* Plugin activated hook.
[7680] Fix | Delete
*
[7681] Fix | Delete
* @author Vova Feldman (@svovaf)
[7682] Fix | Delete
* @since 1.0.1
[7683] Fix | Delete
*
[7684] Fix | Delete
* @uses FS_Api
[7685] Fix | Delete
*/
[7686] Fix | Delete
function _activate_plugin_event_hook() {
[7687] Fix | Delete
$this->_logger->entrance( 'slug = ' . $this->_slug );
[7688] Fix | Delete
[7689] Fix | Delete
if ( ! $this->is_user_admin() ) {
[7690] Fix | Delete
return;
[7691] Fix | Delete
}
[7692] Fix | Delete
[7693] Fix | Delete
$this->unregister_uninstall_hook();
[7694] Fix | Delete
[7695] Fix | Delete
// Clear API cache on activation.
[7696] Fix | Delete
FS_Api::clear_cache();
[7697] Fix | Delete
[7698] Fix | Delete
$is_premium_version_activation = $this->is_plugin() ?
[7699] Fix | Delete
( current_filter() !== ( 'activate_' . $this->_free_plugin_basename ) ) :
[7700] Fix | Delete
$this->is_premium();
[7701] Fix | Delete
[7702] Fix | Delete
if ( $is_premium_version_activation && $this->is_pending_activation() ) {
[7703] Fix | Delete
$this->clear_pending_activation_mode();
[7704] Fix | Delete
}
[7705] Fix | Delete
[7706] Fix | Delete
$this->_logger->info( 'Activating ' . ( $is_premium_version_activation ? 'premium' : 'free' ) . ' plugin version.' );
[7707] Fix | Delete
[7708] Fix | Delete
if ( $this->is_plugin() ) {
[7709] Fix | Delete
// This logic is relevant only to plugins since both the free and premium versions of a plugin can be active at the same time.
[7710] Fix | Delete
// 1. If running in the activation of the FREE module, get the basename of the PREMIUM.
[7711] Fix | Delete
// 2. If running in the activation of the PREMIUM module, get the basename of the FREE.
[7712] Fix | Delete
$other_version_basename = $is_premium_version_activation ?
[7713] Fix | Delete
$this->_free_plugin_basename :
[7714] Fix | Delete
$this->premium_plugin_basename();
[7715] Fix | Delete
[7716] Fix | Delete
if ( ! $this->_is_network_active ) {
[7717] Fix | Delete
/**
[7718] Fix | Delete
* Themes are always network activated, but the ACTUAL activation is per site.
[7719] Fix | Delete
*
[7720] Fix | Delete
* During the activation, the plugin isn't yet active, therefore,
[7721] Fix | Delete
* _is_network_active will be set to false even if it's a network level
[7722] Fix | Delete
* activation. So we need to fix that by looking at the is_network_admin() value.
[7723] Fix | Delete
*
[7724] Fix | Delete
* @author Vova Feldman
[7725] Fix | Delete
*/
[7726] Fix | Delete
$this->_is_network_active = (
[7727] Fix | Delete
$this->_is_multisite_integrated &&
[7728] Fix | Delete
fs_is_network_admin()
[7729] Fix | Delete
);
[7730] Fix | Delete
}
[7731] Fix | Delete
[7732] Fix | Delete
/**
[7733] Fix | Delete
* If the other module version is active, deactivate it.
[7734] Fix | Delete
*
[7735] Fix | Delete
* is_plugin_active() checks if the plugin is active on the site or the network level and
[7736] Fix | Delete
* deactivate_plugins() deactivates the plugin whether it's activated on the site or network level.
[7737] Fix | Delete
*
[7738] Fix | Delete
* @author Leo Fajardo (@leorw)
[7739] Fix | Delete
* @since 1.2.2
[7740] Fix | Delete
*/
[7741] Fix | Delete
if (
[7742] Fix | Delete
is_plugin_active( $other_version_basename ) &&
[7743] Fix | Delete
$this->apply_filters( 'deactivate_on_activation', true )
[7744] Fix | Delete
) {
[7745] Fix | Delete
deactivate_plugins( $other_version_basename );
[7746] Fix | Delete
}
[7747] Fix | Delete
}
[7748] Fix | Delete
[7749] Fix | Delete
if ( $this->is_registered() ) {
[7750] Fix | Delete
if ( $is_premium_version_activation ) {
[7751] Fix | Delete
$this->reconnect_locally();
[7752] Fix | Delete
}
[7753] Fix | Delete
[7754] Fix | Delete
[7755] Fix | Delete
// Schedule re-activation event and sync.
[7756] Fix | Delete
// $this->sync_install( array(), true );
[7757] Fix | Delete
$this->schedule_install_sync();
[7758] Fix | Delete
[7759] Fix | Delete
// If activating the premium module version, add an admin notice to congratulate for an upgrade completion.
[7760] Fix | Delete
if ( $is_premium_version_activation ) {
[7761] Fix | Delete
$this->_admin_notices->add(
[7762] Fix | Delete
sprintf( $this->get_text_inline( 'The upgrade of %s was successfully completed.', 'successful-version-upgrade-message' ), sprintf( '<b>%s</b>', $this->_plugin->title ) ),
[7763] Fix | Delete
$this->get_text_x_inline( 'W00t',
[7764] Fix | Delete
'Used to express elation, enthusiasm, or triumph (especially in electronic communication).', 'woot' ) . '!'
[7765] Fix | Delete
);
[7766] Fix | Delete
}
[7767] Fix | Delete
} else if ( $this->is_anonymous() ) {
[7768] Fix | Delete
if ( isset( $this->_storage->is_anonymous_ms ) && $this->_storage->is_anonymous_ms['is'] ) {
[7769] Fix | Delete
$plugin_version = $this->_storage->is_anonymous_ms['version'];
[7770] Fix | Delete
$network = true;
[7771] Fix | Delete
} else {
[7772] Fix | Delete
$plugin_version = isset( $this->_storage->is_anonymous ) ?
[7773] Fix | Delete
$this->_storage->is_anonymous['version'] :
[7774] Fix | Delete
null;
[7775] Fix | Delete
$network = false;
[7776] Fix | Delete
}
[7777] Fix | Delete
[7778] Fix | Delete
/**
[7779] Fix | Delete
* Reset "skipped" click cache on the following:
[7780] Fix | Delete
* 1. Freemius DEV mode.
[7781] Fix | Delete
* 2. WordPress DEBUG mode.
[7782] Fix | Delete
* 3. If a plugin and the user skipped the exact same version before.
[7783] Fix | Delete
*
[7784] Fix | Delete
* @since 1.2.2.7 Ulrich Pogson (@grapplerulrich) asked to not reset the SKIPPED flag if the exact same THEME version was activated before unless the developer is running with WP_DEBUG on, or Freemius debug mode on (WP_FS__DEV_MODE).
[7785] Fix | Delete
*
[7786] Fix | Delete
* @todo 4. If explicitly asked to retry after every activation.
[7787] Fix | Delete
*/
[7788] Fix | Delete
if ( WP_FS__DEV_MODE ||
[7789] Fix | Delete
(
[7790] Fix | Delete
( $this->is_plugin() || ( defined( 'WP_DEBUG' ) && WP_DEBUG ) ) &&
[7791] Fix | Delete
$this->get_plugin_version() == $plugin_version
[7792] Fix | Delete
)
[7793] Fix | Delete
) {
[7794] Fix | Delete
$this->reset_anonymous_mode( $network );
[7795] Fix | Delete
}
[7796] Fix | Delete
}
[7797] Fix | Delete
[7798] Fix | Delete
$is_trial_or_has_features_enabled_license = ( $this->is_trial() || $this->has_features_enabled_license() );
[7799] Fix | Delete
[7800] Fix | Delete
if ( $this->is_addon() && ! $is_trial_or_has_features_enabled_license ) {
[7801] Fix | Delete
/**
[7802] Fix | Delete
* When activating an add-on, try to also activate a license.
[7803] Fix | Delete
*
[7804] Fix | Delete
* @author Leo Fajardo (@leorw)
[7805] Fix | Delete
* @since 2.3.0
[7806] Fix | Delete
*/
[7807] Fix | Delete
if ( ! $this->_is_network_active ) {
[7808] Fix | Delete
$this->maybe_activate_addon_license();
[7809] Fix | Delete
} else {
[7810] Fix | Delete
$this->maybe_network_activate_addon_license();
[7811] Fix | Delete
}
[7812] Fix | Delete
[7813] Fix | Delete
/**
[7814] Fix | Delete
* Avoid redirecting to the license activation screen after automatically activating an add-on license.
[7815] Fix | Delete
*
[7816] Fix | Delete
* @author Leo Fajardo (@leorw)
[7817] Fix | Delete
* @since 2.3.0
[7818] Fix | Delete
*/
[7819] Fix | Delete
$is_trial_or_has_features_enabled_license = ( $this->is_trial() || $this->has_features_enabled_license() );
[7820] Fix | Delete
[7821] Fix | Delete
if ( $is_trial_or_has_features_enabled_license && true === $this->_storage->require_license_activation ) {
[7822] Fix | Delete
$this->_storage->require_license_activation = false;
[7823] Fix | Delete
}
[7824] Fix | Delete
}
[7825] Fix | Delete
[7826] Fix | Delete
if (
[7827] Fix | Delete
$is_premium_version_activation &&
[7828] Fix | Delete
(
[7829] Fix | Delete
( ! $this->is_registered() && $this->is_anonymous() ) ||
[7830] Fix | Delete
(
[7831] Fix | Delete
$this->is_registered() &&
[7832] Fix | Delete
! $is_trial_or_has_features_enabled_license
[7833] Fix | Delete
)
[7834] Fix | Delete
)
[7835] Fix | Delete
) {
[7836] Fix | Delete
$this->_storage->require_license_activation = true;
[7837] Fix | Delete
}
[7838] Fix | Delete
[7839] Fix | Delete
if ( ! isset( $this->_storage->is_plugin_new_install ) ) {
[7840] Fix | Delete
/**
[7841] Fix | Delete
* If no previous version of plugin's version exist, it means that it's either
[7842] Fix | Delete
* the first time that the plugin installed on the site, or the plugin was installed
[7843] Fix | Delete
* before but didn't have Freemius integrated.
[7844] Fix | Delete
*
[7845] Fix | Delete
* Since register_activation_hook() do NOT fires on updates since 3.1, and only fires
[7846] Fix | Delete
* on manual activation via the dashboard, is_plugin_activation() is TRUE
[7847] Fix | Delete
* only after immediate activation.
[7848] Fix | Delete
*
[7849] Fix | Delete
* @since 1.1.4
[7850] Fix | Delete
* @link https://make.wordpress.org/core/2010/10/27/plugin-activation-hooks-no-longer-fire-for-updates/
[7851] Fix | Delete
*/
[7852] Fix | Delete
$this->_storage->is_plugin_new_install = empty( $this->_storage->plugin_last_version );
[7853] Fix | Delete
}
[7854] Fix | Delete
[7855] Fix | Delete
/**
[7856] Fix | Delete
* Also flush when activating the premium version so that even if Freemius was off before, the API
[7857] Fix | Delete
* connectivity test can be run again.
[7858] Fix | Delete
*
[7859] Fix | Delete
* @author Leo Fajardo (@leorw)
[7860] Fix | Delete
* @since 2.2.3.1
[7861] Fix | Delete
*/
[7862] Fix | Delete
$has_api_connectivity = $this->has_api_connectivity( WP_FS__DEV_MODE || $is_premium_version_activation );
[7863] Fix | Delete
[7864] Fix | Delete
if ( ! $this->_anonymous_mode &&
[7865] Fix | Delete
( false !== $has_api_connectivity ) &&
[7866] Fix | Delete
! $this->_isAutoInstall
[7867] Fix | Delete
) {
[7868] Fix | Delete
// Store hint that the plugin was just activated to enable auto-redirection to settings.
[7869] Fix | Delete
set_transient( "fs_{$this->_module_type}_{$this->_slug}_activated", true, 60 );
[7870] Fix | Delete
}
[7871] Fix | Delete
[7872] Fix | Delete
/**
[7873] Fix | Delete
* Activation hook is executed after the plugin's main file is loaded, therefore,
[7874] Fix | Delete
* after the plugin was loaded. The logic is located at activate_plugin()
[7875] Fix | Delete
* ./wp-admin/includes/plugin.php.
[7876] Fix | Delete
*
[7877] Fix | Delete
* @author Vova Feldman (@svovaf)
[7878] Fix | Delete
* @since 1.1.9
[7879] Fix | Delete
*/
[7880] Fix | Delete
$this->_storage->was_plugin_loaded = true;
[7881] Fix | Delete
}
[7882] Fix | Delete
[7883] Fix | Delete
/**
[7884] Fix | Delete
* @author Leo Fajardo (@leorw)
[7885] Fix | Delete
* @since 2.3.0
[7886] Fix | Delete
*/
[7887] Fix | Delete
private function maybe_activate_addon_license() {
[7888] Fix | Delete
$parent_fs = $this->get_parent_instance();
[7889] Fix | Delete
[7890] Fix | Delete
if (
[7891] Fix | Delete
! is_object( $parent_fs ) ||
[7892] Fix | Delete
( ! $parent_fs->is_registered() && ! $parent_fs->is_network_registered() )
[7893] Fix | Delete
) {
[7894] Fix | Delete
// Try to activate a license only if the parent plugin is active and has a valid `install`.
[7895] Fix | Delete
return;
[7896] Fix | Delete
}
[7897] Fix | Delete
[7898] Fix | Delete
$license = $this->get_active_parent_license();
[7899] Fix | Delete
if ( ! is_object( $license ) ) {
[7900] Fix | Delete
return;
[7901] Fix | Delete
}
[7902] Fix | Delete
[7903] Fix | Delete
if (
[7904] Fix | Delete
$this->is_bundle_license_auto_activation_enabled() &&
[7905] Fix | Delete
! empty( $license->products )
[7906] Fix | Delete
) {
[7907] Fix | Delete
$this->activate_bundle_license( $license );
[7908] Fix | Delete
[7909] Fix | Delete
return;
[7910] Fix | Delete
}
[7911] Fix | Delete
[7912] Fix | Delete
if ( ! $this->is_registered() ) {
[7913] Fix | Delete
// Opt in with a license key.
[7914] Fix | Delete
$this->opt_in(
[7915] Fix | Delete
$parent_fs->get_current_or_network_user()->email,
[7916] Fix | Delete
false,
[7917] Fix | Delete
false,
[7918] Fix | Delete
$license->secret_key
[7919] Fix | Delete
);
[7920] Fix | Delete
} else {
[7921] Fix | Delete
// Activate the license.
[7922] Fix | Delete
$install = $this->api_site_call(
[7923] Fix | Delete
'/',
[7924] Fix | Delete
'put',
[7925] Fix | Delete
array( 'license_key' => $this->apply_filters( 'license_key', $license->secret_key ) )
[7926] Fix | Delete
);
[7927] Fix | Delete
[7928] Fix | Delete
if ( ! FS_Api::is_api_error( $install ) ) {
[7929] Fix | Delete
$this->_sync_addon_license( $this->get_id(), true );
[7930] Fix | Delete
}
[7931] Fix | Delete
}
[7932] Fix | Delete
}
[7933] Fix | Delete
[7934] Fix | Delete
/**
[7935] Fix | Delete
* @author Leo Fajardo (@leorw)
[7936] Fix | Delete
* @since 2.3.0
[7937] Fix | Delete
*
[7938] Fix | Delete
* @param FS_Plugin_License $license
[7939] Fix | Delete
*/
[7940] Fix | Delete
private function maybe_network_activate_addon_license( $license = null ) {
[7941] Fix | Delete
$parent_fs = $this->get_parent_instance();
[7942] Fix | Delete
if ( ! is_object( $parent_fs ) || ( ! $parent_fs->is_registered() && ! $parent_fs->is_network_registered() ) ) {
[7943] Fix | Delete
// Try to activate a license only if the parent plugin is active and has a valid `install`.
[7944] Fix | Delete
return;
[7945] Fix | Delete
}
[7946] Fix | Delete
[7947] Fix | Delete
$license = ( ! is_null( $license ) ) ?
[7948] Fix | Delete
$license :
[7949] Fix | Delete
$this->get_active_parent_license();
[7950] Fix | Delete
[7951] Fix | Delete
if ( ! is_object( $license ) ) {
[7952] Fix | Delete
return;
[7953] Fix | Delete
}
[7954] Fix | Delete
[7955] Fix | Delete
if (
[7956] Fix | Delete
$this->is_bundle_license_auto_activation_enabled() &&
[7957] Fix | Delete
! empty( $license->products )
[7958] Fix | Delete
) {
[7959] Fix | Delete
$this->activate_bundle_license( $license );
[7960] Fix | Delete
[7961] Fix | Delete
return;
[7962] Fix | Delete
}
[7963] Fix | Delete
[7964] Fix | Delete
if ( ! $this->is_network_registered() ) {
[7965] Fix | Delete
$sites = $this->get_sites_for_network_level_optin();
[7966] Fix | Delete
[7967] Fix | Delete
if ( count( $sites ) > $license->left() ) {
[7968] Fix | Delete
// If the add-on is network active, try to activate the license only if it can be activated on all sites.
[7969] Fix | Delete
return;
[7970] Fix | Delete
}
[7971] Fix | Delete
[7972] Fix | Delete
// Opt in with a license key.
[7973] Fix | Delete
$this->opt_in(
[7974] Fix | Delete
$parent_fs->get_user()->email,
[7975] Fix | Delete
false,
[7976] Fix | Delete
false,
[7977] Fix | Delete
$license->secret_key,
[7978] Fix | Delete
false,
[7979] Fix | Delete
false,
[7980] Fix | Delete
false,
[7981] Fix | Delete
null,
[7982] Fix | Delete
$sites
[7983] Fix | Delete
);
[7984] Fix | Delete
} else {
[7985] Fix | Delete
$blog_2_install_map = array();
[7986] Fix | Delete
$site_ids = array();
[7987] Fix | Delete
[7988] Fix | Delete
$all_sites = Freemius::get_sites();
[7989] Fix | Delete
[7990] Fix | Delete
foreach ( $all_sites as $site ) {
[7991] Fix | Delete
$blog_id = Freemius::get_site_blog_id( $site );
[7992] Fix | Delete
$install = $this->get_install_by_blog_id( $blog_id );
[7993] Fix | Delete
[7994] Fix | Delete
if ( is_object( $install ) && FS_Plugin_License::is_valid_id( $install->license_id ) ) {
[7995] Fix | Delete
// Skip license activation for installs that are already associated with a license.
[7996] Fix | Delete
continue;
[7997] Fix | Delete
}
[7998] Fix | Delete
[7999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function