EnlighterJS / Plugin.WordPress

:package: Official WordPress Plugin of EnlighterJS
http://wordpress.org/plugins/enlighter/
GNU General Public License v2.0
115 stars 18 forks source link

Warning with lang attribute in shortcode : Illegal string offset 'lang' #226

Closed julien-jacob closed 4 years ago

julien-jacob commented 4 years ago

Hello !

I have this warning when I use a shortcode like : [enlighter lang="javascript"]alert('hello');[/enlighter]

Warning: Illegal string offset 'lang' in /wp-content/plugins/enlighter/class/ShortcodeFilter.php on line 84

I fix it with change :

if ($attb['lang']) {

by

if (isset($attb['lang'])) {

In /wp-content/plugins/enlighter/class/ShortcodeFilter.php on line 84 And no Warnig after :) I use a bad shortcode syntax ?

Best regards

AndiDittrich commented 4 years ago

Dear @julien-jacob

thanks for your report. i've to investigate the issue - the error code sounds weird since the $attb variable should be an array not a string. maybe it's a compatibility issue with the current wordpress release or php .

btw. shortcodes are deprecated and should not used anymore - take a look on the full visual editor integration

br, Andi

AndiDittrich commented 4 years ago

fixed within the master branch. it is only raised in case the generic enlighter shortcode is used without attributes

it is caused by shortcode_parse_atts which returns a string instead of an empty array in case no attributes were found (great wp api consistency.....)

however, thanks for your report!