| 1 |
<?php |
| 2 |
/** |
| 3 |
* Display the table of payment gateways. |
| 4 |
* |
| 5 |
* @author David Bisset |
| 6 |
* @package Charitable/Admin View/Settings |
| 7 |
* @copyright Copyright (c) 2023, WP Charitable LLC |
| 8 |
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 9 |
* @since 1.0.0 |
| 10 |
* @version 1.6.38 |
| 11 |
* @version 1.8.0 |
| 12 |
*/ |
| 13 |
|
| 14 |
$helper = charitable_get_helper( 'gateways' ); |
| 15 |
$gateways = $helper->get_available_gateways(); |
| 16 |
$default = $helper->get_default_gateway(); |
| 17 |
$upgrades = $helper->get_recommended_gateways(); |
| 18 |
|
| 19 |
foreach ( $gateways as $gateway ) : |
| 20 |
|
| 21 |
$gateway = new $gateway(); |
| 22 |
$is_active = $helper->is_active_gateway( $gateway->get_gateway_id() ); |
| 23 |
|
| 24 |
if ( $is_active ) { |
| 25 |
$action_url = esc_url( |
| 26 |
add_query_arg( |
| 27 |
array( |
| 28 |
'charitable_action' => 'disable_gateway', |
| 29 |
'gateway_id' => $gateway->get_gateway_id(), |
| 30 |
'_nonce' => wp_create_nonce( 'gateway' ), |
| 31 |
), |
| 32 |
admin_url( 'admin.php?page=charitable-settings&tab=gateways' ) |
| 33 |
) |
| 34 |
); |
| 35 |
$action_text = __( 'Disable Gateway', 'charitable' ); |
| 36 |
} else { |
| 37 |
$action_url = esc_url( |
| 38 |
add_query_arg( |
| 39 |
array( |
| 40 |
'charitable_action' => 'enable_gateway', |
| 41 |
'gateway_id' => $gateway->get_gateway_id(), |
| 42 |
'_nonce' => wp_create_nonce( 'gateway' ), |
| 43 |
), |
| 44 |
admin_url( 'admin.php?page=charitable-settings&tab=gateways' ) |
| 45 |
) |
| 46 |
); |
| 47 |
$action_text = __( 'Enable Gateway', 'charitable' ); |
| 48 |
} |
| 49 |
|
| 50 |
$action_url = esc_url( |
| 51 |
add_query_arg( |
| 52 |
array( |
| 53 |
'charitable_action' => $is_active ? 'disable_gateway' : 'enable_gateway', |
| 54 |
'gateway_id' => $gateway->get_gateway_id(), |
| 55 |
'_nonce' => wp_create_nonce( 'gateway' ), |
| 56 |
), |
| 57 |
admin_url( 'admin.php?page=charitable-settings&tab=gateways' ) |
| 58 |
) |
| 59 |
); |
| 60 |
|
| 61 |
$make_default_url = esc_url( |
| 62 |
add_query_arg( |
| 63 |
array( |
| 64 |
'charitable_action' => 'make_default_gateway', |
| 65 |
'gateway_id' => $gateway->get_gateway_id(), |
| 66 |
'_nonce' => wp_create_nonce( 'gateway' ), |
| 67 |
), |
| 68 |
admin_url( 'admin.php?page=charitable-settings&tab=gateways' ) |
| 69 |
) |
| 70 |
); |
| 71 |
|
| 72 |
$gateway_name = null !== $gateway->get_name() ? $gateway->get_name() : ''; |
| 73 |
|
| 74 |
?> |
| 75 |
<div class="charitable-settings-object charitable-gateway cf <?php echo esc_attr( strtolower( $gateway_name ) ); ?>" style="position: relative;"> |
| 76 |
<?php if ( $gateway->get_badge() ) : ?> |
| 77 |
<div class="starburst" id="wpcharitable-starburst-new"><span>New!</span></div> |
| 78 |
<?php endif; ?> |
| 79 |
<?php if ( $gateway->get_badge() ) : ?> |
| 80 |
<span class="gateway-logo"><svg width="49" height="20" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M48.4718 10.3338c0-3.41791-1.6696-6.11484-4.8607-6.11484-3.2045 0-5.1434 2.69693-5.1434 6.08814 0 4.0187 2.289 6.048 5.5743 6.048 1.6023 0 2.8141-.3604 3.7296-.8678v-2.6702c-.9155.4539-1.9658.7343-3.2987.7343-1.3061 0-2.464-.4539-2.6121-2.0294h6.5841c0-.1735.0269-.8678.0269-1.1882Zm-6.6514-1.26838c0-1.50868.929-2.13618 1.7773-2.13618.8213 0 1.6965.6275 1.6965 2.13618h-3.4738Zm-8.5499-4.84646c-1.3195 0-2.1678.61415-2.639 1.04139l-.1751-.82777h-2.9621V20l3.3661-.7076.0134-3.7784c.4847.3471 1.1984.8411 2.3832.8411 2.4102 0 4.6048-1.9225 4.6048-6.1548-.0134-3.87186-2.235-5.98134-4.5913-5.98134Zm-.8079 9.19894c-.7944 0-1.2656-.2804-1.5888-.6275l-.0134-4.95328c.35-.38719.8348-.65421 1.6022-.65421 1.2253 0 2.0735 1.36182 2.0735 3.11079 0 1.7891-.8347 3.1242-2.0735 3.1242Zm-9.6001-9.98666 3.3796-.72096V0l-3.3796.70761v2.72363Zm0 1.01469h3.3796V16.1282h-3.3796V4.44593Zm-3.6219.98798-.2154-.98798h-2.9083V16.1282h3.3661V8.21095c.7944-1.02804 2.1408-.84112 2.5582-.69426V4.44593c-.4309-.16022-2.0062-.45394-2.8006.98798Zm-6.7322-3.88518-3.2853.69426-.01346 10.69421c0 1.976 1.49456 3.4313 3.48726 3.4313 1.1041 0 1.912-.2003 2.3563-.4406v-2.7103c-.4309.1736-2.5583.7877-2.5583-1.1882V7.28972h2.5583V4.44593h-2.5583l.0135-2.8972ZM3.40649 7.83712c0-.5207.43086-.72096 1.14447-.72096 1.0233 0 2.31588.30707 3.33917.85447V4.83311c-1.11755-.44059-2.22162-.61415-3.33917-.61415C1.81769 4.21896 0 5.63418 0 7.99733c0 3.68487 5.11647 3.09747 5.11647 4.68627 0 .6141-.53858.8144-1.29258.8144-1.11755 0-2.54477-.4539-3.675782-1.0681v3.1776c1.252192.534 2.517842.761 3.675782.761 2.80059 0 4.72599-1.3752 4.72599-3.765-.01346-3.97867-5.14339-3.27106-5.14339-4.76638Z" fill="#635BFF"/></svg></span> |
| 81 |
<?php else : ?> |
| 82 |
<h4 style="padding-left: 20px;"><?php echo esc_html( $gateway->get_name() ); ?></h4> |
| 83 |
<?php endif; ?> |
| 84 |
<?php if ( $gateway->get_badge() ) : ?> |
| 85 |
<span class="gateway-badge""><?php echo esc_html( $gateway->get_badge() ); ?></span> |
| 86 |
<?php endif; ?> |
| 87 |
<?php if ( $gateway->get_gateway_id() == $default ) : ?> |
| 88 |
|
| 89 |
<span class="default-gateway"><?php _e( 'Default gateway', 'charitable' ); ?></span> |
| 90 |
|
| 91 |
<?php elseif ( $is_active ) : ?> |
| 92 |
|
| 93 |
<a href="<?php echo esc_url( $make_default_url ); ?>" class="make-default-gateway"><?php _e( 'Make default gateway', 'charitable' ); ?></a> |
| 94 |
|
| 95 |
<?php endif ?> |
| 96 |
<span class="actions"> |
| 97 |
<?php |
| 98 |
if ( $is_active ) : |
| 99 |
$settings_url = esc_url( |
| 100 |
add_query_arg( |
| 101 |
array( |
| 102 |
'group' => 'gateways_' . $gateway->get_gateway_id(), |
| 103 |
), |
| 104 |
admin_url( 'admin.php?page=charitable-settings&tab=gateways' ) |
| 105 |
) |
| 106 |
); |
| 107 |
?> |
| 108 |
|
| 109 |
<a href="<?php echo esc_url( $settings_url ); ?>" class="button button-primary"><?php _e( 'Gateway Settings', 'charitable' ); ?></a> |
| 110 |
<?php endif ?> |
| 111 |
<a href="<?php echo $action_url; ?>" class="button"><?php echo $action_text; ?></a> |
| 112 |
</span> |
| 113 |
</div> |
| 114 |
<?php endforeach ?> |
| 115 |
<?php |
| 116 |
if ( ! empty( $upgrades ) ) : |
| 117 |
if ( 1 === count( $upgrades ) ) { |
| 118 |
$currencies = charitable_get_currency_helper()->get_all_currencies(); |
| 119 |
$gateway = key( $upgrades ); |
| 120 |
$message = sprintf( |
| 121 |
/* translators: %1$s: currency; %2$s: hyperlink %3$s: payment gateway name */ |
| 122 |
__( '<strong>Tip</strong>: Accept donations in %1$s with <a href="%2$s" target="_blank">%3$s</a>.', 'charitable' ), |
| 123 |
$currencies[ charitable_get_currency() ], |
| 124 |
'https://www.wpcharitable.com/extensions/charitable-' . $gateway . '/?utm_source=WordPress&utm_campaign=WP+Charitable&utm_medium=Upgrade+Notice&utm_content=Accept+Donations', |
| 125 |
current( $upgrades ) |
| 126 |
); |
| 127 |
} else { |
| 128 |
$message = sprintf( |
| 129 |
/* translators: %1$s: hyperlink; %2$s: single extension name; %3$s: comma-separated list of extension names */ |
| 130 |
__( '<strong>Need more options?</strong> <a href="%1$s" target="_blank">Click here to browse our payment gateway extensions</a>, including %3$s and %2$s.', 'charitable' ), |
| 131 |
'https://www.wpcharitable.com/extensions/category/payment-gateways/?utm_source=WordPress&utm_campaign=WP+Charitable&utm_medium=Admin+Notice&utm_content=Need+More+Options+Browse+Gateway+Extensions', |
| 132 |
array_pop( $upgrades ), |
| 133 |
implode( ', ', $upgrades ) |
| 134 |
); |
| 135 |
} |
| 136 |
?> |
| 137 |
<p class="charitable-gateway-prompt charitable-settings-notice"><?php echo esc_html( $message ); ?></p> |
| 138 |
<?php endif ?> |
| 139 |
|