MS_View_Membership_Overview_Dripped

The Membership 2 MS View Membership Overview Dripped class.

Defined (1)

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

/app/view/membership/overview/class-ms-view-membership-overview-dripped.php  
  1. class MS_View_Membership_Overview_Dripped extends MS_View_Membership_Overview_Simple { 
  2.  
  3. public function available_content_panel_data() { 
  4. $relative = array(); 
  5. $absolute = array(); 
  6. $membership = $this->data['membership']; 
  7. $rule_types = MS_Model_Rule::get_dripped_rule_types(); 
  8.  
  9. foreach ( $rule_types as $rule_type ) { 
  10. $rule = $membership->get_rule( $rule_type ); 
  11. $contents = (array) $rule->get_contents(); 
  12.  
  13. foreach ( $contents as $content ) { 
  14. if ( $rule->has_dripped_rules( $content->id ) ) { 
  15. $infos = $rule->dripped[$content->id]; 
  16. $key = false; 
  17. $content->date = $rule->get_dripped_description( $content->id ); 
  18. $content->icon = 'visibility'; 
  19.  
  20. switch ( $infos['type'] ) { 
  21. case MS_Model_Rule::DRIPPED_TYPE_FROM_REGISTRATION: 
  22. $content->icon = 'clock'; 
  23. $key = MS_Helper_Period::get_period_in_days( 
  24. $infos['delay_unit'],  
  25. $infos['delay_type'] 
  26. ); 
  27. $key = 100000 + ($key * 1000); 
  28. while ( isset( $relative[ $key ] ) ) { $key += 1; } 
  29. $relative[$key] = $content; 
  30. break; 
  31.  
  32. case MS_Model_Rule::DRIPPED_TYPE_SPEC_DATE: 
  33. $key = preg_replace( '/[^0-9]/', '', $infos['date'] ); 
  34. if ( ! $rule->has_access( $content->id ) ) { 
  35. $content->icon = 'lock'; 
  36. // Fall through 
  37.  
  38. case MS_Model_Rule::DRIPPED_TYPE_INSTANTLY: 
  39. default: 
  40. if ( empty( $key ) ) { $key = 0; } 
  41.  
  42. $key = ($key * 1000); 
  43. while ( isset( $relative[ $key ] ) ) { $key += 1; } 
  44. $absolute[$key] = $content; 
  45. break; 
  46. ?> 
  47. <div class="clear"></div> 
  48.  
  49. <div class="cf"> 
  50. <div class="ms-half ms-available-soon space"> 
  51. <div class="ms-bold"> 
  52. <i class="dashicons dashicons-calendar ms-low"></i> 
  53. <?php _e( 'Available on a specific date:', 'membership2' ); ?> 
  54. </div> 
  55. <div class="inside"> 
  56. <?php $this->content_box( $absolute ); ?> 
  57. </div> 
  58. </div> 
  59.  
  60. <div class="ms-half ms-available"> 
  61. <div class="ms-bold"> 
  62. <i class="dashicons dashicons-clock ms-low"></i> 
  63. <?php _e( 'Relative to registration:', 'membership2' ); ?> 
  64. </div> 
  65. <div class="inside"> 
  66. <?php $this->content_box( $relative ); ?> 
  67. </div> 
  68. </div> 
  69. </div> 
  70.  
  71. <div class="cf"> 
  72. <div class="ms-half"> 
  73. <div class="inside"> 
  74. <div class="ms-protection-edit-wrapper"> 
  75. <?php 
  76. $edit_url = MS_Controller_Plugin::get_admin_url( 
  77. 'protection',  
  78. array( 
  79. 'tab' => $rule->rule_type,  
  80. 'membership_id' => $membership->id,  
  81. ); 
  82. MS_Helper_Html::html_element( 
  83. array( 
  84. 'id' => 'edit_dripped',  
  85. 'type' => MS_Helper_Html::TYPE_HTML_LINK,  
  86. 'value' => __( 'Edit Dripped Content', 'membership2' ),  
  87. 'url' => $edit_url,  
  88. 'class' => 'wpmui-field-button button',  
  89. ); 
  90.  
  91. if ( ! $membership->is_free ) { 
  92. $payment_url = esc_url_raw( 
  93. add_query_arg( 
  94. array( 
  95. 'step' => MS_Controller_Membership::STEP_PAYMENT,  
  96. 'edit' => 1,  
  97. ); 
  98. MS_Helper_Html::html_element( 
  99. array( 
  100. 'id' => 'setup_payment',  
  101. 'type' => MS_Helper_Html::TYPE_HTML_LINK,  
  102. 'value' => __( 'Payment Options', 'membership2' ),  
  103. 'url' => $payment_url,  
  104. 'class' => 'wpmui-field-button button',  
  105. ); 
  106. ?> 
  107. </div> 
  108. </div> 
  109. </div> 
  110. </div> 
  111.  
  112. <?php 
  113.  
  114. /** 
  115. * Echo a content list as 2-column table that show Content-Title and the 
  116. * Available date. 
  117. * Used by Dripped-Content view. 
  118. * @since 1.0.0 
  119. * @param array $contents List of content items to display. 
  120. */ 
  121. protected function content_box( $contents ) { 
  122. $row_class = ''; 
  123. ksort( $contents ); 
  124. $rule_titles = MS_Model_Rule::get_rule_type_titles(); 
  125.  
  126. $edit_url = MS_Controller_Plugin::get_admin_url( 
  127. 'protection',  
  128. array( 
  129. 'tab' => $rule->rule_type,  
  130. ); 
  131. $edit_link = array( 
  132. 'id' => 'edit_dripped',  
  133. 'type' => MS_Helper_Html::TYPE_HTML_LINK,  
  134. ); 
  135.  
  136. ?> 
  137. <table class="ms-list-table ms-list-date widefat"> 
  138. <thead> 
  139. <tr> 
  140. <th class="col-icon"> </th> 
  141. <th class="col-text"><?php _e( 'Rule', 'membership2' ); ?></th> 
  142. <th class="col-text"><?php _e( 'Protected Item', 'membership2' ); ?></th> 
  143. <th class="col-date"><?php _e( 'Access', 'membership2' ); ?></th> 
  144. </tr> 
  145. </thead> 
  146. <tbody> 
  147. <?php foreach ( $contents as $id => $content ) : 
  148. $row_class = ($row_class == 'alternate' ? '' : 'alternate' ); 
  149. ?> 
  150. <tr class="<?php echo esc_attr( $row_class . ' ' . $content->icon ); ?>"> 
  151. <td class="col-icon"> 
  152. <i class="dashicons dashicons-<?php echo esc_attr( $content->icon ); ?>"></i> 
  153. </td> 
  154. <td class="col-text col-type"> 
  155. <?php 
  156. $edit_link['url'] = esc_url_raw( 
  157. add_query_arg( 
  158. 'tab',  
  159. $content->type,  
  160. $edit_url 
  161. ); 
  162. $edit_link['value'] = $rule_titles[ $content->type ]; 
  163. MS_Helper_Html::html_element( $edit_link ); 
  164. ?> 
  165. </td> 
  166. <td class="col-text"> 
  167. <?php MS_Helper_Html::content_tag( $content, 'span' ); ?> 
  168. </td> 
  169. <td class="col-date"> 
  170. <?php echo '' . $content->date; ?> 
  171. </td> 
  172. </tr> 
  173. <?php endforeach;?> 
  174. </tbody> 
  175. </table> 
  176. <?php