function op_font_str($font = '') { if ($font = _op_font_item($font)) { if ($font[0] == 'google') { op_add_fonts($font[1]); return '"' . $font[1] . '", ' . $font[2]['fallback']; } else { return $font[2]; } } return false; }
/** * Button creator shortcode * @param array $atts * @return string */ static function button_1($atts) { /* * Cache busting */ if (function_exists('wp_using_ext_object_cache')) { wp_using_ext_object_cache(false); } // Decode encoded chars $atts = op_urldecode($atts); /* * Generating unique ID for this button */ $uid = 'btn_1_' . md5(serialize($atts)); if (false === ($data = get_transient('el_' . $uid))) { $atts = shortcode_atts(array('href' => '', 'new_window' => '', 'cc' => '', 'align' => 'center', 'element_type' => 'a', 'location' => null, 'text' => '', 'text_size' => 20, 'text_color' => null, 'text_font' => null, 'text_bold' => 'N', 'text_underline' => 'N', 'text_italic' => 'N', 'text_letter_spacing' => null, 'subtext_panel' => 'N', 'subtext' => '', 'subtext_size' => 15, 'subtext_color' => null, 'subtext_font' => null, 'subtext_bold' => 'N', 'subtext_underline' => 'N', 'subtext_italic' => 'N', 'subtext_letter_spacing' => null, 'text_shadow_panel' => 'N', 'text_shadow_vertical' => 0, 'text_shadow_horizontal' => 0, 'text_shadow_color' => null, 'text_shadow_blur' => 0, 'styling_width' => 63, 'styling_height' => 23, 'styling_border_color' => null, 'styling_border_size' => 0, 'styling_border_radius' => 0, 'styling_border_opacity' => 100, 'styling_gradient' => 'N', 'styling_shine' => 'N', 'styling_gradient_start_color' => null, 'styling_gradient_end_color' => null, 'drop_shadow_panel' => 'N', 'drop_shadow_vertical' => 0, 'drop_shadow_horizontal' => 0, 'drop_shadow_blur' => 0, 'drop_shadow_spread' => 0, 'drop_shadow_color' => null, 'drop_shadow_opacity' => 100, 'inset_shadow_panel' => 'N', 'inset_shadow_vertical' => 0, 'inset_shadow_horizontal' => 0, 'inset_shadow_blur' => 0, 'inset_shadow_spread' => 0, 'inset_shadow_color' => null, 'inset_shadow_opacity' => 100), $atts); /* * Only text/subtext box options are extracted here */ extract(shortcode_atts(array('text' => '', 'text_size' => 20, 'text_color' => null, 'text_font' => null, 'text_bold' => 'N', 'text_underline' => 'N', 'text_italic' => 'N', 'text_letter_spacing' => null, 'subtext_panel' => 'N', 'subtext' => '', 'subtext_size' => 15, 'subtext_color' => null, 'subtext_font' => null, 'subtext_bold' => 'N', 'subtext_underline' => 'N', 'subtext_italic' => 'N', 'subtext_letter_spacing' => null, 'cc' => '', 'align' => 'center'), $atts)); /* * Initializing CSS styles */ $styles = array('text' => array(), 'subtext' => array(), 'container' => array(), 'gradient' => array(), 'shine' => array(), 'hover' => array(), 'active' => array()); /* * Text box */ if (null !== $text_size) { $styles['text']['font-size'] = $text_size . 'px'; } if (null !== $text_color) { $styles['text']['color'] = $text_color; } if (null !== $text_font) { $text_font = explode(';', $text_font); if (isset($text_font[1]) && $text_font[1] !== 'google') { $styles['text']['font-family'] = op_default_fonts($text_font[0]); } else { $styles['text']['font-family'] = $text_font[0]; $data['fonts'][] = $text_font[0]; } } if ('Y' === $text_bold || 1 == $text_bold) { $styles['text']['font-weight'] = 'bold'; } else { $styles['text']['font-weight'] = 'normal'; } if ('Y' === $text_underline || 1 == $text_underline) { $styles['text']['text-decoration'] = 'underline'; } if ('Y' === $text_italic || 1 == $text_italic) { $styles['text']['font-style'] = 'italic'; } if (null !== $text_letter_spacing && 0 !== (int) $text_letter_spacing) { $styles['text']['letter-spacing'] = $text_letter_spacing . 'px'; } /* * Subtext box */ if ($subtext_panel === 'Y') { if (null !== $subtext_size) { $styles['subtext']['font-size'] = $subtext_size . 'px'; } if (null !== $subtext_color) { $styles['subtext']['color'] = $subtext_color; } if (null !== $subtext_font) { $subtext_font = explode(';', $subtext_font); if (isset($subtext_font[1]) && $subtext_font[1] !== 'google') { $styles['subtext']['font-family'] = op_default_fonts($subtext_font[0]); } else { $styles['subtext']['font-family'] = $subtext_font[0]; $data['fonts'][] = $subtext_font[0]; } } if ('Y' === $subtext_bold) { $styles['subtext']['font-weight'] = 'bold'; } else { $styles['subtext']['font-weight'] = 'normal'; } if ('Y' === $subtext_underline) { $styles['subtext']['text-decoration'] = 'underline'; } if ('Y' === $subtext_italic) { $styles['subtext']['font-style'] = 'italic'; } if (null !== $subtext_letter_spacing && 0 !== (int) $subtext_letter_spacing) { $styles['subtext']['letter-spacing'] = $subtext_letter_spacing . 'px'; } } $atts['styles'] = $styles; $atts['uid'] = $uid; $data['content'] = op_sl_parse('button_1', $atts); /* * We are saving transient only when there is some content returned */ if (is_string($data['content']) && 0 === strpos($data['content'], '##')) { $data['content'] = substr($data['content'], 2); } elseif (!empty($data['content'])) { $data['content'] = self::credit_card_icons($data['content'], $cc, $align); set_transient('el_' . $uid, $data, OP_SL_ELEMENT_CACHE_LIFETIME); } } /* * We need to load external fonts everytime */ if (isset($data['fonts'])) { foreach (array_unique($data['fonts']) as $font) { op_add_fonts($font); } } /* * Cache busting */ if (function_exists('wp_using_ext_object_cache')) { wp_using_ext_object_cache(true); } return $data['content']; }