Plugin: Social Locker for WordPress
Version: 1.0.0+
Purpose: To invoke Social Locker via php anywhere on wordpress site.

The Social Locker provides shortcodes to lock content inside posts. If you need to lock something outside posts, for example, on your blog home page, use the way described in this article. What’s more, the way is suitable for any type shortcodes, not only for Social Locker.

Assume, that the content you need to lock looks like:

<CENTER> 
  <FORM> 
    <input type="button" value="Submit"> 
  </FORM> 
</CENTER>

Note: It may includes any php code or javascript inside. it makes no difference.

1. Wrap your content via the buffering functions:

<?php ob_start(); ?>

<CENTER> 
  <FORM> 
    <input type="button" value="Submit"> 
  </FORM> 
</CENTER>

<?php $to_lock = ob_get_contents(); ob_end_clean(); ?>

2. Then invoke the do_shortcode() function:

<?php ob_start(); ?>

<CENTER> 
  <FORM> 
    <input type="button" value="Submit"> 
  </FORM> 
</CENTER>

<?php $to_lock = ob_get_contents(); ob_end_clean(); ?>

<?php echo do_shortcode('[sociallocker]'.$to_lock.'[/sociallocker]');?>

You can use any shortcode instead of [sociallocker].

Comments

  1. david

    Hi,
    I just tryed to lock a gallery with your method and it doesn’t seems to work !
    When I click on like, the gallery doen’t show but only a “0” appear…
    Any Idea ?

    1. onepress Article Author

      Hi,

      Sorry not sure that you mean. It works with pages and posts. The way described above is just extra ability for developers who need to render a locker somewhere else.

      Paul

Leave a Reply

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