Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Wordpress 4.0.1和Bootstrap 3减少PHP编译器_Wordpress_Twitter Bootstrap_Less - Fatal编程技术网

使用Wordpress 4.0.1和Bootstrap 3减少PHP编译器

使用Wordpress 4.0.1和Bootstrap 3减少PHP编译器,wordpress,twitter-bootstrap,less,Wordpress,Twitter Bootstrap,Less,我正试图在我的新Wordpress主题中添加一个php编译器。因此,我遵循本教程: My functions.php /** * LESS Compiler. */ function autoCompileLess() { // include lessc.inc require_once( get_template_directory().'/less/lessc.inc.php' ); // input and output location $input

我正试图在我的新Wordpress主题中添加一个php编译器。因此,我遵循本教程:

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(is_user_logged_in()) {
add_action(‘init’, ‘autoCompileLess’);
}
…/wp admin将显示一个没有代码的空白页。怎么了

********编辑*************

我将主题复制到XAMPP安装,并出现以下错误:

致命错误:未捕获异常“exception”,消息为“parse error: 在
&:extend(.clearfix all)失败
D:\xampp\htdocs\wordpress/wp content/themes/templateName/less/mixins/grid.less
在线11'中
D:\xampp\htdocs\wordpress\wp content\themes\templateName\less\lessc.inc.php:3460
堆栈跟踪:#0
D:\xampp\htdocs\wordpress\wp content\themes\templateName\less\lessc.inc.php(2273):
lessc#u解析器->throwError()#1
D:\xampp\htdocs\wordpress\wp content\themes\templateName\less\lessc.inc.php(121):
lessc_parser->parse('//网格系统?…)#2
D:\xampp\htdocs\wordpress\wp content\themes\templateName\less\lessc.inc.php(753):
lessc->tryImport(数组、对象(stdClass)、对象(stdClass))#3
D:\xampp\htdocs\wordpress\wp content\themes\templateName\less\lessc.inc.php(162):
lessc->compileProp(数组、对象(stdClass)、对象(stdClass))#4
D:\xampp\htdocs\wordpress\wp content\themes\templateName\less\lessc.inc.php(147):
lessc->compileImportedOps(数组、对象(stdClass)、对象(stdClass),
对象(lessc_解析器),'D:\xampp\htdocs…')#5
D:\xampp\htdocs\wordpress\w在
D:\xampp\htdocs\wordpress\wp content\themes\templateName\less\lessc.inc.php
在线3460


感谢Bass Jobson,我根据Bass Jobson的评论找到了一个解决方案:

Leafo/lesshpp与Bootstrap 3.1.1不兼容,似乎不再积极开发。因此,我改为oyejorge/lesshp

从Leafo/Lesspp过渡

寻求从leafo/LESSHPP轻松过渡的项目可以使用 php适配器。要使用,请下载less.php源代码并 将文件解压缩到您的项目中,以便新的“lessc.inc.php” 替换现有的“lessc.inc.php”

注意,“setPreserveComments”将不再对 编译更少


首先尝试调试代码,以找出出现错误的原因。嘿,WB_调试已打开:
/***对于开发人员:WordPress调试模式。**将此更改为true,以启用开发期间的通知显示。*强烈建议插件和主题开发人员在其开发环境中使用WP_DEBUG*。*/定义('WP_DEBUG',true);定义('WP\u DEBUG\u LOG',true);定义('WP\u DEBUG\u DISPLAY'true)
但我什么都看不到。。。这也是一个空白页。。。我认为服务器没有提供php错误和调试等。我将主题复制到XAMPP Wordpress安装中,并得到了许多错误。我编辑了上述问题。请参见: