PluginProbe
JetFormBuilder — Dynamic Blocks Form Builder / 3.6.3
JetFormBuilder — Dynamic Blocks Form Builder v3.6.3
3.6.5.2 3.6.5.1 3.6.5 3.6.4.2 3.6.4.1 3.6.4 3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 All 130 releases
jetformbuilder / modules / gateways / export / single-controller.php
single-controller.php
64 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3
4 namespace JFB_Modules\Gateways\Export;
5
6 use JFB_Modules\Gateways\Query_Views\Payment_For_Export_View;
7
8 // If this file is called directly, abort.
9 if ( ! defined( 'WPINC' ) ) {
10 die;
11 }
12
13
14 class Single_Controller extends Base_Export_Controller {
15
16 /**
17 * @throws \Exception
18 */
19 public function do_export() {
20 $payment_id = $this->get_payment_id();
21 $payment_view = Payment_For_Export_View::find( array( 'id' => $payment_id ) );
22 $payment_view->set_select( array_keys( $this->columns ) );
23
24 $payment = $payment_view->set_limit( array( 1 ) )->query()->query_one();
25
26 $this->get_exporter()->set_title(
27 /* translators: %d - record ID */
28 sprintf( __( 'JFB Payment %d', 'jet-form-builder' ), $payment_id )
29 );
30 $this->get_exporter()->open();
31
32 // headings
33 $this->get_exporter()->add_row(
34 $this->prepare_row(
35 $this->columns,
36 $this->record_columns,
37 $this->payers_columns,
38 $this->shipping_columns
39 )
40 );
41
42 $this->add_row( $payment );
43 $this->get_exporter()->close();
44 die;
45 }
46
47 /**
48 * @return int
49 * @throws \Exception
50 */
51 protected function get_payment_id(): int {
52 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
53 $payment_id = absint( $_GET['id'] ?? '' );
54
55 if ( ! $payment_id ) {
56 throw new \Exception(
57 esc_html__( 'Payment ID is empty', 'jet-form-builder' )
58 );
59 }
60
61 return $payment_id;
62 }
63 }
64