Description
Enqueue the correct font for this iconWe may find genericons in jetpack\_inc\genericons\genericons.css Note: Default sizes for dashicons are 20px, genericons 16px So if we want to display a mixture then we'll need to do something to get the sizes consistent.
Usage
$string = bw_dash_enqueue_font( $icon, $atts );Parameters
- $icon
- ( string ) required – the name of the icon required
- $atts
- ( array ) required – shortcode parameters
Returns
string the name of the base class to use based on the chosen fontTO DO
Refactor to better allow for SVG iconsSource
File name: oik-bob-bing-wide/shortcodes/oik-dash.phpLines:
1 to 59 of 59
function bw_dash_enqueue_font( $icon, $atts ) { //bw_trace2(); //e( $icon ); $font = bw_array_get( $atts, "font", null ); if ( !$font ) { oik_require_lib( 'class-oik-svg-icons'); $svgicons = new OIK_SVG_icons(); $svgicon = $svgicons->get_icon( $icon, '' ); //$svgicons = bw_list_svgicons(); //$svgicon = bw_array_get( $svgicons, $icon, null ); if ( !$svgicon ) { $dashicons = bw_assoc( bw_list_dashicons()); $dashicon = bw_array_get( $dashicons, $icon, null ); if ( !$dashicon ) { oik_require( "shortcodes/oik-gener.php", "oik-bob-bing-wide" ); $genericons = bw_assoc( bw_list_genericons() ); $genericon = bw_array_get( $genericons, $icon, null ); if ( $genericon ) { $font = "genericons"; } else { // No need to load a font for this? OR do we default to dashicons anyway? // Or do we load up our special one which contains the definition of the extras // $texticons = bw_assoc( bw_list_texticons() ); $texticon = bw_array_get( $texticons, $icon, null ); if ( $texticon ) { $font = "texticons"; } } } else { $font = "dashicons"; } } else { $font = "svg"; } } switch ( $font ) { case "svg": $font = null; $font_class = "svg"; break; case "genericons" : wp_register_style( 'genericons', oik_url( 'css/genericons/genericons.css' ), false ); $font_class = "genericon"; break; default: $font_class = $font; } if ( $font ) { $enqueued = wp_style_is( $font, "enqueued" ); if ( !$enqueued ) { wp_enqueue_style( $font ); } } return( $font_class ); }View on GitHub
Invoked by
Calls
1 to 5 of 5
- bw_assoc() – Convert a simple array into an associative array keyed on the value
- bw_list_dashicons() – Produce a list of the possible dashicons in the dashicons.css file
- bw_list_genericons() – Produce a list of the possible genericons in the genericons.css file
- bw_list_texticons() – Return a list of texticons which are normal characters but displayed using dashicons logic
- oik_url() – Return the URL for a resource file
Call hooks
API Letters:
