Class: AC\TableScreen
The AC\TableScreen class contains all information about the WordPress List Table.
The class is located at /admin-columns/classes/TableScreen.php and can be viewed on github. Please read over the extended comments found above each function to learn more.
Public Methods
get_id() : AC\Type\TableId
The `TableId` is a hard-coded identifier for each type of list table. There are multiple types of list tables, each with its own identifier:
| List Table | Table ID | Class |
| Posts | post |
AC\TableScreen\Post |
| Pages | page |
AC\TableScreen\Post |
| Custom Post Type | post_type_slug |
AC\TableScreen\Post |
| Users | wp-users |
AC\TableScreen\User |
| Media | wp-media |
AC\TableScreen\Media |
| Comments | wp-comments |
AC\TableScreen\Comment |
| Categories | wp-taxonomy_category |
ACP\TableScreen\Taxonomy |
| Tags | wp-taxonomy_post_tag |
ACP\TableScreen\Taxonomy |
| Custom Taxonomy | wp-taxonomy_taxonomyslug |
ACP\TableScreen\Taxonomy |
| Network Users | wp-ms_users |
ACP\TableScreen\NetworkUser |
The Table ID can be shown on the columns settings page by clicking the menu next to title and then enabling Column Info.
get_labels() : AC\Type\Labels
Returns the labels (singular and plural) of the list table. For example Post(s), Page(s), User(s), or Comment(s).
get_labels()->get_plural() : string e.g. "Posts"
get_labels()->get_singular() : string e.g. "Post"
Code Example
<?php
if ( 'page' === (string)$table->get_id() ) {
// Targets the "Page" list table
}
if ( 'wp-users' === (string)$table->get_id() ) {
// Targets the "Users" list table
}
if ( 'wp-media' === (string)$table->get_id() ) {
// Targets the "Media" list table
}
Class: AC/TableScreen/Post
Table ID: post
This class AC/TableScreen/Post extends the AC/TableScreen and inherits its methods and has the following additional public methods:
Public Methods
get_post_type() : PostTypeSlug
Return the post-type e.g. post , page , product or custom_post_type_name
Example: (string)$table->get_post-type();
get_meta_type() : string
Returns its meta-type (string). e.g. post
This method is mostly used when working with custom metadata.
Example: get_metadata( (string)$table->get_meta_type(), 1346, 'custom_key' );
Code Example
<?php
if ( $table instanceof AC\TableScreen\Post ) {
// Targets a "Post Types" list table
// output: 'page', 'post', 'product' etc.
$post_type = (string)$table->get_post_type();
// output: 'user', 'post', 'comment', 'term' etc,
$meta_type = (string)$table->get_meta_type();
}
More code examples for the AC\TableScreen can be found on github.
Class: AC/TableScreen/User
Table ID: wp-users
This class AC/TableScreen/User extends the AC/TableScreen and inherits its methods and has the following additional public methods:
Public Methods
get_meta_type() : string
Returns its meta-type (string). e.g. user
This method is mostly used when working with custom metadata.
Example: get_metadata( (string)$table->get_meta_type(), 1346, 'custom_key' );
Code Example
<?php
if ( $table instanceof AC\TableScreen\User ) {
// Targets the "Users" list table
}
Class: AC/TableScreen/Taxonomy
Table ID: wp-users
This class AC/TableScreen/User extends the AC/TableScreen and inherits its methods and has the following additional public methods:
Public Methods
get_taxonomy) : TaxonomySlug
Return the post-type e.g. category, post_tag, my_custom_taxonomy etc.
Example: $taxonomy = (string)get_post_type()
get_meta_type() : string
Returns its meta-type (string). e.g. term
This method is mostly used when working with custom metadata.
Example: get_metadata( (string)$table->get_meta_type(), 1346, 'custom_key' );
Code Example
<?php
if ( $table instanceof AC\TableScreen\Taxonomy ) {
// Targets the "Taxonomies" list table e.g. Categories, Tags, Custom Taxonomy
// output: 'cateogory', 'post_tag' etc.
$taxonomy = (string)$table->get_taxonomy();
}