MS_Rule_Post

The Membership 2 MS Rule Post class.

Defined (1)

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

/app/rule/post/class-ms-rule-post.php  
  1. class MS_Rule_Post extends MS_Controller { 
  2.  
  3. /** 
  4. * The rule ID. 
  5. * @type string 
  6. */ 
  7. const RULE_ID = 'post'; 
  8.  
  9. /** 
  10. * Setup the rule. 
  11. * @since 1.0.0 
  12. */ 
  13. public function prepare_obj() { 
  14. if ( MS_Rule_Post_Model::is_active() ) { 
  15. MS_Model_Rule::register_rule( 
  16. self::RULE_ID,  
  17. __CLASS__,  
  18. __( 'Posts', 'membership2' ),  
  19. 11,  
  20. true // can be dripped 
  21. ); 
  22.  
  23. $this->add_filter( 
  24. 'ms_view_protectedcontent_define-' . self::RULE_ID,  
  25. 'handle_render_callback', 10, 2 
  26. ); 
  27.  
  28. $this->add_filter( 
  29. 'ms_rule_listtable-' . self::RULE_ID,  
  30. 'return_listtable' 
  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_Rule_Post_View' ); 
  42.  
  43. $view->data = $data; 
  44. $callback = array( $view, 'to_html' ); 
  45.  
  46. return $callback; 
  47.  
  48. /** 
  49. * Returns the ListTable object for this rule. 
  50. * @since 1.0.0 
  51. * @return MS_Helper_ListTable 
  52. */ 
  53. public function return_listtable( $empty ) { 
  54. $base = MS_Model_Membership::get_base(); 
  55. $rule = $base->get_rule( self::RULE_ID ); 
  56. return new MS_Rule_Post_ListTable( $rule ); 
  57.