init.php 657 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. class No_Iframes extends Plugin {
  3. private $host;
  4. function about() {
  5. return array(1.0,
  6. "Remove embedded iframes (unless whitelisted)",
  7. "fox");
  8. }
  9. function init($host) {
  10. $this->host = $host;
  11. $host->add_hook($host::HOOK_SANITIZE, $this);
  12. }
  13. function hook_sanitize($doc, $site_url, $allowed_elements, $disallowed_attributes) {
  14. $xpath = new DOMXpath($doc);
  15. $entries = $xpath->query('//iframe');
  16. foreach ($entries as $entry) {
  17. if (!iframe_whitelisted($entry))
  18. $entry->parentNode->removeChild($entry);
  19. }
  20. return array($doc, $allowed_elements, $disallowed_attributes);
  21. }
  22. function api_version() {
  23. return 2;
  24. }
  25. }
  26. ?>