Admin
4 years ago
Ajax
4 years ago
Asset
4 years ago
Autoloader
4 years ago
Capabilities
4 years ago
Check
4 years ago
Column
4 years ago
ColumnRepository
4 years ago
Controller
4 years ago
Deprecated
4 years ago
Exception
4 years ago
Form
4 years ago
Helper
4 years ago
Integration
4 years ago
ListScreen
4 years ago
ListScreenRepository
4 years ago
ListTable
4 years ago
Message
4 years ago
Meta
4 years ago
Plugin
4 years ago
Preferences
4 years ago
Promo
4 years ago
Relation
4 years ago
Request
4 years ago
Response
4 years ago
Sanitize
4 years ago
Screen
4 years ago
Settings
4 years ago
Storage
4 years ago
Table
4 years ago
ThirdParty
4 years ago
Transient
4 years ago
Type
4 years ago
AdminColumns.php
4 years ago
ApplyFilter.php
4 years ago
ArrayIterator.php
4 years ago
Autoloader.php
4 years ago
Builder.php
4 years ago
Capabilities.php
4 years ago
Collection.php
4 years ago
Column.php
4 years ago
ColumnGroups.php
4 years ago
ColumnRepository.php
4 years ago
Config.php
4 years ago
DefaultColumnsRepository.php
4 years ago
Dependencies.php
4 years ago
EncodedListScreenData.php
4 years ago
EncodedListScreenDataFactory.php
4 years ago
Expirable.php
4 years ago
Groups.php
4 years ago
Helper.php
4 years ago
Integration.php
4 years ago
IntegrationRepository.php
4 years ago
Integrations.php
4 years ago
ListScreen.php
4 years ago
ListScreenCollection.php
4 years ago
ListScreenFactory.php
4 years ago
ListScreenGroups.php
4 years ago
ListScreenPost.php
4 years ago
ListScreenRepository.php
4 years ago
ListScreenRepositoryWritable.php
4 years ago
ListScreenTypes.php
4 years ago
ListScreenWP.php
4 years ago
ListScreens.php
4 years ago
ListTable.php
4 years ago
ListTableFactory.php
4 years ago
Message.php
4 years ago
MetaType.php
4 years ago
Middleware.php
4 years ago
NoticeChecks.php
4 years ago
OpCacheInvalidateTrait.php
4 years ago
PermissionChecker.php
4 years ago
Plugin.php
4 years ago
PluginActionLinks.php
4 years ago
PluginInformation.php
4 years ago
Preferences.php
4 years ago
Promo.php
4 years ago
PromoCollection.php
4 years ago
Registrable.php
4 years ago
Relation.php
4 years ago
Renderable.php
4 years ago
Request.php
4 years ago
Sanitize.php
4 years ago
Screen.php
4 years ago
ScreenController.php
4 years ago
Transient.php
4 years ago
TypedArrayIterator.php
4 years ago
View.php
4 years ago
WpListTableFactory.php
4 years ago
AdminColumns.php
183 lines
| 1 | <?php |
| 2 | |
| 3 | namespace AC; |
| 4 | |
| 5 | use AC\Admin\AdminScripts; |
| 6 | use AC\Admin\MenuFactory; |
| 7 | use AC\Admin\Page\Columns; |
| 8 | use AC\Admin\PageFactory; |
| 9 | use AC\Admin\PageRequestHandler; |
| 10 | use AC\Admin\Preference; |
| 11 | use AC\Admin\RequestHandler; |
| 12 | use AC\Admin\WpMenuFactory; |
| 13 | use AC\Asset\Location\Absolute; |
| 14 | use AC\Asset\Script; |
| 15 | use AC\Asset\Style; |
| 16 | use AC\Controller; |
| 17 | use AC\Deprecated; |
| 18 | use AC\ListScreenRepository\Database; |
| 19 | use AC\ListScreenRepository\Storage; |
| 20 | use AC\Plugin\InstallCollection; |
| 21 | use AC\Plugin\Version; |
| 22 | use AC\Screen\QuickEdit; |
| 23 | use AC\Settings\GeneralOption; |
| 24 | use AC\Table; |
| 25 | use AC\ThirdParty; |
| 26 | |
| 27 | class AdminColumns extends Plugin { |
| 28 | |
| 29 | /** |
| 30 | * @var Storage |
| 31 | */ |
| 32 | private $storage; |
| 33 | |
| 34 | /** |
| 35 | * @since 2.5 |
| 36 | * @var self |
| 37 | */ |
| 38 | private static $instance; |
| 39 | |
| 40 | public static function instance() { |
| 41 | if ( null === self::$instance ) { |
| 42 | self::$instance = new self; |
| 43 | } |
| 44 | |
| 45 | return self::$instance; |
| 46 | } |
| 47 | |
| 48 | protected function __construct() { |
| 49 | parent::__construct( AC_FILE, 'ac_version', new Version( AC_VERSION ) ); |
| 50 | |
| 51 | $this->storage = new Storage(); |
| 52 | $this->storage->set_repositories( [ |
| 53 | 'acp-database' => new ListScreenRepository\Storage\ListScreenRepository( |
| 54 | new Database( ListScreenTypes::instance() ), |
| 55 | true |
| 56 | ), |
| 57 | ] ); |
| 58 | |
| 59 | $location = new Absolute( |
| 60 | $this->get_url(), |
| 61 | $this->get_dir() |
| 62 | ); |
| 63 | |
| 64 | RequestHandler::add_handler( |
| 65 | new PageRequestHandler( |
| 66 | new PageFactory( $this->storage, $location, new MenuFactory( admin_url( 'options-general.php' ), new IntegrationRepository() ) ), |
| 67 | Columns::NAME |
| 68 | ) |
| 69 | ); |
| 70 | |
| 71 | $services = [ |
| 72 | new Admin\Admin( new RequestHandler(), new WpMenuFactory(), new AdminScripts( $location ) ), |
| 73 | new Admin\Notice\ReadOnly(), |
| 74 | new Ajax\NumberFormat( new Request() ), |
| 75 | new Deprecated\Hooks, |
| 76 | new ListScreens(), |
| 77 | new Screen, |
| 78 | new ThirdParty\ACF, |
| 79 | new ThirdParty\NinjaForms, |
| 80 | new ThirdParty\WooCommerce, |
| 81 | new ThirdParty\WPML( $this->storage ), |
| 82 | new Controller\DefaultColumns( new Request(), new DefaultColumnsRepository() ), |
| 83 | new QuickEdit( $this->storage, new Table\Preference() ), |
| 84 | new Capabilities\Manage(), |
| 85 | new Controller\AjaxColumnRequest( $this->storage, new Request() ), |
| 86 | new Controller\AjaxGeneralOptions( new GeneralOption() ), |
| 87 | new Controller\AjaxRequestCustomFieldKeys(), |
| 88 | new Controller\AjaxColumnValue( $this->storage ), |
| 89 | new Controller\AjaxScreenOptions( new Preference\ScreenOptions() ), |
| 90 | new Controller\ListScreenRestoreColumns( $this->storage ), |
| 91 | new Controller\RestoreSettingsRequest( $this->storage->get_repository( 'acp-database' ) ), |
| 92 | new PluginActionLinks( $this->get_basename() ), |
| 93 | new NoticeChecks( $this->get_location() ), |
| 94 | new Controller\TableListScreenSetter( $this->storage, new PermissionChecker(), $location, new Table\Preference() ), |
| 95 | ]; |
| 96 | |
| 97 | foreach ( $services as $service ) { |
| 98 | if ( $service instanceof Registrable ) { |
| 99 | $service->register(); |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | $installer = new InstallCollection(); |
| 104 | $installer->add_install( new Plugin\Install\Capabilities() ) |
| 105 | ->add_install( new Plugin\Install\Database() ); |
| 106 | |
| 107 | $this->set_installer( $installer ); |
| 108 | |
| 109 | add_action( 'init', [ $this, 'install' ], 1000 ); |
| 110 | add_action( 'init', [ $this, 'register_global_scripts' ] ); |
| 111 | } |
| 112 | |
| 113 | /** |
| 114 | * @return Storage |
| 115 | */ |
| 116 | public function get_storage() { |
| 117 | return $this->storage; |
| 118 | } |
| 119 | |
| 120 | public function register_global_scripts() { |
| 121 | $assets = [ |
| 122 | new Script( 'ac-select2-core', $this->get_location()->with_suffix( 'assets/js/select2.js' ) ), |
| 123 | new Script( 'ac-select2', $this->get_location()->with_suffix( 'assets/js/select2_conflict_fix.js' ), [ 'jquery', 'ac-select2-core' ] ), |
| 124 | new Style( 'ac-select2', $this->get_location()->with_suffix( 'assets/css/select2.css' ) ), |
| 125 | new Style( 'ac-jquery-ui', $this->get_location()->with_suffix( 'assets/css/ac-jquery-ui.css' ) ), |
| 126 | ]; |
| 127 | |
| 128 | foreach ( $assets as $asset ) { |
| 129 | $asset->register(); |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | /** |
| 134 | * @deprecated 4.3.1 |
| 135 | */ |
| 136 | public function admin() { |
| 137 | _deprecated_function( __METHOD__, '4.3.1' ); |
| 138 | } |
| 139 | |
| 140 | /** |
| 141 | * @since 3.0 |
| 142 | * @deprecated 4.0 |
| 143 | */ |
| 144 | public function api() { |
| 145 | _deprecated_function( __METHOD__, '4.0' ); |
| 146 | } |
| 147 | |
| 148 | /** |
| 149 | * @return ListScreen[] |
| 150 | * @deprecated 4.0 |
| 151 | */ |
| 152 | public function get_list_screens() { |
| 153 | _deprecated_function( __METHOD__, '4.0', 'ListScreenTypes::instance()->get_list_screens()' ); |
| 154 | |
| 155 | return ListScreenTypes::instance()->get_list_screens(); |
| 156 | } |
| 157 | |
| 158 | /** |
| 159 | * @return array |
| 160 | * @since 1.0 |
| 161 | * @deprecated 4.1 |
| 162 | */ |
| 163 | public function get_post_types() { |
| 164 | _deprecated_function( __METHOD__, '4.1' ); |
| 165 | |
| 166 | return ( new ListScreens )->get_post_types(); |
| 167 | } |
| 168 | |
| 169 | /** |
| 170 | * @param ListScreen $list_screen |
| 171 | * |
| 172 | * @return self |
| 173 | * @deprecated 4.1 |
| 174 | */ |
| 175 | public function register_list_screen( ListScreen $list_screen ) { |
| 176 | _deprecated_function( __METHOD__, '4.1', 'ListScreenTypes::instance()->register_list_screen()' ); |
| 177 | |
| 178 | ListScreenTypes::instance()->register_list_screen( $list_screen ); |
| 179 | |
| 180 | return $this; |
| 181 | } |
| 182 | |
| 183 | } |