plugin = $plugin; } /** * Registers the module's WordPress hooks. Runs on `plugins_loaded`. */ abstract public function register(): void; /** * Default values for this module's settings section (keyed by module ID). * * @return array */ public static function default_settings(): array { return array(); } /** * Sanitizes this module's settings section. * * @param array $values Merged section values. * @param array $defaults Section defaults. * @return array */ public static function sanitize_settings( array $values, array $defaults ): array { return array_intersect_key( $values, $defaults ); } /** * Reads one of this module's settings. * * @param string $id Module ID (section name). * @param string $key Setting key inside the section. * @param mixed $default_value Returned when missing. * @return mixed */ protected function setting( string $id, string $key, $default_value = null ) { return $this->plugin->options()->get( $id . '.' . $key, $default_value ); } }