PHP Class Themosis\Taxonomy\TaxonomyBuilder

Inheritance: extends Themosis\Field\Wrapper
Show file Open project: themosis/framework

Protected Properties

Property Type Description
$action Themosis\Hook\IHook
$container Themosis\Foundation\Application
$datas Themosis\Foundation\DataContainer Store the taxonomy data.
$fields array The taxonomy custom fields.
$prefix string
$validator Themosis\Validation\ValidationBuilder
$view Illuminate\View\Factory

Public Methods

Method Description
__construct ( Application $container, DataContainer $datas, Themosis\Hook\IHook $action, ValidationBuilder $validator, Illuminate\View\Factory $view ) Build a TaxonomyBuilder instance.
addFields ( array $fields, string $taxonomy = '' ) : TaxonomyBuilder Register/display taxonomy custom fields.
bind ( ) : TaxonomyBuilder Link the taxonomy to its custom post type. Allow the taxonomy to be found in 'parse_query' or 'pre_get_posts' filters.
displayAddFields ( ) Display fields on add form screen.
displayEditFields ( stdClass $term ) Display fields on edit form screen.
get ( null $property = null ) : array Return a defined taxonomy property.
make ( string $name, string | array $postType, string $plural, string $singular ) : TaxonomyBuilder
register ( ) Triggered by the 'init' action/event.
registerFields ( ) Register the term meta.
sanitize ( array $rules = [] ) : TaxonomyBuilder Sanitize custom fields values by using passed rules.
sanitizeField ( mixed $value, string $key, string $type ) : mixed Used to run the sanitize callbacks.
save ( integer $term_id ) Save term custom field data to database.
set ( array $params = [] ) : TaxonomyBuilder Set the custom taxonomy. A user can also override the arguments by passing an array of taxonomy arguments.

Protected Methods

Method Description
getValue ( integer $term_id, Themosis\Field\Fields\IField $field, string $value = '' ) : mixed | string Return a default value for the custom fields.
setDefaultArguments ( array $posttypes, string $plural, string $singular ) : array Set the taxonomy default arguments.
setNonce ( ) Set a custom nonce.

Method Details

__construct() public method

Build a TaxonomyBuilder instance.
public __construct ( Application $container, DataContainer $datas, Themosis\Hook\IHook $action, ValidationBuilder $validator, Illuminate\View\Factory $view )
$container Themosis\Foundation\Application
$datas Themosis\Foundation\DataContainer The taxonomy properties.
$action Themosis\Hook\IHook
$validator Themosis\Validation\ValidationBuilder
$view Illuminate\View\Factory

addFields() public method

Can be called without the need to create a custom taxonomy previously (pass taxonomy name as second parameter to the method).
public addFields ( array $fields, string $taxonomy = '' ) : TaxonomyBuilder
$fields array A list of custom fields to use.
$taxonomy string The taxonomy name used to attach the fields to.
return TaxonomyBuilder

bind() public method

Link the taxonomy to its custom post type. Allow the taxonomy to be found in 'parse_query' or 'pre_get_posts' filters.
public bind ( ) : TaxonomyBuilder
return TaxonomyBuilder

displayAddFields() public method

Display fields on add form screen.
public displayAddFields ( )

displayEditFields() public method

Display fields on edit form screen.
public displayEditFields ( stdClass $term )
$term stdClass The term object

get() public method

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

getValue() protected method

Return a default value for the custom fields.
protected getValue ( integer $term_id, Themosis\Field\Fields\IField $field, string $value = '' ) : mixed | string
$term_id integer
$field Themosis\Field\Fields\IField
$value string
return mixed | string

make() public method

public make ( string $name, string | array $postType, string $plural, string $singular ) : TaxonomyBuilder
$name string The taxonomy slug name.
$postType string | array The taxonomy object type slug: 'post', 'page', ...
$plural string The taxonomy plural display name.
$singular string The taxonomy singular display name.
return TaxonomyBuilder

register() public method

Register the custom taxonomy.
public register ( )

registerFields() public method

Register the term meta.
public registerFields ( )

sanitize() public method

Sanitize custom fields values by using passed rules.
public sanitize ( array $rules = [] ) : TaxonomyBuilder
$rules array Sanitize rules.
return TaxonomyBuilder

sanitizeField() public method

Used to run the sanitize callbacks.
public sanitizeField ( mixed $value, string $key, string $type ) : mixed
$value mixed
$key string
$type string
return mixed

save() public method

Save term custom field data to database.
public save ( integer $term_id )
$term_id integer

set() public method

Set the custom taxonomy. A user can also override the arguments by passing an array of taxonomy arguments.
public set ( array $params = [] ) : TaxonomyBuilder
$params array Taxonomy arguments to override defaults.
return TaxonomyBuilder

setDefaultArguments() protected method

Set the taxonomy default arguments.
protected setDefaultArguments ( array $posttypes, string $plural, string $singular ) : array
$posttypes array The post type names to attach the taxonomy to.
$plural string The plural display name.
$singular string The singular display name.
return array

setNonce() protected method

Set a custom nonce.
protected setNonce ( )

Property Details

$action protected property

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

$container protected property

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

$datas protected property

Store the taxonomy data.
protected DataContainer,Themosis\Foundation $datas
return Themosis\Foundation\DataContainer

$fields protected property

The taxonomy custom fields.
protected array $fields
return array

$prefix protected property

protected string $prefix
return string

$validator protected property

protected ValidationBuilder,Themosis\Validation $validator
return Themosis\Validation\ValidationBuilder

$view protected property

protected Factory,Illuminate\View $view
return Illuminate\View\Factory