PHP Class Themosis\PostType\PostTypeBuilder

Inheritance: implements Themosis\PostType\IPostType
Datei anzeigen Open project: themosis/framework

Protected Properties

Property Type Description
$action Themosis\Hook\IHook
$container Themosis\Foundation\Application Application container.
$datas Themosis\Foundation\DataContainer PostTypeData instance.
$filter Themosis\Hook\IHook
$metabox Themosis\Metabox\IMetabox The custom publish metabox.
$postType object | WP_Error The registered custom post type.
$prefix string Instance abstract name prefix for registration into the container.
$status array The custom statuses.
$view Illuminate\View\View The custom view used for publish metabox.

Public Methods

Method Description
__construct ( Application $container, DataContainer $datas, Themosis\Metabox\IMetabox $metabox, Illuminate\View\View $view, Themosis\Hook\IHook $action, Themosis\Hook\IHook $filter ) Build a custom post type.
applyStatus ( string $value ) : mixed Apply the selected status to the post on save.
get ( null $property = null ) : array Return a defined post type property.
has_status ( ) : boolean Check if the custom post type has statuses registered.
instance ( ) : stdClass | WP_Post_type Return the WordPress post type instance.
make ( string $name, string $plural, string $singular ) : PostTypeBuilder Define a new custom post type.
register ( ) Triggered by the 'init' action event.
removeDefaultPublishBox ( ) Remove default publish metabox from the custom post type edit screen.
reorderStatusViews ( array $views ) : array Re-order the status views/links on top of the List Table.
set ( array $params = [] ) : PostTypeBuilder Set the custom post type. A user can also override the arguments by passing an array of custom post type arguments.
setTitle ( string $title ) : PostTypeBuilder Allow a user to change the title placeholder text.
status ( array | string $status, array $args = [] ) : PostTypeBuilder Add custom post type status.

Protected Methods

Method Description
exposeStatuses ( ) Handle output of custom statuses to admin JS object.
setDefaultArguments ( string $plural, string $singular ) : array Set the custom post type default arguments.

Method Details

__construct() public method

Build a custom post type.
public __construct ( Application $container, DataContainer $datas, Themosis\Metabox\IMetabox $metabox, Illuminate\View\View $view, Themosis\Hook\IHook $action, Themosis\Hook\IHook $filter )
$container Themosis\Foundation\Application The application container.
$datas Themosis\Foundation\DataContainer The post type properties.
$metabox Themosis\Metabox\IMetabox The custom metabox for custom publish metabox
$view Illuminate\View\View The view that handles custom publish metabox
$action Themosis\Hook\IHook The action class
$filter Themosis\Hook\IHook The filter class

applyStatus() public method

Apply the selected status to the post on save.
public applyStatus ( string $value ) : mixed
$value string The translated value by WordPress (is always "publish" for some reasons.)
return mixed

exposeStatuses() protected method

Handle output of custom statuses to admin JS object.
protected exposeStatuses ( )

get() public method

Return a defined post type property.
public get ( null $property = null ) : array
$property null
return array

has_status() public method

Check if the custom post type has statuses registered.
public has_status ( ) : boolean
return boolean

instance() public method

Return the WordPress post type instance.
public instance ( ) : stdClass | WP_Post_type
return stdClass | WP_Post_type if WordPress 4.6+

make() public method

Define a new custom post type.
public make ( string $name, string $plural, string $singular ) : PostTypeBuilder
$name string The post type slug name.
$plural string The post type plural name for display.
$singular string The post type singular name for display.
return PostTypeBuilder

register() public method

Register a WordPress custom post type.
public register ( )

removeDefaultPublishBox() public method

Remove default publish metabox from the custom post type edit screen.

reorderStatusViews() public method

If there is a 'trash' view, move it to last position for better user experience.
public reorderStatusViews ( array $views ) : array
$views array The statuses views.
return array

set() public method

Set the custom post type. A user can also override the arguments by passing an array of custom post type arguments.
public set ( array $params = [] ) : PostTypeBuilder
$params array The custom post type arguments.
return PostTypeBuilder

setDefaultArguments() protected method

Set the custom post type default arguments.
protected setDefaultArguments ( string $plural, string $singular ) : array
$plural string The post type plural display name.
$singular string The post type singular display name.
return array

setTitle() public method

Allow a user to change the title placeholder text.
public setTitle ( string $title ) : PostTypeBuilder
$title string The title placeholder text.
return PostTypeBuilder

status() public method

Add custom post type status.
public status ( array | string $status, array $args = [] ) : PostTypeBuilder
$status array | string The status key name.
$args array The status arguments.
return PostTypeBuilder

Property Details

$action protected_oe property

protected IHook,Themosis\Hook $action
return Themosis\Hook\IHook

$container protected_oe property

Application container.
protected Application,Themosis\Foundation $container
return Themosis\Foundation\Application

$datas protected_oe property

PostTypeData instance.
protected DataContainer,Themosis\Foundation $datas
return Themosis\Foundation\DataContainer

$filter protected_oe property

protected IHook,Themosis\Hook $filter
return Themosis\Hook\IHook

$metabox protected_oe property

The custom publish metabox.
protected IMetabox,Themosis\Metabox $metabox
return Themosis\Metabox\IMetabox

$postType protected_oe property

The registered custom post type.
protected object|WP_Error $postType
return object | WP_Error

$prefix protected_oe property

Instance abstract name prefix for registration into the container.
protected string $prefix
return string

$status protected_oe property

The custom statuses.
protected array $status
return array

$view protected_oe property

The custom view used for publish metabox.
protected View,Illuminate\View $view
return Illuminate\View\View