Split functionality from container to manager classes.

This commit is contained in:
Andrey Savchenko committed 2018-02-12 17:02:17 +02:00
1 parent 2c074c1cea
commit 67d686f601
4 files changed
+165 -96

No files matched your search

+46
View File
@@ -0,0 +1,46 @@
<?php
namespace Rarst\Laps\Manager;
use Pimple\Container;
use Pimple\ServiceProviderInterface;
use Rarst\Laps\Bootable_Provider_Interface;
use Rarst\Laps\Laps;
/**
* Reorders
*/
class Load_Order_Manager implements ServiceProviderInterface, Bootable_Provider_Interface {
public function register( Container $pimple ) {
}
public function boot( Laps $laps ) {
add_action( 'pre_update_option_active_plugins', [ $this, 'pre_update_option_active_plugins' ] );
add_action( 'pre_update_site_option_active_sitewide_plugins', [ $this, 'pre_update_option_active_plugins' ] );
}
/**
* Reorder active plugins so Laps is first and starts timing load early.
*
* @param array $plugins
*
* @return array
*/
public function pre_update_option_active_plugins( $plugins ) {
$plugin = plugin_basename( dirname( dirname( __DIR__ ) ) . '/laps.php' );
$key = array_search( $plugin, $plugins, true );
if ( false !== $key && $key > 0 ) {
unset( $plugins[ $key ] );
array_unshift( $plugins, $plugin );
$plugins = array_values( $plugins );
}
return $plugins;
}
}