July 3, 2008
In WordPress 2.6 a lot of plugins could fail if they are not updated. The changes are explained by Ozh in What plugin coders know about WordPress 2.6.
The change allows WordPress users to move their config file and the contents of the wp-content folder to a different directory, which seems like a good move for security purposes but can make it difficult to code for since you often need to know where these files are before you can access any WordPress variables.
I need to update all my plugins, that’s a given, but I also need to update the plugin generator. I think I have a handy solution but I want to open it up to feedback before I make any changes.
My solution is to use the following function which will check each directory for the presence of either of the critical files, wp-load.php or wp-config.php; for example:
[php]
function get_config(){
$root = dirname(__FILE__);
while(!file_exists($root.'/wp-load.php') && !file_exists($root.'/wp-config.php')){
$root = dirname($root)
}
return $root;
}
I think it is also worth checking the plugin directory, i.e. the directory that is wp-content/plugins/ by default for a specifically named text file, perhaps plugin-paths.txt or similar so that the information can be provided manually by the blog owner.
I would appreciate any thoughts you might have on this.
Post Image The Easy Peasy Way
26 comments
page 1065
Html 5 Gallery
6 comments
page 1305
Post Image The Easy Peasy Way
26 comments
page 1065
Post Image The Easy Peasy Way
26 comments
page 1065
Using Your Own Url Shortener
4 comments
page 1190
Dont Mess With My Toot Toot
16 comments
page 599
Quick N Dirty Admin Login Screen
no comment
page 128
Using Your Own Url Shortener
4 comments
page 1190
Post Image The Easy Peasy Way
26 comments
page 1065
Theming Habari Vs Wordpress
13 comments
page 440
Are Child Themes The Best Option
15 comments
page 1262
Upload From Url
6 comments
page 326
Silence Is Golden
3 comments
page 213
Fun With Sidebar Tabs Styling
2 comments
page 336
Using Your Own Url Shortener
4 comments
page 1190
Wordpress 25 Exif Fields
12 comments
page 230
Html 5 Gallery
6 comments
page 1305
Dont Mess With My Toot Toot
16 comments
page 599
Dont Mess With My Toot Toot
16 comments
page 599
Converting Wordpress Themes To Habari
one comment
page 694
Wordpress 25 Exif Fields
12 comments
page 230
Fun With Sidebar Tabs Styling
2 comments
page 336
Using Your Own Url Shortener
4 comments
page 1190
Post Image The Easy Peasy Way
26 comments
page 1065
How To Add Sidebars To A Theme
10 comments
page 1053
Using Your Own Url Shortener
4 comments
page 1190
Html 5 Gallery
6 comments
page 1305
Dont Mess With My Toot Toot
16 comments
page 599
Quick N Dirty Replacement Text
no comment
page 122
1 query every 1972 seconds, updated 1 seconds ago.
(__)
`
Andrew Rickmann
Oliver, thanks for the link, but those examples don’t address the situation where you need to find include the config file manually, e.g. if you are responding to ajax requests.
Chris, thanks for that. You are right, that’s what I get for rushing my posts.
(__)
`
Chris
I think that your loop would need an emergency break in case in fails to find either one of the two files up the tree like so:
while ($root && $root != '.' && !file_exists($root.'/wp-load.php' ...)
(__)
`
Oliver
I recently found some helpful code examples here.
It`s German but it may help you to change your configuration so that you can simply change the plugin path for all the plugins you are currently making use of.