PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.7
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.7
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
formidable / stripe / controllers / FrmTransLiteListsController.php

FrmTransLiteListsController.php in Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More 6.7, at stripe/controllers/FrmTransLiteListsController.php

178 lines 4.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 die( 'You are not allowed to call this page directly.' );
4 }
5
6 class FrmTransLiteListsController {
7
8 /**
9 * @return void
10 */
11 public static function add_list_hooks() {
12 if ( FrmTransLiteAppHelper::should_fallback_to_paypal() ) {
13 return;
14 }
15
16 $hook_name = 'manage_' . sanitize_title( FrmAppHelper::get_menu_name() ) . '_page_formidable-payments_columns';
17 add_filter( $hook_name, __CLASS__ . '::payment_columns' );
18 add_filter( 'screen_options_show_screen', __CLASS__ . '::remove_screen_options', 10, 2 );
19 }
20
21 /**
22 * @param array $columns
23 * @return array
24 */
25 public static function payment_columns( $columns = array() ) {
26 add_screen_option(
27 'per_page',
28 array(
29 'label' => esc_html__( 'Payments', 'formidable' ),
30 'default' => 20,
31 'option' => 'formidable_page_formidable_payments_per_page',
32 )
33 );
34
35 $type = FrmAppHelper::get_simple_request(
36 array(
37 'param' => 'trans_type',
38 'type' => 'request',
39 'default' => 'payments',
40 )
41 );
42
43 $columns['cb'] = '<input type="checkbox" />';
44 $columns['user_id'] = esc_html__( 'Customer', 'formidable' );
45
46 if ( 'subscriptions' === $type ) {
47 $add_columns = array(
48 'sub_id' => esc_html__( 'Profile ID', 'formidable' ),
49 'item_id' => esc_html__( 'Entry', 'formidable' ),
50 'form_id' => esc_html__( 'Form', 'formidable' ),
51 'amount' => esc_html__( 'Billing Cycle', 'formidable' ),
52 'end_count' => esc_html__( 'Payments Made', 'formidable' ),
53 'next_bill_date' => esc_html__( 'Next Bill Date', 'formidable' ),
54 );
55 } else {
56 $add_columns = array(
57 'receipt_id' => esc_html__( 'Receipt ID', 'formidable' ),
58 'item_id' => esc_html__( 'Entry', 'formidable' ),
59 'form_id' => esc_html__( 'Form', 'formidable' ),
60 'amount' => esc_html__( 'Amount', 'formidable' ),
61 'sub_id' => esc_html__( 'Subscription', 'formidable' ),
62 'begin_date' => esc_html__( 'Begin Date', 'formidable' ),
63 'expire_date' => esc_html__( 'Expire Date', 'formidable' ),
64 );
65 }
66
67 $columns = $columns + $add_columns;
68
69 $columns['status'] = esc_html__( 'Status', 'formidable' );
70 $columns['created_at'] = esc_html__( 'Date', 'formidable' );
71
72 $paypal_is_active = class_exists( 'FrmPaymentsController', false );
73 if ( $paypal_is_active ) {
74 $columns['paysys'] = esc_html__( 'Processor', 'formidable' );
75 }
76
77 $columns['mode'] = esc_html__( 'Mode', 'formidable' );
78
79 return $columns;
80 }
81
82 /**
83 * Prevent the "screen options" tab from showing when
84 * viewing a payment or subscription
85 *
86 * @since 6.5
87 */
88 public static function remove_screen_options( $show_screen, $screen ) {
89 if ( ! in_array( FrmAppHelper::simple_get( 'action', 'sanitize_title' ), array( 'edit', 'show', 'new', 'duplicate' ), true ) ) {
90 return $show_screen;
91 }
92
93 $menu_name = sanitize_title( FrmAppHelper::get_menu_name() );
94 if ( $screen->id === $menu_name . '_page_formidable-payments' ) {
95 $show_screen = false;
96 }
97
98 return $show_screen;
99 }
100
101 /**
102 * Handle payment/subscription list routing.
103 *
104 * @param string $action
105 * @return void
106 */
107 public static function route( $action ) {
108 self::display_list();
109 }
110
111 /**
112 * @return array
113 */
114 public static function list_page_params() {
115 $values = array();
116 foreach ( array(
117 'id' => '',
118 'paged' => 1,
119 'form' => '',
120 'search' => '',
121 'sort' => '',
122 'sdir' => '',
123 ) as $var => $default ) {
124 $values[ $var ] = FrmAppHelper::get_param( $var, $default );
125 }
126
127 return $values;
128 }
129
130 /**
131 * Display a list.
132 *
133 * @param array $response
134 * @return void
135 */
136 public static function display_list( $response = array() ) {
137 FrmAppHelper::include_svg();
138
139 $defaults = array(
140 'errors' => array(),
141 'message' => '',
142 );
143 $response = array_merge( $defaults, $response );
144 $errors = $response['errors'];
145 $message = $response['message'];
146
147 $wp_list_table = new FrmTransLiteListHelper( self::list_page_params() );
148
149 $pagenum = $wp_list_table->get_pagenum();
150
151 $wp_list_table->prepare_items();
152
153 $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
154 if ( $pagenum > $total_pages && $total_pages > 0 ) {
155 // if the current page is higher than the total pages,
156 // reset it and prepare again to get the right entries
157 $_GET['paged'] = $total_pages;
158 $_REQUEST['paged'] = $total_pages;
159 $pagenum = $wp_list_table->get_pagenum();
160 $wp_list_table->prepare_items();
161 }
162
163 include FrmTransLiteAppHelper::plugin_path() . '/views/lists/list.php';
164 }
165
166 /**
167 * @param mixed $save
168 * @param string $option
169 * @param int $value
170 */
171 public static function save_per_page( $save, $option, $value ) {
172 if ( $option === 'formidable_page_formidable_payments_per_page' ) {
173 $save = absint( $value );
174 }
175 return $save;
176 }
177 }
178