Usage
WordPress
[icon type color size class]
Parameters
Type
(Required) (String) The icon class
Default: None
Color
(Optional) (String) The icon color
Default: inherit
Size
(Optional) (String) The icon size
Default: inherit
Class
(Optional) (String) Additional classes
Default: None
Source File
Located in /libs/Shortcodes.php on line 222.
WordPress
public function icon_shortcode($atts){
extract(shortcode_atts(array('type' => '', 'mode' => 'solid', 'color' => 'inherit', 'size' => 'inherit', 'class' => ''), $atts));
//Prepend the fa- prefix to the icon name if not provided
if ( !str_contains($type, 'fa-') ){
$type = 'fa-' . $type;
}
//Choose the appropriate FA weight
$mode = 'fa-solid';
if ( $mode === 'regular' || $mode === 'r' || $mode === 'far' ){
$mode = 'fa-regular';
} elseif ( $mode === 'light' || $mode === 'l' || $mode === 'fal' ){
$mode = 'fa-light';
} elseif ( $mode === 'brand' || $mode === 'b' || $mode === 'fab' ){
$mode = 'fa-brands';
}
$extra_style = ( !empty($color) )? 'color:' . $color . ';' :'';
$extra_style .= ( !empty($size) )? 'font-size:' . $size . ';' :'';
return '<i class="nebula-shortcode ' . esc_attr($class . ' nebula-icon-shortcode ' . $mode . ' ' . $type) . '" style="' . esc_attr($extra_style) . '"></i>';
}
Override
To override or disable this shortcode, use add_shortcode() to declare the shortcode first.