Exemplo n.º 1
0
 public static function dropcap($atts = null, $content = null)
 {
     $atts = shortcode_atts(array('font_size' => 20, 'canvas_size' => 30, 'color' => '', 'background' => '', 'align' => 'left', 'shape' => 'circle', 'radius' => 5, 'border' => 'none', 'class' => ''), $atts, 'dropcap');
     $style = array();
     $font_size = 0 != absint($atts['font_size']) ? absint($atts['font_size']) : 20;
     $canvas_size = 0 != absint($atts['canvas_size']) ? absint($atts['canvas_size']) : 30;
     preg_match('/^(\\d+)px.+$/', $atts['border'], $matches);
     if (isset($matches[1])) {
         $border_width = absint($matches[1]);
     } else {
         $border_width = 0;
     }
     $metric = $canvas_size + 2 * $border_width;
     $radius = absint($atts['radius']);
     $style['font-size'] = $font_size . 'px';
     $style['width'] = $style['height'] = $metric . 'px';
     $style['line-height'] = $canvas_size . 'px';
     $style['color'] = !empty($atts['color']) ? esc_attr($atts['color']) : false;
     $style['background'] = !empty($atts['background']) ? esc_attr($atts['background']) : false;
     $style['border'] = esc_attr($atts['border']);
     $style['border-radius'] = $radius . 'px';
     $classes = array();
     $classes[] = 'cherry-dropcap';
     $classes[] = esc_attr($atts['class']);
     $classes[] = 'align-' . $atts['align'];
     $format = '<div class="%1$s" style="%2$s">%3$s</div>';
     $classes = implode(' ', $classes);
     $style = Cherry_Shortcodes_Tools::prepare_styles($style);
     $content = do_shortcode($content);
     $output = sprintf($format, $classes, $style, $content);
     return apply_filters('cherry_shortcodes_output', $output, $atts, 'dropcap');
 }
Exemplo n.º 2
0
 /**
  * Get icon HTML markup from icon attr value in shortcode.
  * Get icon HTML for Cherry shortcodes.
  *
  * @since  1.0.0
  *
  * @param  string $icon  Passed icon.
  * @param  string $class Custom class for icon.
  * @param  string $alt   Alt attribute value if icon is image.
  * @return string        Icon HTML markup.
  */
 public static function get_icon_html($icon, $class = 'cherry-icon', $alt = null, $style = array())
 {
     if (!$icon || 'none' == $icon) {
         return false;
     }
     if (false !== strpos($icon, 'icon:')) {
         $icon = trim(str_replace('icon:', '', $icon));
         $style = Cherry_Shortcodes_Tools::prepare_styles($style);
         $rand_class = Cherry_Shortcodes_Tools::rand_class('icon');
         $style = sprintf('%s{%s}', $rand_class, $style);
         $class .= ' ' . Cherry_Shortcodes_Tools::esc_class($rand_class);
         Cherry_Shortcodes_Tools::print_styles($style);
         return sprintf('<span class="%1$s %2$s"></span>', esc_attr($icon), esc_attr($class));
     } else {
         $icon = Cherry_Shortcodes_Tools::get_image_url($icon);
         return sprintf('<span class="%2$s"><img src="%1$s" alt="%3$s"></span>', esc_url($icon), esc_attr($class), esc_attr($alt));
     }
 }
Exemplo n.º 3
0
 /**
  * Get icon HTML markup from icon attr value in shortcode.
  * Get icon HTML for Cherry shortcodes.
  *
  * @since  1.0.0
  *
  * @param  string $icon  Passed icon.
  * @param  string $class Custom class for icon.
  * @param  string $alt   Alt attribute value if icon is image.
  * @return string        Icon HTML markup.
  */
 public static function get_icon_html($icon, $class = 'cherry-icon', $alt = null, $style = array())
 {
     if (!$icon) {
         return false;
     }
     if (false !== strpos($icon, 'icon:')) {
         $icon = trim(str_replace('icon:', '', $icon));
         $style = sprintf(' style="%s"', Cherry_Shortcodes_Tools::prepare_styles($style));
         return sprintf('<span class="%1$s %2$s"%3$s></span>', esc_attr($icon), esc_attr($class), $style);
     } else {
         return sprintf('<span class="%2$s"><img src="%1$s" alt="%3$s"></span>', esc_url($icon), esc_attr($class), esc_attr($alt));
     }
 }