@@ 481-488 (lines=8) @@ | ||
478 | * @return array |
|
479 | */ |
|
480 | function give_filter_offline_gateway( $gateway_list, $form_id ) { |
|
481 | if ( |
|
482 | // Show offline payment gateway if enable for new donation form. |
|
483 | ( false === strpos( $_SERVER['REQUEST_URI'], '/wp-admin/post-new.php?post_type=give_forms' ) ) |
|
484 | && $form_id |
|
485 | && ! give_is_setting_enabled( give_get_meta( $form_id, '_give_customize_offline_donations', true ), array( 'enabled', 'global' ) ) |
|
486 | ) { |
|
487 | unset( $gateway_list['offline'] ); |
|
488 | } |
|
489 | ||
490 | // Output. |
|
491 | return $gateway_list; |
|
@@ 509-514 (lines=6) @@ | ||
506 | * @return void |
|
507 | */ |
|
508 | function _give_customize_offline_donations_on_save_callback( $meta_key, $meta_value, $postid ) { |
|
509 | if ( |
|
510 | ! give_is_setting_enabled( $meta_value, array( 'global', 'enabled' ) ) |
|
511 | && ( 'offline' === give_get_meta( $postid, '_give_default_gateway', true ) ) |
|
512 | ) { |
|
513 | give_update_meta( $postid, '_give_default_gateway', 'global' ); |
|
514 | } |
|
515 | } |
|
516 | ||
517 | add_filter( 'give_save__give_customize_offline_donations', '_give_customize_offline_donations_on_save_callback', 10, 3 ); |