• Resolved A Day

    (@a-day)


    Hi there

    No doubt a very naïve question, so please forgive me in advance, I cannot find an answer elsewhere.

    I would like to take URL query data from the link that opens the map page and use it to specify the placemarker, location and zoom to open the map with.

    eg website.com/map/?pmark=100&pcentre=London&pzoom=16

    Do I need to re-write your bgmp-map shortcode in order to do this? In order to read in the arguments in php? If so could you give me a quick hint as to where I should start?

    Or is there a simpler method I am unaware of?

    Much gratitude for any, possible incredibly basic, advice…!

    https://ww.wp.xz.cn/plugins/basic-google-maps-placemarks/

Viewing 1 replies (of 1 total)
  • Plugin Author Ian Dunn

    (@iandunn)

    That should be easy, but instead of adding the [bgmp-map] shortcode in the page content, you’ll need to do it in a page template with PHP.

    e.g., something like

    <?php
    $bgmp_map = sprintf(
        '[bgmp-map id="%d" center="%s" zoom="%s"',
         absint( $_GET['id'] ),
         sanitize_text_string( $_GET['center'],
         absint( $_GET['zoom'] )
     );
    echo do_shortcode( $bgmp_map );
    ?>

    I haven’t tested that, so it’ll probably need to be tweaked, but that’s the basic idea.

    http://codex.ww.wp.xz.cn/do_shortcode

    Make sure you properly whitelist/validate the GET parameters, or you could introduce severe security vulnerabilities.

    http://codex.ww.wp.xz.cn/Data_Validation

Viewing 1 replies (of 1 total)

The topic ‘passing URL query as shortcode attributes’ is closed to new replies.