[wp-testers] Deleting Categories
Owen Winkler
ringmaster at midnightcircus.com
Fri Nov 18 15:05:11 GMT 2005
Chris Haynes wrote:
> Is adding just a "edit" button for a category that has zero posts in it
> difficult? Does this require a lot of code to write?
Ok - You must first detect whether a category has posts in it. You
can't do that well when the page loads because you might have other
users adding posts while you are editing (maybe not your blog, but
certainly other blogs that use WordPress would have this problem).
So you would need to do that with Ajax. Construct the javascript
structures to make the request to the server, have the server run the
request in PHP to detect any existing posts, and then return a response
- possibly asking if they are sure they want to edit/delete that
category, possibly redirecting them to a new page to perform the edit,
possibly telling them they can't do it because that category has posts.
And what is the app to do if they're in the middle of editing that
post, but they need to redirect to a different page?
This becomes even more challenging with categories that were originally
added via ajax since they will need to have all of those extra event
handlers added to also support the ajax editing. Also, the original
HTML output can't necessarily contain those edit links next to each
category in the list because if the browser doesn't have javascript
enabled, then the links won't work via ajax. Plus, you need to respect
category-editing permissions... Does the scope seem more expansive than
you originally thought?
Yes, it can be done. Yes, it's probably more than 10 lines of code.
In terms of overall difficulty, I'm sure that someone familiar with the
ajax tools that WordPress provides could do it inside an hour or so. I
think there are maybe 3-4 people with that knowledge, though, and it
would still need to be tested more thoroughly because it's been my
experience that nothing written using ajax works perfectly on the first
try. Usually not the second try, either.
I'm not saying the idea is bad - I actually like it. I'm just trying to
put into perspective the work that this type of request would generate,
and why it hasn't suddenly been committed like a lot of other things
have recently.
Owen
More information about the wp-testers
mailing list