How to fix “warning illegal string”?

At the very start of your function, you are checking if these values exist:

$position = isset($atts['position']) ? $atts['position'] : '';
$name = isset($atts['name']) ? $atts['name'] : '';
$company = isset($atts['company']) ? $atts['company'] : '';

So instead of using $atts[...] later on in your code, you should use the variables you have just set.

Also note that you can get rid of the ternary expressions later on if you set the values correctly right away:

$name = isset($atts['name']) ? $atts['name'] : '';
$position = isset($atts['position']) ? (', ' . $atts['position']) : '';
$company = isset($atts['company']) ? (' - ' . $atts['company']) : '';

...

$output .= '<div class="name">'.$name.$position.company.'</div>';

Leave a Comment