# solid-performance/1.1.0/src/Performance/Admin/Provider.php

Solid Performance – Your No-Code Caching, Performance, &amp; Page Speed Solution, version 1.1.0. 109 lines.

- Page: https://pluginprobe.com/plugins/solid-performance/1.1.0/code/src/Performance/Admin/Provider.php
- Raw: https://pluginprobe.com/plugins/solid-performance/1.1.0/raw/src/Performance/Admin/Provider.php
- Modified: 2024-09-03T15:51:20+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/solid-performance/1.1.0/code/src/Performance/Admin/Provider.php#L10-L20`.

```php
<?php
/**
 * The provider hooking Admin class methods to WordPress events.
 *
 * @since 0.1.0
 *
 * @package SolidWP\Performance
 */

namespace SolidWP\Performance\Admin;

use SolidWP\Performance\Contracts\Service_Provider;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * The provider for all Admin related functionality.
 *
 * @since 0.1.0
 *
 * @package SolidWP\Performance
 */
class Provider extends Service_Provider {

	/**
	 * {@inheritdoc}
	 */
	public function register(): void {
		$this->container->singleton( Settings_Page::class, Settings_Page::class );

		add_filter( 'admin_bar_menu', $this->container->callback( Admin_Bar::class, 'add_purge_admin_bar_link' ), 100 );
		add_filter( 'init', $this->container->callback( Purge_Listener::class, 'purge_page_cache' ) );
		add_filter( 'init', $this->container->callback( Purge_Listener::class, 'purge_single_page_cache' ) );
		add_filter( 'admin_menu', $this->container->callback( Settings_Page::class, 'add_settings_page' ), 100 );
		add_action( 'admin_init', $this->container->callback( Settings_Page::class, 'register_settings' ) );
		add_action( 'rest_api_init', $this->container->callback( Settings_Page::class, 'register_settings' ) );
		add_action( 'plugin_action_links_' . plugin_basename( SWPSP_PLUGIN_FILE ), $this->container->callback( Settings_Page::class, 'settings_link' ), 10 );
		add_filter( 'init', $this->container->callback( Post_Cache_Exclusion::class, 'register_meta' ), 20 );
		add_action( 'admin_init', $this->container->callback( Post_Cache_Exclusion::class, 'register_meta_script' ) );
		add_action( 'admin_init', $this->container->callback( Post_Cache_Exclusion::class, 'load_classic' ) );
		add_action( 'enqueue_block_editor_assets', $this->container->callback( Post_Cache_Exclusion::class, 'script_enqueue' ) );

		$this->register_option_purger();
	}

	/**
	 * Configure the Option Purger with the different WP option names can trigger a cache flush.
	 *
	 * @return void
	 */
	private function register_option_purger(): void {
		$this->container->singleton( Option_Purger::class, Option_Purger::class );
		$this->container->when( Option_Purger::class )
						->needs( '$option_names' )
						->give(
							// Different WP option names that will force a cache flush.
							static fn(): array => array_fill_keys(
								[
									// options-general.php.
									'blogname',
									'blogdescription',
									'site_icon',
									'WPLANG',
									'timezone_string',
									'gmt_offset',
									'date_format',
									'time_format',
									'start_of_week',

									// options-reading.php.
									'page_for_posts',
									'page_on_front',
									'posts_per_page',
									'blog_public',

									// options-discussion.php.
									'require_name_email',
									'comment_registration',
									'close_comments_for_old_posts',
									'show_comments_cookies_opt_in',
									'thread_comments',
									'thread_comments_depth',
									'page_comments',
									'comments_per_page',
									'default_comments_page',
									'comment_order',
									'show_avatars',
									'avatar_rating',
									'avatar_default',

									// options-permalink.php.
									'permalink_structure',
									'category_base',
									'tag_base',

									// Appearance: themes.php.
									'template',
									'stylesheet',
								],
								true
							)
						);

		add_action( 'updated_option', $this->container->callback( Option_Purger::class, 'collect' ), 10, 3 );
	}
}

```
