YOOtheme Pro is here! The best WordPress and Joomla theme. Learn more

Avatar dimitri.longo asked

Yootheme not compatible with Install wordpress in subdirectory and warp theme (wp-content) in root, not working

Hello
i try to install wp in subdirectory and move (& rename wp-content). I follow the Codex https://codex.wordpress.org/Editing_wp-config.php#Moving_wp-content_folder
home url : http://mywebsite:8888/
site url : http://mywebsite:8888/core
My new structure :
public_html
|->index.php
|->wp-config.php
|-> core
|->custom
|-->plugins
|-->themes

in wp-config i have as stated in the codex

define( 'WP_CONTENT_DIR', dirname( __FILE__ ) . '/custom' );  
define( 'WP_CONTENT_URL', 'http://' . $_SERVER['HTTP_HOST'] . '/custom' );

and change index.php to

define('WP_USE_THEMES', true);  
/** Loads the WordPress Environment and Template */  
require( dirname( __FILE__ ) . '/core/wp-blog-header.php' );

it works well with plugin and themes except Yootheme warp theme
it seems it can' load assets like css and js in
SystemHelper.php line 652

// add css/js  
    $siteurl = sprintf('/%s/i', preg_quote(parse_url(site_url(), PHP_URL_PATH), '/'));  
    if (isset($_GET['page']) && $_GET['page'] == 'warp') {  
        wp_enqueue_script('warp-js-jquery-mustache', preg_replace($siteurl, '', $this['path']->url('warp:vendor/jquery/jquery-mustache.js'), 1));  
        wp_enqueue_script('warp-js-jquery-cookie', preg_replace($siteurl, '', $this['path']->url('warp:vendor/jquery/jquery-cookie.js'), 1));  
        wp_enqueue_script('warp-js-jquery-less', preg_replace($siteurl, '', $this['path']->url('warp:vendor/jquery/jquery-less.js'), 1));  

so $siteurl = /\/core/i
and the the DIR URI is :

/mywebsite/wp-content/themes/yoo_gusto_wp/warp/vendor/jquery/jquery-mustache.js 

and final URL is :

http://mywebsite:8888/core/mywebsite/wp-content/themes/yoo_gusto_wp/warp/vendor/jquery/jquery-mustache.js

But in order to load the url should look like this :

http://mywebsite:8888/wp-content/themes/yoo_gusto_wp/warp/systems/wordpress/config/css/admin.css

So i can alter the warp core, and it will works, maybe you have another idea ? or maybe i did something wrong.

PS : same issue in front end with js & css load in theme.config.php with $this['asset']->addFile('js', 'warp:vendor/uikit/js/components/autocomplete.js'); for example
when site live, same issue
for the front-end (wrong url)

Warp\Asset\FileAsset Object  
 (  
    [path:protected] => /home/mywebsite/public_html/custom/themes/yoo_sun_wp/css/theme.css  
[type:protected] => File  
[url:protected] => /core/home/mywebsite/public_html/custom/themes/yoo_sun_wp/css/theme.css  
[content:protected] =>   
[loaded:protected] =>   
[options:protected] => Array  
     (  
          [base_path] => /home/mywebsite/public_html/wp  
    [base_url] => /core  
        )  
    )  

the correct url should be like this :

Warp\Asset\FileAsset Object  
 (  
    [path:protected] => /home/mywebsite/public_html/custom/themes/yoo_sun_wp/css/theme.css  
[type:protected] => File  
[url:protected] => /custom/themes/yoo_sun_wp/css/theme.css  
[content:protected] =>   
[loaded:protected] =>   
[options:protected] => Array  
     (  
          [base_path] => /home/mywebsite/public_html/wp  
    [base_url] => /core  
        )  
    )  

I test with this repo for local dev, same issue with path.
I add a live test link here...

Thanks for help
Dimitri

  • WordPress
  • Feature Request
  • General Question

Edited

4 Answers

1

Avatar philipp Yootheme answered

Hi Dimitri,

I just wanted you to know I had a look into this, and rebuild the same error locally with exact the same behaviour of the links.

I first tried it with relocating only the wp-content folder into the custom folder, this worked fine, but after relocating the wordpress folder into the core folder, the warp framework doesn't calculate the links correctly.
So you made nothing wrong ;)

I think there is (at the moment) no way arround altering warp core. I will have a closer look into this problem tomorrow and see if I can find a proper solution for this one.

Kind Regards
Philipp


Update 22.Oct

Hi Dimitri,
so I had a closer look into this today,
I found a little quickfix for your frontend problem, so that the style and everything gets loaded correctly.
Fixing the problem in the backend seems not to be so "easy".
I will have a talk here with the developers if there can be a clean solution found for both problems.

So to fix your website open the file website/custom/themes/yoo_aurora_wp/warp/src/Warp/Helper/PathHelper.php and replace the following line 96:

$url = $root.'/'.ltrim(preg_replace('/'.preg_quote(str_replace(DIRECTORY_SEPARATOR, '/', $this['system']->path), '/').'/i', '', $url, 1), '/');

by these lines:

$shortedPath = substr($this['system']->path, 0, -4);  
$url = substr($root, 0, -5).'/'.ltrim(preg_replace('/'.preg_quote(str_replace(DIRECTORY_SEPARATOR, '/', $shortedPath), '/').'/i', '', $url, 1), '/');

We use here the substr function to remove the 'core' from your system path and to remove the '/core' from your root path. This is really hard coded so keep in mind when changing the name of the folder to adapt substr function here.

After this changes your website should load the scripts and the styles correctly.

Kind Regards
Philipp

Edited

0

Avatar dimitri.longo answered

So nice of you to take a closer look, i was surprised none of yoothemes users have this problem, because in dev environment have wp-content outside the core is very useful, for instance i put wordpress as a submodule in git and i can switch wordpress branch etc, too many advantages, i hope your team will find a fix for both front end and back end in future release, i will wait until then to have a dev workflow like that.

thank you again, your answer will help yootheme dev

Regards
Dimitri

Edited

0

Avatar vincent.tervooren.52 answered

I have the exact same issue and got to do some rewrite on the server side to fix it. It would be great that a large theme and plugin provider as you do respect WordPress standards for generating paths and URLs. It’s pretty common to have WordPress in a subfolder and content in another when you’re using Git for example.

0

Avatar chimy answered

Hi,
The plugin "widgetkit 2" has same url problem like "http:/mydomain/app/data/home/qxu15899303417/htdocs/content/plugins/widgetkit/cache/widgetkit-e4a97163.js".
期待yootheme团队的回复。

Here is my solution.
file:
C:\xampp\htdocs\wordpress\skeleton\content\plugins\widgetkit\src\Framework\src\Routing\UrlGenerator.php
line: 91
add:
$path = str_replace( '/app/C:/xampp/htdocs/wordpress/skeleton', '', $path );

Edited

Know someone who can answer? Share a link to this question via email or twitter.