Advertisement
neatekFb

Rational connection scripts and styles - Wordpress

Jun 7th, 2017
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.02 KB | None | 0 0
  1. <?php
  2. // Vladimir Zhelnov // neatek.ru // neatek.pw
  3. // functions.php (Wordpress)
  4.  
  5. define('DEV_MODE',          true);
  6.  
  7. function theme_main_scripts(){
  8.     $v = '1.0.0';
  9.    
  10.     // Disable Apache or other server caching via rand()
  11.     if(DEV_MODE) $v = rand();
  12.     wp_enqueue_script('jquery');
  13.  
  14.     // Connect Styles =>
  15.     $array = array(
  16.         // path to style & dependencies
  17.         ['/style.css', array() ],
  18.         ['/assets/normalize.css', array() ],
  19.         ['/assets/assets/owl.carousel.css', array() ],
  20.         ['/assets/assets/owl.theme.default.min.css', array() ],
  21.     );
  22.     foreach ($array as $key => $value)
  23.         wp_enqueue_style( 'theme-'.basename($value[0]), MAIN_THEME_URI.$value[0], $value[1], $v );
  24.  
  25.     // Connect Scripts =>
  26.     $array = array(
  27.         // path to script & dependencies
  28.         ['/js/index.js', array('jquery') ],
  29.         ['/assets/owl.carousel.min.js', array('jquery') ]
  30.     );
  31.     foreach ($array as $key => $value)
  32.         wp_enqueue_script( 'theme-'.basename($value[0]), MAIN_THEME_URI.$value[0], $value[1], $v );
  33. }
  34. add_action( 'wp_enqueue_scripts', 'theme_main_scripts' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement