← All changes
|
includes/admin/settings/class-charitable-gateway-settings.php
+34
-23
1.6.60
→
1.8.13
View file →
| @@ -2,10 +2,10 @@ | ||
| 2 | 2 | /** |
| 3 | 3 | * Charitable Gateway Settings UI. |
| 4 | 4 | * |
| 5 | 5 | * @package Charitable/Classes/Charitable_Gateway_Settings |
| 6 | - * @author Eric Daams | |
| 7 | - * @copyright Copyright (c) 2022, Studio 164a | |
| 6 | + * @author David Bisset | |
| 7 | + * @copyright Copyright (c) 2023, WP Charitable LLC | |
| 8 | 8 | * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 9 | 9 | * @since 1.0.0 |
| 10 | 10 | * @version 1.0.0 |
| 11 | 11 | */ |
| @@ -67,30 +67,37 @@ | ||
| 67 | 67 | return array(); |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | return array( |
| 71 | - 'section' => array( | |
| 72 | - 'title' => '', | |
| 73 | - 'type' => 'hidden', | |
| 74 | - 'priority' => 10000, | |
| 75 | - 'value' => 'gateways', | |
| 76 | - 'save' => false, | |
| 71 | + 'section' => array( | |
| 72 | + 'title' => '', | |
| 73 | + 'type' => 'hidden', | |
| 74 | + 'priority' => 10000, | |
| 75 | + 'value' => 'gateways', | |
| 76 | + 'save' => false, | |
| 77 | 77 | ), |
| 78 | 78 | 'section_gateways' => array( |
| 79 | - 'title' => __( 'Available Payment Gateways', 'charitable' ), | |
| 80 | - 'type' => 'heading', | |
| 81 | - 'priority' => 5, | |
| 79 | + 'title' => __( 'Payment Gateways', 'charitable' ), | |
| 80 | + 'type' => 'heading', | |
| 81 | + 'priority' => 5, | |
| 82 | 82 | ), |
| 83 | - 'gateways' => array( | |
| 84 | - 'title' => false, | |
| 85 | - 'callback' => array( $this, 'render_gateways_table' ), | |
| 86 | - 'priority' => 10, | |
| 83 | + 'gateways' => array( | |
| 84 | + 'title' => false, | |
| 85 | + 'callback' => array( $this, 'render_gateways_table' ), | |
| 86 | + 'priority' => 10, | |
| 87 | 87 | ), |
| 88 | - 'test_mode' => array( | |
| 89 | - 'title' => __( 'Turn on Test Mode', 'charitable' ), | |
| 90 | - 'type' => 'checkbox', | |
| 91 | - 'priority' => 15, | |
| 88 | + 'test_mode' => array( | |
| 89 | + 'title' => __( 'Turn on Test Mode', 'charitable' ), | |
| 90 | + 'type' => 'checkbox', | |
| 91 | + 'help' => __( 'When test mode is on, donations are routed to each gateway\'s sandbox/test credentials instead of live, no real charges are made, and the donation form displays a "Test Mode" banner. Use this to verify your setup end-to-end before accepting real donations. Turn off when you\'re ready to go live.', 'charitable' ), | |
| 92 | + 'priority' => 15, | |
| 93 | + 'class' => 'charitable-test-mode-checkbox', | |
| 92 | 94 | ), |
| 95 | + 'additional_gateways' => array( | |
| 96 | + 'type' => 'content', | |
| 97 | + 'content' => '<p class="charitable-gateways-additional-link"><a href="https://www.wpcharitable.com/multiple-payment-gateways/" target="_blank" rel="noopener noreferrer">' . esc_html__( 'View Additional Payment Gateways', 'charitable' ) . '</a></p>', | |
| 98 | + 'priority' => 20, | |
| 99 | + ), | |
| 93 | 100 | ); |
| 94 | 101 | } |
| 95 | 102 | |
| 96 | 103 | /** |
| @@ -97,18 +104,21 @@ | ||
| 97 | 104 | * Add settings for each individual payment gateway. |
| 98 | 105 | * |
| 99 | 106 | * @since 1.0.0 |
| 100 | 107 | * |
| 101 | - * @return array[] | |
| 108 | + * @param array $fields The existing fields. | |
| 109 | + * @return array | |
| 102 | 110 | */ |
| 103 | 111 | public function add_individual_gateway_fields( $fields ) { |
| 112 | + | |
| 104 | 113 | foreach ( charitable_get_helper( 'gateways' )->get_active_gateways() as $gateway ) { |
| 105 | 114 | if ( ! class_exists( $gateway ) ) { |
| 106 | 115 | continue; |
| 107 | 116 | } |
| 117 | + $gateway = new $gateway(); | |
| 108 | 118 | |
| 109 | - $gateway = new $gateway; | |
| 110 | 119 | $fields[ 'gateways_' . $gateway->get_gateway_id() ] = apply_filters( 'charitable_settings_fields_gateways_gateway', array(), $gateway ); |
| 120 | + | |
| 111 | 121 | } |
| 112 | 122 | |
| 113 | 123 | return $fields; |
| 114 | 124 | } |
| @@ -117,9 +127,9 @@ | ||
| 117 | 127 | * Add gateway keys to the settings groups. |
| 118 | 128 | * |
| 119 | 129 | * @since 1.0.0 |
| 120 | 130 | * |
| 121 | - * @param string[] $groups | |
| 131 | + * @param string[] $groups The existing groups. | |
| 122 | 132 | * @return string[] |
| 123 | 133 | */ |
| 124 | 134 | public function add_gateway_settings_dynamic_groups( $groups ) { |
| 125 | 135 | foreach ( charitable_get_helper( 'gateways' )->get_active_gateways() as $gateway_key => $gateway ) { |
| @@ -126,9 +136,9 @@ | ||
| 126 | 136 | if ( ! class_exists( $gateway ) ) { |
| 127 | 137 | continue; |
| 128 | 138 | } |
| 129 | 139 | |
| 130 | - $groups[ 'gateways_' . $gateway_key ] = apply_filters( 'charitable_gateway_settings_fields_gateways_gateway', array(), new $gateway ); | |
| 140 | + $groups[ 'gateways_' . $gateway_key ] = apply_filters( 'charitable_gateway_settings_fields_gateways_gateway', array(), new $gateway() ); | |
| 131 | 141 | } |
| 132 | 142 | |
| 133 | 143 | return $groups; |
| 134 | 144 | } |
| @@ -137,8 +147,9 @@ | ||
| 137 | 147 | * Display table with available payment gateways. |
| 138 | 148 | * |
| 139 | 149 | * @since 1.0.0 |
| 140 | 150 | * |
| 151 | + * @param array $args The arguments. | |
| 141 | 152 | * @return void |
| 142 | 153 | */ |
| 143 | 154 | public function render_gateways_table( $args ) { |
| 144 | 155 | charitable_admin_view( 'settings/gateways', $args ); |