Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Is it possible to rename the wp-content folder dynamically? I am building a custom framework to use on themes and it would be nice to set it up where it does everything on its own.

I am using this following code right now in wp-config

define ('WP_CONTENT_DIR','/name_of_new_folder');
define('WP_CONTENT_URL','http://example.com/name_of_new_folder');

Can I pull the site domain through dynamically with PHP?

share|improve this question
add comment

2 Answers

Don't do what seems to be possible...

You can use the possibility to change the WordPress constants WP_CONTENT_DIR and WP_CONTENT_URL in your wp-config.php.

BUT it really, really, really, really is not recommended.

Why? not recommended??

It's pretty easy: Just do a cross file search (with your IDE or for e.g. Notepad++) for wp-content and you'll find it hardcoded it many places. Some of the stuff will still work, but some wont. Yeah, I've already tried that.

share|improve this answer
    
I've read a bunch about it and it seemed the only problem people had was with plugins not working correctly? I believe this is due to bad plugin writing. Is there anything else I should look out for? I'm doing this solely for security reasons. –  ftntravis Nov 15 '12 at 4:15
    
@ftntravis That's security through obscurity, so no real security. Actually there's no real reason to change the name. Aside from poorly coded plugins (the majority), there're things that rely on it. For example other constants like PLUGINDIR or MUPLUGINDIR (both deprecated, but in enough plugins still in use). Then there're points where you'll maybe hit edge cases in core. The MU blogs dir for example. My advice: Just don't do it. It doesn't add any value or security. It just looks different, nothing else. –  kaiser Nov 15 '12 at 8:47
1  
Thank you for the explanation, I appreciate it! And will definitely take it into consideration. –  ftntravis Nov 15 '12 at 18:33
add comment

Figured it out!

define('WP_CONTENT_DIR', ABSPATH . 'name_of_new_folder');
define('WP_CONTENT_URL', 'http://'.$_SERVER['HTTP_HOST'].'/name_of_new_folder');
share|improve this answer
2  
Check if your target directory is_writable() first. Usually it isn’t. –  toscho Nov 11 '12 at 23:53
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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