0

Installing Wordpress SEO (an a few others but not all plugins) gives the following console error:

GET http://craigmdennis.com/content/plugins/nfs/c08/h04/mnt/152547/domains/craigmdennis.com/html/content/plugins/wordpress-seo/js/wp-seo-admin-global.js?ver=1.2.5 404 (Not Found)

For some reason it is listing the complete server path after my url. It seems as though /nfs/c08/h04/mnt/152547/domains/craigmdennis.com/html/content/plugins/ or http://craigmdennis.com/content/plugins/ should not be present in the url.

Here is the directory structure (please note the custom content directory):

wp/
content/
content/themes/
content/plugins/
.htaccess
index.php
wp-config.php

I am not running MU. I also have a subdomain for media (shouldn't be effecting the issue but I'm listing it for completedness)

Here are the relevant parts of my wp-config.php file:

define('WP_SITEURL', 'http://' . $_SERVER['SERVER_NAME'] . '/wp');

define('WP_HOME',    'http://' . $_SERVER['HTTP_HOST']);

define('WP_CONTENT_DIR', $_SERVER['DOCUMENT_ROOT'] . '/content');

define('WP_CONTENT_URL', 'http://' . $_SERVER['SERVER_NAME'] . '/content');

Does anyone know what's going on here? Thanks.

[EDIT] I think it's related to __FILE__ and not DOCUMENT_ROOT as the plugins all use __FILE__ to get the directory name. This provides /nfs/c08/h04/mnt/ instead of /home/.

When I echo the location of the plugins_url() I get /home/152547/domains/dev.craigmdennis.com/html/content/plugins which is correct but when I pass in FILE as a parameter I get the aforementioned /nfs/c08/h04/mnt/152547/domains/dev.craigmdennis.com/html/content/plugins/{plugin-folder}.

Could this be something to do with PHP resolving aliases for __FILE__ This would explain why it works on my local server (with no aliases) and doesn't on Media Temple (which may alias /nfs/c08/h04/mnt/ for /home/ Is this a Wordpress issue or an issue on my server?

Craig
  • 164
  • 2
  • 13

3 Answers3

0

Taking the example of Craig's solution, I've found a solution:

Craig posted this link that gives me some light about it:

See: http://php.net/manual/en/language.constants.predefined.php#104842

Using the WP_PLGUIN_DIR global using my external plugin folder solved the issue.

I've declared this on my wp-config.php

define( 'WP_PLUGIN_DIR', '/var/www/name-of-the-external-folder/plugins' );

Hope it helps anyone here, It took me a while to discover.

0

Given that the js location is determined as follows:

$js_location = WPSEO_URL . 'js/wp-seo-admin-global.js'

where:

WPSEO_URL = WP_PLUGIN_URL . '/' . <WP_SEO_PLUGIN_PATH> . '/'

I suspect the problem lies with the derivation of <WP_SEO_PLUGIN_PATH>. This value is determined by the code in the function plugins_url() found in wp-includes\link-template.php

If you debug that function, it may yield the reason why <WP_SEO_PLUGIN_PATH> is producing the wrong value: 'nfs/c08/h04/mnt/152547/domains/craigmdennis.com/html/content/plugins/wordpress-seo'

KalenGi
  • 665
  • 7
  • 18
0

The error is the result of the php __FILE__ resolving any aliases or symlinks on the server.

The solution is to set define('WP_CONTENT_DIR', dirname(__FILE__) . '/content'); so it is also the absolute file path on the server after resolving aliases.

See: http://php.net/manual/en/language.constants.predefined.php#104842

Craig
  • 164
  • 2
  • 13