Plugin Directory

Changeset 949437


Ignore:
Timestamp:
07/16/2014 07:44:46 AM (12 years ago)
Author:
speedito
Message:

version 1.0

Location:
restrict-partial-content
Files:
2 edited
3 copied

Legend:

Unmodified
Added
Removed
  • restrict-partial-content/tags/1.0/readme.txt

    r921489 r949437  
    44Requires at least: 3.9.1
    55Tested up to: 3.9.1
    6 Stable tag: 0.3
     6Stable tag: 1.0
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
    99
    10 This is a simple plugin to allow you to restrict the access to specific portion of the page/post. You can use the shortcode provided to show some of the content and restrict the remaining content to specific users or user types(via roles).
     10This is a simple plugin to restrict the access based on user role, user id or date/time (displays a countdown timer).
    1111
    1212== Description ==
    13 Typical use case would be to restrict access to a bit of content to users unless they are logged. Can help you improve your subscription rates.
     13Typical use case would be to restrict access to a portion of the content to users unless. Restriction can be based on user role (to boost user subscriptions). You can also setup a timer function to open up content after a certain time.
    1414
    1515Options available are:
     
    1717<li>Restrict access based on the type of user</li>
    1818<li>Restrict access based on specific user id</li>
     19<li>Restrict access based date/time</li>
    1920</ol>
    2021
     
    34352. allow_user => The User ID(s) to allow access to the restricted content.
    35363. message => The message that is visible when content is restricted
     374. open_time => The exact date and time when the content should become visible (format to use YYYY-MM-DD HH:MM:SS see example on <a href="http://speedsoftsol.com/restrict-partial-content" target="_blank">demo page</a>)
    3638
    3739
     
    4143Initial launch
    4244
    43 = 0.2 =
    44 Improved Error checking
    45 
    46 = 0.3 =
    47 Improved Error checking
     45= 1.0 =
     46Added option to restrict content based on role and timeouts
  • restrict-partial-content/tags/1.0/restrict-partial-content.php

    r921489 r949437  
    44 * Plugin URI: http://wordpress.org/plugins/restrict-partial-content/
    55 * Description: This plugin helps to protect specific portion of the content
    6  * Version: 0.3
     6 * Version: 1.0
    77 * Author: Waqas Ahmed
    88 * Author URI: http://speedsoftsol.com
     
    1818        'allow_role' => 'all',
    1919        'allow_user' => 'all',
    20         'message' => ' [This content is restricted] ',
     20        'message' => ' [This content is restricted. Either login with the correct access or wait till the content is available for everyone.] ',
     21        'open_time' => 'No Time'
    2122    ), $atts ) );
    2223
     24    $restrict = 1; //Restrict everyone but allow the role and user specified
     25
     26
     27    //Find the server date
     28    $server_date = strtotime(current_time('Y-m-d H:i:s')); // use current_time
     29    //Calculate diff
     30    $interval = 0;
     31    if ($open_time != 'No Time') {
     32        $content_opening_date = strtotime($open_time);
     33        $interval = $content_opening_date - $server_date;
     34        if ($interval <0 ) {
     35            $restrict = 0;
     36        }
     37    }
     38   
     39   
    2340    // Find current user role and ID
    2441    $user_info = wp_get_current_user();
     
    2643    $user_id = $user_info->ID;
    2744
    28     $restrict = 1; //Restrict everyone but allow the role and user specified
    2945    $user_list = explode (",", $allow_user);
    3046    $user_list_trimmed = array_map('trim', $user_list);
     
    4157   
    4258    if ($restrict == 1) {
    43         $output = '<span class="restricted-content">'.$message.'</div>';
     59        wp_enqueue_style( 'restrict-content', plugins_url().'/restrict-partial-content/restrict-partial.css');
     60        $output = '<div class="restricted-content">'.$message.'</div>';
     61        if ($interval >0) {
     62            $output .= '<div id="timer">
     63            <div id="timer-days"></div><div id="timer-hours"></div><div id="timer-minutes"></div><div id="timer-seconds"></div>
     64        </div>
     65            <div id="timer-message"></div>
     66        ';
     67        $output .= "<script>
     68
     69    function counter(total_time) {
     70        var d = Math.floor(total_time/86400);
     71        var remaining_time = total_time - (d*86400);
     72       
     73        var h = Math.floor(remaining_time/3600);
     74        var remaining_time = remaining_time - (h*3600);
     75
     76        var m = Math.floor(remaining_time/60);
     77        var remaining_time = remaining_time - (m*60);
     78        var s = remaining_time;
     79       
     80        document.getElementById('timer-days').innerHTML = d + ' days';
     81        document.getElementById('timer-hours').innerHTML = h + ' hours';
     82        document.getElementById('timer-minutes').innerHTML = m + ' minutes';
     83        document.getElementById('timer-seconds').innerHTML = s + ' seconds';
     84       
     85        total_time--;
     86        if (total_time <0 ) {
     87            document.getElementById('timer-message').innerHTML = 'Refresh the page to view the content';
     88            document.getElementById('timer').style.display='none';
     89            document.getElementById('timer-message').style.display='inline-block';
     90            return;
     91        }
     92        setTimeout(function () {counter (total_time)}, 1000);
     93
     94    }
     95   
     96    counter(".$interval.");
     97    </script>";
     98        }
    4499    }
    45100    else {
    46         $output = $content;
     101        $output = do_shortcode( $content );
    47102    }
    48103    return $output;
    49104}
    50105add_shortcode( 'restrict', 'render_restrict' );
     106
  • restrict-partial-content/trunk/readme.txt

    r921489 r949437  
    44Requires at least: 3.9.1
    55Tested up to: 3.9.1
    6 Stable tag: 0.3
     6Stable tag: 1.0
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
    99
    10 This is a simple plugin to allow you to restrict the access to specific portion of the page/post. You can use the shortcode provided to show some of the content and restrict the remaining content to specific users or user types(via roles).
     10This is a simple plugin to restrict the access based on user role, user id or date/time (displays a countdown timer).
    1111
    1212== Description ==
    13 Typical use case would be to restrict access to a bit of content to users unless they are logged. Can help you improve your subscription rates.
     13Typical use case would be to restrict access to a portion of the content to users unless. Restriction can be based on user role (to boost user subscriptions). You can also setup a timer function to open up content after a certain time.
    1414
    1515Options available are:
     
    1717<li>Restrict access based on the type of user</li>
    1818<li>Restrict access based on specific user id</li>
     19<li>Restrict access based date/time</li>
    1920</ol>
    2021
     
    34352. allow_user => The User ID(s) to allow access to the restricted content.
    35363. message => The message that is visible when content is restricted
     374. open_time => The exact date and time when the content should become visible (format to use YYYY-MM-DD HH:MM:SS see example on <a href="http://speedsoftsol.com/restrict-partial-content" target="_blank">demo page</a>)
    3638
    3739
     
    4143Initial launch
    4244
    43 = 0.2 =
    44 Improved Error checking
    45 
    46 = 0.3 =
    47 Improved Error checking
     45= 1.0 =
     46Added option to restrict content based on role and timeouts
  • restrict-partial-content/trunk/restrict-partial-content.php

    r921489 r949437  
    44 * Plugin URI: http://wordpress.org/plugins/restrict-partial-content/
    55 * Description: This plugin helps to protect specific portion of the content
    6  * Version: 0.3
     6 * Version: 1.0
    77 * Author: Waqas Ahmed
    88 * Author URI: http://speedsoftsol.com
     
    1818        'allow_role' => 'all',
    1919        'allow_user' => 'all',
    20         'message' => ' [This content is restricted] ',
     20        'message' => ' [This content is restricted. Either login with the correct access or wait till the content is available for everyone.] ',
     21        'open_time' => 'No Time'
    2122    ), $atts ) );
    2223
     24    $restrict = 1; //Restrict everyone but allow the role and user specified
     25
     26
     27    //Find the server date
     28    $server_date = strtotime(current_time('Y-m-d H:i:s')); // use current_time
     29    //Calculate diff
     30    $interval = 0;
     31    if ($open_time != 'No Time') {
     32        $content_opening_date = strtotime($open_time);
     33        $interval = $content_opening_date - $server_date;
     34        if ($interval <0 ) {
     35            $restrict = 0;
     36        }
     37    }
     38   
     39   
    2340    // Find current user role and ID
    2441    $user_info = wp_get_current_user();
     
    2643    $user_id = $user_info->ID;
    2744
    28     $restrict = 1; //Restrict everyone but allow the role and user specified
    2945    $user_list = explode (",", $allow_user);
    3046    $user_list_trimmed = array_map('trim', $user_list);
     
    4157   
    4258    if ($restrict == 1) {
    43         $output = '<span class="restricted-content">'.$message.'</div>';
     59        wp_enqueue_style( 'restrict-content', plugins_url().'/restrict-partial-content/restrict-partial.css');
     60        $output = '<div class="restricted-content">'.$message.'</div>';
     61        if ($interval >0) {
     62            $output .= '<div id="timer">
     63            <div id="timer-days"></div><div id="timer-hours"></div><div id="timer-minutes"></div><div id="timer-seconds"></div>
     64        </div>
     65            <div id="timer-message"></div>
     66        ';
     67        $output .= "<script>
     68
     69    function counter(total_time) {
     70        var d = Math.floor(total_time/86400);
     71        var remaining_time = total_time - (d*86400);
     72       
     73        var h = Math.floor(remaining_time/3600);
     74        var remaining_time = remaining_time - (h*3600);
     75
     76        var m = Math.floor(remaining_time/60);
     77        var remaining_time = remaining_time - (m*60);
     78        var s = remaining_time;
     79       
     80        document.getElementById('timer-days').innerHTML = d + ' days';
     81        document.getElementById('timer-hours').innerHTML = h + ' hours';
     82        document.getElementById('timer-minutes').innerHTML = m + ' minutes';
     83        document.getElementById('timer-seconds').innerHTML = s + ' seconds';
     84       
     85        total_time--;
     86        if (total_time <0 ) {
     87            document.getElementById('timer-message').innerHTML = 'Refresh the page to view the content';
     88            document.getElementById('timer').style.display='none';
     89            document.getElementById('timer-message').style.display='inline-block';
     90            return;
     91        }
     92        setTimeout(function () {counter (total_time)}, 1000);
     93
     94    }
     95   
     96    counter(".$interval.");
     97    </script>";
     98        }
    4499    }
    45100    else {
    46         $output = $content;
     101        $output = do_shortcode( $content );
    47102    }
    48103    return $output;
    49104}
    50105add_shortcode( 'restrict', 'render_restrict' );
     106
Note: See TracChangeset for help on using the changeset viewer.