AdminColumns.php
5.17 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<?php
namespace AC;
use AC\Admin;
use AC\Admin\AdminScripts;
use AC\Admin\PageRequestHandler;
use AC\Admin\PageRequestHandlers;
use AC\Admin\Preference;
use AC\Controller;
use AC\ListScreenRepository\Database;
use AC\ListScreenRepository\Storage;
use AC\Plugin\SetupFactory;
use AC\Plugin\Version;
use AC\Screen\QuickEdit;
use AC\Service;
use AC\Settings\GeneralOption;
use AC\Table;
use AC\ThirdParty;
class AdminColumns extends Plugin {
/**
* @var Storage
*/
private $storage;
/**
* @var self
*/
private static $instance;
public static function instance() {
if ( null === self::$instance ) {
self::$instance = new self;
}
return self::$instance;
}
protected function __construct() {
parent::__construct( AC_FILE, new Version( AC_VERSION ) );
$plugin_information = new PluginInformation( $this->get_basename() );
$is_network_active = $plugin_information->is_network_active();
$is_acp_active = $this->is_acp_active();
$this->storage = new Storage();
$this->storage->set_repositories( [
'acp-database' => new ListScreenRepository\Storage\ListScreenRepository(
new Database( ListScreenTypes::instance() ),
true
),
] );
$location = $this->get_location();
$menu_factory = new Admin\MenuFactory( admin_url( 'options-general.php' ), $location );
$page_handler = new PageRequestHandler();
$page_handler->add( 'columns', new Admin\PageFactory\Columns( $this->storage, $location, $menu_factory, $is_acp_active ) )
->add( 'settings', new Admin\PageFactory\Settings( $location, $menu_factory, $is_acp_active ) )
->add( 'addons', new Admin\PageFactory\Addons( $location, new IntegrationRepository(), $menu_factory ) )
->add( 'help', new Admin\PageFactory\Help( $location, $menu_factory ) );
PageRequestHandlers::add_handler( $page_handler );
$color_repository = new Admin\Colors\ColorRepository( new Admin\Colors\Storage\OptionFactory() );
$services = [
new Admin\Admin( new PageRequestHandlers(), $location, new AdminScripts( $location ) ),
new Admin\Notice\ReadOnlyListScreen(),
new Ajax\NumberFormat( new Request() ),
new ListScreens(),
new Screen(),
new ThirdParty\ACF(),
new ThirdParty\NinjaForms(),
new ThirdParty\WooCommerce(),
new ThirdParty\WPML( $this->storage ),
new Controller\DefaultColumns( new Request(), new DefaultColumnsRepository() ),
new QuickEdit( $this->storage, new Table\LayoutPreference() ),
new Capabilities\Manage(),
new Controller\AjaxColumnRequest( $this->storage, new Request() ),
new Controller\AjaxGeneralOptions( new GeneralOption() ),
new Controller\AjaxRequestCustomFieldKeys(),
new Controller\AjaxColumnModalValue( $this->storage ),
new Controller\AjaxColumnValue( $this->storage ),
new Controller\AjaxScreenOptions( new Preference\ScreenOptions() ),
new Controller\ListScreenRestoreColumns( $this->storage ),
new Controller\RestoreSettingsRequest( $this->storage->get_repository( 'acp-database' ) ),
new PluginActionLinks( $this->get_basename(), $is_acp_active ),
new Controller\TableListScreenSetter( $this->storage, new PermissionChecker(), $location, new Table\LayoutPreference() ),
new Admin\Scripts( $location ),
new Service\IntegrationColumns( new IntegrationRepository() ),
new Service\Colors(
new Admin\Colors\Shipped\ColorUpdater(
new Admin\Colors\Shipped\ColorParser( ABSPATH . 'wp-admin/css/common.css' ),
$color_repository,
new Admin\Colors\Storage\OptionFactory()
),
new Admin\Colors\StyleInjector( $color_repository )
),
];
if ( ! $is_acp_active ) {
$services[] = new Service\NoticeChecks( $location );
}
$setup_factory = new SetupFactory\AdminColumns( 'ac_version', $this->get_version() );
$services[] = new Service\Setup( $setup_factory->create( SetupFactory::SITE ) );
if ( $is_network_active ) {
$services[] = new Service\Setup( $setup_factory->create( SetupFactory::NETWORK ) );
}
array_map( static function ( Registerable $service ) {
$service->register();
}, $services );
}
private function is_acp_active(): bool {
return defined( 'ACP_FILE' );
}
/**
* @return Storage
*/
public function get_storage() {
return $this->storage;
}
/**
* @deprecated 4.3.1
*/
public function admin() {
_deprecated_function( __METHOD__, '4.3.1' );
}
/**
* @since 3.0
* @deprecated 4.0
*/
public function api() {
_deprecated_function( __METHOD__, '4.0' );
}
/**
* @return ListScreen[]
* @deprecated 4.0
*/
public function get_list_screens() {
_deprecated_function( __METHOD__, '4.0', 'ListScreenTypes::instance()->get_list_screens()' );
return ListScreenTypes::instance()->get_list_screens();
}
/**
* @return array
* @since 1.0
* @deprecated 4.1
*/
public function get_post_types() {
_deprecated_function( __METHOD__, '4.1' );
return ( new ListScreens )->get_post_types();
}
/**
* @param ListScreen $list_screen
*
* @return self
* @deprecated 4.1
*/
public function register_list_screen( ListScreen $list_screen ) {
_deprecated_function( __METHOD__, '4.1', 'ListScreenTypes::instance()->register_list_screen()' );
ListScreenTypes::instance()->register_list_screen( $list_screen );
return $this;
}
}