Completed
Push — componentlibrary ( 67a692...eed31d )
by Doğa
01:48
created

youtubeNoCookieEmbed.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
 * Changes oEmbed YouTube URLs from youtube.com to youtube-nocookie.com in favor of GDPR.
4
 */
5
namespace Flynt\YoutubeNoCookieEmbed;
6
7
use Flynt\Utils\Oembed;
8
9
add_action('oembed_result', 'Flynt\YoutubeNoCookieEmbed\setNoCookieDomain', 10, 2);
10
add_filter('embed_oembed_html', 'Flynt\YoutubeNoCookieEmbed\setNoCookieDomain', 10, 2);
11
12
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...
13
{
14
    if (preg_match('#https?://(www\.)?youtube\.com#i', $searchString)) {
15
        $searchString = preg_replace(
16
            '#(https?:)?//(www\.)?youtube\.com#i',
17
            '$1//$2youtube-nocookie.com',
18
            $searchString
19
        );
20
    }
21
22
    return $searchString;
23
}
24