resolver()->resolve( $key, $context ); return $resolved ? $resolved['value'] : $fallback; } /** * Get a variable's safely rendered HTML value. * * @param string $key Variable key. * @param array $context Resolution context. * @param mixed $fallback Safely escaped fallback returned when the key is unknown. * @return string */ function glovario_get_rendered_value( $key, $context = array(), $fallback = '' ) { $resolved = Glovario\Plugin::instance()->resolver()->resolve( $key, $context ); if ( $resolved ) { return Glovario\Plugin::instance()->renderer()->render( $resolved['value'], $resolved['variable']['type'], $resolved['context'] ); } return esc_html( is_scalar( $fallback ) || null === $fallback ? (string) $fallback : '' ); } /** * Echo a variable's safely rendered HTML value. * * @param string $key Variable key. * @param array $context Resolution context. * @param mixed $fallback Safely escaped fallback output when the key is unknown. */ function glovario_the_value( $key, $context = array(), $fallback = '' ) { // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Renderer applies type-aware escaping. echo glovario_get_rendered_value( $key, $context, $fallback ); }