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 ); } }