Submit
Path:
~
/
home
/
getwphos
/
www
/
BenjaminMarc-Struktur
/
wp-content
/
plugins
/
struktur-core
/
shortcodes
/
underline-text
/
File Content:
underline-text.php
<?php namespace StrukturCore\CPT\Shortcodes\UnderlineText; use StrukturCore\Lib; class UnderlineText implements Lib\ShortcodeInterface { private $base; function __construct() { $this->base = 'qodef_underline_text'; add_action( 'vc_before_init', array( $this, 'vcMap' ) ); } public function getBase() { return $this->base; } public function vcMap() { if ( function_exists( 'vc_map' ) ) { vc_map( array( 'name' => esc_html__( 'Underline Text', 'struktur-core' ), 'base' => $this->base, 'category' => esc_html__( 'by STRUKTUR', 'struktur-core' ), 'icon' => 'icon-wpb-underline-text extended-custom-icon', 'allowed_container_element' => 'vc_row', 'params' => array( array( 'type' => 'textfield', 'param_name' => 'custom_class', 'heading' => esc_html__( 'Custom CSS Class', 'struktur-core' ), 'description' => esc_html__( 'Style particular content element differently - add a class name and refer to it in custom CSS', 'struktur-core' ) ), array( 'type' => 'textarea', 'param_name' => 'text', 'heading' => esc_html__( 'Text', 'struktur-core' ) ), array( 'type' => 'dropdown', 'param_name' => 'text_tag', 'heading' => esc_html__( 'Text Tag', 'struktur-core' ), 'value' => array_flip( struktur_select_get_title_tag( true, array( 'p' => 'p' ) ) ), 'save_always' => true, 'dependency' => array( 'element' => 'text', 'not_empty' => true ) ), array( 'type' => 'colorpicker', 'param_name' => 'text_color', 'heading' => esc_html__( 'Text Color', 'struktur-core' ), 'dependency' => array( 'element' => 'text', 'not_empty' => true ) ), array( 'type' => 'textfield', 'param_name' => 'underline_words', 'heading' => esc_html__( 'Underline Words', 'struktur-core' ), 'description' => esc_html__( 'Enter the positions of the words you would like to display as underline. Separate the positions with commas (e.g. if you would like the first, second, and third word to have a underline, you would enter "1,2,3")', 'struktur-core' ), 'dependency' => array( 'element' => 'text', 'not_empty' => true ) ) ) ) ); } } public function render( $atts, $content = null ) { $args = array( 'custom_class' => '', 'text' => '', 'text_tag' => 'h5', 'text_color' => '', 'underline_words' => '' ); $params = shortcode_atts( $args, $atts ); $params['holder_classes'] = $this->getHolderClasses( $params, $args ); $params['holder_styles'] = $this->getHolderStyles( $params ); $params['text'] = $this->getModifiedTitle( $params ); $params['text_tag'] = ! empty( $params['text_tag'] ) ? $params['text_tag'] : $args['text_tag']; $html = struktur_core_get_shortcode_module_template_part( 'templates/underline-text', 'underline-text', '', $params ); return $html; } private function getHolderClasses( $params, $args ) { $holderClasses = array(); $holderClasses[] = ! empty( $params['custom_class'] ) ? esc_attr( $params['custom_class'] ) : ''; return implode( ' ', $holderClasses ); } private function getHolderStyles( $params ) { $styles = array(); if ( ! empty( $params['text_color'] ) ) { $styles[] = 'color: ' . $params['text_color']; } return implode( ';', $styles ); } private function getModifiedTitle( $params ) { $text = $params['text']; if ( ! empty( $text ) ) { $underline_words = array_filter( explode( ',', str_replace( ' ', '', $params['underline_words'] ) ) ); array_walk( $underline_words, 'intval' ); if ( ! empty( $underline_words ) ) { $split_text = explode( ' ', $text ); $link_begin = '<span class="qodef-ut-underline">'; $link_end = '</span>'; $prev_value = - 1; foreach ( $underline_words as $value ) { $value = intval($value); if ( ! empty( $split_text[ $value - 1 ] ) ) { $value = intval( $value ); $link_begin_html = $prev_value + 1 !== $value ? $link_begin : ''; $link_end_html = ! in_array( $value + 1, $underline_words ) ? $link_end : ''; $prev_value = $value; $split_text[ $value - 1 ] = $link_begin_html . $split_text[ $value - 1 ] . $link_end_html; } } $text = implode( ' ', $split_text ); } } return $text; } }
Edit
Rename
Chmod
Delete
FILE
FOLDER
Name
Size
Permission
Action
assets
---
0755
templates
---
0755
elementor-underline-text.php
5411 bytes
0644
functions.php
1086 bytes
0644
load.php
167 bytes
0644
underline-text.php
4623 bytes
0644
N4ST4R_ID | Naxtarrr