'',
'flame' => '',
'star' => '',
'gem' => '',
'check' => '',
'arrow-right' => '',
'layout-grid' => '',
'x' => '',
'chevron-left' => '',
'chevron-right' => '',
'share-2' => '',
'truck' => '',
);
const GLYPHS = array(
'🎁' => 'gift',
'🔥' => 'flame',
'★' => 'star',
'⭐' => 'star',
'💎' => 'gem',
'✓' => 'check',
'✔' => 'check',
'⟶' => 'arrow-right',
'→' => 'arrow-right',
'🚚' => 'truck',
);
public static function svg( $name, $size = '1em' ) {
if ( ! isset( self::PATHS[ $name ] ) ) {
return '';
}
return '';
}
public static function mask_url( $name ) {
if ( ! isset( self::PATHS[ $name ] ) ) {
return '';
}
$svg = '';
return 'url("data:image/svg+xml,' . rawurlencode( $svg ) . '")';
}
public static function name_of( $glyph ) {
$glyph = trim( str_replace( "\u{FE0F}", '', (string) $glyph ) );
return self::GLYPHS[ $glyph ] ?? '';
}
public static function text( $text ) {
return self::lead_html( esc_html( (string) $text ) );
}
public static function lead_html( $html ) {
$trimmed = ltrim( str_replace( "\u{FE0F}", '', (string) $html ) );
foreach ( self::GLYPHS as $glyph => $name ) {
if ( 0 === strpos( $trimmed, $glyph ) ) {
return '' . self::svg( $name ) . '' . ltrim( substr( $trimmed, strlen( $glyph ) ) ) . '';
}
}
return (string) $html;
}
public static function boot() {
static $done = false;
if ( $done || is_admin() ) {
return;
}
$done = true;
add_action( 'wp_head', array( __CLASS__, 'print_css' ), 20 );
}
public static function print_css() {
echo '' . "\n";
}
}
}