namespace WPForms\Admin\Education;
* @since 1.8.6 Added `$icon` parameter.
* @param string $text Badge text.
* @param string $size Badge size.
* @param string $position Badge position.
* @param string $color Badge color.
* @param string $shape Badge shape.
* @param string $icon Badge icon name in Font Awesome "format", e.g. `fa-check`, defaults to empty string.
public static function get_badge(
string $position = 'inline',
string $color = 'titanium',
string $shape = 'rounded',
if ( ! empty( $icon ) ) {
$icon = self::get_inline_icon( $icon );
'<span class="wpforms-badge wpforms-badge-%1$s wpforms-badge-%2$s wpforms-badge-%3$s wpforms-badge-%4$s">%5$s%6$s</span>',
* @since 1.8.6 Added `$icon` parameter.
* @param string $text Badge text.
* @param string $size Badge size.
* @param string $position Badge position.
* @param string $color Badge color.
* @param string $shape Badge shape.
* @param string $icon Badge icon name in Font Awesome "format", e.g. `fa-check`, defaults to empty string.
public static function print_badge(
string $position = 'inline',
string $color = 'titanium',
string $shape = 'rounded',
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo self::get_badge( $text, $size, $position, $color, $shape, $icon );
* @param array $addon Addon data.
public static function get_addon_badge( array $addon ): string {
// List of possible badges.
'text' => esc_html__( 'Recommended', 'wpforms-lite' ),
'text' => esc_html__( 'New', 'wpforms-lite' ),
'text' => esc_html__( 'Featured', 'wpforms-lite' ),
// Get first badge that exists.
foreach ( $badges as $key => $value ) {
if ( ! empty( $addon[ $key ] ) ) {
return self::get_badge( $badge['text'], 'sm', 'inline', $badge['color'], 'rounded', $badge['icon'] ?? '' );
* @param string $name Font Awesome icon name, e.g. `fa-check`.
* @return string HTML markup for the icon element.
public static function get_inline_icon( string $name ): string {
return sprintf( '<i class="fa %1$s" aria-hidden="true"></i>', esc_attr( $name ) );
* Get available education addons.
public static function get_edu_addons(): array {
if ( $addons !== null ) {
$addons_obj = wpforms()->obj( 'addons' );
$addons = $addons_obj->get_available();