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

About the display of array objects [caption] #266

Closed xyx115 closed 4 years ago

xyx115 commented 4 years ago

This plugin is one I really like. Recently, when using the plugin to display array objects, I encountered an error.

If there is [caption] => in the content, the display result is =>, and the previous content is lost.

Change the programming language, or use the plug-in output alone [caption] =>, the result is the same. Only left =>.

Please help to improve.

Thank you.

For example: Below is the original content I want to display `Array ( [width] => 70 [height] => 70 [file] => 2020/05/logo_250x25003.png [sizes] => Array ( )

[image_meta] => Array
    (
        [aperture] => 0
        [credit] => 
        [camera] => 
        [caption] => 
        [created_timestamp] => 0
        [copyright] => 
        [focal_length] => 0
        [iso] => 0
        [shutter_speed] => 0
        [title] => 
        [orientation] => 0
        [keywords] => Array
            (
            )

    )

)`

After the plugin shows, the result is: `Array ( [width] => 70 [height] => 70 [file] => 2020/05/logo_250x25003.png [sizes] => Array ( )

[image_meta] => Array
    (
        [aperture] => 0
        [credit] => 
        [camera] => 
         => 
        [created_timestamp] => 0
        [copyright] => 
        [focal_length] => 0
        [iso] => 0
        [shutter_speed] => 0
        [title] => 
        [orientation] => 0
        [keywords] => Array
            (
            )

    )

)`

Or I want to display the following: [credit] => [camera] => [caption] => [created_timestamp] => 0 [copyright] => [focal_length] => 0 [iso] => 0

The actual display is: [credit] => [camera] => => [created_timestamp] => 0 [copyright] => [focal_length] => 0 [iso] => 0

AndiDittrich commented 4 years ago

Hi @xyx115

[caption] is a reserved/build-in shortcode from WordPress - https://codex.wordpress.org/Caption_Shortcode

there is no workaround/fix available - you have to disable Shortcodes for your whole website or escape them with double brackets

xyx115 commented 4 years ago

thank you for your reply. Sorry, because of my unfamiliarity with wordpress and it bothers you.

In my test, when using the code in the default editor of wordpress, the display is normal.

As you said, then I can only escape [caption] when displaying and then output. After testing, your method works.

Thank you

AndiDittrich commented 4 years ago

the WordPress standard codeblock replaces the brackets with [ but on the other hand it would break any shortcode which is adding dynamic/external content into the codeblock. maybe i'll add a option to control this in the future

xyx115 commented 4 years ago

Thank you for your efforts