Changeset 949437
- Timestamp:
- 07/16/2014 07:44:46 AM (12 years ago)
- Location:
- restrict-partial-content
- Files:
-
- 2 edited
- 3 copied
-
tags/1.0 (copied) (copied from restrict-partial-content/trunk)
-
tags/1.0/readme.txt (copied) (copied from restrict-partial-content/trunk/readme.txt) (4 diffs)
-
tags/1.0/restrict-partial-content.php (copied) (copied from restrict-partial-content/trunk/restrict-partial-content.php) (4 diffs)
-
trunk/readme.txt (modified) (4 diffs)
-
trunk/restrict-partial-content.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
restrict-partial-content/tags/1.0/readme.txt
r921489 r949437 4 4 Requires at least: 3.9.1 5 5 Tested up to: 3.9.1 6 Stable tag: 0.36 Stable tag: 1.0 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html 9 9 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).10 This is a simple plugin to restrict the access based on user role, user id or date/time (displays a countdown timer). 11 11 12 12 == 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.13 Typical 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. 14 14 15 15 Options available are: … … 17 17 <li>Restrict access based on the type of user</li> 18 18 <li>Restrict access based on specific user id</li> 19 <li>Restrict access based date/time</li> 19 20 </ol> 20 21 … … 34 35 2. allow_user => The User ID(s) to allow access to the restricted content. 35 36 3. message => The message that is visible when content is restricted 37 4. 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>) 36 38 37 39 … … 41 43 Initial launch 42 44 43 = 0.2 = 44 Improved Error checking 45 46 = 0.3 = 47 Improved Error checking 45 = 1.0 = 46 Added option to restrict content based on role and timeouts -
restrict-partial-content/tags/1.0/restrict-partial-content.php
r921489 r949437 4 4 * Plugin URI: http://wordpress.org/plugins/restrict-partial-content/ 5 5 * Description: This plugin helps to protect specific portion of the content 6 * Version: 0.36 * Version: 1.0 7 7 * Author: Waqas Ahmed 8 8 * Author URI: http://speedsoftsol.com … … 18 18 'allow_role' => 'all', 19 19 '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' 21 22 ), $atts ) ); 22 23 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 23 40 // Find current user role and ID 24 41 $user_info = wp_get_current_user(); … … 26 43 $user_id = $user_info->ID; 27 44 28 $restrict = 1; //Restrict everyone but allow the role and user specified29 45 $user_list = explode (",", $allow_user); 30 46 $user_list_trimmed = array_map('trim', $user_list); … … 41 57 42 58 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 } 44 99 } 45 100 else { 46 $output = $content;101 $output = do_shortcode( $content ); 47 102 } 48 103 return $output; 49 104 } 50 105 add_shortcode( 'restrict', 'render_restrict' ); 106 -
restrict-partial-content/trunk/readme.txt
r921489 r949437 4 4 Requires at least: 3.9.1 5 5 Tested up to: 3.9.1 6 Stable tag: 0.36 Stable tag: 1.0 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html 9 9 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).10 This is a simple plugin to restrict the access based on user role, user id or date/time (displays a countdown timer). 11 11 12 12 == 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.13 Typical 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. 14 14 15 15 Options available are: … … 17 17 <li>Restrict access based on the type of user</li> 18 18 <li>Restrict access based on specific user id</li> 19 <li>Restrict access based date/time</li> 19 20 </ol> 20 21 … … 34 35 2. allow_user => The User ID(s) to allow access to the restricted content. 35 36 3. message => The message that is visible when content is restricted 37 4. 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>) 36 38 37 39 … … 41 43 Initial launch 42 44 43 = 0.2 = 44 Improved Error checking 45 46 = 0.3 = 47 Improved Error checking 45 = 1.0 = 46 Added option to restrict content based on role and timeouts -
restrict-partial-content/trunk/restrict-partial-content.php
r921489 r949437 4 4 * Plugin URI: http://wordpress.org/plugins/restrict-partial-content/ 5 5 * Description: This plugin helps to protect specific portion of the content 6 * Version: 0.36 * Version: 1.0 7 7 * Author: Waqas Ahmed 8 8 * Author URI: http://speedsoftsol.com … … 18 18 'allow_role' => 'all', 19 19 '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' 21 22 ), $atts ) ); 22 23 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 23 40 // Find current user role and ID 24 41 $user_info = wp_get_current_user(); … … 26 43 $user_id = $user_info->ID; 27 44 28 $restrict = 1; //Restrict everyone but allow the role and user specified29 45 $user_list = explode (",", $allow_user); 30 46 $user_list_trimmed = array_map('trim', $user_list); … … 41 57 42 58 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 } 44 99 } 45 100 else { 46 $output = $content;101 $output = do_shortcode( $content ); 47 102 } 48 103 return $output; 49 104 } 50 105 add_shortcode( 'restrict', 'render_restrict' ); 106
Note: See TracChangeset
for help on using the changeset viewer.