0

I'm going with this git workflow for my current wordpress project which I'm running locally using MAMP. It allows me to separate the WP core files from the theme and plugin folders using submodules, which is great. My wp-config has some extra entries to tell Wordpress where the core files are and where the theme folders are:

if ( !defined('ABSPATH') )
    define('ABSPATH', dirname(__FILE__) . '/wordpress/');

define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] . '/core');
define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/core/wordpress');
define('WP_CONTENT_DIR', realpath(ABSPATH . '../wp-content/'));
define('WP_CONTENT_URL', WP_HOME . '/wp-content');
define('UPLOADS', '../wp-content/uploads');

My structure from the site root looks like:

-wordpress (contains core files)
-wp-content
    -themes
    -plugins
    -uploads
-wp-config.php

So my home url is: http://localhost:8888/core/

The issues I'm running into all over is with the plugins. Some of them are using get_bloginfo('wpurl') to load assets. So an example of that would look like this:

http://localhost:8888/core/wordpress/wp-content/plugins/{PLUGIN}/images/{PLUGIN_IMAGE}.png

where it should actually be:

http://localhost:8888/core/wp-content/plugins/{PLUGIN}/images/{PLUGIN_IMAGE}.png

Can I override this somehow without modifying the plugins individually?

1

bloginfo/get_bloginfo use site_url to retrieve the wpurl value, site_url provides the site_url filter, so you should be able to use that filter to alter the output.

function alter_site_url_wpse_107701($url) {
  return str_replace('/core/wordpress','/core',$url);
}
add_filter('site_url','alter_site_url_wpse_107701');

I am guessing a bit at exactly what you need to replace, but I think that is close.

  • This is what I was looking for pretty much. I only need it to override for plugins, otherwise it will override my whole site. The plugins are the only area causing problems currently. – Jared Eitnier Jul 24 '13 at 19:27
  • With that, you can only control the part of the address returned by site_url, which isn't the entire string. I don't know that you can restrict that only to plugins. I'd have to do some research. – s_ha_dum Jul 24 '13 at 19:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.