Skip to content

Commit

Permalink
Merge pull request #7658 from Automattic/fix/passing-array-to-strncmp
Browse files Browse the repository at this point in the history
Fix lesson loading error issue in learning mode for themes that are using referenced styles
  • Loading branch information
Imran92 authored Aug 7, 2024
2 parents 763b07b + 7b89ba1 commit 15275e8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 4 additions & 0 deletions changelog/fix-passing-array-to-strncmp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Prevent lesson loading error in learning mode for themes that are using referenced styles
10 changes: 4 additions & 6 deletions includes/course-theme/class-sensei-course-theme-styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public static function apply_block_support( $block_content, $block ) {

$style = esc_attr( implode( ' ', $colors ) );
return self::set_style_attribute( $block_content, $style );

}

/**
Expand Down Expand Up @@ -78,11 +77,9 @@ public static function output_global_styles_colors() {
* @return array Name-value pairs of CSS variables
*/
private static function get_colors_as_css_variables( $styles ) {

if ( empty( $styles ) ) {
return [];
}

}

/**
Expand Down Expand Up @@ -139,7 +136,6 @@ private static function get_block_colors( $attributes ) {
$colors = self::get_colors( $styles );

return self::format_css_variables( $colors );

}

/**
Expand All @@ -155,7 +151,10 @@ private static function format_css_variables( $variables, $postfix = '' ) {
if ( $postfix ) {
$variable = $variable . $postfix;
}
if ( $value ) {
if (
$value &&
is_string( $value )
) {
$css[] = sprintf( '%s: %s;', $variable, self::get_property_value( $value ) );
}
}
Expand Down Expand Up @@ -190,7 +189,6 @@ private static function output_style( $css ) {
* @return string Style property value.
*/
private static function get_property_value( $value ) {

$prefix = 'var:';
$prefix_len = strlen( $prefix );
$token_in = '|';
Expand Down

0 comments on commit 15275e8

Please sign in to comment.