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
if ( $this->apply_filters( 'has_paid_plan_account', $this->has_paid_plan() ) ) {
[21500] Fix | Delete
switch ( $plan_change ) {
[21501] Fix | Delete
case 'none':
[21502] Fix | Delete
if ( ! $background && is_admin() ) {
[21503] Fix | Delete
$plan = $this->is_trial() ?
[21504] Fix | Delete
$this->get_trial_plan() :
[21505] Fix | Delete
$this->get_plan();
[21506] Fix | Delete
[21507] Fix | Delete
if ( $plan->is_free() ) {
[21508] Fix | Delete
$this->_admin_notices->add(
[21509] Fix | Delete
sprintf(
[21510] Fix | Delete
$this->get_text_inline( 'It looks like you are still on the %s plan. If you did upgrade or change your plan, it\'s probably an issue on our side - sorry.', 'plan-did-not-change-message' ),
[21511] Fix | Delete
'<i><b>' . $plan->title . ( $this->is_trial() ? ' ' . $this->get_text_x_inline( 'Trial', 'trial period', 'trial' ) : '' ) . '</b></i>'
[21512] Fix | Delete
) . ' ' . sprintf(
[21513] Fix | Delete
'<a href="%s">%s</a>',
[21514] Fix | Delete
$this->contact_url(
[21515] Fix | Delete
'bug',
[21516] Fix | Delete
sprintf( $this->get_text_inline( 'I have upgraded my account but when I try to Sync the License, the plan remains %s.', 'plan-did-not-change-email-message' ),
[21517] Fix | Delete
strtoupper( $plan->name )
[21518] Fix | Delete
)
[21519] Fix | Delete
),
[21520] Fix | Delete
$this->get_text_inline( 'Please contact us here', 'contact-us-here' )
[21521] Fix | Delete
),
[21522] Fix | Delete
$hmm_text
[21523] Fix | Delete
);
[21524] Fix | Delete
}
[21525] Fix | Delete
}
[21526] Fix | Delete
break;
[21527] Fix | Delete
case 'upgraded':
[21528] Fix | Delete
case 'activated':
[21529] Fix | Delete
$this->add_after_plan_activation_or_upgrade_instructions_notice( 'upgraded' === $plan_change );
[21530] Fix | Delete
[21531] Fix | Delete
$this->_admin_notices->remove_sticky( array(
[21532] Fix | Delete
'trial_started',
[21533] Fix | Delete
'trial_promotion',
[21534] Fix | Delete
'trial_expired',
[21535] Fix | Delete
'activation_complete',
[21536] Fix | Delete
'license_expired',
[21537] Fix | Delete
) );
[21538] Fix | Delete
break;
[21539] Fix | Delete
case 'changed':
[21540] Fix | Delete
$this->_admin_notices->add_sticky(
[21541] Fix | Delete
sprintf(
[21542] Fix | Delete
$this->get_text_inline( 'Your plan was successfully changed to %s.', 'plan-changed-to-x-message' ),
[21543] Fix | Delete
$this->get_plan_title()
[21544] Fix | Delete
),
[21545] Fix | Delete
'plan_changed'
[21546] Fix | Delete
);
[21547] Fix | Delete
[21548] Fix | Delete
$this->_admin_notices->remove_sticky( array(
[21549] Fix | Delete
'trial_started',
[21550] Fix | Delete
'trial_promotion',
[21551] Fix | Delete
'trial_expired',
[21552] Fix | Delete
'activation_complete',
[21553] Fix | Delete
) );
[21554] Fix | Delete
break;
[21555] Fix | Delete
case 'downgraded':
[21556] Fix | Delete
$this->_admin_notices->add_sticky(
[21557] Fix | Delete
($this->has_free_plan() ?
[21558] Fix | Delete
sprintf( $this->get_text_inline( 'Your license has expired. You can still continue using the free %s forever.', 'license-expired-blocking-message' ), $this->_module_type ) :
[21559] Fix | Delete
/* translators: %1$s: product title; %2$s, %3$s: wrapping HTML anchor element; %4$s: 'plugin', 'theme', or 'add-on'. */
[21560] Fix | Delete
sprintf( $this->get_text_inline( 'Your license has expired. %1$sUpgrade now%2$s to continue using the %3$s without interruptions.', 'license-expired-blocking-message_premium-only' ), sprintf('<a href="%s">', $this->pricing_url()), '</a>', $this->get_module_label(true) ) ),
[21561] Fix | Delete
'license_expired',
[21562] Fix | Delete
$hmm_text
[21563] Fix | Delete
);
[21564] Fix | Delete
$this->_admin_notices->remove_sticky( 'plan_upgraded' );
[21565] Fix | Delete
break;
[21566] Fix | Delete
case 'cancelled':
[21567] Fix | Delete
$this->_admin_notices->add(
[21568] Fix | Delete
$this->get_text_inline( 'Your license has been cancelled. If you think it\'s a mistake, please contact support.', 'license-cancelled' ) . ' ' .
[21569] Fix | Delete
sprintf(
[21570] Fix | Delete
'<a href="%s">%s</a>',
[21571] Fix | Delete
$this->contact_url( 'bug' ),
[21572] Fix | Delete
$this->get_text_inline( 'Please contact us here', 'contact-us-here' )
[21573] Fix | Delete
),
[21574] Fix | Delete
$hmm_text,
[21575] Fix | Delete
'error'
[21576] Fix | Delete
);
[21577] Fix | Delete
$this->_admin_notices->remove_sticky( 'plan_upgraded' );
[21578] Fix | Delete
break;
[21579] Fix | Delete
case 'expired':
[21580] Fix | Delete
$this->_admin_notices->add_sticky(
[21581] Fix | Delete
sprintf( $this->get_text_inline( 'Your license has expired. You can still continue using all the %s features, but you\'ll need to renew your license to continue getting updates and support.', 'license-expired-non-blocking-message' ), $this->get_plan()->title ),
[21582] Fix | Delete
'license_expired',
[21583] Fix | Delete
$hmm_text
[21584] Fix | Delete
);
[21585] Fix | Delete
[21586] Fix | Delete
$this->_storage->expired_license_notice_shown = WP_FS__SCRIPT_START_TIME;
[21587] Fix | Delete
[21588] Fix | Delete
$this->_admin_notices->remove_sticky( 'plan_upgraded' );
[21589] Fix | Delete
break;
[21590] Fix | Delete
case 'trial_started':
[21591] Fix | Delete
$this->add_complete_upgrade_instructions_notice(
[21592] Fix | Delete
sprintf(
[21593] Fix | Delete
$this->get_text_inline( 'Your trial has been successfully started.', 'trial-started-message' ),
[21594] Fix | Delete
'<i>' . $this->get_plugin_name() . '</i>'
[21595] Fix | Delete
),
[21596] Fix | Delete
'trial_started',
[21597] Fix | Delete
$this->get_trial_plan()->title
[21598] Fix | Delete
);
[21599] Fix | Delete
[21600] Fix | Delete
$this->_admin_notices->remove_sticky( array(
[21601] Fix | Delete
'trial_promotion',
[21602] Fix | Delete
) );
[21603] Fix | Delete
break;
[21604] Fix | Delete
case 'trial_expired':
[21605] Fix | Delete
$this->_admin_notices->add_sticky(
[21606] Fix | Delete
($this->has_free_plan() ?
[21607] Fix | Delete
$this->get_text_inline( 'Your free trial has expired. You can still continue using all our free features.', 'trial-expired-message' ) :
[21608] Fix | Delete
/* translators: %1$s: product title; %2$s, %3$s: wrapping HTML anchor element; %4$s: 'plugin', 'theme', or 'add-on'. */
[21609] Fix | Delete
sprintf( $this->get_text_inline( 'Your free trial has expired. %1$sUpgrade now%2$s to continue using the %3$s without interruptions.', 'trial-expired-message_premium-only' ), sprintf('<a href="%s">', $this->pricing_url()), '</a>', $this->get_module_label(true))),
[21610] Fix | Delete
'trial_expired',
[21611] Fix | Delete
$hmm_text
[21612] Fix | Delete
);
[21613] Fix | Delete
$this->_admin_notices->remove_sticky( array(
[21614] Fix | Delete
'trial_started',
[21615] Fix | Delete
'trial_promotion',
[21616] Fix | Delete
'plan_upgraded',
[21617] Fix | Delete
) );
[21618] Fix | Delete
break;
[21619] Fix | Delete
}
[21620] Fix | Delete
}
[21621] Fix | Delete
[21622] Fix | Delete
if ( 'none' !== $plan_change ) {
[21623] Fix | Delete
if (
[21624] Fix | Delete
! is_object( $this->_license ) ||
[21625] Fix | Delete
! $this->_license->is_whitelabeled
[21626] Fix | Delete
) {
[21627] Fix | Delete
$this->_admin_notices->remove_sticky( 'license_whitelabeled' );
[21628] Fix | Delete
}
[21629] Fix | Delete
[21630] Fix | Delete
$this->do_action( 'after_license_change', $plan_change, $this->get_plan() );
[21631] Fix | Delete
}
[21632] Fix | Delete
}
[21633] Fix | Delete
[21634] Fix | Delete
/**
[21635] Fix | Delete
* @author Leo Fajardo (@leorw)
[21636] Fix | Delete
* @since 2.5.4
[21637] Fix | Delete
*
[21638] Fix | Delete
* @param mixed $result
[21639] Fix | Delete
*
[21640] Fix | Delete
* @return string
[21641] Fix | Delete
*/
[21642] Fix | Delete
private function generate_api_blocked_notice_message_from_result( $result ) {
[21643] Fix | Delete
$api_domains = $this->apply_filters( 'api_domains', array(
[21644] Fix | Delete
'api.freemius.com',
[21645] Fix | Delete
'wp.freemius.com',
[21646] Fix | Delete
) );
[21647] Fix | Delete
[21648] Fix | Delete
$api_domains_list_items = '';
[21649] Fix | Delete
[21650] Fix | Delete
foreach( $api_domains as $api_domain ) {
[21651] Fix | Delete
$api_domains_list_items .= "<li>{$api_domain}</li>";
[21652] Fix | Delete
}
[21653] Fix | Delete
[21654] Fix | Delete
$error_message = sprintf(
[21655] Fix | Delete
$this->get_text_inline( 'Your server is blocking the access to Freemius\' API, which is crucial for %1$s synchronization. Please contact your host to whitelist the following domains:%2$s', 'server-blocking-access' ),
[21656] Fix | Delete
$this->get_plugin_name(),
[21657] Fix | Delete
"<ol>{$api_domains_list_items}</ol><a href='#' class='fs-api-request-error-show-details-link'>" . $this->get_text_inline( 'Show error details', 'show-error-details' ) . " <span class='dashicons dashicons-arrow-down-alt2'></span></a>"
[21658] Fix | Delete
);
[21659] Fix | Delete
[21660] Fix | Delete
$error_message =
[21661] Fix | Delete
"<div>{$error_message}</div>" .
[21662] Fix | Delete
'<div class="fs-api-request-error-details" style="display: none">' .
[21663] Fix | Delete
'<strong>' . $this->get_text_inline( 'Error received from the server:', 'server-error-message' ) . '</strong><br>' .
[21664] Fix | Delete
$result->error->message .
[21665] Fix | Delete
'</div>';
[21666] Fix | Delete
[21667] Fix | Delete
return $error_message;
[21668] Fix | Delete
}
[21669] Fix | Delete
[21670] Fix | Delete
/**
[21671] Fix | Delete
* Include the required JS at the footer of the admin to trigger the license activation dialog box.
[21672] Fix | Delete
*
[21673] Fix | Delete
* @author Vova Feldman (@svovaf)
[21674] Fix | Delete
* @since 2.0.0
[21675] Fix | Delete
*/
[21676] Fix | Delete
public function _open_license_activation_dialog_box() {
[21677] Fix | Delete
$vars = array( 'license_id' => $this->_site->license_id );
[21678] Fix | Delete
fs_require_once_template( 'js/open-license-activation.php', $vars );
[21679] Fix | Delete
}
[21680] Fix | Delete
[21681] Fix | Delete
/**
[21682] Fix | Delete
* @author Vova Feldman (@svovaf)
[21683] Fix | Delete
* @since 1.0.5
[21684] Fix | Delete
*
[21685] Fix | Delete
* @param bool $background
[21686] Fix | Delete
* @param FS_Plugin_License|null $premium_license
[21687] Fix | Delete
*/
[21688] Fix | Delete
protected function _activate_license( $background = false, $premium_license = null ) {
[21689] Fix | Delete
$this->_logger->entrance();
[21690] Fix | Delete
[21691] Fix | Delete
if ( is_null( $premium_license ) ) {
[21692] Fix | Delete
$license_id = fs_request_get( 'license_id' );
[21693] Fix | Delete
[21694] Fix | Delete
if ( is_object( $this->_site ) &&
[21695] Fix | Delete
FS_Plugin_License::is_valid_id( $license_id ) &&
[21696] Fix | Delete
$license_id == $this->_site->license_id
[21697] Fix | Delete
) {
[21698] Fix | Delete
// License is already activated.
[21699] Fix | Delete
return;
[21700] Fix | Delete
}
[21701] Fix | Delete
[21702] Fix | Delete
$premium_license = FS_Plugin_License::is_valid_id( $license_id ) ?
[21703] Fix | Delete
$this->_get_license_by_id( $license_id ) :
[21704] Fix | Delete
$this->_get_available_premium_license();
[21705] Fix | Delete
}
[21706] Fix | Delete
[21707] Fix | Delete
if ( ! is_object( $premium_license ) ) {
[21708] Fix | Delete
return;
[21709] Fix | Delete
}
[21710] Fix | Delete
[21711] Fix | Delete
if ( ! is_object( $this->_site ) ) {
[21712] Fix | Delete
// Not yet opted-in.
[21713] Fix | Delete
$user = $this->get_current_or_network_user();
[21714] Fix | Delete
if ( ! is_object( $user ) ) {
[21715] Fix | Delete
$user = self::_get_user_by_id( $premium_license->user_id );
[21716] Fix | Delete
}
[21717] Fix | Delete
[21718] Fix | Delete
if ( is_object( $user ) ) {
[21719] Fix | Delete
$this->install_with_user( $user, $premium_license->secret_key, false, false, false );
[21720] Fix | Delete
} else {
[21721] Fix | Delete
$this->opt_in(
[21722] Fix | Delete
false,
[21723] Fix | Delete
false,
[21724] Fix | Delete
false,
[21725] Fix | Delete
$premium_license->secret_key
[21726] Fix | Delete
);
[21727] Fix | Delete
[21728] Fix | Delete
return;
[21729] Fix | Delete
}
[21730] Fix | Delete
}
[21731] Fix | Delete
[21732] Fix | Delete
[21733] Fix | Delete
/**
[21734] Fix | Delete
* If the premium license is already associated with the install, just
[21735] Fix | Delete
* update the license reference (activation is not required).
[21736] Fix | Delete
*
[21737] Fix | Delete
* @since 1.1.9
[21738] Fix | Delete
*/
[21739] Fix | Delete
if ( $premium_license->id == $this->_site->license_id ) {
[21740] Fix | Delete
// License is already activated.
[21741] Fix | Delete
$this->_update_site_license( $premium_license );
[21742] Fix | Delete
$this->_store_account();
[21743] Fix | Delete
[21744] Fix | Delete
return;
[21745] Fix | Delete
}
[21746] Fix | Delete
[21747] Fix | Delete
if ( $this->_site->user_id != $premium_license->user_id ) {
[21748] Fix | Delete
$api_request_params = array( 'license_key' => $premium_license->secret_key );
[21749] Fix | Delete
} else {
[21750] Fix | Delete
$api_request_params = array();
[21751] Fix | Delete
}
[21752] Fix | Delete
[21753] Fix | Delete
$api = $this->get_api_site_scope();
[21754] Fix | Delete
$license = $api->call( "/licenses/{$premium_license->id}.json?is_enriched=true", 'put', $api_request_params );
[21755] Fix | Delete
[21756] Fix | Delete
if ( ! $this->is_api_result_entity( $license ) ) {
[21757] Fix | Delete
if ( ! $background ) {
[21758] Fix | Delete
$this->_admin_notices->add( sprintf(
[21759] Fix | Delete
'%s %s',
[21760] Fix | Delete
$this->get_text_inline( 'It looks like the license could not be activated.', 'license-activation-failed-message' ),
[21761] Fix | Delete
( is_object( $license ) && isset( $license->error ) ?
[21762] Fix | Delete
$license->error->message :
[21763] Fix | Delete
sprintf( '%s<br><code>%s</code>',
[21764] Fix | Delete
$this->get_text_inline( 'Error received from the server:', 'server-error-message' ),
[21765] Fix | Delete
var_export( $license, true )
[21766] Fix | Delete
)
[21767] Fix | Delete
)
[21768] Fix | Delete
),
[21769] Fix | Delete
$this->get_text_x_inline( 'Hmm', 'something somebody says when they are thinking about what you have just said.', 'hmm' ) . '...',
[21770] Fix | Delete
'error'
[21771] Fix | Delete
);
[21772] Fix | Delete
}
[21773] Fix | Delete
[21774] Fix | Delete
return;
[21775] Fix | Delete
}
[21776] Fix | Delete
[21777] Fix | Delete
$premium_license = new FS_Plugin_License( $license );
[21778] Fix | Delete
[21779] Fix | Delete
// Updated site plan.
[21780] Fix | Delete
$site = $this->get_api_site_scope()->get( '/', true );
[21781] Fix | Delete
if ( $this->is_api_result_entity( $site ) ) {
[21782] Fix | Delete
$this->_site = new FS_Site( $site );
[21783] Fix | Delete
}
[21784] Fix | Delete
$this->_update_site_license( $premium_license );
[21785] Fix | Delete
[21786] Fix | Delete
$this->_store_account();
[21787] Fix | Delete
[21788] Fix | Delete
if ( $this->is_addon() || $this->has_addons() ) {
[21789] Fix | Delete
/**
[21790] Fix | Delete
* Purge the valid user licenses cache so that when the "Account" or the "Add-Ons" page is loaded,
[21791] Fix | Delete
* an updated valid user licenses collection will be fetched from the server which is used to also
[21792] Fix | Delete
* update the account add-ons (add-ons the user has licenses for).
[21793] Fix | Delete
*
[21794] Fix | Delete
* @author Leo Fajardo (@leorw)
[21795] Fix | Delete
* @since 2.2.4
[21796] Fix | Delete
*/
[21797] Fix | Delete
$this->purge_valid_user_licenses_cache();
[21798] Fix | Delete
}
[21799] Fix | Delete
[21800] Fix | Delete
if ( ! $background ) {
[21801] Fix | Delete
$this->add_complete_upgrade_instructions_notice(
[21802] Fix | Delete
$this->get_text_inline( 'Your license was successfully activated.', 'license-activated-message' ),
[21803] Fix | Delete
'license_activated'
[21804] Fix | Delete
);
[21805] Fix | Delete
}
[21806] Fix | Delete
[21807] Fix | Delete
$this->_admin_notices->remove_sticky( array(
[21808] Fix | Delete
'trial_promotion',
[21809] Fix | Delete
'license_expired',
[21810] Fix | Delete
) );
[21811] Fix | Delete
}
[21812] Fix | Delete
[21813] Fix | Delete
/**
[21814] Fix | Delete
* @author Vova Feldman (@svovaf)
[21815] Fix | Delete
* @since 1.0.5
[21816] Fix | Delete
*
[21817] Fix | Delete
* @param bool $show_notice
[21818] Fix | Delete
*/
[21819] Fix | Delete
protected function _deactivate_license( $show_notice = true ) {
[21820] Fix | Delete
$this->_logger->entrance();
[21821] Fix | Delete
[21822] Fix | Delete
$hmm_text = $this->get_text_x_inline( 'Hmm', 'something somebody says when they are thinking about what you have just said.', 'hmm' ) . '...';
[21823] Fix | Delete
[21824] Fix | Delete
if ( ! FS_Plugin_License::is_valid_id( $this->_site->license_id ) ) {
[21825] Fix | Delete
$this->_admin_notices->add(
[21826] Fix | Delete
sprintf( $this->get_text_inline( 'It looks like your site currently doesn\'t have an active license.', 'no-active-license-message' ), $this->get_plan_title() ),
[21827] Fix | Delete
$hmm_text
[21828] Fix | Delete
);
[21829] Fix | Delete
[21830] Fix | Delete
return;
[21831] Fix | Delete
}
[21832] Fix | Delete
[21833] Fix | Delete
$api = $this->get_api_site_scope();
[21834] Fix | Delete
$license = $api->call( "/licenses/{$this->_site->license_id}.json", 'delete' );
[21835] Fix | Delete
[21836] Fix | Delete
$this->handle_license_deactivation_result( $license, $hmm_text, $show_notice );
[21837] Fix | Delete
}
[21838] Fix | Delete
[21839] Fix | Delete
/**
[21840] Fix | Delete
* @author Leo Fajardo (@leorw)
[21841] Fix | Delete
* @since 2.2.1
[21842] Fix | Delete
*
[21843] Fix | Delete
* @param FS_Plugin_License $license
[21844] Fix | Delete
* @param bool|string $hmm_text
[21845] Fix | Delete
* @param bool $show_notice
[21846] Fix | Delete
*/
[21847] Fix | Delete
private function handle_license_deactivation_result( $license, $hmm_text = false, $show_notice = true ) {
[21848] Fix | Delete
if ( isset( $license->error ) ) {
[21849] Fix | Delete
$this->_admin_notices->add(
[21850] Fix | Delete
$this->get_text_inline( 'It looks like the license deactivation failed.', 'license-deactivation-failed-message' ) . '<br> ' .
[21851] Fix | Delete
$this->get_text_inline( 'Error received from the server:', 'server-error-message' ) . ' ' . var_export( $license->error, true ),
[21852] Fix | Delete
$hmm_text,
[21853] Fix | Delete
'error'
[21854] Fix | Delete
);
[21855] Fix | Delete
[21856] Fix | Delete
return;
[21857] Fix | Delete
}
[21858] Fix | Delete
[21859] Fix | Delete
// Update license cache.
[21860] Fix | Delete
if ( is_array( $this->_licenses ) ) {
[21861] Fix | Delete
for ( $i = 0, $len = count( $this->_licenses ); $i < $len; $i ++ ) {
[21862] Fix | Delete
if ( $license->id == $this->_licenses[ $i ]->id ) {
[21863] Fix | Delete
$this->_licenses[ $i ] = new FS_Plugin_License( $license );
[21864] Fix | Delete
}
[21865] Fix | Delete
}
[21866] Fix | Delete
}
[21867] Fix | Delete
[21868] Fix | Delete
// Update site plan to default.
[21869] Fix | Delete
$this->_sync_plans();
[21870] Fix | Delete
$this->_site->plan_id = $this->_plans[0]->id;
[21871] Fix | Delete
// Unlink license from site.
[21872] Fix | Delete
$this->_update_site_license( null );
[21873] Fix | Delete
[21874] Fix | Delete
$this->_store_account();
[21875] Fix | Delete
[21876] Fix | Delete
if ( $show_notice ) {
[21877] Fix | Delete
$this->_admin_notices->add(
[21878] Fix | Delete
sprintf( $this->is_only_premium() ?
[21879] Fix | Delete
$this->get_text_inline( 'Your %s license was successfully deactivated.', 'license-deactivation-message_premium-only' ) :
[21880] Fix | Delete
$this->get_text_inline( 'Your license was successfully deactivated, you are back to the %s plan.', 'license-deactivation-message' ),
[21881] Fix | Delete
$this->get_plan_title()
[21882] Fix | Delete
),
[21883] Fix | Delete
$this->get_text_inline( 'O.K', 'ok' )
[21884] Fix | Delete
);
[21885] Fix | Delete
}
[21886] Fix | Delete
[21887] Fix | Delete
$this->_admin_notices->remove_sticky( array(
[21888] Fix | Delete
'plan_upgraded',
[21889] Fix | Delete
'license_activated',
[21890] Fix | Delete
) );
[21891] Fix | Delete
}
[21892] Fix | Delete
[21893] Fix | Delete
/**
[21894] Fix | Delete
* Site plan downgrade.
[21895] Fix | Delete
*
[21896] Fix | Delete
* @author Vova Feldman (@svovaf)
[21897] Fix | Delete
* @since 1.0.4
[21898] Fix | Delete
*
[21899] Fix | Delete
* @return object
[21900] Fix | Delete
*
[21901] Fix | Delete
* @uses FS_Api
[21902] Fix | Delete
*/
[21903] Fix | Delete
private function _downgrade_site() {
[21904] Fix | Delete
$this->_logger->entrance();
[21905] Fix | Delete
[21906] Fix | Delete
$deactivate_license = fs_request_get_bool( 'deactivate_license' );
[21907] Fix | Delete
[21908] Fix | Delete
$api = $this->get_api_site_scope();
[21909] Fix | Delete
$site = $api->call( 'downgrade.json', 'put', array( 'deactivate_license' => $deactivate_license ) );
[21910] Fix | Delete
[21911] Fix | Delete
$plan_downgraded = false;
[21912] Fix | Delete
$plan = false;
[21913] Fix | Delete
if ( $this->is_api_result_entity( $site ) ) {
[21914] Fix | Delete
$prev_plan_id = $this->_site->plan_id;
[21915] Fix | Delete
[21916] Fix | Delete
// Update new site plan id.
[21917] Fix | Delete
$this->_site->plan_id = $site->plan_id;
[21918] Fix | Delete
[21919] Fix | Delete
$plan = $this->get_plan();
[21920] Fix | Delete
$subscription = $this->_sync_site_subscription( $this->_license );
[21921] Fix | Delete
[21922] Fix | Delete
// Plan downgraded if plan was changed or subscription was cancelled.
[21923] Fix | Delete
$plan_downgraded = ( $plan instanceof FS_Plugin_Plan && $prev_plan_id != $plan->id ) ||
[21924] Fix | Delete
( is_object( $subscription ) && ! isset( $subscription->error ) && ! $subscription->is_active() );
[21925] Fix | Delete
} else {
[21926] Fix | Delete
// handle different error cases.
[21927] Fix | Delete
$this->handle_license_deactivation_result(
[21928] Fix | Delete
$site,
[21929] Fix | Delete
$this->get_text_x_inline( 'Hmm', 'something somebody says when they are thinking about what you have just said.', 'hmm' ) . '...'
[21930] Fix | Delete
);
[21931] Fix | Delete
}
[21932] Fix | Delete
[21933] Fix | Delete
if ( ! $plan_downgraded ) {
[21934] Fix | Delete
return (object) array(
[21935] Fix | Delete
'error' => (object) array(
[21936] Fix | Delete
'message' => $this->get_text_inline( 'Seems like we are having some temporary issue with your subscription cancellation. Please try again in few minutes.', 'subscription-cancellation-failure-message' )
[21937] Fix | Delete
)
[21938] Fix | Delete
);
[21939] Fix | Delete
}
[21940] Fix | Delete
[21941] Fix | Delete
// Remove previous sticky message about upgrade (if exist).
[21942] Fix | Delete
$this->_admin_notices->remove_sticky( 'plan_upgraded' );
[21943] Fix | Delete
[21944] Fix | Delete
$this->_admin_notices->add(
[21945] Fix | Delete
sprintf( $this->get_text_inline( 'Your subscription was successfully cancelled. Your %s plan license will expire in %s.', 'plan-x-downgraded-message' ),
[21946] Fix | Delete
$plan->title,
[21947] Fix | Delete
human_time_diff( time(), strtotime( $this->_license->expiration ) )
[21948] Fix | Delete
)
[21949] Fix | Delete
);
[21950] Fix | Delete
[21951] Fix | Delete
// Store site updates.
[21952] Fix | Delete
$this->_store_site();
[21953] Fix | Delete
[21954] Fix | Delete
if ( $deactivate_license &&
[21955] Fix | Delete
! FS_Plugin_License::is_valid_id( $site->license_id )
[21956] Fix | Delete
) {
[21957] Fix | Delete
if ( $this->_site->is_localhost() ) {
[21958] Fix | Delete
$this->_license->activated_local = max( 0, $this->_license->activated_local - 1 );
[21959] Fix | Delete
} else {
[21960] Fix | Delete
$this->_license->activated = max( 0, $this->_license->activated - 1 );
[21961] Fix | Delete
}
[21962] Fix | Delete
[21963] Fix | Delete
// Handle successful license deactivation result.
[21964] Fix | Delete
$this->handle_license_deactivation_result( $this->_license );
[21965] Fix | Delete
}
[21966] Fix | Delete
[21967] Fix | Delete
return $site;
[21968] Fix | Delete
}
[21969] Fix | Delete
[21970] Fix | Delete
/**
[21971] Fix | Delete
* @author Vova Feldman (@svovaf)
[21972] Fix | Delete
* @since 1.1.8.1
[21973] Fix | Delete
*
[21974] Fix | Delete
* @param bool|string $plan_name
[21975] Fix | Delete
*
[21976] Fix | Delete
* @return bool If trial was successfully started.
[21977] Fix | Delete
*/
[21978] Fix | Delete
function start_trial( $plan_name = false ) {
[21979] Fix | Delete
$this->_logger->entrance();
[21980] Fix | Delete
[21981] Fix | Delete
// Alias.
[21982] Fix | Delete
$oops_text = $this->get_text_x_inline( 'Oops', 'exclamation', 'oops' ) . '...';
[21983] Fix | Delete
[21984] Fix | Delete
if ( $this->is_trial() ) {
[21985] Fix | Delete
// Already in trial mode.
[21986] Fix | Delete
$this->_admin_notices->add(
[21987] Fix | Delete
sprintf( $this->get_text_inline( 'You are already running the %s in a trial mode.', 'in-trial-mode' ), $this->_module_type ),
[21988] Fix | Delete
$oops_text,
[21989] Fix | Delete
'error'
[21990] Fix | Delete
);
[21991] Fix | Delete
[21992] Fix | Delete
return false;
[21993] Fix | Delete
}
[21994] Fix | Delete
[21995] Fix | Delete
if ( $this->_site->is_trial_utilized() ) {
[21996] Fix | Delete
// Trial was already utilized.
[21997] Fix | Delete
$this->_admin_notices->add(
[21998] Fix | Delete
$this->get_text_inline( 'You already utilized a trial before.', 'trial-utilized' ),
[21999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function