PluginProbe
Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More / 2.4.1
Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More v2.4.1
2.4.1 2.4.0 2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.2 2.2.1 2.2.0 2.1.2 2.1.1 trunk 0.0.1 0.0.2 0.0.3 0.0.4 0.0.5 0.0.6 0.0.7 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 All 68 releases
← All changes | includes/Admin/Settings.php +13 -546 1.0.3 → 2.4.1 View file →
@@ -1,9 +1,8 @@
1 1 <?php
2 2
3 3 namespace Better_Payment\Lite\Admin;
4 4
5 -use Better_Payment\Lite\Classes\Helper;
6 5 use Better_Payment\Lite\Controller;
7 6
8 7 /**
9 8 * Exit if accessed directly
@@ -12,248 +11,24 @@
12 11 exit;
13 12 }
14 13
15 14 /**
16 - * The plugin settings class
17 - *
15 + * Settings persistence helpers.
16 + *
17 + * This class used to render the PHP admin — the settings page, the transactions
18 + * list and single view, the analytics page — and register their AJAX handlers.
19 + * The admin is React now (Admin\ReactAdmin + API\AdminAPI) and this class was
20 + * never instantiated, so all of that was unreachable and has been removed. What
21 + * remains are the three static helpers live code still calls: the quick-setup
22 + * wizard (Setup_Wizard::save_setup_wizard_data) and the Elementor bootstrap in
23 + * better-payment.php.
24 + *
18 25 * @since 0.0.1
19 26 */
20 27 class Settings extends Controller
21 28 {
22 - // Check if pro is enabled
23 - protected $pro_enabled;
24 -
25 - var $page_slug_prefix = '';
26 -
27 29 /**
28 - * @var int|string
29 - */
30 - protected $file_version;
31 -
32 - /**
33 - * Constructor
34 - *
35 - * @since 0.0.1
36 - */
37 - public function __construct($page_slug_prefix = 'better-payment')
38 - {
39 - $this->page_slug_prefix = $page_slug_prefix;
40 - $this->file_version = defined('WP_DEBUG') && WP_DEBUG ? time() : BETTER_PAYMENT_VERSION;
41 -
42 - $this->pro_enabled = apply_filters('better_payment/pro_enabled', false);
43 -
44 - add_action('admin_menu', [$this, 'register_menu']);
45 - add_action('wp_ajax_better_payment_settings_action', [$this, 'save_settings_ajax']);
46 -
47 - //Transactions page: actions
48 - add_action('wp_ajax_better-payment-delete-transaction', [$this, 'admin_transaction_delete']);
49 - add_action('wp_ajax_better-payment-filter-transaction', [$this, 'admin_transaction_filter']);
50 - add_action('wp_ajax_better-payment-view-transaction', [$this, 'admin_transaction_view']);
51 -
52 - //EL Editor Style
53 - add_action('elementor/editor/before_enqueue_scripts', [$this, 'editor_enqueue_scripts']);
54 - }
55 -
56 - /**
57 - * Enqueue editor scripts
58 - *
59 - * @since 0.0.1
60 - */
61 - public function editor_enqueue_scripts()
62 - {
63 - // bp icon font
64 - wp_enqueue_style(
65 - 'bp-icon-admin-editor',
66 - BETTER_PAYMENT_ASSETS . '/icon/style.min.css',
67 - false
68 - );
69 - }
70 -
71 - /**
72 - * Register menu
73 - *
74 - * @since 0.0.1
75 - */
76 - public function register_menu()
77 - {
78 - add_menu_page(
79 - __('Better Payment', 'better-payment'),
80 - __('Better Payment', 'better-payment'),
81 - 'manage_options',
82 - $this->page_slug_prefix . '-settings',
83 - [$this, 'render_better_payment_admin_pages'],
84 - BETTER_PAYMENT_ASSETS . '/img/better-payment-icon-white-small.png',
85 - 64
86 - );
87 -
88 - add_submenu_page(
89 - $this->page_slug_prefix . '-settings',
90 - __('Settings', 'better-payment'),
91 - __('Settings', 'better-payment'),
92 - 'manage_options',
93 - $this->page_slug_prefix . '-settings',
94 - [$this, 'render_better_payment_admin_pages'],
95 - 64
96 - );
97 -
98 - $analyticsObj = new Analytics();
99 -
100 - $settings = apply_filters( 'better_payment/admin/get_submenu_page_list', array(
101 - $this->page_slug_prefix . '-transactions' => array(
102 - 'title' => __('Transactions', 'better-payment'),
103 - 'capability' => 'manage_options',
104 - 'callback' => [$this, 'render_better_payment_admin_pages'],
105 - ),
106 - ), $this->page_slug_prefix );
107 -
108 - if( ! $this->pro_enabled ){
109 - $settings[ $this->page_slug_prefix . '-analytics' ] = array(
110 - 'title' => __('Analytics', 'better-payment'),
111 - 'capability' => 'manage_options',
112 - 'callback' => [$analyticsObj, 'render_page'],
113 - );
114 - }
115 -
116 - foreach( $settings as $slug => $setting ) {
117 - $cap = isset( $setting['capability'] ) ? $setting['capability'] : 'manage_options';
118 - add_submenu_page( $this->page_slug_prefix . '-settings', $setting['title'], $setting['title'], $cap, $slug, $setting['callback'] );
119 - }
120 - }
121 -
122 - /**
123 - * Admin pages
124 - *
125 - * @since 0.0.1
126 - */
127 - public function render_better_payment_admin_pages()
128 - {
129 - $bp_admin_saved_settings = DB::get_settings();
130 - $bp_admin_all_transactions_count = DB::get_transaction_count();
131 - $bp_admin_completed_transactions_count = DB::get_transaction_count('', 'v2', 0, 'completed');
132 - $bp_admin_incomplete_transactions_count = DB::get_transaction_count('', 'v2', 1, 'incomplete');
133 -
134 - $template = !empty($_GET['page']) ? sanitize_text_field($_GET['page']) : 'better-payment-settings';
135 -
136 - $menuObj = new Menu();
137 - $menu_slugs = $menuObj->better_payment_menu_slugs();
138 - $template = in_array($template, $menu_slugs) ? $template : 'better-payment-settings';
139 -
140 - $transaction_pagination_args = [];
141 - $bp_admin_all_transactions_paginations = '';
142 - $viewMode = 0;
143 -
144 - if ($template == 'better-payment-transactions') {
145 - //Transactions Page
146 - $action = isset($_GET['action']) ? sanitize_text_field($_GET['action']) : 'list';
147 - $id = isset($_GET['id']) ? intval($_GET['id']) : 0;
148 - $template = 'better-payment-transaction';
149 -
150 - switch ($action) {
151 - case 'edit':
152 - $template .= '-edit';
153 - break;
154 -
155 - case 'view':
156 - $viewMode = 1;
157 - $template .= '-view';
158 - break;
159 -
160 - default:
161 - $template .= '-list';
162 - break;
163 - }
164 -
165 - $ui_postfix = '';
166 - $template .= $ui_postfix;
167 -
168 - //Pagination
169 - $transaction_pagination_paged = isset($_GET['paged']) && intval($_GET['paged']) > 1 ? intval($_GET['paged']) : 1;
170 - $transaction_pagination_order = isset($_GET['order']) ? sanitize_text_field($_GET['order']) : 'DESC';
171 - $transaction_pagination_orderby = isset($_GET['orderby']) ? sanitize_text_field($_GET['orderby']) : 'id';
172 - $transaction_pagination_per_page = isset($_GET['per_page']) ? intval($_GET['per_page']) : 20;
173 - $transaction_pagination_source = isset($_GET['source']) ? sanitize_text_field($_GET['source']) : '';
174 - $transaction_pagination_status = isset($_GET['status']) ? sanitize_text_field($_GET['status']) : 'all';
175 - $transaction_pagination_search_text = isset($_GET['search_text']) ? sanitize_text_field($_GET['search_text']) : '';
176 -
177 - if ($transaction_pagination_paged) {
178 - $args =
179 - $transaction_pagination_args = [
180 - 'search_text' => $transaction_pagination_search_text,
181 - 'per_page' => $transaction_pagination_per_page,
182 - 'paged' => $transaction_pagination_paged,
183 - 'number' => $transaction_pagination_per_page,
184 - 'offset' => ($transaction_pagination_paged - 1) * $transaction_pagination_per_page,
185 - 'orderby' => $transaction_pagination_orderby,
186 - 'order' => $transaction_pagination_order,
187 - 'status' => $transaction_pagination_status
188 - ];
189 - }
190 - $bp_admin_filtered_all_transactions_count = DB::get_transaction_count( $transaction_pagination_args, 'v2', 1);
191 - $bp_admin_filtered_all_transactions_count = $transaction_pagination_search_text ? $bp_admin_filtered_all_transactions_count : $bp_admin_all_transactions_count;
192 -
193 - $bp_admin_all_transactions_paginations = self::bp_paginate_links( $transaction_pagination_args, $bp_admin_filtered_all_transactions_count );
194 - $paginations_showing_entities_html = self::bp_paginate_showing_entities_html( $transaction_pagination_args, $bp_admin_filtered_all_transactions_count );
195 -
196 - $fetchNullIfIncomplete = $transaction_pagination_status === 'incomplete' ? 1 : 0;
197 - $bp_admin_all_transactions = DB::get_transactions($transaction_pagination_args, 0, 'v2', $fetchNullIfIncomplete);
198 - }
199 -
200 - $bp_admin_all_transactions_analytics = DB::get_transactions_analytics();
201 -
202 - //Transaction details/view page
203 - if($viewMode){
204 - $transaction_id = isset($_REQUEST['id']) ? (int) sanitize_text_field($_REQUEST['id']) : 0;
205 - if($transaction_id == 0){
206 - esc_html_e('Record not found!', 'better-payment');
207 - exit;
208 - }
209 - $bp_admin_transaction = DB::get_transaction($transaction_id);
210 -
211 - //Fetch referer content
212 - $better_payment_helper = new Helper();
213 - $bp_admin_transaction_form_fields = is_object($bp_admin_transaction) && isset($bp_admin_transaction) ? maybe_unserialize($bp_admin_transaction->form_fields_info) : [];
214 - $referer_page_id = !empty($bp_admin_transaction_form_fields['referer_page_id']) ? $bp_admin_transaction_form_fields['referer_page_id'] : '';
215 - $referer_widget_id = !empty($bp_admin_transaction_form_fields['referer_widget_id']) ? $bp_admin_transaction_form_fields['referer_widget_id'] : '';
216 -
217 - $bp_transaction_referer_content = '';
218 -
219 - if($referer_page_id != '' && $referer_widget_id != ''){
220 - $bp_transaction_referer_content = $better_payment_helper->get_better_payment_widget_settings($referer_page_id, $referer_widget_id);
221 - }
222 - }
223 -
224 - include_once BETTER_PAYMENT_ADMIN_VIEWS_PATH . '/' . "$template.php";
225 - }
226 -
227 - /**
228 - * Settings save ajax
229 - *
230 - * @since 0.0.1
231 - */
232 - public static function save_settings_ajax()
233 - {
234 - /**
235 - * Verify the Nonce
236 - */
237 - if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'better_payment_admin_nonce')) {
238 - return;
239 - }
240 -
241 - if (isset($_POST['form_data']) && $_POST['reset_button'] == 'true') {
242 - self::save_default_settings(1);
243 - wp_send_json_success("success");
244 - } else if (isset($_POST['form_data'])) {
245 - self::save_settings($_POST['form_data']);
246 - wp_send_json_success("success");
247 - } else {
248 - wp_send_json_error("error");
249 - }
250 -
251 - die;
252 - }
253 -
254 - /**
255 - * This function is responsible for
30 + * This function is responsible for
256 31 * save all settings data, including checking the disable field to prevent
257 32 * users manipulation.
258 33 *
259 34 * @param array $values
@@ -265,9 +40,9 @@
265 40 $saved_settings = DB::get_settings();
266 41 $default_settings = DB::default_settings();
267 42
268 43 $saved_settings = wp_parse_args($default_settings, $saved_settings); // newly added default values to merge
269 -
44 +
270 45 $data = [];
271 46 $new_posted_fields = [];
272 47
273 48 if (!empty($posted_fields)) {
@@ -276,9 +51,9 @@
276 51 }
277 52 }
278 53
279 54 if (count($new_posted_fields)) {
280 -
55 +
281 56 foreach ($saved_settings as $saved_settings_item_key => $saved_settings_item_value) {
282 57 if (isset($new_posted_fields[$saved_settings_item_key]) && $new_posted_fields[$saved_settings_item_key] != '') {
283 58 $data[$saved_settings_item_key] = self::sanitize_field($saved_settings_item_key, $new_posted_fields[$saved_settings_item_key]);
284 59 } else {
@@ -309,316 +84,8 @@
309 84 return false;
310 85 }
311 86
312 87 return DB::update_settings($default_settings);
313 - }
314 -
315 - /**
316 - * transaction template
317 - *
318 - * @since 0.0.1
319 - */
320 - public function admin_transaction_view()
321 - {
322 - $response = [];
323 -
324 - if (!wp_verify_nonce($_REQUEST['nonce'], 'better_payment_admin_nonce')) {
325 - $response['message'] = __("Access Denied!", 'better-payment');
326 - wp_send_json_error($response);
327 - }
328 -
329 - if (!current_user_can('manage_options')) {
330 - $response['message'] = __("Access Denied!", 'better-payment');
331 - wp_send_json_error($response);
332 - }
333 -
334 - $transaction_id = isset($_REQUEST['id']) ? (int) sanitize_text_field($_REQUEST['id']) : 0;
335 -
336 - $bp_admin_transaction = '';
337 -
338 - if($transaction_id == 0){
339 - return __('Record not found!', 'better-payment');
340 - }
341 -
342 - $bp_admin_transaction = DB::get_transaction($transaction_id);
343 -
344 - include_once BETTER_PAYMENT_ADMIN_VIEWS_PATH . "/template-transaction-view.php";
345 - exit;
346 - }
347 -
348 - /**
349 - * Transaction delete
350 - *
351 - * @since 0.0.1
352 - */
353 - public function admin_transaction_delete()
354 - {
355 - $response = [];
356 -
357 - if (!wp_verify_nonce($_REQUEST['nonce'], 'better_payment_admin_nonce')) {
358 - $response['message'] = __("Access Denied!", 'better-payment');
359 - wp_send_json_error($response);
360 - }
361 -
362 - if (!current_user_can('manage_options')) {
363 - $response['message'] = __("Access Denied!", 'better-payment');
364 - wp_send_json_error($response);
365 - }
366 -
367 - $id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;
368 -
369 - if (DB::delete_transaction($id)) {
370 - $response['message'] = __("Deleted Successfully!", 'better-payment');
371 -
372 - $current_page = sanitize_text_field($_REQUEST['currentPage']);
373 - $per_page = sanitize_text_field($_REQUEST['perPage']);
374 - $total_entry_count = sanitize_text_field($_REQUEST['totalEntryCount']);
375 -
376 - $args = [
377 - 'paged' => $current_page,
378 - 'per_page' => $per_page,
379 - ];
380 -
381 - $response['pagination_showing_entities_html'] = self::bp_paginate_showing_entities_html($args, intval($total_entry_count) - 1);
382 - wp_send_json_success($response);
383 - } else {
384 - $response['message'] = __("Something went wrong!", 'better-payment');
385 - wp_send_json_error( $response );
386 - }
387 - }
388 -
389 - /**
390 - * Transaction filter
391 - *
392 - * @since 0.0.1
393 - */
394 - public function admin_transaction_filter()
395 - {
396 - $response = [];
397 -
398 - if (!wp_verify_nonce($_REQUEST['nonce'], 'better_payment_admin_nonce')) {
399 - $response['message'] = __("Access Denied!", 'better-payment');
400 - wp_send_json_error($response);
401 - }
402 -
403 - if (!current_user_can('manage_options')) {
404 - $response['message'] = __("Access Denied!", 'better-payment');
405 - wp_send_json_error($response);
406 - }
407 -
408 - $filter_search_text = ( isset($_REQUEST['filterFormData']['search_text']) && !empty($_REQUEST['filterFormData']['search_text']) ) ? sanitize_text_field( $_REQUEST['filterFormData']['search_text'] ) : '';
409 - $filter_payment_date_from = ( isset($_REQUEST['filterFormData']['payment_date_from']) && !empty($_REQUEST['filterFormData']['payment_date_from']) ) ? sanitize_text_field( $_REQUEST['filterFormData']['payment_date_from'] ) : '';
410 - $filter_payment_date_to = ( isset($_REQUEST['filterFormData']['payment_date_to']) && !empty($_REQUEST['filterFormData']['payment_date_to']) ) ? sanitize_text_field( $_REQUEST['filterFormData']['payment_date_to'] ) : '';
411 - $filter_order_by = ( isset($_REQUEST['filterFormData']['order_by']) && !empty($_REQUEST['filterFormData']['order_by']) ) ? sanitize_text_field( $_REQUEST['filterFormData']['order_by'] ) : 'id';
412 - $filter_order = ( isset($_REQUEST['filterFormData']['order']) && !empty($_REQUEST['filterFormData']['order']) ) ? sanitize_text_field( $_REQUEST['filterFormData']['order'] ) : 'DESC';
413 - $filter_status = ( isset($_REQUEST['filterFormData']['status']) && !empty($_REQUEST['filterFormData']['status']) ) ? sanitize_text_field( $_REQUEST['filterFormData']['status'] ) : 'all';
414 - $filter_source = ( isset($_REQUEST['filterFormData']['source']) && !empty($_REQUEST['filterFormData']['source']) ) ? sanitize_text_field( $_REQUEST['filterFormData']['source'] ) : '';
415 - $filter_paged = ( isset($_REQUEST['filterFormData']['paged']) && !empty($_REQUEST['filterFormData']['paged']) ) ? intval( $_REQUEST['filterFormData']['paged'] ) : 1;
416 - $filter_per_page = ( isset($_REQUEST['filterFormData']['per_page']) && !empty($_REQUEST['filterFormData']['per_page']) ) ? intval( $_REQUEST['filterFormData']['per_page'] ) : 20;
417 -
418 - $args = array(
419 - 'search_text' => $filter_search_text,
420 - 'payment_date_from' => $filter_payment_date_from,
421 - 'payment_date_to' => $filter_payment_date_to,
422 - 'order_by' => $filter_order_by,
423 - 'order' => $filter_order,
424 - 'status' => $filter_status,
425 - 'source' => $filter_source,
426 - 'paged' => $filter_paged,
427 - 'per_page' => $filter_per_page,
428 - );
429 -
430 - if( !empty($args['payment_date_from']) ){
431 - $args['payment_date_from'] = date('Y-m-d H:i:s',strtotime($args['payment_date_from']));
432 - }
433 - if( !empty($args['payment_date_to']) ){
434 - $args['payment_date_to'] = date('Y-m-d H:i:s',strtotime($args['payment_date_to']));
435 - }
436 -
437 - $args['offset'] = ( $args['paged'] - 1) * $args['per_page'];
438 -
439 - $fetchNullIfIncomplete = !empty($args['status']) && 'incomplete' === $args['status'] ? 1 : 0;
440 - $bp_admin_all_transactions = DB::get_transactions($args, 0, 'v2', $fetchNullIfIncomplete);
441 -
442 - //Pagination
443 - $fetchNull = !empty($args['status']) && 'incomplete' === $args['status'] ? 1 : 0;
444 - $only_incompleted_transactions = !empty($args['status']) && 'incomplete' === $args['status'] ? 1 : 0;
445 - $only_completed_transactions = !empty($args['status']) && 'completed' === $args['status'] ? 1 : 0;
446 -
447 - $bp_admin_all_transactions_count = DB::get_transaction_count($args, 'v2', $fetchNull);
448 - $bp_admin_all_transactions_paginations = self::bp_paginate_links($args, $bp_admin_all_transactions_count );
449 - $paginations_showing_entities_html = self::bp_paginate_showing_entities_html($args, $bp_admin_all_transactions_count );
450 -
451 - $bp_admin_completed_transactions_count = DB::get_transaction_count($args, 'v2', 0, 'completed');
452 - $bp_admin_incomplete_transactions_count = DB::get_transaction_count($args, 'v2', 1, 'incomplete');
453 -
454 - $bp_admin_completed_transactions_count = $only_incompleted_transactions ? 0 : $bp_admin_completed_transactions_count;
455 - $bp_admin_incomplete_transactions_count = $only_completed_transactions ? 0 : $bp_admin_incomplete_transactions_count;
456 -
457 - include_once BETTER_PAYMENT_ADMIN_VIEWS_PATH . "/template-transaction-list.php";
458 - exit;
459 - }
460 -
461 - /**
462 - * Paging links
463 - *
464 - * @since 0.0.1
465 - */
466 - public static function bp_paginate_links($args, $total_entry_count )
467 - {
468 - $pagination_html = '';
469 -
470 - $defaults = array(
471 - 'search_text' => '',
472 - 'per_page' => 20,
473 - 'paged' => 1,
474 - );
475 -
476 - $args = wp_parse_args($args, $defaults);
477 -
478 - $current_page = intval($args['paged']);
479 - $per_page = intval($args['per_page']);
480 - $total_entry_count = intval($total_entry_count);
481 - $total_page_count = ceil($total_entry_count / $per_page);
482 -
483 - $previous_page = $current_page - 1;
484 - $next_page = $current_page + 1;
485 -
486 - $prev_button_disabled = (1 == $current_page) ? 'disabled' : '';
487 - $next_button_disabled = $total_page_count == $current_page ? 'disabled' : '';
488 -
489 - $prev_button_link = ($current_page > 1) ? self::get_pagination_link($args, $previous_page) : "#";
490 - $next_button_link = ($current_page < $total_page_count) ? self::get_pagination_link($args, $next_page) : "#";
491 -
492 - $showing_entry_from = $per_page * ($current_page - 1) + 1;
493 -
494 - $pagination_html .= "<ul class=''>";
495 -
496 - //Showing entries content
497 - if ($showing_entry_from > $total_entry_count) {
498 - return '';
499 - }
500 -
501 - if ( $total_page_count == 1 ) {
502 - return '';
503 - }
504 -
505 - //Previous button
506 - if($current_page > 1){
507 - $pagination_html .= "<li><a href='$prev_button_link' $prev_button_disabled class='pagination-previous'><i class='bp-icon bp-caret-left'></i></a></li>";
508 - }
509 -
510 - //Pagination links
511 - for ($i = 1; $i <= $total_page_count; $i++) {
512 - $is_current_class = ($i == $current_page) ? 'is-current active' : '';
513 - $page_link = self::get_pagination_link($args, $i);
514 -
515 - if ( $total_page_count > 5 ) {
516 - $first_page = 1;
517 - $last_page = $total_page_count;
518 -
519 - switch( $i ){
520 - case $first_page :
521 - case $last_page :
522 - case $current_page - 2 :
523 - case $current_page - 1 :
524 - case $current_page :
525 - case $current_page + 1 :
526 - case $current_page + 2 :
527 - case $i + 3 && $current_page < 6 && $i < 6:
528 - case $i + 4 && $current_page < 6 && $i < 6:
529 - $pagination_html .= "
530 - <li>
531 - <a href=\"$page_link\" class=\"pagination-link $is_current_class \" aria-label=\"Page $i\"> $i </a>
532 - </li>
533 - ";
534 - break;
535 - case $current_page - 3 :
536 - case $current_page + 3 :
537 - $pagination_html .= "
538 - <li>
539 - ...
540 - </li>
541 - ";
542 - break;
543 - default:
544 - break;
545 - }
546 -
547 - } else {
548 - $pagination_html .= "
549 - <li>
550 - <a href=\"$page_link\" class=\"pagination-link $is_current_class \" aria-label=\"Page $i\"> $i </a>
551 - </li>
552 - ";
553 - }
554 - }
555 -
556 - //Next button
557 - if($current_page < $total_page_count){
558 - $pagination_html .= "<li><a href='$next_button_link' class='pagination-next' $next_button_disabled><i class='bp-icon bp-caret-right'></i></a></li>";
559 - }
560 -
561 - $pagination_html .= "</ul>";
562 -
563 - return $pagination_html;
564 - }
565 -
566 - protected static function get_pagination_link( $args, $target_paged ){
567 - $per_page = ! empty( $args['per_page'] ) ? intval( $args['per_page'] ) : 20;
568 - $search_text = ! empty( $args['search_text'] ) ? sanitize_text_field( $args['search_text'] ) : '';
569 - $valid_search_text = $search_text != '' && strlen($search_text) >= 2;
570 -
571 - $button_link = admin_url("admin.php?page=better-payment-transactions&per_page={$per_page}&paged={$target_paged}");
572 -
573 - if($valid_search_text){
574 - $button_link = admin_url("admin.php?page=better-payment-transactions&per_page={$per_page}&paged={$target_paged}&search_text={$search_text}");
575 - }
576 -
577 - return $button_link;
578 - }
579 -
580 - /**
581 - * Pagination showing entities html
582 - *
583 - * @since 0.0.1
584 - */
585 - public static function bp_paginate_showing_entities_html($args, $total_entry_count)
586 - {
587 - $pagination_showing_entries_html = '';
588 -
589 - $defaults = array(
590 - 'per_page' => 20,
591 - 'paged' => 1,
592 - );
593 -
594 - $args = wp_parse_args($args, $defaults);
595 -
596 - $current_page = intval($args['paged']);
597 - $per_page = intval($args['per_page']);
598 -
599 - $total_entry_count = intval($total_entry_count);
600 - $total_page_count = ceil($total_entry_count / $per_page);
601 -
602 - $showing_entry_from = $per_page * ($current_page - 1) + 1;
603 - $showing_entry_to = $per_page * $current_page;
604 -
605 - //Showing entries content
606 - if ($total_page_count == 1 || $current_page == $total_page_count) {
607 - $showing_entry_to = $total_entry_count;
608 - }
609 -
610 - $pagination_showing_entries_html = __("Showing {$showing_entry_from}-{$showing_entry_to} of $total_entry_count entries", "better-payment");
611 -
612 - if ($showing_entry_from > $total_entry_count) {
613 - return '';
614 - }
615 -
616 - if ($total_page_count == 1) {
617 - return $pagination_showing_entries_html;
618 - }
619 -
620 - return $pagination_showing_entries_html;
621 88 }
622 89
623 90 /**
624 91 * This function is responsible for the data sanitization