PHP Class Carbon_Fields\Container\Post_Meta_Container

Inheritance: extends Container
Show file Open project: htmlburger/carbon-fields

Public Properties

Property Type Description
$settings array List of default container settings

Protected Properties

Property Type Description
$post_id integer ID of the post the container is working with

Public Methods

Method Description
__construct ( string $title ) Create a new post meta fields container
attach ( ) Add meta box for each of the container post types
check_setup_settings ( array &$settings = [] ) Check if all required container settings have been specified
detach ( ) Revert the result of attach()
hide_on_template ( string | array $template_path ) : object Hide the container from pages whose template has filename $template_path.
init ( ) Create DataStore instance, set post ID to operate with (if such exists).
is_valid_attach ( ) : boolean Perform checks whether the container should be attached during the current request
is_valid_save ( integer $post_id ) : boolean Perform checks whether the current save() request is valid Possible errors are triggering save() for autosave requests or performing post save outside of the post edit page (like Quick Edit)
is_valid_save_conditions ( integer $post_id ) : boolean Perform checks whether the current save() request is valid Possible errors are triggering save() for autosave requests or performing post save outside of the post edit page (like Quick Edit)
postbox_classes ( $classes ) Classes to add to the post meta box
render ( ) Output the container markup
save ( integer $post_id ) Perform save operation after successful is_valid_save() check.
set_context ( string $context ) Sets the meta box container context
set_post_id ( integer $post_id ) Set the post ID the container will operate with.
set_priority ( string $priority ) Sets the meta box container priority
show_on_category ( string $category_slug ) : object Show the container only on posts from the specified category.
show_on_level ( integer $level ) : object Show the container only on hierarchical posts of level $level.
show_on_page ( integer | string $page ) : object Show the container only on particular page referenced by it's path.
show_on_page_children ( string $parent_page_path ) : object Show the container only on pages whose parent is referenced by $parent_page_path.
show_on_post_format ( string | array $post_format ) : object Show the container only on posts from the specified format.
show_on_post_type ( string | array $post_types ) : object Show the container only on posts from the specified type(s).
show_on_taxonomy_term ( string $term_slug, string $taxonomy_slug ) : object Show the container only on posts which have term $term_slug from the $taxonomy_slug taxonomy.
show_on_template ( string | array $template_path ) : object Show the container only on pages whose template has filename $template_path.

Method Details

__construct() public method

Create a new post meta fields container
public __construct ( string $title )
$title string Unique title of the container

attach() public method

Add meta box for each of the container post types
public attach ( )

check_setup_settings() public method

Check if all required container settings have been specified
public check_setup_settings ( array &$settings = [] )
$settings array Container settings

detach() public method

Revert the result of attach()
public detach ( )

hide_on_template() public method

Hide the container from pages whose template has filename $template_path.
public hide_on_template ( string | array $template_path ) : object
$template_path string | array
return object $this

init() public method

Bind attach() and save() to the appropriate WordPress actions.
public init ( )

is_valid_attach() public method

Perform checks whether the container should be attached during the current request
public is_valid_attach ( ) : boolean
return boolean True if the container is allowed to be attached

is_valid_save() public method

Perform checks whether the current save() request is valid Possible errors are triggering save() for autosave requests or performing post save outside of the post edit page (like Quick Edit)
See also: is_valid_save_conditions()
public is_valid_save ( integer $post_id ) : boolean
$post_id integer ID of the post against which save() is ran
return boolean

is_valid_save_conditions() public method

Perform checks whether the current save() request is valid Possible errors are triggering save() for autosave requests or performing post save outside of the post edit page (like Quick Edit)
public is_valid_save_conditions ( integer $post_id ) : boolean
$post_id integer ID of the post against which save() is ran
return boolean

postbox_classes() public method

Classes to add to the post meta box
public postbox_classes ( $classes )

render() public method

Output the container markup
public render ( )

save() public method

The call is propagated to all fields in the container.
public save ( integer $post_id )
$post_id integer ID of the post against which save() is ran

set_context() public method

Sets the meta box container context
See also: https://codex.wordpress.org/Function_Reference/add_meta_box
public set_context ( string $context )
$context string ('normal', 'advanced' or 'side')

set_post_id() public method

Set the post ID the container will operate with.
public set_post_id ( integer $post_id )
$post_id integer

set_priority() public method

Sets the meta box container priority
See also: https://codex.wordpress.org/Function_Reference/add_meta_box
public set_priority ( string $priority )
$priority string ('high', 'core', 'default' or 'low')

show_on_category() public method

Show the container only on posts from the specified category.
See also: show_on_taxonomy_term()
public show_on_category ( string $category_slug ) : object
$category_slug string
return object $this

show_on_level() public method

Levels start from 1 (top level post)
public show_on_level ( integer $level ) : object
$level integer
return object $this

show_on_page() public method

Show the container only on particular page referenced by it's path.
public show_on_page ( integer | string $page ) : object
$page integer | string page ID or page path
return object $this

show_on_page_children() public method

Show the container only on pages whose parent is referenced by $parent_page_path.
public show_on_page_children ( string $parent_page_path ) : object
$parent_page_path string
return object $this

show_on_post_format() public method

Learn more about {@link http://codex.wordpress.org/Post_Formats Post Formats (Codex)}
public show_on_post_format ( string | array $post_format ) : object
$post_format string | array Name of the format as listed on Codex
return object $this

show_on_post_type() public method

Show the container only on posts from the specified type(s).
public show_on_post_type ( string | array $post_types ) : object
$post_types string | array
return object $this

show_on_taxonomy_term() public method

Show the container only on posts which have term $term_slug from the $taxonomy_slug taxonomy.
public show_on_taxonomy_term ( string $term_slug, string $taxonomy_slug ) : object
$term_slug string
$taxonomy_slug string
return object $this

show_on_template() public method

Show the container only on pages whose template has filename $template_path.
public show_on_template ( string | array $template_path ) : object
$template_path string | array
return object $this

Property Details

$post_id protected property

ID of the post the container is working with
See also: init()
protected int $post_id
return integer

$settings public property

List of default container settings
See also: init()
public array $settings
return array