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.



Wordpress feature image page?
24 comments on page 1065

Addsettingsfield?
3 comments on page 793

Shorter link?
4 comments on page 1190

Shorter link?
4 comments on page 1190

Cssimageforlogin?
no comment on page 128

Cssimageforlogin?
no comment on page 128

Get featured image url wordpress?
24 comments on page 1065

How to clear wpcache?
9 comments on page 1310

Photo gallry code html5?
6 comments on page 1305

Wordpress get image size?
24 comments on page 1065

Sitecouk wptheme?
2 comments on page 1376

Wordpress chat disqus?
no comment on page 1308

Howtocreategoodsizelayout?
4 comments on page 1026

Friend connect profile?
6 comments on page 1364

Get medium image from post?
24 comments on page 1065

Tabbed widgets wp?
no comment on page 333

Wordpress pictue cache lschen?
9 comments on page 1310

Wordpress plugin post separator?
no comment on page 1371

Display photos html 5?
6 comments on page 1305

Fun wordpress themes?
2 comments on page 1376

Wp featured image without size?
24 comments on page 1065

Wordpress get url global?
4 comments on page 1190

Wp unlimited?
3 comments on page 1141

Html5 image gallery?
6 comments on page 1305

Wordpress exif plugin?
12 comments on page 230

Css login screen?
no comment on page 128

Htlm 5 photo gallery?
6 comments on page 1305

Image gallery html 5?
6 comments on page 1305

Css login screen?
no comment on page 128

Comments by intensedebate?
7 comments on page 1175

Wordpress andrew rickmann?
2 comments on page 1376

Wordpress medium large?
24 comments on page 1065

Fun with uninstallation wordpress?
53 comments on page 100

How to clear wp cache?
9 comments on page 1310

Html5 gallery?
6 comments on page 1305

Photoshop frameworks?
3 comments on page 296

Wordpress post multiple images?
24 comments on page 1065

Html 5 photo gallery?
6 comments on page 1305

Login screen css template?
no comment on page 128

Html5 photo gallery code?
6 comments on page 1305
  every 2005s, 1s ago, in 0.03s.
 __
(__)
   `
 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.


0s