Completed
Push — componentlibrary ( f49604...c525d2 )
by Markus
01:55
created

functions.php ➔ setNoCookieDomain()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 2
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
1
<?php
2
3
namespace Flynt\Features\YoutubeNoCookieEmbed;
4
5
use Flynt\Utils\Oembed;
6
7
add_action('oembed_result', 'Flynt\Features\YoutubeNoCookieEmbed\setNoCookieDomain', 10, 2);
8
add_filter('embed_oembed_html', 'Flynt\Features\YoutubeNoCookieEmbed\setNoCookieDomain', 10, 2);
9
10
function setNoCookieDomain($searchString, $url)
0 ignored issues
show
Unused Code introduced by
The parameter $url is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
11
{
12
    if (preg_match('#https?://(www\.)?youtube\.com#i', $searchString)) {
13
        $searchString = preg_replace(
14
            '#(https?:)?//(www\.)?youtube\.com#i',
15
            '$1//$2youtube-nocookie.com',
16
            $searchString
17
        );
18
    }
19
20
    return $searchString;
21
}
22