| 1 |
<?php |
| 2 |
/** |
| 3 |
* Display the table of payment gateways. |
| 4 |
* |
| 5 |
* @author Studio 164a |
| 6 |
* @package Charitable/Admin View/Settings |
| 7 |
* @since 1.0.0 |
| 8 |
*/ |
| 9 |
|
| 10 |
$helper = charitable_get_helper( 'gateways' ); |
| 11 |
$gateways = $helper->get_available_gateways(); |
| 12 |
$default = $helper->get_default_gateway(); |
| 13 |
|
| 14 |
if ( count( $gateways ) ) : |
| 15 |
|
| 16 |
foreach ( $gateways as $gateway ) : |
| 17 |
|
| 18 |
$gateway = new $gateway; |
| 19 |
$is_active = $helper->is_active_gateway( $gateway->get_gateway_id() ); |
| 20 |
$action_url = esc_url( add_query_arg( array( |
| 21 |
'charitable_action' => $is_active ? 'disable_gateway' : 'enable_gateway', |
| 22 |
'gateway_id' => $gateway->get_gateway_id(), |
| 23 |
'_nonce' => wp_create_nonce( 'gateway' ) |
| 24 |
), admin_url( 'admin.php?page=charitable-settings&tab=gateways' ) ) ); |
| 25 |
|
| 26 |
$make_default_url = esc_url( add_query_arg( array( |
| 27 |
'charitable_action' => 'make_default_gateway', |
| 28 |
'gateway_id' => $gateway->get_gateway_id(), |
| 29 |
'_nonce' => wp_create_nonce( 'gateway' ) |
| 30 |
), admin_url( 'admin.php?page=charitable-settings&tab=gateways' ) ) ); |
| 31 |
|
| 32 |
?> |
| 33 |
<div class="charitable-settings-object charitable-gateway cf"> |
| 34 |
<h4><?php echo $gateway->get_name() ?></h4> |
| 35 |
<?php if ( $gateway->get_gateway_id() == $default ) : ?> |
| 36 |
|
| 37 |
<span class="default-gateway"><?php _e( 'Default gateway', 'charitable' ) ?></span> |
| 38 |
|
| 39 |
<?php elseif ( $is_active ) : ?> |
| 40 |
|
| 41 |
<a href="<?php echo $make_default_url ?>" class="make-default-gateway"><?php _e( 'Make default gateway', 'charitable' ) ?></a> |
| 42 |
|
| 43 |
<?php endif ?> |
| 44 |
<span class="actions"> |
| 45 |
<?php if ( $is_active ) : |
| 46 |
$settings_url = esc_url( add_query_arg( array( |
| 47 |
'group' => 'gateways_' . $gateway->get_gateway_id() |
| 48 |
), admin_url( 'admin.php?page=charitable-settings&tab=gateways' ) ) ); |
| 49 |
?> |
| 50 |
|
| 51 |
<a href="<?php echo $settings_url ?>" class="button button-primary"><?php _e( 'Gateway Settings', 'charitable' ) ?></a> |
| 52 |
|
| 53 |
<?php endif; |
| 54 |
|
| 55 |
if ( $is_active ) : ?> |
| 56 |
|
| 57 |
<a href="<?php echo $action_url ?>" class="button"><?php _e( 'Disable Gateway', 'charitable' ) ?></a> |
| 58 |
|
| 59 |
<?php else : ?> |
| 60 |
|
| 61 |
<a href="<?php echo $action_url ?>" class="button"><?php _e( 'Enable Gateway', 'charitable' ) ?></a> |
| 62 |
|
| 63 |
<?php endif ?> |
| 64 |
</span> |
| 65 |
</div> |
| 66 |
<?php endforeach ?> |
| 67 |
<?php else : ?> |
| 68 |
<?php _e( 'There are no gateways available in your system.', 'charitable' ) ?> |
| 69 |
<?php endif ?> |