Class: AC\Column\Context
The AC\Column\Context class contains the properties, options, and methods of a column.
The specific class of this object changes depending on the column's type (e.g., a standard Custom Field column, an ACF column, a MetaBox column, etc.). You can use instanceof to check the object's class and safely access methods and properties unique to that column type.
There main scenario where you might want to use AC\Column\Context:
If you have been using a filter or action to hook into Admin Columns and one of the callback values is a column context object.
Class: AC\Column\Context
This is the generic, base context object that all other column contexts extend. It provides access to common column properties.
The class is located at /admin-columns/classes/Column/Context.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_type_label()
Returns the hard-coded label for the column. e.g. Featured Image, Custom Field, Slug
get( $name )
Returns a column option set by the user.
Example usage:
get('label')
Returns the custom set column header label e.g. My custom Label
get('width')
Returns an array with the width and width_unit of the column.
e.g. [ 'width' => 200, 'width_unit' => 'px' ]
get('field')
Returns the meta_key for a Custom Field column. e.g. my_meta_key
get('field_type')
Returns the type of field for a Custom Field column. e.g. date , image , excerpt , numeric
all()
Returns an array with all column options set by the user.
Class: AC\Column\CustomFieldContext
For native WordPress "Custom Field" columns. It extends AC\Column\Context
The class is located at /admin-columns/classes/Column/CustomFieldContext.php and can be viewed on github.
get_meta_key()
Returns the meta key of the custom field . e.g. _page_template , my_custom_field_key
get_meta_type()
Returns the meta type of the custom field. e.g. post , user , comment, term
get_taxonomy()
Returns the taxonomy name when available. e.g. post_tag , category , custom_term
get_post_type()
Returns the post type name when available. e.g. page , post , product
get_field_type()
Returns the display format for the field. e.g. date, image, numeric
Column Context for Add-ons
Below is a list of the different Column Context classes that are available.
They all extend AC\Column\CustomFieldContext
-
Advanced Custom Field:
ACA\ACF\Column\Context -
JetEngine Field:
ACA\JetEngine\Column\FieldContext -
JetEngine Relational Field:
ACA\JetEngine\Column\RelationContext -
MetaBox Field:
ACA\MetaBox\Column\FieldContext -
MetaBox Relational Field:
ACA\MetaBox\Column\RelationContext -
Pods Field:
ACA\Pods\Column\FieldContext -
Toolset Types Field:
ACA\Types\Column\FieldContext -
Toolset Types Relational Field:
ACA\Types\Column\RelationshipContext
Code Examples
Code examples are available for all context objects, using the ac/column/render hook to illustrate each object’s properties and method usage.
All code examples are located on github.