### Quick Install Script Source: https://github.com/codepress/admin-columns/blob/main/CONTRIBUTING.md Run this script from the admin-columns/ folder for a full development setup, including PHP and frontend dependencies. ```bash ./install.sh ``` -------------------------------- ### Install Frontend Dependencies Source: https://github.com/codepress/admin-columns/blob/main/CONTRIBUTING.md Install frontend dependencies using npm and run the development setup script. This is only necessary if you plan to make frontend changes. ```bash npm install npm run setup:dev ``` -------------------------------- ### Complete ListScreenCollection Usage Example Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/api-reference-collections.md Demonstrates the full lifecycle of a `ListScreenCollection`, including creation, adding screens, checking for existence, counting, retrieving the first item, iterating, getting an array copy, and removing screens. ```php use AC\ListScreenCollection; // Create collection $collection = new ListScreenCollection(); // Add screens $collection->add($screen1); $collection->add($screen2); // Check contents if ($collection->contains($screen1)) { echo 'Screen found'; } // Count $total = count($collection); // Get first $first = $collection->first(); // Iterate foreach ($collection as $id => $screen) { echo $screen->get_title(); } // Get array copy $screens_array = $collection->get_copy(); // Remove $collection->remove($screen1); ``` -------------------------------- ### Complete ColumnCollection Usage Example Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/api-reference-collections.md Provides a comprehensive example of using ColumnCollection, covering creation, adding columns, iteration, retrieving the first column, counting, and conversion from an iterator. ```php use AC\ColumnCollection; // Create empty $collection = new ColumnCollection(); // Add columns $collection->add($column1); $collection->add($column2); // Iterate foreach ($collection as $column) { echo $column->get_label(); } // Get first $first = $collection->first(); // Count $total = count($collection); // Convert from iterator $existing_iterator = $list_screen->get_columns(); $new_collection = ColumnCollection::from_iterator($existing_iterator); ``` -------------------------------- ### Complete List Screen Usage Example Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/api-reference-list-screen.md Demonstrates how to retrieve a list screen, access its properties, iterate through its columns, check user permissions, and get relevant URLs. This snippet is useful for understanding the core functionalities of the Admin Columns API. ```php use AC\Type\ColumnId; add_action('wp_loaded', function() { // Get a list screen $layout = ac_get_list_screen('post-posts'); if (!$layout) { return; } // Access basic properties echo 'Title: ' . $layout->get_title(); echo 'Table: ' . $layout->get_table_id(); echo 'Screen: ' . $layout->get_screen_id(); // Iterate columns foreach ($layout->get_columns() as $column) { echo $column->get_label() . ' (' . $column->get_type() . ')'; // Get column settings if ($column->get_setting('my_setting')) { // Process setting } } // Check user access $current_user = wp_get_current_user(); if ($layout->is_user_allowed($current_user)) { echo 'User can access this layout'; } // Get URLs echo 'View table: ' . $layout->get_table_url(); echo 'Edit layout: ' . $layout->get_editor_url(); }); ``` -------------------------------- ### Complete AdminColumns Plugin Usage Example Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/api-reference-admin-columns.md A comprehensive example demonstrating how to access plugin information (version, paths, basename) and use it to enqueue admin styles within a WordPress admin menu action hook. ```php add_action('admin_menu', function() { $plugin = AC(); // Get plugin information $version = $plugin->get_version(); $dir_path = $plugin->get_dir_path(); $dir_url = $plugin->get_dir_url(); $basename = $plugin->get_basename(); $file = $plugin->get_file(); // Use in your code if (is_plugin_active($basename)) { // Enqueue assets wp_enqueue_style( 'my-admin-style', $dir_url . 'assets/css/admin.css', [], (string)$version ); } }); ``` -------------------------------- ### Install PHP Dependencies Source: https://github.com/codepress/admin-columns/blob/main/CONTRIBUTING.md Install the plugin's PHP dependencies using Composer. This also handles build tooling and namespace prefixing. ```bash composer install ``` -------------------------------- ### Plugin Initialization Hooks Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/api-reference-admin-columns.md Hook into the plugin's setup process using `after_setup_theme`. Ensure the plugin is loaded and initialized correctly. ```php add_action('after_setup_theme', static function () { require __DIR__ . '/vendor/autoload.php'; require __DIR__ . '/api.php'; if ( ! defined('ACP_VERSION')) { $container = new Container( (new ContainerBuilder()) ->addDefinitions(require __DIR__ . '/settings/container-definitions.php') ->build() ); new Loader($container); } }, 1); add_action('after_setup_theme', static function () { do_action('ac/ready'); }, 2); ``` -------------------------------- ### Registry: Get, Check, and Set Services Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/quick-reference.md Interact with the service registry to get, check for the existence of, or register services. ```php // Get a service $service = Registry::get(string $id, $default = null) // Check existence $exists = Registry::has(string $id): bool // Register a service Registry::set(string $id, $value): void ``` -------------------------------- ### Displaying Column Information Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/api-reference-column.md Example of how to retrieve and display basic information about columns. ```APIDOC ## Displaying Column Information ### Description Iterates through a list of columns and prints their ID, type, label, and group. ### Usage Example ```php add_action('wp_loaded', function() { $columns = ac_get_columns('post-posts'); foreach ($columns as $column) { printf( "ID: %s | Type: %s | Label: %s | Group: %s\n", $column->get_id(), $column->get_type(), $column->get_label(), $column->get_group() ); if ($column->get_description()) { echo "Description: " . $column->get_description() . "\n"; } } }); ``` ``` -------------------------------- ### Get All Registered Repositories Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/api-reference-list-screen-repository.md Retrieves an array of all registered repositories from the Storage class. ```php public function get_repositories(): array ``` -------------------------------- ### ListScreenId Usage Example Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/types.md Demonstrates how to create a ListScreenId, retrieve its ID, and check for validity before instantiation. It also shows the __toString method. ```php use AC\Type\ListScreenId; $id = new ListScreenId('post-posts'); echo $id->get_id(); // "post-posts" echo $id; // "post-posts" (has __toString) // Check validity before constructing if (ListScreenId::is_valid_id($user_input)) { $id = new ListScreenId($user_input); } ``` -------------------------------- ### Instantiate ListScreen Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/api-reference-list-screen.md Example of creating a new ListScreen instance with a custom ID, title, table screen, and a collection of columns. User preferences can also be set during instantiation. ```php use AC\ListScreen; use AC\Type\ListScreenId; use AC\TableScreen; use AC\ColumnCollection; use AC\Type\TableId; use AC\Type\Labels; use AC\Type\Uri; $list_screen = new ListScreen( new ListScreenId('custom-layout-1'), 'My Custom Layout', $table_screen, new ColumnCollection([ $column1, $column2 ]), [ 'users' => [1, 2], 'roles' => ['editor', 'contributor'] ] ); ``` -------------------------------- ### ColumnId Usage Example Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/types.md Shows how to create a ColumnId instance and use it to retrieve a column from a list screen. ```php use AC\Type\ColumnId; $id = new ColumnId('post_title'); $column = $list_screen->get_column($id); ``` -------------------------------- ### Registry: Get Common Storage Service Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/quick-reference.md Retrieve the ListScreenRepository Storage service from the registry. ```php // Common service $storage = Registry::get(AC\ListScreenRepository\Storage::class) ``` -------------------------------- ### Graceful Degradation Examples Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/architecture-and-integration.md Demonstrates how the plugin handles non-existent list screens and collection operations without throwing exceptions, returning null or empty collections instead. ```php // No exception if list screen not found $screen = ac_get_list_screen('invalid-id'); // Returns null, not exception // No exception on collection operations $screens = ac_get_list_screens('post-posts'); // Returns empty collection, never null ``` -------------------------------- ### ListScreenStatus Usage Example Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/types.md Illustrates creating active and inactive ListScreenStatus objects using both the constructor and static factory methods, and how to set the status for a list screen. ```php use AC\Type\ListScreenStatus; // Create active status $status = new ListScreenStatus(); $status = ListScreenStatus::create_active(); // Create inactive status $status = ListScreenStatus::create_inactive(); // Use in list screen $list_screen->set_status($status); ``` -------------------------------- ### TableId Usage Example Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/types.md Demonstrates creating a TableId, using it with API functions, and validating input before creating an instance. ```php use AC\Type\TableId; // Create a table identifier $table_id = new TableId('post-posts'); // Use with API functions $screens = ac_get_list_screens('post-posts'); // Verify before creating if (TableId::validate($input)) { $id = new TableId($input); } ``` -------------------------------- ### Access Storage and Find/Save ListScreen Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/README.md Demonstrates how to get the Storage service from the Registry and use it to find a ListScreen by its ID, and then save it. This is used for managing the persistence of list screen configurations. ```php $storage = Registry::get(Storage::class); $screen = $storage->find(new ListScreenId('post-posts')); $storage->save($screen); ``` -------------------------------- ### Get Plugin Information Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/api-reference-public-functions.md Retrieve the version, file path, and URL of the Admin Columns plugin instance. The plugin instance is a singleton and created lazily. ```php $plugin = AC(); echo $plugin->get_version(); echo $plugin->get_file(); echo $plugin->get_dir_path(); echo $plugin->get_dir_url(); ``` -------------------------------- ### Enumerating Available Layouts Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/architecture-and-integration.md Example of how to retrieve and iterate through all available list screen layouts for a specific table type, such as the post list table. ```php add_action('wp_loaded', function() { // Get all layouts for the post list table $screens = ac_get_list_screens('post-posts'); foreach ($screens as $screen) { printf( "Layout: %s (ID: %s, Status: %s)\n", $screen->get_title(), $screen->get_id(), $screen->get_status() ); } }); ``` -------------------------------- ### ListScreenCollection Constructor Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/api-reference-collections.md Shows how to initialize a ListScreenCollection, optionally with an array of existing ListScreen objects. This is the primary way to start managing a group of list screens. ```php public function __construct(array $list_screens = []) ``` -------------------------------- ### Clone Plugin into WordPress Source: https://github.com/codepress/admin-columns/blob/main/CONTRIBUTING.md Manually place the plugin into your WordPress installation by cloning the repository into the wp-content/plugins directory. ```bash cd wp-content/plugins git clone https://github.com/codepress/admin-columns.git cd admin-columns ``` -------------------------------- ### ColumnCollection Constructor Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/api-reference-collections.md Shows how to instantiate a ColumnCollection, optionally initializing it with an array of existing columns. This is the starting point for managing a set of columns. ```php use AC\Column\Base; use AC\ColumnCollection; $collection = new ColumnCollection([$column1, $column2]); ``` -------------------------------- ### AC() Instance Methods Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/api-reference-public-functions.md Get the singleton instance of the Admin Columns plugin and access its core methods. ```APIDOC ## AC() ### Description Returns the singleton instance of the Admin Columns plugin. ### Usage ```php $plugin = AC(); echo $plugin->get_version(); echo $plugin->get_file(); echo $plugin->get_dir_path(); echo $plugin->get_dir_url(); ``` ### Notes - Returns the same instance on every call (singleton pattern). - The instance is created lazily on first call. - Safe to call at any time during plugin execution. ``` -------------------------------- ### Mocking Storage for Unit Tests Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/architecture-and-integration.md Provides an example of how to mock the Storage service using PHPUnit's mocking capabilities and register it with the Registry for use in unit tests. ```php // For unit tests, you might mock the Storage $mock_storage = $this->createMock(Storage::class); Registry::set(Storage::class, $mock_storage); // Now your code will use mock ``` -------------------------------- ### Processing All Columns for a List Screen Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/api-reference-collections.md This example shows how to retrieve all list screens for a given post type and then iterate through each screen to access and count its associated columns. ```php add_action('wp_loaded', function() { $screens = ac_get_list_screens('post-posts'); foreach ($screens as $screen) { $columns = $screen->get_columns(); echo sprintf( '%s has %d columns: ', $screen->get_title(), count($columns) ); foreach ($columns as $column) { echo $column->get_label() . ', '; } } }); ``` -------------------------------- ### Start Development Watch Mode Source: https://github.com/codepress/admin-columns/blob/main/src/README.md Use these commands to continuously build JavaScript and CSS during development. The Tailwind CSS can be watched separately. ```bash npm run ac:build:development ``` ```bash npm run ac:tailwind ``` -------------------------------- ### Initialize TableScreen with Labels Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/types.md When creating a TableScreen instance, you can pass a Labels object to configure the table's display names. This example shows how to retrieve the plural label from the initialized TableScreen. ```php $table_screen = new TableScreen( new TableId('post-posts'), 'edit-post', new Labels('Post', 'Posts'), $url ); echo $table_screen->get_labels()->get_plural(); // "Posts" ``` -------------------------------- ### Find and Use a Specific Column Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/api-reference-list-screen.md Example of retrieving a single column by its ID and accessing its label if the column is found. ```php use AC\Type\ColumnId; $column = $list_screen->get_column(new ColumnId('post_title')); if ($column) { echo $column->get_label(); } ``` -------------------------------- ### Setting Up Test Environment with wp_loaded Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/architecture-and-integration.md Demonstrates how to set up a testing environment by hooking into the 'wp_loaded' action to ensure the plugin is ready before executing tests with the public API. It also shows how to manually trigger the initialization. ```php // In test setup add_action('wp_loaded', function() { // Plugin is ready // Can now test with public API }); do_action('wp_loaded'); // Trigger initialization ``` -------------------------------- ### Getting and Comparing Plugin Version Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/architecture-and-integration.md Shows how to retrieve the plugin's current version and use version comparison functions to implement feature detection for compatibility with newer plugin versions. ```php $plugin = AC(); $version = $plugin->get_version(); echo (string)$version; // "7.0.19" // Use for feature detection if (version_compare((string)$version, '7.0', '>=')) { // Use features available in 7.0+ } ``` -------------------------------- ### Get Plugin Information Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/quick-reference.md Access various plugin details like version, file path, directory, and base name using the AC() helper. ```php $plugin = AC() $plugin->get_version(): Version $plugin->get_file(): string $plugin->get_dir_path(): string $plugin->get_dir_url(): string $plugin->get_basename(): string // Example echo $plugin->get_dir_url() . 'assets/css/style.css' ``` -------------------------------- ### Access Storage and Find Screens Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/api-reference-list-screen-repository.md Demonstrates how to retrieve the Storage instance from the registry and use it to find list screens by ID or table ID. ```php use AC\Registry; use AC\ListScreenRepository\Storage; use AC\Type\ListScreenId; use AC\Type\TableId; $storage = Registry::get(Storage::class); if (!$storage instanceof Storage) { error_log('Storage not available'); return; } // Find a specific screen $id = new ListScreenId('custom-layout-1'); $screen = $storage->find($id); // Find all screens for a table $table_id = new TableId('post-posts'); $screens = $storage->find_all_by_table_id($table_id); // Save changes if ($screen && !$screen->is_read_only()) { $screen->set_title('Updated Title'); $storage->save($screen); } ``` -------------------------------- ### Access Plugin Instance via Global Function Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/api-reference-admin-columns.md Demonstrates how to get the singleton plugin instance using the global AC() function. This is the recommended way to access the plugin. ```php $plugin = AC(); ``` -------------------------------- ### Complete ColumnIterator Usage Example Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/api-reference-collections.md Illustrates comprehensive usage of the ColumnIterator interface, including counting columns, retrieving the first column, iterating using a foreach loop, and manual iteration with while loop. ```php $columns = $list_screen->get_columns(); // Count columns $count = count($columns); // Get first without iteration $first_column = $columns->first(); // Iterate columns foreach ($columns as $column) { echo $column->get_label(); } // Manual iteration $columns->rewind(); while ($columns->valid()) { $column = $columns->current(); echo $column->get_id(); $columns->next(); } ``` -------------------------------- ### Get the First ListScreen from a Collection Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/api-reference-collections.md Retrieve the first `ListScreen` object from the collection using the `first` method. Returns `null` if the collection is empty. ```php public function first(): ?ListScreen ``` -------------------------------- ### Instantiate Url\Documentation Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/types.md Create an instance of Url\Documentation to generate links to Admin Columns documentation. An optional path can be provided to link to a specific section. ```php new Url\Documentation($path = null); ``` -------------------------------- ### Build for Production Source: https://github.com/codepress/admin-columns/blob/main/src/README.md Execute these commands to create a full production build of the frontend assets, including or excluding language files as needed. ```bash npm run build ``` ```bash npm run build-nolanguage ``` -------------------------------- ### Instantiate Base Column Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/api-reference-column.md Demonstrates how to create a new Base column instance with all its parameters. ```php use AC\Column\Base; use AC\Type\ColumnId; use AC\Setting\ComponentCollection; use AC\Column\Context; use AC\Setting\Config; use AC\FormatterCollection; $column = new Base( 'post_title', // type 'Post Title', // label new ComponentCollection(), // settings new ColumnId('post_title'), // id new Context( // context new Config(['type' => 'post_title']), 'Post Title' ), new FormatterCollection(), // formatters 'primary', // group 'The main post title' // description ); ``` -------------------------------- ### Column API - Context Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/quick-reference.md Get the context of a Column object. ```php // Context $column->get_context(): Context ``` -------------------------------- ### ContainerException Usage Example Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/errors.md Demonstrates how to catch a ContainerException, which is thrown by the dependency injection container for configuration or injection errors. This is useful for debugging container issues. ```php use AC\Exception\ContainerException; try { $container->make('missing-service'); } catch (ContainerException $e) { error_log('Container error: ' . $e->getMessage()); return false; } ``` -------------------------------- ### Countable Methods Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/api-reference-collections.md Method for getting the number of items in the collection. ```APIDOC ## Countable Methods - **count(): int** — Total screens ``` -------------------------------- ### Filtering List Screens by Status and User Permissions Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/api-reference-collections.md This example shows how to create a filtered `ListScreenCollection` containing only active screens that the current user is permitted to access. It utilizes `get_status` and `is_user_allowed` methods. ```php use AC\ListScreenCollection; $all_screens = ac_get_list_screens('post-posts'); $filtered = new ListScreenCollection(); foreach ($all_screens as $screen) { // Only include active screens for current user $user = wp_get_current_user(); if ($screen->get_status() === ListScreenStatus::create_active() && $screen->is_user_allowed($user)) { $filtered->add($screen); } } // Use filtered collection $first = $filtered->first(); ``` -------------------------------- ### Get Table URL Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/api-reference-table-screen.md Retrieves the URL for the table view. ```php public function get_url(): Uri ``` ```php $url = $table_screen->get_url(); echo $url; // "https://example.com/wp-admin/edit.php" ``` -------------------------------- ### DI Container vs. Registry Usage Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/api-reference-registry.md Illustrates the difference between using the DI Container for object construction and the Registry for runtime service access. Shows a common pattern for populating the Registry from the Container during initialization. ```php // DI Container: used during object construction $container->make(ListScreenRepository\Storage::class); // Registry: used for dynamic access $storage = Registry::get(ListScreenRepository\Storage::class); // Common pattern: populated from container during initialization foreach ($important_services as $id => $definition) { Registry::set($id, $container->make($definition)); } ``` -------------------------------- ### Get Table ID Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/api-reference-table-screen.md Retrieves the unique identifier for the table. ```php public function get_id(): TableId ``` ```php $table_id = $table_screen->get_id(); echo $table_id; // e.g., "post-posts" ``` -------------------------------- ### Plugin Initialization Flow Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/architecture-and-integration.md Illustrates the sequence of events during plugin initialization, from WordPress loading the main file to the public API becoming available. ```text Plugin Entry ↓ Loader (initializes all services) ↓ Container (manages dependencies) ├── TableScreenRepository (knows all table types) ├── Storage (aggregates list screen repositories) └── Various factories (create specific objects) Public API ├── ac_get_list_screen() ├── ac_get_list_screens() ├── ac_get_column() └── ac_get_columns() ``` -------------------------------- ### Get Screen ID Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/api-reference-table-screen.md Retrieves the WordPress screen ID for the table. ```php public function get_screen_id(): string ``` ```php $screen_id = $table_screen->get_screen_id(); if ($screen_id === 'edit-post') { // This is the post list table } ``` -------------------------------- ### Get ListScreen Title Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/api-reference-list-screen.md Retrieves the display title of the list screen layout. ```php public function get_title(): string ``` -------------------------------- ### Accessing ListScreenRepository Storage Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/api-reference-registry.md Demonstrates retrieving the main storage service for list screen configurations from the Registry. ```php $storage = Registry::get(AC\ListScreenRepository\Storage::class); $list_screen = $storage->find(new ListScreenId('post-posts')); ``` -------------------------------- ### Get Table Labels Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/api-reference-table-screen.md Retrieves the singular and plural labels associated with the table. ```php public function get_labels(): Labels ``` ```php $labels = $table_screen->get_labels(); echo $labels->get_singular(); // "Post" echo $labels->get_plural(); // "Posts" ``` -------------------------------- ### Instantiate Url\CouponCode Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/types.md Create an instance of Url\CouponCode to generate promotional URLs that include a coupon code. The constructor requires the coupon code string. ```php new Url\CouponCode($coupon_code); ``` -------------------------------- ### Get TableScreen Object Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/api-reference-list-screen.md Retrieves the TableScreen object associated with this list screen layout. ```php public function get_table_screen(): TableScreen ``` -------------------------------- ### Registry Internal Implementation: Lazy Loading Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/api-reference-registry.md Demonstrates the internal mechanism of the Registry, including its static storage and lazy-loading behavior. When a Closure is stored, it is executed only when the service is first accessed via `get()`. ```php private static array $items = []; // Services are keyed by their identifier // Values can be any PHP type or a Closure // When get() is called with a Closure value, it executes the Closure if ($value instanceof Closure) { $value = $value(); // Lazy-load behavior } ``` -------------------------------- ### Get ListScreen ID Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/api-reference-list-screen.md Retrieves the unique identifier for the current list screen layout. ```php public function get_id(): ListScreenId ``` -------------------------------- ### Get Table DOM Selector Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/api-reference-table-screen.md Retrieves the CSS selector for the table element in the DOM. ```php public function get_attr_id(): string ``` ```php $selector = $table_screen->get_attr_id(); // Use in JavaScript to target the table // document.querySelector('#the-list') ``` -------------------------------- ### Inspecting Column Configuration Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/architecture-and-integration.md Demonstrates how to access a specific list screen and iterate through its columns to inspect their labels, types, and settings. ```php add_action('wp_loaded', function() { $screen = ac_get_list_screen('post-posts'); if ($screen) { foreach ($screen->get_columns() as $column) { echo sprintf( "Column: %s (Type: %s, Group: %s)\n", $column->get_label(), $column->get_type(), $column->get_group() ); // Check for specific setting $width = $column->get_setting('width'); if ($width) { // Column has width setting } } } }); ``` -------------------------------- ### Displaying List Screen Information in Admin Notices Source: https://github.com/codepress/admin-columns/blob/main/_autodocs/README.md This example demonstrates how to display list screen titles in admin notices. It includes a check to ensure the code runs after 'wp_loaded' to prevent timing errors. ```php add_action('admin_notices', function() { if (!did_action('wp_loaded')) { return; // Too early } $screens = ac_get_list_screens('post-posts'); foreach ($screens as $screen) { printf( '
Layout: %s