Skip to content

Commit

Permalink
fix(EventConverter): fix incompatibility with WP_Hook since WP 4.7
Browse files Browse the repository at this point in the history
  • Loading branch information
whizark committed Feb 10, 2017
1 parent a5b8c5f commit 8e6d7a9
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Devaloka\Component\EventConverter\FilterFunction;
use Devaloka\Component\EventConverter\EventConverter;
use WP_Hook;

/**
* Class EventConverterListener
Expand Down Expand Up @@ -57,8 +58,11 @@ public function onAll($tag)
continue;
}

foreach ($GLOBALS['wp_filter'][$eventName] as $priority => $indices) {
foreach ($indices as $index => $value) {
/** @var WP_Hook $hooks */
$hook = $GLOBALS['wp_filter'][$eventName];

foreach ($hook as $priority => $callbacks) {
foreach ($callbacks as $index => $value) {
if ($value['function'] === [$this, __FUNCTION__]) {
continue;
}
Expand All @@ -72,12 +76,12 @@ public function onAll($tag)
$value['accepted_args']
);

$GLOBALS['wp_filter'][$eventName][$priority][$index]['function'] = $this->converter->create(
$callbacks[$priority][$index]['function'] = $this->converter->create(
current_filter(),
$filterFunction
);

$GLOBALS['wp_filter'][$eventName][$priority][$index]['_devaloka_event_converter'] = true;
$callbacks[$priority][$index]['_devaloka_event_converter'] = true;
}
}
}
Expand Down

0 comments on commit 8e6d7a9

Please sign in to comment.