Make WordPress Core

Ticket #24354: 24354.3.diff

File 24354.3.diff, 1.1 KB (added by MikeHansenMe, 8 years ago)
  • src/wp-includes/category-functions.php

     
    171171 * @return int 0, if failure and ID of category on success.
    172172 */
    173173function get_cat_ID( $cat_name ) {
     174        $cat_name = _wp_specialchars( $cat_name ); // get_term_by expects $cat_name to be escaped
    174175        $cat = get_term_by( 'name', $cat_name, 'category' );
    175         if ( $cat )
     176        if ( $cat ) {
    176177                return $cat->term_id;
     178        }
    177179        return 0;
    178180}
    179181
  • tests/phpunit/tests/taxonomy.php

     
    482482
    483483                $this->assertFalse( is_tax( 'wptests_tax' ) );
    484484        }
     485
     486        /**
     487         *      @ticket 24354
     488         */
     489        function test_cat_has_ampersand() {
     490                $name = 'News & Press';
     491                $expected = wp_create_category( $name );
     492                $this->assertEquals( $expected, get_cat_id( $name ) );
     493        }
    485494}