Skip to content

Instantly share code, notes, and snippets.

@obiPlabon
Created October 19, 2015 08:14
Show Gist options
  • Select an option

  • Save obiPlabon/23f7b7c9ded7e31bfbbe to your computer and use it in GitHub Desktop.

Select an option

Save obiPlabon/23f7b7c9ded7e31bfbbe to your computer and use it in GitHub Desktop.
<?php
/**
* Template Name: Assets
*/
$js_dir = dirname( __FILE__ ) . '/assets/js/';
$css_dir = dirname( __FILE__ ) . '/assets/css/';
$js = $js_dir . '*.js';
$css = $css_dir . '*.css';
$register = array();
$enqueue = array();
foreach( glob( $css ) as $file ) {
$file_name = str_replace($css_dir, '', $file);
$name = str_replace('.css', '', $file_name);
$register[] = sprintf( 'wp_register_style( \'obi-theme-%s\', $assets_dir . \'/css/%s\', array(), \'1.0.0\' );', $name, $file_name );
$enqueue[] = sprintf( 'wp_enqueue_style( \'obi-theme-%s\' );', $name );
}
echo '<pre>';
echo implode("\n", $register);
echo '<hr>';
echo implode("\n", $enqueue);
echo '</pre>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment