registerService(IConfig::class, function($c) { return $c->get(IConfig::class); }); $context->registerEventListener( TemplateResponse::EVENT_LOAD_ADDITIONAL_SCRIPTS, LoadStylesListener::class ); } public function boot(IBootContext $context): void { } } class LoadStylesListener { private IConfig $config; public function __construct(IConfig $config) { $this->config = $config; } public function __invoke(): void { $value = $this->config->getAppValue('minimalprofile', 'hidden_fields', ''); $hidden = ($value !== '') ? json_decode($value, true) ?? [] : []; if (empty($hidden)) { return; } $selectors = [ 'pronouns' => '#account-property-pronouns', 'role' => '#account-property-role', 'headline' => '#account-property-headline', 'biography' => '#account-property-biography', 'organisation' => '#account-property-organisation', 'phone' => '#account-property-phone', 'address' => '#account-property-address', 'birthdate' => '#account-property-birthdate', 'website' => '#account-property-website', 'twitter' => '#account-property-twitter', 'fediverse' => '#account-property-fediverse', 'location' => '#account-property-location', ]; $css = ''; foreach ($hidden as $field) { if (isset($selectors[$field])) { $css .= '.personal-settings-setting-box:has(' . $selectors[$field] . ') { display: none !important; }' . "\n"; } } if ($css) { Util::addInlineStyle($css); } } }