Submit
Path:
~
/
home
/
getwphos
/
www
/
almajd14
/
wp-content
/
plugins
/
halstein-core
/
inc
/
shortcodes
/
button
/
File Content:
class-halsteincore-button-shortcode.php
<?php if ( ! function_exists( 'halstein_core_add_button_shortcode' ) ) { /** * Function that isadding shortcode into shortcodes list for registration * * @param array $shortcodes - Array of registered shortcodes * * @return array */ function halstein_core_add_button_shortcode( $shortcodes ) { $shortcodes[] = 'HalsteinCore_Button_Shortcode'; return $shortcodes; } add_filter( 'halstein_core_filter_register_shortcodes', 'halstein_core_add_button_shortcode', 9 ); } if ( class_exists( 'HalsteinCore_Shortcode' ) ) { class HalsteinCore_Button_Shortcode extends HalsteinCore_Shortcode { public function __construct() { $this->set_layouts( apply_filters( 'halstein_core_filter_button_layouts', array() ) ); parent::__construct(); } public function map_shortcode() { $this->set_shortcode_path( HALSTEIN_CORE_SHORTCODES_URL_PATH . '/button' ); $this->set_base( 'halstein_core_button' ); $this->set_name( esc_html__( 'Button', 'halstein-core' ) ); $this->set_description( esc_html__( 'Shortcode that displays button with provided parameters', 'halstein-core' ) ); $this->set_option( array( 'field_type' => 'text', 'name' => 'custom_class', 'title' => esc_html__( 'Custom Class', 'halstein-core' ), ) ); $options_map = halstein_core_get_variations_options_map( $this->get_layouts() ); $this->set_option( array( 'field_type' => 'select', 'name' => 'button_layout', 'title' => esc_html__( 'Layout', 'halstein-core' ), 'options' => $this->get_layouts(), 'default_value' => $options_map['default_value'], 'visibility' => array( 'map_for_page_builder' => $options_map['visibility'], 'map_for_widget' => $options_map['visibility'], ), ) ); $this->set_option( array( 'field_type' => 'select', 'name' => 'size', 'title' => esc_html__( 'Size', 'halstein-core' ), 'options' => array( '' => esc_html__( 'Normal', 'halstein-core' ), 'small' => esc_html__( 'Small', 'halstein-core' ), 'large' => esc_html__( 'Large', 'halstein-core' ), 'full' => esc_html__( 'Normal Full Width', 'halstein-core' ), ), 'dependency' => array( 'hide' => array( 'button_layout' => array( 'values' => 'textual', 'default_value' => 'filled-one', ), ), ), ) ); $this->set_option( array( 'field_type' => 'text', 'name' => 'text', 'title' => esc_html__( 'Button Text', 'halstein-core' ), 'default_value' => esc_html__( 'Button Text', 'halstein-core' ), ) ); $this->set_option( array( 'field_type' => 'text', 'name' => 'button_line_break_positions', 'title' => esc_html__( 'Positions of Line Break', 'halstein-core' ), 'description' => esc_html__( 'Enter the positions of the words after which you would like to create a line break. Separate the positions with commas (e.g. if you would like the first, third, and fourth word to have a line break, you would enter "1,3,4")', 'halstein-core' ), 'group' => esc_html__( 'Typography Style', 'halstein-core' ), 'dependency' => array( 'show' => array( 'button_layout' => array( 'values' => 'textual-full-width', 'default_value' => 'filled-one', ), ), ), ) ); $this->set_option( array( 'field_type' => 'select', 'name' => 'button_disable_text_break_words', 'title' => esc_html__( 'Disable Line Break', 'halstein-core' ), 'description' => esc_html__( 'Enabling this option will disable line breaks for screen size 1024 and lower', 'halstein-core' ), 'options' => halstein_core_get_select_type_options_pool( 'no_yes', false ), 'default_value' => 'no', 'group' => esc_html__( 'Typography Style', 'halstein-core' ), 'dependency' => array( 'show' => array( 'button_layout' => array( 'values' => 'textual-full-width', 'default_value' => 'filled-one', ), ), ), ) ); $this->set_option( array( 'field_type' => 'text', 'name' => 'link', 'title' => esc_html__( 'Button Link', 'halstein-core' ), ) ); $this->set_option( array( 'field_type' => 'select', 'name' => 'target', 'title' => esc_html__( 'Target', 'halstein-core' ), 'options' => halstein_core_get_select_type_options_pool( 'link_target' ), 'default_value' => '_self', ) ); $this->set_option( array( 'field_type' => 'color', 'name' => 'color', 'title' => esc_html__( 'Text Color', 'halstein-core' ), 'group' => esc_html__( 'Style', 'halstein-core' ), ) ); $this->set_option( array( 'name' => 'hover_color', 'field_type' => 'color', 'title' => esc_html__( 'Text Hover Color', 'halstein-core' ), 'group' => esc_html__( 'Style', 'halstein-core' ), ) ); $this->set_option( array( 'field_type' => 'color', 'name' => 'background_color', 'title' => esc_html__( 'Background Color', 'halstein-core' ), 'group' => esc_html__( 'Style', 'halstein-core' ), ) ); $this->set_option( array( 'field_type' => 'color', 'name' => 'hover_background_color', 'title' => esc_html__( 'Background Hover Color', 'halstein-core' ), 'group' => esc_html__( 'Style', 'halstein-core' ), ) ); $this->set_option( array( 'field_type' => 'color', 'name' => 'border_color', 'title' => esc_html__( 'Border Color', 'halstein-core' ), 'group' => esc_html__( 'Style', 'halstein-core' ), ) ); $this->set_option( array( 'field_type' => 'color', 'name' => 'hover_border_color', 'title' => esc_html__( 'Border Hover Color', 'halstein-core' ), 'group' => esc_html__( 'Style', 'halstein-core' ), ) ); $this->set_option( array( 'field_type' => 'text', 'name' => 'margin', 'title' => esc_html__( 'Margin', 'halstein-core' ), 'group' => esc_html__( 'Style', 'halstein-core' ), ) ); $this->set_option( array( 'field_type' => 'text', 'name' => 'padding', 'title' => esc_html__( 'Padding', 'halstein-core' ), 'group' => esc_html__( 'Style', 'halstein-core' ), ) ); $this->set_option( array( 'field_type' => 'text', 'name' => 'font_size', 'title' => esc_html__( 'Font Size', 'halstein-core' ), 'group' => esc_html__( 'Typography Style', 'halstein-core' ), ) ); $this->set_option( array( 'field_type' => 'select', 'name' => 'font_weight', 'title' => esc_html__( 'Font Weight', 'halstein-core' ), 'options' => halstein_core_get_select_type_options_pool( 'font_weight' ), 'group' => esc_html__( 'Typography Style', 'halstein-core' ), ) ); $this->set_option( array( 'field_type' => 'select', 'name' => 'text_transform', 'title' => esc_html__( 'Text Transform', 'halstein-core' ), 'options' => halstein_core_get_select_type_options_pool( 'text_transform' ), 'group' => esc_html__( 'Typography Style', 'halstein-core' ), ) ); $this->set_option( array( 'field_type' => 'select', 'name' => 'html_type', 'title' => esc_html__( 'HTML Type', 'halstein-core' ), 'options' => array( 'default' => esc_html__( 'Default', 'halstein-core' ), 'input' => esc_html__( 'Input', 'halstein-core' ), 'submit' => esc_html__( 'Submit', 'halstein-core' ), ), 'default_value' => 'default', 'visibility' => array( 'map_for_page_builder' => false, ), ) ); $this->set_option( array( 'field_type' => 'text', 'name' => 'input_name', 'title' => esc_html__( 'Input Name', 'halstein-core' ), 'visibility' => array( 'map_for_page_builder' => false, ), ) ); $this->set_option( array( 'field_type' => 'array', 'name' => 'custom_attrs', 'title' => esc_html__( 'Custom Data Attributes', 'halstein-core' ), 'visibility' => array( 'map_for_page_builder' => false, ), ) ); } public static function call_shortcode( $params ) { $html = qode_framework_call_shortcode( 'halstein_core_button', $params ); $html = str_replace( "\n", '', $html ); return $html; } public function render( $options, $content = null ) { parent::render( $options ); $atts = $this->get_atts(); $atts['text'] = $this->get_modified_text( $atts ); $atts['holder_classes'] = $this->get_holder_classes( $atts ); $atts['data_attrs'] = $this->get_data_attrs( $atts ); $atts['styles'] = $this->get_styles( $atts ); return halstein_core_get_template_part( 'shortcodes/button', 'variations/' . $atts['button_layout'] . '/templates/' . $atts['html_type'], '', $atts ); } private function get_holder_classes( $atts ) { $holder_classes = $this->init_holder_classes(); $holder_classes[] = 'qodef-button'; $holder_classes[] = ! empty( $atts['button_layout'] ) ? 'qodef-layout--' . $atts['button_layout'] : ''; $holder_classes[] = ! empty( $atts['size'] ) ? 'qodef-size--' . $atts['size'] : ''; $holder_classes[] = 'default' === $atts['html_type'] ? 'qodef-html--link' : ''; $holder_classes[] = 'yes' === $atts['button_disable_text_break_words'] ? 'qodef-text-break--disabled' : ''; return implode( ' ', $holder_classes ); } private function get_modified_text( $atts ) { $text = $atts['text']; if ( ! empty( $text ) && ! empty( $atts['button_line_break_positions'] ) ) { $split_text = explode( ' ', $text ); $line_break_positions = explode( ',', str_replace( ' ', '', $atts['button_line_break_positions'] ) ); foreach ( $line_break_positions as $position ) { $position = intval( $position ); if ( isset( $split_text[ $position - 1 ] ) && ! empty( $split_text[ $position - 1 ] ) ) { $split_text[ $position - 1 ] = $split_text[ $position - 1 ] . '<br />'; } } $text = implode( ' ', $split_text ); } return $text; } private function get_data_attrs( $atts ) { $data = array(); if ( ! empty( $atts['hover_color'] ) ) { $data['data-hover-color'] = $atts['hover_color']; } if ( ! empty( $atts['hover_background_color'] ) ) { $data['data-hover-background-color'] = $atts['hover_background_color']; } if ( ! empty( $atts['hover_border_color'] ) ) { $data['data-hover-border-color'] = $atts['hover_border_color']; } if ( ! empty( $atts['custom_attrs'] ) && is_array( $atts['custom_attrs'] ) ) { $data = array_merge( $data, $atts['custom_attrs'] ); } return $data; } private function get_styles( $atts ) { $styles = array(); if ( ! empty( $atts['color'] ) ) { $styles[] = 'color: ' . $atts['color']; } if ( ! empty( $atts['background_color'] ) && 'outlined' !== $atts['button_layout'] && 'textual' !== $atts['button_layout'] ) { $styles[] = 'background-color: ' . $atts['background_color']; } if ( ! empty( $atts['border_color'] ) && 'textual' !== $atts['button_layout'] ) { $styles[] = 'border-color: ' . $atts['border_color']; } if ( ! empty( $atts['font_family'] ) ) { $styles[] = 'font-family: ' . $atts['font_family']; } if ( ! empty( $atts['font_size'] ) ) { if ( qode_framework_string_ends_with_typography_units( $atts['font_size'] ) ) { $styles[] = 'font-size: ' . $atts['font_size']; } else { $styles[] = 'font-size: ' . intval( $atts['font_size'] ) . 'px'; } } if ( ! empty( $atts['font_weight'] ) ) { $styles[] = 'font-weight: ' . $atts['font_weight']; } if ( ! empty( $atts['text_transform'] ) ) { $styles[] = 'text-transform: ' . $atts['text_transform']; } if ( '' !== $atts['margin'] ) { $styles[] = 'margin: ' . $atts['margin']; } if ( '' !== $atts['padding'] ) { $styles[] = 'padding: ' . $atts['padding']; } return $styles; } } }
Submit
FILE
FOLDER
Name
Size
Permission
Action
assets
---
0755
variations
---
0755
widget
---
0755
class-halsteincore-button-shortcode-elementor.php
371 bytes
0644
class-halsteincore-button-shortcode.php
12436 bytes
0644
include.php
235 bytes
0644
N4ST4R_ID | Naxtarrr