rAthus

[WordPress] force NitroPack to update custom CSS and JS files when modified

Mar 9th, 2021 (edited)
785
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.95 KB | None | 0 0
  1. Dans .htaccess :
  2.  
  3. # Simulation nouveaux fichiers CSS et JS pour NitroPack
  4. RewriteRule ^(.*)-([\d]*)-nitrokek\.(.*)$ /$1.$3 [L]
  5.  
  6. Dans functions.php :
  7.  
  8. <?php
  9.  
  10. // styles du child theme
  11. function akn_enqueue_styles() {
  12.     $ver = 'BASE';
  13.     if (file_exists(get_stylesheet_directory().'/style.css'))
  14.         $ver = date('YmdHis',filemtime(get_stylesheet_directory().'/style.css'));
  15.     wp_enqueue_style('akn-style', get_stylesheet_directory_uri().'/style-'.$ver.'-nitrokek.css', array(), false);
  16. }
  17. add_action('wp_enqueue_scripts', 'akn_enqueue_styles');
  18.  
  19. // javascript du child theme
  20. function akn_enqueue_scripts() {
  21.     $ver = 'BASE';
  22.     if (file_exists(get_stylesheet_directory().'/js/rAthus.js'))
  23.         $ver = date('YmdHis',filemtime(get_stylesheet_directory().'/js/rAthus.js'));
  24.     wp_enqueue_script('script-rathus', get_stylesheet_directory_uri().'/js/rAthus-'.$ver.'-nitrokek.js', array('jquery'), false, true);
  25. }
  26. add_action('wp_enqueue_scripts', 'akn_enqueue_scripts');
  27.  
Add Comment
Please, Sign In to add comment