Make WordPress Core

Ticket #24354: 24354.2.diff

File 24354.2.diff, 1.0 KB (added by MikeHansenMe, 11 years ago)

Tests and refresh of patch

  • tests/phpunit/tests/taxonomy.php

     
    234234                );
    235235                $this->assertEquals( 0, wp_insert_category( $cat, false ) );
    236236        }
     237
     238        /**
     239         *      @ticket 24354
     240         */
     241        function test_cat_has_ampersand() {
     242                $name = 'News & Press';
     243                $expected = wp_create_category( $name );
     244                $this->assertEquals( $expected, get_cat_id( $name ) );
     245        }
    237246}
  • src/wp-includes/category.php

     
    168168 * @return int 0, if failure and ID of category on success.
    169169 */
    170170function get_cat_ID( $cat_name ) {
     171        $cat_name = _wp_specialchars( $cat_name ); // get_term_by expects $cat_name to be escaped
    171172        $cat = get_term_by( 'name', $cat_name, 'category' );
    172173        if ( $cat )
    173174                return $cat->term_id;