Make WordPress Core

Ticket #35582: 35582.1.diff

File 35582.1.diff, 1.7 KB (added by danielbachhuber, 9 years ago)
  • src/wp-includes/functions.php

    diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php
    index fb2d20f..a5a1d55 100644
    a b function wp_parse_id_list( $list ) { 
    32763276}
    32773277
    32783278/**
     3279 * Clean up an array, comma- or space-separated list of slugs.
     3280 *
     3281 * @since 4.5.0
     3282 *
     3283 * @param array|string $list List of slugs.
     3284 * @return array Sanitized array of slugs.
     3285 */
     3286function wp_parse_slug_list( $list ) {
     3287        if ( ! is_array( $list ) ) {
     3288                $list = preg_split( '/[\s,]+/', $list );
     3289        }
     3290
     3291        foreach( $list as $key => $value ) {
     3292                $list[ $key ] = sanitize_title( $value );
     3293        }
     3294
     3295        return array_unique( $list );
     3296}
     3297
     3298/**
    32793299 * Extract a slice of an array, given a list of keys.
    32803300 *
    32813301 * @since 3.1.0
  • tests/phpunit/tests/functions.php

    diff --git a/tests/phpunit/tests/functions.php b/tests/phpunit/tests/functions.php
    index 631b303..987a900 100644
    a b class Tests_Functions extends WP_UnitTestCase { 
    412412        }
    413413
    414414        /**
     415         * @dataProvider data_wp_parse_slug_list
     416         */
     417        function test_wp_parse_slug_list( $expected, $actual ) {
     418                $this->assertSame( $expected, array_values( wp_parse_slug_list( $actual ) ) );
     419        }
     420
     421        function data_wp_parse_slug_list() {
     422                return array(
     423                        array( array( 'apple', 'banana', 'carrot', 'dog' ), 'apple,banana,carrot,dog' ),
     424                        array( array( 'apple', 'banana', 'carrot', 'dog' ), 'apple, banana,,carrot,dog' ),
     425                        array( array( 'apple', 'banana', 'carrot', 'dog' ), 'apple banana carrot dog' ),
     426                        array( array( 'apple', 'banana-carrot', 'd-o-g' ), array( 'apple ', 'banana carrot', 'd o g' ) ),
     427                );
     428        }
     429
     430        /**
    415431         * @ticket 19354
    416432         */
    417433        function test_data_is_not_an_allowed_protocol() {