/app/rule/content/class-ms-rule-content.php

  1. <?php 
  2.  
  3. class MS_Rule_Content extends MS_Controller { 
  4.  
  5. /** 
  6. * The rule ID. 
  7. * 
  8. * @type string 
  9. */ 
  10. const RULE_ID = 'content'; 
  11.  
  12. /** 
  13. * Setup the rule. 
  14. * 
  15. * @since 1.0.0 
  16. */ 
  17. public function prepare_obj() { 
  18. if ( MS_Rule_Content_Model::is_active() ) { 
  19. MS_Model_Rule::register_rule( 
  20. self::RULE_ID,  
  21. __CLASS__,  
  22. __( 'Comments & More Tag', 'membership2' ),  
  23. 80 
  24. ); 
  25.  
  26. $this->add_filter( 
  27. 'ms_view_protectedcontent_define-' . self::RULE_ID,  
  28. 'handle_render_callback', 10, 2 
  29. ); 
  30.  
  31. $this->add_filter( 
  32. 'ms_rule_listtable-' . self::RULE_ID,  
  33. 'return_listtable' 
  34. ); 
  35.  
  36. /** 
  37. * Tells Membership2 Admin to display this form to manage this rule. 
  38. * 
  39. * @since 1.0.0 
  40. * 
  41. * @param array $callback (Invalid callback) 
  42. * @param array $data The data collection. 
  43. * @return array Correct callback. 
  44. */ 
  45. public function handle_render_callback( $callback, $data ) { 
  46. $view = MS_Factory::load( 'MS_Rule_Content_View' ); 
  47.  
  48. $view->data = $data; 
  49. $callback = array( $view, 'to_html' ); 
  50.  
  51. return $callback; 
  52.  
  53. /** 
  54. * Returns the ListTable object for this rule. 
  55. * 
  56. * @since 1.0.0 
  57. * 
  58. * @return MS_Helper_ListTable 
  59. */ 
  60. public function return_listtable( $empty ) { 
  61. $base = MS_Model_Membership::get_base(); 
  62. $rule = $base->get_rule( self::RULE_ID ); 
  63. return new MS_Rule_Content_ListTable( $rule ); 
  64.  
.