예제 #1
0
파일: basic.php 프로젝트: aragonc/3clicks
 /**
  * Shortcode callback function.
  *
  * @return string
  */
 protected function do_shortcode()
 {
     extract($this->extract());
     $content = preg_replace('#^<\\/p>|<p>$#', '', $content);
     // Compose final HTML id attribute
     $final_id = strlen($id) ? $id : 'g1-dropcap-' . $this->get_counter();
     // Compose final HTML class attribute
     $final_class = array('g1-dropcap', 'g1-dropcap--' . $style);
     $final_class = array_merge($final_class, explode(' ', $class));
     // Compose CSS
     $css = '';
     if (strlen($text_color)) {
         $color = new G1_Color($text_color);
         $css .= '#' . esc_attr($final_id) . '.g1-dropcap--simple,' . "\n" . '#' . esc_attr($final_id) . '.g1-dropcap--solid {' . "\n" . 'color: #' . $color->get_hex() . ';' . "\n" . '}' . "\n";
     }
     if (strlen($bg_color)) {
         $color = new G1_Color($bg_color);
         $hex = $color->get_hex();
         list($from, $to) = G1_Color_Generator::get_warm_gradient($color);
         $from_hex = $from->get_hex();
         $to_hex = $to->get_hex();
         $css .= '#' . esc_attr($final_id) . '.g1-dropcap--solid  {' . "\n" . 'background-color: #' . $hex . ';' . "\n" . '}' . "\n";
     }
     //$css = str_replace(array("\n", "\r"), '', $css);
     // Compose output
     $out = '';
     $out .= strlen($css) ? "\n" . '<style type="text/css">' . $css . '</style>' . "\n" : '';
     $out .= '<span id="' . esc_attr($final_id) . '" ';
     $out .= 'class="' . sanitize_html_classes($final_class) . '" ';
     $out .= '><span>';
     $out .= $content;
     $out .= '</span></span>';
     return $out;
 }