PHP Class Carbon_Fields\Helper\Helper

Datei anzeigen Open project: htmlburger/carbon-fields Class Usage Examples

Public Methods

Method Description
__construct ( ) Create a new helper.
add_templates ( object $object ) Adds the field/container template(s) to the templates stack.
expand_nested_field ( array $input_groups, array $row, array $field_name ) : array Recursively expand the subfields of a complex field.
get_comment_meta ( integer $id, string $name, string $type = null ) : mixed Retrieve comment meta field for a comment.
get_complex_field_regex ( string $field_name, array $group_names = [], array $field_names = [] ) : string Build the regex for parsing a certain complex field.
get_complex_fields ( string $type, string $name, integer $id = null ) : array Retrieve the complex field data for a certain field.
get_field_value ( string $data_type, string $name, string $type = null, integer $id = null ) : mixed Retrieve a certain field value from the database.
get_field_value_by_store ( string $store_type, string $name, integer $id = null ) : mixed Retrieve a certain field value from the database.
get_json_data ( ) : array Retrieve containers and sidebars for use in the JS.
get_post_meta ( integer $id, string $name, string $type = null ) : mixed Retrieve post meta field for a post.
get_term_meta ( integer $id, string $name, string $type = null ) : mixed Retrieve term meta field for a term.
get_the_post_meta ( string $name, string $type = null ) : mixed Shorthand for get_post_meta().
get_theme_option ( string $name, string $type = null ) : mixed Retrieve theme option field value.
get_user_meta ( integer $id, string $name, string $type = null ) : mixed Retrieve user meta field for a user.
init_containers ( ) Initialize containers.
init_scripts ( ) Initialize main scripts
ksort_recursive ( &$array, integer $sort_flags = SORT_REGULAR ) : array Recursive sorting function by array key.
load_textdomain ( ) Load the plugin textdomain.
maybe_old_relationship_field ( mixed $value ) : mixed Detect if using the old way of storing the relationship field values.
parse_relationship_field ( string $raw_value = '', string $type = '' ) : array Parse the raw value of the relationship and association fields.
preg_quote_array ( array $pieces, string $glue = '|' ) : string Build a string of concatenated pieces for an OR regex.
print_json_data_script ( ) Print the carbon JSON data script.
trigger_fields_register ( ) Register containers and fields.

Method Details

__construct() public method

Hook the main Carbon Fields initialization functionality.
public __construct ( )

add_templates() public method

Adds the field/container template(s) to the templates stack.
public add_templates ( object $object )
$object object field or container object

expand_nested_field() public static method

Recursively expand the subfields of a complex field.
public static expand_nested_field ( array $input_groups, array $row, array $field_name ) : array
$input_groups array Input groups.
$row array Data row (key and value).
$field_name array Field name pieces.
return array Expanded data.

get_comment_meta() public static method

Retrieve comment meta field for a comment.
public static get_comment_meta ( integer $id, string $name, string $type = null ) : mixed
$id integer Comment ID.
$name string Custom field name.
$type string Custom field type (optional).
return mixed Meta value.

get_complex_field_regex() public static method

Build the regex for parsing a certain complex field.
public static get_complex_field_regex ( string $field_name, array $group_names = [], array $field_names = [] ) : string
$field_name string Name of the complex field.
$group_names array Array of group names.
$field_names array Array of subfield names.
return string Regex

get_complex_fields() public static method

Retrieve the complex field data for a certain field.
public static get_complex_fields ( string $type, string $name, integer $id = null ) : array
$type string Datastore type.
$name string Name of the field.
$id integer ID of the entry (optional).
return array Complex data entries.

get_field_value() public static method

Handles the logic for different field types.
public static get_field_value ( string $data_type, string $name, string $type = null, integer $id = null ) : mixed
$data_type string Data type.
$name string Custom field name.
$type string Custom field type (optional).
$id integer ID (optional).
return mixed Meta value.

get_field_value_by_store() public static method

Handles the logic for different data stores (containers).
public static get_field_value_by_store ( string $store_type, string $name, integer $id = null ) : mixed
$store_type string Data store type.
$name string Custom field name.
$id integer ID (optional).
return mixed Meta value.

get_json_data() public method

Retrieve containers and sidebars for use in the JS.
public get_json_data ( ) : array
return array $carbon_data

get_post_meta() public static method

Retrieve post meta field for a post.
public static get_post_meta ( integer $id, string $name, string $type = null ) : mixed
$id integer Post ID.
$name string Custom field name.
$type string Custom field type (optional).
return mixed Meta value.

get_term_meta() public static method

Retrieve term meta field for a term.
public static get_term_meta ( integer $id, string $name, string $type = null ) : mixed
$id integer Term ID.
$name string Custom field name.
$type string Custom field type (optional).
return mixed Meta value.

get_the_post_meta() public static method

Uses the ID of the current post in the loop.
public static get_the_post_meta ( string $name, string $type = null ) : mixed
$name string Custom field name.
$type string Custom field type (optional).
return mixed Meta value.

get_theme_option() public static method

Retrieve theme option field value.
public static get_theme_option ( string $name, string $type = null ) : mixed
$name string Custom field name.
$type string Custom field type (optional).
return mixed Option value.

get_user_meta() public static method

Retrieve user meta field for a user.
public static get_user_meta ( integer $id, string $name, string $type = null ) : mixed
$id integer User ID.
$name string Custom field name.
$type string Custom field type (optional).
return mixed Meta value.

init_containers() public method

Initialize containers.
public init_containers ( )

init_scripts() public method

Initialize main scripts
public init_scripts ( )

ksort_recursive() public static method

Recursive sorting function by array key.
public static ksort_recursive ( &$array, integer $sort_flags = SORT_REGULAR ) : array
$sort_flags integer Flags for controlling sorting behavior.
return array Sorted array.

load_textdomain() public method

Load the plugin textdomain.
public load_textdomain ( )

maybe_old_relationship_field() public static method

If so, parse them to the new way of storing the data.
public static maybe_old_relationship_field ( mixed $value ) : mixed
$value mixed Old field value.
return mixed New field value.

parse_relationship_field() public static method

Parse the raw value of the relationship and association fields.
public static parse_relationship_field ( string $raw_value = '', string $type = '' ) : array
$raw_value string Raw relationship value.
$type string Field type.
return array Array of parsed data.

preg_quote_array() public static method

Build a string of concatenated pieces for an OR regex.
public static preg_quote_array ( array $pieces, string $glue = '|' ) : string
$pieces array Pieces
$glue string Glue between the pieces
return string Result string

print_json_data_script() public method

Print the carbon JSON data script.

trigger_fields_register() public method

Register containers and fields.