PluginProbe
Easy Invoice – Invoice Generator, PDF Quotes & Payments / 2.4.3
Easy Invoice – Invoice Generator, PDF Quotes & Payments v2.4.3
2.4.3 2.4.4 2.4.2 2.4.0 2.4.1 2.3.8 2.3.7 2.3.6 2.3.5 2.3.4 2.3.3 2.3.2 2.3.1 2.2.0 2.1.21 2.1.20 2.1.19 2.1.18 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 All 60 releases
← All changes | includes/EasyInvoice.php +26 -11 2.4.1 → 2.4.3 View file →
@@ -225,13 +225,16 @@
225 225 private function initPaymentGateways() {
226 226 if ( ! $this->gateway_manager ) {
227 227 $this->gateway_manager = new PaymentGatewayManager();
228 228
229 - // Register payment gateways.
230 - $gateways = [
231 - new Gateways\PayPalGateway(),
232 - new Gateways\ManualGateway(),
233 - ];
229 + // Register payment gateways: PayPal, then one gateway per offline
230 + // method (bank transfer, cheque, cash and any the merchant added).
231 + // The single "Manual Payment" gateway of earlier versions is gone;
232 + // setDefaultPaymentMethods() carries its enabled state over.
233 + $gateways = [ new Gateways\PayPalGateway() ];
234 + foreach ( Services\OfflinePayments::methods() as $method ) {
235 + $gateways[] = new Gateways\OfflineGateway( $method );
236 + }
234 237
235 238 foreach ( $gateways as $gateway ) {
236 239 $this->gateway_manager->registerGateway( $gateway );
237 240 }
@@ -251,15 +254,27 @@
251 254 * @access private
252 255 * @return void
253 256 */
254 257 private function setDefaultPaymentMethods() {
255 - $payment_methods = get_option( 'easy_invoice_payment_methods', [] );
258 + $payment_methods = get_option( 'easy_invoice_payment_methods', null );
259 + if ( null === $payment_methods ) {
260 + // First run: an invoice with no way to pay is a dead end, and bank
261 + // transfer needs no account with anyone. The merchant can switch it
262 + // off under Settings → Payment Methods.
263 + update_option( 'easy_invoice_payment_methods', [ 'bank_transfer' ] );
264 + return;
265 + }
266 + $payment_methods = is_array( $payment_methods ) ? $payment_methods : [];
256 267
257 - $defaults_updated = false;
258 -
259 - // Bank Transfer, Cheque, and Cash payment defaults moved to Pro plugin
260 -
261 - if ( $defaults_updated ) {
268 + // Sites that had "Manual Payment" switched on keep an offline option:
269 + // its three sub-choices are gateways of their own now.
270 + if ( in_array( 'manual', $payment_methods, true ) ) {
271 + $payment_methods = array_values( array_diff( $payment_methods, [ 'manual' ] ) );
272 + foreach ( [ 'bank_transfer', 'cheque', 'cash' ] as $offline ) {
273 + if ( ! in_array( $offline, $payment_methods, true ) ) {
274 + $payment_methods[] = $offline;
275 + }
276 + }
262 277 update_option( 'easy_invoice_payment_methods', array_unique( $payment_methods ) );
263 278 }
264 279 }
265 280