• Resolved Hook and Loop

    (@twodozen)


    Since updating to LMM v3.2 and WP v3.5, I’m getting this error on pages using shortcodes to call maps:

    “Leaflet Maps Marker warning!
    You must enqueue the plugin stylesheets manually if you want to show maps by calling do_shortcode() in your template files!
    Please add the following code before your get_header() call inside your template, which is usually located in header.php:

    $plugin_version = get_option(‘leafletmapsmarker_version’);
    global $wp_styles;
    wp_enqueue_style( ‘leafletmapsmarker’, LEAFLET_PLUGIN_URL . ‘leaflet-dist/leaflet.css’, array(), $plugin_version );
    wp_enqueue_style( ‘leafletmapsmarker-ie-only’, LEAFLET_PLUGIN_URL . ‘leaflet-dist/leaflet.ie.css’, array(), $plugin_version );
    $wp_styles->add_data(‘leafletmapsmarker-ie-only’, ‘conditional’, ‘lt IE 9’);

    ********

    Anyone else experience this?

    https://www.ads-software.com/extend/plugins/leaflet-maps-marker/

Viewing 15 replies - 1 through 15 (of 28 total)
  • Thread Starter Hook and Loop

    (@twodozen)

    I should add:

    1. The problem goes away when I switch to default theme (“2012”)
    2. Restoring the previous version (2.6) removed the problem

    Hi,
    this is not an error – conditional loading of css requires to some code once to heade.php of your template in order to display maps – please just follow the instructions and maps will work as normal.
    regards,
    Robert

    Thread Starter Hook and Loop

    (@twodozen)

    Hi Robert,

    To clarify – it wasn’t necessary in v2 but is needed for v3?

    Btw, I did follow the instructions but the error persisted.

    Regards,
    Moz

    Hi Moz,

    didnt find a way to automatically add css files if shortcode is called via do_shortcode() in template files for v3.2 (didnt exist before). This is way I added the instructions – my thought was that if someone added shortcodes to template files, he/she is able to do that with the code needed for my plugin.
    I would have to take a look at your site/admin in order so see whats wrong.

    Will try to find a solution for this for v3.2.1 so that no manual changes in template files are needed
    regards,

    Robert

    OK but I can’t find file to put the ‘code’ inside.
    In this moment i have to turn off Leaflet Maps Marker on my side, because
    “Leaflet Maps Marker warning!” kill it
    What can I do to restore Leaflet Maps Marker to good version?
    I use themes Adventure Journal in WordPress
    Regards
    Witold

    Uf! I fougth the place to put this “code” in Adventure Journal

    <head>
    <meta charset=”<?php bloginfo( ‘charset’ ); ?>” />
    […]
    * to support sites with threaded comments (when in use).
    */
    if ( is_singular() && get_option( ‘thread_comments’ ) )
    wp_enqueue_script( ‘comment-reply’ );

    /* Always have wp_head() just before the closing </head>
    * tag of your theme, or you will break many plugins, which
    * generally use this hook to add elements to <head> such
    * as styles, scripts, and meta tags.
    */
    $plugin_version = get_option(‘leafletmapsmarker_version’);
    global $wp_styles;
    wp_enqueue_style( ‘leafletmapsmarker’, LEAFLET_PLUGIN_URL . ‘leaflet-dist/leaflet.css’, array(), $plugin_version );
    wp_enqueue_style( ‘leafletmapsmarker-ie-only’, LEAFLET_PLUGIN_URL . ‘leaflet-dist/leaflet.ie.css’, array(), $plugin_version );
    $wp_styles->add_data(‘leafletmapsmarker-ie-only’, ‘conditional’, ‘lt IE 9’);

    wp_head();
    ?>
    </head>

    Hi Moz & WJJ,
    I just released v3.2.1 which includes an alternative function for conditional css if do_shortcode() is used in template files: https://www.mapsmarker.com/2012/12/12/v3-2-1-no-more-manual-edits-when-using-do_shortcode-is-available/
    please check if this works for you (no more manual edits are needed).
    best regards,
    Robert

    Hi Robert,

    With v3.2.1 installed i still have the warning on some pages where is used [mapsmarker layer=”xxx”]

    The warning was present in v.3.2 as well but i waited for update – as you mentioned yesterday.
    Maybe in some cases it still need manual edit.

    Thank you

    I implemented a “95%-solution” – in which template files do you include the shortcode?

    I use them in categories description, but is some works and in some don`t.
    I will ask support from template developers team as well.

    Thank you

    automatic enqueuing of css files if shortcode is used in category description is not supported – please add those few lines to your template instead.

    Thread Starter Hook and Loop

    (@twodozen)

    I’m staying with v2 until this is a bit more stable. Amending theme files isn’t a viable option for me in this case due to overwrite problems later when theme is updated.

    Hi twodozen,

    v3.2.1 is stable and doesnt need any manual theme changes if you embedd the maps via do_shortcode() in theme files.

    The only usecase where you still need manual edits is when you use a shortcode within category descriptions. Enhancing my plugin to also check this field, would slow down its overall performance (as I had to check every available category description).
    regards,

    Robert

    I think I just had an idea: I will add an option to disable selective css loading which is disabled by default. In case you are using shortcodes in fields like category description for example which are not supported by my plugin, you can fix this my setting the option without having to touch your theme. Only disadvantage: css files then get loaded on every page again.

    Hi again,
    I just released v3.2.2 which should fix all those issues – please check again.
    regards,
    Robert

Viewing 15 replies - 1 through 15 (of 28 total)
  • The topic ‘3.2 requires adding to code to header of template files’ is closed to new replies.