| @@ -19,8 +19,11 @@ | ||
| 19 | 19 | * @var int[] |
| 20 | 20 | */ |
| 21 | 21 | private $valid_entry_ids = array(); |
| 22 | 22 | |
| 23 | + /** | |
| 24 | + * @param array $args | |
| 25 | + */ | |
| 23 | 26 | public function __construct( $args ) { |
| 24 | 27 | $this->table = FrmAppHelper::get_simple_request( |
| 25 | 28 | array( |
| 26 | 29 | 'param' => 'trans_type', |
| @@ -43,9 +46,14 @@ | ||
| 43 | 46 | global $wpdb; |
| 44 | 47 | |
| 45 | 48 | $orderby = FrmAppHelper::get_param( 'orderby', 'id', 'get', 'sanitize_title' ); |
| 46 | 49 | $order = FrmAppHelper::get_param( 'order', 'DESC', 'get', 'sanitize_text_field' ); |
| 47 | - if ( ! in_array( $order, array( 'ASC', 'DESC' ), true ) ) { | |
| 50 | + | |
| 51 | + if ( ! is_string( $orderby ) ) { | |
| 52 | + $orderby = 'id'; | |
| 53 | + } | |
| 54 | + | |
| 55 | + if ( ! is_string( $order ) || ! in_array( strtoupper( $order ), array( 'ASC', 'DESC' ), true ) ) { | |
| 48 | 56 | $order = 'DESC'; |
| 49 | 57 | } |
| 50 | 58 | |
| 51 | 59 | $page = $this->get_pagenum(); |
| @@ -82,22 +90,20 @@ | ||
| 82 | 90 | |
| 83 | 91 | $table_name = $this->table === 'subscriptions' ? 'frm_subscriptions' : 'frm_payments'; |
| 84 | 92 | $form_id = FrmAppHelper::get_param( 'form', 0, 'get', 'absint' ); |
| 85 | 93 | |
| 86 | - if ( $form_id ) { | |
| 87 | - // @codingStandardsIgnoreStart | |
| 88 | - $query = $wpdb->prepare( | |
| 89 | - "FROM `{$wpdb->prefix}{$table_name}` p | |
| 90 | - JOIN `{$wpdb->prefix}frm_items` i ON p.item_id = i.id | |
| 91 | - WHERE i.form_id = %d", | |
| 92 | - $form_id | |
| 93 | - ); | |
| 94 | - // @codingStandardsIgnoreEnd | |
| 95 | - } else { | |
| 96 | - $query = "FROM `{$wpdb->prefix}{$table_name}` p"; | |
| 94 | + if ( ! $form_id ) { | |
| 95 | + return "FROM `{$wpdb->prefix}{$table_name}` p"; | |
| 97 | 96 | } |
| 98 | 97 | |
| 99 | - return $query; | |
| 98 | + // @codingStandardsIgnoreStart | |
| 99 | + return $wpdb->prepare( | |
| 100 | + "FROM `{$wpdb->prefix}{$table_name}` p | |
| 101 | + JOIN `{$wpdb->prefix}frm_items` i ON p.item_id = i.id | |
| 102 | + WHERE i.form_id = %d", | |
| 103 | + $form_id | |
| 104 | + ); | |
| 105 | + // @codingStandardsIgnoreEnd | |
| 100 | 106 | } |
| 101 | 107 | |
| 102 | 108 | /** |
| 103 | 109 | * @return void |
| @@ -102,9 +108,9 @@ | ||
| 102 | 108 | /** |
| 103 | 109 | * @return void |
| 104 | 110 | */ |
| 105 | 111 | public function no_items() { |
| 106 | - esc_html_e( 'No payments found.', 'formidable' ); | |
| 112 | + include FrmTransLiteAppHelper::plugin_path() . '/views/lists/no-payments.php'; | |
| 107 | 113 | } |
| 108 | 114 | |
| 109 | 115 | /** |
| 110 | 116 | * @return array |
| @@ -114,10 +120,9 @@ | ||
| 114 | 120 | 'payments' => __( 'Payments', 'formidable' ), |
| 115 | 121 | 'subscriptions' => __( 'Subscriptions', 'formidable' ), |
| 116 | 122 | ); |
| 117 | 123 | |
| 118 | - $links = array(); | |
| 119 | - | |
| 124 | + $links = array(); | |
| 120 | 125 | $frm_payment = new FrmTransLitePayment(); |
| 121 | 126 | $frm_sub = new FrmTransLiteSubscription(); |
| 122 | 127 | $counts = array( |
| 123 | 128 | 'payments' => $frm_payment->get_count(), |
| @@ -131,19 +136,17 @@ | ||
| 131 | 136 | ) |
| 132 | 137 | ); |
| 133 | 138 | |
| 134 | 139 | foreach ( $statuses as $status => $name ) { |
| 135 | - if ( $status === $type ) { | |
| 136 | - $class = ' class="current"'; | |
| 137 | - } else { | |
| 138 | - $class = ''; | |
| 139 | - } | |
| 140 | + $class = $status === $type ? ' class="current"' : ''; | |
| 140 | 141 | |
| 141 | - if ( $counts[ $status ] || 'published' === $status ) { | |
| 142 | + if ( $counts[ $status ] || 'payments' === $status ) { | |
| 143 | + // phpcs:disable Generic.WhiteSpace.ScopeIndent | |
| 142 | 144 | $links[ $status ] = '<a href="' . esc_url( '?page=formidable-payments&trans_type=' . $status ) . '" ' . $class . '>' |
| 143 | 145 | // translators: %1$s: Transaction type (Payments or Subscriptions), %2$s: Span start tag, %3$s: Count, %4$s: Span close tag. |
| 144 | 146 | . sprintf( esc_html__( '%1$s %2$s(%3$s)%4$s', 'formidable' ), esc_html( $name ), '<span class="count">', number_format_i18n( $counts[ $status ] ), '</span>' ) |
| 145 | 147 | . '</a>'; |
| 148 | + // phpcs:enable Generic.WhiteSpace.ScopeIndent | |
| 146 | 149 | } |
| 147 | 150 | |
| 148 | 151 | unset( $status, $name ); |
| 149 | 152 | } |
| @@ -169,8 +172,9 @@ | ||
| 169 | 172 | 'receipt_id' => 'receipt_id', |
| 170 | 173 | 'sub_id' => 'sub_id', |
| 171 | 174 | 'begin_date' => 'begin_date', |
| 172 | 175 | 'expire_date' => 'expire_date', |
| 176 | + 'paysys' => 'paysys', | |
| 173 | 177 | 'status' => 'status', |
| 174 | 178 | 'next_bill_date' => 'next_bill_date', |
| 175 | 179 | ); |
| 176 | 180 | } |
| @@ -175,18 +179,38 @@ | ||
| 175 | 179 | ); |
| 176 | 180 | } |
| 177 | 181 | |
| 178 | 182 | /** |
| 183 | + * If the Payments submodule or the PayPal add-on is active, add a bulk delete action. | |
| 184 | + * | |
| 185 | + * @since 6.27 | |
| 186 | + * | |
| 187 | + * @return array | |
| 188 | + */ | |
| 189 | + public function get_bulk_actions() { | |
| 190 | + $actions = array(); | |
| 191 | + | |
| 192 | + if ( $this->payments_addon_list_helper_exists() ) { | |
| 193 | + $actions['bulk_delete'] = __( 'Delete', 'formidable' ); | |
| 194 | + } | |
| 195 | + | |
| 196 | + return $actions; | |
| 197 | + } | |
| 198 | + | |
| 199 | + /** | |
| 179 | 200 | * @param string $which |
| 201 | + * | |
| 180 | 202 | * @return void |
| 181 | 203 | */ |
| 182 | 204 | public function extra_tablenav( $which ) { |
| 183 | 205 | $footer = $which !== 'top'; |
| 206 | + | |
| 184 | 207 | if ( $footer ) { |
| 185 | 208 | return; |
| 186 | 209 | } |
| 187 | 210 | |
| 188 | 211 | $form_id = FrmAppHelper::simple_get( 'form', 'absint', 0 ); |
| 212 | + | |
| 189 | 213 | if ( $form_id ) { |
| 190 | 214 | // Don't show the switcher if it's already in the header. |
| 191 | 215 | return; |
| 192 | 216 | } |
| @@ -205,13 +229,12 @@ | ||
| 205 | 229 | * @return void |
| 206 | 230 | */ |
| 207 | 231 | public function display_rows() { |
| 208 | 232 | $date_format = FrmTransLiteAppHelper::get_date_format(); |
| 209 | - | |
| 210 | - $alt = 0; | |
| 211 | - | |
| 212 | - $form_ids = $this->get_form_ids(); | |
| 213 | - $args = compact( 'form_ids', 'date_format' ); | |
| 233 | + $gateways = FrmTransLiteAppHelper::get_gateways(); | |
| 234 | + $alt = 0; | |
| 235 | + $form_ids = $this->get_form_ids(); | |
| 236 | + $args = compact( 'form_ids', 'date_format', 'gateways' ); | |
| 214 | 237 | // $form_ids is indexed by entry ID. |
| 215 | 238 | $this->valid_entry_ids = array_keys( $form_ids ); |
| 216 | 239 | |
| 217 | 240 | foreach ( $this->items as $item ) { |
| @@ -252,16 +275,33 @@ | ||
| 252 | 275 | } |
| 253 | 276 | |
| 254 | 277 | protected function get_column_info() { |
| 255 | 278 | $column_info = parent::get_column_info(); |
| 256 | - // Remove the checkbox column. | |
| 257 | - unset( $column_info[0]['cb'] ); | |
| 279 | + | |
| 280 | + if ( ! $this->payments_addon_list_helper_exists() ) { | |
| 281 | + // Remove the checkbox column for Lite only. | |
| 282 | + unset( $column_info[0]['cb'] ); | |
| 283 | + } | |
| 284 | + | |
| 258 | 285 | return $column_info; |
| 259 | 286 | } |
| 260 | 287 | |
| 261 | 288 | /** |
| 289 | + * Check for Payments submodule (Stripe, Authorize.Net add-ons), as well as PayPal. | |
| 290 | + * | |
| 291 | + * @since 6.27 | |
| 292 | + * | |
| 293 | + * @return bool | |
| 294 | + */ | |
| 295 | + private function payments_addon_list_helper_exists() { | |
| 296 | + return class_exists( 'FrmTransListHelper' ) || class_exists( 'FrmPaymentsListHelper' ); | |
| 297 | + } | |
| 298 | + | |
| 299 | + /** | |
| 262 | 300 | * @param object $item |
| 263 | 301 | * @param array $args |
| 302 | + * | |
| 303 | + * @return string | |
| 264 | 304 | */ |
| 265 | 305 | private function get_column_value( $item, $args ) { |
| 266 | 306 | $column_name = $args['column_name']; |
| 267 | 307 | $function_name = 'get_' . $column_name . '_column'; |
| @@ -270,9 +310,9 @@ | ||
| 270 | 310 | $val = $this->$function_name( $item, $args ); |
| 271 | 311 | } else { |
| 272 | 312 | $val = $item->$column_name ? $item->$column_name : ''; |
| 273 | 313 | |
| 274 | - if ( strpos( $column_name, '_date' ) !== false ) { | |
| 314 | + if ( str_contains( $column_name, '_date' ) ) { | |
| 275 | 315 | if ( ! empty( $item->$column_name ) && $item->$column_name !== '0000-00-00' ) { |
| 276 | 316 | $val = FrmTransLiteAppHelper::format_the_date( $item->$column_name, $args['date_format'] ); |
| 277 | 317 | } else { |
| 278 | 318 | $val = ''; |
| @@ -287,8 +327,9 @@ | ||
| 287 | 327 | * @return array |
| 288 | 328 | */ |
| 289 | 329 | private function get_form_ids() { |
| 290 | 330 | $entry_ids = array(); |
| 331 | + | |
| 291 | 332 | foreach ( $this->items as $item ) { |
| 292 | 333 | $entry_ids[] = absint( $item->item_id ); |
| 293 | 334 | unset( $item ); |
| 294 | 335 | } |
| @@ -307,8 +348,9 @@ | ||
| 307 | 348 | // @codingStandardsIgnoreEnd |
| 308 | 349 | unset( $entry_ids ); |
| 309 | 350 | |
| 310 | 351 | $form_ids = array(); |
| 352 | + | |
| 311 | 353 | foreach ( $forms as $form ) { |
| 312 | 354 | $form_ids[ $form->id ] = $form; |
| 313 | 355 | unset( $form ); |
| 314 | 356 | } |
| @@ -323,9 +365,9 @@ | ||
| 323 | 365 | */ |
| 324 | 366 | private function get_row_classes( $atts ) { |
| 325 | 367 | $class = 'column-' . $atts['column_name']; |
| 326 | 368 | |
| 327 | - if ( in_array( $atts['column_name'], $atts['hidden'] ) ) { | |
| 369 | + if ( in_array( $atts['column_name'], $atts['hidden'], true ) ) { | |
| 328 | 370 | $class .= ' frm_hidden'; |
| 329 | 371 | } |
| 330 | 372 | |
| 331 | 373 | return 'class="' . esc_attr( $class ) . '"'; |
| @@ -331,12 +373,26 @@ | ||
| 331 | 373 | return 'class="' . esc_attr( $class ) . '"'; |
| 332 | 374 | } |
| 333 | 375 | |
| 334 | 376 | /** |
| 377 | + * Get the checkbox for bulk actions. | |
| 378 | + * This is only required when the Payments submodule or PayPal is active. | |
| 379 | + * | |
| 380 | + * @since 6.27 | |
| 381 | + * | |
| 335 | 382 | * @param object $item |
| 336 | 383 | * |
| 337 | 384 | * @return string |
| 338 | 385 | */ |
| 386 | + private function get_cb_column( $item ) { | |
| 387 | + return '<input type="checkbox" name="item-action[]" value="' . esc_attr( $item->id ) . '" />'; | |
| 388 | + } | |
| 389 | + | |
| 390 | + /** | |
| 391 | + * @param object $item | |
| 392 | + * | |
| 393 | + * @return string | |
| 394 | + */ | |
| 339 | 395 | private function get_receipt_id_column( $item ) { |
| 340 | 396 | return $this->get_action_column( $item, 'receipt_id' ); |
| 341 | 397 | } |
| 342 | 398 | |
| @@ -346,34 +402,50 @@ | ||
| 346 | 402 | * |
| 347 | 403 | * @return string |
| 348 | 404 | */ |
| 349 | 405 | private function get_action_column( $item, $field ) { |
| 350 | - $link = add_query_arg( | |
| 406 | + $link = $this->get_view_payment_link( $item, $field ); | |
| 407 | + return '<strong>' . $link . '</strong><br />' . $this->row_actions( $this->get_row_actions( $item ) ); | |
| 408 | + } | |
| 409 | + | |
| 410 | + /** | |
| 411 | + * @since 6.27 | |
| 412 | + * | |
| 413 | + * @param object $item | |
| 414 | + * @param string $field | |
| 415 | + * | |
| 416 | + * @return string | |
| 417 | + */ | |
| 418 | + private function get_view_payment_link( $item, $field ) { | |
| 419 | + $link_params = array( | |
| 420 | + 'class' => 'rot-title', | |
| 421 | + 'href' => esc_url( $this->get_url_to_payment( $item->id, 'show' ) ), | |
| 422 | + 'title' => __( 'View', 'formidable' ), | |
| 423 | + ); | |
| 424 | + return '<a ' . FrmAppHelper::array_to_html_params( $link_params ) . '>' . esc_html( $item->{ $field } ) . '</a>'; | |
| 425 | + } | |
| 426 | + | |
| 427 | + /** | |
| 428 | + * @param int|string $payment_id | |
| 429 | + * @param string $action Supports 'show' and 'edit'. | |
| 430 | + * | |
| 431 | + * @return string | |
| 432 | + */ | |
| 433 | + private function get_url_to_payment( $payment_id, $action = 'show' ) { | |
| 434 | + return add_query_arg( | |
| 351 | 435 | array( |
| 352 | - 'action' => 'show', | |
| 353 | - 'id' => $item->id, | |
| 436 | + 'action' => $action, | |
| 437 | + 'id' => $payment_id, | |
| 354 | 438 | 'type' => $this->table, |
| 355 | 439 | 'page' => FrmAppHelper::simple_get( 'page' ), |
| 356 | 440 | ), |
| 357 | 441 | admin_url( 'admin.php' ) |
| 358 | 442 | ); |
| 359 | - | |
| 360 | - $link_params = array( | |
| 361 | - 'class' => 'rot-title', | |
| 362 | - 'href' => esc_url( $link ), | |
| 363 | - 'title' => __( 'View', 'formidable' ), | |
| 364 | - ); | |
| 365 | - $link = '<a ' . FrmAppHelper::array_to_html_params( $link_params ) . '>' | |
| 366 | - . $item->{$field} | |
| 367 | - . '</a>'; | |
| 368 | - | |
| 369 | - return '<strong>' . $link . '</strong>' | |
| 370 | - . '<br />' | |
| 371 | - . $this->row_actions( $this->get_row_actions( $item ) ); | |
| 372 | 443 | } |
| 373 | 444 | |
| 374 | 445 | /** |
| 375 | 446 | * @param object $item |
| 447 | + * | |
| 376 | 448 | * @return array |
| 377 | 449 | */ |
| 378 | 450 | private function get_row_actions( $item ) { |
| 379 | 451 | $base_link = '?page=formidable-payments&action='; |
| @@ -382,26 +454,41 @@ | ||
| 382 | 454 | |
| 383 | 455 | $actions = array(); |
| 384 | 456 | $actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . esc_html__( 'View', 'formidable' ) . '</a>'; |
| 385 | 457 | |
| 386 | - if ( $this->table !== 'subscriptions' && 'stripe' !== $item->paysys && class_exists( 'FrmPaymentsController', false ) ) { | |
| 458 | + if ( $this->supports_edit_link() ) { | |
| 387 | 459 | $edit_link = $base_link . 'edit&id=' . $item->id; |
| 388 | 460 | $actions['edit'] = '<a href="' . esc_url( $edit_link ) . '">' . esc_html__( 'Edit', 'formidable' ) . '</a>'; |
| 389 | 461 | } |
| 390 | 462 | |
| 391 | - $actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" data-frmverify="' . esc_attr__( 'Permanently delete this payment?', 'formidable' ) . '" data-frmverify-btn="frm-button-red">' . esc_html__( 'Delete', 'formidable' ) . '</a>'; | |
| 463 | + $actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" data-frmverify="' . esc_attr__( 'Permanently delete this payment?', 'formidable' ) . '" data-frmverify-btn="frm-button-red">' . esc_html__( 'Delete', 'formidable' ) . '</a>'; // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong | |
| 392 | 464 | |
| 393 | 465 | return $actions; |
| 394 | 466 | } |
| 395 | 467 | |
| 396 | 468 | /** |
| 469 | + * @since 6.27 | |
| 470 | + * | |
| 471 | + * @return bool | |
| 472 | + */ | |
| 473 | + private function supports_edit_link() { | |
| 474 | + if ( $this->table === 'subscriptions' ) { | |
| 475 | + return false; | |
| 476 | + } | |
| 477 | + | |
| 478 | + return class_exists( 'FrmTransAppController', false ) || class_exists( 'FrmPaymentsController', false ); | |
| 479 | + } | |
| 480 | + | |
| 481 | + /** | |
| 397 | 482 | * Get the column value for displaying an entry ID. |
| 398 | 483 | * |
| 399 | 484 | * @param object $item A payment or subscription object. |
| 485 | + * | |
| 400 | 486 | * @return string |
| 401 | 487 | */ |
| 402 | 488 | private function get_item_id_column( $item ) { |
| 403 | - $entry_id = (int) $item->item_id; | |
| 489 | + $entry_id = (int) $item->item_id; | |
| 490 | + // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict | |
| 404 | 491 | $entry_is_deleted = ! in_array( $entry_id, $this->valid_entry_ids ); |
| 405 | 492 | |
| 406 | 493 | if ( $entry_is_deleted ) { |
| 407 | 494 | // translators: %d: ID of the deleted entry. |
| @@ -413,14 +500,14 @@ | ||
| 413 | 500 | |
| 414 | 501 | /** |
| 415 | 502 | * @param object $item |
| 416 | 503 | * @param array $atts |
| 504 | + * | |
| 417 | 505 | * @return mixed |
| 418 | 506 | */ |
| 419 | 507 | private function get_form_id_column( $item, $atts ) { |
| 420 | 508 | if ( isset( $atts['form_ids'][ $item->item_id ] ) ) { |
| 421 | - $form_link = FrmFormsHelper::edit_form_link( $atts['form_ids'][ $item->item_id ]->form_id ); | |
| 422 | - return $form_link; | |
| 509 | + return FrmFormsHelper::edit_form_link( $atts['form_ids'][ $item->item_id ]->form_id ); | |
| 423 | 510 | } |
| 424 | 511 | |
| 425 | 512 | return ''; |
| 426 | 513 | } |
| @@ -426,12 +513,12 @@ | ||
| 426 | 513 | } |
| 427 | 514 | |
| 428 | 515 | /** |
| 429 | 516 | * @param object $item |
| 517 | + * | |
| 430 | 518 | * @return string |
| 431 | 519 | */ |
| 432 | 520 | private function get_user_id_column( $item ) { |
| 433 | - global $wpdb; | |
| 434 | 521 | $val = FrmDb::get_var( 'frm_items', array( 'id' => $item->item_id ), 'user_id' ); |
| 435 | 522 | return FrmTransLiteAppHelper::get_user_link( $val ); |
| 436 | 523 | } |
| 437 | 524 | |
| @@ -437,8 +524,9 @@ | ||
| 437 | 524 | |
| 438 | 525 | /** |
| 439 | 526 | * @param object $item |
| 440 | 527 | * @param array $atts |
| 528 | + * | |
| 441 | 529 | * @return string |
| 442 | 530 | */ |
| 443 | 531 | private function get_created_at_column( $item, $atts ) { |
| 444 | 532 | if ( empty( $item->created_at ) || $item->created_at === '0000-00-00 00:00:00' ) { |
| @@ -446,13 +534,14 @@ | ||
| 446 | 534 | } |
| 447 | 535 | |
| 448 | 536 | $date = FrmAppHelper::get_localized_date( $atts['date_format'], $item->created_at ); |
| 449 | 537 | $date_title = FrmAppHelper::get_localized_date( $atts['date_format'] . ' g:i:s A', $item->created_at ); |
| 450 | - $val = '<abbr title="' . esc_attr( $date_title ) . '">' . $date . '</abbr>'; | |
| 451 | - return $val; | |
| 538 | + return '<abbr title="' . esc_attr( $date_title ) . '">' . $date . '</abbr>'; | |
| 452 | 539 | } |
| 453 | 540 | |
| 454 | 541 | /** |
| 542 | + * @param object $item | |
| 543 | + * | |
| 455 | 544 | * @return string |
| 456 | 545 | */ |
| 457 | 546 | private function get_amount_column( $item ) { |
| 458 | 547 | if ( $this->table === 'subscriptions' ) { |
| @@ -475,12 +564,17 @@ | ||
| 475 | 564 | // translators: %1$s: Count, %2$s: Limit. |
| 476 | 565 | return sprintf( __( '%1$s of %2$s', 'formidable' ), $count, $limit ); |
| 477 | 566 | } |
| 478 | 567 | |
| 568 | + /** | |
| 569 | + * @param object $item | |
| 570 | + * | |
| 571 | + * @return string | |
| 572 | + */ | |
| 479 | 573 | private function get_status_column( $item ) { |
| 480 | 574 | $status = esc_html( FrmTransLiteAppHelper::show_status( FrmTransLiteAppHelper::get_payment_status( $item ) ) ); |
| 481 | 575 | |
| 482 | - if ( 'processing' === $item->status ) { | |
| 576 | + if ( 'processing' === ( $item->status ?? '' ) ) { | |
| 483 | 577 | $status .= $this->get_processing_tooltip(); |
| 484 | 578 | } |
| 485 | 579 | |
| 486 | 580 | return $status; |
| @@ -500,8 +594,9 @@ | ||
| 500 | 594 | } |
| 501 | 595 | |
| 502 | 596 | /** |
| 503 | 597 | * @param object $item |
| 598 | + * | |
| 504 | 599 | * @return string |
| 505 | 600 | */ |
| 506 | 601 | private function get_sub_id_column( $item ) { |
| 507 | 602 | if ( empty( $item->sub_id ) ) { |
| @@ -520,19 +615,16 @@ | ||
| 520 | 615 | * Convert the supported pay systems to their proper case. |
| 521 | 616 | * |
| 522 | 617 | * @param object $item |
| 523 | 618 | * @param array $atts |
| 619 | + * | |
| 524 | 620 | * @return string |
| 525 | 621 | */ |
| 526 | 622 | private function get_paysys_column( $item, $atts ) { |
| 527 | - switch ( $item->paysys ) { | |
| 528 | - case 'stripe': | |
| 529 | - return 'Stripe'; | |
| 530 | - case 'paypal': | |
| 531 | - return 'PayPal'; | |
| 532 | - case 'square': | |
| 533 | - return 'Square'; | |
| 623 | + if ( isset( $atts['gateways'][ $item->paysys ] ) ) { | |
| 624 | + return $atts['gateways'][ $item->paysys ]['label']; | |
| 534 | 625 | } |
| 626 | + | |
| 535 | 627 | return $item->paysys; |
| 536 | 628 | } |
| 537 | 629 | |
| 538 | 630 | /** |
| @@ -541,10 +633,29 @@ | ||
| 541 | 633 | * |
| 542 | 634 | * @since 6.6 |
| 543 | 635 | * |
| 544 | 636 | * @param stdClass $item Payment or Subscription object. |
| 637 | + * | |
| 545 | 638 | * @return string |
| 546 | 639 | */ |
| 547 | 640 | private function get_mode_column( $item ) { |
| 548 | 641 | return esc_html( FrmTransLiteAppHelper::get_test_mode_display_string( $item ) ); |
| 642 | + } | |
| 643 | + | |
| 644 | + /** | |
| 645 | + * Render the tabs for the payments list, if the user has access to coupons. | |
| 646 | + * | |
| 647 | + * @since 6.27 | |
| 648 | + * | |
| 649 | + * @param string $active_tab | |
| 650 | + * | |
| 651 | + * @return void | |
| 652 | + */ | |
| 653 | + public static function render_tabs( $active_tab = 'payments' ) { | |
| 654 | + if ( ! current_user_can( 'frm_change_settings' ) ) { | |
| 655 | + // Coupons are only available to people who can access global settings. | |
| 656 | + return; | |
| 657 | + } | |
| 658 | + | |
| 659 | + include FrmTransLiteAppHelper::plugin_path() . '/views/lists/tabs.php'; | |
| 549 | 660 | } |
| 550 | 661 | } |