/** * Show trial promotional notice (if any trial exist). * * @author Vova Feldman (@svovaf) * @since 1.0.9 */ function _add_trial_notice() { // Check if trial already utilized. if ($this->_site->is_trial_utilized()) { return; } // Check if already paying. if ($this->is_paying()) { return; } // Check if trial message is already shown. if ($this->_admin_notices->has_sticky('trial_promotion')) { return; } $trial_plans = FS_Plan_Manager::instance()->get_trial_plans($this->_plans); $trial_plans_count = count($trial_plans); // Check if any of the plans contains trial. if (0 === $trial_plans_count) { return; } /** * @var FS_Plugin_Plan $paid_plan */ $paid_plan = $trial_plans[0]; $require_subscription = $paid_plan->is_require_subscription; $upgrade_url = $this->get_trial_url(); $cc_string = $require_subscription ? sprintf(__fs('no-commitment-for-x-days', $this->_slug), $paid_plan->trial_period) : __fs('no-cc-required', $this->_slug) . '!'; $total_paid_plans = count($this->_plans) - (FS_Plan_Manager::instance()->has_free_plan($this->_plans) ? 1 : 0); if ($total_paid_plans === $trial_plans_count) { // All paid plans have trials. $message = sprintf(__fs('hey', $this->_slug) . '! ' . __fs('trial-x-promotion-message', $this->_slug), sprintf('<b>%s</b>', $this->get_plugin_name()), strtolower(__fs('awesome', $this->_slug)), $paid_plan->trial_period); } else { $plans_string = ''; for ($i = 0; $i < $trial_plans_count; $i++) { $plans_string .= sprintf('<a href="%s">%s</a>', $upgrade_url, $trial_plans[$i]->title); if ($i < $trial_plans_count - 2) { $plans_string .= ', '; } else { if ($i == $trial_plans_count - 2) { $plans_string .= ' and '; } } } // Not all paid plans have trials. $message = sprintf(__fs('hey', $this->_slug) . '! ' . __fs('trial-x-promotion-message', $this->_slug), sprintf('<b>%s</b>', $this->get_plugin_name()), $plans_string, $paid_plan->trial_period); } $message .= ' ' . $cc_string; // Add start trial button. $message .= ' ' . sprintf('<a style="margin-left: 10px; vertical-align: super;" href="%s"><button class="button button-primary">%s ➜</button></a>', $upgrade_url, __fs('start-free-trial', $this->_slug)); $this->_admin_notices->add_sticky($this->apply_filters('trial_promotion_message', $message), 'trial_promotion', '', 'promotion'); $this->_storage->trial_promotion_shown = WP_FS__SCRIPT_START_TIME; }
/** * Show trial promotional notice (if any trial exist). * * @author Vova Feldman (@svovaf) * @since 1.0.9 */ function _add_trial_notice() { // Check if trial already utilized. if ($this->_site->is_trial_utilized()) { return; } // Check if already paying. if ($this->is_paying()) { return; } // Check if trial message is already shown. if ($this->_admin_notices->has_sticky('trial_promotion')) { return; } $trial_plans = FS_Plan_Manager::instance()->get_trial_plans($this->_plans); $trial_plans_count = count($trial_plans); // Check if any of the plans contains trial. if (0 === $trial_plans_count) { return; } /** * @var FS_Plugin_Plan $paid_plan */ $paid_plan = $trial_plans[0]; $require_subscription = $paid_plan->is_require_subscription; $upgrade_url = $this->get_trial_url(); $cc_string = $require_subscription ? sprintf(__('No commitment for %s days - cancel anytime!', WP_FS__SLUG), $paid_plan->trial_period) : __('No credit card required!', WP_FS__SLUG); $total_paid_plans = count($this->_plans) - (FS_Plan_Manager::instance()->has_free_plan($this->_plans) ? 1 : 0); if ($total_paid_plans === $trial_plans_count) { // All paid plans have trials. $message = sprintf(__('Hey! How do you like %s so far? Test all our awesome premium features with a %d-day free trial.', WP_FS__SLUG) . ' ' . $cc_string, sprintf('<b>%s</b>', $this->get_plugin_name()), $paid_plan->trial_period); } else { $plans_string = ''; for ($i = 0; $i < $trial_plans_count; $i++) { $plans_string .= sprintf('<a href="%s">%s</a>', $upgrade_url, $trial_plans[$i]->title); if ($i < $trial_plans_count - 2) { $plans_string .= ', '; } else { if ($i == $trial_plans_count - 2) { $plans_string .= ' and '; } } } // Not all paid plans have trials. $message = sprintf(__('Hey! How do you like the plugin so far? Test all our %s features with a %d-day free trial.' . $cc_string, WP_FS__SLUG), $plans_string, $paid_plan->trial_period); } // Add start trial button. $message .= ' ' . sprintf('<a style="margin-left: 10px;" href="%s"><button class="button button-primary">%s ➜</button></a>', $upgrade_url, __('Start free trial', WP_FS__SLUG)); $this->_admin_notices->add_sticky($this->apply_filters('trial_promotion_message', $message), 'trial_promotion', '', 'promotion'); $this->_storage->trial_promotion_shown = WP_FS__SCRIPT_START_TIME; }