Skip to content

PHP Warning: Array to string conversion in class-kadence-blocks-css.php:1980 (render_border_styles) #980

Description

@alt126je

Summary

render_border_styles() in includes/class-kadence-blocks-css.php emits repeated PHP Warning: Array to string conversion on line 1980 when concatenating $width . ' ' . $style . ' ' . $color for the CSS border shorthand. One (or more) of those three values is sometimes an array instead of a string.

The output HTML/CSS still renders correctly, but the warning floods error_log on every front-end render of pages containing certain Kadence blocks with border attributes.

Environment

  • Plugin version: 3.6.7 (latest stable on WP.org as of 2026-05-09)
  • WordPress: 6.x (latest)
  • PHP: 8.x
  • Theme: Kadence
  • Other relevant plugins: Yoast SEO Premium, Google Site Kit, WPConsent, WPCode

Affected file & line

wp-content/plugins/kadence-blocks/includes/class-kadence-blocks-css.php:1980

Function: public function render_border_styles( $attributes, $name = 'borderStyle', $single_styles = false, $args = array() ) — starts at line 1939.

The offending statement (line 1980):

$this->add_property( $property_prefix . $args[ $prop_key ], $width . ' ' . $style . ' ' . $color );

$width, $style, and $color are computed by an internal helper a few lines above inside the nested foreach ( $sizes as $size ) / foreach ( $args['sides'] as $side => $prop_key ) loop. Under certain attribute shapes the helper returns an array instead of a scalar string.

Steps to reproduce

  1. Create or open a page containing one of the following Kadence blocks with border-related attributes set in the editor:
    • kadence/column (with borderStyle, borderWidth, mobileBorderStyle, tabletBorderStyle, borderRadius)
    • kadence/advancedheading (with markBorderStyles, mobileMarkBorderStyles, tabletMarkBorderStyles, mobileBorderRadius)
    • kadence/rowlayout (with borderStyle, borderRadius)
    • kadence/singlebtn (with borderHoverStyle, borderHoverRadius, borderRadius)
    • kadence/accordion (with titleBorder, titleBorderHover, titleBorderActive, contentBorderStyle, titleBorderRadius)
    • kadence/testimonials (with mediaBorderStyle, mediaBorderRadius)
  2. Enable WP_DEBUG_LOG and visit the page on the front end.
  3. Observe many Array to string conversion warnings written to wp-content/debug.log, all pointing to class-kadence-blocks-css.php:1980.

Evidence from a real site

I scanned all posts and pages on a production site (49 entries total) via REST API. Three pages dispatch a combined 143 border-related attributes whose value is an array:

Block Attribute Occurrences
column borderWidth 31
advancedheading markBorderStyles 20
advancedheading mobileMarkBorderStyles 20
advancedheading tabletMarkBorderStyles 20
column borderStyle 17
column mobileBorderStyle 8
advancedheading mobileBorderRadius 6
column borderRadius 4
rowlayout borderStyle 2
singlebtn borderHoverRadius 2
singlebtn borderHoverStyle 2
singlebtn borderRadius 2
column tabletBorderStyle 1
rowlayout borderRadius 1
accordion titleBorder 1
accordion titleBorderHover 1
accordion titleBorderActive 1
accordion titleBorderRadius 1
accordion contentBorderStyle 1
testimonials mediaBorderStyle 1
testimonials mediaBorderRadius 1

These attributes are stored as arrays — which appears to be the modern Kadence schema for responsive/per-side border values — so the content is well-formed; the bug is in how render_border_styles() (or the helper that resolves $width/$style/$color) handles them when one slot legitimately stays as an array.

Expected behavior

$width, $style, and $color should always be cast to scalar strings (or guarded with is_array() and reduced via implode(' ', …) / array index lookup) before the concatenation on line 1980. No Array to string conversion warning should be emitted.

Actual behavior

Warning is logged on every front-end render of pages with the affected blocks. The visual output is still correct, but the log fills with thousands of lines per day on busy sites.

Suggested fix

Inside render_border_styles(), after the helper resolves $width/$style/$color, normalize them to strings before the concatenation, e.g.:

$width = is_array( $width ) ? implode( ' ', array_filter( $width, 'is_scalar' ) ) : (string) $width;
$style = is_array( $style ) ? (string) ( $style[0] ?? '' )                          : (string) $style;
$color = is_array( $color ) ? (string) ( $color[0] ?? '' )                          : (string) $color;

Or, more cleanly, fix the helper that produces these values so it always returns a scalar string for this use site.

Workaround

Until a fix lands, the warning can be suppressed selectively (only this exact signature, in this exact file) without touching plugin code, via a small mu-plugin / WPCode snippet that registers a narrow set_error_handler. All other PHP warnings keep flowing to the log normally.

Thanks for the great plugin — happy to test a patch if you push one to a branch.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions