MS_Gateway_Manual_View_Button

The Membership 2 MS Gateway Manual View Button class.

Defined (1)

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

/app/gateway/manual/view/class-ms-gateway-manual-view-button.php  
  1. class MS_Gateway_Manual_View_Button extends MS_View { 
  2.  
  3. public function to_html() { 
  4. $fields = $this->prepare_fields(); 
  5. $subscription = $this->data['ms_relationship']; 
  6. $invoice = $subscription->get_current_invoice(); 
  7. $gateway = $this->data['gateway']; 
  8.  
  9. $action_url = MS_Model_Pages::get_page_url( MS_Model_Pages::MS_PAGE_REGISTER ); 
  10. $action_url = apply_filters( 
  11. 'ms_gateway_manual_view_button_form_action_url',  
  12. $action_url 
  13. ); 
  14.  
  15. $row_class = 'gateway_' . $gateway->id; 
  16. if ( ! $gateway->is_live_mode() ) { 
  17. $row_class .= ' sandbox-mode'; 
  18.  
  19. ob_start(); 
  20. ?> 
  21. <form action="<?php echo esc_url( $action_url ); ?>" method="post"> 
  22. <?php 
  23. foreach ( $fields as $field ) { 
  24. MS_Helper_Html::html_element( $field ); 
  25. ?> 
  26. </form> 
  27. <?php 
  28. $payment_form = apply_filters( 
  29. 'ms_gateway_form',  
  30. ob_get_clean(),  
  31. $gateway,  
  32. $invoice,  
  33. $this 
  34. ); 
  35.  
  36. ob_start(); 
  37. ?> 
  38. <tr class="<?php echo esc_attr( $row_class ); ?>"> 
  39. <td class="ms-buy-now-column" colspan="2"> 
  40. <?php echo $payment_form; ?> 
  41. </td> 
  42. </tr> 
  43. <?php 
  44. $html = ob_get_clean(); 
  45.  
  46. $html = apply_filters( 
  47. 'ms_gateway_button-' . $gateway->id,  
  48. $html,  
  49. $this 
  50. ); 
  51.  
  52. $html = apply_filters( 
  53. 'ms_gateway_button',  
  54. $html,  
  55. $gateway->id,  
  56. $this 
  57. ); 
  58.  
  59. return $html; 
  60.  
  61. private function prepare_fields() { 
  62. $gateway = $this->data['gateway']; 
  63. $subscription = $this->data['ms_relationship']; 
  64.  
  65. $fields = array( 
  66. '_wpnonce' => array( 
  67. 'id' => '_wpnonce',  
  68. 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN,  
  69. 'value' => wp_create_nonce( "{$gateway->id}_{$subscription->id}" ),  
  70. ),  
  71. 'gateway' => array( 
  72. 'id' => 'gateway',  
  73. 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN,  
  74. 'value' => $gateway->id,  
  75. ),  
  76. 'ms_relationship_id' => array( 
  77. 'id' => 'ms_relationship_id',  
  78. 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN,  
  79. 'value' => $subscription->id,  
  80. ),  
  81. 'step' => array( 
  82. 'id' => 'step',  
  83. 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN,  
  84. 'value' => $this->data['step'],  
  85. ),  
  86. ); 
  87.  
  88. if ( false !== strpos( $gateway->pay_button_url, '://' ) ) { 
  89. $fields['submit'] = array( 
  90. 'id' => 'submit',  
  91. 'type' => MS_Helper_Html::INPUT_TYPE_IMAGE,  
  92. 'value' => $gateway->pay_button_url,  
  93. ); 
  94. } else { 
  95. $fields['submit'] = array( 
  96. 'id' => 'submit',  
  97. 'type' => MS_Helper_Html::INPUT_TYPE_SUBMIT,  
  98. 'value' => $gateway->pay_button_url 
  99. ? $gateway->pay_button_url 
  100. : __( 'Signup', 'membership2' ),  
  101. ); 
  102.  
  103. return $fields;