MS_View_Metabox

Render Membership Metabox.

Defined (1)

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

/app/view/class-ms-view-metabox.php  
  1. class MS_View_Metabox extends MS_View { 
  2.  
  3. /** 
  4. * Create view output. 
  5. * @since 1.0.0 
  6. * @return string 
  7. */ 
  8. public function to_html() { 
  9. ob_start(); 
  10. ?> 
  11. <div id="ms-metabox-wrapper" class="ms_metabox ms-wrap"> 
  12. <?php if ( ! empty( $this->data['special_page'] ) ) : ?> 
  13. <div> 
  14. <?php _e( 'Membership Special Page', 'membership2' ); ?> 
  15. </div> 
  16. <?php else : 
  17. $membership_id = $this->data['base_id']; 
  18. $toggle = array( 
  19. 'id' => sprintf( 'access_%s', $membership_id ),  
  20. 'type' => MS_Helper_Html::INPUT_TYPE_RADIO_SLIDER,  
  21. 'title' => __( 'Enable Protection', 'membership2' ),  
  22. 'value' => $this->data['is_protected'],  
  23. 'class' => 'ms-protect-content',  
  24. 'read_only' => ! empty( $this->data['read_only'] ),  
  25. 'ajax_data' => array( 
  26. 'action' => MS_Controller_Metabox::AJAX_ACTION_TOGGLE_ACCESS,  
  27. 'post_id' => $this->data['post_id'],  
  28. 'rule_type' => $this->data['rule_type'],  
  29. 'membership_id' => $membership_id,  
  30. ),  
  31. ); 
  32. MS_Helper_Html::html_element( $toggle ); 
  33. ?> 
  34. <div id="ms-metabox-access-wrapper"> 
  35. <hr /> 
  36. <table> 
  37. <tbody> 
  38. <tr> 
  39. <th> 
  40. <?php _e( 'Membership', 'membership2' ); ?> 
  41. </th> 
  42. <th> 
  43. <?php _e( 'Access', 'membership2' ); ?> 
  44. </th> 
  45. </tr> 
  46.  
  47. <?php foreach ( $this->data['access'] as $membership_id => $data ) : ?> 
  48. <tr class="ms-membership-<?php echo esc_attr( $membership_id ); ?>"> 
  49. <td> 
  50. <?php echo esc_html( $data['name'] ); ?> 
  51. </td> 
  52. <td> 
  53. <?php 
  54. $toggle = array( 
  55. 'id' => sprintf( 'access_%s', $membership_id ),  
  56. 'type' => MS_Helper_Html::INPUT_TYPE_RADIO_SLIDER,  
  57. 'value' => $data['has_access'],  
  58. 'class' => 'ms-protection-rule',  
  59. 'read_only' => ! empty( $this->data['read_only'] ),  
  60. 'ajax_data' => array( 
  61. 'action' => MS_Controller_Metabox::AJAX_ACTION_TOGGLE_ACCESS,  
  62. 'post_id' => $this->data['post_id'],  
  63. 'rule_type' => $this->data['rule_type'],  
  64. 'membership_id' => $membership_id,  
  65. ),  
  66. ); 
  67.  
  68. MS_Helper_Html::html_element( $toggle ); 
  69. ?> 
  70. </td> 
  71. </tr> 
  72. <?php endforeach; ?> 
  73. </tbody> 
  74. </table> 
  75. </div> 
  76. <?php endif;?> 
  77. </div> 
  78. <div style="clear:both;"></div> 
  79. <?php 
  80. $html = ob_get_clean(); 
  81.  
  82. return apply_filters( 'ms_view_membership_metabox_to_html', $html );