PHP Warning: Array to string conversion (with fix)
-
Error:
[29-Apr-2024 18:48:08 UTC] PHP Warning: Array to string conversion in /mywebsite.com/wp-content/plugins/wp-job-manager/includes/ui/class-ui-elements.php on line 99
Line 99 is:'class' => join( ' ', [ $class, $args['class'] ] ),
Full function:/** * Generate HTML for a button or action link. * * @param array $args Button options. * @param string $class Base classname. * * @return string Button HTML. */ public static function button( $args, $class ) { if ( empty( $args ) ) { return ''; } $args = wp_parse_args( $args, [ 'label' => '', 'url' => '', 'onclick' => '', 'class' => '', ] ); if ( empty( $args['url'] ) ) { $args['url'] = '#'; } $attrs = [ 'class' => join( ' ', [ $class, $args['class'] ] ), 'href' => esc_url( $args['url'] ), ]; if ( ! empty( $args['onclick'] ) ) { $attrs['onclick'] = $args['onclick']; $attrs['role'] = 'button'; } return '<a ' . self::html_attrs( $attrs ) . '><span>' . esc_html( $args['label'] ) . '</span></a>'; }
Suggested fix for line 99:
'class' => join(' ', array_filter(array_merge((array)$class, (array)$args['class']))),
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘PHP Warning: Array to string conversion (with fix)’ is closed to new replies.