PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.6.22
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.6.22
1.8.12.3 1.8.12.2 1.8.12.1 1.8.12 1.8.11.3 1.8.11.2 1.8.11.1 1.8.11 1.6.6 1.6.60 1.6.7 1.6.8 1.6.9 1.7.0 1.7.0.1 1.7.0.11 1.7.0.12 1.7.0.14 1.7.0.2 1.7.0.3 1.7.0.5 1.7.0.6 1.7.0.7 1.7.0.9 1.8.0 All 210 releases
charitable / includes / admin / settings / class-charitable-gateway-settings.php

class-charitable-gateway-settings.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.6.22, at includes/admin/settings/class-charitable-gateway-settings.php

149 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Charitable Gateway Settings UI.
4 *
5 * @package Charitable/Classes/Charitable_Gateway_Settings
6 * @author Eric Daams
7 * @copyright Copyright (c) 2019, Studio 164a
8 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9 * @since 1.0.0
10 * @version 1.0.0
11 */
12
13 // Exit if accessed directly.
14 if ( ! defined( 'ABSPATH' ) ) {
15 exit;
16 }
17
18 if ( ! class_exists( 'Charitable_Gateway_Settings' ) ) :
19
20 /**
21 * Charitable_Gateway_Settings
22 *
23 * @final
24 * @since 1.0.0
25 */
26 final class Charitable_Gateway_Settings {
27
28 /**
29 * The single instance of this class.
30 *
31 * @var Charitable_Gateway_Settings|null
32 */
33 private static $instance = null;
34
35 /**
36 * Create object instance.
37 *
38 * @since 1.0.0
39 */
40 private function __construct() {
41 }
42
43 /**
44 * Returns and/or create the single instance of this class.
45 *
46 * @since 1.2.0
47 *
48 * @return Charitable_Gateway_Settings
49 */
50 public static function get_instance() {
51 if ( is_null( self::$instance ) ) {
52 self::$instance = new self();
53 }
54
55 return self::$instance;
56 }
57
58 /**
59 * Returns all the payment gateway settings fields.
60 *
61 * @since 1.0.0
62 *
63 * @return array
64 */
65 public function add_gateway_fields() {
66 if ( ! charitable_is_settings_view( 'gateways' ) ) {
67 return array();
68 }
69
70 return array(
71 'section' => array(
72 'title' => '',
73 'type' => 'hidden',
74 'priority' => 10000,
75 'value' => 'gateways',
76 'save' => false,
77 ),
78 'section_gateways' => array(
79 'title' => __( 'Available Payment Gateways', 'charitable' ),
80 'type' => 'heading',
81 'priority' => 5,
82 ),
83 'gateways' => array(
84 'title' => false,
85 'callback' => array( $this, 'render_gateways_table' ),
86 'priority' => 10,
87 ),
88 'test_mode' => array(
89 'title' => __( 'Turn on Test Mode', 'charitable' ),
90 'type' => 'checkbox',
91 'priority' => 15,
92 ),
93 );
94 }
95
96 /**
97 * Add settings for each individual payment gateway.
98 *
99 * @since 1.0.0
100 *
101 * @return array[]
102 */
103 public function add_individual_gateway_fields( $fields ) {
104 foreach ( charitable_get_helper( 'gateways' )->get_active_gateways() as $gateway ) {
105 if ( ! class_exists( $gateway ) ) {
106 continue;
107 }
108
109 $gateway = new $gateway;
110 $fields[ 'gateways_' . $gateway->get_gateway_id() ] = apply_filters( 'charitable_settings_fields_gateways_gateway', array(), $gateway );
111 }
112
113 return $fields;
114 }
115
116 /**
117 * Add gateway keys to the settings groups.
118 *
119 * @since 1.0.0
120 *
121 * @param string[] $groups
122 * @return string[]
123 */
124 public function add_gateway_settings_dynamic_groups( $groups ) {
125 foreach ( charitable_get_helper( 'gateways' )->get_active_gateways() as $gateway_key => $gateway ) {
126 if ( ! class_exists( $gateway ) ) {
127 continue;
128 }
129
130 $groups[ 'gateways_' . $gateway_key ] = apply_filters( 'charitable_gateway_settings_fields_gateways_gateway', array(), new $gateway );
131 }
132
133 return $groups;
134 }
135
136 /**
137 * Display table with available payment gateways.
138 *
139 * @since 1.0.0
140 *
141 * @return void
142 */
143 public function render_gateways_table( $args ) {
144 charitable_admin_view( 'settings/gateways', $args );
145 }
146 }
147
148 endif;
149