flyntwp /
flynt
| 1 | <?php |
||
| 2 | |||
| 3 | /** |
||
| 4 | * Changes oEmbed YouTube URLs from youtube.com to youtube-nocookie.com in favor of GDPR. |
||
| 5 | */ |
||
| 6 | |||
| 7 | namespace Flynt\YoutubeNoCookieEmbed; |
||
| 8 | |||
| 9 | use Flynt\Utils\Oembed; |
||
| 10 | |||
| 11 | add_action('oembed_result', 'Flynt\YoutubeNoCookieEmbed\setNoCookieDomain', 10, 2); |
||
| 12 | add_filter('embed_oembed_html', 'Flynt\YoutubeNoCookieEmbed\setNoCookieDomain', 10, 2); |
||
| 13 | |||
| 14 | function setNoCookieDomain($searchString, $url) |
||
|
0 ignored issues
–
show
|
|||
| 15 | { |
||
| 16 | if (preg_match('#https?://(www\.)?youtube\.com#i', $searchString)) { |
||
| 17 | $searchString = preg_replace( |
||
| 18 | '#(https?:)?//(www\.)?youtube\.com#i', |
||
| 19 | '$1//$2youtube-nocookie.com', |
||
| 20 | $searchString |
||
| 21 | ); |
||
| 22 | } |
||
| 23 | |||
| 24 | return $searchString; |
||
| 25 | } |
||
| 26 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.