IntegrationColumns.php
933 Bytes
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
<?php
namespace AC\Service;
use AC\Column\Placeholder;
use AC\IntegrationRepository;
use AC\ListScreen;
use AC\Registerable;
final class IntegrationColumns implements Registerable {
/**
* @var IntegrationRepository
*/
private $repository;
public function __construct( IntegrationRepository $repository ) {
$this->repository = $repository;
}
public function register() {
add_action( 'ac/column_types', [ $this, 'register_integration_columns' ], 1 );
}
public function register_integration_columns( ListScreen $list_screen ) {
if ( ! function_exists( 'ACP' ) ) {
foreach ( $this->repository->find_all() as $integration ) {
if ( ! $integration->show_placeholder( $list_screen ) ) {
continue;
}
if ( $integration->is_plugin_active() ) {
$column = new Placeholder();
$column->set_integration( $integration );
$list_screen->register_column_type( $column );
}
}
}
}
}