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

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