Wordpress Bones Theme CSS and JS Versioning

后端 未结 2 367
独厮守ぢ
独厮守ぢ 2021-01-21 05:40

I have a website that has been built using the bones wordpress theme. No matter what I do I can\'t seem to get versioning to work on css and js using the wordpress enqueue funct

2条回答
  •  独厮守ぢ
    2021-01-21 06:42

    I found it !

    There's a filter into Bones theme, which remove every CSS/JS versionning.

    Just look into the bones-theme/library/bones.php file, you got a filter function

    // ~L.48
    add_filter( 'style_loader_src', 'bones_remove_wp_ver_css_js', 9999 );
    
    /** Some code **/
    // ~L.89
    function bones_remove_wp_ver_css_js( $src ) {
      if ( strpos( $src, 'ver=' ) )
            $src = remove_query_arg( 'ver', $src );
      return $src;
    }
    

    You can either edit it or just remove the hook, and place your versionning inside wp_enqueue_script()/wp_enqueue_style() functions.

提交回复
热议问题