Subscriptions.php
1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
namespace ACA\WC\Column\UserSubscription;
use AC;
use ACP\ConditionalFormat\FilteredHtmlFormatTrait;
use ACP\ConditionalFormat\Formattable;
use ACP\Export\Exportable;
use ACP\Export\Model\StrippedValue;
class Subscriptions extends AC\Column
implements Exportable, Formattable {
use FilteredHtmlFormatTrait;
public function __construct() {
$this->set_type( 'column-wc-user-subscriptions' )
->set_label( __( 'Subscriptions', 'woocommerce' ) )
->set_group( 'woocommerce_subscriptions' );
}
public function get_value( $user_id ) {
$subscriptions = wcs_get_users_subscriptions( $user_id );
if ( empty( $subscriptions ) ) {
return $this->get_empty_char();
}
$result = [];
foreach ( $subscriptions as $subscription ) {
$label = ac_helper()->html->tooltip( '#' . $subscription->get_id(), $subscription->get_status() );
$result[] = ac_helper()->html->link( get_edit_post_link( $subscription->get_id() ), $label );
}
return implode( ', ', $result );
}
public function get_raw_value( $user_id ) {
return wcs_get_users_subscriptions( $user_id );
}
public function export() {
return new StrippedValue( $this );
}
}