Class: AC\Column
The AC\Column
class contains the properties, options, and methods of a column.
There are two main scenarios where you might want to use AC\Column:
If you have been using a filter or action to hook into Admin Columns and one of the callback values is a column object. Or when you have created a new column yourself and have extended on AC\Column
.
The class is located at /admin-columns/classes/Column.php
and can be viewed on github. Please read over the extended comments found above each function to learn more.
Method and properties
get_name()
Returns the column name. The `Name` is a unique identifier that is assigned when the Column has been stored in the database. e.g. 5eeca98f4e9ba
The Column Name can be found on the columns settings page by opening screen options (in the top-right corner) and then enabling Column Name.
get_type()
Returns the column type. The `Type` is a hard-coded identifier for each type of column. There are many types of columns, each with its own type. e.g. title
, date
or column-meta
.
The Column Type can be found on the columns settings page by opening screen options (in the top-right corner) and then enabling Column Type.
get_label()
Returns the hard-coded label for the column. e.g. Featured Image, Custom Field, Slug
get_option( $name )
Returns a column option set by the user.
Example usage:
get_option('label')
Returns the custom set column header label e.g. My custom Label
get_option('width')
Returns an array with the width and width_unit of the column.
e.g. [ 'width' => 200, 'width_unit' => 'px' ]
get_option('custom_field')
Returns the meta_key for a Custom Field column. e.g. my_meta_key
get_option('field_type')
Returns the type of field for a Custom Field column. e.g. date
, image
, excerpt
, numeric
get_options()
Returns an array
with all column options set by the user.
get_post_type()
Returns the post type name of a column when available. e.g. page
, post
, cars
get_taxonomy()
Returns the taxonomy name of a column when available. e.g. post_tag
, category
, custom_term
get_value( $id )
Property: $id
(int
) is the Post/Comment/User/Term ID. e.g. 2146
Returns the column value that is displayed in the column cell as a string
. e.g. <a href="/post/2146">My Value</a>
get_raw_value( $id )
Returns the raw column value (used by sorting and inline edit ) as an array
or string
. For example, it will return the name of the author without any HTML markup, such as the author link.
is_valid()
Determines if a column should be made available for a specific WordPress list table. Returns true
or false
.
In this example on GitHub, we created a Page Template column that is only available to specific post types which support page templates.
is_original()
Returns true
when the column is not added by Admin Columns. It probably is defined in WordPress core, another plugin or theme. Examples of original columns are the Title, Date or Author column.
get_list_screen()
Returns a AC\ListScreen
object. e.g. AC\ListScreen\Post
Learn more about the AC\ListScreen object.