From b5227a6c7583e3e2a320ed3bd8aa1c075ed46a04 Mon Sep 17 00:00:00 2001 From: "Soare Robert Daniel (Mac 2023)" Date: Thu, 3 Aug 2023 15:37:55 +0300 Subject: [PATCH] chore: add automatic confirmation cron --- .fleet/settings.json | 3 + inc/server/class-form-server.php | 6 +- .../inc/plugins/class-form-emails-storing.php | 173 ++++++++++++++++-- .../inc/plugins/class-form-pro-features.php | 9 +- src/blocks/frontend/form/index.js | 6 +- 5 files changed, 173 insertions(+), 24 deletions(-) create mode 100644 .fleet/settings.json diff --git a/.fleet/settings.json b/.fleet/settings.json new file mode 100644 index 000000000..b88a2e69b --- /dev/null +++ b/.fleet/settings.json @@ -0,0 +1,3 @@ +{ + "toolchains": [] +} \ No newline at end of file diff --git a/inc/server/class-form-server.php b/inc/server/class-form-server.php index e9af9bde7..89da9ba0e 100644 --- a/inc/server/class-form-server.php +++ b/inc/server/class-form-server.php @@ -186,9 +186,9 @@ public function register_routes() { array( array( 'methods' => WP_REST_Server::READABLE, - 'callback' => array( $this, 'confirm_form' ), + 'callback' => array( $this, 'confirm_form_submission'), 'permission_callback' => function ( $request ) { - $session = $request->get_param( 'stripe_session_id' ); + $session = $request->get_param( 'stripe_checkout' ); if ( apply_filters( 'otter_form_session_confirmation', $session ) ) { return __return_true(); @@ -331,7 +331,7 @@ public function frontend( $request ) { * @param WP_REST_Request $request Form request. * @return WP_Error|WP_HTTP_Response|WP_REST_Response */ - public function confirm_form( $request ) { + public function confirm_form_submission( $request ) { $response = new Form_Data_Response(); diff --git a/plugins/otter-pro/inc/plugins/class-form-emails-storing.php b/plugins/otter-pro/inc/plugins/class-form-emails-storing.php index 617063f2c..1b186c33d 100644 --- a/plugins/otter-pro/inc/plugins/class-form-emails-storing.php +++ b/plugins/otter-pro/inc/plugins/class-form-emails-storing.php @@ -73,6 +73,12 @@ public function init() { add_action( 'save_post', array( $this, 'form_record_save_meta_box' ), 10, 2 ); add_filter( 'otter_form_record_confirm', array( $this, 'confirm_submission' ), 10, 2 ); + + add_action( 'transition_post_status', array( $this, 'apply_hooks_on_draft_transition' ), 10, 3 ); + add_action( 'otter_form_update_record_meta_dump', array( $this, 'update_submission_dump_data' ), 10, 2 ); + add_action( 'otter_form_automatic_confirmation', array( $this, 'move_old_stripe_draft_sessions_to_unread' ) ); + add_filter( 'cron_schedules', array( $this, 'form_confirmation_schedule' ) ); + add_action( 'wp', array( $this, 'schedule_automatic_confirmation' ) ); } /** @@ -716,13 +722,24 @@ public function fields_meta_box_markup( $post ) { $meta = get_post_meta( $post->ID, self::FORM_RECORD_META_KEY, true ); $previous_field_option = ''; + if ( empty( $meta ) ) { return; } + + $inputs = array(); + foreach ( $meta['inputs'] as $id => $field ) { + if ( empty( $field ) || 'stripe-field' === $field['type'] ) { + continue; + } + + $inputs[ $id ] = $field; + } + ?> - $field ) { ?> + $field ) { ?>