Personalization_Tag
in package
The class represents a personalization tag that contains all necessary information for replacing the tag with its value and displaying it in the UI.
Table of Contents
- $attributes : array<string|int, mixed>
- The attributes which are used in the Personalization Tag UI.
- $callback : callable
- The callback function which returns the value of the personalization tag.
- $category : string
- The category of the personalization tag for categorization on the UI.
- $name : string
- The name of the tag displayed in the UI.
- $token : string
- The token which is used in HTML_Tag_Processor to replace the tag with its value.
- $value_to_insert : string
- The value that is inserted via the UI. When the value is null the token is generated based on $token attribute and $attributes.
- __construct() : mixed
- Personalization_Tag constructor.
- execute_callback() : string
- Executes the callback function for the personalization tag.
- get_attributes() : array<string|int, mixed>
- Returns the attributes of the personalization tag.
- get_category() : string
- Returns the category of the personalization tag.
- get_name() : string
- Returns the name of the personalization tag.
- get_token() : string
- Returns the token of the personalization tag.
- get_value_to_insert() : string
- Returns the token to insert via UI in the editor.
Properties
$attributes
The attributes which are used in the Personalization Tag UI.
private
array<string|int, mixed>
$attributes
$callback
The callback function which returns the value of the personalization tag.
private
callable
$callback
$category
The category of the personalization tag for categorization on the UI.
private
string
$category
$name
The name of the tag displayed in the UI.
private
string
$name
$token
The token which is used in HTML_Tag_Processor to replace the tag with its value.
private
string
$token
$value_to_insert
The value that is inserted via the UI. When the value is null the token is generated based on $token attribute and $attributes.
private
string
$value_to_insert
Methods
__construct()
Personalization_Tag constructor.
public
__construct(string $name, string $token, string $category, callable $callback[, array<string|int, mixed> $attributes = array() ][, string|null $value_to_insert = null ]) : mixed
Example usage: $tag = new Personalization_Tag( 'First Name', 'user:first_name', 'User', function( $context, $args ) { return $context['user_firstname'] ?? 'user'; }, array( default => 'user' ), 'user:first default="user"' );
Parameters
- $name : string
-
The name of the tag displayed in the UI.
- $token : string
-
The token used in HTML_Tag_Processor to replace the tag with its value.
- $category : string
-
The category of the personalization tag for categorization on the UI.
- $callback : callable
-
The callback function which returns the value of the personalization tag.
- $attributes : array<string|int, mixed> = array()
-
The attributes which are used in the Personalization Tag UI.
- $value_to_insert : string|null = null
-
The value that is inserted via the UI. When the value is null the token is generated based on $token attribute and $attributes.
Return values
mixed —execute_callback()
Executes the callback function for the personalization tag.
public
execute_callback(mixed $context[, array<string|int, mixed> $args = array() ]) : string
Parameters
- $context : mixed
-
The context for the personalization tag.
- $args : array<string|int, mixed> = array()
-
The additional arguments for the callback.
Return values
string — The value of the personalization tag.get_attributes()
Returns the attributes of the personalization tag.
public
get_attributes() : array<string|int, mixed>
Return values
array<string|int, mixed> —get_category()
Returns the category of the personalization tag.
public
get_category() : string
Return values
string —get_name()
Returns the name of the personalization tag.
public
get_name() : string
Return values
string —get_token()
Returns the token of the personalization tag.
public
get_token() : string
Return values
string —get_value_to_insert()
Returns the token to insert via UI in the editor.
public
get_value_to_insert() : string