diff --git a/system/Filters/Filters.php b/system/Filters/Filters.php index 38d0fd8183ab..cd7bcbb15574 100644 --- a/system/Filters/Filters.php +++ b/system/Filters/Filters.php @@ -264,19 +264,25 @@ public function runRequired(string $position = 'before') } // Set the toolbar filter to the last position to be executed - if ( - in_array('toolbar', $this->config->required['after'], true) - && ($count = count($this->config->required['after'])) > 1 - && $this->config->required['after'][$count - 1] !== 'toolbar' - ) { - array_splice( - $this->config->required['after'], - array_search('toolbar', $this->config->required['after'], true), - 1 - ); - $this->config->required['after'][] = 'toolbar'; + $afters = []; + $found = false; + + foreach ($this->config->required['after'] as $alias) { + if ($alias === 'toolbar') { + $found = true; + + continue; + } + + $afters[] = $alias; } + if ($found) { + $afters[] = 'toolbar'; + } + + $this->config->required['after'] = $afters; + $filterClasses = []; foreach ($this->config->required[$position] as $alias) {