64 lines
1.5 KiB
PHP
64 lines
1.5 KiB
PHP
<?php
|
|
|
|
if (! defined('ABSPATH')) {
|
|
exit;
|
|
}
|
|
|
|
|
|
function dekart_page_has_map(): bool
|
|
{
|
|
if (is_admin()) {
|
|
return false;
|
|
}
|
|
if (is_page_template(array( 'page-contacts.php', 'page-camp.php', 'page-after-school.php', 'page-semejnye-klassy.php' ))) {
|
|
return true;
|
|
}
|
|
global $post;
|
|
$content = ($post && isset($post->post_content)) ? (string) $post->post_content : '';
|
|
if ('' !== $content && (false !== strpos($content, 'ya-map') || has_shortcode($content, 'map'))) {
|
|
return true;
|
|
}
|
|
return (bool) apply_filters('dekart_page_has_map', false);
|
|
}
|
|
|
|
|
|
add_action('wp_enqueue_scripts', static function () {
|
|
if (is_admin()) {
|
|
return;
|
|
}
|
|
wp_dequeue_style('bodhi-svgs-attachment');
|
|
}, 100);
|
|
|
|
|
|
add_action('wp_enqueue_scripts', static function () {
|
|
if (is_admin() || dekart_page_has_map()) {
|
|
return;
|
|
}
|
|
global $wp_styles;
|
|
if (! $wp_styles instanceof WP_Styles) {
|
|
return;
|
|
}
|
|
|
|
$patterns = (array) apply_filters('dekart_map_css_patterns', array(
|
|
'api-maps.yandex',
|
|
'maps.yandex',
|
|
'maps.googleapis',
|
|
'maps.google',
|
|
'maptiler',
|
|
'leaflet',
|
|
'openstreetmap',
|
|
));
|
|
foreach ($wp_styles->registered as $handle => $style) {
|
|
$src = (string) $style->src;
|
|
if ('' === $src) {
|
|
continue;
|
|
}
|
|
foreach ($patterns as $needle) {
|
|
if (false !== stripos($src, $needle)) {
|
|
wp_dequeue_style($handle);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}, 100);
|