最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

wp enqueue style - Scripts and stylesheets failing to load in Chrome IOS (and only Chrome IOS)

programmeradmin2浏览0评论

My script and stylesheet files have been failing to load in Chrome IOS, and only Chrome IOS. I changing the value of $ver in wp_register_script from a string with a value ("1.0.17") to an empty string, and this caused the problem to clear up. I changed it back, and that caused the problem to happen again, but when I did that process a second time the problem didn't occur, and now I can't reproduce it.

Does anybody know what might be going on with this, and how I can prevent it from happening in the future?

class Queue{
    private $cssVer = "1.0.43";
    // Chrome breaker?
    private $jsVer = "1.0.17";

    function __construct() {
        $this->suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
        $this->add_actions();
    } 
    public function add_actions(){
        add_action( 'wp_enqueue_scripts',array( $this, 'queue_all' ),20 );
    }
    public function queue_all(){
        $this->queue_scripts();
        $this->queue_styles();
    }
    private function queue_styles(){
        $this->enqueue_all_css();
    }
    private  function queue_scripts(){
        $this->enqueue_custom_js();
    }
    private function enqueue_all_css(){
        wp_register_style('style-label', 
            get_stylesheet_directory_uri().'/folder/filename'.$this->suffix.'.css', 
            null, 
            $this->cssVer, 
            "all"
        );
        wp_enqueue_style( 'style-label',1 );
    }
    private function enqueue_custom_js(){
            wp_register_script('label-js', 
                get_stylesheet_directory_uri().'/folder/file'.$this->suffix.'.js', 
                ['jquery'], 
                $this->jsVer, 
                false
            );
            wp_enqueue_script( 'label-js' );
        }
    }
}
发布评论

评论列表(0)

  1. 暂无评论