Guest User

Untitled

a guest
Dec 14th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. <?php
  2. /**
  3. * Adds shortcode for PDF download element.
  4. *
  5. * @package your-package.
  6. */
  7.  
  8. /**
  9. * Add shortcode function for PDF download element.
  10. * [pdf_download name="Aktuelle Produktinformationen" label="PDF DOWNLOAD" link="#"].
  11. *
  12. * @param array $atts attributes.
  13. */
  14. function pdf_download_sc_func( $atts ) {
  15. $atts = shortcode_atts(
  16. array(
  17. 'name' => 'Aktuelle Produktinformationen',
  18. 'label' => 'PDF DOWNLOAD',
  19. 'link' => '#',
  20. ),
  21. $atts,
  22. 'pdf_download'
  23. );
  24. ob_start();
  25. ?>
  26. <a class="pdf-download" href="<?php echo esc_url( $atts['link'] ); ?>" target="_blank" rel="noopener">
  27. <img class="pdf-download__icon" src="<?php echo esc_url( get_stylesheet_directory_uri() ); ?>/img/pdf-icon.svg" alt="PDF Icon">
  28. <div class="pdf-download__text">
  29. <span><?php echo esc_html( $atts['name'] ); ?></span><br>
  30. <strong><?php echo esc_html( $atts['label'] ); ?></strong>
  31. </div>
  32. </a>
  33. <?php
  34. return ob_get_clean();
  35. }
  36. add_shortcode( 'pdf_download', 'pdf_download_sc_func' );
Add Comment
Please, Sign In to add comment