| 1 |
<?php |
| 2 |
/** |
| 3 |
* The provider hooking Admin class methods to WordPress events. |
| 4 |
* |
| 5 |
* @since 0.1.0 |
| 6 |
* |
| 7 |
* @package SolidWP\Performance |
| 8 |
*/ |
| 9 |
|
| 10 |
namespace SolidWP\Performance\Notices; |
| 11 |
|
| 12 |
use SolidWP\Performance\Contracts\Service_Provider; |
| 13 |
use SolidWP\Performance\Notices\Notices\Advanced_Cache; |
| 14 |
use SolidWP\Performance\Notices\Notices\Permalink; |
| 15 |
use SolidWP\Performance\Notices\Notices\Welcome; |
| 16 |
use SolidWP\Performance\Notices\Notices\Wp_Cache_Constant; |
| 17 |
|
| 18 |
if ( ! defined( 'ABSPATH' ) ) { |
| 19 |
exit; |
| 20 |
} |
| 21 |
|
| 22 |
/** |
| 23 |
* The provider for all Admin related functionality. |
| 24 |
* |
| 25 |
* @since 0.1.0 |
| 26 |
* |
| 27 |
* @package SolidWP\Performance |
| 28 |
*/ |
| 29 |
class Provider extends Service_Provider { |
| 30 |
|
| 31 |
/** |
| 32 |
* {@inheritdoc} |
| 33 |
*/ |
| 34 |
public function register(): void { |
| 35 |
add_action( 'admin_notices', $this->container->callback( Permalink::class, 'queue' ), 1 ); |
| 36 |
add_action( 'admin_notices', $this->container->callback( Wp_Cache_Constant::class, 'queue' ), 1 ); |
| 37 |
add_action( 'admin_notices', $this->container->callback( Advanced_Cache::class, 'queue' ), 1 ); |
| 38 |
add_action( 'admin_notices', $this->container->callback( Notice_Handler::class, 'display' ), 100 ); |
| 39 |
|
| 40 |
$this->set_up_welcome_notice(); |
| 41 |
} |
| 42 |
|
| 43 |
/** |
| 44 |
* Only hooks functionality in when the Welcome notice should be displayed. |
| 45 |
* |
| 46 |
* @since 0.1.0 |
| 47 |
* |
| 48 |
* @return void |
| 49 |
*/ |
| 50 |
private function set_up_welcome_notice(): void { |
| 51 |
if ( ! $this->container->get( Welcome::class )->has_been_shown() ) { |
| 52 |
add_filter( 'init', $this->container->callback( Welcome::class, 'maybe_render' ), 10 ); |
| 53 |
add_filter( 'admin_enqueue_scripts', $this->container->callback( Welcome::class, 'enqueue_styles' ), 10 ); |
| 54 |
} |
| 55 |
} |
| 56 |
} |
| 57 |
|