MS_Rule_MenuItem_View

The Membership 2 MS Rule MenuItem View class.

Defined (1)

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

/app/rule/menuitem/class-ms-rule-menuitem-view.php  
  1. class MS_Rule_MenuItem_View extends MS_View { 
  2.  
  3. public function to_html() { 
  4. $membership = MS_Model_Membership::get_base(); 
  5. $menus = $membership->get_rule( MS_Rule_MenuItem::RULE_ID )->get_menu_array(); 
  6.  
  7. $menu_ids = array_keys( $menus ); 
  8. $menu_id = reset( $menu_ids ); 
  9. if ( isset( $_REQUEST['menu_id'] ) ) { 
  10. $menu_id = $_REQUEST['menu_id']; 
  11.  
  12. // This fixes the list-title generated by MS_Helper_ListTable_Rule. 
  13. unset( $_GET['status'] ); 
  14.  
  15. $rule_menu = $membership->get_rule( MS_Rule_MenuItem::RULE_ID ); 
  16. $rule_listtable = new MS_Rule_MenuItem_ListTable( 
  17. $rule_menu,  
  18. $menus,  
  19. $menu_id 
  20. ); 
  21.  
  22. $fields['rule_menu'] = array( 
  23. 'id' => 'rule_menu',  
  24. 'name' => 'rule',  
  25. 'value' => 'menu',  
  26. 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN,  
  27. ); 
  28.  
  29. $menu_url = esc_url_raw( 
  30. add_query_arg( array( 'menu_id' => $menu_id ) ) 
  31. ); 
  32. $rule_listtable->prepare_items(); 
  33.  
  34. $header_data = apply_filters( 
  35. 'ms_view_membership_protectedcontent_header',  
  36. array( 
  37. 'title' => __( 'Menu Items', 'membership2' ),  
  38. 'desc' => __( 'Protect individual menu items.', 'membership2' ),  
  39. ),  
  40. MS_Rule_MenuItem::RULE_ID,  
  41. $this 
  42. ); 
  43.  
  44. ob_start(); 
  45. ?> 
  46. <div class="ms-settings"> 
  47. <?php MS_Helper_Html::settings_tab_header( $header_data ); ?> 
  48.  
  49. <form id="ms-menu-form" method="post" action="<?php echo '' . $menu_url; ?>"> 
  50. <?php 
  51. MS_Helper_Html::html_element( $fields['rule_menu'] ); 
  52. $rule_listtable->views(); 
  53. $rule_listtable->display(); 
  54.  
  55. do_action( 
  56. 'ms_view_membership_protectedcontent_footer',  
  57. MS_Rule_MenuItem::RULE_ID,  
  58. $this 
  59. ); 
  60. ?> 
  61. </form> 
  62. </div> 
  63. <?php 
  64.  
  65. MS_Helper_Html::settings_footer(); 
  66.  
  67. return ob_get_clean(); 
  68.