首页 > 解决方案 > 更新到 Worpdress 5.7 后,预加载器无法正常工作

问题描述

更新到 WP 5.7 后,我的 Preloader 停止工作。我在functions.php中有以下代码,以前可以正常工作。

// Preloader Code Header
add_action('wp_head', 'dp_preloader');
function dp_preloader() {
?>
    <!-- Preloader -->
    <div class="dp_preloader">
        <div class="dp_loader_icon">&nbsp;</div>
    </div>
    <style>
    .dp_preloader {position: fixed;top: 0;left: 0;right: 0;bottom: 0;background-color: #ffffff;z-index: 999999;height: 100%;width: 100%;overflow: hidden !important;}
    .dp_preloader .dp_loader_icon {position: absolute;left: 50%;top: 50%;background-repeat: no-repeat;background-position: center;-webkit-background-size: cover;background-size: cover;background-image: url(<?php echo get_stylesheet_directory_uri();?>/img/preloader.gif);width: 64px;height: 64px;margin: 0px 0 0 -30px;}
    </style>
<?php 
}
// Preloader Code Footer
add_action('wp_footer', 'dp_preloader_css');
function dp_preloader_css() {
?>
    <script type="text/javascript">
        jQuery(window).load(function(){ 
            jQuery('.dp_loader_icon').fadeOut('fast'); 
            jQuery('.dp_preloader').delay(0).fadeOut('fast'); 
        })
    </script>
<?php
}
        

标签: imagepreloaderimage-preloader

解决方案


推荐阅读