MS_View_Membership_Tab_Type

The Membership 2 MS View Membership Tab Type class.

Defined (1)

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

/app/view/membership/tab/class-ms-view-membership-tab-type.php  
  1. class MS_View_Membership_Tab_Type extends MS_View { 
  2.  
  3. /** 
  4. * Create view output. 
  5. * @since 1.0.0 
  6. * @return string 
  7. */ 
  8. public function to_html() { 
  9. $fields = $this->prepare_fields(); 
  10.  
  11. ob_start(); 
  12. ?> 
  13. <div class="ms-membership-add ms-cols-2"> 
  14. <form method="post" id="ms-choose-type-form"> 
  15. <div class="ms-settings-row cf"> 
  16. <h3><?php _e( 'Set the membership type:', 'membership2' ); ?></h3> 
  17. <?php MS_Helper_Html::html_element( $fields['type'] ); ?> 
  18. </div> 
  19. <div> 
  20. <?php 
  21. foreach ( $fields['control_fields'] as $field ) { 
  22. MS_Helper_Html::html_element( $field ); 
  23. ?> 
  24. </div> 
  25. </form> 
  26. </div> 
  27. <?php 
  28. $html = ob_get_clean(); 
  29.  
  30. return $html; 
  31.  
  32. /** 
  33. * Prepare the fields displayed in the form. 
  34. * @since 1.0.0 
  35. * @return array 
  36. */ 
  37. public function prepare_fields() { 
  38. $membership = $this->data['membership']; 
  39. $action = 'save'; 
  40.  
  41. $fields = array( 
  42. 'type' => array( 
  43. 'id' => 'type',  
  44. 'type' => MS_Helper_Html::INPUT_TYPE_RADIO,  
  45. 'value' => $membership->type,  
  46. 'class' => 'ms-choose-type',  
  47. 'after' => '<div class="ms-italic ms-block">' . __( 'Changing this option might result in loss or changes in your protection rules for this Membership.<br>Please check your rules after you save changes here.', 'membership2' ) . '</div>',  
  48. 'field_options' => array( 
  49. MS_Model_Membership::TYPE_STANDARD => array( 
  50. 'text' => __( 'Standard Membership', 'membership2' ),  
  51. 'desc' => __( 'Make your content available to Members and hidden to Guests (logged-out users).', 'membership2' ),  
  52. ),  
  53. MS_Model_Membership::TYPE_DRIPPED => array( 
  54. 'text' => __( 'Dripped Content Membership.', 'membership2' ),  
  55. 'desc' => __( 'Set-up membership content to be released / made available in intervals.', 'membership2' ),  
  56. ),  
  57. ),  
  58. ),  
  59.  
  60. 'control_fields' => array( 
  61. 'membership_id' => array( 
  62. 'id' => 'membership_id',  
  63. 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN,  
  64. 'value' => $membership->id,  
  65. ),  
  66. 'step' => array( 
  67. 'id' => 'step',  
  68. 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN,  
  69. 'value' => MS_Controller_Membership::STEP_EDIT,  
  70. ),  
  71. 'tab' => array( 
  72. 'id' => 'tab',  
  73. 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN,  
  74. 'value' => MS_Controller_Membership::TAB_TYPE,  
  75. ),  
  76. 'action' => array( 
  77. 'id' => 'action',  
  78. 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN,  
  79. 'value' => $action,  
  80. ),  
  81. '_wpnonce' => array( 
  82. 'id' => '_wpnonce',  
  83. 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN,  
  84. 'value' => wp_create_nonce( $action ),  
  85. ),  
  86. 'save' => array( 
  87. 'id' => 'save',  
  88. 'type' => MS_Helper_Html::INPUT_TYPE_SUBMIT,  
  89. 'value' => __( 'Save', 'membership2' ),  
  90. ),  
  91. ),  
  92. ); 
  93.  
  94. return $fields;