frontend.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. $has_lightbox = vamtam_sanitize_bool( $settings->lightbox_embed );
  3. $button_class = array(
  4. 'vamtam-button',
  5. $settings->color,
  6. 'hover-' . $settings->hover_color,
  7. 'button-' . $settings->layout_type,
  8. 'icon-animation-' . $settings->icon_animation,
  9. );
  10. $button_attrs = '';
  11. if ( $has_lightbox ) {
  12. global $wp_embed, $content_width;
  13. $lightbox_content = do_shortcode( $wp_embed->run_shortcode( '[embed width="' . esc_attr( $content_width ) . '"]' . $settings->link . '[/embed]' ) );
  14. $button_attrs .= ' data-vamtam-lightbox="' . esc_attr( $lightbox_content ) . '"';
  15. $settings->link_target = '_blank';
  16. Vamtam_Elements_B::enqueue_lightbox_template();
  17. }
  18. $style = 'font-size:' . (int) $settings->font_size . 'px;line-height:' . ((int) $settings->font_size + 2 ) . 'px;';
  19. if ( 'custom' == $settings->width ) {
  20. $style .= 'width:' . (int) $settings->custom_width . 'px;';
  21. }
  22. if ( ! empty( $settings->padding ) ) {
  23. if ( 'underline' === $settings->layout_type ) {
  24. $style .= 'padding:' . (int) $settings->padding . 'px 0px;';
  25. } else {
  26. $style .= 'padding:' . (int) $settings->padding . 'px ' . (int) $settings->padding * 2 . 'px;';
  27. }
  28. }
  29. $button_attrs .= 'style="' . esc_attr( $style ) . '"';
  30. ?>
  31. <div class="<?php echo esc_attr( $module->get_classname() ) ?>" style="<?php if ( ! empty( $settings->align ) ) echo esc_attr( 'text-align:' . $settings->align ) ?>">
  32. <a href="<?php echo esc_url( $settings->link ) ?>" target="<?php echo esc_attr( $settings->link_target ) ?>" class="<?php echo esc_attr( implode( ' ', $button_class ) ) ?>" role="button" <?php echo $button_attrs // xss ok ?>>
  33. <?php if ( ! empty( $settings->icon ) && ( 'before' == $settings->icon_position || ! isset( $settings->icon_position ) ) ) : ?>
  34. <i class="vamtam-button-icon vamtam-button-icon-before fa <?php echo esc_attr( $settings->icon ) ?>" <?php if ( empty( $settings->text ) ) : ?>style="margin-right:0"<?php endif ?>></i>
  35. <?php endif; ?>
  36. <?php if ( ! empty( $settings->text ) ) : ?>
  37. <span class="vamtam-button-text"><?php echo $settings->text; // xss ok ?></span>
  38. <?php endif; ?>
  39. <?php if ( ! empty( $settings->icon ) && 'after' == $settings->icon_position ) : ?>
  40. <i class="vamtam-button-icon vamtam-button-icon-after fa <?php echo esc_attr( $settings->icon ) ?>" <?php if ( empty( $settings->text ) ) : ?>style="margin-left:0"<?php endif ?>></i>
  41. <?php endif; ?>
  42. </a>
  43. </div>