MS_Gateway_Paypalsingle_View_Settings

The Membership 2 MS Gateway Paypalsingle View Settings class.

Defined (1)

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

/app/gateway/paypalsingle/view/class-ms-gateway-paypalsingle-view-settings.php  
  1. class MS_Gateway_Paypalsingle_View_Settings extends MS_View { 
  2.  
  3. public function to_html() { 
  4. $fields = $this->prepare_fields(); 
  5. $gateway = $this->data['model']; 
  6.  
  7. ob_start(); 
  8. /** Render tabbed interface. */ 
  9. ?> 
  10. <form class="ms-gateway-settings-form ms-form"> 
  11. <?php 
  12. $description = sprintf( 
  13. '%s<br>%s',  
  14. __( 'This the a basic PayPal gateway that allows your members to easily make a single payment.', 'membership2' ),  
  15. __( 'If you use this gateway for recurring payments then your members have to confirm each recuring payment individually.', 'membership2' ) 
  16. ); 
  17.  
  18. MS_Helper_Html::settings_box_header( '', $description ); 
  19. foreach ( $fields as $field ) { 
  20. MS_Helper_Html::html_element( $field ); 
  21. MS_Helper_Html::settings_box_footer(); 
  22. ?> 
  23. </form> 
  24. <?php 
  25. $html = ob_get_clean(); 
  26. return $html; 
  27.  
  28. protected function prepare_fields() { 
  29. $gateway = $this->data['model']; 
  30. $action = MS_Controller_Gateway::AJAX_ACTION_UPDATE_GATEWAY; 
  31. $nonce = wp_create_nonce( $action ); 
  32.  
  33. $fields = array( 
  34. 'merchant_id' => array( 
  35. 'id' => 'paypal_email',  
  36. 'type' => MS_Helper_Html::INPUT_TYPE_TEXT,  
  37. 'title' => __( 'PayPal Email', 'membership2' ),  
  38. 'value' => $gateway->paypal_email,  
  39. 'class' => 'ms-text-large',  
  40. 'ajax_data' => array( 1 ),  
  41. ),  
  42.  
  43. 'paypal_site' => array( 
  44. 'id' => 'paypal_site',  
  45. 'type' => MS_Helper_Html::INPUT_TYPE_SELECT,  
  46. 'title' => __( 'PayPal Site', 'membership2' ),  
  47. 'field_options' => $gateway->get_paypal_sites(),  
  48. 'value' => $gateway->paypal_site,  
  49. 'class' => 'ms-text-large',  
  50. 'ajax_data' => array( 1 ),  
  51. ),  
  52.  
  53. 'mode' => array( 
  54. 'id' => 'mode',  
  55. 'type' => MS_Helper_Html::INPUT_TYPE_SELECT,  
  56. 'title' => __( 'PayPal Mode', 'membership2' ),  
  57. 'value' => $gateway->mode,  
  58. 'field_options' => $gateway->get_mode_types(),  
  59. 'class' => 'ms-text-large',  
  60. 'ajax_data' => array( 1 ),  
  61. ),  
  62.  
  63. 'pay_button_url' => array( 
  64. 'id' => 'pay_button_url',  
  65. 'type' => MS_Helper_Html::INPUT_TYPE_TEXT,  
  66. 'title' => apply_filters( 
  67. 'ms_translation_flag',  
  68. __( 'Payment button label or URL', 'membership2' ),  
  69. 'gateway-button' . $gateway->id 
  70. ),  
  71. 'value' => $gateway->pay_button_url,  
  72. 'class' => 'ms-text-large',  
  73. 'ajax_data' => array( 1 ),  
  74. ),  
  75. ); 
  76.  
  77. // Process the fields and add missing default attributes. 
  78. foreach ( $fields as $key => $field ) { 
  79. if ( ! empty( $field['ajax_data'] ) ) { 
  80. $fields[ $key ]['ajax_data']['field'] = $fields[ $key ]['id']; 
  81. $fields[ $key ]['ajax_data']['_wpnonce'] = $nonce; 
  82. $fields[ $key ]['ajax_data']['action'] = $action; 
  83. $fields[ $key ]['ajax_data']['gateway_id'] = $gateway->id; 
  84.  
  85. return $fields; 
  86.