diff --git a/.wp-env.json b/.wp-env.json
new file mode 100644
index 0000000..799b4b4
--- /dev/null
+++ b/.wp-env.json
@@ -0,0 +1,15 @@
+{
+ "core": null,
+ "plugins": [
+ ".",
+ "../../../",
+ "https://github.com/pronamic/gravityforms/releases/download/2.6.6/gravityforms-2.6.6.zip",
+ "pronamic/wp-pronamic-pay-test-helper",
+ "https://downloads.wordpress.org/plugin/pronamic-client.zip",
+ "https://downloads.wordpress.org/plugin/query-monitor.zip",
+ "https://downloads.wordpress.org/plugin/one-time-login.zip"
+ ],
+ "config": {
+ "PRONAMIC_PAY_DEBUG": true
+ }
+}
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7bd0385..cc17bfa 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,10 @@ This projects adheres to [Semantic Versioning](http://semver.org/) and [Keep a C
## [Unreleased][unreleased]
-
+## [4.2.0] - 2022-09-26
+- Fixed conditional logic object without any logic.
+- Updated for new payment methods and fields registration.
+
## [4.1.1] - 2022-08-15
- Fixed compatibility issue with plugins producing output in `gform_admin_pre_render` filter.
- Fixed duplicate configurations in payment gateway configuration field setting ([pronamic/wp-pronamic-pay-gravityforms#8](https://github.com/pronamic/wp-pronamic-pay-gravityforms/issues/8)).
@@ -345,7 +349,8 @@ This projects adheres to [Semantic Versioning](http://semver.org/) and [Keep a C
## 1.0.0 - 2015-01-01
- First release.
-[unreleased]: https://github.com/pronamic/wp-pronamic-pay-gravityforms/compare/4.1.1...HEAD
+[unreleased]: https://github.com/pronamic/wp-pronamic-pay-gravityforms/compare/4.2.0...HEAD
+[4.2.0]: https://github.com/pronamic/wp-pronamic-pay-gravityforms/compare/4.1.1...4.2.0
[4.1.1]: https://github.com/pronamic/wp-pronamic-pay-gravityforms/compare/4.1.0...4.1.1
[4.1.0]: https://github.com/pronamic/wp-pronamic-pay-gravityforms/compare/4.0.1...4.1.0
[4.0.1]: https://github.com/pronamic/wp-pronamic-pay-gravityforms/compare/4.0.0...4.0.1
diff --git a/composer.json b/composer.json
index fa3c0ce..fe00ca6 100644
--- a/composer.json
+++ b/composer.json
@@ -58,7 +58,7 @@
},
"scripts": {
"coveralls": "vendor/bin/php-coveralls -v",
- "phpcbf": "vendor/bin/phpcbf",
+ "phpcbf": "XDEBUG_MODE=off vendor/bin/phpcbf",
"phpcs": "XDEBUG_MODE=off vendor/bin/phpcs -s -v",
"phplint": "find src tests -name '*.php' | xargs -n 1 -P 4 php -l",
"phpmd": "vendor/bin/phpmd src,tests text phpmd.ruleset.xml --suffixes php",
diff --git a/package.json b/package.json
index ffd2beb..e75e344 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "gravityforms",
- "version": "4.1.1",
+ "version": "4.2.0",
"description": "Gravity Forms driver for the WordPress payment processing library.",
"repository": {
"type": "git",
@@ -35,6 +35,7 @@
"last 2 versions"
],
"devDependencies": {
+ "@wordpress/env": "^5.2.0",
"autoprefixer": "^10.2.5",
"eslint": "^8.0",
"eslint-plugin-json": "^3.1",
@@ -46,6 +47,7 @@
"grunt-postcss": "^0.9.0",
"grunt-sass-lint": "^0.2.4",
"load-grunt-tasks": "^5.1.0",
+ "npm-run-all": "^4.1.5",
"sass-lint": "^1.13.1"
},
"scripts": {
@@ -53,6 +55,13 @@
"build-image-svg-default": "svgo images/src/wp-pay.svg -o images/dist/wp-pay.svgo-min.svg",
"eslint": "eslint . --ext .json --ext .js",
"lint": "npm-run-all --parallel eslint sass-lint",
- "sass-lint": "sass-lint --verbose"
+ "sass-lint": "sass-lint --verbose",
+ "start": "wp-env start && npm run setup && npm run login",
+ "setup": "npm-run-all setup-*",
+ "setup-gravityforms": "wp-env run cli wp config set GF_LICENSE_KEY $GRAVITYFORMS_LICENSE_KEY",
+ "setup-mollie": "wp-env run cli wp config set MOLLIE_API_KEY $MOLLIE_API_KEY",
+ "setup-buckaroo-website-key": "wp-env run cli wp config set BUCKAROO_WEBSITE_KEY $BUCKAROO_WEBSITE_KEY",
+ "setup-buckaroo-secret-key": "wp-env run cli wp config set BUCKAROO_SECRET_KEY $BUCKAROO_SECRET_KEY",
+ "login": "wp-env run cli wp user one-time-login admin"
}
}
diff --git a/pronamic-pay-gravityforms.php b/pronamic-pay-gravityforms.php
new file mode 100644
index 0000000..89525e4
--- /dev/null
+++ b/pronamic-pay-gravityforms.php
@@ -0,0 +1,41 @@
+
+ * @copyright 2005-2022 Pronamic
+ * @license GPL-3.0-or-later
+ * @package Pronamic\WordPress\Pay\Extensions\GravityForms
+ */
+
+add_filter(
+ 'pronamic_pay_plugin_integrations',
+ function ( $integrations ) {
+ foreach ( $integrations as $integration ) {
+ if ( $integration instanceof \Pronamic\WordPress\Pay\Extensions\GravityForms\Extension ) {
+ return $integrations;
+ }
+ }
+
+ $integrations[] = new \Pronamic\WordPress\Pay\Extensions\GravityForms\Extension();
+
+ return $integrations;
+ }
+);
diff --git a/src/Admin.php b/src/Admin.php
index 1a41de3..5ef6a97 100644
--- a/src/Admin.php
+++ b/src/Admin.php
@@ -29,16 +29,16 @@ class Admin {
*/
public static function bootstrap() {
// Actions.
- add_action( 'admin_init', array( __CLASS__, 'admin_init' ) );
- add_action( 'admin_init', array( __CLASS__, 'maybe_redirect_to_entry' ) );
+ add_action( 'admin_init', [ __CLASS__, 'admin_init' ] );
+ add_action( 'admin_init', [ __CLASS__, 'maybe_redirect_to_entry' ] );
- add_action( 'gform_entry_info', array( __CLASS__, 'entry_info' ), 10, 2 );
+ add_action( 'gform_entry_info', [ __CLASS__, 'entry_info' ], 10, 2 );
// Filters.
- add_filter( 'gform_custom_merge_tags', array( __CLASS__, 'custom_merge_tags' ), 10 );
+ add_filter( 'gform_custom_merge_tags', [ __CLASS__, 'custom_merge_tags' ], 10 );
// Actions - AJAX.
- add_action( 'wp_ajax_gf_get_form_data', array( __CLASS__, 'ajax_get_form_data' ) );
+ add_action( 'wp_ajax_gf_get_form_data', [ __CLASS__, 'ajax_get_form_data' ] );
}
/**
@@ -56,11 +56,11 @@ public static function admin_init() {
* @return array
*/
public static function form_settings_menu_item( $menu_items ) {
- $menu_items[] = array(
+ $menu_items[] = [
'name' => 'pronamic_pay',
'label' => __( 'Pay', 'pronamic_ideal' ),
- 'query' => array( 'fid' => null ),
- );
+ 'query' => [ 'fid' => null ],
+ ];
return $menu_items;
}
@@ -93,102 +93,102 @@ public static function entry_info( $form_id, $lead ) {
*/
public static function custom_merge_tags( $merge_tags ) {
// Payment.
- $merge_tags[] = array(
+ $merge_tags[] = [
'label' => __( 'Payment Status', 'pronamic_ideal' ),
'tag' => '{payment_status}',
- );
+ ];
- $merge_tags[] = array(
+ $merge_tags[] = [
'label' => __( 'Payment Date', 'pronamic_ideal' ),
'tag' => '{payment_date}',
- );
+ ];
- $merge_tags[] = array(
+ $merge_tags[] = [
'label' => __( 'Transaction Id', 'pronamic_ideal' ),
'tag' => '{transaction_id}',
- );
+ ];
- $merge_tags[] = array(
+ $merge_tags[] = [
'label' => __( 'Payment Amount', 'pronamic_ideal' ),
'tag' => '{payment_amount}',
- );
+ ];
- $merge_tags[] = array(
+ $merge_tags[] = [
'label' => __( 'Pronamic Payment ID', 'pronamic_ideal' ),
'tag' => '{pronamic_payment_id}',
- );
+ ];
- $merge_tags[] = array(
+ $merge_tags[] = [
'label' => __( 'Pronamic Pay Again URL', 'pronamic_ideal' ),
'tag' => '{pronamic_pay_again_url}',
- );
+ ];
// Bank transfer.
- $merge_tags[] = array(
+ $merge_tags[] = [
'label' => __( 'Pronamic bank transfer recipient reference', 'pronamic_ideal' ),
'tag' => '{pronamic_payment_bank_transfer_recipient_reference}',
- );
+ ];
- $merge_tags[] = array(
+ $merge_tags[] = [
'label' => __( 'Pronamic bank transfer recipient bank name', 'pronamic_ideal' ),
'tag' => '{pronamic_payment_bank_transfer_recipient_bank_name}',
- );
+ ];
- $merge_tags[] = array(
+ $merge_tags[] = [
'label' => __( 'Pronamic bank transfer recipient name', 'pronamic_ideal' ),
'tag' => '{pronamic_payment_bank_transfer_recipient_name}',
- );
+ ];
- $merge_tags[] = array(
+ $merge_tags[] = [
'label' => __( 'Pronamic bank transfer recipient IBAN', 'pronamic_ideal' ),
'tag' => '{pronamic_payment_bank_transfer_recipient_iban}',
- );
+ ];
- $merge_tags[] = array(
+ $merge_tags[] = [
'label' => __( 'Pronamic bank transfer recipient BIC', 'pronamic_ideal' ),
'tag' => '{pronamic_payment_bank_transfer_recipient_bic}',
- );
+ ];
- $merge_tags[] = array(
+ $merge_tags[] = [
'label' => __( 'Pronamic bank transfer recipient city', 'pronamic_ideal' ),
'tag' => '{pronamic_payment_bank_transfer_recipient_city}',
- );
+ ];
- $merge_tags[] = array(
+ $merge_tags[] = [
'label' => __( 'Pronamic bank transfer recipient country', 'pronamic_ideal' ),
'tag' => '{pronamic_payment_bank_transfer_recipient_country}',
- );
+ ];
- $merge_tags[] = array(
+ $merge_tags[] = [
'label' => __( 'Pronamic bank transfer recipient account number', 'pronamic_ideal' ),
'tag' => '{pronamic_payment_bank_transfer_recipient_account_number}',
- );
+ ];
// Subscription.
- $merge_tags[] = array(
+ $merge_tags[] = [
'label' => __( 'Pronamic Subscription Payment ID', 'pronamic_ideal' ),
'tag' => '{pronamic_subscription_payment_id}',
- );
+ ];
- $merge_tags[] = array(
+ $merge_tags[] = [
'label' => __( 'Pronamic Subscription Amount', 'pronamic_ideal' ),
'tag' => '{pronamic_subscription_amount}',
- );
+ ];
- $merge_tags[] = array(
+ $merge_tags[] = [
'label' => __( 'Pronamic Subscription Cancel URL', 'pronamic_ideal' ),
'tag' => '{pronamic_subscription_cancel_url}',
- );
+ ];
- $merge_tags[] = array(
+ $merge_tags[] = [
'label' => __( 'Pronamic Subscription Renew URL', 'pronamic_ideal' ),
'tag' => '{pronamic_subscription_renew_url}',
- );
+ ];
- $merge_tags[] = array(
+ $merge_tags[] = [
'label' => __( 'Pronamic Subscription Renewal Date', 'pronamic_ideal' ),
'tag' => '{pronamic_subscription_renewal_date}',
- );
+ ];
return $merge_tags;
}
@@ -207,12 +207,12 @@ public static function maybe_redirect_to_entry() {
if ( ! empty( $lead ) ) {
$url = add_query_arg(
- array(
+ [
'page' => 'gf_entries',
'view' => 'entry',
'id' => $lead['form_id'],
'lid' => $lead_id,
- ),
+ ],
admin_url( 'admin.php' )
);
@@ -243,13 +243,13 @@ public static function ajax_get_form_data() {
*/
public static function get_new_feed_url( $form_id ) {
return add_query_arg(
- array(
+ [
'page' => 'gf_edit_forms',
'view' => 'settings',
'subview' => 'pronamic_pay',
'id' => $form_id,
'fid' => 0,
- ),
+ ],
admin_url( 'admin.php' )
);
}
diff --git a/src/AdminPaymentFormPostType.php b/src/AdminPaymentFormPostType.php
index ee977d4..243dfa5 100644
--- a/src/AdminPaymentFormPostType.php
+++ b/src/AdminPaymentFormPostType.php
@@ -36,17 +36,17 @@ class AdminPaymentFormPostType {
* Construct and initialize admin payment form post type.
*/
public function __construct() {
- add_filter( 'manage_edit-pronamic_pay_gf_columns', array( $this, 'edit_columns' ) );
+ add_filter( 'manage_edit-pronamic_pay_gf_columns', [ $this, 'edit_columns' ] );
- add_action( 'manage_pronamic_pay_gf_posts_custom_column', array( $this, 'custom_columns' ), 10, 2 );
+ add_action( 'manage_pronamic_pay_gf_posts_custom_column', [ $this, 'custom_columns' ], 10, 2 );
- add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) );
+ add_action( 'add_meta_boxes', [ $this, 'add_meta_boxes' ] );
- add_action( 'gform_after_delete_form', array( $this, 'delete_payment_form' ) );
+ add_action( 'gform_after_delete_form', [ $this, 'delete_payment_form' ] );
- add_filter( 'wp_insert_post_data', array( $this, 'insert_post_data' ), 99, 2 );
+ add_filter( 'wp_insert_post_data', [ $this, 'insert_post_data' ], 99, 2 );
- add_action( 'save_post_' . self::POST_TYPE, array( $this, 'save_post' ) );
+ add_action( 'save_post_' . self::POST_TYPE, [ $this, 'save_post' ] );
}
/**
@@ -56,14 +56,14 @@ public function __construct() {
* @return array
*/
public function edit_columns( $columns ) {
- $columns = array(
+ $columns = [
'cb' => '',
'title' => __( 'Title', 'pronamic_ideal' ),
'pronamic_pay_gf_form' => __( 'Form', 'pronamic_ideal' ),
'pronamic_pay_gf_config' => __( 'Configuration', 'pronamic_ideal' ),
'pronamic_pay_gf_transaction_description' => __( 'Transaction Description', 'pronamic_ideal' ),
'date' => __( 'Date', 'pronamic_ideal' ),
- );
+ ];
return $columns;
}
@@ -84,10 +84,10 @@ public function custom_columns( $column, $post_id ) {
'%s',
esc_attr(
add_query_arg(
- array(
+ [
'page' => 'gf_edit_forms',
'id' => $form_id,
- ),
+ ],
admin_url( 'admin.php' )
)
),
@@ -122,7 +122,7 @@ public function add_meta_boxes() {
add_meta_box(
'pronamic_pay_gf',
__( 'Configuration', 'pronamic_ideal' ),
- array( $this, 'meta_box_config' ),
+ [ $this, 'meta_box_config' ],
'pronamic_pay_gf',
'normal',
'high'
@@ -148,15 +148,15 @@ public function meta_box_config( $post ) {
*/
public function delete_payment_form( $form_id ) {
$query = new WP_Query(
- array(
+ [
'post_type' => 'pronamic_pay_gf',
- 'meta_query' => array(
- array(
+ 'meta_query' => [
+ [
'key' => '_pronamic_pay_gf_form_id',
'value' => $form_id,
- ),
- ),
- )
+ ],
+ ],
+ ]
);
foreach ( $query->posts as $post ) {
@@ -239,7 +239,7 @@ public function save_post( $post_id ) {
}
/* OK, its safe for us to save the data now. */
- $definition = array(
+ $definition = [
'_pronamic_pay_gf_form_id' => 'sanitize_text_field',
'_pronamic_pay_gf_config_id' => 'sanitize_text_field',
'_pronamic_pay_gf_entry_id_prefix' => 'sanitize_text_field',
@@ -247,19 +247,19 @@ public function save_post( $post_id ) {
'_pronamic_pay_gf_transaction_description' => 'sanitize_text_field',
'_pronamic_pay_gf_delay_admin_notification' => FILTER_VALIDATE_BOOLEAN,
'_pronamic_pay_gf_delay_user_notification' => FILTER_VALIDATE_BOOLEAN,
- '_pronamic_pay_gf_delay_notification_ids' => array(
+ '_pronamic_pay_gf_delay_notification_ids' => [
'filter' => FILTER_SANITIZE_STRING,
'flags' => FILTER_REQUIRE_ARRAY,
- ),
+ ],
'_pronamic_pay_gf_delay_post_creation' => FILTER_VALIDATE_BOOLEAN,
- '_pronamic_pay_gf_fields' => array(
+ '_pronamic_pay_gf_fields' => [
'filter' => FILTER_SANITIZE_STRING,
'flags' => FILTER_REQUIRE_ARRAY,
- ),
- '_pronamic_pay_gf_links' => array(
+ ],
+ '_pronamic_pay_gf_links' => [
'filter' => FILTER_SANITIZE_STRING,
'flags' => FILTER_REQUIRE_ARRAY,
- ),
+ ],
'_pronamic_pay_gf_user_role_field_id' => 'sanitize_text_field',
'_pronamic_pay_gf_subscription_amount_type' => 'sanitize_text_field',
'_pronamic_pay_gf_subscription_amount_field' => 'sanitize_text_field',
@@ -279,7 +279,7 @@ public function save_post( $post_id ) {
// Feed conditions.
'_gaddon_setting_feed_condition_conditional_logic_object' => 'sanitize_text_field',
'_gform_setting_feed_condition_conditional_logic_object' => 'sanitize_text_field',
- );
+ ];
$delay_actions = Extension::get_delay_actions();
@@ -367,7 +367,7 @@ function( $action ) {
\delete_post_meta( $post_id, '_pronamic_pay_gf_subscription_frequency' );
}
- if ( \in_array( $meta_key, array( '_gform_setting_feed_condition_conditional_logic_object', '_gaddon_setting_feed_condition_conditional_logic_object' ), true ) ) {
+ if ( \in_array( $meta_key, [ '_gform_setting_feed_condition_conditional_logic_object', '_gaddon_setting_feed_condition_conditional_logic_object' ], true ) ) {
\delete_post_meta( $post_id, '_pronamic_pay_gf_condition_field_id' );
\delete_post_meta( $post_id, '_pronamic_pay_gf_condition_operator' );
\delete_post_meta( $post_id, '_pronamic_pay_gf_condition_value' );
diff --git a/src/Entry.php b/src/Entry.php
index 55e99fd..939cac6 100644
--- a/src/Entry.php
+++ b/src/Entry.php
@@ -53,12 +53,12 @@ public static function is_payment_approved( array $entry ) {
$approved = in_array(
$payment_status,
- array(
+ [
// @since 1.0.0 - Approved
PaymentStatuses::APPROVED,
// @since 1.2.3 - Paid
PaymentStatuses::PAID,
- ),
+ ],
true
);
}
diff --git a/src/Extension.php b/src/Extension.php
index 32722a2..a2c17bb 100644
--- a/src/Extension.php
+++ b/src/Extension.php
@@ -59,10 +59,10 @@ class Extension extends AbstractPluginIntegration {
*/
public function __construct() {
parent::__construct(
- array(
+ [
'name' => __( 'Gravity Forms', 'pronamic_ideal' ),
'version' => '2.3.0',
- )
+ ]
);
// Dependencies.
@@ -77,10 +77,10 @@ public function __construct() {
* @return void
*/
public function setup() {
- add_filter( 'pronamic_payment_source_text_' . self::SLUG, array( $this, 'source_text' ), 10, 2 );
- add_filter( 'pronamic_payment_source_description_' . self::SLUG, array( $this, 'source_description' ), 10, 2 );
- add_filter( 'pronamic_subscription_source_text_' . self::SLUG, array( $this, 'subscription_source_text' ), 10, 2 );
- add_filter( 'pronamic_subscription_source_description_' . self::SLUG, array( $this, 'subscription_source_description' ), 10, 2 );
+ add_filter( 'pronamic_payment_source_text_' . self::SLUG, [ $this, 'source_text' ], 10, 2 );
+ add_filter( 'pronamic_payment_source_description_' . self::SLUG, [ $this, 'source_description' ], 10, 2 );
+ add_filter( 'pronamic_subscription_source_text_' . self::SLUG, [ $this, 'subscription_source_text' ], 10, 2 );
+ add_filter( 'pronamic_subscription_source_description_' . self::SLUG, [ $this, 'subscription_source_description' ], 10, 2 );
// Check if dependencies are met and integration is active.
if ( ! $this->is_active() ) {
@@ -95,9 +95,9 @@ public function setup() {
// Actions
// Initialize hook, Gravity Forms uses the default priority (10).
- add_action( 'init', array( $this, 'init' ), 20 );
+ add_action( 'init', [ $this, 'init' ], 20 );
- add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
+ add_action( 'admin_enqueue_scripts', [ $this, 'admin_enqueue_scripts' ] );
// Add-on
// The `class_exists` call is required to prevent strange errors on some hosting environments.
@@ -121,32 +121,30 @@ public function init() {
if ( is_admin() ) {
Admin::bootstrap();
} else {
- add_action( 'gform_pre_submission', array( $this, 'pre_submission' ) );
+ add_action( 'gform_pre_submission', [ $this, 'pre_submission' ] );
}
- add_filter( 'pronamic_payment_source_url_' . self::SLUG, array( $this, 'source_url' ), 10, 2 );
- add_filter( 'pronamic_subscription_source_url_' . self::SLUG, array( $this, 'subscription_source_url' ), 10, 2 );
- add_filter( 'pronamic_payment_redirect_url_' . self::SLUG, array( $this, 'redirect_url' ), 10, 2 );
- add_action( 'pronamic_payment_status_update_' . self::SLUG, array( $this, 'update_status' ), 10, 2 );
- add_action( 'pronamic_pay_update_payment', array( $this, 'update_payment' ) );
- add_action( 'pronamic_subscription_status_update_' . self::SLUG, array( $this, 'subscription_update_status' ) );
- add_action( 'pronamic_subscription_renewal_notice_' . self::SLUG, array( $this, 'subscription_renewal_notice' ) );
+ add_filter( 'pronamic_payment_source_url_' . self::SLUG, [ $this, 'source_url' ], 10, 2 );
+ add_filter( 'pronamic_subscription_source_url_' . self::SLUG, [ $this, 'subscription_source_url' ], 10, 2 );
+ add_filter( 'pronamic_payment_redirect_url_' . self::SLUG, [ $this, 'redirect_url' ], 10, 2 );
+ add_action( 'pronamic_payment_status_update_' . self::SLUG, [ $this, 'update_status' ], 10, 2 );
+ add_action( 'pronamic_pay_update_payment', [ $this, 'update_payment' ] );
+ add_action( 'pronamic_subscription_status_update_' . self::SLUG, [ $this, 'subscription_update_status' ] );
+ add_action( 'pronamic_subscription_renewal_notice_' . self::SLUG, [ $this, 'subscription_renewal_notice' ] );
add_filter( 'pronamic_pay_subscription_amount_editable_' . self::SLUG, '__return_true' );
- add_filter( 'gform_replace_merge_tags', array( $this, 'replace_merge_tags' ), 10, 7 );
-
- add_filter( 'gform_gf_field_create', array( $this, 'field_create' ), 10, 2 );
+ add_filter( 'gform_replace_merge_tags', [ $this, 'replace_merge_tags' ], 10, 7 );
- add_filter( 'gform_currencies', array( __CLASS__, 'currencies' ), 10, 1 );
+ add_filter( 'gform_gf_field_create', [ $this, 'field_create' ], 10, 2 );
- \add_filter( 'gform_form_args', array( $this, 'maybe_prepopulate_form' ), 10, 1 );
- \add_filter( 'gform_pre_render', array( $this, 'allow_field_prepopulation' ), 10, 3 );
+ \add_filter( 'gform_form_args', [ $this, 'maybe_prepopulate_form' ], 10, 1 );
+ \add_filter( 'gform_pre_render', [ $this, 'allow_field_prepopulation' ], 10, 3 );
// Register scripts and styles if Gravity Forms No-Conflict Mode is enabled.
- add_filter( 'gform_noconflict_scripts', array( $this, 'no_conflict_scripts' ) );
- add_filter( 'gform_noconflict_styles', array( $this, 'no_conflict_styles' ) );
+ add_filter( 'gform_noconflict_scripts', [ $this, 'no_conflict_scripts' ] );
+ add_filter( 'gform_noconflict_styles', [ $this, 'no_conflict_styles' ] );
- \add_filter( 'gform_payment_statuses', array( $this, 'gform_payment_statuses' ) );
+ \add_filter( 'gform_payment_statuses', [ $this, 'gform_payment_statuses' ] );
$this->maybe_display_confirmation();
}
@@ -200,14 +198,14 @@ public function admin_enqueue_scripts() {
wp_register_style(
'pronamic-pay-gravityforms',
plugins_url( 'css/admin' . $min . '.css', dirname( __FILE__ ) ),
- array(),
+ [],
$this->get_version()
);
wp_register_script(
'pronamic-pay-gravityforms',
plugins_url( 'js/admin' . $min . '.js', dirname( __FILE__ ) ),
- array( 'jquery' ),
+ [ 'jquery' ],
$this->get_version(),
true
);
@@ -278,7 +276,7 @@ public function source_text( $text, Payment $payment ) {
$text .= sprintf(
false === $entry ? '%2$s' : '%2$s',
- add_query_arg( array( 'pronamic_gf_lid' => $payment->get_source_id() ), admin_url( 'admin.php' ) ),
+ add_query_arg( [ 'pronamic_gf_lid' => $payment->get_source_id() ], admin_url( 'admin.php' ) ),
/* translators: %s: source id */
sprintf( __( 'Entry #%s', 'pronamic_ideal' ), $payment->get_source_id() )
);
@@ -311,9 +309,9 @@ public function source_url( $url, Payment $payment ) {
if ( false !== $entry ) {
$url = add_query_arg(
- array(
+ [
'pronamic_gf_lid' => $payment->get_source_id(),
- ),
+ ],
admin_url( 'admin.php' )
);
}
@@ -336,7 +334,7 @@ public function subscription_source_text( $text, Subscription $subscription ) {
$text .= sprintf(
false === $entry ? '%2$s' : '%2$s',
- add_query_arg( array( 'pronamic_gf_lid' => $subscription->get_source_id() ), admin_url( 'admin.php' ) ),
+ add_query_arg( [ 'pronamic_gf_lid' => $subscription->get_source_id() ], admin_url( 'admin.php' ) ),
/* translators: %s: source id */
sprintf( __( 'Entry #%s', 'pronamic_ideal' ), $subscription->get_source_id() )
);
@@ -369,9 +367,9 @@ public function subscription_source_url( $url, Subscription $subscription ) {
if ( false !== $entry ) {
$url = add_query_arg(
- array(
+ [
'pronamic_gf_lid' => $subscription->get_source_id(),
- ),
+ ],
admin_url( 'admin.php' )
);
}
@@ -454,10 +452,10 @@ private function maybe_update_payment_user( $lead, $feed ) {
// Update payment post author.
wp_update_post(
- array(
+ [
'ID' => $payment->get_id(),
'post_author' => $user->ID,
- )
+ ]
);
// Update subscription customer user ID and post author.
@@ -475,10 +473,10 @@ private function maybe_update_payment_user( $lead, $feed ) {
// Update subscription post author.
wp_update_post(
- array(
+ [
'ID' => $subscription->get_id(),
'post_author' => $user->ID,
- )
+ ]
);
}
}
@@ -554,10 +552,10 @@ public function redirect_url( $url, $payment ) {
$url = $confirmation['redirect'];
} else {
$url = add_query_arg(
- array(
+ [
'pay_confirmation' => $payment->get_id(),
'_wpnonce' => wp_create_nonce( 'gf_confirmation_payment_' . $payment->get_id() ),
- ),
+ ],
$lead['source_url']
);
}
@@ -593,12 +591,12 @@ public function update_status( Payment $payment, $can_redirect = false ) {
$data = new PaymentData( $form, $lead, $feed );
- $action = array(
+ $action = [
'id' => $payment->get_id(),
'transaction_id' => $payment->get_transaction_id(),
'amount' => $payment->get_total_amount()->get_value(),
'entry_id' => $lead['id'],
- );
+ ];
// Get subscription ID from payment period.
$periods = $payment->get_periods();
@@ -731,7 +729,7 @@ public function update_payment( Payment $payment ) {
$result = $this->addon->refund_payment(
$entry,
- array(
+ [
// The Gravity Forms payment add-on callback feature uses the action ID to prevent processing an action twice.
'id' => '',
'type' => 'refund_payment',
@@ -760,7 +758,7 @@ public function update_payment( Payment $payment ) {
\__( 'Payment has been (partially) refunded. Amount: %s.', 'pronamic_ideal' ),
$diff_amount->format_i18n()
),
- )
+ ]
);
if ( true === $result ) {
@@ -803,12 +801,12 @@ public function subscription_update_status( Subscription $subscription ) {
}
// Action.
- $action = array(
+ $action = [
'id' => $subscription->get_id(),
'subscription_id' => $subscription->get_id(),
'amount' => $amount,
'entry_id' => $lead['id'],
- );
+ ];
switch ( $subscription->get_status() ) {
case SubscriptionStatus::ACTIVE:
@@ -868,12 +866,12 @@ public function subscription_renewal_notice( Subscription $subscription ) {
$amount = $current_phase->get_amount()->get_value();
}
- $action = array(
+ $action = [
'subscription_id' => $subscription->get_id(),
'amount' => $amount,
'entry_id' => $lead['id'],
'type' => 'renew_subscription',
- );
+ ];
$this->addon->post_payment_action( $lead, $action );
}
@@ -1048,7 +1046,7 @@ public function fulfill_order( $entry ) {
// Delay notifications.
// Determine if the feed has Gravity Form 1.7 Feed IDs.
if ( $feed->has_delayed_notifications() ) {
- $delay_notification_ids = array();
+ $delay_notification_ids = [];
foreach ( $feed->delay_notification_ids as $notification_id ) {
if ( ! isset( $form['notifications'][ $notification_id ] ) ) {
@@ -1139,12 +1137,12 @@ public function maybe_display_confirmation() {
$form = GFAPI::get_form( $lead['form_id'] );
- GFFormDisplay::$submission[ $form['id'] ] = array(
+ GFFormDisplay::$submission[ $form['id'] ] = [
'is_confirmation' => true,
'confirmation_message' => $confirmation,
'form' => $form,
'lead' => $lead,
- );
+ ];
}
}
@@ -1172,7 +1170,7 @@ public function get_confirmation( $lead, $payment_status = PaymentStatus::OPEN )
$confirmation_id = $feed->links[ $link ]['confirmation_id'];
if ( isset( $form['confirmations'][ $confirmation_id ] ) ) {
- $form['confirmations'] = array_intersect_key( $form['confirmations'], array( $confirmation_id => true ) );
+ $form['confirmations'] = array_intersect_key( $form['confirmations'], [ $confirmation_id => true ] );
}
}
@@ -1271,16 +1269,16 @@ public function replace_merge_tags( $text, $form, $entry, $url_encode, $esc_html
if ( null !== $payment ) {
$pay_again_url = \add_query_arg(
- array(
+ [
'pay_again' => $payment->get_id(),
'key' => $payment->key,
- ),
+ ],
rgar( $entry, 'source_url' )
);
}
// Replacements.
- $replacements = array(
+ $replacements = [
'{payment_status}' => rgar( $entry, 'payment_status' ),
'{payment_date}' => rgar( $entry, 'payment_date' ),
'{transaction_id}' => rgar( $entry, 'transaction_id' ),
@@ -1300,7 +1298,7 @@ public function replace_merge_tags( $text, $form, $entry, $url_encode, $esc_html
'{pronamic_subscription_cancel_url}' => $subscription_cancel_url,
'{pronamic_subscription_renew_url}' => $subscription_renew_url,
'{pronamic_subscription_renewal_date}' => $subscription_renewal_date,
- );
+ ];
if ( $url_encode ) {
foreach ( $replacements as &$value ) {
@@ -1313,142 +1311,119 @@ public function replace_merge_tags( $text, $form, $entry, $url_encode, $esc_html
return $text;
}
- /**
- * Filter currencies.
- *
- * @param array $currencies Available currencies.
- *
- * @return mixed
- */
- public static function currencies( $currencies ) {
- if ( PaymentMethods::is_active( PaymentMethods::GULDEN ) ) {
- $currencies['NLG'] = array(
- 'name' => PaymentMethods::get_name( PaymentMethods::GULDEN ),
- 'symbol_left' => 'G',
- 'symbol_right' => '',
- 'symbol_padding' => ' ',
- 'thousand_separator' => '',
- 'decimal_separator' => '.',
- 'decimals' => 4,
- );
- }
-
- return $currencies;
- }
-
/**
* Get delay actions based on active addons and built-in delay support.
*
* @return array
*/
public static function get_delay_actions() {
- $actions = array(
- 'gravityformsactivecampaign' => array(
+ $actions = [
+ 'gravityformsactivecampaign' => [
'active' => false,
'meta_key_suffix' => 'activecampaign_subscription',
'delayed_payment_integration' => true,
'label' => __( 'Subscribing the user to ActiveCampaign', 'pronamic_ideal' ),
- ),
- 'gravityformsaweber' => array(
+ ],
+ 'gravityformsaweber' => [
'active' => false,
'meta_key_suffix' => 'aweber_subscription',
'delayed_payment_integration' => true,
'label' => __( 'Subscribing the user to AWeber', 'pronamic_ideal' ),
'delay_callback' => function() {
// @link https://github.com/wp-premium/gravityformsaweber/blob/1.4.2/aweber.php#L124-L125
- \remove_action( 'gform_post_submission', array( 'GFAWeber', 'export' ), 10 );
+ \remove_action( 'gform_post_submission', [ 'GFAWeber', 'export' ], 10 );
},
'process_callback' => function( $entry, $form ) {
if ( Core_Util::class_method_exists( 'GFAWeber', 'export' ) ) {
- call_user_func( array( 'GFAWeber', 'export' ), $entry, $form, false );
+ call_user_func( [ 'GFAWeber', 'export' ], $entry, $form, false );
}
},
- ),
- 'gravityformscampaignmonitor' => array(
+ ],
+ 'gravityformscampaignmonitor' => [
'active' => false,
'meta_key_suffix' => 'campaignmonitor_subscription',
'delayed_payment_integration' => true,
'label' => __( 'Subscribing the user to Campaign Monitor', 'pronamic_ideal' ),
'delay_callback' => function() {
// @link https://github.com/wp-premium/gravityformscampaignmonitor/blob/2.5.1/campaignmonitor.php#L124-L125
- \remove_action( 'gform_after_submission', array( 'GFCampaignMonitor', 'export' ), 10 );
+ \remove_action( 'gform_after_submission', [ 'GFCampaignMonitor', 'export' ], 10 );
},
'process_callback' => function( $entry, $form ) {
// @link https://github.com/wp-premium/gravityformscampaignmonitor/blob/2.5.1/campaignmonitor.php#L1184
if ( Core_Util::class_method_exists( 'GFCampaignMonitor', 'export' ) ) {
- call_user_func( array( 'GFCampaignMonitor', 'export' ), $entry, $form, false );
+ call_user_func( [ 'GFCampaignMonitor', 'export' ], $entry, $form, false );
}
},
- ),
- 'gravityformsmailchimp' => array(
+ ],
+ 'gravityformsmailchimp' => [
'active' => false,
'meta_key_suffix' => 'mailchimp_subscription',
'delayed_payment_integration' => true,
'label' => __( 'Subscribing the user to MailChimp', 'pronamic_ideal' ),
'delay_callback' => function() {
// @link https://github.com/wp-premium/gravityformsmailchimp/blob/2.4.1/mailchimp.php#L120-L121
- \remove_action( 'gform_after_submission', array( 'GFMailChimp', 'export' ), 10 );
+ \remove_action( 'gform_after_submission', [ 'GFMailChimp', 'export' ], 10 );
},
'process_callback' => function( $entry, $form ) {
// @link https://github.com/wp-premium/gravityformsmailchimp/blob/2.4.5/mailchimp.php#L1512.
if ( Core_Util::class_method_exists( 'GFMailChimp', 'export' ) ) {
- call_user_func( array( 'GFMailChimp', 'export' ), $entry, $form, false );
+ call_user_func( [ 'GFMailChimp', 'export' ], $entry, $form, false );
}
},
- ),
- 'slicedinvoices' => array(
+ ],
+ 'slicedinvoices' => [
'active' => false,
'meta_key_suffix' => 'sliced_invoices',
'delayed_payment_integration' => false,
'label' => __( 'Creating quotes and invoices with Sliced Invoices', 'pronamic_ideal' ),
- ),
- 'gravityforms-moneybird' => array(
+ ],
+ 'gravityforms-moneybird' => [
'active' => false,
'meta_key_suffix' => 'moneybird',
'delayed_payment_integration' => false,
'label' => __( 'Sending estimates and invoices with Moneybird', 'pronamic_ideal' ),
- ),
- 'gravityformstwilio' => array(
+ ],
+ 'gravityformstwilio' => [
'active' => false,
'meta_key_suffix' => 'twilio',
'delayed_payment_integration' => true,
'label' => __( 'Sending data to Twilio', 'pronamic_ideal' ),
- ),
- 'gravityformswebhooks' => array(
+ ],
+ 'gravityformswebhooks' => [
'active' => false,
'meta_key_suffix' => 'webhooks',
'delayed_payment_integration' => false,
'label' => __( 'Sending a trigger to Webhooks', 'pronamic_ideal' ),
- ),
- 'gravityformsdropbox' => array(
+ ],
+ 'gravityformsdropbox' => [
'active' => false,
'meta_key_suffix' => 'dropbox',
'delayed_payment_integration' => false,
'label' => __( 'Uploading files to Dropbox', 'pronamic_ideal' ),
- ),
- 'gravityformszapier' => array(
+ ],
+ 'gravityformszapier' => [
'active' => class_exists( 'GFZapier' ),
'meta_key_suffix' => 'zapier',
'delayed_payment_integration' => false,
'label' => __( 'Sending data to Zapier', 'pronamic_ideal' ),
'delay_callback' => function() {
// @link https://github.com/wp-premium/gravityformszapier/blob/1.4.2/zapier.php#L106
- remove_action( 'gform_after_submission', array( 'GFZapier', 'send_form_data_to_zapier' ), 10 );
+ remove_action( 'gform_after_submission', [ 'GFZapier', 'send_form_data_to_zapier' ], 10 );
},
'process_callback' => function( $entry, $form ) {
// @link https://github.com/wp-premium/gravityformszapier/blob/1.4.2/zapier.php#L469-L533.
if ( Core_Util::class_method_exists( 'GFZapier', 'send_form_data_to_zapier' ) ) {
- call_user_func( array( 'GFZapier', 'send_form_data_to_zapier' ), $entry, $form );
+ call_user_func( [ 'GFZapier', 'send_form_data_to_zapier' ], $entry, $form );
}
},
- ),
- 'gravityformsuserregistration' => array(
+ ],
+ 'gravityformsuserregistration' => [
'active' => false,
'meta_key_suffix' => 'user_registration',
'delayed_payment_integration' => true,
'label' => __( 'Registering the user', 'pronamic_ideal' ),
- ),
- 'gravityflow' => array(
+ ],
+ 'gravityflow' => [
'active' => false,
'meta_key_suffix' => 'gravityflow',
'delayed_payment_integration' => true,
@@ -1464,19 +1439,19 @@ public static function get_delay_actions() {
$gravityflow->process_workflow( $form, $entry['id'] );
}
},
- ),
- );
+ ],
+ ];
$addons = GFAddOn::get_registered_addons();
foreach ( $addons as $class ) {
- $addon = call_user_func( array( $class, 'get_instance' ) );
+ $addon = call_user_func( [ $class, 'get_instance' ] );
$slug = $addon->get_slug();
if ( isset( $addon->delayed_payment_integration ) ) {
if ( ! isset( $actions[ $slug ] ) ) {
- $actions[ $slug ] = array();
+ $actions[ $slug ] = [];
}
$actions[ $slug ]['meta_key_suffix'] = $slug;
@@ -1544,7 +1519,7 @@ public function maybe_prepopulate_form( $args ) {
}
// Set field values.
- $field_values = array();
+ $field_values = [];
foreach ( $entry as $key => $value ) {
$is_numeric = \is_numeric( $key );
diff --git a/src/FeedsDB.php b/src/FeedsDB.php
index 62e7d05..cdcd2e8 100644
--- a/src/FeedsDB.php
+++ b/src/FeedsDB.php
@@ -32,25 +32,25 @@ class FeedsDB {
* @param array $meta Meta query array.
* @return PayFeed[]
*/
- public static function get_feeds_by_form_id( $form_id, $meta = array() ) {
- $feeds = array();
+ public static function get_feeds_by_form_id( $form_id, $meta = [] ) {
+ $feeds = [];
- $meta_query = array(
- array(
+ $meta_query = [
+ [
'key' => '_pronamic_pay_gf_form_id',
'value' => $form_id,
- ),
- );
+ ],
+ ];
$meta_query = array_merge( $meta_query, $meta );
$query = new WP_Query(
- array(
+ [
'fields' => 'ids',
'post_type' => 'pronamic_pay_gf',
'posts_per_page' => 50,
'meta_query' => $meta_query,
- )
+ ]
);
foreach ( $query->posts as $post_id ) {
@@ -69,19 +69,19 @@ public static function get_feeds_by_form_id( $form_id, $meta = array() ) {
* @return array
*/
public static function get_active_feeds_by_form_id( $form_id ) {
- $meta = array(
- array(
+ $meta = [
+ [
'relation' => 'OR',
- array(
+ [
'key' => '_pronamic_pay_gf_feed_active',
'value' => 1,
- ),
- array(
+ ],
+ [
'key' => '_pronamic_pay_gf_feed_active',
'compare' => 'NOT EXISTS',
- ),
- ),
- );
+ ],
+ ],
+ ];
$feeds = self::get_feeds_by_form_id( $form_id, $meta );
diff --git a/src/Fields.php b/src/Fields.php
index 0b0a14b..890b6af 100644
--- a/src/Fields.php
+++ b/src/Fields.php
@@ -52,7 +52,7 @@ public function __construct() {
}
// Add extra fields settings.
- add_action( 'gform_field_standard_settings', array( $this, 'field_standard_settings' ), 10, 2 );
+ add_action( 'gform_field_standard_settings', [ $this, 'field_standard_settings' ], 10, 2 );
}
/**
@@ -67,11 +67,11 @@ public function __construct() {
*/
public static function add_pay_field_group( $field_groups ) {
if ( ! isset( $field_groups['pronamic_pay_fields'] ) ) {
- $field_groups['pronamic_pay_fields'] = array(
+ $field_groups['pronamic_pay_fields'] = [
'name' => 'pronamic_pay_fields',
'label' => __( 'Payment Fields', 'pronamic_ideal' ),
- 'fields' => array(),
- );
+ 'fields' => [],
+ ];
}
return $field_groups;
diff --git a/src/IssuersField.php b/src/IssuersField.php
index 7682c96..ef18169 100644
--- a/src/IssuersField.php
+++ b/src/IssuersField.php
@@ -12,6 +12,7 @@
use GF_Field_Select;
use Pronamic\WordPress\Pay\Core\Gateway;
+use Pronamic\WordPress\Pay\Fields\IDealIssuerSelectField;
use Pronamic\WordPress\Pay\Core\PaymentMethods;
use Pronamic\WordPress\Pay\Plugin;
@@ -49,12 +50,12 @@ class IssuersField extends GF_Field_Select {
*
* @param array $properties Properties.
*/
- public function __construct( $properties = array() ) {
+ public function __construct( $properties = [] ) {
parent::__construct( $properties );
// Actions.
- if ( ! has_action( 'gform_editor_js_set_default_values', array( __CLASS__, 'editor_js_set_default_values' ) ) ) {
- add_action( 'gform_editor_js_set_default_values', array( __CLASS__, 'editor_js_set_default_values' ) );
+ if ( ! has_action( 'gform_editor_js_set_default_values', [ __CLASS__, 'editor_js_set_default_values' ] ) ) {
+ add_action( 'gform_editor_js_set_default_values', [ __CLASS__, 'editor_js_set_default_values' ] );
}
if (
@@ -86,7 +87,7 @@ public function __construct( $properties = array() ) {
$this->cssClass .= ' pronamic_pay_display_icons';
}
- if ( false === strpos( $this->cssClass, 'gf_list_2col' ) && in_array( $this->pronamicPayDisplayMode, array( 'icons-64', 'icons-125' ), true ) ) {
+ if ( false === strpos( $this->cssClass, 'gf_list_2col' ) && in_array( $this->pronamicPayDisplayMode, [ 'icons-64', 'icons-125' ], true ) ) {
$this->cssClass .= ' gf_list_2col';
}
}
@@ -99,7 +100,7 @@ public function __construct( $properties = array() ) {
* @return array
*/
public function get_form_editor_field_settings() {
- return array(
+ return [
'conditional_logic_field_setting',
'error_message_setting',
'enable_enhanced_ui_setting',
@@ -113,7 +114,7 @@ public function get_form_editor_field_settings() {
'rules_setting',
'pronamic_pay_config_field_setting',
'pronamic_pay_display_field_setting',
- );
+ ];
}
/**
@@ -139,15 +140,24 @@ private function get_gateway() {
$gateway = Plugin::get_gateway( $feed->config_id );
- if ( $gateway ) {
- $issuers = $gateway->get_transient_issuers();
+ if ( null === $gateway ) {
+ continue;
+ }
- if ( empty( $issuers ) ) {
- continue;
- }
+ // Always use iDEAL payment method for issuer field.
+ $issuer_field = $gateway->first_payment_method_field( PaymentMethods::IDEAL, IDealIssuerSelectField::class );
+
+ if ( null === $issuer_field ) {
+ continue;
+ }
+
+ $options = $issuer_field->get_options();
- return $gateway;
+ if ( 1 === count( $options ) ) {
+ continue;
}
+
+ return $gateway;
}
}
@@ -160,7 +170,7 @@ private function get_gateway() {
* @param int $form_id Gravity Forms form ID.
*/
private function set_choices( $form_id ) {
- $this->choices = array();
+ $this->choices = [];
// Prevent HTTP requests in forms list.
if ( \doing_filter( 'gform_form_actions' ) ) {
@@ -174,21 +184,24 @@ private function set_choices( $form_id ) {
}
// Always use iDEAL payment method for issuer field.
- $gateway->set_payment_method( PaymentMethods::IDEAL );
+ $issuer_field = $gateway->first_payment_method_field( PaymentMethods::IDEAL, IDealIssuerSelectField::class );
- $field = $gateway->get_issuer_field();
-
- if ( null === $field ) {
+ if ( null === $issuer_field ) {
return;
}
- foreach ( $field['choices'] as $group ) {
- foreach ( $group['options'] as $value => $label ) {
- $this->choices[] = array(
- 'value' => $value,
- 'text' => $label,
- );
- }
+ /**
+ * Gravity Forms has no support for