diff --git a/README.md b/README.md index 95e4199..8ed73dd 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ Elgg Hooks =============================== -![Elgg 4.3](https://img.shields.io/badge/Elgg-4.3-green.svg?style=flat-square) +![Elgg 5.0](https://img.shields.io/badge/Elgg-5.0-green.svg?style=flat-square) Some hooks for Elgg diff --git a/classes/wZm/Hooks/FilterHooks.php b/classes/wZm/Hooks/FilterHooks.php index f329c4c..914bcb3 100644 --- a/classes/wZm/Hooks/FilterHooks.php +++ b/classes/wZm/Hooks/FilterHooks.php @@ -10,7 +10,7 @@ namespace wZm\Hooks; class FilterHooks { - public function __invoke(\Elgg\Hook $hook) { - elgg_unregister_plugin_hook_handler('sanitize', 'input', \wZm\Hooks\HtmlawedConfig::class); + public function __invoke(\Elgg\Event $event) { + elgg_unregister_event_handler('sanitize', 'input', \wZm\Hooks\HtmlawedConfig::class); } } \ No newline at end of file diff --git a/classes/wZm/Hooks/HtmlawedConfig.php b/classes/wZm/Hooks/HtmlawedConfig.php index 2c7db97..0a42967 100644 --- a/classes/wZm/Hooks/HtmlawedConfig.php +++ b/classes/wZm/Hooks/HtmlawedConfig.php @@ -11,8 +11,8 @@ class HtmlawedConfig { - public function __invoke(\Elgg\Hook $hook) { - $var = $hook->getValue(); + public function __invoke(\Elgg\Event $event) { + $var = $event->getValue(); if ((!is_string($var) && !is_array($var)) || empty($var) || isset($var['params']['head_extend']) || isset($var['params']['footer_extend'])) { return $var; @@ -38,30 +38,30 @@ public function __invoke(\Elgg\Hook $hook) { // apparent this doesn't work. // 'style:color,cursor,text-align,font-size,font-weight,font-style,border,margin,padding,float' ]; - + // add nofollow to all links on output if (!elgg_in_context('input')) { $config['anti_link_spam'] = ['/./', '']; } - $config = elgg_trigger_plugin_hook('config', 'htmlawed', null, $config); - $spec = elgg_trigger_plugin_hook('spec', 'htmlawed', null, ''); + $config = elgg_trigger_event_results('config', 'htmlawed', [], $config); + $spec = elgg_trigger_event_results('spec', 'htmlawed', [], ''); if (!is_array($var)) { return \Htmlawed::filter($var, $config, $spec); - } else { - $callback = function (&$v, $k, $config_spec) { - if (!is_string($v) || empty($v)) { - return; - } - - list ($config, $spec) = $config_spec; - $v = \Htmlawed::filter($v, $config, $spec); - }; - - array_walk_recursive($var, $callback, [$config, $spec]); - - return $var; } + + $callback = function (&$v, $k, $config_spec) { + if (!is_string($v) || empty($v)) { + return; + } + + list ($config, $spec) = $config_spec; + $v = \Htmlawed::filter($v, $config, $spec); + }; + + array_walk_recursive($var, $callback, [$config, $spec]); + + return $var; } } diff --git a/composer.json b/composer.json index 3285f44..101fe75 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,7 @@ } ], "conflict": { - "elgg/elgg": "<4.3", + "elgg/elgg": "<5.0", "subwebz/theme": "*" }, "support": { diff --git a/elgg-plugin.php b/elgg-plugin.php index a135eb2..92b04d1 100644 --- a/elgg-plugin.php +++ b/elgg-plugin.php @@ -3,10 +3,10 @@ return [ 'plugin' => [ 'name' => 'Elgg Hooks', - 'version' => '2.0.0', + 'version' => '3.0.0', ], - 'hooks' => [ + 'events' => [ 'action:validate' => [ 'plugins/settings/save' => [ \wZm\Hooks\FilterHooks::class => ['priority' => 800],