views:

48

answers:

2

I need help in finishing a Wordpress plugin I'm developing. I'm almost finished, but I am experiencing some problems and I can't figure out why I get the errors. I am posting the link to the plugin so you may download and test. I think it's the best way to discover what is wrong


What does it do?

The plugin lets you select a image and stores the image URL in a custom property. You can then retrieve this custom property in your template design.

When you install it, it will add two custom metaboxes to POST and PAGE edit screen in the backend. Each custom property has a button for selecting image. When you click this button, a UI Dialog box opens and displays files and folders.

Once you have selected an image and saved the POST / PAGE, you can retrieve the custom property and use the image url in your template design.

Installation

Just dowload the plugin from here: http://stiengenterprises.com/download/wp-filebrowser

Unzip and copy the folder to you/plugin dir, then activate the plugin.

Known issues

1) 404 Not found

When clicking the 'Get image url' button, jQuery triggers jQuery("#fileBrowser").dialog() which then loads 'fileBrowser.php'.

At line one, I have the following code:
require_once($_SERVER['DOCUMENT_ROOT'].'/wp-blog-header.php');

This is what is causing the 404 Not Found error. This line did not cause any troubles in WP v2.9.1.

2) File upload
I've not been able to use jQuery Form Plugin to uplaod files. I would really like to use this for file Upload. I do not want to use Flash.

I have had a go at it, but no luck :( You can see my Stackoverflow ticket here: http://stackoverflow.com/questions/3707372/does-anyone-have-a-good-example-tutorial-on-how-to-use-jquery-form-upload

I would really really appreciate any help you can give me :)

UPDATE

after testing Todd's suggestion, it works on my local installation of WPMU. But I still receive an error message on my web server:

Warning: require_once(WP_HOME/wp-blog-header.php) [function.require-once]: 
failed to open stream: No such file or directory in 
/home/mysite/wpmu/wp-content/plugins/wp-filebrowser/fileBrowser.php on line 4

Fatal error: require_once() [function.require]: 
Failed opening required 'WP_HOME/wp-blog-header.php' 
(include_path='.:/usr/local/php5/lib/php:/usr/local/lib/php') in 
/home/mysite/wpmu/wp-content/plugins/wp-filebrowser/fileBrowser.php on line 4

Line 4 is require_once(WP_HOME.'/wp-blog-header.php');

+2  A: 

404 Problem:

You do not have to use the

$_SERVER['DOCUMENT_ROOT']

In the WordPress wp-config.php there are the following constant:

define('WP_HOME','http://example.com');

Use these instead and that should fix your problem.

require_once(WP_HOME.'/wp-blog-header.php');

File Upload

This should get you pointed in the right direction: http://ppshein.wordpress.com/2009/05/22/upload-files-with-jquery-ajax-and-php/

Todd Moses
That solved the issue on my local installation of WPMU. But not on my web server. Se above error messge I keep getting.
Steven
You may need to change the WP_HOME constant in your wp-config.php directory on the web server. Check its value to make sure it is correct.
Todd Moses
One thing though. The entire point of including `wp-blog-header.php`, is to have access to WP functions / constants. So how is it that I'm able to use WP_HOME constant if I haven't included the header first?
Steven
A: 

Thanks to Pavel Velikiy, I have fixed the 404 problem. See separate thread here.

The solution was to add header('HTTP/1.1 200 OK') just after require_once.

As for upload part, I'll deal with that later :)

PS. I'm answering my own solution so I can mark it as solved.

Steven