add wp-rocket
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
namespace WP_Rocket\ServiceProvider;
|
||||
|
||||
use WP_Rocket\Engine\Container\ServiceProvider\AbstractServiceProvider;
|
||||
|
||||
/**
|
||||
* Service provider for WP Rocket features common for admin and front
|
||||
*
|
||||
* @since 3.3
|
||||
* @author Remy Perona
|
||||
*/
|
||||
class Common_Subscribers extends AbstractServiceProvider {
|
||||
|
||||
/**
|
||||
* The provides array is a way to let the container
|
||||
* know that a service is provided by this service
|
||||
* provider. Every service that is registered via
|
||||
* this service provider must have an alias added
|
||||
* to this array or it will be ignored.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $provides = [
|
||||
'db_optimization_subscriber',
|
||||
'webp_subscriber',
|
||||
'expired_cache_purge',
|
||||
'expired_cache_purge_subscriber',
|
||||
'detect_missing_tags',
|
||||
];
|
||||
|
||||
/**
|
||||
* Registers the subscribers in the container
|
||||
*
|
||||
* @since 3.3
|
||||
* @author Remy Perona
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register() {
|
||||
$options = $this->getContainer()->get( 'options' );
|
||||
|
||||
$this->getContainer()->share( 'db_optimization_subscriber', 'WP_Rocket\Subscriber\Admin\Database\Optimization_Subscriber' )
|
||||
->withArgument( $this->getContainer()->get( 'db_optimization' ) )
|
||||
->withArgument( $options );
|
||||
$this->getContainer()->add( 'expired_cache_purge', 'WP_Rocket\Cache\Expired_Cache_Purge' )
|
||||
->withArgument( rocket_get_constant( 'WP_ROCKET_CACHE_PATH' ) );
|
||||
$this->getContainer()->share( 'expired_cache_purge_subscriber', 'WP_Rocket\Subscriber\Cache\Expired_Cache_Purge_Subscriber' )
|
||||
->withArgument( $options )
|
||||
->withArgument( $this->getContainer()->get( 'expired_cache_purge' ) );
|
||||
$this->getContainer()->share( 'webp_subscriber', 'WP_Rocket\Subscriber\Media\Webp_Subscriber' )
|
||||
->withArgument( $options )
|
||||
->withArgument( $this->getContainer()->get( 'options_api' ) )
|
||||
->withArgument( $this->getContainer()->get( 'cdn_subscriber' ) )
|
||||
->withArgument( $this->getContainer()->get( 'beacon' ) );
|
||||
$this->getContainer()->share( 'detect_missing_tags_subscriber', 'WP_Rocket\Subscriber\Tools\Detect_Missing_Tags_Subscriber' );
|
||||
}
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
namespace WP_Rocket\ServiceProvider;
|
||||
|
||||
use WP_Rocket\Engine\Container\ServiceProvider\AbstractServiceProvider;
|
||||
|
||||
/**
|
||||
* Service Provider for database optimization
|
||||
*
|
||||
* @since 3.3
|
||||
* @author Remy Perona
|
||||
*/
|
||||
class Database extends AbstractServiceProvider {
|
||||
|
||||
/**
|
||||
* The provides array is a way to let the container
|
||||
* know that a service is provided by this service
|
||||
* provider. Every service that is registered via
|
||||
* this service provider must have an alias added
|
||||
* to this array or it will be ignored.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $provides = [
|
||||
'db_optimization_process',
|
||||
'db_optimization',
|
||||
];
|
||||
|
||||
/**
|
||||
* Registers the option array in the container
|
||||
*
|
||||
* @since 3.3
|
||||
* @author Remy Perona
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register() {
|
||||
$this->getContainer()->add( 'db_optimization_process', 'WP_Rocket\Admin\Database\Optimization_Process' );
|
||||
$this->getContainer()->add( 'db_optimization', 'WP_Rocket\Admin\Database\Optimization' )
|
||||
->withArgument( $this->getContainer()->get( 'db_optimization_process' ) );
|
||||
}
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
namespace WP_Rocket\ServiceProvider;
|
||||
|
||||
use WP_Rocket\Engine\Container\ServiceProvider\AbstractServiceProvider;
|
||||
|
||||
/**
|
||||
* Service provider for the WP Rocket options
|
||||
*
|
||||
* @since 3.3
|
||||
* @author Remy Perona
|
||||
*/
|
||||
class Options extends AbstractServiceProvider {
|
||||
|
||||
/**
|
||||
* The provides array is a way to let the container
|
||||
* know that a service is provided by this service
|
||||
* provider. Every service that is registered via
|
||||
* this service provider must have an alias added
|
||||
* to this array or it will be ignored.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $provides = [
|
||||
'options',
|
||||
];
|
||||
|
||||
/**
|
||||
* Registers the option array in the container
|
||||
*
|
||||
* @since 3.3
|
||||
* @author Remy Perona
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register() {
|
||||
$this->getContainer()->add( 'options', 'WP_Rocket\Admin\Options_Data' )
|
||||
->withArgument( $this->getContainer()->get( 'options_api' )->get( 'settings', [] ) );
|
||||
}
|
||||
}
|
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
namespace WP_Rocket\ServiceProvider;
|
||||
|
||||
use WP_Rocket\Engine\Container\ServiceProvider\AbstractServiceProvider;
|
||||
|
||||
/**
|
||||
* Service provider for the WP Rocket updates.
|
||||
*
|
||||
* @since 3.3.6
|
||||
* @author Grégory Viguier
|
||||
*/
|
||||
class Updater_Subscribers extends AbstractServiceProvider {
|
||||
|
||||
/**
|
||||
* The provided array is a way to let the container
|
||||
* know that a service is provided by this service
|
||||
* provider. Every service that is registered via
|
||||
* this service provider must have an alias added
|
||||
* to this array or it will be ignored.
|
||||
*
|
||||
* @var array
|
||||
* @since 3.3.6
|
||||
* @access protected
|
||||
* @author Grégory Viguier
|
||||
*/
|
||||
protected $provides = [
|
||||
'plugin_updater_common_subscriber',
|
||||
'plugin_information_subscriber',
|
||||
'plugin_updater_subscriber',
|
||||
];
|
||||
|
||||
/**
|
||||
* Registers the option array in the container.
|
||||
*
|
||||
* @since 3.3.6
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*/
|
||||
public function register() {
|
||||
$api_url = wp_parse_url( WP_ROCKET_WEB_INFO );
|
||||
|
||||
$this->getContainer()->add( 'plugin_updater_common_subscriber', 'WP_Rocket\Subscriber\Plugin\Updater_Api_Common_Subscriber' )
|
||||
->withArgument(
|
||||
[
|
||||
'api_host' => $api_url['host'],
|
||||
'site_url' => home_url(),
|
||||
'plugin_version' => WP_ROCKET_VERSION,
|
||||
'settings_slug' => WP_ROCKET_SLUG,
|
||||
'settings_nonce_key' => WP_ROCKET_PLUGIN_SLUG,
|
||||
'plugin_options' => $this->getContainer()->get( 'options' ),
|
||||
]
|
||||
);
|
||||
$this->getContainer()->add( 'plugin_information_subscriber', 'WP_Rocket\Subscriber\Plugin\Information_Subscriber' )
|
||||
->withArgument(
|
||||
[
|
||||
'plugin_file' => WP_ROCKET_FILE,
|
||||
'api_url' => WP_ROCKET_WEB_INFO,
|
||||
]
|
||||
);
|
||||
$this->getContainer()->add( 'plugin_updater_subscriber', 'WP_Rocket\Subscriber\Plugin\Updater_Subscriber' )
|
||||
->withArgument(
|
||||
[
|
||||
'plugin_file' => WP_ROCKET_FILE,
|
||||
'plugin_version' => WP_ROCKET_VERSION,
|
||||
'vendor_url' => WP_ROCKET_WEB_MAIN,
|
||||
'api_url' => WP_ROCKET_WEB_CHECK,
|
||||
'icons' => [
|
||||
'2x' => WP_ROCKET_ASSETS_IMG_URL . 'icon-256x256.png',
|
||||
'1x' => WP_ROCKET_ASSETS_IMG_URL . 'icon-128x128.png',
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user