Make logo url mandatory field

This commit is contained in:
emilicastells 2022-06-17 16:59:49 +02:00
parent b362f295f8
commit d6bd02c9c1
No known key found for this signature in database
GPG key ID: 1520C07081754570

View file

@ -424,12 +424,30 @@ class PayUponInvoice {
PayUponInvoiceGateway::ID === $this->current_ppcp_settings_page_id
&& $this->pui_product_status->pui_is_active()
) {
$pui_gateway = WC()->payment_gateways->payment_gateways()[ PayUponInvoiceGateway::ID ];
$error_messages = array();
$pui_gateway = WC()->payment_gateways->payment_gateways()[ PayUponInvoiceGateway::ID ];
if ( $pui_gateway->get_option( 'logo_url' ) === '' ) {
$error_messages[] = esc_html__( 'Could not enable gateway because "Logo URL" field is empty.', 'woocommerce-paypal-payments' );
}
if ( $pui_gateway->get_option( 'customer_service_instructions' ) === '' ) {
printf(
'<div class="notice notice-error"><p>%1$s</p></div>',
esc_html__( 'Could not enable gateway because "Customer service instructions" field is empty.', 'woocommerce-paypal-payments' )
);
$error_messages[] = esc_html__( 'Could not enable gateway because "Customer service instructions" field is empty.', 'woocommerce-paypal-payments' );
}
if ( count( $error_messages ) > 0 ) { ?>
<div class="notice notice-error">
<?php
array_map(
static function( $message ) {
/**
* Already escaped when adding into `$error_messages`.
* phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
*/
echo '<p>' . $message . '</p>';
},
$error_messages
)
?>
</div>
<?php
}
}
}