PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.33.1
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.33.1
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.33.1, at stripe/controllers/FrmTransLiteListsController.php

215 lines 5.8 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 $unread_count = FrmEntriesHelper::get_visible_unread_inbox_count();
13 $hook_name = 'manage_' . sanitize_title( FrmAppHelper::get_menu_name() ) . ( $unread_count ? '-' . $unread_count : '' ) . '_page_formidable-payments_columns';
14
15 add_filter( $hook_name, self::class . '::payment_columns' );
16 add_filter( 'screen_options_show_screen', self::class . '::remove_screen_options', 10, 2 );
17 }
18
19 /**
20 * @param array $columns
21 *
22 * @return array
23 */
24 public static function payment_columns( $columns = array() ) {
25 add_screen_option(
26 'per_page',
27 array(
28 'label' => esc_html__( 'Payments', 'formidable' ),
29 'default' => 20,
30 'option' => 'formidable_page_formidable_payments_per_page',
31 )
32 );
33
34 $type = FrmAppHelper::get_simple_request(
35 array(
36 'param' => 'trans_type',
37 'type' => 'request',
38 'default' => 'payments',
39 )
40 );
41
42 $columns['cb'] = '<input type="checkbox" />';
43 $columns['user_id'] = esc_html__( 'Customer', 'formidable' );
44
45 if ( 'subscriptions' === $type ) {
46 $add_columns = array(
47 'sub_id' => esc_html__( 'Profile ID', 'formidable' ),
48 'item_id' => esc_html__( 'Entry', 'formidable' ),
49 'form_id' => esc_html__( 'Form', 'formidable' ),
50 'amount' => esc_html__( 'Billing Cycle', 'formidable' ),
51 'end_count' => esc_html__( 'Payments Made', 'formidable' ),
52 'next_bill_date' => esc_html__( 'Next Bill Date', 'formidable' ),
53 );
54 } else {
55 $add_columns = array(
56 'receipt_id' => esc_html__( 'Receipt ID', 'formidable' ),
57 'item_id' => esc_html__( 'Entry', 'formidable' ),
58 'form_id' => esc_html__( 'Form', 'formidable' ),
59 'amount' => esc_html__( 'Amount', 'formidable' ),
60 'sub_id' => esc_html__( 'Subscription', 'formidable' ),
61 'begin_date' => esc_html__( 'Begin Date', 'formidable' ),
62 'expire_date' => esc_html__( 'Expire Date', 'formidable' ),
63 );
64 }
65
66 $columns = $columns + $add_columns;
67
68 $columns['status'] = esc_html__( 'Status', 'formidable' );
69 $columns['created_at'] = esc_html__( 'Date', 'formidable' );
70 $columns['paysys'] = esc_html__( 'Processor', 'formidable' );
71
72 if ( 'bulk_delete' !== FrmAppHelper::simple_get( 'action' ) && ! class_exists( 'FrmTransListHelper' ) && class_exists( 'FrmPaymentsListHelper' ) ) {
73 $columns['mode'] = esc_html__( 'Mode', 'formidable' );
74 }
75
76 return $columns;
77 }
78
79 /**
80 * Prevent the "screen options" tab from showing when
81 * viewing a payment or subscription
82 *
83 * @since 6.5
84 *
85 * @param bool $show_screen Whether to show the screen options tab.
86 * @param object $screen The current screen.
87 *
88 * @return bool
89 */
90 public static function remove_screen_options( $show_screen, $screen ) {
91 if ( ! in_array( FrmAppHelper::simple_get( 'action', 'sanitize_title' ), array( 'edit', 'show', 'new', 'duplicate' ), true ) ) {
92 return $show_screen;
93 }
94
95 $menu_name = sanitize_title( FrmAppHelper::get_menu_name() );
96 $unread_count = FrmEntriesHelper::get_visible_unread_inbox_count();
97
98 if ( $unread_count ) {
99 $menu_name .= '-' . $unread_count;
100 }
101
102 if ( $screen->id === $menu_name . '_page_formidable-payments' ) {
103 return false;
104 }
105
106 return $show_screen;
107 }
108
109 /**
110 * Handle payment/subscription list routing.
111 *
112 * @param string $action
113 *
114 * @return void
115 */
116 public static function route( $action ) {
117 if ( 'coupons' === $action ) {
118 FrmAppHelper::permission_check( 'frm_change_settings' );
119
120 include FrmTransLiteAppHelper::plugin_path() . '/views/lists/coupons.php';
121 return;
122 }
123
124 // Show no-payments placeholder if payments table doesn't exist.
125 if ( ! FrmTransLiteAppHelper::payments_table_exists() ) {
126 include FrmTransLiteAppHelper::plugin_path() . '/views/lists/no-payments.php';
127 return;
128 }
129
130 /**
131 * @since 6.27
132 *
133 * @param bool $route_handled
134 * @param string $action
135 */
136 $route_handled = apply_filters( 'frm_trans_lite_route', false, $action );
137
138 if ( $route_handled ) {
139 return;
140 }
141
142 self::display_list();
143 }
144
145 /**
146 * @return array
147 */
148 public static function list_page_params() {
149 $values = array();
150
151 foreach ( array(
152 'id' => '',
153 'paged' => 1,
154 'form' => '',
155 'search' => '',
156 'sort' => '',
157 'sdir' => '',
158 ) as $var => $default ) {
159 $values[ $var ] = FrmAppHelper::get_param( $var, $default );
160 }
161
162 return $values;
163 }
164
165 /**
166 * Display a list.
167 *
168 * @param array $response
169 *
170 * @return void
171 */
172 public static function display_list( $response = array() ) {
173 FrmAppHelper::include_svg();
174
175 $defaults = array(
176 'errors' => array(),
177 'message' => '',
178 );
179 $response = array_merge( $defaults, $response );
180 $errors = $response['errors'];
181 $message = $response['message'];
182 $wp_list_table = new FrmTransLiteListHelper( self::list_page_params() );
183 $pagenum = $wp_list_table->get_pagenum();
184
185 $wp_list_table->prepare_items();
186
187 $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
188
189 if ( $pagenum > $total_pages && $total_pages > 0 ) {
190 // If the current page is higher than the total pages,
191 // reset it and prepare again to get the right entries.
192 $_GET['paged'] = $total_pages;
193 $_REQUEST['paged'] = $total_pages;
194 $pagenum = $wp_list_table->get_pagenum();
195 $wp_list_table->prepare_items();
196 }
197
198 include FrmTransLiteAppHelper::plugin_path() . '/views/lists/list.php';
199 }
200
201 /**
202 * @param mixed $save
203 * @param string $option
204 * @param int $value
205 *
206 * @return mixed
207 */
208 public static function save_per_page( $save, $option, $value ) {
209 if ( $option === 'formidable_page_formidable_payments_per_page' ) {
210 return absint( $value );
211 }
212 return $save;
213 }
214 }
215