PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.5
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.5
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 | extensions/blocks/cookie-consent/cookie-consent.php +34 -2 13.2.4 → 16.3-a.5 View file →
@@ -11,8 +11,12 @@
11 11
12 12 use Automattic\Jetpack\Blocks;
13 13 use Jetpack_Gutenberg;
14 14
15 +if ( ! defined( 'ABSPATH' ) ) {
16 + exit( 0 );
17 +}
18 +
15 19 const COOKIE_NAME = 'eucookielaw';
16 20
17 21 /**
18 22 * Should the block be registered?
@@ -46,11 +50,11 @@
46 50 }
47 51
48 52 Blocks::jetpack_register_block(
49 53 __DIR__,
50 - array( 'render_callback' => __NAMESPACE__ . '\load_assets' ),
51 54 array(
52 - 'attributes' => array(
55 + 'render_callback' => __NAMESPACE__ . '\load_assets',
56 + 'attributes' => array(
53 57 'render_from_template' => array(
54 58 'default' => false,
55 59 'type' => 'boolean',
56 60 ),
@@ -101,8 +105,13 @@
101 105 * Enqueue necessary scripts and styles.
102 106 */
103 107 Jetpack_Gutenberg::load_assets_as_required( __DIR__ );
104 108
109 + /*
110 + * Add a fallback color to block styles.
111 + */
112 + $content = add_css_fallback_values( $content );
113 +
105 114 return sprintf(
106 115 '<div class="%1$s">%2$s</div>',
107 116 esc_attr( Blocks::classes( Blocks::get_block_feature( __DIR__ ), $attr ) ),
108 117 $content
@@ -167,4 +176,27 @@
167 176 );
168 177 }
169 178
170 179 add_action( 'rest_api_init', __NAMESPACE__ . '\cookie_consent_register_settings' );
180 +
181 +/**
182 + * Add a fallback color to block styles.
183 + *
184 + * @since 15.1
185 + *
186 + * @param string $content The block content.
187 + * @return string The content with fallback values added to CSS custom properties.
188 + */
189 +function add_css_fallback_values( $content ) {
190 + // Define the CSS custom properties and their fallback values.
191 + $css_fallbacks = array(
192 + 'var(--wp--preset--color--contrast)' => 'var(--wp--preset--color--contrast, #000000)',
193 + 'var(--wp--preset--color--tertiary)' => 'var(--wp--preset--color--tertiary, #f0f0f0)',
194 + );
195 +
196 + // Replace CSS custom properties with their fallback versions.
197 + foreach ( $css_fallbacks as $original => $with_fallback ) {
198 + $content = str_replace( $original, $with_fallback, $content );
199 + }
200 +
201 + return $content;
202 +}