Advertisement
Guest User

Untitled

a guest
May 20th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.38 KB | None | 0 0
  1. <?php
  2. if ( ! defined( 'ABSPATH' ) ) {
  3. die( '-1' );
  4. }
  5.  
  6. /**
  7. * Shortcode attributes
  8. * @var $atts
  9. * @var $source
  10. * @var $text
  11. * @var $link
  12. * @var $google_fonts
  13. * @var $font_container
  14. * @var $el_class
  15. * @var $el_id
  16. * @var $css
  17. * @var $css_animation
  18. * @var $font_container_data - returned from $this->getAttributes
  19. * @var $google_fonts_data - returned from $this->getAttributes
  20. * Shortcode class
  21. * @var $this WPBakeryShortCode_VC_Custom_heading
  22. */
  23. $source = $text = $link = $google_fonts = $font_container = $el_id = $el_class = $css = $css_animation = $font_container_data = $google_fonts_data = '';
  24.  
  25. // This is needed to extract $font_container_data and $google_fonts_data
  26. extract( $this->getAttributes( $atts ) );
  27.  
  28. $atts = vc_map_get_attributes( $this->getShortcode(), $atts );
  29. extract( $atts );
  30.  
  31.  
  32. /**
  33. * @var $css_class
  34. */
  35. extract( $this->getStyles( $el_class . $this->getCSSAnimation( $css_animation ), $css, $google_fonts_data, $font_container_data, $atts ) );
  36.  
  37. $settings = get_option( 'wpb_js_google_fonts_subsets' );
  38. if ( is_array( $settings ) && ! empty( $settings ) ) {
  39. $subsets = '&subset=' . implode( ',', $settings );
  40. } else {
  41. $subsets = '';
  42. }
  43.  
  44. if ( ( ! isset( $atts['use_theme_fonts'] ) || 'yes' !== $atts['use_theme_fonts'] ) && isset( $google_fonts_data['values']['font_family'] ) ) {
  45. wp_enqueue_style( 'vc_google_fonts_' . vc_build_safe_css_class( $google_fonts_data['values']['font_family'] ), '//fonts.googleapis.com/css?family=' . $google_fonts_data['values']['font_family'] . $subsets );
  46. }
  47.  
  48. if ( ! empty( $styles ) ) {
  49. $style = 'style="' . esc_attr( implode( ';', $styles ) ) . '"';
  50. } else {
  51. $style = '';
  52. }
  53.  
  54. if ( 'post_title' === $source ) {
  55. $text = get_the_title( get_the_ID() );
  56. }
  57.  
  58. if ( ! empty( $link ) ) {
  59. $link = vc_build_link( $link );
  60. $text = '<a href="' . esc_attr( $link['url'] ) . '"' . ( $link['target'] ? ' target="' . esc_attr( $link['target'] ) . '"' : '' ) . ( $link['rel'] ? ' rel="' . esc_attr( $link['rel'] ) . '"' : '' ) . ( $link['title'] ? ' title="' . esc_attr( $link['title'] ) . '"' : '' ) . '>' . $text . '</a>';
  61. }
  62.  
  63. /* Responsive text */
  64. $text_data = '';
  65. if ( isset( $responsive_font ) && 'yes' == $responsive_font ) {
  66. $text_id = uniqid();
  67. $text_css = '';
  68. $text_el = '[data-uid="' . esc_attr( $text_id ) . '"]';
  69.  
  70. if ( $font_size_xs != '' || $line_height_xs != '' ) {
  71. $text_css .= '@media (max-width: 767px) { ' .
  72. $text_el . '{';
  73.  
  74. if ( $font_size_xs != '' ) {
  75. $text_css .= 'font-size: ' . kleo_set_default_unit( $font_size_xs ) . ' !important;';
  76. }
  77.  
  78. if ( $line_height_xs != '' ) {
  79. $text_css .= 'line-height: ' . kleo_set_default_unit( $line_height_xs ) . ' !important;';
  80. }
  81. $text_css .= '} }';
  82. }
  83.  
  84. if ( $font_size_sm != '' || $line_height_sm != '' ) {
  85. $text_css .= '@media (min-width: 768px) and (max-width: 991px) { ' .
  86. $text_el . '{';
  87.  
  88. if ( $font_size_sm != '' ) {
  89. $text_css .= 'font-size: ' . kleo_set_default_unit( $font_size_sm ) . ' !important;';
  90. }
  91.  
  92. if ( $line_height_sm != '' ) {
  93. $text_css .= 'line-height: ' . kleo_set_default_unit( $line_height_sm ) . ' !important;';
  94. }
  95. $text_css .= '} }';
  96. }
  97.  
  98. if ( $font_size_md != '' || $line_height_md != '' ) {
  99. $text_css .= '@media (min-width: 992px) and (max-width: 1199px) { ' .
  100. $text_el . '{';
  101.  
  102. if ( $font_size_md != '' ) {
  103. $text_css .= 'font-size: ' . kleo_set_default_unit( $font_size_md ) . ' !important;';
  104. }
  105.  
  106. if ( $line_height_md != '' ) {
  107. $text_css .= 'line-height: ' . kleo_set_default_unit( $line_height_md ) . ' !important;';
  108. }
  109. $text_css .= '} }';
  110. }
  111.  
  112. $text_data = ' data-uid="' . esc_attr( $text_id ) . '"';
  113. echo '<style>' . $text_css . '</style>';
  114. }
  115.  
  116. $output = '';
  117. if ( apply_filters( 'vc_custom_heading_template_use_wrapper', false ) ) {
  118. $output .= '<div class="' . esc_attr( $css_class ) . '" id="'.esc_attr( $atts['el_id'] ).'" >';
  119. $output .= '<' . $font_container_data['values']['tag'] . ' ' . $style . $text_data . ' >';
  120. $output .= $text;
  121. $output .= '</' . $font_container_data['values']['tag'] . '>';
  122. $output .= '</div>';
  123. } else {
  124. $output .= '<' . $font_container_data['values']['tag'] . ' ' . $style . $text_data . ' class="' . esc_attr( $css_class ) . '" id="'.esc_attr( $atts['el_id'] ).'">';
  125. $output .= $text;
  126. $output .= '</' . $font_container_data['values']['tag'] . '>';
  127. }
  128.  
  129. echo $output; // PHPCS: XSS ok.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement