Skip to content

Instantly share code, notes, and snippets.

@hansschuijff
Created November 11, 2020 10:29
Show Gist options
  • Save hansschuijff/4cee94b8ebf6fe46755e648ffccb496f to your computer and use it in GitHub Desktop.
Save hansschuijff/4cee94b8ebf6fe46755e648ffccb496f to your computer and use it in GitHub Desktop.
<?php
/**
* Set the display_logo option to "no" for all mollie payment options
*
* @package DeWittePrins\CoreFunctionality;
* @since 1.7.12
* @author Hans Schuijff
* @link https://dewitteprins.nl
* @license GNU-2.0+
*/
namespace DeWittePrins\CoreFunctionality\Mollie;
/**
* Adds a filter for every mollie payment method option
*
* @since 1.7.12
*
* @return void
*/
function add_mollie_option_filter() {
$mollie_payment_options = get_mollie_payment_options();
foreach( $mollie_payment_options as $option ) {
add_filter( "option_{$option}", __NAMESPACE__ . '\filter_display_logo_option', 10, 2 );
}
}
add_action( 'init', __NAMESPACE__ . '\add_mollie_option_filter');
/**
* Filters any mollie payment method option
* to set "display_logo" value to 'no'
*
* @since 1.7.12
*
* @param array $value Value of the option
* @return array Same as $value, but with display_logo set to "no"
*/
function filter_display_logo_option( $value) {
if ( is_array( $value)
&& isset( $value['display_logo'] ) ) {
$value['display_logo'] = 'no';
}
return $value;
}
/**
* Returns an array with all mollie gateway payment method options
*
* @since 1.7.12
*
* @return array
*/
function get_mollie_payment_options() {
return [
"mollie_wc_gateway_banktransfer_settings",
"mollie_wc_gateway_belfius_settings",
"mollie_wc_gateway_directdebit_settings",
"mollie_wc_gateway_creditcard_settings",
"mollie_wc_gateway_directdebit_settings",
"mollie_wc_gateway_eps_settings",
"mollie_wc_gateway_directdebit_settings",
"mollie_wc_gateway_giropay_settings",
"mollie_wc_gateway_directdebit_settings",
"mollie_wc_gateway_ideal_settings",
"mollie_wc_gateway_directdebit_settings",
"mollie_wc_gateway_inghomepay_settings",
"mollie_wc_gateway_directdebit_settings",
"mollie_wc_gateway_kbc_settings",
"mollie_wc_gateway_directdebit_settings",
"mollie_wc_gateway_klarnapaylater_settings",
"mollie_wc_gateway_klarnasliceit_settings",
"mollie_wc_gateway_bancontact_settings",
"mollie_wc_gateway_directdebit_settings",
"mollie_wc_gateway_mistercash_settings",
"mollie_wc_gateway_directdebit_settings",
"mollie_wc_gateway_paypal_settings",
"mollie_wc_gateway_paysafecard_settings",
"mollie_wc_gateway_przelewy24_settings",
"mollie_wc_gateway_sofort_settings",
"mollie_wc_gateway_directdebit_settings",
"mollie_wc_gateway_giftcard_settings",
"mollie_wc_gateway_applepay_settings",
"mollie_wc_gateway_mybank_settings",
"mollie_wc_gateway_mealvoucher_settings",
];
}
/**
* Returns an array with all woocommerce payment method options
*
* @since 1.7.12
*
* @return array
*/
function get_woocommerce_payment_options() {
return [
"woocommerce_bacs_settings",
"woocommerce_cheque_settings",
"woocommerce_cod_settings",
"woocommerce_paypal_settings",
];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment