Make WordPress Core

Ticket #23636: 23636.2.patch

File 23636.2.patch, 1.8 KB (added by dlh, 11 years ago)
  • src/wp-includes/taxonomy.php

     
    18041804        }
    18051805
    18061806        if ( ! empty( $args['slug'] ) ) {
    1807                 $slug = sanitize_title( $args['slug'] );
    1808                 $where .= " AND t.slug = '$slug'";
     1807                if ( is_array( $args['slug'] ) ) {
     1808                        $slug = array_map( 'sanitize_title', $args['slug'] );
     1809                        $where .= " AND t.slug IN ('" . implode( "', '", $slug ) . "')";
     1810                } else {
     1811                        $slug = sanitize_title( $args['slug'] );
     1812                        $where .= " AND t.slug = '$slug'";
     1813                }
    18091814        }
    18101815
    18111816        if ( ! empty( $args['name__like'] ) ) {
  • tests/phpunit/tests/term/getTerms.php

     
    352352                add_filter( 'wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10, 3 );
    353353        }
    354354
     355        function test_get_terms_by_slug() {
     356                $foo = $this->factory->tag->create( array( 'slug' => 'foo' ) );
     357
     358                $found = get_terms( 'post_tag', array(
     359                        'hide_empty' => false,
     360                        'fields' => 'ids',
     361                        'slug' => 'foo',
     362                ) );
     363
     364                $this->assertEquals( array( $foo ), $found );
     365        }
     366
     367        function test_get_terms_by_multiple_slugs() {
     368                $foo = $this->factory->tag->create( array( 'slug' => 'foo' ) );
     369                $bar = $this->factory->tag->create( array( 'slug' => 'bar' ) );
     370
     371                $found = get_terms( 'post_tag', array(
     372                        'hide_empty' => false,
     373                        'fields' => 'ids',
     374                        'slug' => array( 'foo', 'bar' )
     375                ) );
     376
     377                $this->assertEquals( array( $foo, $bar ), $found );
     378        }
     379
    355380        public function test_get_terms_hierarchical_tax_hide_empty_false_fields_ids() {
    356381                // Set up a clean taxonomy.
    357382                $tax = 'hierarchical_fields';