Make WordPress Core

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#2652 closed defect (bug) (invalid)

category_exists() checks using slug

Reported by: Viper007Bond Owned by:
Milestone: Priority: lowest
Severity: trivial Version: 2.0.2
Component: Administration Keywords:
Focuses: Cc:


Okay, maybe I'm missing something, but I noticed when you give category_exists() a category name, it creates a sanitized version of that name (i.e. what it's slug would be) and then sees if there are any categories that already have that slug. However, you can change the slugs for categories in the admin area to something completely different than the category name.

Now is category_exists() really just used to see if a category slug exists? Or is it just checking in a bad method?

Change History (4)

#1 @Viper007Bond
12 years ago

  • Priority changed from normal to lowest
  • Severity changed from normal to trivial

Er, meant to hit preview rather than submit.

Anyway, if it is just used to check for slug collisions, shouldn't this be called like "category_slug_exists()" or something? I was going to use this function for a script I'm writing that manually creates posts and any needed categories, but I want to check my category name, not the slug (I'm currently manually querying).

#2 @Viper007Bond
12 years ago

I really need an edit button and to not submit tickets so late at night. :|

What I meant in my original ticket post:

"Now is category_exists() really just used to see if a category slug exists (so no slug collisions occur)? Or is it just checking via what appears to be a bad method?

#3 @Viper007Bond
12 years ago

  • Resolution set to invalid
  • Status changed from new to closed

Er, I'm an idiot. wp-hackers is the place for this kinda thing. I'll start a discussion on this there.


#4 @ryan
12 years ago

Maybe add slug as an optional second arg and check both name and slug for uniqueness.

category_exists($cat_name, $cat_slug = '')
Note: See TracTickets for help on using tickets.