WP_Interactivity_API::data_wp_text_processor()
Processes the data-wp-text directive.
It updates the inner content of the current HTML element based on the evaluation of its associated reference.
Метод класса: WP_Interactivity_API{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
// private - только в коде основоного (родительского) класса $result = $this->data_wp_text_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_text_processor() WP Interactivity API::data wp text processor WP 6.7.1
private function data_wp_text_processor( WP_Interactivity_API_Directives_Processor $p, string $mode ) { if ( 'enter' === $mode ) { $attribute_value = $p->get_attribute( 'data-wp-text' ); $result = $this->evaluate( $attribute_value ); /* * Follows the same logic as Preact in the client and only changes the * content if the value is a string or a number. Otherwise, it removes the * content. */ if ( is_string( $result ) || is_numeric( $result ) ) { $p->set_content_between_balanced_tags( esc_html( $result ) ); } else { $p->set_content_between_balanced_tags( '' ); } } }