M_More

The Membership 2 M More class.

Defined (1)

The class is defined in the following location(s).

/app_old/membershipincludes/includes/default.rules.php  
  1. class M_More extends M_Rule { 
  2.  
  3. var $name = 'more'; 
  4. var $label = 'More tag'; 
  5. var $description = 'Allows content placed after the More tag to be protected.'; 
  6.  
  7. var $rulearea = 'public'; 
  8.  
  9. function admin_main($data) { 
  10. if(!$data) $data = array(); 
  11. ?> 
  12. <div class='level-operation' id='main-more'> 
  13. <h2 class='sidebar-name'><?php _e('More tag', 'membership');?><span><a href='#remove' class='removelink' id='remove-more' title='<?php _e("Remove More tag from this rules area.", 'membership'); ?>'><?php _e('Remove', 'membership'); ?></a></span></h2> 
  14. <div class='inner-operation'> 
  15. <p><strong><?php _e('Positive : ', 'membership'); ?></strong><?php _e('User can read full post content beyond the More tag.', 'membership'); ?></p> 
  16. <p><strong><?php _e('Negative : ', 'membership'); ?></strong><?php _e('User is unable to read full post content beyond the More tag.', 'membership'); ?></p> 
  17. <input type='hidden' name='more[]' value='yes' /> 
  18. </div> 
  19. </div> 
  20. <?php 
  21.  
  22. function on_positive($data) { 
  23.  
  24. global $M_options, $wp_filter; 
  25.  
  26. $this->data = $data; 
  27.  
  28. if(isset($M_options['moretagdefault']) && $M_options['moretagdefault'] == 'no' ) { 
  29.  
  30. // remove the filters - otherwise we don't need to do anything 
  31. if(isset($wp_filter['the_content_more_link'][99])) { 
  32. foreach($wp_filter['the_content_more_link'][99] as $key => $value) { 
  33. if(strstr($key, 'show_moretag_protection') !== false) { 
  34. unset($wp_filter['the_content_more_link'][99][$key]); 
  35. if(empty($wp_filter['the_content_more_link'][99])) { 
  36. unset($wp_filter['the_content_more_link'][99]); 
  37.  
  38. if(isset($wp_filter['the_content'][1])) { 
  39. foreach($wp_filter['the_content'][1] as $key => $value) { 
  40. if(strstr($key, 'replace_moretag_content') !== false) { 
  41. unset($wp_filter['the_content'][1][$key]); 
  42. if(empty($wp_filter['the_content'][1])) { 
  43. unset($wp_filter['the_content'][1]); 
  44.  
  45. if(isset($wp_filter['the_content_feed'][1])) { 
  46. foreach($wp_filter['the_content_feed'][1] as $key => $value) { 
  47. if(strstr($key, 'replace_moretag_content') !== false) { 
  48. unset($wp_filter['the_content_feed'][1][$key]); 
  49. if(empty($wp_filter['the_content_feed'][1])) { 
  50. unset($wp_filter['the_content_feed'][1]); 
  51.  
  52.  
  53. function on_negative($data) { 
  54.  
  55. global $M_options; 
  56.  
  57. $this->data = $data; 
  58.  
  59. if(isset($M_options['moretagdefault']) && $M_options['moretagdefault'] != 'no' ) { 
  60. // add the filters - otherwise we don't need to do anything 
  61. add_filter('the_content_more_link', array(&$this, 'show_moretag_protection'), 99, 2); 
  62. add_filter('the_content', array(&$this, 'replace_moretag_content'), 1); 
  63.  
  64. function show_moretag_protection($more_tag_link, $more_tag) { 
  65.  
  66. global $M_options; 
  67.  
  68. return stripslashes($M_options['moretagmessage']); 
  69.  
  70.  
  71. function replace_moretag_content($the_content) { 
  72.  
  73. global $M_options; 
  74.  
  75. $morestartsat = strpos($the_content, '<span id="more-'); 
  76.  
  77. if($morestartsat !== false) { 
  78. $the_content = substr($the_content, 0, $morestartsat); 
  79. $the_content .= stripslashes($M_options['moretagmessage']); 
  80.  
  81. return $the_content; 
  82.  
  83.