From 78165197a936f6eaecf9ff93aa858d58d39483a2 Mon Sep 17 00:00:00 2001 From: Jesse Norell Date: Thu, 26 Jul 2018 17:46:34 -0600 Subject: [PATCH] add type='link' shortcode attribute Using type='link' shortcode attribute will output an html link rather than a button. --- includes/helper-functions.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/includes/helper-functions.php b/includes/helper-functions.php index 72c63cbf..f0316ddb 100644 --- a/includes/helper-functions.php +++ b/includes/helper-functions.php @@ -14,11 +14,17 @@ * Adds a button to re-open the cookie preferences modal. * @since 1.0.0 * @author Fernando Claussen - * @param string $text The button text. - * @param string $type The type of preferences. Possible options are `cookies` or `consents` + * @param array $atts Configurable attributes to specify text, tab and element type. */ -function gdpr_preferences( $text, $tab = 'gdpr-consent-management' ) { - echo ''; +function gdpr_preferences( $atts ) { + $tab = ( isset( $atts['tab'] ) ) ? $atts['tab'] : 'gdpr-consent-management'; + $type = ( isset( $atts['type'] ) ) ? $atts['type'] : 'button'; + + if ( $type == 'link' ) { + echo '' . esc_html( $atts['text'] ) . ''; + } else { + echo ''; + } } function gdpr_preferences_shortcode( $atts ) { @@ -26,11 +32,12 @@ function gdpr_preferences_shortcode( $atts ) { array( 'text' => esc_html__( 'Privacy Preferences', 'gdpr' ), 'tab' => 'gdpr-consent-management', + 'type' => 'button', ), $atts, 'gdpr_preferences' ); ob_start(); - gdpr_preferences( $atts['text'], $atts['tab'] ); + gdpr_preferences( $atts ); return ob_get_clean(); }