Skip to content

Instantly share code, notes, and snippets.

View gvgvgvijayan's full-sized avatar

Vijayan gvgvgvijayan

View GitHub Profile
<?php
...
/**
* Column cb.
*
* @param array $item Item data.
* @return string
*/
public function column_cb( $item ) {
return sprintf(
<?php
...
/**
* Return title column.
*
* @param array $item Item data.
* @return string
*/
public function column_title( $item ) {
$edit_url = get_edit_post_link( $item['id'] );
<?php
...
/**
* Get list columns.
*
* @return array
*/
public function get_columns() {
return array(
<?php
...
/**
* The Default columns
*
* @param array $item The Item being displayed.
* @param string $column_name The column we're currently in.
* @return string The Content to display
*/
public function column_default( $item, $column_name ) {
<?php
...
/**
* Display text for when there are no items.
*/
public function no_items() {
esc_html_e( 'No posts found.', 'admin-table-tut' );
}
...
<?php
...
/**
* Return instances post object.
*
* @return WP_Query Custom query object with passed arguments.
*/
protected function get_posts_object() {
$post_types = $this->allowed_post_types;
<?php
...
/**
* A map method return all allowed post types to human readable format.
*
* @return array Array of allowed post types in human readable format.
*/
private function allowed_post_types_readable() {
$formatted = array_map(
array( $this, 'human_readable' ),
<?php
...
/**
* Convert slug string to human readable.
*
* @param string $title String to transform human readable.
*
* @return string Human readable of the input string.
*/
<?php
...
/**
* Retrieve post types to be shown in the table.
*
* @return array Allowed post types in an array.
*/
private function allowed_post_types() {
$post_types = get_post_types( array( 'public' => true ) );
unset( $post_types['attachment'] );
<?php
...
/**
* Draft_List_Table constructor.
*/
public function __construct() {
parent::__construct(
array(
'singular' => 'Draft',