['post', 'page'], 'checks' => Postlint_Checks::default_enabled(), 'thin_content_words' => 150, 'batch_size' => 100, 'default_image_id' => 0, 'weekly_rescan' => false, ]; } public static function get() { $stored = get_option(POSTLINT_OPTION_SETTINGS, []); return array_merge(self::defaults(), is_array($stored) ? $stored : []); } public static function register() { register_setting('postlint_settings', POSTLINT_OPTION_SETTINGS, [ 'type' => 'array', 'sanitize_callback' => [__CLASS__, 'sanitize'], 'default' => self::defaults(), ]); } public static function sanitize($raw) { $defaults = self::defaults(); $raw = is_array($raw) ? $raw : []; $available_types = get_post_types(['public' => true], 'names'); unset($available_types['attachment']); $types = isset($raw['post_types']) && is_array($raw['post_types']) ? array_values(array_intersect(array_map('strval', $raw['post_types']), $available_types)) : $defaults['post_types']; if (empty($types)) { $types = ['post']; } $checks = isset($raw['checks']) && is_array($raw['checks']) ? array_values(array_intersect(array_map('strval', $raw['checks']), array_keys(Postlint_Checks::all_checks()))) : $defaults['checks']; return [ 'post_types' => $types, 'checks' => $checks, 'thin_content_words' => max(1, min(5000, is_numeric($raw['thin_content_words'] ?? 150) ? (int) $raw['thin_content_words'] : 150)), 'batch_size' => max(10, min(1000, is_numeric($raw['batch_size'] ?? 100) ? (int) $raw['batch_size'] : 100)), 'default_image_id' => max(0, is_numeric($raw['default_image_id'] ?? 0) ? (int) $raw['default_image_id'] : 0), 'weekly_rescan' => !empty($raw['weekly_rescan']), ]; } }