PluginProbe
Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More / 2.2.2
Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More v2.2.2
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 1.0.5 1.0.6 All 66 releases
better-payment / includes / Campaign / CampaignListColumns.php

CampaignListColumns.php in Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More 2.2.2, at includes/Campaign/CampaignListColumns.php

63 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Better_Payment\Lite\Campaign;
4
5 use Better_Payment\Lite\Controller;
6
7 if ( ! defined( 'ABSPATH' ) ) {
8 exit;
9 }
10
11 /**
12 * Adds "Stats" and "Edit in Builder" columns to the bp_campaign post list table.
13 */
14 class CampaignListColumns extends Controller {
15
16 public function add_columns( array $columns ): array {
17 // Insert stats column before the date column
18 $date = $columns['date'] ?? null;
19 unset( $columns['date'] );
20
21 $columns['campaign_stats'] = __( 'Campaign Stats', 'better-payment' );
22 $columns['campaign_builder'] = __( 'Builder', 'better-payment' );
23
24 if ( $date ) {
25 $columns['date'] = $date;
26 }
27
28 return $columns;
29 }
30
31 public function render_column( string $column, int $post_id ) {
32 if ( $column === 'campaign_stats' ) {
33 $stats = CampaignStats::get_stats( $post_id );
34 $meta = MetaBox::get_all( $post_id );
35 $goal = (float) ( $meta['bpc_goal_amount'] ?? 0 );
36 $currency = $meta['bpc_currency'] ?? 'USD';
37 $raised = $stats['total_raised'];
38 $progress = $stats['progress'];
39
40 printf(
41 '<strong>%s %s</strong> raised<br><small>%d donors &nbsp;|&nbsp; %d%%</small>',
42 esc_html( $currency ),
43 esc_html( number_format( $raised, 2 ) ),
44 (int) $stats['donor_count'],
45 (int) $progress
46 );
47
48 if ( $goal > 0 ) {
49 printf( '<br><small>of %s %s goal</small>', esc_html( $currency ), esc_html( number_format( $goal, 2 ) ) );
50 }
51 }
52
53 if ( $column === 'campaign_builder' ) {
54 $url = admin_url( 'admin.php?page=bp-campaign-builder&campaign_id=' . $post_id );
55 printf(
56 '<a href="%s" class="button button-small">%s</a>',
57 esc_url( $url ),
58 esc_html__( 'Open Builder', 'better-payment' )
59 );
60 }
61 }
62 }
63