0

I loaded lessphp in my wordpress theme - it's a full custom - but I do not understand why it can not correctly link the .less file.

to be clearer the current paths are these:

path:(themefolder/lessphp/lessc.inc.php)
path:(themefolder/lessphp/input.less) hemmm not working! yeaaa!
path:(themefolder/lessphp/output.css) hemmm not working! 

ps. for now, I am in wamp localhost.

Into head:

<?php
    //$inputPath = get_bloginfo("template_url")."/lessphp/input.less";

    require "lessphp/lessc.inc.php";
    $less = new lessc;
    $less->checkedCompile("lessphp/input.less", "lessphp/output.css");
?>

Before writing of course I read and did everything but, nothing, I still do not understand ...

The php error is:

Fatal error: Uncaught exception 'Exception' with message 'load error: failed to find lessphp/input.less' in C:\Server\www\shape\wp-content\themes\shape\lessphp\lessc.inc.php on line 1818

How can I do??

and, is it possible to change the classic path??

thank you.

Lelio Faieta
  • 6,457
  • 7
  • 40
  • 74
Alberto
  • 274
  • 1
  • 5
  • 16
  • 1
    Relative paths in PHP are nothing but trouble. Prefix your paths with `__DIR__` to make them relative to the current script directory. StackOverflow is full of questions like this – Phil Sep 19 '18 at 14:26
  • And while you're at it, make sure file permissions are set accordingly. – Hans Sep 19 '18 at 14:28
  • I read other post but not have a solution... _DIR_ not working and not working whit absolute path.... but thanks. – Alberto Sep 19 '18 at 14:52
  • THE SOLUTION: compileFile($inputFile,$outputFile); ?> /yourpath/output.css"> WORK. – Alberto Sep 22 '18 at 07:20

1 Answers1

0

THE SOLUTION:

only wamp localhost:

Change the path from bloginfo("xxx") to php dirname(FILE).

<?php

    $lesspath = dirname(FILE)."\yourextrafolderpath\lessphp\lessc.inc.php";
    $inputFile = dirname(FILE).'\extrafolderpath\input.less';
    $outputFile = dirname(FILE).'\extrafolderpath\output.css';

    require_once $lesspath; $less = new lessc;

    // create a new cache object, and compile
    $less->compileFile($inputFile,$outputFile);

?>

<link rel="stylesheet" href="<?php bloginfo("template_url"); ?>/extrafolderpath/output.css"> 

Alternative way for wamp localhost & wordpress online:

<?php

        $lesspath = get_parent_theme_file_path()."\yourextrafolderpath\lessphp\lessc.inc.php";
        $inputFile = get_parent_theme_file_path().'\extrafolderpath\input.less';
        $outputFile = get_parent_theme_file_path().'\extrafolderpath\output.css';

        require_once $lesspath; $less = new lessc;

        // create a new cache object, and compile
        $less->compileFile($inputFile,$outputFile);

    ?>

    <link rel="stylesheet" href="<?php bloginfo("template_url"); ?>/extrafolderpath/output.css">

Tested... Work.

Alberto
  • 274
  • 1
  • 5
  • 16