/** *Automatically load assests like fonts into your frontend **/ public function load_shortcode_assets() { $output = ""; foreach (AviaBuilder::$resources_to_load as $element) { if ($element['type'] == 'iconfont') { $output .= avia_font_manager::load_font($element); } } echo $output; }
/** * * The iconfont method renders a single icon-select element based on a font * @param array $element the array holds data like type, value, id, class, description which are necessary to render the whole option-section * @return string $output the string returned contains the html code generated within the method */ static function iconfont($element) { $output = ""; if (!empty($element['chars']) && is_array($element['chars'])) { $chars = $element['chars']; } else { $chars = avia_font_manager::load_charlist(); } //get either the passed font or the default font $std_font = isset($element['shortcode_data']['font']) ? $element['shortcode_data']['font'] : key(AviaBuilder::$default_iconfont); $output .= "<div class='avia_icon_select_container avia-attach-element-container'>"; $run = 0; $active_font = ""; foreach ($chars as $font => $charset) { $run++; asort($charset); if ($run === 1) { //if the el value is empty set it to the first char if (empty($element['std'])) { $element['std'] = key($charset); } $standard = avia_font_manager::get_display_char($element['std'], $std_font); } $output .= "<div class='av-iconselect-heading'>Font: {$font}</div>"; foreach ($charset as $key => $char) { $char = avia_font_manager::try_decode_icon($char); $charcode_prefix = "Charcode: \\"; $active_char = ""; if ($char == $standard && !empty($std_font) && $std_font == $font) { $active_char = "avia-active-element"; $active_font = $font; } $output .= "<span title='{$charcode_prefix}{$key}' data-element-nr='{$key}' data-element-font='{$font}' class='avia-attach-element-select avia_icon_preview avia-font-{$font} {$active_char}'>{$char}</span>"; } } //default icon value $output .= self::hidden($element); //fake character value needed for backend editor $element['id'] = $element['id'] . "_fakeArg"; $element['std'] = empty($standard) ? "" : $standard; $output .= self::hidden($element); //font value needed for backend and editor $element['id'] = "font"; $element['std'] = $active_font; $element = self::ajax_modify_id($element); $output .= self::hidden($element); $output .= "</div>"; return $output; }
/** *Automatically load assests like fonts into your frontend **/ public function load_shortcode_assets() { $output = ""; $output .= avia_font_manager::load_font(); /* if the builder is decoupled from the theme then make sure to only load iconfonts if they are actually necessary. in enfolds case it is foreach(AviaBuilder::$resources_to_load as $element) { if($element['type'] == 'iconfont') { $output .= avia_font_manager::load_font(); } } */ echo $output; }
static function get_char_from_fallback($key) { $font = key(AviaBuilder::$default_iconfont); if (empty(self::$charlist_fallback)) { $config = AviaBuilder::$default_iconfont[$font]; $chars = array(); @(include $config['include'] . '/' . $config['compat']); self::$charlist_fallback = $chars; } $key = $key - 1; $key = self::$charlist_fallback[$font][$key]; return $key; }