Skip Navigation

[Résolu] [Bug] Shortcodes not processed on map popup text under some circumstances

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem: Shortcodes inside Map Marker popups are not executed correctly in some circumstances.

Solution: Follow the format shown here for best results. Close all wpv-map-render shortcodes explicitly.

[wpv-map-render map_id="map-6"][/wpv-map-render]
[wpv-map-marker map_id="map-6" marker_id="marker-6" marker_field="wpcf-property-address"][/wpv-map-marker]

Relevant Documentation:
https://toolset.com/documentation/user-guides/display-on-google-maps/displaying-markers-on-google-maps/

This support ticket is created Il y a 5 années et 9 mois. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 3 réponses, has 2 voix.

Last updated by Christian Cox Il y a 5 années et 9 mois.

Assisted by: Christian Cox.

Auteur
Publications
#953616
toolset-maps-bug.png

Hi there,
please note that I am a Toolset and WPML contractor and I have performed an in-depth debug before posting this report.
I also had contacts with your developer Konstantinos K. regarding this issue, and he suggested to open this thread.

I am trying to: populate the popup text of a map built with Toolset maps, with a value coming from a custom field set up with Types.

Link to a page where the issue can be seen: please see the attached screenshot

I expected to see: the custom field value

Instead, I got: the shortcode unprocessed (see screenshot).

After my debug session I have found that the problem is triggered dependently on the nesting of the shortcodes.
Please note I made the following tests on a Vanilla WP install with a default theme and only Types, Views and Toolset Maps plugins installed.

The following code (inserted in a content template) triggers the bug:

[wpv-map-render map_id="map-3"][wpv-map-marker map_id='map-3' marker_id='marker-2' marker_field='wpcf-location-address'][types field='location-popup-text'][/types][/wpv-map-marker][/wpv-map-render]

While the following works just fine:

[wpv-map-render map_id="map-3"][/wpv-map-render]
[wpv-map-marker map_id='map-3' marker_id='marker-2' marker_field='wpcf-location-address'][types field='location-popup-text'][/types][/wpv-map-marker]

As you can see, when the [wpv-map-marker] shortcode is nested inside the [wpv-map-render] the problem occurs, when it's outside everything works fine.

In your documentation at page https://toolset.com/documentation/user-guides/display-on-google-maps/displaying-markers-on-google-maps/ the following example is present:

[wpv-map-render map_id="map-6"]
[wpv-map-marker map_id="map-6" marker_id="marker-6" marker_field="wpcf-property-address"][/wpv-map-marker]

As you can see, it doesn't have the closing [/wpv-map-render] tag, but when you insert the tag using the relevant button, the closing tag is automatically added so I believe the example is not up to date.

That said, I would have expected that also the first (nested) version of the code should be working. By the way, I was also able to fix it by adding a call to do_shortcode inside the function that renders the shortcode [wpv-map-marker] (method Toolset_Addon_Maps_Views::marker_shortcode).

#953815

Hi, thanks for the report. I agree the documentation was a bit confusing for this example. The Map shortcode should be explicitly closed, and should not contain Marker shortcodes or any other content between the opening and closing tags. The document has been updated so that the example code is more accurate:

[wpv-map-render map_id="map-6"][/wpv-map-render]
[wpv-map-marker map_id="map-6" marker_id="marker-6" marker_field="wpcf-property-address"][/wpv-map-marker]

Please follow this format for the best results.

#954354

Hi Christian,
thanks for your reply. Even if this could be not properly a bug, please consider that it's considered a best practice to let enclosing shortcodes explicitly process included shortcodes.
For your reference check the official WordPress Plugin Handbook and in the Codex on this matter:
https://developer.wordpress.org/plugins/shortcodes/enclosing-shortcodes/#shortcode-ception
https://codex.wordpress.org/Shortcode_API#Enclosing_vs_self-closing_shortcodes

As a plugin developer myself, to avoid confusion, I would recommend you to add a proper call to do_shortcode, as suggested in the WordPress documentation and also in my first message of this thread.
If you don't want users to insert content inside the shortcode you shouldn't use enclosing shortcodes, and prefer the self-closing ones (as they were previously in your documentation).

Just my 2 cents, of course, it's up to you.

#954479

Thank you for the report, I will relay your suggestions to the development team.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.