1 | <?php |
||
2 | class No_Iframes extends Plugin { |
||
3 | private $host; |
||
4 | |||
5 | public function about() { |
||
6 | return array(1.0, |
||
7 | "Remove embedded iframes (unless whitelisted)", |
||
8 | "fox"); |
||
9 | } |
||
10 | |||
11 | public function init($host) { |
||
12 | $this->host = $host; |
||
13 | |||
14 | $host->add_hook($host::HOOK_SANITIZE, $this); |
||
15 | } |
||
16 | |||
17 | /** |
||
18 | * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
||
19 | */ |
||
20 | public function hook_sanitize($doc, $site_url, $allowed_elements, $disallowed_attributes) { |
||
0 ignored issues
–
show
|
|||
21 | |||
22 | $xpath = new DOMXpath($doc); |
||
23 | $entries = $xpath->query('//iframe'); |
||
24 | |||
25 | foreach ($entries as $entry) { |
||
26 | if (!iframe_whitelisted($entry)) { |
||
27 | $entry->parentNode->removeChild($entry); |
||
28 | } |
||
29 | } |
||
30 | |||
31 | return array($doc, $allowed_elements, $disallowed_attributes); |
||
32 | } |
||
33 | |||
34 | public function api_version() { |
||
35 | return 2; |
||
36 | } |
||
37 | |||
38 | } |
||
39 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.