Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
function leaky_paywall_2checkout_gateway_settings( $settings ) {
if ( !in_array( '2checkout', $settings['payment_gateway'] ) ) {
return;
}
?>
<table class="form-table">
<tr>
<th><?php _e( '2Checkout Test Seller ID', 'issuem-leaky-paywall' ); ?></th>
<td>
<input type="text" id="twocheckout_test_seller_id" class="regular-text" name="twocheckout_test_seller_id" value="<?php echo htmlspecialchars( stripcslashes( $settings['twocheckout_test_seller_id'] ) ); ?>" />
<p class="description"><?php _e( '2Checkout test account number', 'issuem-leaky-paywall' ); ?></p>
</td>
</tr>
<tr>
<th><?php _e( 'Test Publishable Key', 'issuem-leaky-paywall' ); ?></th>
<td>
<input type="text" id="twocheckout_test_publishable" class="regular-text" name="twocheckout_test_publishable" value="<?php echo htmlspecialchars( stripcslashes( $settings['twocheckout_test_publishable'] ) ); ?>" />
<p class="description"><?php _e( 'Test Publishable key', 'issuem-leaky-paywall' ); ?></p>
</td>
</tr>
<tr>
<th><?php _e( 'Test Private Key', 'issuem-leaky-paywall' ); ?></th>
<td>
<input type="text" id="twocheckout_test_private" class="regular-text" name="twocheckout_test_private" value="<?php echo htmlspecialchars( stripcslashes( $settings['twocheckout_test_private'] ) ); ?>" />
<p class="description"><?php _e( 'Test Private key', 'issuem-leaky-paywall' ); ?></p>
</td>
</tr>
</table>
<?php
}
add_action( 'leaky_paywall_payments_settings', 'leaky_paywall_2checkout_gateway_settings', 15, 1 );
function leaky_paywall_update_2checkout_gateway_settings( $settings ) {
if ( !empty( $_POST['twocheckout_test_seller_id'] ) ) {
$settings['twocheckout_test_seller_id'] = trim( $_POST['twocheckout_test_seller_id'] );
}
if ( !empty( $_POST['twocheckout_test_publishable'] ) ) {
$settings['twocheckout_test_publishable'] = trim( $_POST['twocheckout_test_publishable'] );
}
if ( !empty( $_POST['twocheckout_test_private'] ) ) {
$settings['twocheckout_test_private'] = trim( $_POST['twocheckout_test_private'] );
}
return $settings;
}
add_filter( 'leaky_paywall_update_settings_settings', 'leaky_paywall_update_2checkout_gateway_settings', 10, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment