Skip to content

Commit 2648f9b

Browse files
release: fixes
- Fixed saving of dynamic post content values - Fixed slow animation speed - Fixed a PHP undefined array key warning - Fixed accordion icon on large titles - Fixed over-sanitization of atomic-wind experimental blocks query - Improved theme color output by using CSS variables instead of hex codes - Enhanced security
2 parents 2c9c1ab + 3eb1649 commit 2648f9b

43 files changed

Lines changed: 869 additions & 262 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
},
7373
"minimum-stability": "dev",
7474
"require": {
75-
"codeinwp/themeisle-sdk": "^3.2",
75+
"codeinwp/themeisle-sdk": "^3.3",
7676
"masterminds/html5": "^2.7",
7777
"tubalmartin/cssmin": "^4.1",
7878
"wptt/webfont-loader": "^1.1",

composer.lock

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

inc/class-base-css.php

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,11 @@ public function get_google_fonts( $attr ) {
150150
'fontfamily' => $attr['fontFamily'],
151151
'fontvariant' => ( isset( $attr['fontVariant'] ) && ! empty( $attr['fontVariant'] ) ? array( $attr['fontVariant'] ) : array() ),
152152
);
153-
} elseif ( ! in_array( $attr['fontVariant'], self::$google_fonts[ $attr['fontFamily'] ]['fontvariant'], true ) ) {
154-
array_push( self::$google_fonts[ $attr['fontFamily'] ]['fontvariant'], ( isset( $attr['fontStyle'] ) && 'italic' === $attr['fontStyle'] ) ? $attr['fontVariant'] . ':i' : $attr['fontVariant'] );
153+
} elseif ( isset( $attr['fontVariant'] ) && ! empty( $attr['fontVariant'] ) ) {
154+
$font_variant = $attr['fontVariant'];
155+
if ( ! in_array( $font_variant, self::$google_fonts[ $attr['fontFamily'] ]['fontvariant'], true ) ) {
156+
self::$google_fonts[ $attr['fontFamily'] ]['fontvariant'][] = $font_variant;
157+
}
155158
}
156159
}
157160
}
@@ -199,6 +202,54 @@ public static function hex2rgba( $color, $opacity = false ) {
199202
return $output;
200203
}
201204

