PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.7
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.7
16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 All 506 releases
← All changes | modules/widgets/class-jetpack-eu-cookie-law-widget.php +20 -12 13.6.2 → 16.3-a.7 View file →
@@ -10,9 +10,9 @@
10 10 /**
11 11 * Disable direct access/execution to/of the widget code.
12 12 */
13 13 if ( ! defined( 'ABSPATH' ) ) {
14 - exit;
14 + exit( 0 );
15 15 }
16 16
17 17 if ( ! class_exists( 'Jetpack_EU_Cookie_Law_Widget' ) ) {
18 18 /**
@@ -92,12 +92,8 @@
92 92 'customize_selective_refresh' => true,
93 93 ),
94 94 array()
95 95 );
96 -
97 - if ( is_active_widget( false, false, $this->id_base ) || is_customize_preview() ) {
98 - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_frontend_scripts' ) );
99 - }
100 96 }
101 97
102 98 /**
103 99 * Enqueue scripts and styles.
@@ -139,9 +135,14 @@
139 135 'custom-policy-url' => get_option( 'wp_page_for_privacy_policy' ) ? get_permalink( (int) get_option( 'wp_page_for_privacy_policy' ) ) : '',
140 136 'position' => $this->position_options[0],
141 137 'policy-link-text' => esc_html__( 'Cookie Policy', 'jetpack' ),
142 138 'button' => esc_html__( 'Close and accept', 'jetpack' ),
143 - 'default-text' => esc_html__( "Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use. \r\nTo find out more, including how to control cookies, see here:", 'jetpack' ),
139 + 'default-text' => esc_html__(
140 + 'Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
141 +
142 +To find out more, including how to control cookies, see here:',
143 + 'jetpack'
144 + ),
144 145 );
145 146 }
146 147
147 148 /**
@@ -164,8 +165,11 @@
164 165 if ( apply_filters( 'jetpack_disable_eu_cookie_law_widget', false ) ) {
165 166 return;
166 167 }
167 168
169 + // Enqueue front end assets.
170 + $this->enqueue_frontend_scripts();
171 +
168 172 $instance = wp_parse_args( $instance, $this->defaults() );
169 173
170 174 if ( class_exists( 'Jetpack_AMP_Support' ) && Jetpack_AMP_Support::is_amp_request() ) {
171 175 require __DIR__ . '/eu-cookie-law/widget-amp.php';
@@ -217,8 +221,9 @@
217 221 *
218 222 * @html-template-var array $instance
219 223 *
220 224 * @param array $instance Previously saved values from database.
225 + * @return string|void
221 226 */
222 227 public function form( $instance ) {
223 228 $instance = wp_parse_args( $instance, $this->defaults() );
224 229 if ( Jetpack::is_module_active( 'wordads' ) ) {
@@ -249,13 +254,13 @@
249 254 public function update( $new_instance, $old_instance ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
250 255 $instance = array();
251 256 $defaults = $this->defaults();
252 257
253 - $instance['hide'] = $this->filter_value( isset( $new_instance['hide'] ) ? $new_instance['hide'] : '', $this->hide_options );
254 - $instance['text'] = $this->filter_value( isset( $new_instance['text'] ) ? $new_instance['text'] : '', $this->text_options );
255 - $instance['color-scheme'] = $this->filter_value( isset( $new_instance['color-scheme'] ) ? $new_instance['color-scheme'] : '', $this->color_scheme_options );
256 - $instance['policy-url'] = $this->filter_value( isset( $new_instance['policy-url'] ) ? $new_instance['policy-url'] : '', $this->policy_url_options );
257 - $instance['position'] = $this->filter_value( isset( $new_instance['position'] ) ? $new_instance['position'] : '', $this->position_options );
258 + $instance['hide'] = $this->filter_value( $new_instance['hide'] ?? '', $this->hide_options );
259 + $instance['text'] = $this->filter_value( $new_instance['text'] ?? '', $this->text_options );
260 + $instance['color-scheme'] = $this->filter_value( $new_instance['color-scheme'] ?? '', $this->color_scheme_options );
261 + $instance['policy-url'] = $this->filter_value( $new_instance['policy-url'] ?? '', $this->policy_url_options );
262 + $instance['position'] = $this->filter_value( $new_instance['position'] ?? '', $this->position_options );
258 263
259 264 if ( isset( $new_instance['hide-timeout'] ) ) {
260 265 // Time can be a value between 3 and 1000 seconds.
261 266 $instance['hide-timeout'] = min( 1000, max( 3, (int) $new_instance['hide-timeout'] ) );
@@ -308,9 +313,12 @@
308 313 unset( $instance['button'] );
309 314 }
310 315
311 316 // Show the banner again if a setting has been changed.
312 - setcookie( self::$cookie_name, '', time() - 86400, '/', COOKIE_DOMAIN, is_ssl(), false ); // phpcs:ignore Jetpack.Functions.SetCookie -- Fine to have accessible.
317 + // Sometimes plugins send headers already, so we can't set a cookie and any attempt will throw a warning.
318 + if ( ! headers_sent() ) {
319 + setcookie( self::$cookie_name, '', time() - 86400, '/', COOKIE_DOMAIN, is_ssl(), false ); // phpcs:ignore Jetpack.Functions.SetCookie -- Fine to have accessible.
320 + }
313 321
314 322 return $instance;
315 323 }
316 324