I'm trying to add a php-compiler in my new Wordpress Theme. Therefore I followed this Tutorial: http://www.tailored4wp.com/how-to-use-less-auto-compiler-in-your-next-wordpress-project-quick-tip-361/
My functions.php
/**
* LESS Compiler.
*/
function autoCompileLess() {
// include lessc.inc
require_once( get_template_directory().'/less/lessc.inc.php' );
// input and output location
$inputFile = get_template_directory().'/less/bootstrap.less';
$outputFile = get_template_directory().'/css/bootstrap_less.css';
// load the cache
$cacheFile = $inputFile.".cache";
if (file_exists($cacheFile)) {
$cache = unserialize(file_get_contents($cacheFile));
} else {
$cache = $inputFile;
}
$less = new lessc;
// create a new cache object, and compile
$newCache = $less->cachedCompile($cache);
// output a LESS file, and cache file only if it has been modified since last compile
if (!is_array($cache) || $newCache["updated"] > $cache["updated"]) {
file_put_contents($cacheFile, serialize($newCache));
file_put_contents($outputFile, $newCache['compiled']);
}
}
/**
* Enqueue scripts and styles.
*/
function scripts() {
wp_enqueue_style( 'bootstrap-css', get_template_directory_uri() . '/css/bootstrap_less.css' );
}
add_action( 'wp_enqueue_scripts', 'scripts' );
If I change some less files, there won’t be any file in output-directory. (I set the right permissions)
And if I add
if(is_user_logged_in()) {
add_action(‘init’, ‘autoCompileLess’);
}
…/wp-admin will show a blank page with no code in it. What’s wrong?
********EDIT*************
I copied the Theme to XAMPP Installation and got these Errors:
Fatal error: Uncaught exception 'Exception' with message 'parse error: failed at
&:extend(.clearfix all);D:\xampp\htdocs\wordpress/wp-content/themes/templateName/less/mixins/grid.less on line 11' in D:\xampp\htdocs\wordpress\wp-content\themes\templateName\less\lessc.inc.php:3460 Stack trace: #0 D:\xampp\htdocs\wordpress\wp-content\themes\templateName\less\lessc.inc.php(2273): lessc_parser->throwError() #1 D:\xampp\htdocs\wordpress\wp-content\themes\templateName\less\lessc.inc.php(121): lessc_parser->parse('// Grid system?...') #2 D:\xampp\htdocs\wordpress\wp-content\themes\templateName\less\lessc.inc.php(753): lessc->tryImport(Array, Object(stdClass), Object(stdClass)) #3 D:\xampp\htdocs\wordpress\wp-content\themes\templateName\less\lessc.inc.php(162): lessc->compileProp(Array, Object(stdClass), Object(stdClass)) #4 D:\xampp\htdocs\wordpress\wp-content\themes\templateName\less\lessc.inc.php(147): lessc->compileImportedProps(Array, Object(stdClass), Object(stdClass), Object(lessc_parser), 'D:\xampp\htdocs...') #5 D:\xampp\htdocs\wordpress\w in D:\xampp\htdocs\wordpress\wp-content\themes\templateName\less\lessc.inc.php on line 3460
/** * For developers: WordPress debugging mode. * * Change this to true to enable the display of notices during development. * It is strongly recommended that plugin and theme developers use WP_DEBUG * in their development environments. */ define('WP_DEBUG', true); define('WP_DEBUG_LOG', true); define('WP_DEBUG_DISPLAY' true)But I can't see anything... it's also an empty page... I think the server does not provide php errors and debugging etc. - David Strauch