', esc_attr( $this->get_classes( $attributes ) ), esc_attr( $this->get_styles( $attributes, $category ) ) );
+ $styles = $this->get_styles( $attributes, $category );
+ $classes = $this->get_classes( $attributes );
+
+ $output = sprintf( '
', esc_attr( trim( $classes ) ), esc_attr( $styles ) );
$output .= '
';
$output .= $title;
if ( $attributes['showDesc'] ) {
@@ -103,12 +134,16 @@ public function get_styles( $attributes, $category ) {
if ( is_array( $attributes['focalPoint'] ) && 2 === count( $attributes['focalPoint'] ) ) {
$style .= sprintf(
- 'background-position: %s%% %s%%',
+ 'background-position: %s%% %s%%;',
$attributes['focalPoint']['x'] * 100,
$attributes['focalPoint']['y'] * 100
);
}
+ $global_style_style = StyleAttributesUtils::get_styles_by_attributes( $attributes, $this->global_style_wrapper );
+
+ $style .= $global_style_style;
+
return $style;
}
@@ -137,14 +172,14 @@ public function get_classes( $attributes ) {
$classes[] = "has-{$attributes['contentAlign']}-content";
}
- if ( isset( $attributes['overlayColor'] ) ) {
- $classes[] = "has-{$attributes['overlayColor']}-background-color";
- }
-
if ( isset( $attributes['className'] ) ) {
$classes[] = $attributes['className'];
}
+ $global_style_classes = StyleAttributesUtils::get_classes_by_attributes( $attributes, $this->global_style_wrapper );
+
+ $classes[] = $global_style_classes;
+
return implode( ' ', $classes );
}
@@ -165,7 +200,6 @@ public function get_image( $category, $size = 'full' ) {
return $image;
}
-
/**
* Extra data passed through from server to client for block.
*
diff --git a/src/Utils/StyleAttributesUtils.php b/src/Utils/StyleAttributesUtils.php
index 08ba95f0e6c..858e548001a 100644
--- a/src/Utils/StyleAttributesUtils.php
+++ b/src/Utils/StyleAttributesUtils.php
@@ -154,6 +154,79 @@ public static function get_background_color_class_and_style( $attributes ) {
return null;
}
+ /**
+ * Get class and style for border-color from attributes.
+ *
+ * @param array $attributes Block attributes.
+ *
+ * @return (array | null)
+ */
+ public static function get_border_color_class_and_style( $attributes ) {
+
+ $border_color = $attributes['borderColor'] ?? '';
+
+ $custom_border_color = $attributes['style']['border']['color'] ?? '';
+
+ if ( ! $border_color && '' === $custom_border_color ) {
+ return null;
+ };
+
+ if ( $border_color ) {
+ return array(
+ 'class' => sprintf( 'has-border-color has-%s-border-color', $border_color ),
+ 'style' => null,
+ );
+ } elseif ( '' !== $custom_border_color ) {
+ return array(
+ 'class' => null,
+ 'style' => sprintf( 'border-color: %s;', $custom_border_color ),
+ );
+ }
+ return null;
+ }
+
+ /**
+ * Get class and style for border-radius from attributes.
+ *
+ * @param array $attributes Block attributes.
+ *
+ * @return (array | null)
+ */
+ public static function get_border_radius_class_and_style( $attributes ) {
+
+ $custom_border_radius = $attributes['style']['border']['radius'] ?? '';
+
+ if ( '' === $custom_border_radius ) {
+ return null;
+ };
+
+ return array(
+ 'class' => null,
+ 'style' => sprintf( 'border-radius: %s;', $custom_border_radius ),
+ );
+ }
+
+ /**
+ * Get class and style for border width from attributes.
+ *
+ * @param array $attributes Block attributes.
+ *
+ * @return (array | null)
+ */
+ public static function get_border_width_class_and_style( $attributes ) {
+
+ $custom_border_width = $attributes['style']['border']['width'] ?? '';
+
+ if ( '' === $custom_border_width ) {
+ return null;
+ };
+
+ return array(
+ 'class' => null,
+ 'style' => sprintf( 'border-width: %s;', $custom_border_width ),
+ );
+ }
+
/**
* Get class and style for align from attributes.
*
@@ -222,6 +295,9 @@ public static function get_classes_and_styles_by_attributes( $attributes, $prope
'font_size' => self::get_font_size_class_and_style( $attributes ),
'link_color' => self::get_link_color_class_and_style( $attributes ),
'background_color' => self::get_background_color_class_and_style( $attributes ),
+ 'border_color' => self::get_border_color_class_and_style( $attributes ),
+ 'border_radius' => self::get_border_radius_class_and_style( $attributes ),
+ 'border_width' => self::get_border_width_class_and_style( $attributes ),
);
if ( ! empty( $properties ) ) {