Context: On one of the sites where my WordPress plugin is installed I'm seeing a series of PHP warnings, but I'm not entirely sure why this is happening. I'm hoping someone here can help me figure out how to solve this warning.
Code Sample:
function my_function( $array ) {
if ( ! isset( $array['where'] ) ) { $array['where'] = 'after'; }
if ( ! isset( $array['echo'] ) ) { $array['echo'] = false; }
if ( ! isset( $array['content'] ) ) { $array['content'] = false; }
$array['shortcode'] = true;
$array['devs'] = true;
return social_warfare( $array );
}
add_shortcode( 'my_shortcode', 'my_function' );
The Warning:
Warning: Illegal string offset 'where' in /home/playitda/public_html/domain.com/wp-content/plugins/my_plugin/functions/frontend-output/shortcodes.php on line 14
Warning: Illegal string offset 'echo' in /home/playitda/public_html/domain.com/wp-content/plugins/my_plugin/functions/frontend-output/shortcodes.php on line 15
Warning: Cannot assign an empty string to a string offset in /home/playitda/public_html/domain.com/wp-content/plugins/my_plugin/functions/frontend-output/shortcodes.php on line 15
Warning: Illegal string offset 'content' in /home/playitda/public_html/domain.com/wp-content/plugins/my_plugin/functions/frontend-output/shortcodes.php on line 16
Warning: Cannot assign an empty string to a string offset in /home/playitda/public_html/domain.com/wp-content/plugins/my_plugin/functions/frontend-output/shortcodes.php on line 16
Warning: Illegal string offset 'shortcode' in /home/playitda/public_html/domain.com/wp-content/plugins/my_plugin/functions/frontend-output/shortcodes.php on line 18
Warning: Illegal string offset 'devs' in /home/playitda/public_html/domain.com/wp-content/plugins/my_plugin/functions/frontend-output/shortcodes.php on line 19
For some reason, it's throwing a warning every time it encounters one of the indices in the array. How do I fix this? Thanks!