vc-hoverbox.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. if ( ! defined( 'ABSPATH' ) ) {
  3. die( '-1' );
  4. }
  5. /**
  6. * Class WPBakeryShortCode_Vc_Hoverbox
  7. */
  8. class WPBakeryShortCode_Vc_Hoverbox extends WPBakeryShortCode {
  9. /**
  10. * @param $tag
  11. * @param $atts
  12. * @param $align
  13. * @return string
  14. * @throws \Exception
  15. */
  16. public function getHeading( $tag, $atts, $align ) {
  17. if ( isset( $atts[ $tag ] ) && '' !== trim( $atts[ $tag ] ) ) {
  18. if ( isset( $atts[ 'use_custom_fonts_' . $tag ] ) && 'true' === $atts[ 'use_custom_fonts_' . $tag ] ) {
  19. $custom_heading = visual_composer()->getShortCode( 'vc_custom_heading' );
  20. $data = vc_map_integrate_parse_atts( $this->shortcode, 'vc_custom_heading', $atts, $tag . '_' );
  21. $data['font_container'] = implode( '|', array_filter( array(
  22. 'tag:h2',
  23. 'text_align:' . esc_attr( $align ),
  24. $data['font_container'],
  25. ) ) );
  26. $data['text'] = $atts[ $tag ]; // provide text to shortcode
  27. return $custom_heading->render( array_filter( $data ) );
  28. } else {
  29. $inline_css = array();
  30. $inline_css_string = '';
  31. if ( isset( $atts['style'] ) && 'custom' === $atts['style'] ) {
  32. if ( ! empty( $atts['custom_text'] ) ) {
  33. $inline_css[] = vc_get_css_color( 'color', $atts['custom_text'] );
  34. }
  35. }
  36. if ( $align ) {
  37. $inline_css[] = 'text-align:' . esc_attr( $align );
  38. }
  39. if ( ! empty( $inline_css ) ) {
  40. $inline_css_string = ' style="' . implode( '', $inline_css ) . '"';
  41. }
  42. return '<h2' . $inline_css_string . '>' . $atts[ $tag ] . '</h2>';
  43. }
  44. }
  45. return '';
  46. }
  47. /**
  48. * @param $atts
  49. * @return string
  50. * @throws \Exception
  51. */
  52. public function renderButton( $atts ) {
  53. $button_atts = vc_map_integrate_parse_atts( $this->shortcode, 'vc_btn', $atts, 'hover_btn_' );
  54. $button = visual_composer()->getShortCode( 'vc_btn' );
  55. return $button->render( array_filter( $button_atts ) );
  56. }
  57. }