Plugin: Social Locker for WordPress
Version: 2.0.5+
Purpose: To make Social Locker to reappear after a while.

By default the Social Locker plugin does’not provide an ability to appear again after a while. But it’s possible after editing one of the plugin files.

1. Open to edit the file placed at:
<wproot>/wp-content/plugins/sociallocker-next/assets/js/jquery.op.sociallocker.min.[version].js

2. Find a block containing a theme name that you use for the locker on your site. For example, if you use the “Secrets” theme, it will look like this:

/* secrets theme */

$.onepress.sociallocker.presets['secrets'] = {

    buttons: {
        layout: 'horizontal',
        counter: true
    },
    effects: {
        flip: true
    },

    triggers: {
        overlayRender: function(options, networkName, buttonName, isTouch){
            var overlay = isTouch ? $("<a></a>") : $("<div></div>");
            var title = options.title || $.onepress.sociallocker.lang[networkName + "_" + buttonName];

            overlay.addClass("onp-sociallocker-button-overlay") 
                  .append(
                   $("<div class='onp-sociallocker-overlay-front'></div>")
                        .append($("<div class='onp-sociallocker-overlay-icon'></div>"))
                        .append($("<div class='onp-sociallocker-overlay-text'>" + title + "</div>"))
                   )
                  .append($("<div class='onp-sociallocker-overlay-header'></div>"))
                  .append($("<div class='onp-sociallocker-overlay-back'></div>"));

            return overlay;
        }
    }
};

3. Add a new “locker” with the options “useCookies” and “cookiesLifetime”:

/* secrets theme */

$.onepress.sociallocker.presets['secrets'] = {

    locker: {

        // force to use cookies instead of a local storage
        useCookies: true,
        // the number of days for cookies lifetime
        cookiesLifetime: 7
    },

    // ... rest code
};

The option useCookies forces the locker to use the cookies instead of a local storage. The cookies allows to set a lifetime period that you can use to make the locker to forgot that people alredy shared your content.

The options cookiesLifetime sets the number of days for storing the locker state. In the example above it was set to 7 days.

Done. Save changes. To test how it works just clear the cookies and the locker will reaprear again.

Leave a Reply

Your email address will not be published. Required fields are marked *