Skip to content

Commit

Permalink
Updates for Elgg 5
Browse files Browse the repository at this point in the history
  • Loading branch information
RiverVanRain committed Jun 10, 2023
1 parent 2a23c62 commit 7ca9d4c
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
4 changes: 2 additions & 2 deletions classes/wZm/Hooks/FilterHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
36 changes: 18 additions & 18 deletions classes/wZm/Hooks/HtmlawedConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
}
],
"conflict": {
"elgg/elgg": "<4.3",
"elgg/elgg": "<5.0",
"subwebz/theme": "*"
},
"support": {
Expand Down
4 changes: 2 additions & 2 deletions elgg-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down

0 comments on commit 7ca9d4c

Please sign in to comment.