← All changes
|
includes/admin/settings/class-settings-gateways.php
+502
-359
2.3.1
→
4.17.0
View file →
| @@ -1,414 +1,557 @@ | ||
| 1 | 1 | <?php |
| 2 | + | |
| 2 | 3 | /** |
| 3 | 4 | * Give Settings Page/Tab |
| 4 | 5 | * |
| 5 | 6 | * @package Give |
| 6 | - * @subpackage Classes/Give_Settings_Gateways | |
| 7 | + * @since 1.8 | |
| 7 | 8 | * @copyright Copyright (c) 2016, GiveWP |
| 8 | 9 | * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 9 | - * @since 1.8 | |
| 10 | + * @subpackage Classes/Give_Settings_Gateways | |
| 10 | 11 | */ |
| 11 | 12 | |
| 12 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 13 | - exit; // Exit if accessed directly | |
| 13 | +use Give\PaymentGateways\PayPalCommerce\Repositories\MerchantDetails; | |
| 14 | +use Give\PaymentGateways\Stripe\Admin\AccountManagerSettingField; | |
| 15 | + | |
| 16 | +if (! defined('ABSPATH')) { | |
| 17 | + exit; // Exit if accessed directly | |
| 14 | 18 | } |
| 15 | 19 | |
| 16 | -if ( ! class_exists( 'Give_Settings_Gateways' ) ) : | |
| 20 | +if (! class_exists('Give_Settings_Gateways')) : | |
| 17 | 21 | |
| 18 | - /** | |
| 19 | - * Give_Settings_Gateways. | |
| 20 | - * | |
| 21 | - * @sine 1.8 | |
| 22 | - */ | |
| 23 | - class Give_Settings_Gateways extends Give_Settings_Page { | |
| 22 | + /** | |
| 23 | + * Give_Settings_Gateways. | |
| 24 | + * | |
| 25 | + * @sine 1.8 | |
| 26 | + */ | |
| 27 | + class Give_Settings_Gateways extends Give_Settings_Page | |
| 28 | + { | |
| 29 | + /** | |
| 30 | + * Constructor. | |
| 31 | + */ | |
| 32 | + public function __construct() | |
| 33 | + { | |
| 34 | + $this->id = 'gateways'; | |
| 35 | + $this->label = esc_html__('Payment Gateways', 'give'); | |
| 24 | 36 | |
| 25 | - /** | |
| 26 | - * Constructor. | |
| 27 | - */ | |
| 28 | - public function __construct() { | |
| 29 | - $this->id = 'gateways'; | |
| 30 | - $this->label = esc_html__( 'Payment Gateways', 'give' ); | |
| 37 | + $this->default_tab = 'gateways-settings'; | |
| 31 | 38 | |
| 32 | - $this->default_tab = 'gateways-settings'; | |
| 39 | + parent::__construct(); | |
| 33 | 40 | |
| 34 | - parent::__construct(); | |
| 41 | + // Do not use main form for this tab. | |
| 42 | + if (give_get_current_setting_tab() === $this->id) { | |
| 43 | + add_action('give_admin_field_gateway_notice', [$this, 'render_gateway_notice'], 10, 2); | |
| 44 | + add_action('give_admin_field_enabled_gateways', [$this, 'render_enabled_gateways'], 10, 2); | |
| 45 | + } | |
| 46 | + } | |
| 35 | 47 | |
| 36 | - // Do not use main form for this tab. | |
| 37 | - if ( give_get_current_setting_tab() === $this->id ) { | |
| 38 | - add_action( 'give_admin_field_gateway_notice', array( $this, 'render_gateway_notice' ), 10, 2 ); | |
| 39 | - add_action( 'give_admin_field_enabled_gateways', array( $this, 'render_enabled_gateways' ), 10, 2 ); | |
| 40 | - } | |
| 41 | - } | |
| 48 | + /** | |
| 49 | + * Get settings array. | |
| 50 | + * | |
| 51 | + * @since 1.8 | |
| 52 | + * @return array | |
| 53 | + */ | |
| 54 | + public function get_settings() | |
| 55 | + { | |
| 56 | + $settings = []; | |
| 57 | + $current_section = give_get_current_setting_section(); | |
| 42 | 58 | |
| 43 | - /** | |
| 44 | - * Get settings array. | |
| 45 | - * | |
| 46 | - * @since 1.8 | |
| 47 | - * @return array | |
| 48 | - */ | |
| 49 | - public function get_settings() { | |
| 50 | - $settings = array(); | |
| 51 | - $current_section = give_get_current_setting_section(); | |
| 59 | + switch ($current_section) { | |
| 60 | + case 'offline-donations': | |
| 61 | + $settings = [ | |
| 62 | + // Section 3: Offline gateway. | |
| 63 | + [ | |
| 64 | + 'type' => 'title', | |
| 65 | + 'id' => 'give_title_gateway_settings_3', | |
| 66 | + ], | |
| 67 | + [ | |
| 68 | + 'name' => __('Collect Billing Details', 'give'), | |
| 69 | + 'desc' => __('If enabled, required billing address fields are added to Offline Donation forms. These fields are not required to process the transaction, but you may have a need to collect the data. Billing address details are added to both the donation and donor record in GiveWP. ', 'give'), | |
| 70 | + 'id' => 'give_offline_donation_enable_billing_fields', | |
| 71 | + 'type' => 'radio_inline', | |
| 72 | + 'default' => 'disabled', | |
| 73 | + 'options' => [ | |
| 74 | + 'enabled' => __('Enabled', 'give'), | |
| 75 | + 'disabled' => __('Disabled', 'give'), | |
| 76 | + ], | |
| 77 | + ], | |
| 78 | + [ | |
| 79 | + 'name' => __('Offline Donation Instructions', 'give'), | |
| 80 | + 'desc' => __('The Offline Donation Instructions are a chance for you to educate the donor on how to best submit offline donations. These instructions appear directly on the form, and after submission of the form. Note: You may also customize the instructions on individual forms as needed.', 'give'), | |
| 81 | + 'id' => 'global_offline_donation_content', | |
| 82 | + 'default' => give_get_default_offline_donation_content(), | |
| 83 | + 'type' => 'wysiwyg', | |
| 84 | + 'options' => [ | |
| 85 | + 'textarea_rows' => 6, | |
| 86 | + ], | |
| 87 | + ], | |
| 88 | + [ | |
| 89 | + 'name' => esc_html__('Offline Donations Settings Docs Link', 'give'), | |
| 90 | + 'id' => 'offline_gateway_settings_docs_link', | |
| 91 | + 'url' => esc_url('http://docs.givewp.com/offlinegateway'), | |
| 92 | + 'title' => __('Offline Gateway Settings', 'give'), | |
| 93 | + 'type' => 'give_docs_link', | |
| 94 | + ], | |
| 95 | + [ | |
| 96 | + 'type' => 'sectionend', | |
| 97 | + 'id' => 'give_title_gateway_settings_3', | |
| 98 | + ], | |
| 99 | + ]; | |
| 100 | + break; | |
| 52 | 101 | |
| 53 | - switch ( $current_section ) { | |
| 54 | - case 'paypal-standard': | |
| 55 | - $settings = array( | |
| 56 | - // Section 2: PayPal Standard. | |
| 57 | - array( | |
| 58 | - 'type' => 'title', | |
| 59 | - 'id' => 'give_title_gateway_settings_2', | |
| 60 | - ), | |
| 61 | - array( | |
| 62 | - 'name' => __( 'PayPal Email', 'give' ), | |
| 63 | - 'desc' => __( 'Enter your PayPal account\'s email.', 'give' ), | |
| 64 | - 'id' => 'paypal_email', | |
| 65 | - 'type' => 'email', | |
| 66 | - ), | |
| 67 | - array( | |
| 68 | - 'name' => __( 'PayPal Page Style', 'give' ), | |
| 69 | - 'desc' => __( 'Enter the name of the PayPal page style to use, or leave blank to use the default.', 'give' ), | |
| 70 | - 'id' => 'paypal_page_style', | |
| 71 | - 'type' => 'text', | |
| 72 | - ), | |
| 73 | - array( | |
| 74 | - 'name' => __( 'PayPal Transaction Type', 'give' ), | |
| 75 | - 'desc' => __( 'Nonprofits must verify their status to withdraw donations they receive via PayPal. PayPal users that are not verified nonprofits must demonstrate how their donations will be used, once they raise more than $10,000. By default, Give transactions are sent to PayPal as donations. You may change the transaction type using this option if you feel you may not meet PayPal\'s donation requirements.', 'give' ), | |
| 76 | - 'id' => 'paypal_button_type', | |
| 77 | - 'type' => 'radio_inline', | |
| 78 | - 'options' => array( | |
| 79 | - 'donation' => __( 'Donation', 'give' ), | |
| 80 | - 'standard' => __( 'Standard Transaction', 'give' ) | |
| 81 | - ), | |
| 82 | - 'default' => 'donation', | |
| 83 | - ), | |
| 84 | - array( | |
| 85 | - 'name' => __( 'Billing Details', 'give' ), | |
| 86 | - 'desc' => __( 'This option will enable the billing details section for PayPal Standard which requires the donor\'s address to complete the donation. These fields are not required by PayPal to process the transaction, but you may have a need to collect the data.', 'give' ), | |
| 87 | - 'id' => 'paypal_standard_billing_details', | |
| 88 | - 'type' => 'radio_inline', | |
| 89 | - 'default' => 'disabled', | |
| 90 | - 'options' => array( | |
| 91 | - 'enabled' => __( 'Enabled', 'give' ), | |
| 92 | - 'disabled' => __( 'Disabled', 'give' ), | |
| 93 | - ) | |
| 94 | - ), | |
| 95 | - array( | |
| 96 | - 'name' => __( 'PayPal IPN Verification', 'give' ), | |
| 97 | - 'desc' => __( 'If donations are not getting marked as complete, use a slightly less secure method of verifying donations.', 'give' ), | |
| 98 | - 'id' => 'paypal_verification', | |
| 99 | - 'type' => 'radio_inline', | |
| 100 | - 'default' => 'enabled', | |
| 101 | - 'options' => array( | |
| 102 | - 'enabled' => __( 'Enabled', 'give' ), | |
| 103 | - 'disabled' => __( 'Disabled', 'give' ), | |
| 104 | - ) | |
| 105 | - ), | |
| 106 | - array( | |
| 107 | - 'id' => 'paypal_invoice_prefix', | |
| 108 | - 'name' => esc_html__( 'Invoice ID Prefix', 'give' ), | |
| 109 | - 'desc' => esc_html__( 'Please enter a prefix for your invoice numbers. If you use your PayPal account for multiple stores ensure this prefix is unique as PayPal will not allow orders with the same invoice number.', 'give' ), | |
| 110 | - 'type' => 'text', | |
| 111 | - 'default' => 'GIVE-', | |
| 112 | - ), | |
| 113 | - array( | |
| 114 | - 'name' => __( 'PayPal Standard Gateway Settings Docs Link', 'give' ), | |
| 115 | - 'id' => 'paypal_standard_gateway_settings_docs_link', | |
| 116 | - 'url' => esc_url( 'http://docs.givewp.com/settings-gateway-paypal-standard' ), | |
| 117 | - 'title' => __( 'PayPal Standard Gateway Settings', 'give' ), | |
| 118 | - 'type' => 'give_docs_link', | |
| 119 | - ), | |
| 120 | - array( | |
| 121 | - 'type' => 'sectionend', | |
| 122 | - 'id' => 'give_title_gateway_settings_2', | |
| 123 | - ) | |
| 124 | - ); | |
| 125 | - break; | |
| 102 | + case 'gateways-settings': | |
| 103 | + $settings = [ | |
| 104 | + // Section 1: Gateways. | |
| 105 | + [ | |
| 106 | + 'id' => 'give_title_gateway_settings_1', | |
| 107 | + 'type' => 'title', | |
| 108 | + ], | |
| 109 | + [ | |
| 110 | + 'id' => 'gateway_notice', | |
| 111 | + 'type' => 'gateway_notice', | |
| 112 | + ], | |
| 113 | + [ | |
| 114 | + 'name' => __('Test Mode', 'give'), | |
| 115 | + 'desc' => __( | |
| 116 | + 'If enabled, donations are processed through the sandbox/test accounts configured in each gateway\'s settings. This prevents having to use real money for tests. See the payment gateway documentation for instructions on configuring sandbox accounts.', | |
| 117 | + 'give' | |
| 118 | + ), | |
| 119 | + 'id' => 'test_mode', | |
| 120 | + 'type' => 'radio_inline', | |
| 121 | + 'default' => 'disabled', | |
| 122 | + 'options' => [ | |
| 123 | + 'enabled' => __('Enabled', 'give'), | |
| 124 | + 'disabled' => __('Disabled', 'give'), | |
| 125 | + ], | |
| 126 | + ], | |
| 127 | + [ | |
| 128 | + 'name' => __('Enabled Gateways', 'give') . ' - v2', | |
| 129 | + 'desc' => __('Enable your payment gateway. Can be ordered by dragging.', 'give'), | |
| 130 | + 'id' => 'gateways', | |
| 131 | + 'type' => 'enabled_gateways', | |
| 132 | + ], | |
| 133 | + [ | |
| 134 | + 'name' => __('Enabled Gateways', 'give') . ' - v3', | |
| 135 | + 'desc' => __('Enable your payment gateway. Can be ordered by dragging.', 'give'), | |
| 136 | + 'id' => 'gateways_v3', | |
| 137 | + 'type' => 'enabled_gateways_hidden', | |
| 138 | + ], | |
| 126 | 139 | |
| 127 | - case 'offline-donations' : | |
| 128 | - $settings = array( | |
| 129 | - // Section 3: Offline gateway. | |
| 130 | - array( | |
| 131 | - 'type' => 'title', | |
| 132 | - 'id' => 'give_title_gateway_settings_3', | |
| 133 | - ), | |
| 134 | - array( | |
| 135 | - 'name' => __( 'Collect Billing Details', 'give' ), | |
| 136 | - 'desc' => __( 'Enable to request billing details for offline donations. Will appear above offline donation instructions. Can be enabled/disabled per form.', 'give' ), | |
| 137 | - 'id' => 'give_offline_donation_enable_billing_fields', | |
| 138 | - 'type' => 'radio_inline', | |
| 139 | - 'default' => 'disabled', | |
| 140 | - 'options' => array( | |
| 141 | - 'enabled' => __( 'Enabled', 'give' ), | |
| 142 | - 'disabled' => __( 'Disabled', 'give' ) | |
| 143 | - ) | |
| 144 | - ), | |
| 145 | - array( | |
| 146 | - 'name' => __( 'Offline Donation Instructions', 'give' ), | |
| 147 | - 'desc' => __( 'The following content will appear for all forms when the user selects the offline donation payment option. Note: You may customize the content per form as needed.', 'give' ), | |
| 148 | - 'id' => 'global_offline_donation_content', | |
| 149 | - 'default' => give_get_default_offline_donation_content(), | |
| 150 | - 'type' => 'wysiwyg', | |
| 151 | - 'options' => array( | |
| 152 | - 'textarea_rows' => 6, | |
| 153 | - ) | |
| 154 | - ), | |
| 155 | - array( | |
| 156 | - 'name' => esc_html__( 'Offline Donations Settings Docs Link', 'give' ), | |
| 157 | - 'id' => 'offline_gateway_settings_docs_link', | |
| 158 | - 'url' => esc_url( 'http://docs.givewp.com/offlinegateway' ), | |
| 159 | - 'title' => __( 'Offline Gateway Settings', 'give' ), | |
| 160 | - 'type' => 'give_docs_link', | |
| 161 | - ), | |
| 162 | - array( | |
| 163 | - 'type' => 'sectionend', | |
| 164 | - 'id' => 'give_title_gateway_settings_3', | |
| 165 | - ) | |
| 166 | - ); | |
| 167 | - break; | |
| 140 | + /** | |
| 141 | + * "Enabled Gateways" setting field contains gateways label setting but when you save gateway settings then label will not save | |
| 142 | + * because this is not registered setting API and code will not recognize them. | |
| 143 | + * | |
| 144 | + * This setting will not render on admin setting screen but help internal code to recognize "gateways_label" setting and add them to give setting when save. | |
| 145 | + */ | |
| 146 | + [ | |
| 147 | + 'name' => __('Gateways Label', 'give') . ' - v2', | |
| 148 | + 'desc' => '', | |
| 149 | + 'id' => 'gateways_label', | |
| 150 | + 'type' => 'gateways_label_hidden', | |
| 151 | + ], | |
| 152 | + [ | |
| 153 | + 'name' => __('Gateways Label', 'give') . ' - v3', | |
| 154 | + 'desc' => '', | |
| 155 | + 'id' => 'gateways_label_v3', | |
| 156 | + 'type' => 'gateways_label_hidden', | |
| 157 | + ], | |
| 168 | 158 | |
| 169 | - case 'gateways-settings': | |
| 170 | - $settings = array( | |
| 171 | - // Section 1: Gateways. | |
| 172 | - array( | |
| 173 | - 'id' => 'give_title_gateway_settings_1', | |
| 174 | - 'type' => 'title' | |
| 175 | - ), | |
| 176 | - array( | |
| 177 | - 'id' => 'gateway_notice', | |
| 178 | - 'type' => 'gateway_notice', | |
| 179 | - ), | |
| 180 | - array( | |
| 181 | - 'name' => __( 'Test Mode', 'give' ), | |
| 182 | - 'desc' => __( 'While in test mode no live donations are processed. To fully use test mode, you must have a sandbox (test) account for the payment gateway you are testing.', 'give' ), | |
| 183 | - 'id' => 'test_mode', | |
| 184 | - 'type' => 'radio_inline', | |
| 185 | - 'default' => 'disabled', | |
| 186 | - 'options' => array( | |
| 187 | - 'enabled' => __( 'Enabled', 'give' ), | |
| 188 | - 'disabled' => __( 'Disabled', 'give' ), | |
| 189 | - ) | |
| 190 | - ), | |
| 191 | - array( | |
| 192 | - 'name' => __( 'Enabled Gateways', 'give' ), | |
| 193 | - 'desc' => __( 'Enable your payment gateway. Can be ordered by dragging.', 'give' ), | |
| 194 | - 'id' => 'gateways', | |
| 195 | - 'type' => 'enabled_gateways' | |
| 196 | - ), | |
| 159 | + /** | |
| 160 | + * "Enabled Gateways" setting field contains default gateway setting but when you save gateway settings then this setting will not save | |
| 161 | + * because this is not registered setting API and code will not recognize them. | |
| 162 | + * | |
| 163 | + * This setting will not render on admin setting screen but help internal code to recognize "default_gateway" setting and add them to give setting when save. | |
| 164 | + */ | |
| 165 | + [ | |
| 166 | + 'name' => __('Default Gateway', 'give') . ' - v2', | |
| 167 | + 'desc' => __('The gateway that will be selected by default.', 'give'), | |
| 168 | + 'id' => 'default_gateway', | |
| 169 | + 'type' => 'default_gateway_hidden', | |
| 170 | + ], | |
| 171 | + [ | |
| 172 | + 'name' => __('Default Gateway', 'give') . ' - v3', | |
| 173 | + 'desc' => __('The gateway that will be selected by default.', 'give'), | |
| 174 | + 'id' => 'default_gateway_v3', | |
| 175 | + 'type' => 'default_gateway_hidden', | |
| 176 | + ], | |
| 197 | 177 | |
| 198 | - /** | |
| 199 | - * "Enabled Gateways" setting field contains gateways label setting but when you save gateway settings then label will not save | |
| 200 | - * because this is not registered setting API and code will not recognize them. | |
| 201 | - * | |
| 202 | - * This setting will not render on admin setting screen but help internal code to recognize "gateways_label" setting and add them to give setting when save. | |
| 203 | - */ | |
| 204 | - array( | |
| 205 | - 'name' => __( 'Gateways Label', 'give' ), | |
| 206 | - 'desc' => '', | |
| 207 | - 'id' => 'gateways_label', | |
| 208 | - 'type' => 'gateways_label_hidden' | |
| 209 | - ), | |
| 178 | + [ | |
| 179 | + 'name' => __('Gateways Docs Link', 'give'), | |
| 180 | + 'id' => 'gateway_settings_docs_link', | |
| 181 | + 'url' => esc_url('http://docs.givewp.com/settings-gateways'), | |
| 182 | + 'title' => __('Gateway Settings', 'give'), | |
| 183 | + 'type' => 'give_docs_link', | |
| 184 | + ], | |
| 185 | + [ | |
| 186 | + 'id' => 'give_title_gateway_settings_1', | |
| 187 | + 'type' => 'sectionend', | |
| 188 | + ], | |
| 189 | + ]; | |
| 190 | + break; | |
| 191 | + } | |
| 210 | 192 | |
| 211 | - /** | |
| 212 | - * "Enabled Gateways" setting field contains default gateway setting but when you save gateway settings then this setting will not save | |
| 213 | - * because this is not registered setting API and code will not recognize them. | |
| 214 | - * | |
| 215 | - * This setting will not render on admin setting screen but help internal code to recognize "default_gateway" setting and add them to give setting when save. | |
| 216 | - */ | |
| 217 | - array( | |
| 218 | - 'name' => __( 'Default Gateway', 'give' ), | |
| 219 | - 'desc' => __( 'The gateway that will be selected by default.', 'give' ), | |
| 220 | - 'id' => 'default_gateway', | |
| 221 | - 'type' => 'default_gateway_hidden' | |
| 222 | - ), | |
| 193 | + /** | |
| 194 | + * Filter the payment gateways settings. | |
| 195 | + * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8 | |
| 196 | + */ | |
| 197 | + $settings = apply_filters('give_settings_gateways', $settings); | |
| 223 | 198 | |
| 224 | - array( | |
| 225 | - 'name' => __( 'Gateways Docs Link', 'give' ), | |
| 226 | - 'id' => 'gateway_settings_docs_link', | |
| 227 | - 'url' => esc_url( 'http://docs.givewp.com/settings-gateways' ), | |
| 228 | - 'title' => __( 'Gateway Settings', 'give' ), | |
| 229 | - 'type' => 'give_docs_link', | |
| 230 | - ), | |
| 231 | - array( | |
| 232 | - 'id' => 'give_title_gateway_settings_1', | |
| 233 | - 'type' => 'sectionend' | |
| 234 | - ), | |
| 235 | - ); | |
| 236 | - break; | |
| 237 | - } | |
| 199 | + /** | |
| 200 | + * Filter the settings. | |
| 201 | + * | |
| 202 | + * @since 1.8 | |
| 203 | + * | |
| 204 | + * @param array $settings | |
| 205 | + */ | |
| 206 | + $settings = apply_filters('give_get_settings_' . $this->id, $settings); | |
| 238 | 207 | |
| 239 | - /** | |
| 240 | - * Filter the payment gateways settings. | |
| 241 | - * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8 | |
| 242 | - */ | |
| 243 | - $settings = apply_filters( 'give_settings_gateways', $settings ); | |
| 208 | + // Output. | |
| 209 | + return $settings; | |
| 210 | + } | |
| 244 | 211 | |
| 245 | - /** | |
| 246 | - * Filter the settings. | |
| 247 | - * | |
| 248 | - * @since 1.8 | |
| 249 | - * | |
| 250 | - * @param array $settings | |
| 251 | - */ | |
| 252 | - $settings = apply_filters( 'give_get_settings_' . $this->id, $settings ); | |
| 212 | + /** | |
| 213 | + * Get sections. | |
| 214 | + * | |
| 215 | + * @since 2.9.0 move offline-donations to end of gateway list | |
| 216 | + * @since 1.8 | |
| 217 | + * | |
| 218 | + * @return array | |
| 219 | + */ | |
| 220 | + public function get_sections() | |
| 221 | + { | |
| 222 | + $sections = apply_filters( | |
| 223 | + 'give_get_sections_' . $this->id, | |
| 224 | + [ | |
| 225 | + 'gateways-settings' => __('Gateways', 'give'), | |
| 226 | + ] | |
| 227 | + ); | |
| 253 | 228 | |
| 254 | - // Output. | |
| 255 | - return $settings; | |
| 256 | - } | |
| 229 | + $sections['offline-donations'] = __('Offline Donations', 'give'); | |
| 257 | 230 | |
| 258 | - /** | |
| 259 | - * Get sections. | |
| 260 | - * | |
| 261 | - * @since 1.8 | |
| 262 | - * @return array | |
| 263 | - */ | |
| 264 | - public function get_sections() { | |
| 265 | - $sections = array( | |
| 266 | - 'gateways-settings' => __( 'Gateways', 'give' ), | |
| 267 | - 'paypal-standard' => __( 'PayPal Standard', 'give' ), | |
| 268 | - 'offline-donations' => __( 'Offline Donations', 'give' ) | |
| 269 | - ); | |
| 231 | + return $sections; | |
| 232 | + } | |
| 270 | 233 | |
| 271 | - return apply_filters( 'give_get_sections_' . $this->id, $sections ); | |
| 272 | - } | |
| 234 | + /** | |
| 235 | + * @since 2.13.0 | |
| 236 | + * @return bool | |
| 237 | + */ | |
| 238 | + private function hasPremiumPaymentGateway() | |
| 239 | + { | |
| 240 | + $gateways = give_get_payment_gateways(); | |
| 273 | 241 | |
| 242 | + return (bool)apply_filters('give_gateway_upsell_notice_conditions', count($gateways) > 8); | |
| 243 | + } | |
| 274 | 244 | |
| 275 | - /** | |
| 276 | - * Render Gateway Notice | |
| 277 | - * | |
| 278 | - * @since 2.3.0 | |
| 279 | - * @access public | |
| 280 | - * | |
| 281 | - * @param $field | |
| 282 | - * @param $settings | |
| 283 | - */ | |
| 284 | - public function render_gateway_notice( $field, $settings ) { | |
| 245 | + /** | |
| 246 | + * @since 2.13.0 | |
| 247 | + * | |
| 248 | + * @return bool | |
| 249 | + */ | |
| 250 | + private function canAcceptCreditCard() | |
| 251 | + { | |
| 252 | + return Give\Helpers\Gateways\Stripe::isAccountConfigured() || | |
| 253 | + give(MerchantDetails::class)->accountIsConnected(); | |
| 254 | + } | |
| 285 | 255 | |
| 286 | - $gateways = give_get_payment_gateways(); | |
| 287 | 256 | |
| 288 | - // Only display notice if no active gateways are installed. Filter provided for developers to configure display. | |
| 289 | - if ( apply_filters( 'give_gateway_upsell_notice_conditions', count( $gateways ) <= 3 ) ) : ?> | |
| 257 | + /** | |
| 258 | + * Render Gateway Notice | |
| 259 | + * | |
| 260 | + * @since 4.2.0 Updated messages removing mentions to Stripe fees | |
| 261 | + * @since 2.3.0 | |
| 262 | + * @access public | |
| 263 | + * | |
| 264 | + * @param $field | |
| 265 | + * @param $settings | |
| 266 | + */ | |
| 267 | + public function render_gateway_notice($field, $settings) | |
| 268 | + { | |
| 269 | + if (! $this->hasPremiumPaymentGateway() && ! $this->canAcceptCreditCard()) { | |
| 270 | + ?> | |
| 271 | + <div class="give-gateways-notice"> | |
| 272 | + <div class="give-gateways-cc-icon"> | |
| 273 | + <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="35" | |
| 274 | + height="29" viewBox="0 0 35 29"> | |
| 275 | + <defs> | |
| 276 | + <path id="credit-card-a" | |
| 277 | + d="M32.0772569,3.88888889 L2.92274306,3.88888889 C1.30642361,3.88888889 0,5.1953125 0,6.80555556 L0,28.1944444 C0,29.8046875 1.30642361,31.1111111 2.92274306,31.1111111 L32.0772569,31.1111111 C33.6935764,31.1111111 35,29.8046875 35,28.1944444 L35,6.80555556 C35,5.1953125 33.6935764,3.88888889 32.0772569,3.88888889 Z M3.28732639,6.80555556 L31.7126736,6.80555556 C31.9131944,6.80555556 32.0772569,6.96961806 32.0772569,7.17013889 L32.0772569,9.72222222 L2.92274306,9.72222222 L2.92274306,7.17013889 C2.92274306,6.96961806 3.08680556,6.80555556 3.28732639,6.80555556 Z M31.7126736,28.1944444 L3.28732639,28.1944444 C3.08680556,28.1944444 2.92274306,28.0303819 2.92274306,27.8298611 L2.92274306,17.5 L32.0772569,17.5 L32.0772569,27.8298611 C32.0772569,28.0303819 31.9131944,28.1944444 31.7126736,28.1944444 Z M11.6666667,22.1180556 L11.6666667,24.5486111 C11.6666667,24.9496528 11.3385417,25.2777778 10.9375,25.2777778 L6.5625,25.2777778 C6.16145833,25.2777778 5.83333333,24.9496528 5.83333333,24.5486111 L5.83333333,22.1180556 C5.83333333,21.7170139 6.16145833,21.3888889 6.5625,21.3888889 L10.9375,21.3888889 C11.3385417,21.3888889 11.6666667,21.7170139 11.6666667,22.1180556 Z M23.3333333,22.1180556 L23.3333333,24.5486111 C23.3333333,24.9496528 23.0052083,25.2777778 22.6041667,25.2777778 L14.3402778,25.2777778 C13.9392361,25.2777778 13.6111111,24.9496528 13.6111111,24.5486111 L13.6111111,22.1180556 C13.6111111,21.7170139 13.9392361,21.3888889 14.3402778,21.3888889 L22.6041667,21.3888889 C23.0052083,21.3888889 23.3333333,21.7170139 23.3333333,22.1180556 Z" /> | |
| 278 | + </defs> | |
| 279 | + <g fill="none" fill-rule="evenodd" opacity=".341" transform="translate(0 -3)"> | |
| 280 | + <mask id="credit-card-b" fill="#fff"> | |
| 281 | + <use xlink:href="#credit-card-a" /> | |
| 282 | + </mask> | |
| 283 | + <g fill="#242A42" mask="url(#credit-card-b)"> | |
| 284 | + <rect width="35" height="35" /> | |
| 285 | + </g> | |
| 286 | + </g> | |
| 287 | + </svg> | |
| 288 | + </div> | |
| 290 | 289 | |
| 291 | - <div class="give-gateways-notice"> | |
| 290 | + <p class="give-gateways-notice-title"> | |
| 291 | + <strong> | |
| 292 | + <?php esc_html_e( | |
| 293 | + 'Want to accept credit card donations directly on your website?', | |
| 294 | + 'give' | |
| 295 | + ); ?> | |
| 296 | + </strong> | |
| 297 | + </p> | |
| 292 | 298 | |
| 293 | - <div class="give-gateways-cc-icon"> | |
| 294 | - <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="35" | |
| 295 | - height="29" viewBox="0 0 35 29"> | |
| 296 | - <defs> | |
| 297 | - <path id="credit-card-a" | |
| 298 | - d="M32.0772569,3.88888889 L2.92274306,3.88888889 C1.30642361,3.88888889 0,5.1953125 0,6.80555556 L0,28.1944444 C0,29.8046875 1.30642361,31.1111111 2.92274306,31.1111111 L32.0772569,31.1111111 C33.6935764,31.1111111 35,29.8046875 35,28.1944444 L35,6.80555556 C35,5.1953125 33.6935764,3.88888889 32.0772569,3.88888889 Z M3.28732639,6.80555556 L31.7126736,6.80555556 C31.9131944,6.80555556 32.0772569,6.96961806 32.0772569,7.17013889 L32.0772569,9.72222222 L2.92274306,9.72222222 L2.92274306,7.17013889 C2.92274306,6.96961806 3.08680556,6.80555556 3.28732639,6.80555556 Z M31.7126736,28.1944444 L3.28732639,28.1944444 C3.08680556,28.1944444 2.92274306,28.0303819 2.92274306,27.8298611 L2.92274306,17.5 L32.0772569,17.5 L32.0772569,27.8298611 C32.0772569,28.0303819 31.9131944,28.1944444 31.7126736,28.1944444 Z M11.6666667,22.1180556 L11.6666667,24.5486111 C11.6666667,24.9496528 11.3385417,25.2777778 10.9375,25.2777778 L6.5625,25.2777778 C6.16145833,25.2777778 5.83333333,24.9496528 5.83333333,24.5486111 L5.83333333,22.1180556 C5.83333333,21.7170139 6.16145833,21.3888889 6.5625,21.3888889 L10.9375,21.3888889 C11.3385417,21.3888889 11.6666667,21.7170139 11.6666667,22.1180556 Z M23.3333333,22.1180556 L23.3333333,24.5486111 C23.3333333,24.9496528 23.0052083,25.2777778 22.6041667,25.2777778 L14.3402778,25.2777778 C13.9392361,25.2777778 13.6111111,24.9496528 13.6111111,24.5486111 L13.6111111,22.1180556 C13.6111111,21.7170139 13.9392361,21.3888889 14.3402778,21.3888889 L22.6041667,21.3888889 C23.0052083,21.3888889 23.3333333,21.7170139 23.3333333,22.1180556 Z"/> | |
| 299 | - </defs> | |
| 300 | - <g fill="none" fill-rule="evenodd" opacity=".341" transform="translate(0 -3)"> | |
| 301 | - <mask id="credit-card-b" fill="#fff"> | |
| 302 | - <use xlink:href="#credit-card-a"/> | |
| 303 | - </mask> | |
| 304 | - <g fill="#242A42" mask="url(#credit-card-b)"> | |
| 305 | - <rect width="35" height="35"/> | |
| 306 | - </g> | |
| 307 | - </g> | |
| 308 | - </svg> | |
| 309 | - </div> | |
| 299 | + <p class="give-gateways-notice-message"> | |
| 300 | + <?php | |
| 301 | + printf( | |
| 302 | + __( | |
| 303 | + 'Activate the free Stripe payment gateway %1$s, <a href="%2$s" target="_blank">PayPal Donations</a>, or a premium gateway like <a href="%3$s" target="_blank">2checkout</a>, or <a href="%4$s" target="_blank">Authorize.Net</a>.', | |
| 304 | + 'give' | |
| 305 | + ), | |
| 306 | + Give()->tooltips->render_help( | |
| 307 | + __( | |
| 308 | + 'The Stripe payment gateway includes a 2% processing fee in addition to Stripe’s transaction fee. This ensures our ability to provide future support and updates for the plugin.', | |
| 309 | + 'give' | |
| 310 | + ) | |
| 311 | + ), | |
| 312 | + admin_url('edit.php?post_type=give_forms&page=give-settings&tab=gateways§ion=paypal'), | |
| 313 | + 'https://givewp.com/addons/2checkout/?utm_source=WP%20Admin%20%3E%20Donations%20%3E%20Settings%20%3E%20Gateways&utm_medium=banner', | |
| 314 | + 'https://givewp.com/addons/authorize-net-gateway/?utm_source=WP%20Admin%20%3E%20Donations%20%3E%20Settings%20%3E%20Gateways&utm_medium=banner' | |
| 315 | + ); | |
| 316 | + ?> | |
| 317 | + </p> | |
| 310 | 318 | |
| 311 | - <p class="give-gateways-notice-message"><?php printf( __( 'Activate a premium gateway like <a href="%1$s" target="_blank">Stripe</a>, <a href="%2$s" target="_blank">PayPal Pro</a>, or <a href="%3$s" target="_blank">Authorize.net</a> and allow your donors to give using their credit cards. ', 'give' ), 'https://givewp.com/addons/stripe-gateway/?utm_source=WP%20Admin%20%3E%20Donations%20%3E%20Settings%20%3E%20Gateways&utm_medium=banner', 'https://givewp.com/addons/paypal-pro-gateway/?utm_source=WP%20Admin%20%3E%20Donations%20%3E%20Settings%20%3E%20Gateways&utm_medium=banner', 'https://givewp.com/addons/authorize-net-gateway/?utm_source=WP%20Admin%20%3E%20Donations%20%3E%20Settings%20%3E%20Gateways&utm_medium=banner' ); ?></p> | |
| 319 | + <div class="give-gateways-notice-button"> | |
| 320 | + <?php echo give(AccountManagerSettingField::class)->getStripeConnectButtonMarkup(); ?> | |
| 321 | + <a href="https://givewp.com/addons/category/payment-gateways/?utm_source=WP%20Admin%20%3E%20Donations%20%3E%20Settings%20%3E%20Gateways&utm_medium=banner" | |
| 322 | + target="_blank" class="give-view-gateways-btn button"> | |
| 323 | + <?php esc_html_e('View Premium Gateways', 'give'); ?> | |
| 324 | + </a> | |
| 325 | + </div> | |
| 326 | + </div> | |
| 327 | + <?php | |
| 328 | + } | |
| 329 | + } | |
| 312 | 330 | |
| 313 | - <div class="give-gateways-notice-button"> | |
| 314 | - <a href="https://givewp.com/addons/category/payment-gateways/?utm_source=WP%20Admin%20%3E%20Donations%20%3E%20Settings%20%3E%20Gateways&utm_medium=banner" | |
| 315 | - target="_blank" class="button"><?php esc_html_e( 'View Gateways', 'give' ); ?></a> | |
| 316 | - </div> | |
| 331 | + /** | |
| 332 | + * Render enabled gateways | |
| 333 | + * | |
| 334 | + * @since 3.15.0 Set the v3 settings tab as default in the gateways list | |
| 335 | + * @since 3.0.0 split gateways into separated tabs for v2 and v3 settings | |
| 336 | + * @since 2.0.5 | |
| 337 | + * @access public | |
| 338 | + * | |
| 339 | + * @param $field | |
| 340 | + * @param $settings | |
| 341 | + */ | |
| 342 | + public function render_enabled_gateways($field, $settings) | |
| 343 | + { | |
| 344 | + $id = $field['id']; | |
| 345 | + $gateways = give_get_payment_gateways(); | |
| 317 | 346 | |
| 318 | - </div> | |
| 347 | + $current_page = give_get_current_setting_page(); | |
| 348 | + $current_tab = give_get_current_setting_tab(); | |
| 349 | + $current_section = give_get_current_setting_section(); | |
| 319 | 350 | |
| 320 | - <?php endif; | |
| 351 | + // Legacy gateways are gateways that are not registered with updated gateway registration API. | |
| 352 | + // For example: Razorpay, Paytm, Mollie etc. | |
| 353 | + // These payment gateways support donation processing only with v2 donation forms. | |
| 354 | + $legacyGateways = array_filter( | |
| 355 | + $gateways, | |
| 356 | + static function ($value, $key) { | |
| 357 | + return ! give()->gateways->hasPaymentGateway($key); | |
| 358 | + }, | |
| 359 | + ARRAY_FILTER_USE_BOTH | |
| 360 | + ); | |
| 321 | 361 | |
| 322 | - } | |
| 362 | + // v2 gateways are gateways that are registered with updated gateway registration API. | |
| 363 | + // These payment gateways support donation processing with v2 donation forms. | |
| 364 | + // Legacy payment gateways will display with v2 gateways. | |
| 365 | + $v2Gateways = give_get_ordered_payment_gateways( | |
| 366 | + array_merge( | |
| 367 | + $legacyGateways, | |
| 368 | + array_intersect_key( | |
| 369 | + $gateways, | |
| 370 | + give()->gateways->getPaymentGateways(2) | |
| 371 | + ) | |
| 372 | + ), | |
| 373 | + 2 | |
| 374 | + ); | |
| 323 | 375 | |
| 324 | - /** | |
| 325 | - * Render enabled gateways | |
| 326 | - * | |
| 327 | - * @since 2.0.5 | |
| 328 | - * @access public | |
| 329 | - * | |
| 330 | - * @param $field | |
| 331 | - * @param $settings | |
| 332 | - */ | |
| 333 | - public function render_enabled_gateways( $field, $settings ) { | |
| 334 | - $id = $field['id']; | |
| 335 | - $gateways = give_get_ordered_payment_gateways( give_get_payment_gateways() ); | |
| 336 | - $gateways_label = give_get_option( 'gateways_label', array() ); | |
| 337 | - $default_gateway = give_get_option( 'default_gateway', current( array_keys( $gateways ) ) ); | |
| 376 | + // v3 gateways are gateways that are registered with updated gateway registration API. | |
| 377 | + // These payment gateways support donation processing with v3 donation forms. | |
| 378 | + $v3Gateways = give_get_ordered_payment_gateways( | |
| 379 | + array_intersect_key($gateways, give()->gateways->getPaymentGateways(3)), | |
| 380 | + 3 | |
| 381 | + ); | |
| 338 | 382 | |
| 339 | - ob_start(); | |
| 383 | + $groups = [ | |
| 384 | + 'v3' => [ | |
| 385 | + 'label' => __('Visual Form Builder', 'give'), | |
| 386 | + 'gateways' => $v3Gateways, | |
| 387 | + 'settings' => give_get_option('gateways_v3', []), | |
| 388 | + 'gatewaysLabel' => give_get_option('gateways_label_v3', []), | |
| 389 | + 'defaultGateway' => give_get_option('default_gateway_v3', current(array_keys($v3Gateways))), | |
| 390 | + 'helper' => [ | |
| 391 | + 'text' => __( | |
| 392 | + 'Uses the blocks-based visual form builder for creating and customizing a donation form.', | |
| 393 | + 'give' | |
| 394 | + ), | |
| 395 | + 'image' => GIVE_PLUGIN_URL . 'build/assets/dist/images/admin/give-settings-gateways-v3.jpg', | |
| 396 | + ] | |
| 397 | + ], | |
| 398 | + 'v2' => [ | |
| 399 | + 'label' => __('Option-Based Form Editor', 'give'), | |
| 400 | + 'gateways' => $v2Gateways, | |
| 401 | + 'settings' => $settings, | |
| 402 | + 'gatewaysLabel' => give_get_option('gateways_label', []), | |
| 403 | + 'defaultGateway' => give_get_option('default_gateway', current(array_keys($v2Gateways))), | |
| 404 | + 'helper' => [ | |
| 405 | + 'text' => __( | |
| 406 | + 'Uses the traditional settings options for creating and customizing a donation form.', | |
| 407 | + 'give' | |
| 408 | + ), | |
| 409 | + 'image' => GIVE_PLUGIN_URL . 'build/assets/dist/images/admin/give-settings-gateways-v2.jpg', | |
| 410 | + ], | |
| 411 | + ], | |
| 412 | + ]; | |
| 340 | 413 | |
| 341 | - echo '<div class="gateway-enabled-wrap">'; | |
| 414 | + /** | |
| 415 | + * @since 3.18.0 | |
| 416 | + */ | |
| 417 | + $groups = apply_filters('give_settings_payment_gateways_menu_groups', $groups); | |
| 342 | 418 | |
| 343 | - echo '<div class="gateway-enabled-settings-title">'; | |
| 344 | - printf( | |
| 345 | - ' | |
| 346 | - <span></span> | |
| 347 | - <span>%1$s</span> | |
| 348 | - <span>%2$s</span> | |
| 349 | - <span>%3$s</span> | |
| 350 | - <span>%4$s</span> | |
| 351 | - ', | |
| 352 | - __( 'Gateway', 'give' ), | |
| 353 | - __( 'Label', 'give' ), | |
| 354 | - __( 'Default', 'give' ), | |
| 355 | - __( 'Enabled', 'give' ) | |
| 356 | - ); | |
| 357 | - echo '</div>'; | |
| 419 | + $defaultGroup = current(array_keys($groups)); | |
| 358 | 420 | |
| 359 | - echo '<ul class="give-checklist-fields give-payment-gatways-list">'; | |
| 360 | - foreach ( $gateways as $key => $option ) : | |
| 361 | - $enabled = null; | |
| 362 | - if ( is_array( $settings ) && array_key_exists( $key, $settings ) ) { | |
| 363 | - $enabled = '1'; | |
| 364 | - } | |
| 421 | + ob_start(); | |
| 365 | 422 | |
| 366 | - echo '<li>'; | |
| 367 | - printf( '<span class="give-drag-handle"><span class="dashicons dashicons-menu"></span></span>' ); | |
| 368 | - printf( '<span class="admin-label">%s</span>', esc_html( $option['admin_label'] ) ); | |
| 423 | + echo '<h4>' . __('Enabled Gateways', 'give') . '</h4>'; | |
| 424 | + echo '<div class="give-settings-section-content give-payment-gateways-settings">'; | |
| 369 | 425 | |
| 370 | - $label = ''; | |
| 371 | - if ( ! empty( $gateways_label[ $key ] ) ) { | |
| 372 | - $label = $gateways_label[ $key ]; | |
| 373 | - } | |
| 426 | + if (count($groups) > 1) { | |
| 427 | + echo '<div class="give-settings-section-group-menu">'; | |
| 428 | + echo '<ul>'; | |
| 429 | + foreach ($groups as $slug => $group) { | |
| 430 | + $current_group = ! empty($_GET['group']) ? give_clean($_GET['group']) : $defaultGroup; | |
| 431 | + $active_class = ($slug === $current_group) ? 'active' : ''; | |
| 374 | 432 | |
| 375 | - printf( | |
| 376 | - '<input class="checkout-label" type="text" id="%1$s[%2$s]" name="%1$s[%2$s]" value="%3$s" placeholder="%4$s"/>', | |
| 377 | - 'gateways_label', | |
| 378 | - esc_attr( $key ), | |
| 379 | - esc_html( $label ), | |
| 380 | - esc_html( $option['checkout_label'] ) | |
| 381 | - ); | |
| 433 | + if ($group['helper']) { | |
| 434 | + $helper = sprintf( | |
| 435 | + '<div class="give-settings-section-group-helper"> | |
| 436 | + <img src="%1$s" /> | |
| 437 | + <div class="give-settings-section-group-helper__popout"> | |
| 438 | + <img src="%2$s" /> | |
| 439 | + <h5>%3$s</h5> | |
| 440 | + <p>%4$s</p> | |
| 441 | + </div> | |
| 442 | + </div>', | |
| 443 | + esc_url(GIVE_PLUGIN_URL . 'build/assets/dist/images/admin/help-circle.svg'), | |
| 444 | + esc_url($group['helper']['image']), | |
| 445 | + esc_html($group['label']), | |
| 446 | + esc_html($group['helper']['text']) | |
| 447 | + ); | |
| 448 | + } | |
| 382 | 449 | |
| 383 | - printf( | |
| 384 | - '<input class="gateways-radio" type="radio" name="%1$s" value="%2$s" %3$s %4$s>', | |
| 385 | - 'default_gateway', | |
| 386 | - $key, | |
| 387 | - checked( $key, $default_gateway, false ), | |
| 388 | - disabled( null, $enabled, false ) | |
| 389 | - ); | |
| 450 | + echo sprintf( | |
| 451 | + '<li><a class="%1$s" href="%2$s" data-group="%3$s">%4$s %5$s</a></li>', | |
| 452 | + esc_html($active_class), | |
| 453 | + esc_url( | |
| 454 | + admin_url( | |
| 455 | + "edit.php?post_type=give_forms&page={$current_page}&tab={$current_tab}§ion={$current_section}&group={$slug}" | |
| 456 | + ) | |
| 457 | + ), | |
| 458 | + esc_html($slug), | |
| 459 | + esc_html($group['label']), | |
| 460 | + $helper ?? '' | |
| 461 | + ); | |
| 462 | + } | |
| 463 | + echo '</ul>'; | |
| 464 | + echo '</div>'; | |
| 465 | + } | |
| 390 | 466 | |
| 391 | - printf( | |
| 392 | - '<input class="gateways-checkbox" name="%1$s[%2$s]" id="%1$s[%2$s]" type="checkbox" value="1" %3$s data-payment-gateway="%4$s"/>', | |
| 393 | - esc_attr( $id ), | |
| 394 | - esc_attr( $key ), | |
| 395 | - checked( '1', $enabled, false ), | |
| 396 | - esc_html( $option['admin_label'] ) | |
| 397 | - ); | |
| 398 | - echo '</li>'; | |
| 399 | - endforeach; | |
| 400 | - echo '</ul>'; | |
| 467 | + echo '<div class="give-settings-section-group-content">'; | |
| 468 | + foreach ($groups as $slug => $group) : | |
| 469 | + $current_group = !empty($_GET['group']) ? give_clean($_GET['group']) : $defaultGroup; | |
| 470 | + $hide_class = $slug !== $current_group ? 'give-hidden' : ''; | |
| 471 | + $suffix = $slug === 'v3' ? '_v3' : ''; | |
| 401 | 472 | |
| 402 | - echo '</div>'; // end gateway-enabled-wrap. | |
| 473 | + printf( | |
| 474 | + '<div id="give-settings-section-group-%1$s" class="give-settings-section-group %2$s">', | |
| 475 | + esc_attr($slug), | |
| 476 | + esc_html($hide_class) | |
| 477 | + ); | |
| 403 | 478 | |
| 404 | - printf( | |
| 405 | - '<tr><th>%1$s</th><td>%2$s</td></tr>', | |
| 406 | - $field['title'], | |
| 407 | - ob_get_clean() | |
| 408 | - ); | |
| 409 | - } | |
| 410 | - } | |
| 479 | + echo '<div class="gateway-enabled-wrap">'; | |
| 480 | + echo '<div class="gateway-enabled-settings-title">'; | |
| 481 | + printf( | |
| 482 | + ' | |
| 483 | + <span></span> | |
| 484 | + <span>%1$s</span> | |
| 485 | + <span>%2$s</span> | |
| 486 | + <span style="text-align: center;">%3$s</span> | |
| 487 | + <span style="text-align: center;">%4$s</span> | |
| 488 | + ', | |
| 489 | + __('Gateway', 'give'), | |
| 490 | + __('Label', 'give'), | |
| 491 | + __('Default', 'give'), | |
| 492 | + __('Enabled', 'give') | |
| 493 | + ); | |
| 494 | + echo '</div>'; | |
| 495 | + | |
| 496 | + echo '<ul class="give-checklist-fields give-payment-gatways-list">'; | |
| 497 | + foreach ($group['gateways'] as $key => $option) : | |
| 498 | + $enabled = null; | |
| 499 | + if (is_array($group['settings']) && array_key_exists($key, $group['settings'])) { | |
| 500 | + $enabled = '1'; | |
| 501 | + } | |
| 502 | + | |
| 503 | + echo '<li>'; | |
| 504 | + printf('<span class="give-drag-handle"><span class="dashicons dashicons-menu"></span></span>'); | |
| 505 | + printf( | |
| 506 | + '<span class="admin-label">%1$s %2$s</span>', | |
| 507 | + esc_html($option['admin_label']), | |
| 508 | + !empty($option['admin_tooltip']) ? Give()->tooltips->render_help( | |
| 509 | + esc_attr($option['admin_tooltip']) | |
| 510 | + ) : '' | |
| 511 | + ); | |
| 512 | + | |
| 513 | + $label = ''; | |
| 514 | + if (!empty($group['gatewaysLabel'][$key])) { | |
| 515 | + $label = $group['gatewaysLabel'][$key]; | |
| 516 | + } | |
| 517 | + | |
| 518 | + printf( | |
| 519 | + '<input class="checkout-label" type="text" id="%1$s[%2$s]" name="%1$s[%2$s]" value="%3$s" placeholder="%4$s"/>', | |
| 520 | + 'gateways_label' . $suffix, | |
| 521 | + esc_attr($key), | |
| 522 | + esc_html($label), | |
| 523 | + esc_html($option['checkout_label']) | |
| 524 | + ); | |
| 525 | + | |
| 526 | + printf( | |
| 527 | + '<input class="gateways-radio" type="radio" name="%1$s" value="%2$s" %3$s %4$s>', | |
| 528 | + 'default_gateway' . $suffix, | |
| 529 | + $key, | |
| 530 | + checked($key, $group['defaultGateway'], false), | |
| 531 | + disabled(null, $enabled, false) | |
| 532 | + ); | |
| 533 | + | |
| 534 | + printf( | |
| 535 | + '<input class="gateways-checkbox" name="%1$s[%2$s]" id="%1$s[%2$s]" type="checkbox" value="1" %3$s data-payment-gateway="%4$s"/>', | |
| 536 | + esc_attr($id) . $suffix, | |
| 537 | + esc_attr($key), | |
| 538 | + checked('1', $enabled, false), | |
| 539 | + esc_html($option['admin_label']) | |
| 540 | + ); | |
| 541 | + echo '</li>'; | |
| 542 | + endforeach; | |
| 543 | + echo '</ul>'; | |
| 544 | + | |
| 545 | + echo '</div>'; // end gateway-enabled-wrap. | |
| 546 | + echo '</div>'; // end give-settings-section-group-content. | |
| 547 | + endforeach; | |
| 548 | + | |
| 549 | + echo '</div>'; // end give-settings-section-content. | |
| 550 | + | |
| 551 | + printf('<tr><td colspan="2" style="padding: 0">%s</td></tr>', ob_get_clean()); | |
| 552 | + } | |
| 553 | + } | |
| 411 | 554 | |
| 412 | 555 | endif; |
| 413 | 556 | |
| 414 | 557 | return new Give_Settings_Gateways(); |