WordPress.org

Make WordPress Core

Ticket #11737: 11737.diff

File 11737.diff, 548 bytes (added by nacin, 8 years ago)

I chose null here, but false or an empty string might make more sense.

  • category.php

     
    178178 * @since 1.0.0
    179179 *
    180180 * @param int $cat_id Category ID
    181  * @return string Category name
     181 * @return string|null Category name, or null if category doesn't exist.
    182182 */
    183183function get_cat_name( $cat_id ) {
    184184        $cat_id = (int) $cat_id;
    185185        $category = &get_category( $cat_id );
     186        if ( ! $category || is_wp_error( $category ) )
     187                return null;
    186188        return $category->name;
    187189}
    188190