WP_Interactivity_API::data_wp_context_processor
Processes the data-wp-context directive.
It adds the context defined in the directive value to the stack so that it's available for the nested interactivity elements.
Метод класса: WP_Interactivity_API{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
// private - только в коде основоного (родительского) класса $result = $this->data_wp_context_processor( $p, $mode );
- $p(WP_Interactivity_API_Directives_Processor) (обязательный)
- The directives processor instance.
- $mode(строка) (обязательный)
- Whether the processing is entering or exiting the tag.
Список изменений
| С версии 6.5.0 | Введена. |
Код WP_Interactivity_API::data_wp_context_processor() WP Interactivity API::data wp context processor WP 6.9
private function data_wp_context_processor( WP_Interactivity_API_Directives_Processor $p, string $mode ) {
// When exiting tags, it removes the last context from the stack.
if ( 'exit' === $mode ) {
array_pop( $this->context_stack );
return;
}
$entries = $this->get_directive_entries( $p, 'context' );
$context = end( $this->context_stack ) !== false ? end( $this->context_stack ) : array();
foreach ( $entries as $entry ) {
if ( null !== $entry['suffix'] ) {
continue;
}
$context = array_replace_recursive(
$context,
array( $entry['namespace'] => is_array( $entry['value'] ) ? $entry['value'] : array() )
);
}
$this->context_stack[] = $context;
}