MS_Rule_MemberCaps

The Membership 2 MS Rule MemberCaps class.

Defined (1)

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

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