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

186 lines 5.0 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
74 $paypal_is_active = class_exists( 'FrmPaymentsController', false );
75 if ( $paypal_is_active ) {
76 $columns['paysys'] = esc_html__( 'Processor', 'formidable' );
77 }
78
79 $columns['mode'] = esc_html__( 'Mode', 'formidable' );
80
81 return $columns;
82 }
83
84 /**
85 * Prevent the "screen options" tab from showing when
86 * viewing a payment or subscription
87 *
88 * @since 6.5
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
97 $unread_count = FrmEntriesHelper::get_visible_unread_inbox_count();
98 if ( $unread_count ) {
99 $menu_name .= '-' . $unread_count;
100 }
101
102 if ( $screen->id === $menu_name . '_page_formidable-payments' ) {
103 $show_screen = false;
104 }
105
106 return $show_screen;
107 }
108
109 /**
110 * Handle payment/subscription list routing.
111 *
112 * @param string $action
113 * @return void
114 */
115 public static function route( $action ) {
116 self::display_list();
117 }
118
119 /**
120 * @return array
121 */
122 public static function list_page_params() {
123 $values = array();
124 foreach ( array(
125 'id' => '',
126 'paged' => 1,
127 'form' => '',
128 'search' => '',
129 'sort' => '',
130 'sdir' => '',
131 ) as $var => $default ) {
132 $values[ $var ] = FrmAppHelper::get_param( $var, $default );
133 }
134
135 return $values;
136 }
137
138 /**
139 * Display a list.
140 *
141 * @param array $response
142 * @return void
143 */
144 public static function display_list( $response = array() ) {
145 FrmAppHelper::include_svg();
146
147 $defaults = array(
148 'errors' => array(),
149 'message' => '',
150 );
151 $response = array_merge( $defaults, $response );
152 $errors = $response['errors'];
153 $message = $response['message'];
154
155 $wp_list_table = new FrmTransLiteListHelper( self::list_page_params() );
156
157 $pagenum = $wp_list_table->get_pagenum();
158
159 $wp_list_table->prepare_items();
160
161 $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
162 if ( $pagenum > $total_pages && $total_pages > 0 ) {
163 // if the current page is higher than the total pages,
164 // reset it and prepare again to get the right entries.
165 $_GET['paged'] = $total_pages;
166 $_REQUEST['paged'] = $total_pages;
167 $pagenum = $wp_list_table->get_pagenum();
168 $wp_list_table->prepare_items();
169 }
170
171 include FrmTransLiteAppHelper::plugin_path() . '/views/lists/list.php';
172 }
173
174 /**
175 * @param mixed $save
176 * @param string $option
177 * @param int $value
178 */
179 public static function save_per_page( $save, $option, $value ) {
180 if ( $option === 'formidable_page_formidable_payments_per_page' ) {
181 $save = absint( $value );
182 }
183 return $save;
184 }
185 }
186