Admin.php
2.15 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
namespace ACA\WC;
use AC;
use AC\Registerable;
use ACA\WC\ListScreen\Product;
use ACA\WC\ListScreen\ShopOrder;
use ACA\WC\ListScreen\Subscriptions;
use ACA\WC\Settings\HideOnScreen\FilterOrderCustomer;
use ACA\WC\Settings\HideOnScreen\FilterProductCategory;
use ACA\WC\Settings\HideOnScreen\FilterProductStockStatus;
use ACA\WC\Settings\HideOnScreen\FilterProductType;
use ACA\WC\Settings\HideOnScreen\FilterSubscriptionCustomer;
use ACA\WC\Settings\HideOnScreen\FilterSubscriptionPayment;
use ACA\WC\Settings\HideOnScreen\FilterSubscriptionProduct;
use ACP\Settings\ListScreen\HideOnScreen\FilterPostDate;
use ACP\Settings\ListScreen\HideOnScreenCollection;
use ACP\Type\HideOnScreen\Group;
class Admin implements Registerable {
/**
* @var AC\Asset\Location\Absolute
*/
private $location;
public function __construct( AC\Asset\Location\Absolute $location ) {
$this->location = $location;
}
public function register() {
add_action( 'acp/admin/settings/hide_on_screen', [ $this, 'add_hide_on_screen' ], 10, 2 );
add_action( 'ac/admin_scripts', [ $this, 'admin_scripts' ] );
}
public function admin_scripts() {
$script = new Asset\Script\Admin( 'aca-wc-admin', $this->location );
$script->enqueue();
}
public function add_hide_on_screen( HideOnScreenCollection $collection, AC\ListScreen $list_screen ) {
switch ( true ) {
case $list_screen instanceof ShopOrder :
$collection->add( new FilterOrderCustomer(), new Group( Group::ELEMENT ), 34 );
break;
case $list_screen instanceof Product :
$collection->add( new FilterProductCategory(), new Group( Group::ELEMENT ), 32 )
->add( new FilterProductStockStatus(), new Group( Group::ELEMENT ), 32 )
->add( new FilterProductType(), new Group( Group::ELEMENT ), 32 );
$collection->remove( new FilterPostDate() );
break;
case $list_screen instanceof Subscriptions :
$collection->add( new FilterSubscriptionProduct(), new Group( Group::ELEMENT ), 34 )
->add( new FilterSubscriptionPayment(), new Group( Group::ELEMENT ), 34 )
->add( new FilterSubscriptionCustomer(), new Group( Group::ELEMENT ), 34 );
break;
}
}
}