예제 #1
0
/**
 * Shows offers to purhcase the StyleRoller from time to time.
 * 
 * @since 3.5.0
 */
function onp_sl_styleroller_notices($notices)
{
    if (defined('ONP_SL_STYLER_PLUGIN_ACTIVE')) {
        return $notices;
    }
    // show messages only for administrators
    if (!factory_325_is_administrator()) {
        return $notices;
    }
    global $sociallocker;
    if (in_array($sociallocker->license->type, array('free', 'trial'))) {
        return $notices;
    }
    global $sociallocker;
    $closed = get_option('factory_notices_closed', array());
    // leans when the premium versio was activated
    $premiumActivated = isset($sociallocker->license->data['Activated']) ? $sociallocker->license->data['Activated'] : 0;
    // for old users
    $isNewUser = $premiumActivated !== 0;
    $secondsInDay = 60 * 60 * 24;
    $inSeconds = time() - $premiumActivated;
    $inDays = $inSeconds / $secondsInDay;
    $forceToShow = defined('ONP_DEBUG_SHOW_STYLEROLLER_MESSAGE') && ONP_DEBUG_SHOW_STYLEROLLER_MESSAGE;
    $lang = $sociallocker->options['lang'];
    // offers a discount for new users who purchased the Social Locker a day ago
    if ($isNewUser && $inDays >= 1 && $inDays <= 3 && !isset($closed['sociallocker-styleroller-after-a-day']) || $forceToShow) {
        $premiumActivated = $premiumActivated + 24 * 60 * 60;
        $expiresIn = ceil((3 - $inDays) * 24);
        $notices[] = array('id' => 'sociallocker-styleroller-after-a-day', 'class' => 'call-to-action sociallocker-styleroller-banner onp-sl-' . $lang, 'header' => '<span class="onp-hightlight">' . __('You\'ve got the 40% discount on the StyleRoller Add-On!', 'plugin-sociallocker') . '</span>' . sprintf(__('(Expires In %sh)', 'plugin-sociallocker'), $expiresIn), 'message' => __('<p>It\'s a day since you activated the Social Locker. We would like to make you a small gift, the 40% discount on the StyleRoller Add-on. This is a time-limited offer which will be valid within 2 days.</p><p>The StyleRoller Add-on will help you to brand the Social Locker to fit the look and feel of your website, create your own unique attention-grabbing themes and, as a result, increase the number of likes and shares.</p>', 'plugin-sociallocker'), 'plugin' => $sociallocker->pluginName, 'where' => array('plugins', 'dashboard', 'edit'), 'buttons' => array(array('class' => 'btn btn-primary', 'title' => __('Get StyleRoller For 40% Off', 'plugin-sociallocker'), 'action' => $sociallocker->options['styleroller'] . '-special/?' . http_build_query(array('onp_special' => md5($premiumActivated) . $premiumActivated, 'onp_target' => base64_encode(get_site_url()), 'utm_source' => 'plugin', 'utm_medium' => 'styleroller-banner', 'utm_campaign' => 'after-a-day'))), array('title' => __('Hide this message', 'plugin-sociallocker'), 'class' => 'btn btn-default', 'action' => 'x')));
    }
    // offers a discount for new users who purchased the Social Locker a week ago
    if ($isNewUser && $inDays >= 7 && $inDays <= 9 && !isset($closed['sociallocker-styleroller-after-a-week']) || $forceToShow) {
        $premiumActivated = $premiumActivated + 7 * 24 * 60 * 60;
        $expiresIn = ceil((9 - $inDays) * 24);
        $notices[] = array('id' => 'sociallocker-styleroller-after-a-week', 'class' => 'call-to-action sociallocker-styleroller-banner onp-sl-' . $lang, 'icon' => 'fa fa-frown-o', 'header' => '<span class="onp-hightlight">' . __('Last Chance To Get StyleRoller For 40% Off!', 'plugin-sociallocker') . '</span>' . sprintf(__('(Expires In %sh)', 'plugin-sociallocker'), $expiresIn), 'message' => __('We have noticed you have been using the Social Locker already more than a week. Did you know what via the StyleRoller, an add-on for creating own attention-grabbing themes, you can improve conversions of your lockers by up to 300%? Learn how, click the button below.', 'plugin-sociallocker'), 'plugin' => $sociallocker->pluginName, 'where' => array('plugins', 'dashboard', 'edit'), 'buttons' => array(array('class' => 'btn btn-primary', 'title' => __('Get StyleRoller For 40% Off', 'plugin-sociallocker'), 'action' => $sociallocker->options['styleroller'] . '-special/?' . http_build_query(array('onp_special' => md5($premiumActivated) . $premiumActivated, 'onp_target' => base64_encode(get_site_url()), 'utm_source' => 'plugin', 'utm_medium' => 'styleroller-banner', 'utm_campaign' => 'after-a-week'))), array('title' => __('Hide this message', 'plugin-sociallocker'), 'class' => 'btn btn-default', 'action' => 'x')));
    }
    // this banner only for old users
    if (!$isNewUser || $forceToShow) {
        $firstShowTime = get_option('onp_sl_styleroller_firt_time', false);
        if (!$firstShowTime) {
            $firstShowTime = time();
            update_option('onp_sl_styleroller_firt_time', time());
        }
        $inSeconds = time() - $firstShowTime;
        $inDays = $inSeconds / $secondsInDay;
        // this offer is available only 2 days
        if ($inDays <= 2 && !isset($closed['sociallocker-styleroller-new-addon']) || $forceToShow) {
            $expiresIn = ceil((2 - $inDays) * 24);
            $notices[] = array('id' => 'sociallocker-styleroller-new-addon', 'class' => 'call-to-action sociallocker-styleroller-banner onp-sl-' . $lang, 'icon' => 'fa fa-frown-o', 'header' => '<span class="onp-hightlight">' . __('You\'ve got the 40% discount on the StyleRoller Add-On!', 'plugin-sociallocker') . '</span>' . sprintf(__('(Expires In %sh)', 'plugin-sociallocker'), $expiresIn), 'message' => __('We would like to make you a small gift, the 40% discount on the StyleRoller Add-on. This is a time-limited offer which will be valid within 2 days. The StyleRoller Add-on will help you to brand the Social Locker to fit the look and feel of your website, create your own unique attention-grabbing themes and, as a result, increase the number of likes and shares.', 'plugin-sociallocker'), 'plugin' => $sociallocker->pluginName, 'where' => array('plugins', 'dashboard', 'edit'), 'buttons' => array(array('class' => 'btn btn-primary', 'title' => __('Get StyleRoller For 40% Off', 'plugin-sociallocker'), 'action' => $sociallocker->options['styleroller'] . '-special/?' . http_build_query(array('onp_special' => md5($firstShowTime) . $firstShowTime, 'onp_target' => base64_encode(get_site_url()), 'utm_source' => 'plugin', 'utm_medium' => 'styleroller-banner', 'utm_campaign' => 'new-addon'))), array('title' => __('Hide this message', 'plugin-sociallocker'), 'class' => 'btn btn-default', 'action' => 'x')));
        }
        // this offer apperas after a week withing a day
        if ($inDays >= 7 && $inDays <= 9 && !isset($closed['sociallocker-styleroller-new-addon-after-a-week']) || $forceToShow) {
            $firstShowTime = $firstShowTime + 7 * 24 * 60 * 60;
            $expiresIn = ceil((9 - $inDays) * 24);
            $notices[] = array('id' => 'sociallocker-styleroller-new-addon-after-a-week', 'class' => 'call-to-action sociallocker-styleroller-banner onp-sl-' . $lang, 'icon' => 'fa fa-frown-o', 'header' => '<span class="onp-hightlight">' . __('Last Chance To Get StyleRoller For 40% Off!', 'plugin-sociallocker') . '</span>' . sprintf(__('(Expires In %sh)', 'plugin-sociallocker'), $expiresIn), 'message' => __('Did you know what via the StyleRoller, an add-on for creating own attention-grabbing themes for Social Locker, you can improve conversions of your lockers by up to 300%? Click the button to learn more and get the discount.', 'plugin-sociallocker'), 'plugin' => $sociallocker->pluginName, 'where' => array('plugins', 'dashboard', 'edit'), 'buttons' => array(array('class' => 'btn btn-primary', 'title' => __('Get StyleRoller For 40% Off', 'plugin-sociallocker'), 'action' => $sociallocker->options['styleroller'] . '-special/?' . http_build_query(array('onp_special' => md5($firstShowTime) . $firstShowTime, 'onp_target' => base64_encode(get_site_url()), 'utm_source' => 'plugin', 'utm_medium' => 'styleroller-banner', 'utm_campaign' => 'new-addon-after-a-week'))), array('title' => __('Hide this message', 'plugin-sociallocker'), 'class' => 'btn btn-default', 'action' => 'x')));
        }
    }
    return $notices;
}
예제 #2
0
 /**
  * Adds notices to display.
  * 
  * Calls on the hook 'factory_notices_[plugin_name]'
  * 
  * @param mixed[] $notices
  * @return mixed[]
  */
 function addNotices($notices)
 {
     // show messages only for administrators
     if (!factory_325_is_administrator()) {
         return $notices;
     }
     $closed = get_option('factory_notices_closed', array());
     $time = 0;
     if (isset($closed[$this->plugin->pluginName . '-key-not-bound'])) {
         $time = $closed[$this->plugin->pluginName . '-key-not-bound']['time'];
     }
     // shows the key binding message only if changing the assembly is not required
     $forceBindingMessage = defined('ONP_DEBUG_SHOW_BINDING_MESSAGE') && ONP_DEBUG_SHOW_BINDING_MESSAGE;
     if ($time + 60 * 60 * 24 <= time() && (!$this->plugin->updates || !$this->plugin->updates->needChangeAssembly()) || $forceBindingMessage) {
         $keyBound = get_option('onp_bound_message_' . $this->plugin->pluginName, false);
         if ($keyBound && $this->plugin->license && $this->plugin->license->key && $this->needToProtect() || $forceBindingMessage) {
             $notices[] = array('id' => $this->plugin->pluginName . '-key-not-bound', 'class' => 'call-to-action', 'icon' => 'fa fa-frown-o', 'header' => __('Your license key is not protected!', 'onp_licensing_325'), 'message' => sprintf(__('Bind your license key (for %s) to your email address in order to avoid theft (it will take just a couple of seconds).', 'onp_licensing_325'), $this->plugin->options['title']), 'plugin' => $this->plugin->pluginName, 'buttons' => array(array('class' => 'btn btn-primary', 'title' => '<i class="fa fa-key"></i> ' . sprintf(__('Protect my key: %s', 'onp_licensing_325'), '<i>' . $this->plugin->license->key . '</i>'), 'action' => '?' . http_build_query(array('fy_page' => 'license-manager', 'fy_action' => 'createAccount', 'fy_plugin' => $this->plugin->pluginName))), array('title' => __('Hide this message', 'onp_licensing_325'), 'class' => 'btn btn-default', 'action' => 'x')));
         }
     }
     $forceTrialNotices = defined('ONP_DEBUG_TRIAL_EXPIRES') && ONP_DEBUG_TRIAL_EXPIRES !== false;
     $exipred = floatval($this->data['Expired']);
     if ($exipred != 0 || $forceTrialNotices) {
         $remained = round(($this->data['Expired'] - time()) / (60 * 60 * 24), 2);
         if ($forceTrialNotices) {
             $remained = ONP_DEBUG_TRIAL_EXPIRES;
         }
         if ($remained < 5 && $remained > 0) {
             $time = 0;
             if (isset($closed[$this->plugin->pluginName . '-key-estimate'])) {
                 $time = $closed[$this->plugin->pluginName . '-key-estimate']['time'];
             }
             if ($time + 60 * 60 * 24 <= time() || $forceTrialNotices) {
                 if ($this->type == 'trial' || $forceTrialNotices) {
                     if ($remained <= 1) {
                         $notices[] = array('id' => $this->plugin->pluginName . '-key-estimate', 'class' => 'call-to-action', 'icon' => 'fa fa-clock-o', 'header' => sprintf(__('The trial key for the %s will expire during the day!', 'onp_licensing_325'), $this->plugin->pluginTitle), 'message' => __('Don\'t forget to purchase the premium key or delete the trial key to use the free version of the plugin.', 'onp_licensing_325'), 'plugin' => $this->plugin->pluginName, 'buttons' => array(array('title' => '<i class="fa fa-arrow-circle-o-up"></i> ' . __('Buy a premium key now!', 'onp_licensing_325'), 'class' => 'btn btn-primary', 'action' => onp_licensing_325_get_purchase_url($this->plugin, 'trial-remained-1')), array('title' => __('Hide this message', 'onp_licensing_325'), 'class' => 'btn btn-default', 'action' => 'x')));
                     } else {
                         $notices[] = array('id' => $this->plugin->pluginName . '-key-estimate', 'class' => 'call-to-action', 'icon' => 'fa fa-clock-o', 'header' => sprintf(__('The trial key for the %s will expire in %s days.', 'onp_licensing_325'), $this->plugin->pluginTitle, $remained), 'message' => __('Please don\'t forget to purchase the premium key or delete the trial key to use the free version of the plugin.', 'onp_licensing_325'), 'plugin' => $this->plugin->pluginName, 'buttons' => array(array('title' => '<i class="fa fa-arrow-circle-o-up"></i> ' . __('Buy a premium key now!', 'onp_licensing_325'), 'class' => 'btn btn-primary', 'action' => onp_licensing_325_get_purchase_url($this->plugin, 'trial-remained-' . $remained)), array('title' => __('Hide this message', 'onp_licensing_325'), 'class' => 'btn btn-default', 'action' => 'x')));
                     }
                 }
             }
         }
         if ($this->isExpired() || $forceTrialNotices) {
             $notices[] = array('id' => $this->plugin->pluginName . '-key-expired', 'class' => 'call-to-action', 'icon' => 'fa fa-arrow-circle-o-up', 'header' => sprintf(__('The trial key for the %s has expired.', 'onp_licensing_325'), $this->plugin->pluginTitle), 'message' => __('Please purchase another key or delete the current key to use the free version of the plugin.', 'onp_licensing_325'), 'plugin' => $this->plugin->pluginName, 'buttons' => array(array('title' => '<i class="fa fa-arrow-circle-o-up"></i> ' . __('Buy a premium key now!', 'onp_licensing_325'), 'class' => 'btn btn-primary', 'action' => onp_licensing_325_get_purchase_url($this->plugin, 'trial-expired')), array('title' => __('Visit the license manager', 'onp_licensing_325'), 'class' => 'btn btn-default', 'action' => onp_licensing_325_get_manager_link($this->plugin->pluginName, 'index'))));
         }
     }
     return $notices;
 }