Container
1 week ago
UI
1 week ago
ActionFilterLoader.php
1 week ago
DependencyAssets.php
1 week ago
IStandAloneAction.php
4 years ago
NullSitePress.php
1 week ago
ActionFilterLoader.php
34 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WCML\StandAlone; |
| 4 | |
| 5 | use WPML_Action_Filter_Loader; |
| 6 | |
| 7 | use function WCML\functions\isStandAlone; |
| 8 | |
| 9 | class ActionFilterLoader { |
| 10 | |
| 11 | private $loader; |
| 12 | |
| 13 | public function __construct( $loader = null ) { |
| 14 | $this->loader = null === $loader ? new WPML_Action_Filter_Loader() : $loader; |
| 15 | } |
| 16 | |
| 17 | public function load( $loaders ) { |
| 18 | $this->loader->load( $this->mayBeFilterLoaders( $loaders ) ); |
| 19 | } |
| 20 | |
| 21 | private function mayBeFilterLoaders( $loaders ) { |
| 22 | if ( isStandAlone() ) { |
| 23 | $filtered_loaders = []; |
| 24 | foreach ( $loaders as $loader ) { |
| 25 | if ( is_subclass_of( $loader, IStandAloneAction::class ) ) { |
| 26 | $filtered_loaders[] = $loader; |
| 27 | } |
| 28 | } |
| 29 | return $filtered_loaders; |
| 30 | } |
| 31 | return $loaders; |
| 32 | } |
| 33 | } |
| 34 |