Italy Cookie Choices Shortcodes

Below, you’ll find a detailed guide on how to add the Italy Cookie Choices Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Italy Cookie Choices Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the Italy Cookie Choices Plugin and the shortcodes it provides:

Plugin Icon
Italy Cookie Choices (for EU Cookie Law & Cookie Notice)

"Italy Cookie Choices is a reliable WordPress plugin designed for EU Cookie Law & Cookie Notice compliance. This plugin ensures your website respects user privacy regulations."

★★★★✩ (35) Active Installs: 20000+ Tested with: 6.0.6 PHP Version: 7.4
Included Shortcodes:
  • [accept_button]
  • [delete_cookie]

Italy Cookie Choices [accept_button] Shortcode

The Italy Cookie Choices plugin shortcode ‘accept_button’ is designed to generate a button for users to accept cookies. The button text is customizable via the ‘button_text’ option. Upon clicking, it triggers the ‘cookieChoices.removeCookieConsent()’ function, effectively accepting cookies.

Shortcode: [accept_button]

Examples and Usage

Basic example – A simple shortcode to display the acceptance button for cookie choices.

[accept_button /]

PHP Function Code

In case you have difficulties debugging what causing issues with [accept_button] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'accept_button', array( $this, 'accept_button' ) );

Shortcode PHP function:

function accept_button( $atts, $content = null ) {

		$button_text = ( isset( $this->options['button_text'] ) ) ? $this->options['button_text'] : '' ;

		return '<span class="el"><button onclick="cookieChoices.removeCookieConsent()">' . esc_attr( $button_text ) . '</button></span>';

	}

Code file location:

italy-cookie-choices/italy-cookie-choices/core/Cookie_Choices.php

Italy Cookie Choices [delete_cookie] Shortcode

The Italy Cookie Choices plugin shortcode ‘delete_cookie’ initiates a function to delete cookies. Upon activation, it displays a button labeled ‘Delete cookie’. When clicked, it triggers the ‘deleteCookie()’ JavaScript function, effectively removing the cookie.

Shortcode: [delete_cookie]

Examples and Usage

Basic example – The shortcode [delete_cookie] can be used to display a button with the text “Delete cookie”. When clicked, this button will trigger the deleteCookie() function.

[delete_cookie /]

PHP Function Code

In case you have difficulties debugging what causing issues with [delete_cookie] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'delete_cookie', array( $this, '_delete_cookie' ) );

Shortcode PHP function:

function _delete_cookie( $atts, $content = null ) {

		// $button_text = ( isset( $this->options['button_text'] ) ) ? $this->options['button_text'] : '' ;
		$button_text = 'Delete cookie';

		return '<span class="ele"><button onclick="deleteCookie()">' . esc_attr( $button_text ) . '</button></span>';

	}

Code file location:

italy-cookie-choices/italy-cookie-choices/core/Cookie_Choices.php

Conclusion

Now that you’ve learned how to embed the Italy Cookie Choices Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *