hin a modal window and on click opens its own modal window * Works in the same way as Editor Element * @param array $params this array holds the default values for $content and $args. * @return $params the return array usually holds an innerHtml key that holds item specific markup. */ public function editor_sub_element( $params ) { /** * Fix a bug in 4.7 and 4.7.1 renaming option id (no longer backwards comp.) - can be removed in a future version again */ if( isset( $params['args']['linktarget'] ) ) { $params['args']['link_target'] = $params['args']['linktarget']; } $default = array(); $locked = array(); $attr = $params['args']; Avia_Element_Templates()->set_locked_attributes( $attr, $this, $this->config['shortcode_nested'][0], $default, $locked ); $template = $this->update_template_lockable( 'label', __( 'Button', 'avia_framework' ) . ': {{label}}', $locked ); extract( av_backend_icon( array( 'args' => $attr ) ) ); // creates $font and $display_char if the icon was passed as param 'icon' and the font as 'font' $params['innerHtml'] = ''; $params['innerHtml'] .= "
"; $params['innerHtml'] .= 'class_by_arguments_lockable( 'font', $font, $locked ) . '>'; $params['innerHtml'] .= 'update_option_lockable( array( 'icon', 'icon_fakeArg' ), $locked ) . " class='avia_tab_icon'>{$display_char}"; $params['innerHtml'] .= ''; $params['innerHtml'] .= "" . __( 'Button', 'avia_framework' ) . ": {$attr['label']}
"; return $params; } /** * * @since 4.5.5 * @param string $shortcode * @return boolean */ public function is_nested_self_closing( $shortcode ) { if( in_array( $shortcode, $this->config['shortcode_nested'] ) ) { return true; } return false; } /** * Override base class - we have global attributes here * * @since 4.8.4 * @return boolean */ public function has_global_attributes() { return true; } /** * Create custom stylings * * @since 4.8.4 * @param array $args * @return array */ protected function get_element_styles( array $args ) { $result = parent::get_element_styles( $args ); extract( $result ); $default = array( 'alignment' => 'center', 'button_spacing' => '5', 'button_spacing_unit' => 'px' ); $default = $this->sync_sc_defaults_array( $default, 'no_modal_item', 'no_content' ); $locked = array(); Avia_Element_Templates()->set_locked_attributes( $atts, $this, $shortcodename, $default, $locked, $content ); Avia_Element_Templates()->add_template_class( $meta, $atts, $default ); $atts = shortcode_atts( $default, $atts, $this->config['shortcode'] ); $this->screen_options = AviaHelper::av_mobile_sizes( $atts ); $classes = array( 'avia-buttonrow-wrap', $element_id, 'avia-buttonrow-' . $atts['alignment'] ); $element_styling->add_classes( 'container', $classes ); $element_styling->add_classes_from_array( 'container', $meta, 'el_class' ); $selectors = array( 'container' => ".avia-buttonrow-wrap.{$element_id}" ); $element_styling->add_selectors( $selectors ); $result['default'] = $default; $result['atts'] = $atts; $result['content'] = $content; $result['element_styling'] = $element_styling; $result['meta'] = $meta; return $result; } /** * Create custom stylings for items * * @since 4.8.4 * @param array $args * @return array */ protected function get_element_styles_item( array $args ) { // get settings from container element and remove to get correct element id (override self::has_global_attributes() to activate) $parent_atts = isset( $args['atts']['parent_atts'] ) ? $args['atts']['parent_atts'] : null; unset( $args['atts']['parent_atts'] ); $result = parent::get_element_styles_item( $args ); extract( $result ); /** * Fix a bug in 4.7 and 4.7.1 renaming option id (no longer backwards comp.) - can be removed in a future version again */ if( isset( $atts['linktarget'] ) ) { $atts['link_target'] = $atts['linktarget']; } $default = $this->get_default_btn_atts(); $default = $this->sync_sc_defaults_array( $default, 'modal_item' ); $locked = array(); Avia_Element_Templates()->set_locked_attributes( $atts, $this, $shortcodename, $default, $locked, $content ); $atts = shortcode_atts( $default, $atts, $this->config['shortcode_nested'][0] ); if( $atts['icon_select'] == 'yes' ) { $atts['icon_select'] = 'yes-left-icon'; } $classes = array( 'avia-button', $element_id ); $element_styling->add_classes( 'container', $classes ); $element_styling->add_classes( 'container', $this->class_by_arguments( 'icon_select, size', $atts, true, 'array' ) ); $this->set_button_styes( $element_styling, $atts, true ); if( ! is_array( $parent_atts ) ) { $spacing = $this->spacing; $spacing_unit = $this->spacing_unit; $alignment = $this->alignment; } else { $spacing = isset( $parent_atts['button_spacing'] ) && is_numeric( $parent_atts['button_spacing'] ) ? $parent_atts['button_spacing'] : ''; $spacing_unit = isset( $parent_atts['button_spacing_unit'] ) && ! empty( $parent_atts['button_spacing_unit'] ) ? $parent_atts['button_spacing_unit'] : 'px'; $alignment = isset( $parent_atts['alignment'] ) && ! empty( $parent_atts['alignment'] ) ? $parent_atts['alignment'] : 'center'; } if( ! empty( $spacing ) ) { $spacing_string = $spacing . $spacing_unit; $element_styling->add_styles( 'container', array( 'margin-bottom' => $spacing_string ) ); switch( $alignment ) { case 'left': $element_styling->add_styles( 'container', array( 'margin-right' => $spacing_string ) ); break; case 'right': $element_styling->add_styles( 'container', array( 'margin-left' => $spacing_string ) ); break; case 'center': default: $spacing_string = round( $spacing / 2 ) . $spacing_unit; $element_styling->add_styles( 'container', array( 'margin-right' => $spacing_string ) ); $element_styling->add_styles( 'container', array( 'margin-left' => $spacing_string ) ); break; } } $selectors = array( 'container' => "#top #wrap_all .avia-button.{$element_id}", 'container-hover' => "#top #wrap_all .avia-button.{$element_id}:hover", 'container-hover-overlay' => "#top #wrap_all .avia-button.{$element_id}:hover .avia_button_background", 'container-after' => ".avia-button.{$element_id}.avia-sonar-shadow:after", 'container-after-hover' => ".avia-button.{$element_id}.avia-sonar-shadow:hover:after" ); $element_styling->add_selectors( $selectors ); $result['default'] = $default; $result['atts'] = $atts; $result['content'] = $content; $result['element_styling'] = $element_styling; return $result; } /** * Frontend Shortcode Handler * * @param array $atts array of attributes * @param string $content text within enclosing form of shortcode element * @param string $shortcodename the shortcode found, when == callback name * @return string $output returns the modified html string */ public function shortcode_handler( $atts, $content = '', $shortcodename = '', $meta = '' ) { $result = $this->get_element_styles( compact( array( 'atts', 'content', 'shortcodename', 'meta' ) ) ); extract( $result ); extract( $this->screen_options ); //return $av_font_classes, $av_title_font_classes and $av_display_classes extract( $atts ); $this->alignment = $alignment; $this->spacing = is_numeric( $button_spacing ) && $button_spacing > 0 ? $button_spacing : ''; $this->spacing_unit = $button_spacing_unit; $style_tag = $element_styling->get_style_tag( $element_id ); $container_class = $element_styling->get_class_string( 'container' ); $output = ''; $output .= $style_tag; $output .= "
"; $output .= ShortcodeHelper::avia_remove_autop( $content, true ); $output .= '
'; $this->screen_options = array(); return $output; } /** * Shortcode handler * * @param array $atts * @param string $content * @param string $shortcodename * @return string */ public function av_buttonrow_item( $atts, $content = '', $shortcodename = '' ) { /** * Fixes a problem when 3-rd party plugins call nested shortcodes without executing main shortcode (like YOAST in wpseo-filter-shortcodes) */ if( empty( $this->screen_options ) ) { return ''; } $result = $this->get_element_styles_item( compact( array( 'atts', 'content', 'shortcodename' ) ) ); extract( $result ); extract( $this->screen_options ); //return $av_font_classes, $av_title_font_classes and $av_display_classes $data = ''; $style_hover = ''; $background_hover = ''; $display_char = av_icon( $atts['icon'], $atts['font'] ); if( '' != $atts['color_options'] ) { if( 'custom' != $atts['btn_color_bg_hover'] && 'btn_custom_grad' != $atts['btn_color_bg'] ) { // must be added otherwise we get a bottom border !!! // $style_hover = "style='background-color:{$atts['btn_color_bg_hover']};'"; if( $this->is_special_button_color( $atts['btn_color_bg_hover'] ) ) { $background_hover = ""; } } } if( ! empty( $atts['label_display'] ) && $atts['label_display'] == 'av-button-label-on-hover' ) { $data .= 'data-avia-tooltip="' . htmlspecialchars( $atts['label'] ) . '"'; $atts['label'] = ''; } $blank = AviaHelper::get_link_target( $atts['link_target'] ); $link = trim( AviaHelper::get_url( $atts['link'] ) ); $link = ( in_array( $link, array( 'http://', 'https://', 'manually' ) ) ) ? '' : $link; $title_attr = ! empty( $atts['title_attr'] ) && empty( $atts['label_display'] ) ? 'title="' . esc_attr( $atts['title_attr'] ) . '"' : ''; $content_html = ''; if( 'yes-left-icon' == $atts['icon_select'] ) { $content_html .= ""; } $content_html .= "" . $atts['label'] . ""; if( 'yes-right-icon' == $atts['icon_select'] ) { $content_html .= ""; } $style_tag = $element_styling->get_style_tag( $element_id ); $container_class = $element_styling->get_class_string( 'container' ); $output = ''; $output .= $style_tag; $output .= ""; $output .= $content_html; $output .= $background_hover; $output .= ''; return $output; } } }