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

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