PluginProbe
Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution / 1.4.0
Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution v1.4.0
2.0.1 trunk 1.0.0 1.1.0 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.5.0 1.6.0 1.6.1 1.7.0 1.7.1 1.8.0 1.9.0 2.0.0
solid-performance / src / Performance / Notices / Provider.php

Provider.php in Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution 1.4.0, at src/Performance/Notices/Provider.php

57 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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