WordPress.org

Make WordPress Core

Ticket #11737: 11737.2.diff

File 11737.2.diff, 586 bytes (added by nacin, 4 years ago)

Empty string makes far 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 Category name, or an empty string 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 ''; 
    186188        return $category->name; 
    187189}