Answer the question
In order to leave comments, you need to log in
How to make 2gis API work in Wordpress?
I can't connect 2gis api to wordpress. The following error is displayed:
Consider using 'dppx' units, as in CSS 'dpi' means dots-per-CSS-inch, not dots-per-physical-inch, so does not correspond to the actual 'dpi' of a screen. In media query expression: (min-resolution: 144dpi)
wp_register_script('mapapi', 'http://maps.api.2gis.ru/2.0/loader.js?pkg=full&lazy=true');
wp_enqueue_script('mapapi');
<?php if (is_page('contacts')){?>
<script src="http://maps.api.2gis.ru/2.0/loader.js?pkg=full&lazy=true" data-id="dgLoader" ></script>
<?php } ?>
PS Plugins (if any) do not offer. I think the problem can be solved without resorting to dubious extensions.
Answer the question
In order to leave comments, you need to log in
this is not a mistake but a recommendation
to connect correctly like this
function my_script() {
if ( is_page('contacts') )
wp_enqueue_script('my-script','http://maps.api.2gis.ru/2.0/loader.js?data-id');
}
add_action( 'wp_enqueue_scripts', 'my_script' );
add_filter('clean_url','unclean_url',10,3);
function unclean_url( $good_protocol_url, $original_url, $_context) {
if ( false !== strpos( $original_url, 'data-id' ) ) {
remove_filter( 'clean_url', 'unclean_url', 10, 3 );
$url_parts = parse_url( $good_protocol_url );
return $url_parts['scheme'] . '://' . $url_parts['host'] . $url_parts['path'] . '?pkg=full&lazy=true'."' data-id='dgLoader";
}
return $good_protocol_url;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question