M_Shortcodes

The Membership 2 M Shortcodes class.

Defined (1)

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

/app_old/membershipincludes/includes/default.rules.php  
  1. class M_Shortcodes extends M_Rule { 
  2.  
  3. var $name = 'shortcodes'; 
  4. var $label = 'Shortcodes'; 
  5. var $description = 'Allows specific shortcodes and contained content to be protected.'; 
  6.  
  7. var $rulearea = 'public'; 
  8.  
  9. function admin_main($data) { 
  10.  
  11. global $shortcode_tags; 
  12.  
  13. if(!$data) $data = array(); 
  14. ?> 
  15. <div class='level-operation' id='main-shortcodes'> 
  16. <h2 class='sidebar-name'><?php _e('Shortcodes', 'membership');?><span><a href='#remove' id='remove-shortcodes' class='removelink' title='<?php _e("Remove Shortcodes from this rules area.", 'membership'); ?>'><?php _e('Remove', 'membership'); ?></a></span></h2> 
  17. <div class='inner-operation'> 
  18. <p><?php _e('Select the Shortcodes to be covered by this rule by checking the box next to the relevant shortcode tag.', 'membership'); ?></p> 
  19. <?php 
  20. if($shortcode_tags) { 
  21. ?> 
  22. <table cellspacing="0" class="widefat fixed"> 
  23. <thead> 
  24. <tr> 
  25. <th style="" class="manage-column column-cb check-column" id="cb" scope="col"><input type="checkbox"></th> 
  26. <th style="" class="manage-column column-name" id="name" scope="col"><?php _e('Shortcode tag', 'membership'); ?></th> 
  27. </tr> 
  28. </thead> 
  29.  
  30. <tfoot> 
  31. <tr> 
  32. <th style="" class="manage-column column-cb check-column" id="cb" scope="col"><input type="checkbox"></th> 
  33. <th style="" class="manage-column column-name" id="name" scope="col"><?php _e('Shortcode tag', 'membership'); ?></th> 
  34. </tr> 
  35. </tfoot> 
  36.  
  37. <tbody> 
  38. <?php 
  39. foreach($shortcode_tags as $key => $function) { 
  40. ?> 
  41. <tr valign="middle" class="alternate" id="post-<?php echo $key; ?>"> 
  42. <th class="check-column" scope="row"> 
  43. <input type="checkbox" value="<?php echo esc_attr(trim($key)); ?>" name="shortcodes[]" <?php if(in_array(trim($key), $data)) echo 'checked="checked"'; ?>> 
  44. </th> 
  45. <td class="column-name"> 
  46. <strong>[<?php echo esc_html(trim($key)); ?>]</strong> 
  47. </td> 
  48. </tr> 
  49. <?php 
  50. ?> 
  51. </tbody> 
  52. </table> 
  53. <?php 
  54. ?> 
  55. </div> 
  56. </div> 
  57. <?php 
  58.  
  59. function on_creation() { 
  60. //add_filter('the_content', array(&$this, 'override_shortcodes'), 1); 
  61.  
  62. function override_shortcodes() { 
  63.  
  64. global $M_shortcode_tags, $shortcode_tags; 
  65.  
  66. $M_shortcode_tags = $shortcode_tags; 
  67.  
  68. foreach($shortcode_tags as $key => $function) { 
  69. if($key != 'subscriptionform') { 
  70. $shortcode_tags[$key] = array(&$this, 'do_protected_shortcode'); 
  71.  
  72. return $content; 
  73.  
  74. function on_positive($data) { 
  75.  
  76. global $M_options, $M_shortcode_tags, $shortcode_tags; 
  77.  
  78. $this->data = $data; 
  79.  
  80. if($M_options['shortcodedefault'] == 'no' ) { 
  81. // Need to re-enable some shortcodes 
  82. foreach( (array) $data as $key => $code ) { 
  83. if(isset($M_shortcode_tags[$code]) && isset($shortcode_tags[$code])) { 
  84. $shortcode_tags[$code] = $M_shortcode_tags[$code]; 
  85.  
  86.  
  87. function on_negative($data) { 
  88.  
  89. global $M_options, $M_shortcode_tags, $shortcode_tags; 
  90.  
  91. $M_shortcode_tags = $shortcode_tags; 
  92.  
  93. $this->data = $data; 
  94.  
  95. if($M_options['shortcodedefault'] != 'no' ) { 
  96. // Need to disable some shortcodes 
  97. foreach( (array) $data as $key => $code ) { 
  98. if(isset($M_shortcode_tags[$code]) && isset($shortcode_tags[$code])) { 
  99. if($code != 'subscriptionform') { 
  100. $shortcode_tags[$code] = array(&$this, 'do_protected_shortcode'); 
  101.  
  102.  
  103. // Show the protected shortcode message 
  104. function do_protected_shortcode($atts, $content = null, $code = "") { 
  105.  
  106. global $M_options; 
  107.  
  108. return stripslashes($M_options['shortcodemessage']); 
  109.  
  110.