Code Duplication    Length = 24-24 lines in 2 locations

classes/fields/link.php 1 location

@@ 437-460 (lines=24) @@
434
     *
435
     * @return string
436
     */
437
    public function build_url ( $url ) {
438
        if ( function_exists( 'http_build_url' ) )
439
            return http_build_url( $url );
440
441
        $defaults = array(
442
            'scheme' => 'http',
443
            'host' => '',
444
            'path' => '/',
445
            'query' => '',
446
            'fragment' => ''
447
        );
448
449
        $url = array_merge( $defaults, (array) $url );
450
451
        $new_url = trim( $url[ 'scheme' ] . '://', ':' ) . $url[ 'host' ] . '/' . ltrim( $url[ 'path' ], '/' );
452
453
        if ( !empty( $url[ 'query' ] ) )
454
            $new_url .= '?' . ltrim( $url[ 'query' ], '?' );
455
456
        if ( !empty( $url[ 'fragment' ] ) )
457
            $new_url .= '#' . ltrim( $url[ 'fragment' ], '#' );
458
459
        return $new_url;
460
    }
461
	
462
463
    /**

classes/fields/website.php 1 location

@@ 358-381 (lines=24) @@
355
     *
356
     * @return string
357
     */
358
    public function build_url ( $url ) {
359
        if ( function_exists( 'http_build_url' ) )
360
            return http_build_url( $url );
361
362
        $defaults = array(
363
            'scheme' => 'http',
364
            'host' => '',
365
            'path' => '/',
366
            'query' => '',
367
            'fragment' => ''
368
        );
369
370
        $url = array_merge( $defaults, (array) $url );
371
372
        $new_url = trim( $url[ 'scheme' ] . '://', ':' ) . $url[ 'host' ] . '/' . ltrim( $url[ 'path' ], '/' );
373
374
        if ( !empty( $url[ 'query' ] ) )
375
            $new_url .= '?' . ltrim( $url[ 'query' ], '?' );
376
377
        if ( !empty( $url[ 'fragment' ] ) )
378
            $new_url .= '#' . ltrim( $url[ 'fragment' ], '#' );
379
380
        return $new_url;
381
    }
382
}
383