Skip to content

A helper library for registering WordPress custom table CRUD pages with a simpler API

License

Notifications You must be signed in to change notification settings

eighteen73/custom-tables-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WordPress Custom Table API Class

Allows for easier creation of custom table CRUD pages by using an object oriented approach.

An example

use Eighteen73\CustomTablesApi\CustomTablesApi;

$custom_table = new CustomTablesApi(
	'my_custom_table',
	'My Custom Table Data',
	[
		'id' => [
			'type' => 'bigint',
			'length' => '20',
			'auto_increment' => true,
			'primary_key' => true,
		],
		'title' => [
			'type' => 'varchar',
			'length' => '50',
		],
		'status' => [
			'type' => 'varchar',
			'length' => '50',
		],
		'date' => [
			'type' => 'datetime',
		]
	],
	1,
	[
		'title' => [
			'label' => __( 'Title' ),
			'sortable' => 'title', // ORDER BY title ASC
		],
		'status' => [
			'label' => __( 'Status' ),
			'sortable' => [ 'status', false ], // ORDER BY status ASC
		],
		'date' => [
			'label' => __( 'Date' ),
			'sortable' => [ 'date', true ], // ORDER BY date DESC
		],
	]
);

add_action( 'ct_init', [ $custom_table, 'init' ] );

Credits

Heavily based on CT by Ruben Garcia.

About

A helper library for registering WordPress custom table CRUD pages with a simpler API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages