Submit
Path:
~
/
home
/
getwphos
/
www
/
almajd14
/
wp-content
/
plugins
/
halstein-core
/
inc
/
shortcodes
/
banner
/
File Content:
class-halsteincore-banner-shortcode.php
<?php if ( ! function_exists( 'halstein_core_add_banner_shortcode' ) ) { /** * Function that add shortcode into shortcodes list for registration * * @param array $shortcodes * * @return array */ function halstein_core_add_banner_shortcode( $shortcodes ) { $shortcodes[] = 'HalsteinCore_Banner_Shortcode'; return $shortcodes; } add_filter( 'halstein_core_filter_register_shortcodes', 'halstein_core_add_banner_shortcode' ); } if ( class_exists( 'HalsteinCore_Shortcode' ) ) { class HalsteinCore_Banner_Shortcode extends HalsteinCore_Shortcode { public function __construct() { $this->set_layouts( apply_filters( 'halstein_core_filter_banner_layouts', array() ) ); $this->set_extra_options( apply_filters( 'halstein_core_filter_banner_extra_options', array() ) ); parent::__construct(); } public function map_shortcode() { $this->set_shortcode_path( HALSTEIN_CORE_SHORTCODES_URL_PATH . '/banner' ); $this->set_base( 'halstein_core_banner' ); $this->set_name( esc_html__( 'Banner', 'halstein-core' ) ); $this->set_description( esc_html__( 'Shortcode that adds banner element', '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' => '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'] ), ) ); $this->set_option( array( 'field_type' => 'image', 'name' => 'image', 'title' => esc_html__( 'Image', 'halstein-core' ), ) ); $this->set_option( array( 'field_type' => 'text', 'name' => 'link_url', 'title' => esc_html__( 'Link', 'halstein-core' ), ) ); $this->set_option( array( 'field_type' => 'select', 'name' => 'link_target', 'title' => esc_html__( 'Link Target', 'halstein-core' ), 'options' => halstein_core_get_select_type_options_pool( 'link_target' ), 'default_value' => '_self', ) ); $this->set_option( array( 'field_type' => 'text', 'name' => 'content_margin', 'title' => esc_html__( 'Content Margin', 'halstein-core' ), 'group' => esc_html__( 'Content Style', 'halstein-core' ), ) ); $this->set_option( array( 'field_type' => 'text', 'name' => 'content_padding', 'title' => esc_html__( 'Content Padding', 'halstein-core' ), 'group' => esc_html__( 'Content Style', 'halstein-core' ), ) ); $this->set_option( array( 'field_type' => 'select', 'name' => 'content_predefined_spacing', 'title' => esc_html__( 'Enable Predefined Content Spacing', 'halstein-core' ), 'description' => esc_html__( 'Enabling this option will set the padding and margin settings to the theme predefined values', 'halstein-core' ), 'options' => halstein_core_get_select_type_options_pool( 'no_yes', false ), 'default_value' => 'no', 'group' => esc_html__( 'Content Style', 'halstein-core' ), ) ); $this->set_option( array( 'field_type' => 'color', 'name' => 'content_background_color', 'title' => esc_html__( 'Content Background Color', 'halstein-core' ), 'group' => esc_html__( 'Content Style', 'halstein-core' ), ) ); $this->set_option( array( 'field_type' => 'select', 'name' => 'content_image_responsive_position', 'title' => esc_html__( 'Image Position On Mobile Devices', 'halstein-core' ), 'options' => array( 'center' => esc_html__( 'Center', 'halstein-core' ), 'left' => esc_html__( 'Left', 'halstein-core' ), 'right' => esc_html__( 'Right', 'halstein-core' ), ), 'group' => esc_html__( 'Content Style', 'halstein-core' ), ) ); $this->set_option( array( 'field_type' => 'text', 'name' => 'title', 'title' => esc_html__( 'Title', 'halstein-core' ), 'default_value' => esc_html__( 'Title Text', 'halstein-core' ), ) ); $this->set_option( array( 'field_type' => 'text', 'name' => 'title_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__( 'Title Style', 'halstein-core' ), ) ); $this->set_option( array( 'field_type' => 'select', 'name' => 'disable_title_break_words', 'title' => esc_html__( 'Disable Title Line Break', 'halstein-core' ), 'description' => esc_html__( 'Enabling this option will disable title 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__( 'Title Style', 'halstein-core' ), ) ); $this->set_option( array( 'field_type' => 'select', 'name' => 'title_tag', 'title' => esc_html__( 'Title Tag', 'halstein-core' ), 'options' => halstein_core_get_select_type_options_pool( 'title_tag' ), 'default_value' => 'h3', 'group' => esc_html__( 'Title Style', 'halstein-core' ), ) ); $this->set_option( array( 'field_type' => 'color', 'name' => 'title_color', 'title' => esc_html__( 'Title Color', 'halstein-core' ), 'group' => esc_html__( 'Title Style', 'halstein-core' ), ) ); $this->set_option( array( 'field_type' => 'text', 'name' => 'title_margin_top', 'title' => esc_html__( 'Title Margin Top', 'halstein-core' ), 'group' => esc_html__( 'Title Style', 'halstein-core' ), ) ); $this->set_option( array( 'field_type' => 'text', 'name' => 'title_margin_bottom', 'title' => esc_html__( 'Title Margin Bottom', 'halstein-core' ), 'group' => esc_html__( 'Title Style', 'halstein-core' ), ) ); $this->set_option( array( 'field_type' => 'text', 'name' => 'subtitle', 'title' => esc_html__( 'Subtitle', 'halstein-core' ), ) ); $this->set_option( array( 'field_type' => 'select', 'name' => 'subtitle_tag', 'title' => esc_html__( 'Subtitle Tag', 'halstein-core' ), 'options' => halstein_core_get_select_type_options_pool( 'title_tag' ), 'default_value' => 'h6', 'group' => esc_html__( 'Subtitle Style', 'halstein-core' ), ) ); $this->set_option( array( 'field_type' => 'color', 'name' => 'subtitle_color', 'title' => esc_html__( 'Subtitle Color', 'halstein-core' ), 'group' => esc_html__( 'Subtitle Style', 'halstein-core' ), ) ); $this->set_option( array( 'field_type' => 'text', 'name' => 'subtitle_margin_top', 'title' => esc_html__( 'Subtitle Margin Top', 'halstein-core' ), 'group' => esc_html__( 'Subtitle Style', 'halstein-core' ), ) ); $this->set_option( array( 'field_type' => 'text', 'name' => 'subtitle_margin_bottom', 'title' => esc_html__( 'Subtitle Margin Bottom', 'halstein-core' ), 'group' => esc_html__( 'Subtitle Style', 'halstein-core' ), ) ); $this->set_option( array( 'field_type' => 'textarea', 'name' => 'text_field', 'title' => esc_html__( 'Text', 'halstein-core' ), ) ); $this->set_option( array( 'field_type' => 'text', 'name' => 'text_field_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__( 'Text Style', 'halstein-core' ), ) ); $this->set_option( array( 'field_type' => 'select', 'name' => 'disable_text_field_break_words', 'title' => esc_html__( 'Disable Text Line Break', 'halstein-core' ), 'description' => esc_html__( 'Enabling this option will disable text 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__( 'Text Style', 'halstein-core' ), ) ); $this->set_option( array( 'field_type' => 'select', 'name' => 'text_tag', 'title' => esc_html__( 'Text Tag', 'halstein-core' ), 'options' => halstein_core_get_select_type_options_pool( 'title_tag' ), 'default_value' => 'p', 'group' => esc_html__( 'Text Style', 'halstein-core' ), ) ); $this->set_option( array( 'field_type' => 'color', 'name' => 'text_color', 'title' => esc_html__( 'Text Color', 'halstein-core' ), 'group' => esc_html__( 'Text Style', 'halstein-core' ), ) ); $this->set_option( array( 'field_type' => 'text', 'name' => 'text_margin_top', 'title' => esc_html__( 'Text Margin Top', 'halstein-core' ), 'group' => esc_html__( 'Text Style', 'halstein-core' ), ) ); $this->set_option( array( 'field_type' => 'text', 'name' => 'text_margin_bottom', 'title' => esc_html__( 'Text Margin Bottom', 'halstein-core' ), 'group' => esc_html__( 'Text Style', 'halstein-core' ), ) ); $this->set_option( array( 'field_type' => 'text', 'name' => 'tagline', 'title' => esc_html__( 'Tagline', 'halstein-core' ), 'dependency' => array( 'show' => array( 'layout' => array( 'values' => array( 'link-overlay', 'link-overlay-centered' ), 'default_value' => '', ), ), ), ) ); $this->set_option( array( 'field_type' => 'text', 'name' => 'tagline_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__( 'Tagline Style', 'halstein-core' ), 'dependency' => array( 'show' => array( 'layout' => array( 'values' => array( 'link-overlay', 'link-overlay-centered' ), 'default_value' => '', ), ), ), ) ); $this->set_option( array( 'field_type' => 'select', 'name' => 'disable_tagline_break_words', 'title' => esc_html__( 'Disable Tagline Line Break', 'halstein-core' ), 'description' => esc_html__( 'Enabling this option will disable tagline 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__( 'Tagline Style', 'halstein-core' ), 'dependency' => array( 'show' => array( 'layout' => array( 'values' => array( 'link-overlay', 'link-overlay-centered' ), 'default_value' => '', ), ), ), ) ); $this->set_option( array( 'field_type' => 'select', 'name' => 'tagline_tag', 'title' => esc_html__( 'Tagline Tag', 'halstein-core' ), 'options' => halstein_core_get_select_type_options_pool( 'title_tag' ), 'default_value' => 'h3', 'group' => esc_html__( 'Tagline Style', 'halstein-core' ), 'dependency' => array( 'show' => array( 'layout' => array( 'values' => array( 'link-overlay', 'link-overlay-centered' ), 'default_value' => '', ), ), ), ) ); $this->set_option( array( 'field_type' => 'color', 'name' => 'tagline_color', 'title' => esc_html__( 'Tagline Color', 'halstein-core' ), 'group' => esc_html__( 'Tagline Style', 'halstein-core' ), 'dependency' => array( 'show' => array( 'layout' => array( 'values' => array( 'link-overlay', 'link-overlay-centered' ), 'default_value' => '', ), ), ), ) ); $this->set_option( array( 'field_type' => 'text', 'name' => 'tagline_margin_top', 'title' => esc_html__( 'Tagline Margin Top', 'halstein-core' ), 'group' => esc_html__( 'Tagline Style', 'halstein-core' ), 'dependency' => array( 'show' => array( 'layout' => array( 'values' => array( 'link-overlay', 'link-overlay-centered' ), 'default_value' => '', ), ), ), ) ); $this->set_option( array( 'field_type' => 'text', 'name' => 'tagline_margin_bottom', 'title' => esc_html__( 'Tagline Margin Bottom', 'halstein-core' ), 'group' => esc_html__( 'Tagline Style', 'halstein-core' ), 'dependency' => array( 'show' => array( 'layout' => array( 'values' => array( 'link-overlay', 'link-overlay-centered' ), 'default_value' => '', ), ), ), ) ); $this->set_option( array( 'field_type' => 'color', 'name' => 'arrow_color', 'title' => esc_html__( 'Arrow Color', 'halstein-core' ), 'group' => esc_html__( 'Arrow Style', 'halstein-core' ), 'dependency' => array( 'show' => array( 'layout' => array( 'values' => 'link-overlay', 'default_value' => '', ), ), ), ) ); $this->import_shortcode_options( array( 'shortcode_base' => 'halstein_core_button', 'exclude' => array( 'custom_class', 'link', 'target' ), 'additional_params' => array( 'nested_group' => esc_html__( 'Button', 'halstein-core' ), 'dependency' => array( 'show' => array( 'layout' => array( 'values' => array( 'link-button-left', 'link-button-right' ), 'default_value' => '', ), ), ), ), ) ); $this->map_extra_options(); } public function render( $options, $content = null ) { parent::render( $options ); $atts = $this->get_atts(); $atts['holder_classes'] = $this->get_holder_classes( $atts ); $atts['content_styles'] = $this->get_content_styles( $atts ); $atts['title'] = $this->get_modified_string( $atts, 'title' ); $atts['title_styles'] = $this->get_title_styles( $atts ); $atts['subtitle_styles'] = $this->get_subtitle_styles( $atts ); $atts['text_field'] = $this->get_modified_string( $atts, 'text_field' ); $atts['text_styles'] = $this->get_text_styles( $atts ); $atts['tagline'] = $this->get_modified_string( $atts, 'tagline' ); $atts['tagline_styles'] = $this->get_tagline_styles( $atts ); $atts['arrow_styles'] = $this->get_arrow_styles( $atts ); $atts['button_params'] = $this->generate_button_params( $atts ); return halstein_core_get_template_part( 'shortcodes/banner', 'variations/' . $atts['layout'] . '/templates/' . $atts['layout'], '', $atts ); } private function get_holder_classes( $atts ) { $holder_classes = $this->init_holder_classes(); $holder_classes[] = 'qodef-banner'; $holder_classes[] = ! empty( $atts['layout'] ) ? 'qodef-layout--' . $atts['layout'] : ''; $holder_classes[] = ! empty( $atts['content_predefined_spacing'] ) && 'yes' === $atts['content_predefined_spacing'] ? 'qodef--content-predefined-spacing' : ''; $holder_classes[] = ! empty( $atts['content_image_responsive_position'] ) ? 'qodef-image-responsive-position--' . $atts['content_image_responsive_position'] : ''; $modified_strings = array( 'title', 'text_field', 'tagline' ); foreach ( $modified_strings as $string ) { $holder_classes[] = 'yes' === $atts[ 'disable_' . $string . '_break_words' ] ? 'qodef-' . str_replace( '_', '-', $string ) . '-break--disabled' : ''; } return implode( ' ', $holder_classes ); } private function get_content_styles( $atts ) { $styles = array(); if ( ! empty( $atts['content_margin'] ) ) { $styles[] = 'margin: ' . $atts['content_margin']; } if ( ! empty( $atts['content_padding'] ) ) { $styles[] = 'padding: ' . $atts['content_padding']; } if ( ! empty( $atts['content_background_color'] ) ) { $styles[] = 'background-color: ' . $atts['content_background_color']; } return $styles; } private function get_title_styles( $atts ) { $styles = array(); if ( '' !== $atts['title_margin_top'] ) { if ( qode_framework_string_ends_with_space_units( $atts['title_margin_top'] ) ) { $styles[] = 'margin-top: ' . $atts['title_margin_top']; } else { $styles[] = 'margin-top: ' . intval( $atts['title_margin_top'] ) . 'px'; } } if ( '' !== $atts['title_margin_bottom'] ) { if ( qode_framework_string_ends_with_space_units( $atts['title_margin_bottom'] ) ) { $styles[] = 'margin-bottom: ' . $atts['title_margin_bottom']; } else { $styles[] = 'margin-bottom: ' . intval( $atts['title_margin_bottom'] ) . 'px'; } } if ( ! empty( $atts['title_color'] ) ) { $styles[] = 'color: ' . $atts['title_color']; } return $styles; } private function get_subtitle_styles( $atts ) { $styles = array(); if ( '' !== $atts['subtitle_margin_top'] ) { if ( qode_framework_string_ends_with_space_units( $atts['subtitle_margin_top'] ) ) { $styles[] = 'margin-top: ' . $atts['subtitle_margin_top']; } else { $styles[] = 'margin-top: ' . intval( $atts['subtitle_margin_top'] ) . 'px'; } } if ( '' !== $atts['subtitle_margin_bottom'] ) { if ( qode_framework_string_ends_with_space_units( $atts['subtitle_margin_bottom'] ) ) { $styles[] = 'margin-bottom: ' . $atts['subtitle_margin_bottom']; } else { $styles[] = 'margin-bottom: ' . intval( $atts['subtitle_margin_bottom'] ) . 'px'; } } if ( ! empty( $atts['subtitle_color'] ) ) { $styles[] = 'color: ' . $atts['subtitle_color']; } return $styles; } private function get_text_styles( $atts ) { $styles = array(); if ( '' !== $atts['text_margin_top'] ) { if ( qode_framework_string_ends_with_space_units( $atts['text_margin_top'] ) ) { $styles[] = 'margin-top: ' . $atts['text_margin_top']; } else { $styles[] = 'margin-top: ' . intval( $atts['text_margin_top'] ) . 'px'; } } if ( '' !== $atts['text_margin_bottom'] ) { if ( qode_framework_string_ends_with_space_units( $atts['text_margin_bottom'] ) ) { $styles[] = 'margin-bottom: ' . $atts['text_margin_bottom']; } else { $styles[] = 'margin-bottom: ' . intval( $atts['text_margin_bottom'] ) . 'px'; } } if ( ! empty( $atts['text_color'] ) ) { $styles[] = 'color: ' . $atts['text_color']; } return $styles; } private function get_tagline_styles( $atts ) { $styles = array(); if ( '' !== $atts['tagline_margin_top'] ) { if ( qode_framework_string_ends_with_space_units( $atts['tagline_margin_top'] ) ) { $styles[] = 'margin-top: ' . $atts['tagline_margin_top']; } else { $styles[] = 'margin-top: ' . intval( $atts['tagline_margin_top'] ) . 'px'; } } if ( '' !== $atts['tagline_margin_bottom'] ) { if ( qode_framework_string_ends_with_space_units( $atts['tagline_margin_bottom'] ) ) { $styles[] = 'margin-bottom: ' . $atts['tagline_margin_bottom']; } else { $styles[] = 'margin-bottom: ' . intval( $atts['tagline_margin_bottom'] ) . 'px'; } } if ( ! empty( $atts['tagline_color'] ) ) { $styles[] = 'color: ' . $atts['tagline_color']; } return $styles; } private function get_arrow_styles( $atts ) { $styles = array(); if ( ! empty( $atts['arrow_color'] ) ) { $styles[] = 'color: ' . $atts['arrow_color']; } return $styles; } private function get_modified_string( $atts, $key ) { $string = $atts[ $key ]; if ( ! empty( $string ) && ! empty( $atts[ $key . '_line_break_positions' ] ) ) { $split_string = explode( ' ', $string ); $line_break_positions = explode( ',', str_replace( ' ', '', $atts[ $key . '_line_break_positions' ] ) ); foreach ( $line_break_positions as $position ) { $position = intval( $position ); if ( isset( $split_string[ $position - 1 ] ) && ! empty( $split_string[ $position - 1 ] ) ) { $split_string[ $position - 1 ] = $split_string[ $position - 1 ] . '<br />'; } } $string = implode( ' ', $split_string ); } return $string; } private function generate_button_params( $atts ) { $params = $this->populate_imported_shortcode_atts( array( 'shortcode_base' => 'halstein_core_button', 'exclude' => array( 'custom_class', 'link', 'target' ), 'atts' => $atts, ) ); $params['link'] = ! empty( $atts['link_url'] ) ? $atts['link_url'] : ''; $params['target'] = ! empty( $atts['link_target'] ) ? $atts['link_target'] : ''; return $params; } } }
Submit
FILE
FOLDER
Name
Size
Permission
Action
assets
---
0755
templates
---
0755
variations
---
0755
class-halsteincore-banner-shortcode-elementor.php
371 bytes
0644
class-halsteincore-banner-shortcode.php
22321 bytes
0644
include.php
239 bytes
0644
N4ST4R_ID | Naxtarrr