205+
/**
206+
* Convert a color slug to a CSS variable reference.
207+
* WordPress generates CSS variables in the format: --wp--preset--color--{slug}
208+
*
209+
* @param string|null $slug The color slug.
210+
* @return string|null The CSS variable reference.
211+
* @since 3.1.5
212+
* @access public
213+
*/
214+
public static function get_color_css_variable( $slug ) {
215+
if ( empty( $slug ) ) {
216+
return $slug;
217+
}
218+
219+
// If it's already a color value or CSS variable, return as-is.
220+
if (
221+
strpos( $slug, '#' ) === 0 ||
222+
strpos( $slug, 'rgb' ) === 0 ||
223+
strpos( $slug, 'hsl' ) === 0 ||
224+
strpos( $slug, 'var(' ) === 0
225+
) {
226+
return $slug;
227+
}
228+
229+
// Sanitize slug: WordPress slugs should only contain lowercase alphanumeric, hyphens, and underscores.
230+
// This prevents potential CSS injection if slug comes from untrusted sources.
231+
$sanitized_slug = strtolower( preg_replace( '/[^a-z0-9-_]/', '', $slug ) );
232+
233+
// Convert slug to CSS variable.
234+
return 'var(--wp--preset--color--' . $sanitized_slug . ')';
235+
}
236+
237+
/**
238+
* Resolve a color value which may be a slug from the theme color palette.
239+
* This function converts slugs to CSS variables to preserve the connection to theme.json.
240+
* If the value is a slug, it returns a CSS variable reference.
241+
* Otherwise, returns the value as-is (for hex, rgb, hsl values).
242+
*
243+
* @param string|null $value The color value or slug.
244+
* @return string|null The CSS variable or color value.
245+
* @since 3.1.5
246+
* @access public
247+
*/
248+
public static function resolve_color_value( $value ) {
249+
// Use CSS variable conversion for slugs.
250+
return self::get_color_css_variable( $value );
251+
}
252+
202253
/**
203254
* Get Blocks CSS
204255
*

inc/class-main.php

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -599,30 +599,52 @@ public function about_page() {
599599
public function add_black_friday_data( $configs ) {
600600
$config = $configs['default'];
601601

602-
// translators: %1$s - HTML tag, %2$s - discount, %3$s - HTML tag, %4$s - product name.
603-
$message_template = __( 'Our biggest sale of the year: %1$sup to %2$s OFF%3$s on %4$s. Don\'t miss this limited-time offer.', 'otter-blocks' );
604-
$product_label = 'Otter Blocks';
605-
$discount = '70%';
602+
$message = __( 'Advanced blocks, custom CSS, WooCommerce integration. Everything you need to build better pages, without code. Exclusively for existing Otter users.', 'otter-blocks' );
603+
$cta_label = __( 'Get Otter Pro', 'otter-blocks' );
606604

607605
$plan = apply_filters( 'product_otter_license_plan', 0 );
608606
$license = apply_filters( 'product_otter_license_key', false );
609-
$is_pro = 0 < $plan;
607+
$status = apply_filters( 'product_otter_license_status', false );
608+
609+
$is_pro = 'valid' === $status;
610+
$is_expired = 'expired' === $status || 'active-expired' === $status;
611+
$pro_product_slug = defined( 'OTTER_PRO_BASEFILE' ) ? basename( dirname( OTTER_PRO_BASEFILE ) ) : '';
610612

611613
if ( $is_pro ) {
612-
// translators: %1$s - HTML tag, %2$s - discount, %3$s - HTML tag, %4$s - product name.
613-
$message_template = __( 'Get %1$sup to %2$s off%3$s when you upgrade your %4$s plan or renew early.', 'otter-blocks' );
614-
$product_label = 'Otter Pro';
615-
$discount = '30%';
616-
}
617-
618-
$product_label = sprintf( '<strong>%s</strong>', $product_label );
619-
$url_params = array(
614+
// translators: %s is the discount percentage.
615+
$config['plugin_meta_message'] = sprintf( __( 'Black Friday Sale - up to %s off', 'otter-blocks' ), '30%' );
616+
// translators: %1$s - discount, %2$s - discount.
617+
$message = sprintf( __( 'Upgrade your Otter Pro plan: %1$s off this week. Already on the plan you need? Renew early and save up to %2$s.', 'otter-blocks' ), '30%', '20%' );
618+
$cta_label = __( 'See your options', 'otter-blocks' );
619+
} elseif ( $is_expired ) {
620+
// translators: %s is the discount percentage.
621+
$config['plugin_meta_message'] = sprintf( __( 'Black Friday Sale - %s off', 'otter-blocks' ), '50%' );
622+
// translators: %s is the discount percentage.
623+
$config['upgrade_menu_text'] = sprintf( __( 'BF Sale - %s off', 'otter-blocks' ), '50%' );
624+
$message = __( 'Your Otter Pro features are still here, just locked. Renew at a reduced rate this week.', 'otter-blocks' );
625+
$cta_label = __( 'Reactivate now', 'otter-blocks' );
626+
} else {
627+
// translators: %s is the discount percentage.
628+
$config['plugin_meta_message'] = sprintf( __( 'Black Friday Sale - %s off', 'otter-blocks' ), '60%' );
629+
// translators: %s is the discount percentage.
630+
$config['upgrade_menu_text'] = sprintf( __( 'BF Sale - %s off', 'otter-blocks' ), '60%' );
631+
// translators: %s - discount.
632+
$config['title'] = sprintf( __( 'Otter Pro: %s off this week', 'otter-blocks' ), '60%' );
633+
}
634+
635+
$url_params = array(
620636
'utm_term' => $is_pro ? 'plan-' . $plan : 'free',
621637
'lkey' => ! empty( $license ) ? $license : false,
638+
'expired' => $is_expired ? '1' : false,
622639
);
623-
624-
$config['message'] = sprintf( $message_template, '<strong>', $discount, '</strong>', $product_label );
625-
$config['sale_url'] = add_query_arg(
640+
641+
if ( ( $is_pro || $is_expired ) && ! empty( $pro_product_slug ) ) {
642+
$config['plugin_meta_targets'] = array( $pro_product_slug );
643+
}
644+
645+
$config['cta_label'] = $cta_label;
646+
$config['message'] = $message;
647+
$config['sale_url'] = add_query_arg(
626648
$url_params,
627649
tsdk_translate_link( tsdk_utmify( 'https://themeisle.link/otter-bf', 'bfcm', 'otter' ) )
628650
);

inc/css/blocks/class-advanced-column-css.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@ function ( $value ) use ( $block ) {
188188
array(
189189
'property' => '--background-color-hover',
190190
'value' => 'backgroundColorHover',
191+
'format' => function ( $value ) {
192+
return Base_CSS::resolve_color_value( $value );
193+
},
191194
),
192195
array(
193196
'property' => 'align-self',

inc/css/blocks/class-advanced-heading-css.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,16 @@ public function render_css( $block ) {
4444
array(
4545
'property' => 'color',
4646
'value' => 'headingColor',
47+
'format' => function ( $value, $attrs ) {
48+
return Base_CSS::resolve_color_value( $value );
49+
},
4750
),
4851
array(
4952
'property' => 'background',
5053
'value' => 'backgroundColor',
54+
'format' => function ( $value, $attrs ) {
55+
return Base_CSS::resolve_color_value( $value );
56+
},
5157
),
5258
array(
5359
'property' => 'font-family',
@@ -225,10 +231,16 @@ public function render_css( $block ) {
225231
array(
226232
'property' => 'color',
227233
'value' => 'highlightColor',
234+
'format' => function ( $value, $attrs ) {
235+
return Base_CSS::resolve_color_value( $value );
236+
},
228237
),
229238
array(
230239
'property' => 'background',
231240
'value' => 'highlightBackground',
241+
'format' => function ( $value, $attrs ) {
242+
return Base_CSS::resolve_color_value( $value );
243+
},
232244
),
233245
);
234246

@@ -537,6 +549,9 @@ public function render_css( $block ) {
537549
array(
538550
'property' => 'color',
539551
'value' => 'linkColor',
552+
'format' => function ( $value, $attrs ) {
553+
return Base_CSS::resolve_color_value( $value );
554+
},
540555
),
541556
),
542557
)
@@ -549,6 +564,9 @@ public function render_css( $block ) {
549564
array(
550565
'property' => 'color',
551566
'value' => 'linkHoverColor',
567+
'format' => function ( $value, $attrs ) {
568+
return Base_CSS::resolve_color_value( $value );
569+
},
552570
),
553571
),
554572
)

inc/css/blocks/class-button-css.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,17 @@ public function render_css( $block ) {
135135
'property' => 'color',
136136
'value' => 'color',
137137
'hasSync' => 'gr-btn-color',
138+
'format' => function ( $value ) {
139+
return Base_CSS::resolve_color_value( $value );
140+
},
138141
),
139142
array(
140143
'property' => 'background',
141144
'value' => 'background',
142145
'hasSync' => 'gr-btn-background',
146+
'format' => function ( $value ) {
147+
return Base_CSS::resolve_color_value( $value );
148+
},
143149
),
144150
array(
145151
'property' => 'background',
@@ -150,6 +156,9 @@ public function render_css( $block ) {
150156
'property' => 'border-color',
151157
'value' => 'border',
152158
'hasSync' => 'gr-btn-border-color',
159+
'format' => function ( $value ) {
160+
return Base_CSS::resolve_color_value( $value );
161+
},
153162
),
154163
array(
155164
'property' => 'box-shadow',
@@ -201,11 +210,17 @@ public function render_css( $block ) {
201210
'property' => 'color',
202211
'value' => 'hoverColor',
203212
'hasSync' => 'gr-btn-color-hover',
213+
'format' => function ( $value ) {
214+
return Base_CSS::resolve_color_value( $value );
215+
},
204216
),
205217
array(
206218
'property' => 'background',
207219
'value' => 'hoverBackground',
208220
'hasSync' => 'gr-btn-background-hover',
221+
'format' => function ( $value ) {
222+
return Base_CSS::resolve_color_value( $value );
223+
},
209224
),
210225
array(
211226
'property' => 'background',
@@ -216,6 +231,9 @@ public function render_css( $block ) {
216231
'property' => 'border-color',
217232
'value' => 'hoverBorder',
218233
'hasSync' => 'gr-btn-border-color-hover',
234+
'format' => function ( $value ) {
235+
return Base_CSS::resolve_color_value( $value );
236+
},
219237
),
220238
array(
221239
'property' => 'box-shadow',
@@ -298,10 +316,16 @@ public function render_global_css() {
298316
array(
299317
'property' => '--gr-btn-color',
300318
'value' => 'color',
319+
'format' => function ( $value ) {
320+
return Base_CSS::resolve_color_value( $value );
321+
},
301322
),
302323
array(
303324
'property' => '--gr-btn-background',
304325
'value' => 'background',
326+
'format' => function ( $value ) {
327+
return Base_CSS::resolve_color_value( $value );
328+
},
305329
),
306330
array(
307331
'property' => '--gr-btn-background',
@@ -336,6 +360,9 @@ public function render_global_css() {
336360
array(
337361
'property' => '--gr-btn-border-color',
338362
'value' => 'border',
363+
'format' => function ( $value ) {
364+
return Base_CSS::resolve_color_value( $value );
365+
},
339366
'condition' => function ( $attrs ) {
340367
return isset( $attrs['border'] ) && ! empty( $attrs['border'] );
341368
},
@@ -421,10 +448,16 @@ public function render_global_css() {
421448
array(
422449
'property' => '--gr-btn-color-hover',
423450
'value' => 'hoverColor',
451+
'format' => function ( $value ) {
452+
return Base_CSS::resolve_color_value( $value );
453+
},
424454
),
425455
array(
426456
'property' => '--gr-btn-background-hover',
427457
'value' => 'hoverBackground',
458+
'format' => function ( $value ) {
459+
return Base_CSS::resolve_color_value( $value );
460+
},
428461
),
429462
array(
430463
'property' => '--gr-btn-background-hover',
@@ -433,6 +466,9 @@ public function render_global_css() {
433466
array(
434467
'property' => '--gr-btn-border-color-hover',
435468
'value' => 'hoverBorder',
469+
'format' => function ( $value ) {
470+
return Base_CSS::resolve_color_value( $value );
471+
},
436472
),
437473
array(
438474
'property' => '--gr-btn-shadow-hover',

0 commit comments

Comments
 (0)