forked from Codeinwp/wp-product-review
-
Notifications
You must be signed in to change notification settings - Fork 0
/
class-wppr-recursive-filter.php
55 lines (48 loc) · 1.17 KB
/
class-wppr-recursive-filter.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/**
* Used for filtering autoloader files. Compatible with PHP 5.3 and 5.2
*
* Author: Andrei Baicus <[email protected]>
* Created on: 18/07/2018
*
* @soundtrack D.O.A. (Death of Auto-Tune) - JAY-Z
* @package Hestia
*/
/**
* Class Wppr_Recursive_Filter
*/
class Wppr_Recursive_Filter extends RecursiveFilterIterator {
/**
* Callback function.
*
* @var string
*/
public $callback;
/**
* Hestia_Recursive_Filter constructor.
*
* @param RecursiveIterator $iterator file iterator.
* @param callable $callback callback function.
*/
public function __construct( RecursiveIterator $iterator, $callback ) {
$this->callback = $callback;
parent::__construct( $iterator );
}
/**
* Run the filter.
*
* @return bool
*/
public function accept() {
$callback = $this->callback;
return call_user_func_array( $callback, array( parent::current(), parent::key(), parent::getInnerIterator() ) );
}
/**
* Get the children from iterator.
*
* @return Wppr_Recursive_Filter|RecursiveFilterIterator
*/
public function getChildren() {
return new self( $this->getInnerIterator()->getChildren(), $this->callback );
}
}