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

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