element;
$this->element = $this->apply_mentions_theme_defaults( $this->element );
$styles = $this->get_element_styles();
$style_attr = $this->create_style_string( $styles );
$content = $this->resolve_mentions_content();
$html = '
';
if ( $this->get_property( 'showSeparator', true ) !== false ) {
$separator_style = $this->get_property( 'separatorStyle', 'solid' );
$separator_color = $this->normalize_color( $this->get_property( 'separatorColor', '#e5e7eb' ) );
$separator_width = max( 1, (int) $this->get_property( 'separatorWidth', 1 ) );
$separator_margin = (int) $this->get_property( 'margin', 0 );
$html .= '
';
}
$html .= '
' . nl2br( htmlspecialchars( $content ) ) . '
';
$html .= '
';
$this->element = $original_element;
return $html;
}
/**
* Apply theme defaults to mentions elements when only the theme is stored.
*
* @param array $element Element data.
* @return array
*/
private function apply_mentions_theme_defaults( array $element ): array {
$theme = (string) ( $element['theme'] ?? '' );
if ( '' === $theme ) {
return $element;
}
$defaults = $this->get_mentions_theme_defaults( $theme );
if ( empty( $defaults ) ) {
return $element;
}
foreach ( $defaults as $key => $value ) {
if ( ! array_key_exists( $key, $element ) || '' === $element[ $key ] || null === $element[ $key ] ) {
$element[ $key ] = $value;
}
}
return $element;
}
/**
* Get theme defaults for mentions presets.
*
* @param string $theme Theme identifier.
* @return array