Post Type
Overview
The Post Type module covers custom post type registration, label and capability builders, list-table integrations, post object wrapping, and insert/update helpers.
Types in this module
Lipe\Lib\Post_Type\CapabilitiesLipe\Lib\Post_Type\Custom_Post_Type(deprecated)Lipe\Lib\Post_Type\LabelsLipe\Lib\Post_Type\Post_List_ColumnLipe\Lib\Post_Type\Post_List_FilterLipe\Lib\Post_Type\Post_Object_TraitLipe\Lib\Post_Type\Post_TypeLipe\Lib\Post_Type\Register_Post_StatusLipe\Lib\Post_Type\Register_Post_TypeLipe\Lib\Post_Type\Wp_Insert_PostLipe\Lib\Post_Type\Post_List_Column\Filter(interface)Lipe\Lib\Post_Type\Post_List_Column\ListColumn(interface)Lipe\Lib\Post_Type\Custom_Post_Type\Register_Post_Type(deprecated)
Post_Type
Primary fluent wrapper for registering a custom post type and related admin behavior.
Key public methods
public function __construct(string $post_type)public function labels(string $singular = '', string $plural = ''): Labelspublic function gutenberg_template(array $template, bool|string $template_lock = false): Post_Typepublic function capabilities(): Capabilitiespublic function archive_label(string $label): voidpublic function add_support(string|array $feature): voidpublic function remove_support(string|array $feature): voidpublic function exclude_from_sitemaps(): voidpublic function disable_single(): voidpublic function rest_controllers(string $base = \WP_REST_Posts_Controller::class, string $autosave = \WP_REST_Autosaves_Controller::class, string $revisions = \WP_REST_Revisions_Controller::class, bool $late_registration = false): voidpublic function show_in_rest(bool $show = true, ?string $base = null, string $space = 'wp/v2'): voidpublic function show_in_menu(Dashicons|string $icon = '', ?string $parent_menu = null, int $position = 5): voidpublic function taxonomies(array $taxonomies): voidpublic static function get_post_type(string $post_type): ?Post_Type
Example
<?php
use Lipe\Lib\Post_Type\Post_Type;
$books = new Post_Type('book');
$books->labels('Book', 'Books');
$books->show_in_rest(true, 'books');
$books->add_support(['title', 'editor', 'thumbnail']);
Labels
Fluent label builder used by Post_Type.
Key public methods
public function name(string $label): Labelspublic function singular_name(string $label): Labelspublic function add_new_item(string $label): Labelspublic function archive_label(string $label): Labelspublic function menu_name(string $label): Labelspublic function get_label(string $label_key): ?stringpublic function get_labels(): array
Capabilities
Fluent capability builder used by Post_Type.
Key public methods
public function edit_post(string $capability): Capabilitiespublic function edit_posts(string $capability): Capabilitiespublic function publish_posts(string $capability): Capabilitiespublic function create_posts(string $capability): Capabilitiespublic function get_cap(string $capability_name): ?stringpublic function get_capabilities(): array
List-table integration
Post_List_Columnregisters a custom admin column and exposespublic function maybe_render_column(string $column, int $post_id): voidandpublic function add_column(array $columns): array.Post_List_Filterconnects aPost_List_Column\Filterimplementation to the list table and exposespublic function render_filter(string $post_type): voidandpublic function maybe_filter_query(\WP_Query $query): void.Post_List_Column\ListColumnandPost_List_Column\Filterdefine the contracts used by those classes.
Supporting types
Post_Object_Traitwraps aWP_Postand exposesget_object(),get_id(),exists(), andfactory().Register_Post_Status,Register_Post_Type, andWp_Insert_Postare fluent arg objects for the corresponding WordPress core functions.Custom_Post_TypeandCustom_Post_Type\Register_Post_Typeare deprecated compatibility layers.