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.
Note: This function contains 1 to-do comment.
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 ( strpos($type, 'fa-') === false ){ //@todo "Nebula" 0: Update strpos() to str_contains() in PHP8 $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="' . esc_attr($class . ' nebula-icon-shortcode ' . $mode . ' fa-fw ' . $type) . '" style="' . esc_attr($extra_style) . '"></i>'; }
Override
To override or disable this shortcode, use add_shortcode()
to declare the shortcode first.