MS_Addon_BuddyPress_Rule

The WordPress Core MS Addon BuddyPress Rule class.

Defined (1)

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

/app/addon/buddypress/rule/class-ms-addon-buddypress-rule.php  
  1. class MS_Addon_BuddyPress_Rule extends MS_Controller { 
  2.  
  3. /** 
  4. * The rule ID. 
  5. * @type string 
  6. */ 
  7. const RULE_ID = 'buddypress'; 
  8.  
  9. const PROTECT_ALL = 'buddypress_all'; 
  10. const PROTECT_FRIENDSHIP = 'buddypress_friendship'; 
  11. const PROTECT_GROUP_CREATION = 'buddypress_add_group'; 
  12. const PROTECT_PRIVATE_MSG = 'buddypress_priv_msg'; 
  13. const PROTECT_MEMBERS = 'buddypress_members'; 
  14.  
  15.  
  16. /** 
  17. * Setup the rule. 
  18. * @since 1.0.0 
  19. */ 
  20. public function prepare_obj() { 
  21. MS_Model_Rule::register_rule( 
  22. self::RULE_ID,  
  23. __CLASS__,  
  24. __( 'BuddyPress', 'membership2' ),  
  25. 40 // must be lower than 50 (pages-rule is 50) 
  26. ); 
  27.  
  28. $this->add_filter( 
  29. 'ms_view_protectedcontent_define-' . self::RULE_ID,  
  30. 'handle_render_callback', 10, 2 
  31. ); 
  32.  
  33. /** 
  34. * Tells Membership2 Admin to display this form to manage this rule. 
  35. * @since 1.0.0 
  36. * @param array $callback (Invalid callback) 
  37. * @param array $data The data collection. 
  38. * @return array Correct callback. 
  39. */ 
  40. public function handle_render_callback( $callback, $data ) { 
  41. $view = MS_Factory::load( 'MS_Addon_BuddyPress_Rule_View' ); 
  42.  
  43. $view->data = $data; 
  44. $callback = array( $view, 'to_html' ); 
  45.  
  46. return $callback; 
  47.