attribute['sg_text_html_tag'] );
$url = $this->attribute['sg_text_link'];
$text = '<' . $tag . ' class="animated-text">' . $this->render_text() . '' . $tag . '>';
$text = ! empty( $url['url'] ) ? $this->render_url_element( $url, null, null, $text ) : $text;
$option = $this->render_option();
return $this->render_wrapper( 'animated-text', $text, array(), $option );
}
/**
* Render Text
*/
private function render_text() {
$normal_color_style = esc_attr( $this->attribute['sg_text_normal_color_style'] );
$dynamic_color_style = esc_attr( $this->attribute['sg_text_animated_color_style'] );
$style = $this->attribute['sg_text_style'];
$text = '' . esc_attr( $this->attribute['sg_text_before'] ) . '';
if ( 'rotating' === $style ) {
$text = $text . '' . $this->render_rotating_list() . '';
} elseif ( 'highlighted' === $style ) {
$text = $text . '' . esc_attr( $this->attribute['sg_text_animated'] ) . '' . $this->get_stroke( $this->attribute['sg_text_shape'] ) . '';
} else {
$text = $text . '' . esc_attr( $this->attribute['sg_text_animated'] ) . '';
}
$text = $text . '' . esc_attr( $this->attribute['sg_text_after'] ) . '';
return $text;
}
/**
* Render option
*/
private function render_option() {
$option = array();
$style = $this->attribute['sg_text_style'];
if ( 'rotating' === $style ) {
$text = array();
$lists = $this->attribute['sg_text_rotating_list'];
$rotate = $this->attribute['sg_text_rotating'];
$delay = $this->attribute['sg_text_delay_change'];
foreach ( $lists as $list ) {
array_push( $text, $list['sg_text_rotating_list_text'] );
}
$text = implode( ',', $text );
$option = array(
'style' => esc_attr( $style ),
'text' => esc_attr( $text ),
'rotate' => esc_attr( $rotate ),
'delay' => esc_attr( $delay ),
);
if ( in_array( $rotate, array( 'typing', 'swirl', 'blinds', 'wave' ), true ) ) {
$option['letter-speed'] = esc_attr( $this->attribute['sg_text_letter_speed'] );
}
if ( 'clip' === $rotate ) {
$option['clip-duration'] = esc_attr( $this->attribute['sg_text_clip_duration'] );
}
if ( 'typing' === $rotate ) {
$option['delay-delete'] = esc_attr( $this->attribute['sg_text_delay_delete'] );
}
} elseif ( 'highlighted' === $style ) {
$option = array(
'style' => esc_attr( $style ),
'text' => esc_attr( $this->attribute['sg_text_animated'] ),
'shape' => esc_attr( $this->attribute['sg_text_shape'] ),
);
} else {
$option = array( 'style' => esc_attr( $style ) );
}
return $option;
}
/**
* Render Rotating List
*/
private function render_rotating_list() {
$text_list = '';
$lists = $this->attribute['sg_text_rotating_list'];
$rotate_style = $this->attribute['sg_text_rotating'];
if ( in_array( $rotate_style, array( 'typing', 'swirl', 'blinds', 'wave' ), true ) ) {
foreach ( $lists as $list ) {
$text_string = $list['sg_text_rotating_list_text'];
$text_length = mb_strlen( $text_string, 'UTF-8' );
$text_list = $text_list . '';
for ( $i = 0; $i < $text_length; $i++ ) {
$text_list = $text_list . '' . mb_substr( $text_string, $i, 1, 'UTF-8' ) . '';
}
$text_list = $text_list . '';
}
} else {
foreach ( $lists as $list ) {
$text_list = $text_list . '' . $list['sg_text_rotating_list_text'] . '';
}
}
return $text_list;
}
/**
* Get stroke SVG
*
* @param string $stroke Stroke option.
*/
private function get_stroke( $stroke ) {
$gradient_svg = '';
$gradient_stroke = '';
$color_style = esc_attr( $this->attribute['st_highlight_color_style'] );
if ( 'gradient' === $color_style ) {
$gradient_svg = '';
$gradient_stroke = 'stroke="url(#jkit-highlight-gradient)"';
}
$strokes = array(
'circle' => '',
'curly' => '',
'underline' => '',
'double' => '',
'double-underline' => '',
'underline-zigzag' => '',
'diagonal' => '',
'strikethrough' => '',
'x' => '',
);
return $strokes[ $stroke ];
}
}