WordPress.org

Plugin Directory

!This plugin hasn’t been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.

Pronamic Cookies

Handy solutions to the new Cookie Law. Full site blocker or just a bar. You can also block specific sections of a page.

Sections

You can specify sections you want to require a cookie to be set with the following:

<?php pronamic_cookies_is_section_accepted( $name ); ?>

$name will be a unique name for this cookie. This method will return boolean depending if the cookie has been set or not.

<?php pronamic_cookies_button( $name, $arguments = array() ); ?>

$name will be the same name used in is_pronamic_cookies_section_accepted(); $arguments allow an array of the following keys:

  • title (the title message in the modal)
  • description (an overode description text, from the option set)
  • button (the text on the button itself)

Dynamic

A new dynamic component is available that will ensure that sections are correctly shown even with any caching in place.

<?php $name = 'pronamic_cookies_dynamic'; ?>

Name is the unique naming given to this dynamic section. Its name is important for determining the content you want to show once accepted.

<?php $container = 'pronamic_cookies_dynamic_container'; ?>

This is the name of the surrounding div ( CSS CLASS NAME )

<?php

$arguments = array(
    'title'       => __( 'Title on the message modal' ),
    'description' => __( 'Will overide the description text from the options' ),
    'button'      => __( 'The text on the button' )
);

pronamic_cookies_dynamic( $name, $container, $arguments );

?>

You don't require an if statement with dynamic ( or the usage of pronamic_cookies_is_section_accepted() ).

Success Content

To show the success content for pronamic_cookies_dynamic, you require a function that is used in combination with add_filter

<?php add_filter( 'pronamic_cookies_dynamic_$name', 'function_name' ); ?>

Where $name is the name used in the call to pronamic_cookies_dynamic();

Example

<div class="pronamic_cookies_dynamic_container">
    <a href="#" class="jShowCookieLawModal">Click</a>
</div>
<?php

pronamic_cookies_dynamic( 'facebook_section', 'pronamic_cookies_dynamic_container', array(
    'title' => __( 'Cookies are required for this section' )
) );

// In a functions file
add_filter( 'pronamic_cookies_dynamic_facebook_section', 'facebook_section_success' );

function facebook_section_success( $content ) {
    $content = 'custom javascript or anything else';
    return $content;
}
?>

JavaScript

You can call the modal of pronamic_cookies_dynamic and pronamic_cookies_section from anything (imgs, buttons, links) just give that element the class 'jShowCookieLawModal'

Requires: 3.2 or higher
Compatible up to: 3.7.15
Last Updated: 3 years ago
Active Installs: 5,000+

Ratings

5 out of 5 stars

Support

0 of 1 support threads in the last two months have been marked resolved.

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.

100,1,1
100,1,1
100,1,1
100,1,1
50,2,1
100,1,1
100,1,1