Skip to content

Type_List_Table

linchpin edited this page Feb 22, 2023 · 10 revisions

Type_List_Table

Type_List_Table Class

Methods

get_columns

Returns columns.

public get_columns(): array|void

column_default

Define what data to show on each column of the table

public column_default(array $item, string $column_name): mixed

Parameters:

Parameter Type Description
$item array Data.
$column_name string Current column name.

no_items

Text for when no items are available.

public no_items(): mixed

display

Display the table

public display(): mixed

prepare_items

Prepare Items in the list.

public prepare_items(): mixed

Query, filter data, handle sorting, pagination, and any other data-manipulation required prior to rendering.


get_hidden_columns

Define which columns are hidden

public get_hidden_columns(): array

get_sortable_columns

Define the sortable columns

public get_sortable_columns(): array

column_cb

Get value for checkbox column.

protected column_cb(object $item): string

Parameters:

Parameter Type Description
$item object A row's data.

Return Value:

Text to be placed inside the column

.

fetch_table_data

Get the data for our table

public fetch_table_data(): array

filter_table_data

Filter the terms based on searching the table

public filter_table_data(array $table_data, string $search_key): array

Parameters:

Parameter Type Description
$table_data array The table data.
$search_key string The search key.

handle_table_actions

Handles bulk actions.

public handle_table_actions(): mixed

column_title

Method for rendering the user_login column.

protected column_title(array $item): string

Adds row action links to the user_login column. e.g. url/users.php?page=nds-wp-list-table-demo&action=view_usermeta&user=18&_wpnonce=1984253e5e

Parameters:

Parameter Type Description
$item array The current item.

column_notice_delete

Display if this is a default term

protected column_notice_delete( $item): string

Parameters:

Parameter Type Description
$item ****

column_notice_default

Show is a column is a default title.

protected column_notice_default( $item): string

Parameters:

Parameter Type Description
$item ****

Inherited methods

__construct

Constructor.

public __construct(array|string $args = array()): mixed

The child class should call this constructor from its own constructor to override the default $args.

Parameters:

Parameter Type Description
$args array|string {
Array or string of arguments.

@type string $plural Plural value used for labels and the objects being listed.
This affects things such as CSS class-names and nonces used
in the list table, e.g. 'posts'. Default empty.
@type string $singular Singular label for an object being listed, e.g. 'post'.
Default empty
@type bool $ajax Whether the list table supports Ajax. This includes loading
and sorting data, for example. If true, the class will call
the _js_vars() method in the footer to provide variables
to any scripts handling Ajax events. Default false.
@type string $screen String containing the hook name used to determine the current
screen. If left null, the current screen will be automatically set.
Default null.
}

__get

Make private properties readable for backward compatibility.

public __get(string $name): mixed

Parameters:

Parameter Type Description
$name string Property to get.

Return Value:

Property.


__set

Make private properties settable for backward compatibility.

public __set(string $name, mixed $value): mixed

Parameters:

Parameter Type Description
$name string Property to check if set.
$value mixed Property value.

Return Value:

Newly-set property.


__isset

Make private properties checkable for backward compatibility.

public __isset(string $name): bool

Parameters:

Parameter Type Description
$name string Property to check if set.

Return Value:

Whether the property is set.


__unset

Make private properties un-settable for backward compatibility.

public __unset(string $name): mixed

Parameters:

Parameter Type Description
$name string Property to unset.

__call

Make private/protected methods readable for backward compatibility.

public __call(string $name, array $arguments): mixed|bool

Parameters:

Parameter Type Description
$name string Method to call.
$arguments array Arguments to pass when calling.

Return Value:

Return value of the callback, false otherwise.


ajax_user_can

Checks the current user's permissions

public ajax_user_can(): mixed

prepare_items

Prepares the list of items for displaying.

public prepare_items(): mixed

set_pagination_args

An internal method that sets all the necessary pagination arguments

protected set_pagination_args(array|string $args): mixed

Parameters:

Parameter Type Description
$args array|string Array or string of arguments with information about the pagination.

get_pagination_arg

Access the pagination args.

public get_pagination_arg(string $key): int

Parameters:

Parameter Type Description
$key string Pagination argument to retrieve. Common values include 'total_items',
'total_pages', 'per_page', or 'infinite_scroll'.

Return Value:

Number of items that correspond to the given pagination argument.


has_items

Whether the table has items to display or not

public has_items(): bool

no_items

Message to be displayed when there are no items

public no_items(): mixed

search_box

Displays the search box.

public search_box(string $text, string $input_id): mixed

Parameters:

Parameter Type Description
$text string The 'submit' button label.
$input_id string ID attribute value for the search input field.

