888888.888888.88""Yb..dP"Yb..8888b..Yb..dP.88b.88....db....8b....d8.88..dP""b8..dP"Y8
88__...88__...88__dP.dP...Yb..8I..Yb.YbdP..88Yb88...dPYb...88b..d88.88.dP...`".`Ybo."
88""...88""...88"Yb..Yb...dP..8I..dY..8P...88.Y88..dP__Yb..88YbdP88.88.Yb......o.`Y8b
88.....888888.88..Yb..YbodP..8888Y"..dP....88..Y8.dP""""Yb.88.YY.88.88..YboodP.8bodP'


88b.88.888888.888888.Yb........dP.dP"Yb..88""Yb.88..dP
88Yb88.88__.....88....Yb..db..dP.dP...Yb.88__dP.88odP.
88.Y88.88"".....88.....YbdPYbdP..Yb...dP.88"Yb..88"Yb.
88..Y8.888888...88......YP..YP....YbodP..88..Yb.88..Yb

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
Resizing images in thecontent?
26 comments
page 1065
Html 5 Gallery
Html 5 photo gallery?
6 comments
page 1305
Post Image The Easy Peasy Way
Wordpress first image gallery?
26 comments
page 1065
Post Image The Easy Peasy Way
Inserting an image url in comments?
26 comments
page 1065
Post Image The Easy Peasy Way
Wp attachment functions?
26 comments
page 1065
Using Your Own Url Shortener
String shortner?
4 comments
page 1190
Dont Mess With My Toot Toot
Wordpress custom content?
16 comments
page 599
Quick N Dirty Admin Login Screen
My admin login page?
no comment
page 128
Using Your Own Url Shortener
How to build a shortner link?
4 comments
page 1190
Post Image The Easy Peasy Way
Get post attacments?
26 comments
page 1065
Theming Habari Vs Wordpress
Habari vs wordpress?
13 comments
page 440
Are Child Themes The Best Option
Wp child themes?
15 comments
page 1262
Upload From Url
Upload to url?
6 comments
page 326
Silence Is Golden
Silence is golden wordpress?
3 comments
page 213
How To Add Sidebars To A Theme
Html hot add a side bar?
10 comments
page 1053
How To Add Sidebars To A Theme
How to add picture to the wordpress sidebar on sidebarphp?
10 comments
page 1053
Fun With Sidebar Tabs Styling
Position of the tabs thematic?
2 comments
page 336
Using Your Own Url Shortener
Short url?
4 comments
page 1190
Why I Ditched Disqus
Styling disqus widgets?
5 comments
page 1175
Wordpress 25 Exif Fields
Wordpress exif?
12 comments
page 230
Html 5 Gallery
Html 5 gallery?
6 comments
page 1305
Dont Mess With My Toot Toot
Fun with toots?
16 comments
page 599
Dont Mess With My Toot Toot
Fun with toots?
16 comments
page 599
Converting Wordpress Themes To Habari
Habari timthumb?
one comment
page 694
Wordpress 25 Exif Fields
Habari timthumb?
12 comments
page 230
Fun With Sidebar Tabs Styling
Tabs with html css on same page javascript?
2 comments
page 336
Using Your Own Url Shortener
How to have own url short?
4 comments
page 1190
Post Image The Easy Peasy Way
Insert conditional image php wp?
26 comments
page 1065
How To Add Sidebars To A Theme
Wordpress sidebar above main sidebars?
10 comments
page 1053
Using Your Own Url Shortener
Run short url using htaccess?
4 comments
page 1190
Html 5 Gallery
Html5 simple wordpress theme?
6 comments
page 1305
Dont Mess With My Toot Toot
New posttype not displayed wordpress?
16 comments
page 599
Quick N Dirty Replacement Text
Wpupdatepost object?
no comment
page 122
  1 query every 1972 seconds, updated 1 seconds ago.
Thursday, 12pm
 __
(__)
   `

 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.

Thursday, 10am
 __
(__)
   `

 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' ...)

Thursday, 10am
 __
(__)
   `

 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.