bozdoz / wp-plugin-leaflet-map

Add leaflet maps to Wordpress with shortcodes
https://wordpress.org/plugins/leaflet-map/
GNU General Public License v2.0
140 stars 71 forks source link

Allow Gallery inside Leaflet Popup Message to display in a Lightbox #208

Closed yonkov closed 1 year ago

yonkov commented 1 year ago

Steps to Reproduce

  1. Create a Leaflet Popup custom post type, ,create a Shortcode that calls the Custom Post Type, add some content and a gallery to the CPT:

image Image 1: Leaflet Popups CPT

image Image 2: Adding Content to Leaflet Popups CPT

  1. Link Gallery images to Media Files

This is an important step in order to enable the lightbox

image Image 3: Link Gallery images to Media Files to enable lightbox

  1. Install Lightbox with Photoswipe plugin We need it for the Lightbox to work.

  2. Add the Shortcode in any page with leaflet map like so (replace id with the custom post type id)

    [leaflet-marker lat=37.79418967176286 lng= -122.40021432209008]
    [leaflet-popup id=340]
    [/leaflet-marker]

image Image 4: Leaflet Map with a Leaflet Popup that contains a CPT with a gallery

(By the way, there is some overflow which wasn't in the previous plugin version (December 2022) and causes the header of the popup to be missing)

  1. Try to click any gallery image and you will see that the lightbox is not working. In fact, header and footer are completely missing from html, I guess that is causing the issue :(

image Image 5: Leaflet Map Lightbox Gallery not working

Expected result

The gallery and the lightbox should be working like so: image

Proposed steps

The current PR comments the two problematic lines and the lightbox is now working when you click on an image from the gallery!

Conclusion

I suppose these lines are important for security, so I made it for testing purposes only, A better approach in my opinion, is to give users like me an option to override this function, at their own risk. Otherwise, I am not able to reproduce the design requirements and I am failing with the project unless I "hack" the plugin and get stuck with using an old and insecure version. Thank you for the understanding and hopefully a solution would be made soon

hupe13 commented 1 year ago

is to give users like me an option to override this function, at their own risk.

The shortcode is supposed to apply to everyone. Therefore, this will be the best solution. But then we should take the content of the popup as it is (without addslashes, htmlspecialchars, unescape). Whether it is then displayed in popup is another matter. I tried it once with Photonic - I couldn't get it work. But a simple WordPress gallery works.

bozdoz commented 1 year ago

This is never going to fly with the wordpress plugin in general. I would like to know if v3.2.0 works for you however. Or, if you could improve this merge request to be more generally applicable. As it is, it obviously can't be merged. Thanks for the background info though.

yonkov commented 1 year ago

@bozdoz , I created this PR for testing purposes. not with the idea to be merged. Unfortunately, I tested the the current version 3.2.0 but it does not work for me, due to the reasons I mentioned in the PR description. The gallery shortcode inside the leaflet popup is working, which is an improvement from before. However, when you click on gallery item, the lightbox is not working, so this solution is not really useful for me. The commented code allows for the lightbox to work. Being a plugin and theme developer myself, I am fully aware this solution is against wp.org guidelines, so I was hoping that you would come up with something else..