Add personalization-tag-registry class

The new class which allows register Personalization Tags and then read them.
[MAILPOET-6328]
This commit is contained in:
Jan Lysý
2024-11-21 19:53:00 +01:00
committed by Pavel Dohnal
parent 8a32099af7
commit aab08fa5ab
4 changed files with 279 additions and 13 deletions

View File

@@ -33,6 +33,40 @@ if ( ! function_exists( 'esc_html' ) ) {
}
}
if ( ! function_exists( 'add_filter' ) ) {
/**
* Mock add_filter function.
*
* @param string $tag Tag to add filter for.
* @param callable $callback Callback to call.
*/
function add_filter( $tag, $callback ) {
global $wp_filters;
if ( ! isset( $wp_filters ) ) {
$wp_filters = array();
}
$wp_filters[ $tag ][] = $callback;
}
}
if ( ! function_exists( 'apply_filters' ) ) {
/**
* Mock apply_filters function.
*
* @param string $tag Tag to apply filters for.
* @param mixed $value Value to filter.
*/
function apply_filters( $tag, $value ) {
global $wp_filters;
if ( isset( $wp_filters[ $tag ] ) ) {
foreach ( $wp_filters[ $tag ] as $callback ) {
$value = call_user_func( $callback, $value );
}
}
return $value;
}
}
/**
* Base class for unit tests.
*/