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

209 lines 5.6 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 /**
125 * @since 6.27
126 *
127 * @param bool $route_handled
128 * @param string $action
129 */
130 $route_handled = apply_filters( 'frm_trans_lite_route', false, $action );
131
132 if ( $route_handled ) {
133 return;
134 }
135
136 self::display_list();
137 }
138
139 /**
140 * @return array
141 */
142 public static function list_page_params() {
143 $values = array();
144
145 foreach ( array(
146 'id' => '',
147 'paged' => 1,
148 'form' => '',
149 'search' => '',
150 'sort' => '',
151 'sdir' => '',
152 ) as $var => $default ) {
153 $values[ $var ] = FrmAppHelper::get_param( $var, $default );
154 }
155
156 return $values;
157 }
158
159 /**
160 * Display a list.
161 *
162 * @param array $response
163 *
164 * @return void
165 */
166 public static function display_list( $response = array() ) {
167 FrmAppHelper::include_svg();
168
169 $defaults = array(
170 'errors' => array(),
171 'message' => '',
172 );
173 $response = array_merge( $defaults, $response );
174 $errors = $response['errors'];
175 $message = $response['message'];
176 $wp_list_table = new FrmTransLiteListHelper( self::list_page_params() );
177 $pagenum = $wp_list_table->get_pagenum();
178
179 $wp_list_table->prepare_items();
180
181 $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
182
183 if ( $pagenum > $total_pages && $total_pages > 0 ) {
184 // If the current page is higher than the total pages,
185 // reset it and prepare again to get the right entries.
186 $_GET['paged'] = $total_pages;
187 $_REQUEST['paged'] = $total_pages;
188 $pagenum = $wp_list_table->get_pagenum();
189 $wp_list_table->prepare_items();
190 }
191
192 include FrmTransLiteAppHelper::plugin_path() . '/views/lists/list.php';
193 }
194
195 /**
196 * @param mixed $save
197 * @param string $option
198 * @param int $value
199 *
200 * @return mixed
201 */
202 public static function save_per_page( $save, $option, $value ) {
203 if ( $option === 'formidable_page_formidable_payments_per_page' ) {
204 return absint( $value );
205 }
206 return $save;
207 }
208 }
209