Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Adds shortcode for PDF download element.
- *
- * @package your-package.
- */
- /**
- * Add shortcode function for PDF download element.
- * [pdf_download name="Aktuelle Produktinformationen" label="PDF DOWNLOAD" link="#"].
- *
- * @param array $atts attributes.
- */
- function pdf_download_sc_func( $atts ) {
- $atts = shortcode_atts(
- array(
- 'name' => 'Aktuelle Produktinformationen',
- 'label' => 'PDF DOWNLOAD',
- 'link' => '#',
- ),
- $atts,
- 'pdf_download'
- );
- ob_start();
- ?>
- <a class="pdf-download" href="<?php echo esc_url( $atts['link'] ); ?>" target="_blank" rel="noopener">
- <img class="pdf-download__icon" src="<?php echo esc_url( get_stylesheet_directory_uri() ); ?>/img/pdf-icon.svg" alt="PDF Icon">
- <div class="pdf-download__text">
- <span><?php echo esc_html( $atts['name'] ); ?></span><br>
- <strong><?php echo esc_html( $atts['label'] ); ?></strong>
- </div>
- </a>
- <?php
- return ob_get_clean();
- }
- add_shortcode( 'pdf_download', 'pdf_download_sc_func' );
Add Comment
Please, Sign In to add comment