'show-r15', 'type' => 'checkbox', 'default' => 'off' ], [ 'id' => 'show-r18', 'type' => 'checkbox', 'default' => 'off' ], [ 'id' => 'show-r18g', 'type' => 'checkbox', 'default' => 'off' ], [ 'id' => 'show-aigc', 'type' => 'checkbox', 'default' => 'on' ], [ 'id' => 'collapse-pages', 'type' => 'checkbox', 'default' => 'on' ], [ 'id' => 'load-comments', 'type' => 'checkbox', 'default' => 'on' ], [ 'id' => 'load-related', 'type' => 'checkbox', 'default' => 'on' ], [ 'id' => 'theme', 'type' => 'dropdown', 'options' => ['light', 'dark'], 'default' => 'dark' ], [ 'id' => 'timezone', 'type' => 'dropdown', 'options' => timezone_identifiers_list(), 'default' => 'Asia/Tokyo' ], [ 'id' => 'language', 'type' => 'dropdown', 'options' => ['en', 'zh'], 'default' => 'en' ] ]; $settings = []; function load_settings($original) { global $settings, $settings_entries; foreach ($settings_entries as $entry) { if (!isset($original[$entry['id']])) { $settings[$entry['id']] = $entry['default']; } else switch ($entry['type']) { case 'checkbox': $settings[$entry['id']] = ($original[$entry['id']] == 'on') ? 'on': 'off'; break; case 'dropdown': $settings[$entry['id']] = in_array($original[$entry['id']], $entry['options']) ? $original[$entry['id']] : $entry['default']; break; } } }