get_views

Get an associative array ( id => link ) with the list of views available on this table.

protected get_views(): array

views

Display the list of views available on this table.

public views(): mixed

get_bulk_actions

Get an associative array ( option_name => option_title ) with the list of bulk actions available on this table.

protected get_bulk_actions(): array

bulk_actions

Display the bulk actions dropdown.

protected bulk_actions(string $which = ''): mixed

Parameters:

Parameter Type Description
$which string The location of the bulk actions: 'top' or 'bottom'.
This is designated as optional for backward compatibility.

current_action

Get the current action selected from the bulk actions dropdown.

public current_action(): string|false

Return Value:

The action name or False if no action was selected


row_actions

Generate row actions div

protected row_actions(string[] $actions, bool $always_visible = false): string

Parameters:

Parameter Type Description
$actions string[] An array of action links.
$always_visible bool Whether the actions should be always visible.

months_dropdown

Display a monthly dropdown for filtering items

protected months_dropdown(string $post_type): mixed

Parameters:

Parameter Type Description
$post_type string

view_switcher

Display a view switcher

protected view_switcher(string $current_mode): mixed

Parameters:

Parameter Type Description
$current_mode string

comments_bubble

Display a comment count bubble

protected comments_bubble(int $post_id, int $pending_comments): mixed

Parameters:

Parameter Type Description
$post_id int The post ID.
$pending_comments int Number of pending comments.

get_pagenum

Get the current page number

public get_pagenum(): int

get_items_per_page

Get number of items to display on a single page

protected get_items_per_page(string $option, int $default = 20): int

Parameters:

Parameter Type Description
$option string
$default int

pagination

Display the pagination.

protected pagination(string $which): mixed

Parameters:

Parameter Type Description
$which string

get_columns

Get a list of columns. The format is: 'internal-name' => 'Title'

public get_columns(): array

get_sortable_columns

Get a list of sortable columns. The format is: 'internal-name' => 'orderby' or 'internal-name' => array( 'orderby', true )

protected get_sortable_columns(): array

The second format will make the initial sorting order be descending


get_default_primary_column_name

Gets the name of the default primary column.

protected get_default_primary_column_name(): string

Return Value:

Name of the default primary column, in this case, an empty string.


get_primary_column

Public wrapper for WP_List_Table::get_default_primary_column_name().

public get_primary_column(): string

Return Value:

Name of the default primary column.


get_primary_column_name

Gets the name of the primary column.

protected get_primary_column_name(): string

Return Value:

The name of the primary column.


get_column_info

Get a list of all, hidden and sortable columns, with filter applied

protected get_column_info(): array

get_column_count

Return number of visible columns

public get_column_count(): int

print_column_headers

Print column headers, accounting for hidden and sortable columns.

public print_column_headers(bool $with_id = true): mixed

Parameters:

Parameter Type Description
$with_id bool Whether to set the id attribute or not

display

Display the table

public display(): mixed

get_table_classes

Get a list of CSS classes for the WP_List_Table table tag.

protected get_table_classes(): array

Return Value:

List of CSS classes for the table tag.


display_tablenav

Generate the table navigation above or below the table

protected display_tablenav(string $which): mixed

Parameters:

Parameter Type Description
$which string

extra_tablenav

Extra controls to be displayed between bulk actions and pagination

protected extra_tablenav(string $which): mixed

Parameters:

Parameter Type Description
$which string

display_rows_or_placeholder

Generate the tbody element for the list table.

public display_rows_or_placeholder(): mixed

display_rows

Generate the table rows

public display_rows(): mixed

single_row

Generates content for a single row of the table

public single_row(object $item): mixed

Parameters:

Parameter Type Description
$item object The current item

column_default

protected column_default(object $item, string $column_name): mixed

Parameters:

Parameter Type Description
$item object
$column_name string

column_cb

protected column_cb(object $item): mixed

Parameters:

Parameter Type Description
$item object

single_row_columns

Generates the columns for a single row of the table

protected single_row_columns(object $item): mixed

Parameters:

Parameter Type Description
$item object The current item

handle_row_actions

Generates and display row actions links for the list table.

protected handle_row_actions(object $item, string $column_name, string $primary): string

Parameters:

Parameter Type Description
$item object The item being acted upon.
$column_name string Current column name.
$primary string Primary column name.

Return Value:

The row actions HTML, or an empty string if the current column is the primary column.


ajax_response

Handle an incoming ajax request (called from admin-ajax.php)

public ajax_response(): mixed

_js_vars

Send required variables to JavaScript land

public _js_vars(): mixed


Automatically generated from source code comments on 2023-02-22 using phpDocumentor and saggre/phpdocumentor-markdown