summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/modules/widgets/eu-cookie-law')
-rw-r--r--plugins/jetpack/modules/widgets/eu-cookie-law/eu-cookie-law-admin.js30
-rw-r--r--plugins/jetpack/modules/widgets/eu-cookie-law/eu-cookie-law.js16
-rw-r--r--plugins/jetpack/modules/widgets/eu-cookie-law/form.php226
-rw-r--r--plugins/jetpack/modules/widgets/eu-cookie-law/style.css19
-rw-r--r--plugins/jetpack/modules/widgets/eu-cookie-law/widget.php12
5 files changed, 220 insertions, 83 deletions
diff --git a/plugins/jetpack/modules/widgets/eu-cookie-law/eu-cookie-law-admin.js b/plugins/jetpack/modules/widgets/eu-cookie-law/eu-cookie-law-admin.js
new file mode 100644
index 00000000..b0bfd484
--- /dev/null
+++ b/plugins/jetpack/modules/widgets/eu-cookie-law/eu-cookie-law-admin.js
@@ -0,0 +1,30 @@
+
+/* eslint no-var: 0 */
+
+( function( $ ) {
+ var $document = $( document );
+
+ $document.on( 'ready', function() {
+ var maybeShowNotice = function( e, policyUrl ) {
+ var $policyUrl = $( policyUrl || this )
+ .closest( '.eu-cookie-law-widget-policy-url' );
+
+ if ( $policyUrl.find( 'input[type="radio"][value="default"]' ).is( ':checked' ) ) {
+ $policyUrl.find( '.notice.default-policy' ).css( 'display', 'block' );
+ $policyUrl.find( '.notice.custom-policy' ).hide();
+ } else {
+ $policyUrl.find( '.notice.default-policy' ).hide();
+ $policyUrl.find( '.notice.custom-policy' ).css( 'display', 'block' );
+ }
+ };
+
+ $document.on( 'click', '.eu-cookie-law-widget-policy-url input[type="radio"]', maybeShowNotice );
+ $document.on( 'widget-updated widget-added', function( e, widget ) {
+ var widgetId = $( widget ).attr( 'id' );
+ if ( widgetId.indexOf( 'eu_cookie_law_widget' ) !== -1 ) {
+ maybeShowNotice( null, $( '#' + widgetId + ' .eu-cookie-law-widget-policy-url' ) );
+ }
+ } );
+ $( '.eu-cookie-law-widget-policy-url' ).each( maybeShowNotice );
+ } );
+} )( jQuery );
diff --git a/plugins/jetpack/modules/widgets/eu-cookie-law/eu-cookie-law.js b/plugins/jetpack/modules/widgets/eu-cookie-law/eu-cookie-law.js
index 18ed69c5..b7f8c7db 100644
--- a/plugins/jetpack/modules/widgets/eu-cookie-law/eu-cookie-law.js
+++ b/plugins/jetpack/modules/widgets/eu-cookie-law/eu-cookie-law.js
@@ -4,7 +4,16 @@
initialScrollPosition,
scrollFunction;
- if ( '' !== cookieValue ) {
+ if ( overlay.hasClass( 'top' ) ) {
+ $( '.widget_eu_cookie_law_widget' ).addClass( 'top' );
+ }
+
+ if ( overlay.hasClass( 'ads-active' ) ) {
+ var adsCookieValue = document.cookie.replace( /(?:(?:^|.*;\s*)personalized-ads-consent\s*\=\s*([^;]*).*$)|^.*$/, '$1' );
+ if ( '' !== cookieValue && '' !== adsCookieValue ) {
+ overlay.remove();
+ }
+ } else if ( '' !== cookieValue ) {
overlay.remove();
}
@@ -40,9 +49,12 @@
}
var expireTime = new Date();
- expireTime.setTime( expireTime.getTime() + 2592000000 ); // 30 days
+ expireTime.setTime( expireTime.getTime() + ( overlay.data( 'consent-expiration' ) * 24 * 60 * 60 * 1000 ) );
document.cookie = 'eucookielaw=' + expireTime.getTime() + ';path=/;expires=' + expireTime.toGMTString();
+ if ( overlay.hasClass( 'ads-active' ) && overlay.hasClass( 'hide-on-button' ) ) {
+ document.cookie = 'personalized-ads-consent=' + expireTime.getTime() + ';path=/;expires=' + expireTime.toGMTString();
+ }
overlay.fadeOut( 400, function() {
overlay.remove();
diff --git a/plugins/jetpack/modules/widgets/eu-cookie-law/form.php b/plugins/jetpack/modules/widgets/eu-cookie-law/form.php
index cdd777ad..7b00877b 100644
--- a/plugins/jetpack/modules/widgets/eu-cookie-law/form.php
+++ b/plugins/jetpack/modules/widgets/eu-cookie-law/form.php
@@ -1,6 +1,130 @@
<p>
<strong>
- <?php _ex( 'Hide the banner', 'action', 'jetpack' ); ?>
+ <?php esc_html_e( 'Banner text', 'jetpack' ); ?>
+ </strong>
+ <ul>
+ <li>
+ <label>
+ <input
+ <?php checked( $instance['text'], 'default' ); ?>
+ name="<?php echo esc_attr( $this->get_field_name( 'text' ) ); ?>"
+ type="radio"
+ value="default"
+ />
+ <?php esc_html_e( 'Default', 'jetpack' ); ?>
+ </label>
+ </li>
+ <li>
+ <label>
+ <input
+ <?php checked( $instance['text'], 'custom' ); ?>
+ name="<?php echo esc_attr( $this->get_field_name( 'text' ) ); ?>"
+ type="radio"
+ value="custom"
+ />
+ <?php esc_html_e( 'Custom:', 'jetpack' ); ?>
+ </label>
+ </li>
+ </ul>
+ <textarea
+ class="widefat"
+ name="<?php echo esc_attr( $this->get_field_name( 'customtext' ) ); ?>"
+ placeholder="<?php echo esc_attr( $instance['default-text'] ); ?>"
+ ><?php echo esc_html( $instance['customtext'] ); ?></textarea>
+</p>
+
+<hr />
+
+<p>
+ <strong>
+ <?php esc_html_e( 'Privacy Policy Link', 'jetpack' ); ?>
+ </strong>
+ <ul class="eu-cookie-law-widget-policy-url">
+ <li>
+ <label>
+ <input
+ <?php checked( $instance['policy-url'], 'default' ); ?>
+ name="<?php echo esc_attr( $this->get_field_name( 'policy-url' ) ); ?>"
+ type="radio"
+ value="default"
+ />
+ <?php esc_html_e( 'Default', 'jetpack' ); ?>
+ </label>
+ </li>
+ <li>
+ <label>
+ <input
+ <?php checked( $instance['policy-url'], 'custom' ); ?>
+ name="<?php echo esc_attr( $this->get_field_name( 'policy-url' ) ); ?>"
+ type="radio"
+ value="custom"
+ />
+ <?php esc_html_e( 'Custom URL:', 'jetpack' ); ?>
+ </label>
+ <input
+ class="widefat"
+ name="<?php echo esc_attr( $this->get_field_name( 'custom-policy-url' ) ); ?>"
+ placeholder="<?php echo esc_url( $instance['default-policy-url'] ); ?>"
+ style="margin-top: .5em;"
+ type="text"
+ value="<?php echo esc_url( $instance['custom-policy-url'] ); ?>"
+ />
+ <span class="notice notice-warning default-policy" style="display: none;">
+ <span style="display: block; margin: .5em 0;">
+ <strong><?php esc_html_e( 'Caution:', 'jetpack' ); ?></strong>
+ <?php esc_html_e( 'The default policy URL only covers cookies set by Jetpack. If you’re running other plugins, custom cookies, or third-party tracking technologies, you should create and link to your own cookie statement.', 'jetpack' ); ?>
+ </span>
+ </span>
+ <?php if ( Jetpack::is_module_active( 'wordads' ) ) : ?>
+ <span class="notice notice-warning custom-policy" style="display: none;">
+ <span style="display: block; margin: .5em 0;">
+ <strong><?php esc_html_e( 'Caution:', 'jetpack' ); ?></strong>
+ <?php echo sprintf(
+ __( 'For GDPR compliance, please make sure your policy contains <a href="%s" target="_blank">privacy information relating to Jetpack Ads</a>.', 'jetpack' ),
+ esc_url( 'https://jetpack.com/support/ads/#privacy' )
+ ); ?>
+ </span>
+ </span>
+ <?php endif; ?>
+ </li>
+ </ul>
+</p>
+
+<p>
+ <strong>
+ <?php esc_html_e( 'Link text', 'jetpack' ); ?>
+ </strong>
+ <label>
+ <input
+ class="widefat"
+ name="<?php echo $this->get_field_name( 'policy-link-text' ); ?>"
+ type="text"
+ value="<?php echo esc_attr( $instance['policy-link-text'] ); ?>"
+ />
+ </label>
+</p>
+
+<hr />
+
+<p>
+ <strong>
+ <?php esc_html_e( 'Button text', 'jetpack' ); ?>
+ </strong>
+ <label>
+ <input
+ class="widefat"
+ name="<?php echo $this->get_field_name( 'button' ); ?>"
+ type="text"
+ value="<?php echo esc_attr( $instance['button'] ); ?>"
+ />
+ </label>
+</p>
+
+<hr />
+
+<p>
+ <strong>
+ <?php _ex( 'Capture consent & hide the banner', 'action', 'jetpack' ); ?>
</strong>
<ul>
<li>
@@ -10,6 +134,7 @@
name="<?php echo esc_attr( $this->get_field_name( 'hide' ) ); ?>"
type="radio"
value="button"
+ <?php echo Jetpack::is_module_active( 'wordads' ) ? 'disabled' : ''; ?>
/>
<?php esc_html_e( 'after the user clicks the dismiss button', 'jetpack' ); ?>
</label>
@@ -21,6 +146,7 @@
name="<?php echo esc_attr( $this->get_field_name( 'hide' ) ); ?>"
type="radio"
value="scroll"
+ <?php echo Jetpack::is_module_active( 'wordads' ) ? 'disabled' : ''; ?>
/>
<?php esc_html_e( 'after the user scrolls the page', 'jetpack' ); ?>
</label>
@@ -32,6 +158,7 @@
name="<?php echo esc_attr( $this->get_field_name( 'hide' ) ); ?>"
type="radio"
value="time"
+ <?php echo Jetpack::is_module_active( 'wordads' ) ? 'disabled' : ''; ?>
/>
<?php esc_html_e( 'after this amount of time', 'jetpack' ); ?>
</label>
@@ -46,43 +173,34 @@
<?php esc_html_e( 'seconds', 'jetpack' ); ?>
</li>
</ul>
+ <?php if ( Jetpack::is_module_active( 'wordads' ) ) : ?>
+ <span class="notice notice-warning" style="display: block;">
+ <span style="display: block; margin: .5em 0;">
+ <?php esc_html_e( 'Visitors must provide consent by clicking the dismiss button when Jetpack Ads is turned on.', 'jetpack' ); ?>
+ </span>
+ </span>
+ <?php endif; ?>
</p>
<hr />
<p>
<strong>
- <?php esc_html_e( 'Banner text', 'jetpack' ); ?>
+ <?php _ex( 'Consent expires after', 'action', 'jetpack' ); ?>
</strong>
<ul>
<li>
- <label>
- <input
- <?php checked( $instance['text'], 'default' ); ?>
- name="<?php echo esc_attr( $this->get_field_name( 'text' ) ); ?>"
- type="radio"
- value="default"
- />
- <?php esc_html_e( 'Default', 'jetpack' ); ?>
- </label>
- </li>
- <li>
- <label>
- <input
- <?php checked( $instance['text'], 'custom' ); ?>
- name="<?php echo esc_attr( $this->get_field_name( 'text' ) ); ?>"
- type="radio"
- value="custom"
- />
- <?php esc_html_e( 'Custom:', 'jetpack' ); ?>
- </label>
+ <input
+ max="365"
+ min="1"
+ name="<?php echo esc_attr( $this->get_field_name( 'consent-expiration' ) ); ?>"
+ style="padding: 3px 5px; width: 3.75em;"
+ type="number"
+ value="<?php echo esc_attr( $instance['consent-expiration'] ); ?>"
+ />
+ <?php esc_html_e( 'days', 'jetpack' ); ?>
</li>
</ul>
- <textarea
- class="widefat"
- name="<?php echo esc_attr( $this->get_field_name( 'customtext' ) ); ?>"
- placeholder="<?php echo esc_attr( $instance['default-text'] ); ?>"
- ><?php echo esc_html( $instance['customtext'] ); ?></textarea>
</p>
<hr />
@@ -121,72 +239,36 @@
<p>
<strong>
- <?php esc_html_e( 'Policy URL', 'jetpack' ); ?>
+ <?php _e( 'Position', 'jetpack' ); ?>
</strong>
<ul>
<li>
<label>
<input
- <?php checked( $instance['policy-url'], 'default' ); ?>
- name="<?php echo esc_attr( $this->get_field_name( 'policy-url' ) ); ?>"
+ <?php checked( $instance['position'], 'bottom' ); ?>
+ name="<?php echo esc_attr( $this->get_field_name( 'position' ) ); ?>"
type="radio"
- value="default"
+ value="bottom"
/>
- <?php esc_html_e( 'Default', 'jetpack' ); ?>
+ <?php esc_html_e( 'Bottom', 'jetpack' ); ?>
</label>
</li>
<li>
<label>
<input
- <?php checked( $instance['policy-url'], 'custom' ); ?>
- name="<?php echo esc_attr( $this->get_field_name( 'policy-url' ) ); ?>"
+ <?php checked( $instance['position'], 'top' ); ?>
+ name="<?php echo esc_attr( $this->get_field_name( 'position' ) ); ?>"
type="radio"
- value="custom"
+ value="top"
/>
- <?php esc_html_e( 'Custom:', 'jetpack' ); ?>
+ <?php esc_html_e( 'Top', 'jetpack' ); ?>
</label>
- <input
- class="widefat"
- name="<?php echo esc_attr( $this->get_field_name( 'custom-policy-url' ) ); ?>"
- placeholder="<?php echo esc_url( $instance['default-policy-url'] ); ?>"
- style="margin-top: .5em;"
- type="text"
- value="<?php echo esc_url( $instance['custom-policy-url'] ); ?>"
- />
</li>
</ul>
</p>
-<p>
- <strong>
- <?php esc_html_e( 'Policy link text', 'jetpack' ); ?>
- </strong>
- <label>
- <input
- class="widefat"
- name="<?php echo $this->get_field_name( 'policy-link-text' ); ?>"
- type="text"
- value="<?php echo esc_attr( $instance['policy-link-text'] ); ?>"
- />
- </label>
-</p>
-
<hr />
-<p>
- <strong>
- <?php esc_html_e( 'Button text', 'jetpack' ); ?>
- </strong>
- <label>
- <input
- class="widefat"
- name="<?php echo $this->get_field_name( 'button' ); ?>"
- type="text"
- value="<?php echo esc_attr( $instance['button'] ); ?>"
- />
- </label>
-</p>
-
<p class="small">
<?php esc_html_e( 'It is your own responsibility to ensure that your site complies with the relevant laws.', 'jetpack' ); ?>
<a href="https://jetpack.com/support/extra-sidebar-widgets/eu-cookie-law-widget/">
diff --git a/plugins/jetpack/modules/widgets/eu-cookie-law/style.css b/plugins/jetpack/modules/widgets/eu-cookie-law/style.css
index b97f306d..c1e2520f 100644
--- a/plugins/jetpack/modules/widgets/eu-cookie-law/style.css
+++ b/plugins/jetpack/modules/widgets/eu-cookie-law/style.css
@@ -1,4 +1,4 @@
-.widget_eu_cookie_law_widget.widget {
+.widget_eu_cookie_law_widget {
border: none;
bottom: 1em;
display: none;
@@ -11,6 +11,15 @@
z-index: 50001;
}
+.widget_eu_cookie_law_widget.widget.top {
+ bottom: auto;
+ top: 1em;
+}
+
+.admin-bar .widget_eu_cookie_law_widget.widget.top {
+ top: 3em;
+}
+
#eu-cookie-law {
background-color: #fff;
border: 1px solid #dedede;
@@ -42,6 +51,14 @@
}
/**
+ * Using a highly-specific rule to make sure that certain form styles
+ * will be reset
+ */
+#eu-cookie-law form {
+ margin-bottom: 0;
+}
+
+/**
* Using a highly-specific rule to make sure that all button styles
* will be reset
*/
diff --git a/plugins/jetpack/modules/widgets/eu-cookie-law/widget.php b/plugins/jetpack/modules/widgets/eu-cookie-law/widget.php
index c45edfee..cd016a3e 100644
--- a/plugins/jetpack/modules/widgets/eu-cookie-law/widget.php
+++ b/plugins/jetpack/modules/widgets/eu-cookie-law/widget.php
@@ -1,7 +1,7 @@
<div
- class="<?php echo 'negative' === $instance['color-scheme'] ? 'negative ' : '';
- ?>hide-on-<?php echo esc_attr( $instance['hide'] ); ?>"
+ class="<?php echo implode( ' ', $classes ); ?>"
data-hide-timeout="<?php echo intval( $instance['hide-timeout'] ); ?>"
+ data-consent-expiration="<?php echo intval( $instance['consent-expiration'] ); ?>"
id="eu-cookie-law"
>
<form method="post">
@@ -9,13 +9,9 @@
</form>
<?php if ( 'default' == $instance['text'] || empty( $instance['customtext'] ) ) {
- echo $instance['default-text'];
- ?>
- <br />
- <?php
- esc_html_e( 'To find out more, as well as how to remove or block these, see here:', 'jetpack' );
+ echo nl2br( $instance['default-text'] );
} else {
- echo esc_html( $instance['customtext'] );
+ echo nl2br( esc_html( $instance['customtext'] ) );
} ?>
<a href="<?php